Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:39

0001 #ifndef _RECOMET_METALGORITHMS_HCALNOISEALGO_H_
0002 #define _RECOMET_METALGORITHMS_HCALNOISEALGO_H_
0003 
0004 #include "DataFormats/METReco/interface/HcalNoiseRBX.h"
0005 #include "DataFormats/Common/interface/RefVector.h"
0006 #include "DataFormats/Common/interface/Ref.h"
0007 #include "DataFormats/Common/interface/RefProd.h"
0008 #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 
0011 class CommonHcalNoiseRBXData {
0012 public:
0013   CommonHcalNoiseRBXData(const reco::HcalNoiseRBX &rbx,
0014                          double minRecHitE,
0015                          double minLowHitE,
0016                          double minHighHitE,
0017                          double TS4TS5EnergyThreshold,
0018                          std::vector<std::pair<double, double> > const &TS4TS5UpperCut,
0019                          std::vector<std::pair<double, double> > const &TS4TS5LowerCut,
0020                          double MinRBXRechitR45E);
0021   ~CommonHcalNoiseRBXData() {}
0022 
0023   // accessors to internal variables
0024   inline double energy(void) const { return energy_; }
0025   inline double ratio(void) const { return e2ts_ / e10ts_; }
0026   inline double e2ts(void) const { return e2ts_; }
0027   inline double e10ts(void) const { return e10ts_; }
0028   inline bool validRatio(void) const { return e10ts_ != 0.0; }
0029   inline int numHPDHits(void) const { return numHPDHits_; }
0030   inline int numRBXHits(void) const { return numRBXHits_; }
0031   inline int numHPDNoOtherHits(void) const { return numHPDNoOtherHits_; }
0032   inline int numZeros(void) const { return numZeros_; }
0033   inline double minLowEHitTime(void) const { return minLowEHitTime_; }
0034   inline double maxLowEHitTime(void) const { return maxLowEHitTime_; }
0035   inline double lowEHitTimeSqrd(void) const { return lowEHitTimeSqrd_; }
0036   inline int numLowEHits(void) const { return numLowEHits_; }
0037   inline double minHighEHitTime(void) const { return minHighEHitTime_; }
0038   inline double maxHighEHitTime(void) const { return maxHighEHitTime_; }
0039   inline double highEHitTimeSqrd(void) const { return highEHitTimeSqrd_; }
0040   inline int numHighEHits(void) const { return numHighEHits_; }
0041   inline double RBXEMF(void) const { return RBXEMF_; }
0042   inline double HPDEMF(void) const { return HPDEMF_; }
0043   inline bool PassTS4TS5(void) const { return TS4TS5Decision_; }
0044   inline edm::RefVector<CaloTowerCollection> rbxTowers(void) const { return rbxtowers_; }
0045   inline int r45Count(void) const { return r45Count_; }
0046   inline double r45Fraction(void) const { return r45Fraction_; }
0047   inline double r45EnergyFraction(void) const { return r45EnergyFraction_; }
0048 
0049   bool CheckPassFilter(double Charge,
0050                        double Discriminant,
0051                        std::vector<std::pair<double, double> > const &Cuts,
0052                        int Side);
0053 
0054 private:
0055   // values
0056   double energy_;            // RBX hadronic energy as determined by the sum of calotowers
0057   double e2ts_;              // pedestal subtracted charge in two peak TS for RBX
0058   double e10ts_;             // pedestal subtracted charge in all 10 TS for RBX
0059   int numHPDHits_;           // largest number of hits in an HPD in the RBX
0060   int numRBXHits_;           // number of hits in the RBX
0061   int numHPDNoOtherHits_;    // largest number of hits in an HPD when no other HPD has a hit in the RBX
0062   int numZeros_;             // number of ADC 0 counts in all hits in all TS in the RBX
0063   double minLowEHitTime_;    // minimum time found for any low energy hit in the RBX
0064   double maxLowEHitTime_;    // maximum time found for any low energy hit in the RBX
0065   double lowEHitTimeSqrd_;   // low energy hit time^2
0066   int numLowEHits_;          // number of low energy hits
0067   double minHighEHitTime_;   // minimum time found for any high energy hit in the RBX
0068   double maxHighEHitTime_;   // maximum time found for any high energy hit in the RBX
0069   double highEHitTimeSqrd_;  // high energy hit time^2
0070   int numHighEHits_;         // number of high energy hits
0071   double HPDEMF_;            // minimum electromagnetic fraction found in an HPD in the RBX
0072   double RBXEMF_;            // electromagnetic fraction of the RBX
0073   bool TS4TS5Decision_;      // if this RBX fails TS4TS5 variable or not
0074   edm::RefVector<CaloTowerCollection> rbxtowers_;  // calotowers associated with the RBX
0075   int r45Count_;                                   // Number of rechits above some threshold flagged by R45
0076   double r45Fraction_;                             // Fraction of rechits above some threshold flagged by R45
0077   double r45EnergyFraction_;                       // Energy fraction of rechits above some threshold
0078 };
0079 
0080 class HcalNoiseAlgo {
0081 public:
0082   HcalNoiseAlgo(const edm::ParameterSet &iConfig);
0083   virtual ~HcalNoiseAlgo() {}
0084 
0085   // an rbx is "interesting/problematic" (i.e. is recorded to the event record)
0086   bool isProblematic(const CommonHcalNoiseRBXData &) const;
0087 
0088   // an rbx passes a noise filter
0089   bool passLooseNoiseFilter(const CommonHcalNoiseRBXData &) const;
0090   bool passTightNoiseFilter(const CommonHcalNoiseRBXData &) const;
0091   bool passHighLevelNoiseFilter(const CommonHcalNoiseRBXData &) const;
0092 
0093   // loose filter broken down into separate components
0094   bool passLooseRatio(const CommonHcalNoiseRBXData &) const;
0095   bool passLooseHits(const CommonHcalNoiseRBXData &) const;
0096   bool passLooseZeros(const CommonHcalNoiseRBXData &) const;
0097   bool passLooseTiming(const CommonHcalNoiseRBXData &) const;
0098   bool passLooseRBXRechitR45(const CommonHcalNoiseRBXData &) const;
0099 
0100   // tight filter broken down into separate components
0101   bool passTightRatio(const CommonHcalNoiseRBXData &) const;
0102   bool passTightHits(const CommonHcalNoiseRBXData &) const;
0103   bool passTightZeros(const CommonHcalNoiseRBXData &) const;
0104   bool passTightTiming(const CommonHcalNoiseRBXData &) const;
0105   bool passTightRBXRechitR45(const CommonHcalNoiseRBXData &) const;
0106 
0107   // an rbx passes an energy (or other) threshold to test a certain variable
0108   // for instance, the EMF cut might require that the RBX have 20 GeV of energy
0109   bool passRatioThreshold(const CommonHcalNoiseRBXData &) const;
0110   bool passZerosThreshold(const CommonHcalNoiseRBXData &) const;
0111   bool passEMFThreshold(const CommonHcalNoiseRBXData &) const;
0112 
0113 private:
0114   // energy thresholds used for problematic cuts
0115   double pMinERatio_;  // minimum energy to apply ratio cuts
0116   double pMinEZeros_;  // minimum energy to apply zeros cuts
0117   double pMinEEMF_;    // minimum energy to apply EMF cuts
0118 
0119   // energy thresholds used for loose, tight and high level cuts
0120   double minERatio_;  // minimum energy to apply ratio cuts
0121   double minEZeros_;  // minimum energy to apply zeros cuts
0122   double minEEMF_;    // minimum energy to apply EMF cuts
0123 
0124   // "problematic" cuts
0125   // used to determine whether an RBX is stored in the EDM
0126   double pMinE_;                           // minimum energy
0127   double pMinRatio_;                       // minimum ratio
0128   double pMaxRatio_;                       // maximum ratio
0129   int pMinHPDHits_;                        // minimum # of HPD hits
0130   int pMinRBXHits_;                        // minimum # of RBX hits
0131   int pMinHPDNoOtherHits_;                 // minimum # of HPD hits with no other hits in the RBX
0132   int pMinZeros_;                          // minimum # of zeros
0133   double pMinLowEHitTime_;                 // minimum low energy hit time
0134   double pMaxLowEHitTime_;                 // maximum low energy hit time
0135   double pMinHighEHitTime_;                // minimum high energy hit time
0136   double pMaxHighEHitTime_;                // maximum high energy hit time
0137   double pMaxHPDEMF_;                      // maximum HPD EMF
0138   double pMaxRBXEMF_;                      // maximum RBX EMF
0139   int pMinRBXRechitR45Count_;              // number of R45-flagged hits
0140   double pMinRBXRechitR45Fraction_;        // fraction of R45-flagged hits
0141   double pMinRBXRechitR45EnergyFraction_;  // energy fraction of R45-flagged hits
0142 
0143   // "loose" cuts
0144   // used to determine whether an RBX fails the loose noise cuts
0145   double lMinRatio_;         // minimum ratio
0146   double lMaxRatio_;         // maximum ratio
0147   int lMinHPDHits_;          // minimum # of HPD hits
0148   int lMinRBXHits_;          // minimum # of RBX hits
0149   int lMinHPDNoOtherHits_;   // minimum # of HPD hits with no other hits in the RBX
0150   int lMinZeros_;            // minimum # of zeros
0151   double lMinLowEHitTime_;   // minimum low energy hit time
0152   double lMaxLowEHitTime_;   // maximum low energy hit time
0153   double lMinHighEHitTime_;  // minimum high energy hit time
0154   double lMaxHighEHitTime_;  // maximum high energy hit time
0155   std::vector<double> lMinRBXRechitR45Cuts_;
0156 
0157   // "tight" cuts
0158   // used to determine whether an RBX fails the tight noise cuts
0159   double tMinRatio_;         // minimum ratio
0160   double tMaxRatio_;         // maximum ratio
0161   int tMinHPDHits_;          // minimum # of HPD hits
0162   int tMinRBXHits_;          // minimum # of RBX hits
0163   int tMinHPDNoOtherHits_;   // minimum # of HPD hits with no other hits in the RBX
0164   int tMinZeros_;            // minimum # of zeros
0165   double tMinLowEHitTime_;   // minimum low energy hit time
0166   double tMaxLowEHitTime_;   // maximum low energy hit time
0167   double tMinHighEHitTime_;  // minimum high energy hit time
0168   double tMaxHighEHitTime_;  // maximum high energy hit time
0169   std::vector<double> tMinRBXRechitR45Cuts_;
0170 
0171   // "high level" cuts
0172   // used to determine where an RBX fails the high level noise cuts
0173   double hlMaxHPDEMF_;  // maximum HPD EMF
0174   double hlMaxRBXEMF_;  // maximum RBX EMF
0175 };
0176 
0177 class JoinCaloTowerRefVectorsWithoutDuplicates {
0178 public:
0179   JoinCaloTowerRefVectorsWithoutDuplicates() {}
0180   ~JoinCaloTowerRefVectorsWithoutDuplicates() {}
0181 
0182   void operator()(edm::RefVector<CaloTowerCollection> &v1, const edm::RefVector<CaloTowerCollection> &v2) const;
0183 
0184 private:
0185   // helper function to compare calotower references
0186   struct twrrefcomp {
0187     inline bool operator()(const edm::Ref<CaloTowerCollection> &t1, const edm::Ref<CaloTowerCollection> &t2) const {
0188       return t1->id() < t2->id();
0189     }
0190   };
0191   typedef std::set<edm::Ref<CaloTowerCollection>, twrrefcomp> twrrefset_t;
0192 };
0193 
0194 #endif