![]() |
|
|||
File indexing completed on 2023-03-17 11:23:39
0001 #ifndef EcalSelectiveReadoutSuppressor_h 0002 #define EcalSelectiveReadoutSuppressor_h 0003 0004 #include <vector> 0005 #include "boost/multi_array.hpp" 0006 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" 0007 #include "Geometry/CaloGeometry/interface/CaloGeometry.h" 0008 #include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h" 0009 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h" 0010 #include "FWCore/Framework/interface/ConsumesCollector.h" 0011 #include "FWCore/ParameterSet/interface/ParameterSet.h" 0012 #include "SimCalorimetry/EcalSelectiveReadoutAlgos/interface/EcalSelectiveReadout.h" 0013 #include "FWCore/Framework/interface/EventSetup.h" 0014 #include "CondFormats/EcalObjects/interface/EcalSRSettings.h" 0015 0016 #include <memory> 0017 0018 class CaloGeometryRecord; 0019 0020 class EcalSelectiveReadoutSuppressor { 0021 public: 0022 /** Construtor. 0023 * @param params configuration from python file 0024 * @param settings configuration from condition DB 0025 */ 0026 EcalSelectiveReadoutSuppressor(const edm::ParameterSet& params, edm::ConsumesCollector iC); 0027 0028 void setSettings(const EcalSRSettings* settings); 0029 0030 enum { BARREL, ENDCAP }; 0031 0032 /** Gets number of weights supported by the zero suppression filter 0033 * @return number of weights 0034 */ 0035 static int getFIRTapCount() { return nFIRTaps; } 0036 0037 /** Set the mapping of which cell goes with which trigger tower 0038 * @param map the trigger tower map 0039 */ 0040 void setTriggerMap(const EcalTrigTowerConstituentsMap* map); 0041 0042 /** Set the ECAL electronics mapping 0043 * @param map the ECAL electronics map 0044 */ 0045 void setElecMap(const EcalElectronicsMapping* map); 0046 0047 /** Sets the geometry of the calorimeters 0048 */ 0049 void setGeometry(const CaloGeometry* caloGeometry); 0050 0051 /** Runs the selective readout(SR) algorithm. 0052 * @deprecated use the other run methode instead 0053 * @param eventSetup event conditions 0054 * @param trigPrims the ECAL trigger primitives used as input to the SR. 0055 * @param barrelDigis [in,out] the EB digi collection to filter 0056 * @param endcapDigis [in,out] the EE digi collection to filter 0057 */ 0058 void run(const edm::EventSetup& eventSetup, 0059 const EcalTrigPrimDigiCollection& trigPrims, 0060 EBDigiCollection& barrelDigis, 0061 EEDigiCollection& endcapDigis); 0062 0063 /** Runs the selective readout (SR) algorithm. 0064 * @param eventSetup event conditions 0065 * @param trigPrims the ECAL trigger primitives used as input to the SR. 0066 * @param barrelDigis the input EB digi collection 0067 * @param endcapDigis the input EE digi collection 0068 * @param selectedBarrelDigis [out] the EB digi passing the SR. Pointer to 0069 * the collection to fill. If null, no collection is filled. 0070 * @param selectedEndcapDigis [out] the EE digi passing the SR. Pointer to 0071 * the collection to fill. If null, no collection is filled. 0072 * @param ebSrFlags [out] the computed SR flags for EB. Pointer to 0073 * the collection to fill. If null, no collection is filled. 0074 * @param eeSrFlags [out] the computed SR flags for EE. Pointer to 0075 * the collection to fill. If null, no collection is filled. 0076 */ 0077 void run(const edm::EventSetup& eventSetup, 0078 const EcalTrigPrimDigiCollection& trigPrims, 0079 const EBDigiCollection& barrelDigis, 0080 const EEDigiCollection& endcapDigis, 0081 EBDigiCollection* selectedBarrelDigis, 0082 EEDigiCollection* selectedEndcapDigis, 0083 EBSrFlagCollection* ebSrFlags, 0084 EESrFlagCollection* eeSrFlags); 0085 0086 /** For debugging purposes. 0087 */ 0088 EcalSelectiveReadout* getEcalSelectiveReadout() { return ecalSelectiveReadout.get(); } 0089 0090 /** Writes out TT flags. On of the 'run' method must be called beforehand. 0091 * Beware this method might be removed in future. 0092 * @param os stream to write to 0093 * @param iEvent event index. Ignored if <0. 0094 * @param withHeader. If true writes out a header with the legend. 0095 */ 0096 void printTTFlags(std::ostream& os, int iEvent = -1, bool withHeader = true) const; 0097 0098 private: 0099 /** Returns true if a digi passes the zero suppression. 0100 * @param frame, data frame (aka digi). 0101 * @param thr zero suppression threshold in thrUnit. 0102 * @return true if passed ZS filter, false if failed 0103 */ 0104 0105 bool accept(const edm::DataFrame& frame, int thr); 0106 0107 /// helpers for constructors 0108 /** Initializes ZS threshold and SR classificion to SR ("action") flags 0109 */ 0110 void initCellThresholds(double barrelLowInterest, 0111 double endcapLowInterest, 0112 double barrelHighInterest, 0113 double endcapHighInterest); 0114 /** Converts threshold in GeV to threshold in internal unit used by the 0115 * ZS FIR. 0116 * @param thresholdInGeV the theshold in GeV 0117 * @param iSubDet 0 for barrel, 1 for endcap 0118 * @return threshold in thrUnit unit. INT_MAX means complete suppression, 0119 * INT_MIN means no zero suppression. 0120 */ 0121 int internalThreshold(double thresholdInGeV, int iSubDet) const; 0122 0123 /** Gets the integer weights used by the zero suppression 0124 * FIR filter. 0125 *<P><U>Weight definitions:</U> 0126 *<UL> 0127 *<LI>Uncalibrated normalized weights are defined as such that when applied 0128 * to the average pulse with the highest sample normalized to 1, the 0129 * result is 1. 0130 *<LI>Calibrated weights are defined for each crystal, as uncalibrated 0131 * normalized weights multiplied by an intercalibration constant which 0132 * is expected to be between 0.6 and 1.4 0133 *<LI>FIR weights are defined for each crystal as the closest signed integers 0134 * to 2**10 times the calibrated weigths. The absolute value of these 0135 * weights should not be greater than (2**12-1). 0136 *</UL> 0137 * If a FIR weights exceeds the (2**12-1) absolute value limit, its 0138 * absolute value is replaced by (2**12-1). 0139 */ 0140 std::vector<int> getFIRWeigths(); 0141 0142 /**Transforms CMSSW eta ECAL crystal indices to indices starting at 0 0143 * to use for c-array or vector. 0144 * @param iEta CMSSW eta index (numbering -85...-1,1...85) 0145 * @return index in numbering from 0 to 169 0146 */ 0147 int iEta2cIndex(int iEta) const { return (iEta < 0) ? iEta + 85 : iEta + 84; } 0148 0149 /**Transforms CMSSW phi ECAL crystal indices to indices starting at 0 0150 * to use for c-array or vector. 0151 * @param iPhi CMSSW phi index (numbering 1...360) 0152 * @return index in numbering 0...359 0153 */ 0154 int iPhi2cIndex(int iPhi) const { return iPhi - 1; } 0155 0156 /**Transforms CMSSW eta ECAL TT indices to indices starting at 0 0157 * to use for c-array or vector. 0158 * @param iEta CMSSW eta index (numbering -28...-1,28...56) 0159 * @return index in numbering from 0 to 55 0160 */ 0161 int iTTEta2cIndex(int iEta) const { return (iEta < 0) ? iEta + 28 : iEta + 27; } 0162 0163 /**Transforms CMSSW phi ECAL crystal indices to indices starting at 0 0164 * to use for c-array or vector. 0165 * @param iPhi CMSSW phi index (numbering 1...72) 0166 * @return index in numbering 0...71 0167 */ 0168 int iTTPhi2cIndex(int iPhi) const { return iPhi - 1; } 0169 0170 /** Help function to set the srFlags field. Used in TrigPrimByPass mode 0171 * @param eventSetup the EDM event setup 0172 * @param ebDigi the ECAL barrel APD digis 0173 * @param eeDigi the ECAL endcap VPT digis 0174 */ 0175 void setTtFlags(const edm::EventSetup& eventSetup, const EBDigiCollection& ebDigis, const EEDigiCollection& eeDigis); 0176 0177 /** Help function to set the srFlags field. 0178 * @param trigPrim the trigger primitive digi collection 0179 */ 0180 void setTtFlags(const EcalTrigPrimDigiCollection& trigPrims); 0181 0182 template <class T> 0183 double frame2Energy(const T& frame, int timeOffset = 0) const; 0184 0185 // /** Help function to get SR flag from ZS threshold using min/max convention 0186 // * for SUPPRESS and FULL_READOUT: see zsThreshold. 0187 // * @param thr ZS threshold in thrUnit 0188 // * @param flag for Zero suppression: EcalSrFlag::SRF_ZS1 or 0189 // * EcalSrFlag::SRF_ZS2 0190 // * @return the SR flag 0191 // */ 0192 // int thr2Srf(int thr, int zsFlag) const; 0193 0194 /** Number of endcap, obviously two. 0195 */ 0196 const static size_t nEndcaps = 2; 0197 0198 /** Number of eta trigger tower divisions in one endcap. 0199 */ 0200 const static size_t nEndcapTriggerTowersInEta = 11; 0201 0202 /** Number of eta trigger tower divisions in the barrel. 0203 */ 0204 const static size_t nBarrelTriggerTowersInEta = 34; 0205 0206 /** Number of eta divisions in trigger towers for the whole ECAL 0207 */ 0208 const static size_t nTriggerTowersInEta = 2 * nEndcapTriggerTowersInEta + nBarrelTriggerTowersInEta; 0209 0210 /** Number of phi divisions in trigger towers. 0211 */ 0212 const static size_t nTriggerTowersInPhi = 72; 0213 0214 /** Help class to comput selective readout flags. 0215 */ 0216 std::unique_ptr<EcalSelectiveReadout> ecalSelectiveReadout; 0217 0218 const EcalTrigTowerConstituentsMap* theTriggerMap; 0219 0220 /** Trigger tower flags: see setTtFlags() 0221 */ 0222 EcalSelectiveReadout::ttFlag_t ttFlags[nTriggerTowersInEta][nTriggerTowersInPhi]; 0223 0224 /** Time position of the first sample to use in zero suppession FIR 0225 * filter. Numbering starts at 0. 0226 */ 0227 int firstFIRSample; 0228 0229 /** Weights of zero suppression FIR filter 0230 */ 0231 std::vector<int> firWeights; 0232 0233 /** Depth of DCC zero suppression FIR filter (number of taps), 0234 * in principal 6. 0235 */ 0236 static const int nFIRTaps; 0237 0238 /** DCC zero suppression FIR filter uncalibrated normalized weigths 0239 */ 0240 std::vector<float> weights; 0241 0242 /** Flag to use a symetric zero suppression (cut on absolute value) 0243 */ 0244 bool symetricZS; 0245 0246 /** Zero suppresion threshold for the ECAL expressed in ebThrUnit and 0247 * eeThrUnit. Set to numeric_limits<int>::min() for FULL READOUT and 0248 * to numeric_limits<int>::max() for SUPPRESS. 0249 * First index: 0 for barrel, 1 for endcap 0250 * 2nd index: channel interest (see EcalSelectiveReadout::towerInterest_t 0251 */ 0252 int zsThreshold[2][8]; 0253 0254 /** Internal unit for Zero Suppression threshold (1/4th ADC count) used by 0255 * the FIR. 0256 * Index: 0 for barrel, 1 for endcap 0257 */ 0258 double thrUnit[2]; 0259 0260 /** Switch for trigger primitive simulation module bypass debug mode. 0261 */ 0262 bool trigPrimBypass_; 0263 0264 /** Mode selection for "Trig bypass" mode 0265 * 0: TT thresholds applied on sum of crystal Et's 0266 * 1: TT thresholds applies on compressed Et from Trigger primitive 0267 * @see trigPrimByPass_ switch 0268 */ 0269 int trigPrimBypassMode_; 0270 0271 /** SR flag (low interest/single/neighbor/center) to action flag 0272 * (suppress, ZS1, ZS2, FRO) map. 0273 */ 0274 std::vector<int> actions_; 0275 0276 /** Switch to applies trigPrimBypassLTH_ and trigPrimBypassHTH_ thresholds 0277 * on TPG compressed ET instead of using flags from TPG: trig prim bypass mode 0278 * 1. 0279 */ 0280 bool ttThresOnCompressedEt_; 0281 0282 /** When in trigger primitive simulation module bypass debug mode, 0283 * switch to enable Peak finder effect simulation 0284 */ 0285 bool trigPrimBypassWithPeakFinder_; 0286 0287 /** Low TT Et threshold for trigger primitive simulation module bypass 0288 * debug mode. 0289 */ 0290 double trigPrimBypassLTH_; 0291 0292 /** Low TT Et threshold for trigger primitive simulation module bypass 0293 * debug mode. 0294 */ 0295 double trigPrimBypassHTH_; 0296 0297 /** Maps RU interest flag (low interest, single neighbour, center) to 0298 * Selective readout action flag (type of readout). 0299 * 1st index: 0 for barrel, 1 for endcap 0300 * 2nd index: RU interest (low, single, neighbour, center, 0301 * forced low, forced single...) 0302 */ 0303 int srFlags[2][8]; 0304 0305 /** Default TTF to substitute if absent from the trigger primitive collection 0306 */ 0307 EcalSelectiveReadout::ttFlag_t defaultTtf_; 0308 0309 /** Number of produced events 0310 */ 0311 int ievt_; 0312 0313 edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geoToken_; 0314 }; 0315 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.2.1 LXR engine. The LXR team |
![]() ![]() |