CMS 3D CMS Logo

CaloTowersCreationAlgo.h
Go to the documentation of this file.
1 #ifndef RECOLOCALCALO_CALOTOWERSCREATOR_CALOTOWERSCREATIONALGO_H
2 #define RECOLOCALCALO_CALOTOWERSCREATOR_CALOTOWERSCREATIONALGO_H 1
3 
9 
10 // channel status
13 
16 
17 // severity level assignment for HCAL
20 
21 // severity level assignment for ECAL
23 
24 // need if we want to store the handles
26 #include <tuple>
27 
28 
29 #include <map>
30 class CaloTowerTopology;
31 class HcalTopology;
32 class CaloGeometry;
35 class CaloRecHit;
36 class DetId;
37 
43 //
44 // Modify MetaTower to save energy of rechits for use in tower 4-momentum assignment,
45 // added containers for timing assignment and for holding status information.
46 // Anton Anastassov (Northwestern)
47 //
48 
50 public:
51 
52  int nalgo=-1;
53 
55 
56  CaloTowersCreationAlgo(double EBthreshold, double EEthreshold,
57 
58  bool useEtEBTreshold, bool useEtEETreshold,
59  bool useSymEBTreshold, bool useSymEETreshold,
60 
61  double HcalThreshold,
62  double HBthreshold, double HBthreshold1, double HBthreshold2,
63  double HESthreshold, double HESthreshold1,
64  double HEDthreshold, double HEDthreshold1,
65  double HOthreshold0, double HOthresholdPlus1, double HOthresholdMinus1,
66  double HOthresholdPlus2, double HOthresholdMinus2,
67  double HF1threshold, double HF2threshold,
68  double EBweight, double EEweight,
69  double HBweight, double HESweight, double HEDweight,
70  double HOweight, double HF1weight, double HF2weight,
71  double EcutTower, double EBSumThreshold, double EESumThreshold, bool useHO,
72  // (for momentum reconstruction algorithm)
73  int momConstrMethod,
74  double momHBDepth,
75  double momHEDepth,
76  double momEBDepth,
77  double momEEDepth,
78  int hcalPhase=0
79  );
80 
81  CaloTowersCreationAlgo(double EBthreshold, double EEthreshold,
82 
83  bool useEtEBTreshold, bool useEtEETreshold,
84  bool useSymEBTreshold, bool useSymEETreshold,
85 
86  double HcalThreshold,
87  double HBthreshold, double HBthreshold1, double HBthreshold2,
88  double HESthreshold, double HESthreshold1,
89  double HEDthreshold, double HEDthreshold1,
90  double HOthreshold0, double HOthresholdPlus1, double HOthresholdMinus1,
91  double HOthresholdPlus2, double HOthresholdMinus2,
92  double HF1threshold, double HF2threshold,
93  const std::vector<double> & EBGrid, const std::vector<double> & EBWeights,
94  const std::vector<double> & EEGrid, const std::vector<double> & EEWeights,
95  const std::vector<double> & HBGrid, const std::vector<double> & HBWeights,
96  const std::vector<double> & HESGrid, const std::vector<double> & HESWeights,
97  const std::vector<double> & HEDGrid, const std::vector<double> & HEDWeights,
98  const std::vector<double> & HOGrid, const std::vector<double> & HOWeights,
99  const std::vector<double> & HF1Grid, const std::vector<double> & HF1Weights,
100  const std::vector<double> & HF2Grid, const std::vector<double> & HF2Weights,
101  double EBweight, double EEweight,
102  double HBweight, double HESweight, double HEDweight,
103  double HOweight, double HF1weight, double HF2weight,
104  double EcutTower, double EBSumThreshold, double EESumThreshold, bool useHO,
105  // (for momentum reconstruction algorithm)
106  int momConstrMethod,
107  double momHBDepth,
108  double momHEDepth,
109  double momEBDepth,
110  double momEEDepth,
111  int hcalPhase=0
112 );
113 
114  void setGeometry(const CaloTowerTopology* cttopo, const CaloTowerConstituentsMap* ctmap, const HcalTopology* htopo, const CaloGeometry* geo);
115 
116  // pass the containers of channels status from the event record (stored in DB)
117  // these are called in CaloTowersCreator
120 
121  // Kake a map of number of channels not used in RecHit production.
122  // The key is the calotower id.
123  void makeHcalDropChMap();
124 
125  void makeEcalBadChs();
126 
127  void begin();
128  void process(const HBHERecHitCollection& hbhe);
129  void process(const HORecHitCollection& ho);
130  void process(const HFRecHitCollection& hf);
131  void process(const EcalRecHitCollection& ecal);
132 
133 
134  void process(const CaloTowerCollection& ctc);
135 
136  void finish(CaloTowerCollection& destCollection);
137 
138  // modified rescale method
139  void rescaleTowers(const CaloTowerCollection& ctInput, CaloTowerCollection& ctResult);
140 
141  void setEBEScale(double scale);
142  void setEEEScale(double scale);
143  void setHBEScale(double scale);
144  void setHESEScale(double scale);
145  void setHEDEScale(double scale);
146  void setHOEScale(double scale);
147  void setHF1EScale(double scale);
148  void setHF2EScale(double scale);
149 
150 
151  // Assign to categories based on info from DB and RecHit status
152  // Called in assignHit to check if the energy should be added to
153  // calotower, and how to flag the channel
154  unsigned int hcalChanStatusForCaloTower(const CaloRecHit* hit);
155  std::tuple<unsigned int,bool> ecalChanStatusForCaloTower(const EcalRecHit* hit);
156 
157  // Channel flagging is based on acceptable severity levels specified in the
158  // configuration file. These methods are used to pass the values read in
159  // CaloTowersCreator
160  //
161  // from DB
163  void setEcalSeveritiesToBeExcluded(const std::vector<int>& ecalSev ) {theEcalSeveritiesToBeExcluded= ecalSev;}
164 
165  // flag to use recovered hits
168 
169  // severety level calculator for HCAL
171 
172  // severity level calculator for ECAL
174 
175 
176  // The following are needed for creating towers from rechits excluded from the ------------------------------------
177  // default reconstructions
178 
179  // NB! Controls if rejected hits shold be used instead of the default!!!
181 
183  // void setEcalAcceptSeverityLevelForRejectedHit(unsigned int level) {theEcalAcceptSeverityLevelForRejectedHit = level;}
184  void SetEcalSeveritiesToBeUsedInBadTowers(const std::vector<int>& ecalSev ) {theEcalSeveritiesToBeUsedInBadTowers= ecalSev;}
185 
186 
190 
191  //-------------------------------------------------------------------------------------------------------------------
192 
193 
194 
195  // set the EE EB handles
196 
199 
200 
201 
202 
203  // Add methods to get the seperate positions for ECAL/HCAL
204  // used in constructing the 4-vectors using new methods
205  GlobalPoint emCrystalShwrPos (DetId detId, float fracDepth);
206  GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth);
207  // "effective" point for the EM/HAD shower in CaloTower
208  // position based on non-zero energy cells
209  GlobalPoint hadShwrPos(const std::vector<std::pair<DetId,float> >& metaContains,
210  float fracDepth, double hadE);
211  GlobalPoint emShwrPos(const std::vector<std::pair<DetId,float> >& metaContains,
212  float fracDepth, double totEmE);
213 
214  // overloaded function to get had position based on all had cells in the tower
215  GlobalPoint hadShwrPos(CaloTowerDetId id, float fracDepth);
216  GlobalPoint hadShwPosFromCells(DetId frontCell, DetId backCell, float fracDepth);
217 
218  // for Chris
219  GlobalPoint emShwrLogWeightPos(const std::vector<std::pair<DetId,float> >& metaContains,
220  float fracDepth, double totEmE);
221 
222 
223 private:
224 
225  struct MetaTower {
227  bool empty() const { return metaConstituents.empty();}
228  // contains also energy of RecHit
229  std::vector< std::pair<DetId, float> > metaConstituents;
231  float E=0, E_em=0, E_had=0, E_outer=0;
232  float emSumTimeTimesE=0, hadSumTimeTimesE=0, emSumEForTime=0, hadSumEForTime=0; // Sum(Energy x Timing) : intermediate container
233 
234  // needed to set CaloTower status word
236 
237  };
238 
240  void assignHitEcal(const EcalRecHit* recHit);
241  void assignHitHcal(const CaloRecHit* recHit);
242 
243  void rescale(const CaloTower * ct);
244 
246  MetaTower & find(const CaloTowerDetId & id);
247 
249  void getThresholdAndWeight(const DetId & detId, double & threshold, double & weight) const;
250 
254 
255 
257 
263  std::vector<double> theEBGrid, theEBWeights;
264  std::vector<double> theEEGrid, theEEWeights;
265  std::vector<double> theHBGrid, theHBWeights;
266  std::vector<double> theHESGrid, theHESWeights;
267  std::vector<double> theHEDGrid, theHEDWeights;
268  std::vector<double> theHOGrid, theHOWeights;
269  std::vector<double> theHF1Grid, theHF1Weights;
270  std::vector<double> theHF2Grid, theHF2Weights;
274 
275  double theEBEScale;
276  double theEEEScale;
277  double theHBEScale;
278  double theHESEScale;
279  double theHEDEScale;
280  double theHOEScale;
281  double theHF1EScale;
282  double theHF2EScale;
288 
289  // for checking the status of ECAL and HCAL channels stored in the DB
292 
293  // calculator of severety level for HCAL
295 
296  // calculator for severity level for ECAL
298 
299 
300  // fields that hold the information passed from the CaloTowersCreator configuration file:
301  // controll what is considered bad/recovered/problematic channel for CaloTower purposes
302  //
305  // flag to use recovered hits
308 
309  // controls the tower reconstruction from rejected hits
310 
314 
315 
318 
319  // if Hcal is missing, fudge it scaling Ecal by this factor (if > 0)
321 
324 
325  // Switches and paramters for CaloTower 4-momentum assignment
326  // "depth" variables do not affect all algorithms
332 
333  // compactify timing info
334  int compactTime(float time);
335 
337 
338 
339  // internal map
340  typedef std::vector<MetaTower> MetaTowerMap;
341  MetaTowerMap theTowerMap;
342  unsigned int theTowerMapSize=0;
343 
344  // Number of channels in the tower that were not used in RecHit production (dead/off,...).
345  // These channels are added to the other "bad" channels found in the recHit collection.
346  typedef std::map<CaloTowerDetId, std::pair<short int,bool>> HcalDropChMap;
347  HcalDropChMap hcalDropChMap;
348 
349  // Number of bad Ecal channel in each tower
350  //unsigned short ecalBadChs[CaloTowerDetId::kSizeForDenseIndexing];
351  std::vector<unsigned short> ecalBadChs;
352 
353  // clasification of channels in tower construction: the category definition is
354  // affected by the setting in the configuration file
355  //
357 
358 
359  // the EE and EB collections for ecal anomalous cell info
360 
363 
365 
366  std::vector<HcalDetId> ids_;
367 };
368 
369 #endif
std::vector< double > theHBGrid
const EcalChannelStatus * theEcalChStatus
const HcalChannelQuality * theHcalChStatus
void setEcalChStatusFromDB(const EcalChannelStatus *s)
std::vector< std::pair< DetId, float > > metaConstituents
std::map< CaloTowerDetId, std::pair< short int, bool > > HcalDropChMap
std::vector< double > theHESGrid
std::vector< double > theHEDGrid
GlobalPoint emCrystalShwrPos(DetId detId, float fracDepth)
void assignHitHcal(const CaloRecHit *recHit)
std::vector< int > theEcalSeveritiesToBeUsedInBadTowers
GlobalPoint emShwrPos(const std::vector< std::pair< DetId, float > > &metaContains, float fracDepth, double totEmE)
void setHcalChStatusFromDB(const HcalChannelQuality *s)
std::vector< HcalDetId > ids_
Definition: weight.py:1
void finish(CaloTowerCollection &destCollection)
void setEeHandle(const edm::Handle< EcalRecHitCollection > ee)
edm::Handle< EcalRecHitCollection > theEeHandle
std::vector< double > theHOWeights
MetaTower & find(const CaloTowerDetId &id)
looks for a given tower in the internal cache. If it can&#39;t find it, it makes it.
std::vector< double > theEEGrid
void rescale(const CaloTower *ct)
std::vector< double > theEEWeights
std::vector< double > theHESWeights
void setGeometry(const CaloTowerTopology *cttopo, const CaloTowerConstituentsMap *ctmap, const HcalTopology *htopo, const CaloGeometry *geo)
GlobalPoint hadShwrPos(const std::vector< std::pair< DetId, float > > &metaContains, float fracDepth, double hadE)
void setEbHandle(const edm::Handle< EcalRecHitCollection > eb)
const CaloSubdetectorGeometry * theTowerGeometry
void setUseRejectedRecoveredEcalHits(bool flag)
unsigned int hcalChanStatusForCaloTower(const CaloRecHit *hit)
std::vector< double > theHF2Grid
std::vector< double > theHEDWeights
void rescaleTowers(const CaloTowerCollection &ctInput, CaloTowerCollection &ctResult)
const CaloGeometry * theGeometry
void setEcalSeveritiesToBeExcluded(const std::vector< int > &ecalSev)
void setHcalAcceptSeverityLevelForRejectedHit(unsigned int level)
GlobalPoint emShwrLogWeightPos(const std::vector< std::pair< DetId, float > > &metaContains, float fracDepth, double totEmE)
void setHcalSevLvlComputer(const HcalSeverityLevelComputer *c)
std::vector< double > theHOGrid
void assignHitEcal(const EcalRecHit *recHit)
adds a single hit to the tower
const CaloTowerConstituentsMap * theTowerConstituentsMap
void convert(const CaloTowerDetId &id, const MetaTower &mt, CaloTowerCollection &collection)
const CaloTowerTopology * theTowerTopology
void SetEcalSeveritiesToBeUsedInBadTowers(const std::vector< int > &ecalSev)
std::vector< double > theHF1Weights
void setRecoveredEcalHitsAreUsed(bool flag)
GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth)
bool theHOIsUsed
only affects energy and ET calculation. HO is still recorded in the tower
void process(const HBHERecHitCollection &hbhe)
std::vector< double > theHBWeights
const HcalSeverityLevelComputer * theHcalSevLvlComputer
Definition: DetId.h:18
std::vector< MetaTower > MetaTowerMap
GlobalPoint hadShwPosFromCells(DetId frontCell, DetId backCell, float fracDepth)
void setRecoveredHcalHitsAreUsed(bool flag)
void getThresholdAndWeight(const DetId &detId, double &threshold, double &weight) const
helper method to look up the appropriate threshold & weight
void setUseRejectedHitsOnly(bool flag)
const HcalTopology * theHcalTopology
void setMissingHcalRescaleFactorForEcal(float factor)
std::vector< int > theEcalSeveritiesToBeExcluded
std::vector< unsigned short > ecalBadChs
const EcalSeverityLevelAlgo * theEcalSevLvlAlgo
double a
Definition: hdecay.h:121
void setHcalAcceptSeverityLevel(unsigned int level)
std::vector< double > theHF1Grid
std::vector< double > theEBGrid
std::vector< double > theHF2Weights
void setEcalSevLvlAlgo(const EcalSeverityLevelAlgo *a)
void setUseRejectedRecoveredHcalHits(bool flag)
unsigned int theHcalAcceptSeverityLevelForRejectedHit
std::tuple< unsigned int, bool > ecalChanStatusForCaloTower(const EcalRecHit *hit)
HcalThreshold
GeV, ORCA value w/o selective readout.
std::vector< double > theEBWeights
edm::Handle< EcalRecHitCollection > theEbHandle