Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:09:50

0001 #ifndef DQMOFFLINE_TRIGGER_EGHLTOFFPHO
0002 #define DQMOFFLINE_TRIGGER_EGHLTOFFPHO
0003 
0004 //class: EgHLTOffPho
0005 //
0006 //author: Sam Harper (July 2008)
0007 //
0008 //
0009 //aim: to allow easy access to phoctron ID variables
0010 //     currently the CMSSW photon classes are a mess with key photon variables not being accessable from Photon
0011 //     this a stop gap to produce a simple photon class with all variables easily accessable via methods
0012 //     note as this is meant for HLT Offline DQM, I do not want the overhead of converting to pat
0013 //
0014 //implimentation: aims to be a wrapper for Photon methods, it is hoped that in time these methods will be directly added to Photon and so
0015 //                make this class obsolute
0016 //                unfortunately can not be a pure wrapper as needs to store isol and cluster shape
0017 //
0018 
0019 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
0020 #include "DataFormats/EgammaCandidates/interface/Photon.h"
0021 
0022 #include "DQMOffline/Trigger/interface/EgHLTEgCutCodes.h"
0023 #include "DQMOffline/Trigger/interface/EgHLTTrigCodes.h"
0024 
0025 namespace egHLT {
0026   class OffPho {
0027   public:
0028     //helper struct to store the isolations
0029     struct IsolData {
0030       int nrTrks;
0031       float ptTrks;
0032       float em;
0033       float had;
0034       float hltHad;
0035       float hltTrks;
0036       float hltEm;
0037     };
0038 
0039   public:
0040     //helper struct to store the cluster shapes
0041     struct ClusShapeData {
0042       float sigmaEtaEta;
0043       float sigmaIEtaIEta;
0044       float e2x5MaxOver5x5;
0045       float e1x5Over5x5;
0046       float sigmaPhiPhi;
0047       float sigmaIPhiIPhi;
0048       float r9;
0049     };
0050 
0051   public:
0052     //helper struct to store reco approximations of variables made by HLT
0053     struct HLTData {
0054       //const math::XYZTLorentzVector p4() const;
0055       float HLTeta;
0056       float HLTphi;
0057       float HLTenergy;
0058     };
0059 
0060   private:
0061     const reco::Photon* pho_;  //pointers to the underlying phoctron (we do not own this)
0062 
0063     ClusShapeData clusShapeData_;
0064     IsolData isolData_;
0065     HLTData hltData_;
0066 
0067     //these are bit-packed words telling me which cuts the photon fail (ie 0x0 is passed all cuts)
0068     int cutCode_;
0069     int looseCutCode_;
0070 
0071     //the idea is that these are user definable cuts mean to be idenital to the specified trigger
0072     //it is probably clear to the reader that I havent decided on the most efficient way to do this
0073     std::vector<std::pair<TrigCodes::TrigBitSet, int> >
0074         trigCutsCutCodes_;  //unsorted vector (may sort if have performance issues)
0075 
0076     //and these are the trigger bits stored
0077     //note that the trigger bits are defined at the begining of each job
0078     //and do not necessaryly map between jobs
0079     TrigCodes::TrigBitSet trigBits_;
0080 
0081   public:
0082     OffPho(const reco::Photon& pho, const ClusShapeData& shapeData, const IsolData& isolData, const HLTData& hltData)
0083         : pho_(&pho),
0084           clusShapeData_(shapeData),
0085           isolData_(isolData),
0086           hltData_(hltData),
0087           cutCode_(int(EgCutCodes::INVALID)),
0088           looseCutCode_(int(EgCutCodes::INVALID)) {}
0089     ~OffPho() = default;
0090 
0091     //modifiers
0092     void setCutCode(int code) { cutCode_ = code; }
0093     void setLooseCutCode(int code) { looseCutCode_ = code; }
0094 
0095     //slightly inefficient way, think I can afford it and its a lot easier to just make the sorted vector outside the class
0096     void setTrigCutsCutCodes(const std::vector<std::pair<TrigCodes::TrigBitSet, int> >& trigCutsCutCodes) {
0097       trigCutsCutCodes_ = trigCutsCutCodes;
0098     }
0099     void setTrigBits(TrigCodes::TrigBitSet bits) { trigBits_ = bits; }
0100 
0101     const reco::Photon* recoPho() const { return pho_; }
0102 
0103     //kinematic and geometric methods
0104     float et() const { return pho_->et(); }
0105     float pt() const { return pho_->pt(); }
0106     float energy() const { return pho_->energy(); }
0107     float eta() const { return pho_->eta(); }
0108     float phi() const { return pho_->phi(); }
0109     float etSC() const {
0110       return pho_->superCluster()->position().rho() / pho_->superCluster()->position().r() * energy();
0111     }
0112     float etaSC() const { return pho_->superCluster()->eta(); }
0113     float detEta() const { return etaSC(); }
0114     float phiSC() const { return pho_->superCluster()->phi(); }
0115     float zVtx() const { return pho_->vz(); }
0116     const math::XYZTLorentzVector& p4() const { return pho_->p4(); }
0117 
0118     bool isGap() const { return pho_->isEBGap() || pho_->isEEGap() || pho_->isEBEEGap(); }
0119 
0120     //abreviations of overly long Photon methods, I'm sorry but if you cant figure out what hOverE() means, you shouldnt be using this class
0121     float hOverE() const { return pho_->hadronicOverEm(); }
0122 
0123     float sigmaEtaEta() const;
0124     float sigmaEtaEtaUnCorr() const { return clusShapeData_.sigmaEtaEta; }
0125     float sigmaIEtaIEta() const { return clusShapeData_.sigmaIEtaIEta; }
0126     float sigmaPhiPhi() const { return clusShapeData_.sigmaPhiPhi; }
0127     float sigmaIPhiIPhi() const { return clusShapeData_.sigmaIPhiIPhi; }
0128     float e2x5MaxOver5x5() const { return clusShapeData_.e2x5MaxOver5x5; }
0129     float e1x5Over5x5() const { return clusShapeData_.e1x5Over5x5; }
0130     float r9() const { return clusShapeData_.r9; }
0131 
0132     //isolation
0133     float isolEm() const { return isolData_.em; }
0134     float isolHad() const { return isolData_.had; }
0135     int isolNrTrks() const { return isolData_.nrTrks; }
0136     float isolPtTrks() const { return isolData_.ptTrks; }
0137     float hltIsolHad() const { return isolData_.hltHad; }
0138     float hltIsolTrks() const { return isolData_.hltTrks; }
0139     float hltIsolEm() const { return isolData_.hltEm; }
0140 
0141     //hlt position - not a reco approximation, taken from triggerobject
0142     //const math::XYZTLorentzVector& HLTp4()const{return hltDataPho_.p4();}
0143     float hltPhi() const { return hltData_.HLTphi; }
0144     float hltEta() const { return hltData_.HLTeta; }
0145     float hltEnergy() const { return hltData_.HLTenergy; }
0146     //Diference between HLT Et and reco SC Et
0147     float DeltaE() const { return (hltEnergy() - energy()); }
0148 
0149     //selection cuts
0150     int cutCode() const { return cutCode_; }
0151     int looseCutCode() const { return looseCutCode_; }
0152 
0153     //trigger codes are just used as a unique identifier of the trigger, it is an error to specify more than a single bit
0154     //the idea here is to allow an arbitary number of photon triggers
0155     int trigCutsCutCode(const TrigCodes::TrigBitSet& trigger) const;
0156 
0157     //trigger
0158     TrigCodes::TrigBitSet trigBits() const { return trigBits_; }
0159   };
0160 }  // namespace egHLT
0161 
0162 #endif