CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 HESthreshold, double HEDthreshold,
63  double HOthreshold0, double HOthresholdPlus1, double HOthresholdMinus1,
64  double HOthresholdPlus2, double HOthresholdMinus2,
65  double HF1threshold, double HF2threshold,
66  double EBweight, double EEweight,
67  double HBweight, double HESweight, double HEDweight,
68  double HOweight, double HF1weight, double HF2weight,
69  double EcutTower, double EBSumThreshold, double EESumThreshold, bool useHO,
70  // (for momentum reconstruction algorithm)
71  int momConstrMethod,
72  double momHBDepth,
73  double momHEDepth,
74  double momEBDepth,
75  double momEEDepth,
76  int hcalPhase=0
77  );
78 
79  CaloTowersCreationAlgo(double EBthreshold, double EEthreshold,
80 
81  bool useEtEBTreshold, bool useEtEETreshold,
82  bool useSymEBTreshold, bool useSymEETreshold,
83 
84  double HcalThreshold,
85  double HBthreshold, double HESthreshold, double HEDthreshold,
86  double HOthreshold0, double HOthresholdPlus1, double HOthresholdMinus1,
87  double HOthresholdPlus2, double HOthresholdMinus2,
88  double HF1threshold, double HF2threshold,
89  const std::vector<double> & EBGrid, const std::vector<double> & EBWeights,
90  const std::vector<double> & EEGrid, const std::vector<double> & EEWeights,
91  const std::vector<double> & HBGrid, const std::vector<double> & HBWeights,
92  const std::vector<double> & HESGrid, const std::vector<double> & HESWeights,
93  const std::vector<double> & HEDGrid, const std::vector<double> & HEDWeights,
94  const std::vector<double> & HOGrid, const std::vector<double> & HOWeights,
95  const std::vector<double> & HF1Grid, const std::vector<double> & HF1Weights,
96  const std::vector<double> & HF2Grid, const std::vector<double> & HF2Weights,
97  double EBweight, double EEweight,
98  double HBweight, double HESweight, double HEDweight,
99  double HOweight, double HF1weight, double HF2weight,
100  double EcutTower, double EBSumThreshold, double EESumThreshold, bool useHO,
101  // (for momentum reconstruction algorithm)
102  int momConstrMethod,
103  double momHBDepth,
104  double momHEDepth,
105  double momEBDepth,
106  double momEEDepth,
107  int hcalPhase=0
108 );
109 
110  void setGeometry(const CaloTowerTopology* cttopo, const CaloTowerConstituentsMap* ctmap, const HcalTopology* htopo, const CaloGeometry* geo);
111 
112  // pass the containers of channels status from the event record (stored in DB)
113  // these are called in CaloTowersCreator
116 
117  // Kake a map of number of channels not used in RecHit production.
118  // The key is the calotower id.
119  void makeHcalDropChMap();
120 
121  void makeEcalBadChs();
122 
123  void begin();
124  void process(const HBHERecHitCollection& hbhe);
125  void process(const HORecHitCollection& ho);
126  void process(const HFRecHitCollection& hf);
127  void process(const EcalRecHitCollection& ecal);
128 
129 
130  void process(const CaloTowerCollection& ctc);
131 
132  void finish(CaloTowerCollection& destCollection);
133 
134  // modified rescale method
135  void rescaleTowers(const CaloTowerCollection& ctInput, CaloTowerCollection& ctResult);
136 
137  void setEBEScale(double scale);
138  void setEEEScale(double scale);
139  void setHBEScale(double scale);
140  void setHESEScale(double scale);
141  void setHEDEScale(double scale);
142  void setHOEScale(double scale);
143  void setHF1EScale(double scale);
144  void setHF2EScale(double scale);
145 
146 
147  // Assign to categories based on info from DB and RecHit status
148  // Called in assignHit to check if the energy should be added to
149  // calotower, and how to flag the channel
150  unsigned int hcalChanStatusForCaloTower(const CaloRecHit* hit);
151  std::tuple<unsigned int,bool> ecalChanStatusForCaloTower(const EcalRecHit* hit);
152 
153  // Channel flagging is based on acceptable severity levels specified in the
154  // configuration file. These methods are used to pass the values read in
155  // CaloTowersCreator
156  //
157  // from DB
159  void setEcalSeveritiesToBeExcluded(const std::vector<int>& ecalSev ) {theEcalSeveritiesToBeExcluded= ecalSev;}
160 
161  // flag to use recovered hits
164 
165  // severety level calculator for HCAL
167 
168  // severity level calculator for ECAL
170 
171 
172  // The following are needed for creating towers from rechits excluded from the ------------------------------------
173  // default reconstructions
174 
175  // NB! Controls if rejected hits shold be used instead of the default!!!
176  void setUseRejectedHitsOnly(bool flag) { useRejectedHitsOnly = flag; }
177 
179  // void setEcalAcceptSeverityLevelForRejectedHit(unsigned int level) {theEcalAcceptSeverityLevelForRejectedHit = level;}
180  void SetEcalSeveritiesToBeUsedInBadTowers(const std::vector<int>& ecalSev ) {theEcalSeveritiesToBeUsedInBadTowers= ecalSev;}
181 
182 
185 
186  //-------------------------------------------------------------------------------------------------------------------
187 
188 
189 
190  // set the EE EB handles
191 
194 
195 
196 
197 
198  // Add methods to get the seperate positions for ECAL/HCAL
199  // used in constructing the 4-vectors using new methods
200  GlobalPoint emCrystalShwrPos (DetId detId, float fracDepth);
201  GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth);
202  // "effective" point for the EM/HAD shower in CaloTower
203  // position based on non-zero energy cells
204  GlobalPoint hadShwrPos(const std::vector<std::pair<DetId,float> >& metaContains,
205  float fracDepth, double hadE);
206  GlobalPoint emShwrPos(const std::vector<std::pair<DetId,float> >& metaContains,
207  float fracDepth, double totEmE);
208 
209  // overloaded function to get had position based on all had cells in the tower
210  GlobalPoint hadShwrPos(CaloTowerDetId id, float fracDepth);
211  GlobalPoint hadShwPosFromCells(DetId frontCell, DetId backCell, float fracDepth);
212 
213  // for Chris
214  GlobalPoint emShwrLogWeightPos(const std::vector<std::pair<DetId,float> >& metaContains,
215  float fracDepth, double totEmE);
216 
217 
218 private:
219 
220  struct MetaTower {
222  bool empty() const { return metaConstituents.empty();}
223  // contains also energy of RecHit
224  std::vector< std::pair<DetId, float> > metaConstituents;
226  float E=0, E_em=0, E_had=0, E_outer=0;
227  float emSumTimeTimesE=0, hadSumTimeTimesE=0, emSumEForTime=0, hadSumEForTime=0; // Sum(Energy x Timing) : intermediate container
228 
229  // needed to set CaloTower status word
231 
232  };
233 
235  void assignHitEcal(const EcalRecHit* recHit);
236  void assignHitHcal(const CaloRecHit* recHit);
237 
238  void rescale(const CaloTower * ct);
239 
241  MetaTower & find(const CaloTowerDetId & id);
242 
244  void getThresholdAndWeight(const DetId & detId, double & threshold, double & weight) const;
245 
249 
250 
252 
256  std::vector<double> theEBGrid, theEBWeights;
257  std::vector<double> theEEGrid, theEEWeights;
258  std::vector<double> theHBGrid, theHBWeights;
259  std::vector<double> theHESGrid, theHESWeights;
260  std::vector<double> theHEDGrid, theHEDWeights;
261  std::vector<double> theHOGrid, theHOWeights;
262  std::vector<double> theHF1Grid, theHF1Weights;
263  std::vector<double> theHF2Grid, theHF2Weights;
267 
268  double theEBEScale;
269  double theEEEScale;
270  double theHBEScale;
271  double theHESEScale;
272  double theHEDEScale;
273  double theHOEScale;
274  double theHF1EScale;
275  double theHF2EScale;
281 
282  // for checking the status of ECAL and HCAL channels stored in the DB
285 
286  // calculator of severety level for HCAL
288 
289  // calculator for severity level for ECAL
291 
292 
293  // fields that hold the information passed from the CaloTowersCreator configuration file:
294  // controll what is considered bad/recovered/problematic channel for CaloTower purposes
295  //
298  // flag to use recovered hits
301 
302  // controls the tower reconstruction from rejected hits
303 
307 
308 
311 
312 
315 
316  // Switches and paramters for CaloTower 4-momentum assignment
317  // "depth" variables do not affect all algorithms
323 
324  // compactify timing info
325  int compactTime(float time);
326 
327  void convert(const CaloTowerDetId& id, const MetaTower& mt, CaloTowerCollection & collection);
328 
329 
330  // internal map
331  typedef std::vector<MetaTower> MetaTowerMap;
333  unsigned int theTowerMapSize=0;
334 
335  // Number of channels in the tower that were not used in RecHit production (dead/off,...).
336  // These channels are added to the other "bad" channels found in the recHit collection.
337  typedef std::map<CaloTowerDetId, int> HcalDropChMap;
339 
340  // Number of bad Ecal channel in each tower
341  //unsigned short ecalBadChs[CaloTowerDetId::kSizeForDenseIndexing];
342  std::vector<unsigned short> ecalBadChs;
343 
344  // clasification of channels in tower construction: the category definition is
345  // affected by the setting in the configuration file
346  //
348 
349 
350  // the EE and EB collections for ecal anomalous cell info
351 
354 
355  //store merged depths for tower 28/29
356  std::vector<int> mergedDepths;
357 
359 
360 
361 };
362 
363 #endif
std::vector< double > theHBGrid
const EcalChannelStatus * theEcalChStatus
const HcalChannelQuality * theHcalChStatus
void setEcalChStatusFromDB(const EcalChannelStatus *s)
std::vector< std::pair< DetId, float > > metaConstituents
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)
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::map< CaloTowerDetId, int > HcalDropChMap
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)
tuple HcalThreshold
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)
tuple EBSumThreshold
std::vector< int > mergedDepths
bool theHOIsUsed
only affects energy and ET calculation. HO is still recorded in the tower
tuple EESumThreshold
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 &amp; weight
void setUseRejectedHitsOnly(bool flag)
const HcalTopology * theHcalTopology
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
tuple level
Definition: testEve_cfg.py:34
std::vector< double > theHF2Weights
void setEcalSevLvlAlgo(const EcalSeverityLevelAlgo *a)
int weight
Definition: histoStyle.py:50
void setUseRejectedRecoveredHcalHits(bool flag)
unsigned int theHcalAcceptSeverityLevelForRejectedHit
std::tuple< unsigned int, bool > ecalChanStatusForCaloTower(const EcalRecHit *hit)
std::vector< double > theEBWeights
edm::Handle< EcalRecHitCollection > theEbHandle