CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloTowersCreator.cc
Go to the documentation of this file.
7 // severity level for ECAL
10 
11 const std::vector<double>&
13 {
14  static std::vector<double> retval;
15 
16  if (retval.size() == 0)
17  {
18  retval.push_back(0.);
19  retval.push_back(10.);
20  retval.push_back(20.);
21  retval.push_back(30.);
22  retval.push_back(40.);
23  retval.push_back(50.);
24  retval.push_back(100.);
25  retval.push_back(1000.);
26  }
27 
28  return retval;
29 }
30 
31 
33  algo_(conf.getParameter<double>("EBThreshold"),
34  conf.getParameter<double>("EEThreshold"),
35 
36  conf.getParameter<bool>("UseEtEBTreshold"),
37  conf.getParameter<bool>("UseEtEETreshold"),
38  conf.getParameter<bool>("UseSymEBTreshold"),
39  conf.getParameter<bool>("UseSymEETreshold"),
40 
41 
42  conf.getParameter<double>("HcalThreshold"),
43  conf.getParameter<double>("HBThreshold"),
44  conf.getParameter<double>("HESThreshold"),
45  conf.getParameter<double>("HEDThreshold"),
46  conf.getParameter<double>("HOThreshold0"),
47  conf.getParameter<double>("HOThresholdPlus1"),
48  conf.getParameter<double>("HOThresholdMinus1"),
49  conf.getParameter<double>("HOThresholdPlus2"),
50  conf.getParameter<double>("HOThresholdMinus2"),
51  conf.getParameter<double>("HF1Threshold"),
52  conf.getParameter<double>("HF2Threshold"),
53  conf.getParameter<std::vector<double> >("EBGrid"),
54  conf.getParameter<std::vector<double> >("EBWeights"),
55  conf.getParameter<std::vector<double> >("EEGrid"),
56  conf.getParameter<std::vector<double> >("EEWeights"),
57  conf.getParameter<std::vector<double> >("HBGrid"),
58  conf.getParameter<std::vector<double> >("HBWeights"),
59  conf.getParameter<std::vector<double> >("HESGrid"),
60  conf.getParameter<std::vector<double> >("HESWeights"),
61  conf.getParameter<std::vector<double> >("HEDGrid"),
62  conf.getParameter<std::vector<double> >("HEDWeights"),
63  conf.getParameter<std::vector<double> >("HOGrid"),
64  conf.getParameter<std::vector<double> >("HOWeights"),
65  conf.getParameter<std::vector<double> >("HF1Grid"),
66  conf.getParameter<std::vector<double> >("HF1Weights"),
67  conf.getParameter<std::vector<double> >("HF2Grid"),
68  conf.getParameter<std::vector<double> >("HF2Weights"),
69  conf.getParameter<double>("EBWeight"),
70  conf.getParameter<double>("EEWeight"),
71  conf.getParameter<double>("HBWeight"),
72  conf.getParameter<double>("HESWeight"),
73  conf.getParameter<double>("HEDWeight"),
74  conf.getParameter<double>("HOWeight"),
75  conf.getParameter<double>("HF1Weight"),
76  conf.getParameter<double>("HF2Weight"),
77  conf.getParameter<double>("EcutTower"),
78  conf.getParameter<double>("EBSumThreshold"),
79  conf.getParameter<double>("EESumThreshold"),
80  conf.getParameter<bool>("UseHO"),
81  // (for momentum reconstruction algorithm)
82  conf.getParameter<int>("MomConstrMethod"),
83  conf.getParameter<double>("MomHBDepth"),
84  conf.getParameter<double>("MomHEDepth"),
85  conf.getParameter<double>("MomEBDepth"),
86  conf.getParameter<double>("MomEEDepth")
87  ),
88 
89  ecalLabels_(conf.getParameter<std::vector<edm::InputTag> >("ecalInputs")),
90  allowMissingInputs_(conf.getParameter<bool>("AllowMissingInputs")),
91 
92  theHcalAcceptSeverityLevel_(conf.getParameter<unsigned int>("HcalAcceptSeverityLevel")),
93 
94  theRecoveredHcalHitsAreUsed_(conf.getParameter<bool>("UseHcalRecoveredHits")),
95  theRecoveredEcalHitsAreUsed_(conf.getParameter<bool>("UseEcalRecoveredHits")),
96 
97  // paramaters controlling the use of rejected hits
98 
99  useRejectedHitsOnly_(conf.getParameter<bool>("UseRejectedHitsOnly")),
100 
101  theHcalAcceptSeverityLevelForRejectedHit_(conf.getParameter<unsigned int>("HcalAcceptSeverityLevelForRejectedHit")),
102 
103 
104  useRejectedRecoveredHcalHits_(conf.getParameter<bool>("UseRejectedRecoveredHcalHits")),
105  useRejectedRecoveredEcalHits_(conf.getParameter<bool>("UseRejectedRecoveredEcalHits"))
106 
107 
108 
109 {
110 
111  // register for data access
112  tok_hbhe_ = consumes<HBHERecHitCollection>(conf.getParameter<edm::InputTag>("hbheInput"));
113  tok_ho_ = consumes<HORecHitCollection>(conf.getParameter<edm::InputTag>("hoInput"));
114  tok_hf_ = consumes<HFRecHitCollection>(conf.getParameter<edm::InputTag>("hfInput"));
115 
116  const unsigned nLabels = ecalLabels_.size();
117  for ( unsigned i=0; i != nLabels; i++ )
118  toks_ecal_.push_back(consumes<EcalRecHitCollection>(ecalLabels_[i]));
119 
120 
129 
130  // get the Ecal severities to be excluded
131  const std::vector<std::string> severitynames =
132  conf.getParameter<std::vector<std::string> >("EcalRecHitSeveritiesToBeExcluded");
133 
134  theEcalSeveritiesToBeExcluded_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynames);
135 
136  // get the Ecal severities to be used for bad towers
138  StringToEnumValue<EcalSeverityLevel::SeverityLevel>(conf.getParameter<std::vector<std::string> >("EcalSeveritiesToBeUsedInBadTowers") );
139 
140  if (EScales.instanceLabel=="") produces<CaloTowerCollection>();
141  else produces<CaloTowerCollection>(EScales.instanceLabel);
142 }
143 
145  // get the necessary event setup objects...
149  c.get<CaloGeometryRecord>().get(pG);
150  c.get<IdealGeometryRecord>().get(htopo);
151  c.get<IdealGeometryRecord>().get(cttopo);
152 
153  // ECAL channel status map ****************************************
155  c.get<EcalChannelStatusRcd>().get( ecalChStatus );
156  const EcalChannelStatus* dbEcalChStatus = ecalChStatus.product();
157 
158  // HCAL channel status map ****************************************
159  edm::ESHandle<HcalChannelQuality> hcalChStatus;
160  c.get<HcalChannelQualityRcd>().get( hcalChStatus );
161  const HcalChannelQuality* dbHcalChStatus = hcalChStatus.product();
162 
163  if (!dbHcalChStatus->topo()) dbHcalChStatus->setTopo(htopo.product());
164 
165  // Assignment of severity levels **********************************
166  edm::ESHandle<HcalSeverityLevelComputer> hcalSevLvlComputerHndl;
167  c.get<HcalSeverityLevelComputerRcd>().get(hcalSevLvlComputerHndl);
168  const HcalSeverityLevelComputer* hcalSevLvlComputer = hcalSevLvlComputerHndl.product();
169 
170  edm::ESHandle<EcalSeverityLevelAlgo> ecalSevLvlAlgoHndl;
171  c.get<EcalSeverityLevelAlgoRcd>().get(ecalSevLvlAlgoHndl);
172  const EcalSeverityLevelAlgo* ecalSevLvlAlgo = ecalSevLvlAlgoHndl.product();
173 
174 
183  algo_.setGeometry(cttopo.product(),htopo.product(),pG.product());
184 
185  // for treatment of problematic and anomalous cells
186 
187  algo_.setHcalChStatusFromDB(dbHcalChStatus);
188  algo_.setEcalChStatusFromDB(dbEcalChStatus);
189 
192 
195 
196  algo_.setHcalSevLvlComputer(hcalSevLvlComputer);
197  algo_.setEcalSevLvlAlgo(ecalSevLvlAlgo);
198 
199 
201 
204 
207 
208 
209 
210 
211 
212  algo_.begin(); // clear the internal buffer
213 
214  // can't chain these in a big OR statement, or else it'll
215  // get triggered for each of the first three events
216  bool check1 = hcalSevLevelWatcher_.check(c);
217  bool check2 = hcalChStatusWatcher_.check(c);
218  bool check3 = caloTowerConstituentsWatcher_.check(c);
219  if(check1 || check2 || check3)
220  {
222  }
223 
224  // ----------------------------------------------------------
225  // For ecal error handling need to
226  // have access to the EB and EE collections at the end of
227  // tower reconstruction.
228 
231 
232  for (std::vector<edm::EDGetTokenT<EcalRecHitCollection> >::const_iterator i=toks_ecal_.begin();
233  i!=toks_ecal_.end(); i++) {
234 
236 
237  if (! e.getByToken(*i,ec_tmp) ) continue;
238  if (ec_tmp->size()==0) continue;
239 
240  // check if this is EB or EE
241  if ( (ec_tmp->begin()->detid()).subdetId() == EcalBarrel ) {
242  ebHandle = ec_tmp;
243  }
244  else if ((ec_tmp->begin()->detid()).subdetId() == EcalEndcap ) {
245  eeHandle = ec_tmp;
246  }
247 
248  }
249 
250  algo_.setEbHandle(ebHandle);
251  algo_.setEeHandle(eeHandle);
252 
253  //-----------------------------------------------------------
254 
255 
256 
257  bool present;
258 
259  // Step A/C: Get Inputs and process (repeatedly)
261  present=e.getByToken(tok_hbhe_,hbhe);
262  if (present || !allowMissingInputs_) algo_.process(*hbhe);
263 
265  present=e.getByToken(tok_ho_,ho);
266  if (present || !allowMissingInputs_) algo_.process(*ho);
267 
269  present=e.getByToken(tok_hf_,hf);
270  if (present || !allowMissingInputs_) algo_.process(*hf);
271 
272  std::vector<edm::EDGetTokenT<EcalRecHitCollection> >::const_iterator i;
273  for (i=toks_ecal_.begin(); i!=toks_ecal_.end(); i++) {
275  present=e.getByToken(*i,ec);
276  if (present || !allowMissingInputs_) algo_.process(*ec);
277  }
278 
279  // Step B: Create empty output
280  std::auto_ptr<CaloTowerCollection> prod(new CaloTowerCollection());
281 
282  // Step C: Process
283  algo_.finish(*prod);
284 
285  // Step D: Put into the event
286  if (EScales.instanceLabel=="") e.put(prod);
287  else e.put(prod,EScales.instanceLabel);
288 
289 
290 }
291 
CaloTowersCreator(const edm::ParameterSet &ps)
double HF2Scale
Definition: EScales.h:18
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
void setEcalChStatusFromDB(const EcalChannelStatus *s)
CaloTowersCreationAlgo algo_
double EEScale
Definition: EScales.h:12
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
void setHcalChStatusFromDB(const HcalChannelQuality *s)
void setTopo(const HcalTopology *topo) const
void finish(CaloTowerCollection &destCollection)
void setEeHandle(const edm::Handle< EcalRecHitCollection > ee)
double HOScale
Definition: EScales.h:16
std::vector< int > theEcalSeveritiesToBeExcluded_
double HF1Scale
Definition: EScales.h:17
edm::EDGetTokenT< HORecHitCollection > tok_ho_
double HEDScale
Definition: EScales.h:15
void setEbHandle(const edm::Handle< EcalRecHitCollection > eb)
void setUseRejectedRecoveredEcalHits(bool flag)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
void setEcalSeveritiesToBeExcluded(const std::vector< int > &ecalSev)
void setHcalAcceptSeverityLevelForRejectedHit(unsigned int level)
void setHcalSevLvlComputer(const HcalSeverityLevelComputer *c)
virtual void produce(edm::Event &e, const edm::EventSetup &c)
std::vector< edm::EDGetTokenT< EcalRecHitCollection > > toks_ecal_
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
void SetEcalSeveritiesToBeUsedInBadTowers(const std::vector< int > &ecalSev)
void setRecoveredEcalHitsAreUsed(bool flag)
double EBScale
Definition: EScales.h:11
double HBScale
Definition: EScales.h:13
edm::ESWatcher< HcalChannelQualityRcd > hcalChStatusWatcher_
tuple conf
Definition: dbtoconf.py:185
void process(const HBHERecHitCollection &hbhe)
std::string instanceLabel
Definition: EScales.h:19
unsigned int theHcalAcceptSeverityLevelForRejectedHit_
void setRecoveredHcalHitsAreUsed(bool flag)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
void setUseRejectedHitsOnly(bool flag)
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:58
unsigned int theHcalAcceptSeverityLevel_
edm::SortedCollection< CaloTower > CaloTowerCollection
Definition: CaloTowerFwd.h:15
void setHcalAcceptSeverityLevel(unsigned int level)
std::vector< edm::InputTag > ecalLabels_
double HESScale
Definition: EScales.h:14
edm::ESWatcher< HcalSeverityLevelComputerRcd > hcalSevLevelWatcher_
void setEcalSevLvlAlgo(const EcalSeverityLevelAlgo *a)
void setUseRejectedRecoveredHcalHits(bool flag)
edm::ESWatcher< IdealGeometryRecord > caloTowerConstituentsWatcher_
void setGeometry(const CaloTowerConstituentsMap *cttopo, const HcalTopology *htopo, const CaloGeometry *geo)
Definition: EScales.h:4
std::vector< int > theEcalSeveritiesToBeUsedInBadTowers_
static const std::vector< double > & getGridValues()
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
const HcalTopology * topo() const