Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:13:24

0001 /// ---------------------------------------------------------------------------
0002 /*! \file   SLambdaJetHunter.sys.h
0003  *  \author Derek Anderson
0004  *  \date   01.25.2024
0005  *
0006  *  A minimal analysis module to find lambda-tagged
0007  *  jets in pythia events.
0008  */
0009 /// ---------------------------------------------------------------------------
0010 
0011 #pragma once
0012 
0013 // make common namespaces implicit
0014 using namespace std;
0015 
0016 
0017 
0018 namespace SColdQcdCorrelatorAnalysis {
0019 
0020   // system methods ===========================================================
0021 
0022   // --------------------------------------------------------------------------
0023   //! Initialize output tree
0024   // --------------------------------------------------------------------------
0025   void SLambdaJetHunter::InitTree() {
0026 
0027     // print debug statement
0028     if (m_config.isDebugOn) {
0029       cout << "SLambdaJetHunter::InitTree() Initializing output tree" << endl;
0030     }
0031 
0032     // set up output tree
0033     //  - TODO move to a dedicated class + interface
0034     m_outTree = new TTree(m_config.outTreeName.data(), "A tree of lambda-tagged jets");
0035     m_outTree -> Branch("EvtNJets",       &m_evtNJets,         "EvtNJets/I");
0036     m_outTree -> Branch("EvtNLambdas",    &m_evtNLambdas,      "EvtNLambdas/I");
0037     m_outTree -> Branch("EvtNTaggedJets", &m_evtNTaggedJets,   "EvtNTaggedJets/I");
0038     m_outTree -> Branch("EvtNChrgPars",   &m_evtNChrgPars,     "EvtNChrgPars/I");
0039     m_outTree -> Branch("EvtNNeuPars",    &m_evtNNeuPars,      "EvtNNeuPars/I");
0040     m_outTree -> Branch("EvtSumEPar",     &m_evtSumEPar,       "EvtSumEPar/D");
0041     m_outTree -> Branch("EvtVtxX",        &m_evtVtxX,          "EvtVtxX/D");
0042     m_outTree -> Branch("EvtVtxY",        &m_evtVtxY,          "EvtVtxY/D");
0043     m_outTree -> Branch("EvtVtxZ",        &m_evtVtxZ,          "EvtVtxZ/D");
0044     m_outTree -> Branch("PartonA_ID",     &m_evtPartID.first,  "PartonA_ID/I");
0045     m_outTree -> Branch("PartonB_ID",     &m_evtPartID.second, "PartonB_ID/I");
0046     m_outTree -> Branch("PartonA_Px",     &m_evtPartPx.first,  "PartonA_Px/D");
0047     m_outTree -> Branch("PartonA_Py",     &m_evtPartPy.first,  "PartonA_Py/D");
0048     m_outTree -> Branch("PartonA_Pz",     &m_evtPartPz.first,  "PartonA_Pz/D");
0049     m_outTree -> Branch("PartonA_E",      &m_evtPartE.first,   "PartonA_E/D");
0050     m_outTree -> Branch("PartonB_Px",     &m_evtPartPx.second, "PartonB_Px/D");
0051     m_outTree -> Branch("PartonB_Py",     &m_evtPartPy.second, "PartonB_Py/D");
0052     m_outTree -> Branch("PartonB_Pz",     &m_evtPartPz.second, "PartonB_Pz/D");
0053     m_outTree -> Branch("PartonB_E",      &m_evtPartE.second,  "PartonB_E/D");
0054     m_outTree -> Branch("LambdaID",       &m_lambdaID);
0055     m_outTree -> Branch("LambdaPID",      &m_lambdaPID);
0056     m_outTree -> Branch("LambdaJetID",    &m_lambdaJetID);
0057     m_outTree -> Branch("LambdaEmbedID",  &m_lambdaEmbedID);
0058     m_outTree -> Branch("LambdaZ",        &m_lambdaZ);
0059     m_outTree -> Branch("LambdaDr",       &m_lambdaDr);
0060     m_outTree -> Branch("LambdaEnergy",   &m_lambdaE);
0061     m_outTree -> Branch("LambdaPt",       &m_lambdaPt);
0062     m_outTree -> Branch("LambdaEta",      &m_lambdaEta);
0063     m_outTree -> Branch("LambdaPhi",      &m_lambdaPhi);
0064     m_outTree -> Branch("JetHasLambda",   &m_jetHasLambda);
0065     m_outTree -> Branch("JetNCst",        &m_jetNCst);
0066     m_outTree -> Branch("JetID",          &m_jetID);
0067     m_outTree -> Branch("JetE",           &m_jetE);
0068     m_outTree -> Branch("JetPt",          &m_jetPt);
0069     m_outTree -> Branch("JetEta",         &m_jetEta);
0070     m_outTree -> Branch("JetPhi",         &m_jetPhi);
0071     m_outTree -> Branch("CstID",          &m_cstID);
0072     m_outTree -> Branch("CstPID",         &m_cstPID);
0073     m_outTree -> Branch("CstJetID",       &m_cstJetID);
0074     m_outTree -> Branch("CstEmbedID",     &m_cstEmbedID);
0075     m_outTree -> Branch("CstZ",           &m_cstZ);
0076     m_outTree -> Branch("CstDr",          &m_cstDr);
0077     m_outTree -> Branch("CstEnergy",      &m_cstE);
0078     m_outTree -> Branch("CstPt",          &m_cstPt);
0079     m_outTree -> Branch("CstEta",         &m_cstEta);
0080     m_outTree -> Branch("CstPhi",         &m_cstPhi);
0081     return;
0082 
0083   }  // end 'InitTree()'
0084 
0085 
0086 
0087   // --------------------------------------------------------------------------
0088   //! Open output file
0089   // --------------------------------------------------------------------------
0090   void SLambdaJetHunter::InitOutput() {
0091 
0092     // print debug statement
0093     if (m_config.isDebugOn) {
0094       cout << "SLambdaJetHunter::InitOuput() Initializing output file" << endl;
0095     }
0096 
0097     m_outFile = new TFile(m_config.outFileName.data(), "recreate");
0098     if (!m_outFile) {
0099       cerr << "PANIC: couldn't open SLambdaJetHunter output file!" << endl;
0100       assert(m_outFile);
0101     }
0102     return;
0103 
0104   }  // end 'InitOutput()'
0105 
0106 
0107 
0108   // --------------------------------------------------------------------------
0109   //! Save output tree and close file
0110   // --------------------------------------------------------------------------
0111   void SLambdaJetHunter::SaveAndCloseOutput() {
0112 
0113     // print debug statement
0114     if (m_config.isDebugOn) {
0115       cout << "SLambdaJetHunter::SaveAndCloseOuput() Saving to output file and closing" << endl;
0116     }
0117 
0118     m_outFile -> cd();
0119     m_outTree -> Write();
0120     m_outFile -> Close();
0121     return;
0122 
0123   }  // end 'SaveAndCloseOutput()'
0124 
0125 
0126 
0127   // --------------------------------------------------------------------------
0128   //! Reset output addresses
0129   // --------------------------------------------------------------------------
0130   /*! TODO move to a dedicated class */
0131   void SLambdaJetHunter::ResetOutput() {
0132 
0133     // print debug statement
0134     if (m_config.isDebugOn) {
0135       cout << "SLambdaJetHunter::ResetOuput() Resetting output containers" << endl;
0136     }
0137 
0138     // reset output variables
0139     m_genEvtInfo.Reset();
0140     m_lambdaInfo.clear();
0141     m_jetInfo.clear();
0142     m_cstInfo.clear();
0143 
0144     // reset lists/associations
0145     m_vecSubEvts.clear();
0146     m_vecIDToCheck.clear();
0147     m_vecFastJets.clear();
0148     m_vecVtxToCheck.clear();
0149     m_vecVtxChecking.clear();
0150     m_mapLambdaJetAssoc.clear();
0151 
0152     m_evtNJets       = numeric_limits<uint64_t>::max();
0153     m_evtNLambdas    = numeric_limits<uint64_t>::max();
0154     m_evtNTaggedJets = numeric_limits<uint64_t>::max();
0155     m_evtNChrgPars   = numeric_limits<uint64_t>::max();
0156     m_evtNNeuPars    = numeric_limits<uint64_t>::max();
0157     m_evtSumEPar     = numeric_limits<double>::min();
0158     m_evtVtxX        = numeric_limits<double>::min();
0159     m_evtVtxY        = numeric_limits<double>::min();
0160     m_evtVtxZ        = numeric_limits<double>::min();
0161     m_evtPartID      = {numeric_limits<int>::min(),    numeric_limits<int>::min()};
0162     m_evtPartPx      = {numeric_limits<double>::min(), numeric_limits<double>::min()};
0163     m_evtPartPy      = {numeric_limits<double>::min(), numeric_limits<double>::min()};
0164     m_evtPartPz      = {numeric_limits<double>::min(), numeric_limits<double>::min()};
0165     m_evtPartE       = {numeric_limits<double>::min(), numeric_limits<double>::min()};
0166     m_lambdaID.clear();
0167     m_lambdaPID.clear();
0168     m_lambdaJetID.clear();
0169     m_lambdaEmbedID.clear();
0170     m_lambdaZ.clear();
0171     m_lambdaDr.clear();
0172     m_lambdaE.clear();
0173     m_lambdaPt.clear();
0174     m_lambdaEta.clear();
0175     m_lambdaPhi.clear();
0176     m_jetHasLambda.clear();
0177     m_jetNCst.clear();
0178     m_jetID.clear();
0179     m_jetE.clear();
0180     m_jetPt.clear();
0181     m_jetEta.clear();
0182     m_jetPhi.clear();
0183     m_cstID.clear();
0184     m_cstPID.clear();
0185     m_cstJetID.clear();
0186     m_cstEmbedID.clear();
0187     m_cstZ.clear();
0188     m_cstDr.clear();
0189     m_cstE.clear();
0190     m_cstPt.clear();
0191     m_cstEta.clear();
0192     m_cstPhi.clear();
0193     return;
0194 
0195   }  // end 'ResetOutput()'
0196 
0197 }  // end SColdQcdCorrelatorAnalysis namespace
0198 
0199 // end ------------------------------------------------------------------------