#define SelSensitivity_cxx // The class definition in SelSensitivity.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 every time 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("SelSensitivity.C") // root> T->Process("SelSensitivity.C","some options") // root> T->Process("SelSensitivity.C+") // #include "SelSensitivity.h" #include #include SelSensitivity::SelSensitivity(TTree* tr) : fChain(0) { } SelSensitivity :: ~SelSensitivity() { // if(fOutTree) // SafeDelete(fOutTree) ; // if(fFile) // SafeDelete(fFile) ; } void SelSensitivity::Begin(TTree * /*tree*/) { TString option = GetOption(); } void SelSensitivity::SlaveBegin(TTree * /*tree*/) { TParameter *fInSize = dynamic_cast *>(fInput -> FindObject("CURRENT_SIZE_CUT")) ; if(fInSize) fSizeCut = fInSize -> GetVal() ; else { fSizeCut = 0.0 ; Warning("SlaveBegin","No size cut found\nSetting it to 0.0\n") ; } TNamed *nm = dynamic_cast(fInput -> FindObject("CURRENT_TRIGGER_CONF")) ; if(nm) { TString str = TString::Format("status_%s",nm->GetTitle()) ; fTriggerStatus = new TTreeReaderValue(fReader,str.Data()) ; } else { Error("SlaveBegin","No trigger configuration found\n") ; Abort("Can't proceed\n") ; } fSize = new TTreeReaderValue(fReader,"Size") ; TList *listofcuts = dynamic_cast (fInput -> FindObject("CutsList")) ; if(listofcuts) { fNcuts = listofcuts -> GetSize() ; mcuts = new MCuts*[fNcuts] ; fNvars = 0 ; TIter next1(listofcuts) ; Int_t i = 0 ; MCuts *mcut ; while ( (mcut = (MCuts*)next1()) ) { mcuts[i] = mcut ; ++i ; ++fNvars ; if(!((mcut -> GetIndVar()).EqualTo("-"))) ++fNvars ; } fParameters = new TTreeReaderValue*[fNvars] ; TIter next2(listofcuts) ; i = 0 ; while (( mcut = (MCuts*)next2() )) { fParameters[i] = new TTreeReaderValue(fReader,(mcut -> GetParamName()).Data()) ; ++i ; if(!((mcut -> GetIndVar()).EqualTo("-"))) { fParameters[i] = new TTreeReaderValue(fReader,(mcut -> GetIndVar()).Data()) ; ++i ; } } } else { Error("SlaveBegin","No cuts list found\n") ; Abort("Can't proceed without cuts list\n") ; } hist = new TH1F("TestHist","",30,1.0,4.0) ; fOutput -> Add(hist) ; } Bool_t SelSensitivity::Process(Long64_t entry) { // if(!fOutTree) // return kTRUE ; fReader.SetLocalEntry(entry); Bool_t cutresult = ( (**fSize >= fSizeCut) && ( **fTriggerStatus == 1) ) ; for ( Int_t i = 0, j = 0 ; i < fNcuts && j < fNvars ; ++i ) { if((mcuts[i] -> GetIndVar()).EqualTo("-")) { cutresult = cutresult && (mcuts[i] -> ApplyCut(*(fParameters[j] -> Get()),0.0)) ; ++i ; ++j ; } else { cutresult = cutresult && (mcuts[i] -> ApplyCut(*(fParameters[j] -> Get()), *( fParameters[j+1] -> Get() ) )) ; ++i ; j += 2 ; } } if(cutresult) hist -> Fill(log10(*fEnergy)) ; return kTRUE ; } void SelSensitivity::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. TParameter *dummy_sens = new TParameter ("SENSITIVITY_ITERATION",1.0) ; fOutput -> Add(dummy_sens) ; } void SelSensitivity::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. hist -> Draw("histe1") ; }