void DSelector_kpkm::Init(TTree *locTree) { // USERS: IN THIS FUNCTION, ONLY MODIFY SECTIONS WITH A "USER" OR "EXAMPLE" LABEL. LEAVE THE REST ALONE. // The Init() function is called when the selector needs to initialize a new tree or chain. // Typically here the branch addresses and branch pointers of the tree will be set. // Init() will be called many times when running on PROOF (once per file to be processed). //USERS: SET OUTPUT FILE NAME //can be overriden by user in PROOF dOutputFileName = "kpkm.root"; //"" for none dOutputTreeFileName = "tree_kpkm.root"; //"" for none dFlatTreeFileName = "flat_tree_kpkm.root"; //output flat tree (one combo per tree entry), "" for none dFlatTreeName = "kpkm_Tree"; //if blank, default name will be chosen //Because this function gets called for each TTree in the TChain, we must be careful: //We need to re-initialize the tree interface & branch wrappers, but don't want to recreate histograms bool locInitializedPriorFlag = dInitializedFlag; //save whether have been initialized previously DSelector::Init(locTree); //This must be called to initialize wrappers for each new TTree //gDirectory now points to the output file with name dOutputFileName (if any) if(locInitializedPriorFlag) return; //have already created histograms, etc. below: exit Get_ComboWrappers(); dPreviousRunNumber = 0; /*********************************** EXAMPLE USER INITIALIZATION: ANALYSIS ACTIONS **********************************/ // Define particles of interest for histogramming std::deque<Particle_t> MyPhi; MyPhi.push_back(KPlus); MyPhi.push_back(KMinus); std::deque<Particle_t> MyLambda; MyLambda.push_back(KMinus); MyLambda.push_back(Proton); // Set up default cut parameters dSlope = 1.0; dYint = 0.0; // Read in parameters from configuration file TEnv *env = new TEnv(dOption); std::cout << "dOption: " << dOption << std::endl; if (!dOption) std::cout << "No configuration file provided for TEnv" << std::endl; else { dSlope = env->GetValue("dSlope", dSlope); dYint = env->GetValue("dYint", dYint); env->PrintEnv(); } //ANALYSIS ACTIONS: //Executed in order if added to dAnalysisActions //false/true below: use measured/kinfit data // Initial histograms dAnalysisActions.push_back(new DHistogramAction_ParticleID(dComboWrapper, false, "Pre-cuts")); dAnalysisActions.push_back(new DHistogramAction_ParticleComboKinematics(dComboWrapper, false, "Pre-cuts")); dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyPhi, 1000, 0.9, 2.4, "Phi_pre-cut")); dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyLambda, 1000, 1.0, 3.0, "Lambda_pre-cut")); dAnalysisActions.push_back(new DHistogramAction_MissingMassSquared(dComboWrapper, false, 1000, -0.1, 0.1, "Pre-cuts")); dAnalysisActions.push_back(new DHistogramAction_KinFitResults(dComboWrapper, "Pre-cuts")); // Cut on missing mass squared and histogram the invariant mass dAnalysisActions.push_back(new DCutAction_MissingMassSquared(dComboWrapper, false, -0.02, 0.02)); dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyPhi, 1000, 0.9, 2.4, "Phi_MM2-cut")); dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyLambda, 1000, 1.0, 3.0, "Lambda_MM2-cut")); // Cut on dEdx and histogram the invariant mass dAnalysisActions.push_back(new DCutAction_dEdx(dComboWrapper, false, Proton, SYS_CDC, "dEdx-meas")); dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyPhi, 1000, 0.9, 2.4, "Phi_dEdx-cut")); dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyLambda, 1000, 1.0, 3.0, "Lambda_dEdx-cut")); // Cut on the PID delta t and histogram the invariant mass dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.0, Proton, SYS_TOF, "p_TOF")); dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.0, Proton, SYS_BCAL, "p_BCAL")); dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 2.0, Proton, SYS_FCAL, "p_FCAL")); dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.4, KPlus, SYS_TOF, "Kp_TOF")); dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.5, KPlus, SYS_BCAL, "Kp_BCAL")); dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.0, KPlus, SYS_FCAL, "Kp_FCAL")); dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.4, KMinus, SYS_TOF, "Km_TOF")); dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.5, KMinus, SYS_BCAL, "Km_BCAL")); dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 1.0, KMinus, SYS_FCAL, "Km_FCAL")); dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyPhi, 1000, 0.9, 2.4, "Phi_PID-cuts")); dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyLambda, 1000, 1.0, 3.0, "Lambda_PID-cuts")); // Histograms dAnalysisActions.push_back(new DHistogramAction_BeamEnergy(dComboWrapper, false)); dAnalysisActions.push_back(new DHistogramAction_ParticleComboKinematics(dComboWrapper, false, "Post_timing")); dAnalysisActions.push_back(new DHistogramAction_ParticleID(dComboWrapper, false, "Post_timing")); // Chisq comparison cut and histogram the invariant mass TF1 *f1 = new TF1("f1", "pol1", 0, 1000); f1->SetParameter(0, dYint); f1->SetParameter(1, dSlope); dAnalysisActions.push_back(new DCutAction_ChiSqOrCL(dComboWrapper, "pippim", true, f1, "Post_timing")); dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyPhi, 1000, 0.9, 2.4, "Phi_chisq-cut")); dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyLambda, 1000, 1.0, 3.0, "Lambda_chisq-cut")); // Histograms dAnalysisActions.push_back(new DHistogramAction_KinFitResults(dComboWrapper,"Post_chisq-cut")); dAnalysisActions.push_back(new DHistogramAction_ParticleComboKinematics(dComboWrapper, false, "Post_chisq-cut")); // Cut on Chisq or confidence level after performing comparison cut. Histogram the invariant mass dAnalysisActions.push_back(new DCutAction_KinFitFOM(dComboWrapper, 1E-10)); dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyPhi, 1000, 0.9, 2.4, "Phi_CL-cut")); dAnalysisActions.push_back(new DHistogramAction_InvariantMass(dComboWrapper, false, 0, MyLambda, 1000, 1.0, 3.0, "Lambda_CL-cut")); //below: value: +/- N ns, Unknown: All PIDs, SYS_NULL: all timing systems //dAnalysisActions.push_back(new DCutAction_PIDDeltaT(dComboWrapper, false, 0.5, KPlus, SYS_BCAL)); //INITIALIZE ACTIONS //If you create any actions that you want to run manually (i.e. don't add to dAnalysisActions), be sure to initialize them here as well Initialize_Actions(); /******************************** EXAMPLE USER INITIALIZATION: STAND-ALONE HISTOGRAMS *******************************/ //EXAMPLE MANUAL HISTOGRAMS: dHist_MissingMassSquared = new TH1I("MissingMassSquared", ";Missing Mass Squared (GeV/c^{2})^{2}", 600, -0.06, 0.06); dHist_BeamEnergy = new TH1I("BeamEnergy", ";Beam Energy (GeV)", 600, 0.0, 12.0); /************************** EXAMPLE USER INITIALIZATION: CUSTOM OUTPUT BRANCHES - MAIN TREE *************************/ //EXAMPLE MAIN TREE CUSTOM BRANCHES (OUTPUT ROOT FILE NAME MUST FIRST BE GIVEN!!!! (ABOVE: TOP)): //The type for the branch must be included in the brackets //1st function argument is the name of the branch //2nd function argument is the name of the branch that contains the size of the array (for fundamentals only) /* dTreeInterface->Create_Branch_Fundamental<Int_t>("my_int"); //fundamental = char, int, float, double, etc. dTreeInterface->Create_Branch_FundamentalArray<Int_t>("my_int_array", "my_int"); dTreeInterface->Create_Branch_FundamentalArray<Float_t>("my_combo_array", "NumCombos"); dTreeInterface->Create_Branch_NoSplitTObject<TLorentzVector>("my_p4"); dTreeInterface->Create_Branch_ClonesArray<TLorentzVector>("my_p4_array"); */ /************************** EXAMPLE USER INITIALIZATION: CUSTOM OUTPUT BRANCHES - FLAT TREE *************************/ //EXAMPLE FLAT TREE CUSTOM BRANCHES (OUTPUT ROOT FILE NAME MUST FIRST BE GIVEN!!!! (ABOVE: TOP)): //The type for the branch must be included in the brackets //1st function argument is the name of the branch //2nd function argument is the name of the branch that contains the size of the array (for fundamentals only) /* dFlatTreeInterface->Create_Branch_Fundamental<Int_t>("flat_my_int"); //fundamental = char, int, float, double, etc. dFlatTreeInterface->Create_Branch_FundamentalArray<Int_t>("flat_my_int_array", "flat_my_int"); dFlatTreeInterface->Create_Branch_NoSplitTObject<TLorentzVector>("flat_my_p4"); dFlatTreeInterface->Create_Branch_ClonesArray<TLorentzVector>("flat_my_p4_array"); */ /************************************* ADVANCED EXAMPLE: CHOOSE BRANCHES TO READ ************************************/ //TO SAVE PROCESSING TIME //If you know you don't need all of the branches/data, but just a subset of it, you can speed things up //By default, for each event, the data is retrieved for all branches //If you know you only need data for some branches, you can skip grabbing data from the branches you don't need //Do this by doing something similar to the commented code below //dTreeInterface->Clear_GetEntryBranches(); //now get none //dTreeInterface->Register_GetEntryBranch("Proton__P4"); //manually set the branches you want }