#include #include #include #include #include // ROOT #include #include #include #include #include // GERDA #include #include using namespace std; int waitForEnter(); int main( int argc , char** argv ) { // Help message if ( argc == 2 && strcmp( argv[1] , "--help" ) == 0 ) { cout << endl << "Event browser for tier1 data tree." << endl << endl << "Usage: ./analysis [filelist] [OPTIONS]" << endl << "Options: --help: display this help message and exit" << endl << endl; return 0; } cout << "Reading the input..." << endl; // Retrieve file names vector listOfFiles; ifstream filelist( argv[1] ); string name; while ( filelist >> name ) listOfFiles.push_back(name); // Retrieve tier1 files TChain chain("MGTree"); for ( unsigned int i = 0 ; i < listOfFiles.size()-2 ; i++ ) { chain.Add(listOfFiles.at(i).c_str()); } // Retrieve list file TFile fileWithList( listOfFiles.at(listOfFiles.size()-1).c_str() , "READ" ); TEventList * list = (TEventList*)fileWithList.Get("listofselected")->Clone(); MGTEvent * event = NULL; MGTWaveform * wf = NULL; TH1D * hist = NULL; TApplication app( "app" , &argc , argv ); TCanvas can( "loopCan" , "GERDA tier1" , 7500 , 5500 , 650 , 350 ); can.SetGrid(); can.cd(); // Fundamental: draw something before beginning the loop chain.SetBranchAddress( "event" , &event ); chain.GetEntry(0); wf = event->GetWaveform(0); hist = wf->GimmeHist(); if ( list->Contains(0) ) hist->SetLineColor(kRed); hist->Draw(); cout << endl << "Press \"enter\" for next event," << endl << "\"-\" for previous event," << endl << "\"goto\" to go to a specific event" << endl << "or type \"exit\" to quit: " << endl << endl << "event 0:" << endl; can.ForceUpdate(); int N = chain.GetEntries(); int i = 1; ostringstream convert; string title; while ( 1 == 1 ) { cout << "event " << i << ": "; //cout << flush; hist->SetLineColor(kBlue); chain.GetEntry(i); wf = event->GetWaveform(0); hist = wf->GimmeHist(); hist->SetStats(kFALSE); convert.str(""); convert << i; title = convert.str(); hist->SetTitle( title.c_str() ); if ( list->Contains(i) ) hist->SetLineColor(kRed); can.ForceUpdate(); int choice = waitForEnter(); if ( choice == 1 ) break; if ( choice == 2 && i < N ) i++; if ( choice == 2 && i == N ) continue; if ( choice == 3 && i > 0 ) i--; if ( choice == 3 && i == 0 ) continue; if ( choice == 4 ) { cout << " Go to: "; cin >> i; } } cout << "Close the ROOT session to exit the program"; app.Run(kFALSE); return 0; } int waitForEnter() { string input; getline( cin , input ); if ( input.compare("exit") == 0 ) return 1; if ( input.compare("-") == 0 ) return 3; if ( input.compare("goto") == 0 ) return 4; else return 2; }