#include #include "TString.h" #include "TFile.h" #include "TError.h" #include "TTree.h" #include #include #include "../dataClasses/RawEvent.h" #include "../dataClasses/AEvent.h" int main(int argc, char* argv[]) { //to be extracted from the source as parameters const Int_t noBranches = 4; const Double_t cfRatio = 0.3; const Double_t cfTD = 1.5; //in ns Double_t noiseMin = 5; Double_t noiseMax = 25; Int_t nump = 5; //number of points for smoothing if ( (argc < 3) || (argc > 5) ) { // Tell the user how to run the program std::cerr << "Usage: " << argv[0] << " [list with input files] [outputfile] [smoothParameter (1 - smoothed, 0 - not)] [number of points in one event (1000 or 1024)]" << std::endl; /* "Usage messages" are a conventional way of telling the user * how to run a program if they enter the command incorrectly. */ return 1; } TString infiles = argv[1]; TString ofile = argv[2]; TString smooth = argv[3]; TString Asize = argv[4]; Int_t kEventSize,intSmoth; Bool_t smoothPar = kFALSE; if(argc==3) { kEventSize = 1024; noiseMin = 10.; noiseMax = 100.; Info("convertRawToAnalyzed", "Event size was set to %d", kEventSize); } if(argc>3) { intSmoth = smooth.Atoi(); if((intSmoth!=1) && (intSmoth!=0)) { std::cerr<< argv[3] << " smoothpar should be 1 or 0 " << std::endl; return 1; } if( intSmoth == 1 ) { smoothPar = kTRUE; Info("convertRawToAnalyzed", "we gona SMOOTH"); } else {Info("convertRawToAnalyzed", "we NOT gonna SMOOTH");} } if(argc==5) { kEventSize = Asize.Atoi(); if((kEventSize!=1000) && ((kEventSize!=1024))) { std::cerr<< argv[0] << " the size of Events should be 1000 or 1024 " << std::endl; return 1; } } TFile *f = new TFile(infiles.Data()); if (/*f == 0 || */f->IsZombie()) { Error("convertRawToAnalyzed", "Input file was not opened. Program will be terminated"); return 1; } TTree *tr = (TTree*)f->Get("rtree"); TString bName; RawEvent *revent[noBranches]; for (Int_t j = 0; jSetBranchAddress(bName.Data(), &revent[j]); } TFile *fw = new TFile(ofile.Data(), "RECREATE"); //create .root file with somehow analyzed data TTree *tw = new TTree("atree", "title of drs4 analysis tree"); //create analysis tree atree in it AEvent *wevent[noBranches]; // pointer to the array (of AEvent class) in which analyzed data for each channel will be put for (Int_t j = 0; jSetInputEvent(&revent[j]); //takes raw event from RawEvent wevent[j]->SetCFratio(cfRatio); wevent[j]->SetCFtimeDelay(cfTD); wevent[j]->SetNoiseRange(noiseMin, noiseMax); wevent[j]->SetSmoothPoints(nump); tw->Bronch(bName.Data(), "AEvent", &wevent[j]); // create branches in atree to hold analyzed data } //----event loop in tr input tree Long64_t nentries = tr->GetEntries(); for(Long64_t i = 0; i < nentries; i++) { tr->GetEntry(i); //cout<<" Event "<Reset(); wevent[j]->ProcessEvent(smoothPar); //here all the analysis is going on so far } if ( !(i%100) ) { printf("Found event #%lld\n", i); } tw->Fill(); } //----end of event loop printf("%lld events are processed\n", nentries); tw->Write(); fw->Close(); return 0; }