#define omega2pi_selector_cxx // The class definition in omega2pi_selector.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("omega2pi_selector.C") // Root > T->Process("omega2pi_selector.C","some options") // Root > T->Process("omega2pi_selector.C+") // #include "omega2pi_selector.h" #include #include void omega2pi_selector::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). nSignal=0; user_BdtCut = -999.; TString option = GetOption(); FriendOutput = option.Contains("Signal"); FriendOutputBackground = option.Contains("Background"); bggenData = option.Contains("bggenData"); EvalTMVA = option.Contains("EvalTMVA"); if(EvalTMVA) { Int_t firstEqual = option.First("="); user_BdtCut = atof(option(firstEqual+1,4).Data()); } if(EvalTMVA) { //only used after BDT training completed // setup for TMVA evaluation tmvaReader = new TMVA::Reader( "!Color:!Silent" ); // 3pi PID variables tmvaReader->AddVariable("PiPlus1__timingFOM := (PiPlus1__ChiSq_Timing_KinFit==PiPlus1__ChiSq_Timing_KinFit) ? TMath::Prob(PiPlus1__ChiSq_Timing_KinFit,PiPlus1__NDF_Timing) : 0.",&PiPlus1__Timing_FOM); tmvaReader->AddVariable("PiPlus1__DCdEdx_FOM := TMath::Prob(PiPlus1__ChiSq_DCdEdx,PiPlus1__NDF_DCdEdx)",&PiPlus1__DCdEdx_FOM); tmvaReader->AddVariable("PiPlus1__NDF_Tracking",&PiPlus1__NDF_Tracking_Alt); tmvaReader->AddVariable("PiPlus2__Timing_FOM := (PiPlus2__ChiSq_Timing_KinFit==PiPlus2__ChiSq_Timing_KinFit) ? TMath::Prob(PiPlus2__ChiSq_Timing_KinFit,PiPlus2__NDF_Timing) : 0.",&PiPlus2__Timing_FOM); tmvaReader->AddVariable("PiPlus2__DCdEdx_FOM := TMath::Prob(PiPlus2__ChiSq_DCdEdx,PiPlus2__NDF_DCdEdx)",&PiPlus2__DCdEdx_FOM); tmvaReader->AddVariable("PiPlus2__NDF_Tracking",&PiPlus2__NDF_Tracking_Alt); tmvaReader->AddVariable("PiMinus__Timing_FOM := (PiMinus__ChiSq_Timing_KinFit==PiMinus__ChiSq_Timing_KinFit) ? TMath::Prob(PiMinus__ChiSq_Timing_KinFit,PiMinus__NDF_Timing) : 0.",&PiMinus__Timing_FOM); tmvaReader->AddVariable("PiMinus__DCdEdx_FOM := TMath::Prob(PiMinus__ChiSq_DCdEdx,PiMinus__NDF_DCdEdx)",&PiMinus__DCdEdx_FOM); tmvaReader->AddVariable("PiMinus__NDF_Tracking",&PiMinus__NDF_Tracking_Alt); // Computed variables (friend tree) tmvaReader->AddVariable("Unused__Max_Proton_FOM",&Unused__Max_Proton_FOM); tmvaReader->AddVariable("Unused__Max_KPlus_FOM",&Unused__Max_KPlus_FOM); tmvaReader->AddVariable("Unused__Max_KMinus_FOM" ,&Unused__Max_KMinus_FOM); // book the MVA methods TString methodName = "BDT method"; TString weightFile = "weights/n3pi_BDT.weights.xml"; tmvaReader->BookMVA( methodName, weightFile ); } } void omega2pi_selector::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). TString option = GetOption(); } Bool_t omega2pi_selector::Process(Long64_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 omega2pi_selector::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. // // The processing can be stopped by calling Abort(). // // Use fStatus to set the return value of TTree::Process(). // // The return value is currently not used. GetEntry(entry); if(entry==0) cout<<"--- Processing: "<GetTree()->GetEntries()<<" total combos"< 5) { //Int_t Thrown__ParentID[NumThrownMax]; //[NumThrown] //Int_t Thrown__PID[NumThrownMax]; //[NumThrown] //Int_t Thrown__MatchID[NumThrownMax]; cout << "Index = " << i <<" Thrown PID = " << Thrown__PID[i] << " Thrown Parent ID = " << Thrown__ParentID[i] < 5) { // select highest CL for proton and kaon hypothesis Float_t PID_FOM = TMath::Prob(Unused__ChiSq_DCdEdx[i]+Unused__ChiSq_Timing[i],Unused__NDF_DCdEdx[i]+Unused__NDF_Timing[i]); if(Unused__PID[i] == 321 && PID_FOM > Unused__Max_KPlus_FOM) Unused__Max_KPlus_FOM=PID_FOM; if(Unused__PID[i] == -321 && PID_FOM > Unused__Max_KMinus_FOM) Unused__Max_KMinus_FOM=PID_FOM; } } // construct measured missing mass TLorentzVector measuredMissingP4(0,0,BeamPhoton__P4_Measured->Energy(),BeamPhoton__P4_Measured->Energy()+0.938); Measured__MissingMass = measuredMissingP4.M(); measuredMissingP4 = measuredMissingP4 - *Proton__P4_Measured - *PiPlus1__P4_Measured - *PiPlus2__P4_Measured - *PiMinus1__P4_Measured - *PiMinus2__P4_Measured - *Photon1__P4_Measured - *Photon2__P4_Measured; Measured__MissingMass = measuredMissingP4.M(); //cout << "Passed calculations" <Fill(); //cout << "Written" << endl; return kTRUE; } void omega2pi_selector::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. } void omega2pi_selector::Terminate() { cout << "Entering Terminate()" << endl; if(FriendOutput || FriendOutputBackground){ //cout<<"found "<Write(); outFile->Close(); } // 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. }