////////////////////////////////////////////////////////// // versione con 4 ADC e "filename" anziche' "run_number" ////////////////////////////////////////////////////////// // #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "TH2F.h" #include "TCanvas.h" #include "TPad.h" #include #include //#include //serve per basename #include // serve per stringstream #include #include "Riostream.h" char month[200]; using namespace std; ////////// these values depend o the environment and must be changed by hand /////////////// string DirDat = "Coincidenze/run0611/"; string DirRoot = "/nfs/"; //////////////////////////////////////////////////////////////////////////////////////////// struct event { int adc; Long64_t time; Double_t energy; }; bool SortByTime(const event &lhs, const event &rhs) { return lhs.time < rhs.time; } //int main(int argc, char *argv[]) { void maketree() { //if(argc<2){ //cout<data; string FileDat = DirDat + FileName+".dat"; string FileSort = DirDat + FileName+".sort"; string FileCoinc = DirDat + FileName+".coinc"; string FileRoot = DirRoot + FileName+".ruut"; cout << endl; cout << "File Name: " << FileName << endl; cout << "Merged File: " << FileDat << endl; cout << "ROOT File: " << FileRoot << endl; cout << "coinc. time (ns): " << tau << endl; cout << "Mult. thresh. (keV): " << Ethr << endl; cout << endl; cout << "Merging ADC files..." << endl; cout << endl; cout << "Be patient: I'm working.." << endl; cout << endl; const int Nadc = 4; /////////////////////////////////////////////////////////////////////// ////////////////////////// MERGING AND SORTING //////////////////////// /////////////////////////////////////////////////////////////////////// string file; int adc, diagnostic; Long64_t TimeStamp; Double_t ch; ofstream out(FileDat.c_str()); char *id = new char[10]; long int NEvents = 0; Long64_t nanoseconds; double delay[Nadc]; if ((strcmp(month, "JuneOctober22") == 0) ) delay[Nadc] = {0, 4.0720e4, 0, 4.0720e4}; // June2022 and October2022 delay else if ((strcmp(month, "February23") == 0)) delay[Nadc] = {0, 4.0270e4, 0, 4.0270e4}; //February 2023 delay event DummyEvent; for (int j=0; j> TimeStamp >> ch >> diagnostic; adc = j; if (!in.good()) break; if(diagnostic == 0 && ch != 0) { NEvents++; // nanoseconds = TimeStamp*10; nanoseconds = TimeStamp*10+delay[j]; DummyEvent.adc = adc; DummyEvent.time = nanoseconds; DummyEvent.energy = ch; data.push_back(DummyEvent); out< (FileSort.c_str(), "\n")); ofstream output (FileSort.c_str()); for (unsigned int i=0; i> id1 >> time1 >> ch1; nevents++; if (nevents%parz==0) cout << (int)(nevents*1e2/Nlines) << "% events processed.." << endl; while(nevents <= Nlines) { time[id1] = time1; energy[id1] = ch1; multiplicity = 1; coinc = 1; while (coinc == 1 && nevents<=Nlines) { input >> id2 >> time2 >> ch2; nevents++; if (nevents%parz==0) cout << (int)(nevents*1e2/Nlines) << "% events processed.." << endl; //if (id2 != id1 && time2-time1 < tau) { if (id2 != id1 && time2-time1 < tau && ch1*ch2 > 0) { multiplicity++; coinc = 1; time[id2] = time2; energy[id2] = ch2; } else { coinc = 0; } } for(int j=0; jBranch(id_t, &tempo[j]); tree->Branch(id_ch, &chan[j]); } tree->Branch("mult",&mult); int counter = 0; ifstream z(FileCoinc.c_str()); if(!z) {cout <<"Error: "<> tempo[j] >> chan[j]; } in >> mult; nl = nl + 1; if (nl%fraz==0) cout << (int)(nl*1e2/counter) << "% events processed.." << endl; tree->Fill(); } nl = nl -1; in.close(); f->Write(); cout << endl; cout <<"ROOT file "<