#include "TComplex.h" #include "TCanvas.h" #include "TPad.h" #include "TH1.h" #include "TF1.h" #include "TGraph.h" #include "TStyle.h" #include "TVirtualFitter.h" #include "TDatime.h" #include "TTree.h" #include "TFile.h" #include "Riostream.h" using namespace std; void Readdat(){ //--------------------------------------------------------------------- //---------------------Readdata from .txt: //--------------------------------------------------------------------- ifstream in_x,f; f.open("Envrconv_05112006_SAVE2.txt"); string line; Int_t nlines=0; while(f.eof()==false && getline(f,line,'\n')) { // getline(f,line,'\n'); // cout << line << endl; nlines++; } f.close(); cout << "Number of lines: "<< nlines << endl; Int_t ELMB,channel,year,month,day,hours,min; Double_t sec,totalsec,val; char t; Int_t minsec=0; Int_t hourssec=0; Int_t minhoursec=0; Int_t lines=0; in_x.open("Envrconv_05112006_SAVE2.txt"); TArrayD *ELMBarr = new TArrayD(nlines); TArrayD *Chan = new TArrayD(nlines); TArrayD *time = new TArrayD(nlines); TArrayD *temp = new TArrayD(nlines); while (in_x.eof()==false && in_x >> ELMB >> channel >> year >> t >> month >> t >> day >> hours >> t >> min >> t >>sec >>val) { if (!in_x.good()) cout<< "Can't read file" << endl; hourssec = (hours* 60.0* 60.0); minsec = (min* 60.0); minhoursec = (hourssec + minsec); totalsec = (minhoursec + sec); ELMBarr->AddAt(ELMB,lines); Chan->AddAt(channel,lines); time->AddAt(totalsec,lines); temp->AddAt(val,lines); lines++; } in_x.close(); //--------------------------------------------------------------------- //---------------------Read Mappingfile: //--------------------------------------------------------------------- ifstream m,in_m; m.open("Mapping.txt"); int mlines = 0; string ELMBmaps; string ELMBChs; string Disk; string Type; string Side; string Quadrant; string Num; string identifier; vector Identivec; while(m.eof()==false && m >> ELMBmaps >> ELMBChs >> Disk >> Type >> Side >> Quadrant >> Num) { identifier ="ELMB_"+ELMBmaps + "_Ch" + ELMBChs + "_D" + Disk +"_" + Type + "_" +Side +"_" + Quadrant + "_Num:" + Num; Identivec.push_back(identifier); mlines++; } m.close(); cout << "Number of mlines: "<< mlines << endl; /* for(int k=0;k> ELMBmap >> ELMBCh >> Disk >> Type >> Side >> Quadrant >> Num) { ELMBmaparr->AddAt(ELMBmap,count); ELMBCha->AddAt(ELMBCh,count); count++; } in_m.close(); //--------------------------------------------------------------------- //---------------------stopppoints to divide data per channel //---------------------------------------------------------------------- TArrayD *stoparr = new TArrayD(mlines); TArrayD *Chanstop = new TArrayD(mlines); TArrayD *ELMBstop = new TArrayD(mlines); Int_t p=1; stoparr->At(0)==0; for(int i=0; iAt(i)!= Chan->At(i+1)){ stoparr -> AddAt(i,p); Chanstop -> AddAt(Chan->At(i),p); ELMBstop -> AddAt(ELMBarr->At(i),p); // cout << " p: " << p << " stoparr: " << stoparr->At(p) <At(p) << " ELMBstop: " << ELMBstop->At(p) <At(i)== ELMBmaparr->At(j) && Chanstop->At(i)==ELMBCha->At(j)){ idselectarr ->AddAt(j,id); id++; } } } //for(int s=0; sAt(s) <At(s)]<Branch("tlines",&tlines, "tlines/I"); t1->Branch("tELMB",&tELMB,"tELMB/D"); t1->Branch("tchannel",&tchannel,"tchannel/D"); t1->Branch("ttsec",&ttsec,"ttsec/D"); t1->Branch("tval",&tval,"tval/D"); for(Int_t i=0; iAt(i); tchannel = Chan->At(i); ttsec = time->At(i); tval = temp->At(i); tlines = i; t1->Fill(); } // t1->Print(); g.cd(); t1->Write(); //-----------------------Tree for seperating channels--------------------------// Int_t tstop,nstops; TFile fg("treefg.root","recreate"); TTree *tfg = new TTree("tfg","Idtree"); tfg->Branch("tstop",&tstop,"tstop/I"); tfg->Branch("nstops",&nstops,"nstops/I"); for(Int_t i=0; iAt(i); nstops = i; tfg->Fill(); } fg.cd(); tfg->Write(); //-----------------------Tree for identifier--------------------------// vector *tidentivec = new vector; TFile fi("identi.root","recreate"); TTree *Treeidenti = new TTree("Treeidenti","Vectortree"); Treeidenti->Branch("tidentivec","vector",&tidentivec); for(Int_t i=0; ipush_back(Identivec[idselectarr->At(i)]); Treeidenti->Fill(); } fi.cd(); Treeidenti->Write(); }