#define EventSelector_cxx // The class definition in EventSelector.h has been generated automatically // by the ROOT utility TTree::MakeSelector(). This class is derived // from the ROOT class TSelector. For more information on the TSelector // framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual. // The following methods are defined in this file: // Begin(): called everytime a loop on the tree starts, // a convenient place to create your histograms. // SlaveBegin(): called after Begin(), when on PROOF called only on the // slave servers. // Process(): called for each event, in this function you decide what // to read and fill your histograms. // SlaveTerminate: called at the end of the loop on the tree, when on PROOF // called only on the slave servers. // Terminate(): called at the end of the loop on the tree, // a convenient place to draw/fit your histograms. // // To use this file, try the following session on your Tree T: // // Root > T->Process("EventSelector.C") // Root > T->Process("EventSelector.C","some options") // Root > T->Process("EventSelector.C+") // #include "EventSelector.h" #include #include void EventSelector::Begin(TTree *tree) { // The Begin() function is called at the start of the query. // When running with PROOF Begin() is only called on the client. // The tree argument is deprecated (on PROOF 0 is passed). // cout << "Entry Begin(TTree *tree)" << endl; timer.Start(); TString option = GetOption(); // cout << "Leaving Begin(TTree *tree)" << endl; } void EventSelector::SlaveBegin(TTree *tree) { // The SlaveBegin() function is called after the Begin() function. // When running with PROOF SlaveBegin() is called on each slave server. // The tree argument is deprecated (on PROOF 0 is passed). // cout << "Entry SlaveBegin(TTree *tree)" << endl; Init(tree); TString option = GetOption(); // cout << "Leaving SlaveBegin(TTree *tree)" << endl; } Bool_t EventSelector::Process(Int_t entry) { // The Process() function is called for each entry in the tree (or possibly // keyed object in the case of PROOF) to be processed. The entry argument // specifies which entry in the currently loaded tree is to be processed. // It can be passed to either TTree::GetEntry() or TBranch::GetEntry() // to read either all or the required parts of the data. When processing // keyed objects with PROOF, the object is already loaded and is available // via the fObject pointer. // // This function should contain the "body" of the analysis. It can contain // simple or elaborate selection criteria, run algorithms on the data // of the event and typically fill histograms. // WARNING when a selector is used with a TChain, you must use // the pointer to the current TTree to call GetEntry(entry). // The entry is always the local entry number in the current tree. // Assuming that fChain is the pointer to the TChain being processed, // use fChain->GetTree()->GetEntry(entry). // cout << "Entry Process(Int_t entry)" << endl; time = timer.CpuTime(); timer.Continue(); b_event_fNtrack->GetEntry(entry); // fChain->GetTree()->GetEntry(entry); nevent = fChain->GetTree()->GetEntries(); // if(entry%300 == 0) printf("Event:%d\n",entry); if(event->GetNtrack() > 587){} else{ nselected++; nb += fChain->GetTree()->GetEvent(entry); if(nselected == 1) { firstevent = event; } } mbytes = fChain->GetTree()->GetTotBytes()*1.e-6; cputime += timer.CpuTime() - time; infoobj = new TInfo(nevent,nselected,nb,mbytes,cputime); // cout << "Leaving Process(Int_t entry)" << endl; return kTRUE; } void EventSelector::SlaveTerminate() { // The SlaveTerminate() function is called after all entries or objects // have been processed. When running with PROOF SlaveTerminate() is called // on each slave server. // cout << "Entry SlaveTerminate()" << endl; // slavetimer->Stop(); fOutput->Add(infoobj); fOutput->Add(firstevent); // cout << "Leaving SlaveTerminate()" << endl; } void EventSelector::Terminate() { // The Terminate() function is the last function to be called during // a query. It always runs on the client, it can be used to present // the results graphically or save the results to file. // cout << "Entry Terminate()" << endl; TList *outList = (TList*)set->GetOutputList(); TIter *next = new TIter(outList); TObject *q = new TObject; Int_t TInfoobjcounter = 0; Int_t firsteventcounter = 0; for(Int_t i=0;i<1000;i++){ q = next(); if(q == 0)break; TString infostring = "TInfo"; TString eventstring = "Event"; if((q->GetName()) == infostring ) { TInfoobjcounter += 1; infoobj = (TInfo*)q; mbytes = infoobj->GetBytes(); nselected += infoobj->GetSelected(); nb += infoobj->Getnb(); nevent = infoobj->GetEvents(); cputime += infoobj->GetTime(); } else if((q->GetName()) == eventstring ) { firsteventcounter += 1; if(firsteventcounter == 1) { q->Dump(); } } else { cout << "object without use" << endl; } } // cout << "TInfoobjcounter: " << TInfoobjcounter << endl; // cout << "firsteventcounter: " << firsteventcounter << endl; timer.Stop(); TFile f("/u/dvgamma/MakeEvent4.0004/Event45000.root"); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime() + cputime; printf("You have selected %d events out of %d\n",nselected,nevent); // printf("file compression factor = %f\n",f.GetCompressionFactor()); printf("RealTime=%f seconds, CpuTime=%f seconds \n",rtime,ctime); printf("You have scanned %f Mbytes/Realtime seconds\n",mbytes/rtime); printf("You have scanned %f Mbytes/Cputime seconds\n",mbytes/ctime); // cout << "Leaving Terminate()" << endl; }