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 HcalTopology;
31 class CaloGeometry;
34 class CaloRecHit;
35 class DetId;
36 
42 //
43 // Modify MetaTower to save energy of rechits for use in tower 4-momentum assignment,
44 // added containers for timing assignment and for holding status information.
45 // Anton Anastassov (Northwestern)
46 //
47 
49 public:
50 
51  int nalgo=-1;
52 
54 
55  CaloTowersCreationAlgo(double EBthreshold, double EEthreshold,
56 
57  bool useEtEBTreshold, bool useEtEETreshold,
58  bool useSymEBTreshold, bool useSymEETreshold,
59 
60  double HcalThreshold,
61  double HBthreshold, double HESthreshold, double HEDthreshold,
62  double HOthreshold0, double HOthresholdPlus1, double HOthresholdMinus1,
63  double HOthresholdPlus2, double HOthresholdMinus2,
64  double HF1threshold, double HF2threshold,
65  double EBweight, double EEweight,
66  double HBweight, double HESweight, double HEDweight,
67  double HOweight, double HF1weight, double HF2weight,
68  double EcutTower, double EBSumThreshold, double EESumThreshold, bool useHO,
69  // (for momentum reconstruction algorithm)
70  int momConstrMethod,
71  double momHBDepth,
72  double momHEDepth,
73  double momEBDepth,
74  double momEEDepth
75  );
76 
77  CaloTowersCreationAlgo(double EBthreshold, double EEthreshold,
78 
79  bool useEtEBTreshold, bool useEtEETreshold,
80  bool useSymEBTreshold, bool useSymEETreshold,
81 
82  double HcalThreshold,
83  double HBthreshold, double HESthreshold, double HEDthreshold,
84  double HOthreshold0, double HOthresholdPlus1, double HOthresholdMinus1,
85  double HOthresholdPlus2, double HOthresholdMinus2,
86  double HF1threshold, double HF2threshold,
87  const std::vector<double> & EBGrid, const std::vector<double> & EBWeights,
88  const std::vector<double> & EEGrid, const std::vector<double> & EEWeights,
89  const std::vector<double> & HBGrid, const std::vector<double> & HBWeights,
90  const std::vector<double> & HESGrid, const std::vector<double> & HESWeights,
91  const std::vector<double> & HEDGrid, const std::vector<double> & HEDWeights,
92  const std::vector<double> & HOGrid, const std::vector<double> & HOWeights,
93  const std::vector<double> & HF1Grid, const std::vector<double> & HF1Weights,
94  const std::vector<double> & HF2Grid, const std::vector<double> & HF2Weights,
95  double EBweight, double EEweight,
96  double HBweight, double HESweight, double HEDweight,
97  double HOweight, double HF1weight, double HF2weight,
98  double EcutTower, double EBSumThreshold, double EESumThreshold, bool useHO,
99  // (for momentum reconstruction algorithm)
100  int momConstrMethod,
101  double momHBDepth,
102  double momHEDepth,
103  double momEBDepth,
104  double momEEDepth
105 );
106 
107  void setGeometry(const CaloTowerConstituentsMap* cttopo, const HcalTopology* htopo, const CaloGeometry* geo);
108 
109  // pass the containers of channels status from the event record (stored in DB)
110  // these are called in CaloTowersCreator
113 
114  // Kake a map of number of channels not used in RecHit production.
115  // The key is the calotower id.
116  void makeHcalDropChMap();
117 
118  void makeEcalBadChs();
119 
120  void begin();
121  void process(const HBHERecHitCollection& hbhe);
122  void process(const HORecHitCollection& ho);
123  void process(const HFRecHitCollection& hf);
124  void process(const EcalRecHitCollection& ecal);
125 
126 
127  void process(const CaloTowerCollection& ctc);
128 
129  void finish(CaloTowerCollection& destCollection);
130 
131  // modified rescale method
132  void rescaleTowers(const CaloTowerCollection& ctInput, CaloTowerCollection& ctResult);
133 
134  void setEBEScale(double scale);
135  void setEEEScale(double scale);
136  void setHBEScale(double scale);
137  void setHESEScale(double scale);
138  void setHEDEScale(double scale);
139  void setHOEScale(double scale);
140  void setHF1EScale(double scale);
141  void setHF2EScale(double scale);
142 
143 
144  // Assign to categories based on info from DB and RecHit status
145  // Called in assignHit to check if the energy should be added to
146  // calotower, and how to flag the channel
147  unsigned int hcalChanStatusForCaloTower(const CaloRecHit* hit);
148  std::tuple<unsigned int,bool> ecalChanStatusForCaloTower(const EcalRecHit* hit);
149 
150  // Channel flagging is based on acceptable severity levels specified in the
151  // configuration file. These methods are used to pass the values read in
152  // CaloTowersCreator
153  //
154  // from DB
156  void setEcalSeveritiesToBeExcluded(const std::vector<int>& ecalSev ) {theEcalSeveritiesToBeExcluded= ecalSev;}
157 
158  // flag to use recovered hits
161 
162  // severety level calculator for HCAL
164 
165  // severity level calculator for ECAL
167 
168 
169  // The following are needed for creating towers from rechits excluded from the ------------------------------------
170  // default reconstructions
171 
172  // NB! Controls if rejected hits shold be used instead of the default!!!
173  void setUseRejectedHitsOnly(bool flag) { useRejectedHitsOnly = flag; }
174 
176  // void setEcalAcceptSeverityLevelForRejectedHit(unsigned int level) {theEcalAcceptSeverityLevelForRejectedHit = level;}
177  void SetEcalSeveritiesToBeUsedInBadTowers(const std::vector<int>& ecalSev ) {theEcalSeveritiesToBeUsedInBadTowers= ecalSev;}
178 
179 
182 
183  //-------------------------------------------------------------------------------------------------------------------
184 
185 
186 
187  // set the EE EB handles
188 
191 
192 
193 
194 
195  // Add methods to get the seperate positions for ECAL/HCAL
196  // used in constructing the 4-vectors using new methods
197  GlobalPoint emCrystalShwrPos (DetId detId, float fracDepth);
198  GlobalPoint hadSegmentShwrPos(DetId detId, float fracDepth);
199  // "effective" point for the EM/HAD shower in CaloTower
200  // position based on non-zero energy cells
201  GlobalPoint hadShwrPos(const std::vector<std::pair<DetId,float> >& metaContains,
202  float fracDepth, double hadE);
203  GlobalPoint emShwrPos(const std::vector<std::pair<DetId,float> >& metaContains,
204  float fracDepth, double totEmE);
205 
206  // overloaded function to get had position based on all had cells in the tower
207  GlobalPoint hadShwrPos(CaloTowerDetId id, float fracDepth);
208  GlobalPoint hadShwPosFromCells(DetId frontCell, DetId backCell, float fracDepth);
209 
210  // for Chris
211  GlobalPoint emShwrLogWeightPos(const std::vector<std::pair<DetId,float> >& metaContains,
212  float fracDepth, double totEmE);
213 
214 
215 private:
216 
217  struct MetaTower {
219  bool empty() const { return metaConstituents.empty();}
220  // contains also energy of RecHit
221  std::vector< std::pair<DetId, float> > metaConstituents;
223  float E=0, E_em=0, E_had=0, E_outer=0;
224  float emSumTimeTimesE=0, hadSumTimeTimesE=0, emSumEForTime=0, hadSumEForTime=0; // Sum(Energy x Timing) : intermediate container
225 
226  // needed to set CaloTower status word
228 
229  };
230 
232  void assignHitEcal(const EcalRecHit* recHit);
233  void assignHitHcal(const CaloRecHit* recHit);
234 
235  void rescale(const CaloTower * ct);
236 
238  MetaTower & find(const CaloTowerDetId & id);
239 
241  void getThresholdAndWeight(const DetId & detId, double & threshold, double & weight) const;
242 
246 
247 
249 
253  std::vector<double> theEBGrid, theEBWeights;
254  std::vector<double> theEEGrid, theEEWeights;
255  std::vector<double> theHBGrid, theHBWeights;
256  std::vector<double> theHESGrid, theHESWeights;
257  std::vector<double> theHEDGrid, theHEDWeights;
258  std::vector<double> theHOGrid, theHOWeights;
259  std::vector<double> theHF1Grid, theHF1Weights;
260  std::vector<double> theHF2Grid, theHF2Weights;
264 
265  double theEBEScale;
266  double theEEEScale;
267  double theHBEScale;
268  double theHESEScale;
269  double theHEDEScale;
270  double theHOEScale;
271  double theHF1EScale;
272  double theHF2EScale;
277 
278  // for checking the status of ECAL and HCAL channels stored in the DB
281 
282  // calculator of severety level for HCAL
284 
285  // calculator for severity level for ECAL
287 
288 
289  // fields that hold the information passed from the CaloTowersCreator configuration file:
290  // controll what is considered bad/recovered/problematic channel for CaloTower purposes
291  //
294  // flag to use recovered hits
297 
298  // controls the tower reconstruction from rejected hits
299 
303 
304 
307 
308 
311 
312  // Switches and paramters for CaloTower 4-momentum assignment
313  // "depth" variables do not affect all algorithms
319 
320  // compactify timing info
321  int compactTime(float time);
322 
323  void convert(const CaloTowerDetId& id, const MetaTower& mt, CaloTowerCollection & collection);
324 
325 
326  // internal map
327  typedef std::vector<MetaTower> MetaTowerMap;
329  unsigned int theTowerMapSize=0;
330 
331  // Number of channels in the tower that were not used in RecHit production (dead/off,...).
332  // These channels are added to the other "bad" channels found in the recHit collection.
333  typedef std::map<CaloTowerDetId, int> HcalDropChMap;
335 
336  // Number of bad Ecal channel in each tower
338 
339  // clasification of channels in tower construction: the category definition is
340  // affected by the setting in the configuration file
341  //
343 
344 
345  // the EE and EB collections for ecal anomalous cell info
346 
349 
350 
351 
352 };
353 
354 #endif
std::vector< double > theHBGrid
const EcalChannelStatus * theEcalChStatus
unsigned short ecalBadChs[CaloTowerDetId::kSizeForDenseIndexing]
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
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)
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)
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 &amp; weight
void setUseRejectedHitsOnly(bool flag)
const HcalTopology * theHcalTopology
std::vector< int > theEcalSeveritiesToBeExcluded
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)
void setGeometry(const CaloTowerConstituentsMap *cttopo, const HcalTopology *htopo, const CaloGeometry *geo)
std::vector< double > theEBWeights
edm::Handle< EcalRecHitCollection > theEbHandle