Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:18:52

0001 #ifndef HLTRIGGEROFFLINE_EXOTICA_EVTCOLCONTAINER_CC
0002 #define HLTRIGGEROFFLINE_EXOTICA_EVTCOLCONTAINER_CC
0003 
0004 /** \class EVTColContainer
0005  *
0006  *  Class to manage all the object collections in
0007  *  the Exotica Validation package.
0008  *
0009  *  \author  J. Duarte Campderros
0010  *
0011  */
0012 
0013 #include "DataFormats/Common/interface/TriggerResults.h"
0014 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0015 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
0016 #include "DataFormats/EgammaCandidates/interface/Photon.h"
0017 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
0018 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0019 #include "DataFormats/JetReco/interface/CaloJet.h"
0020 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
0021 #include "DataFormats/JetReco/interface/PFJet.h"
0022 #include "DataFormats/JetReco/interface/PFJetCollection.h"
0023 #include "DataFormats/METReco/interface/CaloMET.h"
0024 #include "DataFormats/METReco/interface/CaloMETFwd.h"
0025 #include "DataFormats/METReco/interface/GenMET.h"
0026 #include "DataFormats/METReco/interface/GenMETFwd.h"
0027 #include "DataFormats/METReco/interface/MET.h"
0028 #include "DataFormats/METReco/interface/METFwd.h"
0029 #include "DataFormats/METReco/interface/PFMET.h"
0030 #include "DataFormats/METReco/interface/PFMETFwd.h"
0031 #include "DataFormats/MuonReco/interface/Muon.h"
0032 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0033 #include "DataFormats/TauReco/interface/PFTau.h"
0034 #include "DataFormats/TauReco/interface/PFTauFwd.h"
0035 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0036 
0037 #include <map>
0038 #include <vector>
0039 
0040 /// Container with all the objects needed
0041 /// Notice that I have "more or less" followed
0042 /// the pdgIds of the particles involved.
0043 
0044 struct EVTColContainer {
0045   enum {
0046     PHOTON = 22,
0047     ELEC = 11,
0048     MUON = 13,
0049     MUTRK = 130,
0050     PFTAU = 15,
0051     TRACK = 0,
0052     PFMET = 39,
0053     PFMHT = 40,
0054     MET = 390000,
0055     GENMET = 390001,
0056     CALOMET = 390002,
0057     HLTMET = 390003,
0058     PFJET = 211,
0059     CALOJET = 111,
0060     CALOMHT = 400002,
0061     _nMAX
0062   };
0063 
0064   int nOfCollections;
0065   int nInitialized;
0066 
0067   const reco::GenParticleCollection *genParticles;
0068   const std::vector<reco::Muon> *muons;
0069   const std::vector<reco::Track> *tracks;
0070   const std::vector<reco::GsfElectron> *electrons;
0071   const std::vector<reco::Photon> *photons;
0072   const std::vector<reco::MET> *METs;
0073   const std::vector<reco::PFMET> *pfMETs;
0074   const std::vector<reco::PFMET> *pfMHTs;
0075   const std::vector<reco::GenMET> *genMETs;
0076   const std::vector<reco::CaloMET> *caloMETs;
0077   const std::vector<reco::CaloMET> *caloMHTs;
0078   const std::vector<reco::PFTau> *pfTaus;
0079   const std::vector<reco::PFJet> *pfJets;
0080   const std::vector<reco::CaloJet> *caloJets;
0081   const edm::TriggerResults *triggerResults;
0082   const reco::BeamSpot *bs;
0083 
0084   EVTColContainer()
0085       : nOfCollections(6),
0086         nInitialized(0),
0087         genParticles(nullptr),
0088         muons(nullptr),
0089         tracks(nullptr),
0090         electrons(nullptr),
0091         photons(nullptr),
0092         METs(nullptr),
0093         pfMETs(nullptr),
0094         pfMHTs(nullptr),
0095         genMETs(nullptr),
0096         caloMETs(nullptr),
0097         caloMHTs(nullptr),
0098         pfTaus(nullptr),
0099         pfJets(nullptr),
0100         caloJets(nullptr),
0101         triggerResults(nullptr),
0102         bs(nullptr) {}
0103   ///
0104   bool isAllInit() { return (nInitialized == nOfCollections); }
0105 
0106   bool isCommonInit() { return false; }
0107 
0108   /// Reset: clear all collections
0109   void reset() {
0110     nInitialized = 0;
0111     genParticles = nullptr;
0112     muons = nullptr;
0113     tracks = nullptr;
0114     electrons = nullptr;
0115     photons = nullptr;
0116     METs = nullptr;
0117     pfMETs = nullptr;
0118     pfMHTs = nullptr;
0119     genMETs = nullptr;
0120     caloMETs = nullptr;
0121     caloMHTs = nullptr;
0122     pfTaus = nullptr;
0123     pfJets = nullptr;
0124     caloJets = nullptr;
0125     triggerResults = nullptr;
0126     bs = nullptr;
0127   }
0128 
0129   /// Setter: multiple overloaded function
0130   void set(const reco::MuonCollection *v) {
0131     muons = v;
0132     ++nInitialized;
0133   }
0134   void set(const reco::TrackCollection *v) {
0135     tracks = v;
0136     ++nInitialized;
0137   }
0138   void set(const reco::GsfElectronCollection *v) {
0139     electrons = v;
0140     ++nInitialized;
0141   }
0142   void set(const reco::PhotonCollection *v) {
0143     photons = v;
0144     ++nInitialized;
0145   }
0146   void set(const reco::METCollection *v) {
0147     METs = v;
0148     ++nInitialized;
0149   }
0150   void set(const reco::PFMETCollection *v) {
0151     pfMETs = v;
0152     ++nInitialized;
0153   }
0154   void setPFMHT(const reco::PFMETCollection *v) {
0155     pfMHTs = v;
0156     ++nInitialized;
0157   }
0158   void set(const reco::GenMETCollection *v) {
0159     genMETs = v;
0160     ++nInitialized;
0161   }
0162   void set(const reco::CaloMETCollection *v) {
0163     caloMETs = v;
0164     ++nInitialized;
0165   }
0166   void setCaloMHT(const reco::CaloMETCollection *v) {
0167     caloMHTs = v;
0168     ++nInitialized;
0169   }
0170   void set(const reco::PFTauCollection *v) {
0171     pfTaus = v;
0172     ++nInitialized;
0173   }
0174   void set(const reco::PFJetCollection *v) {
0175     pfJets = v;
0176     ++nInitialized;
0177   }
0178   void set(const reco::CaloJetCollection *v) {
0179     caloJets = v;
0180     ++nInitialized;
0181   }
0182 
0183   /// Get size of collections
0184   const unsigned int getSize(const unsigned int &objtype) const {
0185     unsigned int size = 0;
0186     if (objtype == EVTColContainer::MUON && muons != nullptr) {
0187       size = muons->size();
0188     } else if (objtype == EVTColContainer::MUTRK && tracks != nullptr) {
0189       size = tracks->size();
0190     } else if (objtype == EVTColContainer::TRACK && tracks != nullptr) {
0191       size = tracks->size();
0192     } else if (objtype == EVTColContainer::ELEC && electrons != nullptr) {
0193       size = electrons->size();
0194     } else if (objtype == EVTColContainer::PHOTON && photons != nullptr) {
0195       size = photons->size();
0196     } else if (objtype == EVTColContainer::MET && METs != nullptr) {
0197       size = METs->size();
0198     } else if (objtype == EVTColContainer::PFMET && pfMETs != nullptr) {
0199       size = pfMETs->size();
0200     } else if (objtype == EVTColContainer::PFMHT && pfMHTs != nullptr) {
0201       size = pfMHTs->size();
0202     } else if (objtype == EVTColContainer::GENMET && genMETs != nullptr) {
0203       size = genMETs->size();
0204     } else if (objtype == EVTColContainer::CALOMET && caloMETs != nullptr) {
0205       size = caloMETs->size();
0206     } else if (objtype == EVTColContainer::CALOMHT && caloMHTs != nullptr) {
0207       size = caloMHTs->size();
0208     } else if (objtype == EVTColContainer::PFTAU && pfTaus != nullptr) {
0209       size = pfTaus->size();
0210     } else if (objtype == EVTColContainer::PFJET && pfJets != nullptr) {
0211       size = pfJets->size();
0212     } else if (objtype == EVTColContainer::CALOJET && caloJets != nullptr) {
0213       size = caloJets->size();
0214     }
0215 
0216     return size;
0217   }
0218 
0219   /// Tranform types into strings
0220   const static std::string getTypeString(const unsigned int &objtype) {
0221     std::string objTypestr;
0222 
0223     if (objtype == EVTColContainer::MUON) {
0224       objTypestr = "Mu";
0225     } else if (objtype == EVTColContainer::MUTRK) {
0226       objTypestr = "refittedStandAloneMuons";
0227     } else if (objtype == EVTColContainer::TRACK) {
0228       objTypestr = "Track";
0229     } else if (objtype == EVTColContainer::ELEC) {
0230       objTypestr = "Ele";
0231     } else if (objtype == EVTColContainer::PHOTON) {
0232       objTypestr = "Photon";
0233     } else if (objtype == EVTColContainer::MET) {
0234       objTypestr = "MET";
0235     } else if (objtype == EVTColContainer::PFMET) {
0236       objTypestr = "PFMET";
0237     } else if (objtype == EVTColContainer::PFMHT) {
0238       objTypestr = "PFMHT";
0239     } else if (objtype == EVTColContainer::GENMET) {
0240       objTypestr = "GenMET";
0241     } else if (objtype == EVTColContainer::CALOMET) {
0242       objTypestr = "CaloMET";
0243     } else if (objtype == EVTColContainer::CALOMHT) {
0244       objTypestr = "CaloMHT";
0245     } else if (objtype == EVTColContainer::PFTAU) {
0246       objTypestr = "PFTau";
0247     } else if (objtype == EVTColContainer::PFJET) {
0248       objTypestr = "PFJet";
0249     } else if (objtype == EVTColContainer::CALOJET) {
0250       objTypestr = "CaloJet";
0251     } else {
0252       edm::LogError("ExoticaValidations") << "EVTColContainer::getTypeString, "
0253                                           << "NOT Implemented error (object type id='" << objtype << "')" << std::endl;
0254       ;
0255     }
0256 
0257     return objTypestr;
0258   }
0259 };
0260 #endif