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.
6 // severity level for ECAL
9 
10 
12  algo_(conf.getParameter<double>("EBThreshold"),
13  conf.getParameter<double>("EEThreshold"),
14 
15  conf.getParameter<bool>("UseEtEBTreshold"),
16  conf.getParameter<bool>("UseEtEETreshold"),
17  conf.getParameter<bool>("UseSymEBTreshold"),
18  conf.getParameter<bool>("UseSymEETreshold"),
19 
20 
21  conf.getParameter<double>("HcalThreshold"),
22  conf.getParameter<double>("HBThreshold"),
23  conf.getParameter<double>("HESThreshold"),
24  conf.getParameter<double>("HEDThreshold"),
25  conf.getParameter<double>("HOThreshold0"),
26  conf.getParameter<double>("HOThresholdPlus1"),
27  conf.getParameter<double>("HOThresholdMinus1"),
28  conf.getParameter<double>("HOThresholdPlus2"),
29  conf.getParameter<double>("HOThresholdMinus2"),
30  conf.getParameter<double>("HF1Threshold"),
31  conf.getParameter<double>("HF2Threshold"),
32  conf.getParameter<std::vector<double> >("EBGrid"),
33  conf.getParameter<std::vector<double> >("EBWeights"),
34  conf.getParameter<std::vector<double> >("EEGrid"),
35  conf.getParameter<std::vector<double> >("EEWeights"),
36  conf.getParameter<std::vector<double> >("HBGrid"),
37  conf.getParameter<std::vector<double> >("HBWeights"),
38  conf.getParameter<std::vector<double> >("HESGrid"),
39  conf.getParameter<std::vector<double> >("HESWeights"),
40  conf.getParameter<std::vector<double> >("HEDGrid"),
41  conf.getParameter<std::vector<double> >("HEDWeights"),
42  conf.getParameter<std::vector<double> >("HOGrid"),
43  conf.getParameter<std::vector<double> >("HOWeights"),
44  conf.getParameter<std::vector<double> >("HF1Grid"),
45  conf.getParameter<std::vector<double> >("HF1Weights"),
46  conf.getParameter<std::vector<double> >("HF2Grid"),
47  conf.getParameter<std::vector<double> >("HF2Weights"),
48  conf.getParameter<double>("EBWeight"),
49  conf.getParameter<double>("EEWeight"),
50  conf.getParameter<double>("HBWeight"),
51  conf.getParameter<double>("HESWeight"),
52  conf.getParameter<double>("HEDWeight"),
53  conf.getParameter<double>("HOWeight"),
54  conf.getParameter<double>("HF1Weight"),
55  conf.getParameter<double>("HF2Weight"),
56  conf.getParameter<double>("EcutTower"),
57  conf.getParameter<double>("EBSumThreshold"),
58  conf.getParameter<double>("EESumThreshold"),
59  conf.getParameter<bool>("UseHO"),
60  // (for momentum reconstruction algorithm)
61  conf.getParameter<int>("MomConstrMethod"),
62  conf.getParameter<double>("MomHBDepth"),
63  conf.getParameter<double>("MomHEDepth"),
64  conf.getParameter<double>("MomEBDepth"),
65  conf.getParameter<double>("MomEEDepth")
66  ),
67 
68  ecalLabels_(conf.getParameter<std::vector<edm::InputTag> >("ecalInputs")),
69  allowMissingInputs_(conf.getParameter<bool>("AllowMissingInputs")),
70 
71  theHcalAcceptSeverityLevel_(conf.getParameter<unsigned int>("HcalAcceptSeverityLevel")),
72 
73  theRecoveredHcalHitsAreUsed_(conf.getParameter<bool>("UseHcalRecoveredHits")),
74  theRecoveredEcalHitsAreUsed_(conf.getParameter<bool>("UseEcalRecoveredHits")),
75 
76  // paramaters controlling the use of rejected hits
77 
78  useRejectedHitsOnly_(conf.getParameter<bool>("UseRejectedHitsOnly")),
79 
80  theHcalAcceptSeverityLevelForRejectedHit_(conf.getParameter<unsigned int>("HcalAcceptSeverityLevelForRejectedHit")),
81 
82 
83  useRejectedRecoveredHcalHits_(conf.getParameter<bool>("UseRejectedRecoveredHcalHits")),
84  useRejectedRecoveredEcalHits_(conf.getParameter<bool>("UseRejectedRecoveredEcalHits"))
85 
86 
87 
88 {
89 
90  // register for data access
91  tok_hbhe_ = consumes<HBHERecHitCollection>(conf.getParameter<edm::InputTag>("hbheInput"));
92  tok_ho_ = consumes<HORecHitCollection>(conf.getParameter<edm::InputTag>("hoInput"));
93  tok_hf_ = consumes<HFRecHitCollection>(conf.getParameter<edm::InputTag>("hfInput"));
94 
95  const unsigned nLabels = ecalLabels_.size();
96  for ( unsigned i=0; i != nLabels; i++ )
97  toks_ecal_.push_back(consumes<EcalRecHitCollection>(ecalLabels_[i]));
98 
99 
108 
109  // get the Ecal severities to be excluded
110  const std::vector<std::string> severitynames =
111  conf.getParameter<std::vector<std::string> >("EcalRecHitSeveritiesToBeExcluded");
112 
113  theEcalSeveritiesToBeExcluded_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynames);
114 
115  // get the Ecal severities to be used for bad towers
117  StringToEnumValue<EcalSeverityLevel::SeverityLevel>(conf.getParameter<std::vector<std::string> >("EcalSeveritiesToBeUsedInBadTowers") );
118 
119  if (eScales_.instanceLabel=="") produces<CaloTowerCollection>();
120  else produces<CaloTowerCollection>(eScales_.instanceLabel);
121 
122  /*
123  std::cout << "VI Producer "
124  << (useRejectedHitsOnly_ ? "use rejectOnly " : " ")
125  << (allowMissingInputs_ ? "allowMissing " : " " )
126  << nLabels << ' ' << severitynames.size()
127  << std::endl;
128  */
129 }
130 
132  // get the necessary event setup objects...
136  c.get<CaloGeometryRecord>().get(pG);
137  c.get<IdealGeometryRecord>().get(htopo);
138  c.get<IdealGeometryRecord>().get(cttopo);
139 
140  // ECAL channel status map ****************************************
142  c.get<EcalChannelStatusRcd>().get( ecalChStatus );
143  const EcalChannelStatus* dbEcalChStatus = ecalChStatus.product();
144 
145  // HCAL channel status map ****************************************
146  edm::ESHandle<HcalChannelQuality> hcalChStatus;
147  c.get<HcalChannelQualityRcd>().get( "withTopo", hcalChStatus );
148 
149  const HcalChannelQuality* dbHcalChStatus = hcalChStatus.product();
150 
151  // Assignment of severity levels **********************************
152  edm::ESHandle<HcalSeverityLevelComputer> hcalSevLvlComputerHndl;
153  c.get<HcalSeverityLevelComputerRcd>().get(hcalSevLvlComputerHndl);
154  const HcalSeverityLevelComputer* hcalSevLvlComputer = hcalSevLvlComputerHndl.product();
155 
156  edm::ESHandle<EcalSeverityLevelAlgo> ecalSevLvlAlgoHndl;
157  c.get<EcalSeverityLevelAlgoRcd>().get(ecalSevLvlAlgoHndl);
158  const EcalSeverityLevelAlgo* ecalSevLvlAlgo = ecalSevLvlAlgoHndl.product();
159 
160 
169  algo_.setGeometry(cttopo.product(),htopo.product(),pG.product());
170 
171  // for treatment of problematic and anomalous cells
172 
173  algo_.setHcalChStatusFromDB(dbHcalChStatus);
174  algo_.setEcalChStatusFromDB(dbEcalChStatus);
175 
178 
181 
182  algo_.setHcalSevLvlComputer(hcalSevLvlComputer);
183  algo_.setEcalSevLvlAlgo(ecalSevLvlAlgo);
184 
185 
187 
190 
193 
194  /*
195  std::cout << "VI Produce: "
196  << (useRejectedHitsOnly_ ? "use rejectOnly " : " ")
197  << (allowMissingInputs_ ? "allowMissing " : " " )
198  << (theRecoveredEcalHitsAreUsed_ ? "use RecoveredEcal ": " " )
199  << toks_ecal_.size()
200  << ' ' << theEcalSeveritiesToBeExcluded_.size()
201  << ' ' << theEcalSeveritiesToBeUsedInBadTowers_.size()
202  << std::endl;
203  */
204 
205  algo_.begin(); // clear the internal buffer
206 
207  // can't chain these in a big OR statement, or else it'll
208  // get triggered for each of the first three events
209  bool check1 = hcalSevLevelWatcher_.check(c);
210  bool check2 = hcalChStatusWatcher_.check(c);
211  bool check3 = caloTowerConstituentsWatcher_.check(c);
212  if(check1 || check2 || check3)
213  {
215  }
216 
217  // check ecal SevLev
219 
220  // ----------------------------------------------------------
221  // For ecal error handling need to
222  // have access to the EB and EE collections at the end of
223  // tower reconstruction.
224 
227 
228  for (std::vector<edm::EDGetTokenT<EcalRecHitCollection> >::const_iterator i=toks_ecal_.begin();
229  i!=toks_ecal_.end(); i++) {
230 
232 
233  if (! e.getByToken(*i,ec_tmp) ) continue;
234  if (ec_tmp->size()==0) continue;
235 
236  // check if this is EB or EE
237  if ( (ec_tmp->begin()->detid()).subdetId() == EcalBarrel ) {
238  ebHandle = ec_tmp;
239  }
240  else if ((ec_tmp->begin()->detid()).subdetId() == EcalEndcap ) {
241  eeHandle = ec_tmp;
242  }
243  }
244 
245  algo_.setEbHandle(ebHandle);
246  algo_.setEeHandle(eeHandle);
247 
248  //-----------------------------------------------------------
249 
250  bool present;
251 
252  // Step A/C: Get Inputs and process (repeatedly)
254  present=e.getByToken(tok_hbhe_,hbhe);
255  if (present || !allowMissingInputs_) algo_.process(*hbhe);
256 
258  present=e.getByToken(tok_ho_,ho);
259  if (present || !allowMissingInputs_) algo_.process(*ho);
260 
262  present=e.getByToken(tok_hf_,hf);
263  if (present || !allowMissingInputs_) algo_.process(*hf);
264 
265  std::vector<edm::EDGetTokenT<EcalRecHitCollection> >::const_iterator i;
266  for (i=toks_ecal_.begin(); i!=toks_ecal_.end(); i++) {
268  present=e.getByToken(*i,ec);
269  if (present || !allowMissingInputs_) algo_.process(*ec);
270  }
271 
272  // Step B: Create empty output
273  std::auto_ptr<CaloTowerCollection> prod(new CaloTowerCollection());
274 
275  // Step C: Process
276  algo_.finish(*prod);
277 
278  /*
279  int totc=0; float totE=0;
280  reco::LeafCandidate::LorentzVector totP4;
281  for (auto const & tw : (*prod) ) { totc += tw.constituents().size(); totE+=tw.energy(); totP4+=tw.p4();}
282  std::cout << "VI " << (*prod).size() << " " << totc << " " << totE << " " << totP4 << std::endl;
283  */
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
algo_(conf.existsAs< bool >("Correct")?conf.getParameter< bool >("Correct"):true, conf.getParameter< double >("e9e25Cut"), conf.getParameter< double >("intercept2DCut"), conf.existsAs< bool >("intercept2DSlope")?conf.getParameter< double >("intercept2DSlope"):defaultSlope2D_, conf.getParameter< std::vector< double > >("e1e9Cut"), conf.getParameter< std::vector< double > >("eCOREe9Cut"), conf.getParameter< std::vector< double > >("eSeLCut"), hfvars_)
void setEcalChStatusFromDB(const EcalChannelStatus *s)
CaloTowersCreationAlgo algo_
double EEScale
Definition: EScales.h:12
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
void setHcalChStatusFromDB(const HcalChannelQuality *s)
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:113
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:86
void setUseRejectedHitsOnly(bool flag)
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
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)
std::vector< int > theEcalSeveritiesToBeUsedInBadTowers_
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
edm::ESWatcher< EcalSeverityLevelAlgoRcd > ecalSevLevelWatcher_