CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
HcalHitReconstructor Class Reference

#include <HcalHitReconstructor.h>

Inheritance diagram for HcalHitReconstructor:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginRun (edm::Run &r, edm::EventSetup const &es)
 
virtual void endRun (edm::Run &r, edm::EventSetup const &es)
 
 HcalHitReconstructor (const edm::ParameterSet &ps)
 
virtual void produce (edm::Event &e, const edm::EventSetup &c)
 
virtual ~HcalHitReconstructor ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

bool correctTiming_
 
DetId::Detector det_
 
bool dropZSmarkedPassed_
 
int firstAuxTS_
 
int firstSample_
 
HBHEStatusBitSetterhbheFlagSetter_
 
HBHETimeProfileStatusBitSetterhbheHSCPFlagSetter_
 
HBHEPulseShapeFlagSetterhbhePulseShapeFlagSetter_
 
HBHETimingShapedFlagSetterhbheTimingShapedFlagSetter_
 
HcalHFStatusBitFromDigishfdigibit_
 
HcalHF_PETalgorithmhfPET_
 
HcalHF_S9S1algorithmhfS8S1_
 
HcalHF_S9S1algorithmhfS9S1_
 
HFTimingTrustFlagHFTimingTrustFlagSetter_
 
edm::InputTag inputLabel_
 
HcalRecoParamsparamTS
 
HcalSimpleRecAlgo reco_
 
int samplesToAdd_
 
HcalADCSaturationFlagsaturationFlagSetter_
 
bool setHSCPFlags_
 
bool setNoiseFlags_
 
bool setPulseShapeFlags_
 
bool setSaturationFlags_
 
bool setTimingTrustFlags_
 
int subdet_
 
HcalOtherSubdetector subdetOther_
 
bool tsFromDB_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Date:
2011/05/10 16:06:10
Revision:
1.13.10.1
Author
J. Temple & E. Yazgan Based on HcalSimpleReconstructor.h by J. Mans

Definition at line 37 of file HcalHitReconstructor.h.

Constructor & Destructor Documentation

HcalHitReconstructor::HcalHitReconstructor ( const edm::ParameterSet ps)
explicit

Definition at line 20 of file HcalHitReconstructor.cc.

References DetId::Calo, gather_cfg::cout, det_, edm::ParameterSet::getParameter(), hbheFlagSetter_, hbheHSCPFlagSetter_, hbhePulseShapeFlagSetter_, hbheTimingShapedFlagSetter_, HcalBarrel, HcalCalibration, HcalForward, HcalOther, HcalOuter, hfdigibit_, hfPET_, hfS8S1_, hfS9S1_, HFTimingTrustFlagSetter_, saturationFlagSetter_, setHSCPFlags_, setNoiseFlags_, setPulseShapeFlags_, setSaturationFlags_, setTimingTrustFlags_, subdet_, HcalZDCDetId::SubdetectorId, and subdetOther_.

20  :
21  reco_(conf.getParameter<bool>("correctForTimeslew"),
22  conf.getParameter<bool>("correctForPhaseContainment"),
23  conf.getParameter<double>("correctionPhaseNS")),
25  inputLabel_(conf.getParameter<edm::InputTag>("digiLabel")),
26  correctTiming_(conf.getParameter<bool>("correctTiming")),
27  setNoiseFlags_(conf.getParameter<bool>("setNoiseFlags")),
28  setHSCPFlags_(conf.getParameter<bool>("setHSCPFlags")),
29  setSaturationFlags_(conf.getParameter<bool>("setSaturationFlags")),
30  setTimingTrustFlags_(conf.getParameter<bool>("setTimingTrustFlags")),
31  setPulseShapeFlags_(conf.getParameter<bool>("setPulseShapeFlags")),
32  dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed")),
33  firstAuxTS_(conf.getParameter<int>("firstAuxTS")),
34  firstSample_(conf.getParameter<int>("firstSample")),
35  samplesToAdd_(conf.getParameter<int>("samplesToAdd")),
36  tsFromDB_(conf.getParameter<bool>("tsFromDB"))
37 {
38 
39  std::string subd=conf.getParameter<std::string>("Subdetector");
40  //Set all FlagSetters to 0
41  /* Important to do this! Otherwise, if the setters are turned off,
42  the "if (XSetter_) delete XSetter_;" commands can crash
43  */
44  hbheFlagSetter_ = 0;
48  hfdigibit_ = 0;
49 
50  hfS9S1_ = 0;
51  hfS8S1_ = 0;
52  hfPET_ = 0;
55 
57  {
58  const edm::ParameterSet& pssat = conf.getParameter<edm::ParameterSet>("saturationParameters");
59  saturationFlagSetter_ = new HcalADCSaturationFlag(pssat.getParameter<int>("maxADCvalue"));
60  }
61 
62  if (!strcasecmp(subd.c_str(),"HBHE")) {
64  bool timingShapedCutsFlags = conf.getParameter<bool>("setTimingShapedCutsFlags");
65  if (timingShapedCutsFlags)
66  {
67  const edm::ParameterSet& psTshaped = conf.getParameter<edm::ParameterSet>("timingshapedcutsParameters");
68  hbheTimingShapedFlagSetter_ = new HBHETimingShapedFlagSetter(psTshaped.getParameter<std::vector<double> >("tfilterEnvelope"),
69  psTshaped.getParameter<bool>("ignorelowest"),
70  psTshaped.getParameter<bool>("ignorehighest"),
71  psTshaped.getParameter<double>("win_offset"),
72  psTshaped.getParameter<double>("win_gain"));
73  }
74 
75  if (setNoiseFlags_)
76  {
77  const edm::ParameterSet& psdigi =conf.getParameter<edm::ParameterSet>("flagParameters");
78  hbheFlagSetter_=new HBHEStatusBitSetter(psdigi.getParameter<double>("nominalPedestal"),
79  psdigi.getParameter<double>("hitEnergyMinimum"),
80  psdigi.getParameter<int>("hitMultiplicityThreshold"),
81  psdigi.getParameter<std::vector<edm::ParameterSet> >("pulseShapeParameterSets")
82  );
83  } // if (setNoiseFlags_)
84  if (setHSCPFlags_)
85  {
86  const edm::ParameterSet& psHSCP = conf.getParameter<edm::ParameterSet>("hscpParameters");
88  psHSCP.getParameter<double>("r1Max"),
89  psHSCP.getParameter<double>("r2Min"),
90  psHSCP.getParameter<double>("r2Max"),
91  psHSCP.getParameter<double>("fracLeaderMin"),
92  psHSCP.getParameter<double>("fracLeaderMax"),
93  psHSCP.getParameter<double>("slopeMin"),
94  psHSCP.getParameter<double>("slopeMax"),
95  psHSCP.getParameter<double>("outerMin"),
96  psHSCP.getParameter<double>("outerMax"),
97  psHSCP.getParameter<double>("TimingEnergyThreshold"));
98  } // if (setHSCPFlags_)
100  {
101  const edm::ParameterSet &psPulseShape = conf.getParameter<edm::ParameterSet>("pulseShapeParameters");
103  psPulseShape.getParameter<double>("MinimumChargeThreshold"),
104  psPulseShape.getParameter<double>("TS4TS5ChargeThreshold"),
105  psPulseShape.getParameter<unsigned int>("TrianglePeakTS"),
106  psPulseShape.getParameter<std::vector<double> >("LinearThreshold"),
107  psPulseShape.getParameter<std::vector<double> >("LinearCut"),
108  psPulseShape.getParameter<std::vector<double> >("RMS8MaxThreshold"),
109  psPulseShape.getParameter<std::vector<double> >("RMS8MaxCut"),
110  psPulseShape.getParameter<std::vector<double> >("LeftSlopeThreshold"),
111  psPulseShape.getParameter<std::vector<double> >("LeftSlopeCut"),
112  psPulseShape.getParameter<std::vector<double> >("RightSlopeThreshold"),
113  psPulseShape.getParameter<std::vector<double> >("RightSlopeCut"),
114  psPulseShape.getParameter<std::vector<double> >("RightSlopeSmallThreshold"),
115  psPulseShape.getParameter<std::vector<double> >("RightSlopeSmallCut"),
116  psPulseShape.getParameter<std::vector<double> >("TS4TS5LowerThreshold"),
117  psPulseShape.getParameter<std::vector<double> >("TS4TS5LowerCut"),
118  psPulseShape.getParameter<std::vector<double> >("TS4TS5UpperThreshold"),
119  psPulseShape.getParameter<std::vector<double> >("TS4TS5UpperCut"),
120  psPulseShape.getParameter<bool>("UseDualFit"),
121  psPulseShape.getParameter<bool>("TriangleIgnoreSlow"));
122  } // if (setPulseShapeFlags_)
123 
124  produces<HBHERecHitCollection>();
125  } else if (!strcasecmp(subd.c_str(),"HO")) {
127  produces<HORecHitCollection>();
128  } else if (!strcasecmp(subd.c_str(),"HF")) {
130 
131  if (setTimingTrustFlags_) {
132 
133  const edm::ParameterSet& pstrust = conf.getParameter<edm::ParameterSet>("hfTimingTrustParameters");
134  HFTimingTrustFlagSetter_=new HFTimingTrustFlag(pstrust.getParameter<int>("hfTimingTrustLevel1"),
135  pstrust.getParameter<int>("hfTimingTrustLevel2"));
136  }
137 
138  if (setNoiseFlags_)
139  {
140  const edm::ParameterSet& psdigi =conf.getParameter<edm::ParameterSet>("digistat");
141  const edm::ParameterSet& psTimeWin =conf.getParameter<edm::ParameterSet>("HFInWindowStat");
142  hfdigibit_=new HcalHFStatusBitFromDigis(psdigi,psTimeWin);
143 
144  const edm::ParameterSet& psS9S1 = conf.getParameter<edm::ParameterSet>("S9S1stat");
145  hfS9S1_ = new HcalHF_S9S1algorithm(psS9S1.getParameter<std::vector<double> >("short_optimumSlope"),
146  psS9S1.getParameter<std::vector<double> >("shortEnergyParams"),
147  psS9S1.getParameter<std::vector<double> >("shortETParams"),
148  psS9S1.getParameter<std::vector<double> >("long_optimumSlope"),
149  psS9S1.getParameter<std::vector<double> >("longEnergyParams"),
150  psS9S1.getParameter<std::vector<double> >("longETParams"),
151  psS9S1.getParameter<int>("flagsToSkip"),
152  psS9S1.getParameter<bool>("isS8S1")
153  );
154 
155  const edm::ParameterSet& psS8S1 = conf.getParameter<edm::ParameterSet>("S8S1stat");
156  hfS8S1_ = new HcalHF_S9S1algorithm(psS8S1.getParameter<std::vector<double> >("short_optimumSlope"),
157  psS8S1.getParameter<std::vector<double> >("shortEnergyParams"),
158  psS8S1.getParameter<std::vector<double> >("shortETParams"),
159  psS8S1.getParameter<std::vector<double> >("long_optimumSlope"),
160  psS8S1.getParameter<std::vector<double> >("longEnergyParams"),
161  psS8S1.getParameter<std::vector<double> >("longETParams"),
162  psS8S1.getParameter<int>("flagsToSkip"),
163  psS8S1.getParameter<bool>("isS8S1")
164  );
165 
166  const edm::ParameterSet& psPET = conf.getParameter<edm::ParameterSet>("PETstat");
167  hfPET_ = new HcalHF_PETalgorithm(psPET.getParameter<std::vector<double> >("short_R"),
168  psPET.getParameter<std::vector<double> >("shortEnergyParams"),
169  psPET.getParameter<std::vector<double> >("shortETParams"),
170  psPET.getParameter<std::vector<double> >("long_R"),
171  psPET.getParameter<std::vector<double> >("longEnergyParams"),
172  psPET.getParameter<std::vector<double> >("longETParams"),
173  psPET.getParameter<int>("flagsToSkip"),
174  psPET.getParameter<std::vector<double> >("short_R_29"),
175  psPET.getParameter<std::vector<double> >("long_R_29")
176  );
177  }
178  produces<HFRecHitCollection>();
179  } else if (!strcasecmp(subd.c_str(),"ZDC")) {
182  produces<ZDCRecHitCollection>();
183  } else if (!strcasecmp(subd.c_str(),"CALIB")) {
186  produces<HcalCalibRecHitCollection>();
187  } else {
188  std::cout << "HcalHitReconstructor is not associated with a specific subdetector!" << std::endl;
189  }
190 
191 }
T getParameter(std::string const &) const
HcalADCSaturationFlag * saturationFlagSetter_
HcalHFStatusBitFromDigis * hfdigibit_
tuple conf
Definition: dbtoconf.py:185
HcalHF_PETalgorithm * hfPET_
HcalHF_S9S1algorithm * hfS9S1_
HBHEPulseShapeFlagSetter * hbhePulseShapeFlagSetter_
static const int SubdetectorId
Definition: HcalZDCDetId.h:22
HBHEStatusBitSetter * hbheFlagSetter_
HBHETimeProfileStatusBitSetter * hbheHSCPFlagSetter_
HBHETimingShapedFlagSetter * hbheTimingShapedFlagSetter_
HcalHF_S9S1algorithm * hfS8S1_
HcalOtherSubdetector subdetOther_
tuple cout
Definition: gather_cfg.py:41
HFTimingTrustFlag * HFTimingTrustFlagSetter_
HcalSimpleRecAlgo reco_
HcalHitReconstructor::~HcalHitReconstructor ( )
virtual

Definition at line 193 of file HcalHitReconstructor.cc.

References hbheFlagSetter_, hbheHSCPFlagSetter_, hbhePulseShapeFlagSetter_, hfdigibit_, hfPET_, and hfS9S1_.

193  {
194  if (hbheFlagSetter_) delete hbheFlagSetter_;
195  if (hfdigibit_) delete hfdigibit_;
198  if (hfS9S1_) delete hfS9S1_;
199  if (hfPET_) delete hfPET_;
200 }
HcalHFStatusBitFromDigis * hfdigibit_
HcalHF_PETalgorithm * hfPET_
HcalHF_S9S1algorithm * hfS9S1_
HBHEPulseShapeFlagSetter * hbhePulseShapeFlagSetter_
HBHEStatusBitSetter * hbheFlagSetter_
HBHETimeProfileStatusBitSetter * hbheHSCPFlagSetter_

Member Function Documentation

void HcalHitReconstructor::beginRun ( edm::Run r,
edm::EventSetup const &  es 
)
virtual

Reimplemented from edm::EDProducer.

Definition at line 202 of file HcalHitReconstructor.cc.

References edm::EventSetup::get(), L1TEmulatorMonitor_cff::p, paramTS, edm::ESHandle< class >::product(), and tsFromDB_.

202  {
203  if ( tsFromDB_==true)
204  {
206  es.get<HcalRecoParamsRcd>().get(p);
207  paramTS = new HcalRecoParams(*p.product());
208  }
209 }
HcalRecoParams * paramTS
T const * product() const
Definition: ESHandle.h:62
void HcalHitReconstructor::endRun ( edm::Run r,
edm::EventSetup const &  es 
)
virtual

Reimplemented from edm::EDProducer.

Definition at line 211 of file HcalHitReconstructor.cc.

References paramTS, and tsFromDB_.

211  {
212  if (tsFromDB_==true)
213  {
214  if (paramTS) delete paramTS;
215  }
216 }
HcalRecoParams * paramTS
void HcalHitReconstructor::produce ( edm::Event e,
const edm::EventSetup c 
)
virtual

Implements edm::EDProducer.

Definition at line 219 of file HcalHitReconstructor.cc.

References abs, HBHEStatusBitSetter::Clear(), HcalTimingCorrector::Correct(), correctTiming_, det_, HcalSeverityLevelComputer::dropChannel(), dropZSmarkedPassed_, HBHETimeProfileStatusBitSetter::EnergyThreshold(), first, firstAuxTS_, HcalRecoParam::firstSample(), firstSample_, edm::EventSetup::get(), edm::Event::getByLabel(), HcalChannelStatus::getValue(), HcalCondObjectContainer< Item >::getValues(), hbheFlagSetter_, hbheHSCPFlagSetter_, hbhePulseShapeFlagSetter_, HBHETimeProfileStatusBitSetter::hbheSetTimeFlagsFromDigi(), hbheTimingShapedFlagSetter_, DetId::Hcal, HcalBarrel, HcalCalibration, HcalEndcap, HcalForward, HcalOther, HcalOuter, hfdigibit_, hfPET_, hfS8S1_, hfS9S1_, HcalHFStatusBitFromDigis::hfSetFlagFromDigi(), HcalHF_PETalgorithm::HFSetFlagFromPET(), HcalHF_S9S1algorithm::HFSetFlagFromS9S1(), HFTimingTrustFlagSetter_, i, HcalSimpleRecAlgo::initPulseCorr(), inputLabel_, edm::EventBase::isRealData(), j, gen::k, L1TEmulatorMonitor_cff::p, paramTS, HcalCaloFlagLabels::PresampleADC, edm::ESHandle< class >::product(), edm::Event::put(), DetId::rawId(), reco_, HcalSimpleRecAlgo::reconstruct(), HcalHFStatusBitFromDigis::resetFlagTimeSamples(), HcalRecoParam::samplesToAdd(), samplesToAdd_, saturationFlagSetter_, HBHEStatusBitSetter::SetFlagsFromDigi(), HBHEStatusBitSetter::SetFlagsFromRecHits(), HcalSimpleRecAlgo::setForData(), HFTimingTrustFlag::setHFTimingTrustFlag(), setHSCPFlags_, setNoiseFlags_, HBHEPulseShapeFlagSetter::SetPulseShapeFlags(), setPulseShapeFlags_, HcalADCSaturationFlag::setSaturationFlag(), setSaturationFlags_, HBHETimingShapedFlagSetter::SetTimingShapedFlags(), setTimingTrustFlags_, subdet_, subdetOther_, and tsFromDB_.

220 {
221 
222  // get conditions
223  edm::ESHandle<HcalDbService> conditions;
224  eventSetup.get<HcalDbRecord>().get(conditions);
225  const HcalQIEShape* shape = conditions->getHcalShape (); // this one is generic
226  // HACK related to HB- corrections
227  if(e.isRealData()) reco_.setForData();
228 
230  eventSetup.get<HcalChannelQualityRcd>().get(p);
231  HcalChannelQuality* myqual = new HcalChannelQuality(*p.product());
232 
234  eventSetup.get<HcalSeverityLevelComputerRcd>().get(mycomputer);
235  const HcalSeverityLevelComputer* mySeverity = mycomputer.product();
236 
237  if (det_==DetId::Hcal) {
238 
239  // HBHE -------------------------------------------------------------------
242 
243  e.getByLabel(inputLabel_,digi);
244 
245  // create empty output
246  std::auto_ptr<HBHERecHitCollection> rec(new HBHERecHitCollection);
247  rec->reserve(digi->size());
248  // run the algorithm
251  std::vector<HBHEDataFrame> HBDigis;
252  std::vector<int> RecHitIndex;
253 
254  // Vote on majority TS0 CapId
255  int favorite_capid = 0;
256  if (correctTiming_) {
257  long capid_votes[4] = {0,0,0,0};
258  for (i=digi->begin(); i!=digi->end(); i++) {
259  capid_votes[(*i)[0].capid()]++;
260  }
261  for (int k = 0; k < 4; k++)
262  if (capid_votes[k] > capid_votes[favorite_capid])
263  favorite_capid = k;
264  }
265 
266  int toaddMem = 0;
267  int first = firstSample_;
268  int toadd = samplesToAdd_;
269 
270  for (i=digi->begin(); i!=digi->end(); i++) {
271  HcalDetId cell = i->id();
272  DetId detcell=(DetId)cell;
273 
274  // check on cells to be ignored and dropped: (rof,20.Feb.09)
275  const HcalChannelStatus* mydigistatus=myqual->getValues(detcell.rawId());
276  if (mySeverity->dropChannel(mydigistatus->getValue() ) ) continue;
278  if (i->zsMarkAndPass()) continue;
279 
280  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
281  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
282  HcalCoderDb coder (*channelCoder, *shape);
283 
284  // firstSample & samplesToAdd
285  if(tsFromDB_) {
286  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
287  first = param_ts->firstSample();
288  toadd = param_ts->samplesToAdd();
289  }
290  if(toaddMem != toadd) {
291  reco_.initPulseCorr(toadd);
292  toaddMem = toadd;
293  }
294 
295  rec->push_back(reco_.reconstruct(*i,first,toadd,coder,calibrations));
296 
297  // Set auxiliary flag
298  int auxflag=0;
299  int fTS = firstAuxTS_;
300  if (fTS<0) fTS=0; // silly protection against time slice <0
301  for (int xx=fTS; xx<fTS+4 && xx<i->size();++xx)
302  auxflag+=(i->sample(xx).adc())<<(7*(xx-fTS)); // store the time slices in the first 28 bits of aux, a set of 4 7-bit adc values
303  // bits 28 and 29 are reserved for capid of the first time slice saved in aux
304  auxflag+=((i->sample(fTS).capid())<<28);
305  (rec->back()).setAux(auxflag);
306 
307  (rec->back()).setFlags(0); // this sets all flag bits to 0
308  // Set presample flag
309  if (fTS>0)
310  (rec->back()).setFlagField((i->sample(fTS-1).adc()), HcalCaloFlagLabels::PresampleADC,7);
311 
314  if (setNoiseFlags_)
315  hbheFlagSetter_->SetFlagsFromDigi(rec->back(),*i,coder,calibrations,first,toadd);
316  if (setPulseShapeFlags_ == true)
317  hbhePulseShapeFlagSetter_->SetPulseShapeFlags(rec->back(), *i, coder, calibrations);
320  if (correctTiming_)
321  HcalTimingCorrector::Correct(rec->back(), *i, favorite_capid);
322  if (setHSCPFlags_ && i->id().ietaAbs()<16)
323  {
324  double DigiEnergy=0;
325  for(int j=0; j!=i->size(); DigiEnergy += i->sample(j++).nominal_fC());
326  if(DigiEnergy > hbheHSCPFlagSetter_->EnergyThreshold())
327  {
328  HBDigis.push_back(*i);
329  RecHitIndex.push_back(rec->size()-1);
330  }
331 
332  } // if (set HSCPFlags_ && |ieta|<16)
333  } // loop over HBHE digis
334 
335 
337  if (setHSCPFlags_) hbheHSCPFlagSetter_->hbheSetTimeFlagsFromDigi(rec.get(), HBDigis, RecHitIndex);
338  // return result
339  e.put(rec);
340 
341  // HO ------------------------------------------------------------------
342  } else if (subdet_==HcalOuter) {
344  e.getByLabel(inputLabel_,digi);
345 
346  // create empty output
347  std::auto_ptr<HORecHitCollection> rec(new HORecHitCollection);
348  rec->reserve(digi->size());
349  // run the algorithm
351 
352  // Vote on majority TS0 CapId
353  int favorite_capid = 0;
354  if (correctTiming_) {
355  long capid_votes[4] = {0,0,0,0};
356  for (i=digi->begin(); i!=digi->end(); i++) {
357  capid_votes[(*i)[0].capid()]++;
358  }
359  for (int k = 0; k < 4; k++)
360  if (capid_votes[k] > capid_votes[favorite_capid])
361  favorite_capid = k;
362  }
363 
364  int toaddMem = 0;
365  int first = firstSample_;
366  int toadd = samplesToAdd_;
367 
368  for (i=digi->begin(); i!=digi->end(); i++) {
369  HcalDetId cell = i->id();
370  DetId detcell=(DetId)cell;
371  // check on cells to be ignored and dropped: (rof,20.Feb.09)
372  const HcalChannelStatus* mydigistatus=myqual->getValues(detcell.rawId());
373  if (mySeverity->dropChannel(mydigistatus->getValue() ) ) continue;
375  if (i->zsMarkAndPass()) continue;
376 
377  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
378  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
379  HcalCoderDb coder (*channelCoder, *shape);
380 
381  // firstSample & samplesToAdd
382  if(tsFromDB_) {
383  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
384  first = param_ts->firstSample();
385  toadd = param_ts->samplesToAdd();
386  }
387  if(toaddMem != toadd) {
388  reco_.initPulseCorr(toadd);
389  toaddMem = toadd;
390  }
391  rec->push_back(reco_.reconstruct(*i,first,toadd,coder,calibrations));
392 
393  // Set auxiliary flag
394  int auxflag=0;
395  int fTS = firstAuxTS_;
396  if (fTS<0) fTS=0; //silly protection against negative time slice values
397  for (int xx=fTS; xx<fTS+4 && xx<i->size();++xx)
398  auxflag+=(i->sample(xx).adc())<<(7*(xx-fTS)); // store the time slices in the first 28 bits of aux, a set of 4 7-bit adc values
399  // bits 28 and 29 are reserved for capid of the first time slice saved in aux
400  auxflag+=((i->sample(fTS).capid())<<28);
401  (rec->back()).setAux(auxflag);
402 
403  (rec->back()).setFlags(0);
404  // Fill Presample ADC flag
405  if (fTS>0)
406  (rec->back()).setFlagField((i->sample(fTS-1).adc()), HcalCaloFlagLabels::PresampleADC,7);
407 
410  if (correctTiming_)
411  HcalTimingCorrector::Correct(rec->back(), *i, favorite_capid);
412  }
413  // return result
414  e.put(rec);
415 
416  // HF -------------------------------------------------------------------
417  } else if (subdet_==HcalForward) {
419  e.getByLabel(inputLabel_,digi);
420 
421 
423  // create empty output
424  std::auto_ptr<HFRecHitCollection> rec(new HFRecHitCollection);
425  rec->reserve(digi->size());
426  // run the algorithm
428 
429  // Vote on majority TS0 CapId
430  int favorite_capid = 0;
431  if (correctTiming_) {
432  long capid_votes[4] = {0,0,0,0};
433  for (i=digi->begin(); i!=digi->end(); i++) {
434  capid_votes[(*i)[0].capid()]++;
435  }
436  for (int k = 0; k < 4; k++)
437  if (capid_votes[k] > capid_votes[favorite_capid])
438  favorite_capid = k;
439  }
440 
441  int toaddMem = 0;
442  int first = firstSample_;
443  int toadd = samplesToAdd_;
444 
445  for (i=digi->begin(); i!=digi->end(); i++) {
446  HcalDetId cell = i->id();
447  DetId detcell=(DetId)cell;
448  // check on cells to be ignored and dropped: (rof,20.Feb.09)
449  const HcalChannelStatus* mydigistatus=myqual->getValues(detcell.rawId());
450  if (mySeverity->dropChannel(mydigistatus->getValue() ) ) continue;
452  if (i->zsMarkAndPass()) continue;
453 
454  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
455  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
456  HcalCoderDb coder (*channelCoder, *shape);
457 
458  // firstSample & samplesToAdd
459  if(tsFromDB_) {
460  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
461  first = param_ts->firstSample();
462  toadd = param_ts->samplesToAdd();
463  }
464  if(toaddMem != toadd) {
465  reco_.initPulseCorr(toadd);
466  toaddMem = toadd;
467  }
468 
469  // Digi parameters depending on Reco ones from DB
470  if (first ==3 && toadd == 4) { // 2010 data cfgs
471  firstAuxTS_=3;
472  // Provide firstSample, samplesToAdd, expected peak for digi flag
473  // (This can be different from rechit value!)
474  if (hfdigibit_!=0)
476  } // 2010 data; firstSample = 3; samplesToAdd =4
477  else if (first == 4 && toadd == 2) // 2011 data cfgs, 10-TS digis
478  {
479  firstAuxTS_=3;
480  if (hfdigibit_!=0)
482  } // 2010 data; firstSample = 4; samplesToAdd =2
483  else if (first == 2 && toadd == 2) // 2011 data cfgs; 6-TS digis
484  {
485  firstAuxTS_=1;
486  if (hfdigibit_!=0)
488  } // 2010 data; firstSample = 2; samplesToAdd =2
489 
490 
491  rec->push_back(reco_.reconstruct(*i,first,toadd,coder,calibrations));
492 
493  // Set auxiliary flag
494  int auxflag=0;
495  int fTS = firstAuxTS_;
496  if (fTS<0) fTS=0; // silly protection against negative time slice values
497  for (int xx=fTS; xx<fTS+4 && xx<i->size();++xx)
498  auxflag+=(i->sample(xx).adc())<<(7*(xx-fTS)); // store the time slices in the first 28 bits of aux, a set of 4 7-bit adc values
499  // bits 28 and 29 are reserved for capid of the first time slice saved in aux
500  auxflag+=((i->sample(fTS).capid())<<28);
501  (rec->back()).setAux(auxflag);
502 
503  // Clear flags
504  (rec->back()).setFlags(0);
505 
506  // Fill Presample ADC flag
507  if (fTS>0)
508  (rec->back()).setFlagField((i->sample(fTS-1).adc()), HcalCaloFlagLabels::PresampleADC,7);
509 
510  // This calls the code for setting the HF noise bit determined from digi shape
511  if (setNoiseFlags_)
512  hfdigibit_->hfSetFlagFromDigi(rec->back(),*i,coder,calibrations);
517  if (correctTiming_)
518  HcalTimingCorrector::Correct(rec->back(), *i, favorite_capid);
519  } // for (i=digi->begin(); i!=digi->end(); i++) -- loop on all HF digis
520 
521  // The following flags require the full set of rechits
522  // These need to be set consecutively, so an energy check should be the first
523  // test performed on these hits (to minimize the loop time)
524  if (setNoiseFlags_)
525  {
526  // Step 1: Set PET flag (short fibers of |ieta|==29)
527  // Neighbor/partner channels that are flagged by Pulse Shape algorithm (HFDigiTime)
528  // won't be considered in these calculations
529  for (HFRecHitCollection::iterator i = rec->begin();i!=rec->end();++i)
530  {
531  int depth=i->id().depth();
532  int ieta=i->id().ieta();
533  // Short fibers and all channels at |ieta|=29 use PET settings in Algo 3
534  if (depth==2 || abs(ieta)==29 )
535  hfPET_->HFSetFlagFromPET(*i,*rec,myqual,mySeverity);
536  }
537 
538  // Step 2: Set S8S1 flag (short fibers or |ieta|==29)
539  for (HFRecHitCollection::iterator i = rec->begin();i!=rec->end();++i)
540  {
541  int depth=i->id().depth();
542  int ieta=i->id().ieta();
543  // Short fibers and all channels at |ieta|=29 use PET settings in Algo 3
544  if (depth==2 || abs(ieta)==29 )
545  hfS8S1_->HFSetFlagFromS9S1(*i,*rec,myqual,mySeverity);
546  }
547 
548  // Set 3: Set S9S1 flag (long fibers)
549  for (HFRecHitCollection::iterator i = rec->begin();i!=rec->end();++i)
550  {
551  int depth=i->id().depth();
552  int ieta=i->id().ieta();
553  // Short fibers and all channels at |ieta|=29 use PET settings in Algo 3
554  if (depth==1 && abs(ieta)!=29 )
555  hfS9S1_->HFSetFlagFromS9S1(*i,*rec,myqual, mySeverity);
556  }
557  }
558 
559  // return result
560  e.put(rec);
561  } else if (subdet_==HcalOther && subdetOther_==HcalCalibration) {
563  e.getByLabel(inputLabel_,digi);
564 
565  // create empty output
566  std::auto_ptr<HcalCalibRecHitCollection> rec(new HcalCalibRecHitCollection);
567  rec->reserve(digi->size());
568  // run the algorithm
569  int toaddMem = 0;
570  int first = firstSample_;
571  int toadd = samplesToAdd_;
572 
574  for (i=digi->begin(); i!=digi->end(); i++) {
575  HcalCalibDetId cell = i->id();
576  // HcalDetId cellh = i->id();
577  DetId detcell=(DetId)cell;
578  // check on cells to be ignored and dropped: (rof,20.Feb.09)
579  const HcalChannelStatus* mydigistatus=myqual->getValues(detcell.rawId());
580  if (mySeverity->dropChannel(mydigistatus->getValue() ) ) continue;
582  if (i->zsMarkAndPass()) continue;
583 
584  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
585  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
586  HcalCoderDb coder (*channelCoder, *shape);
587 
588  // firstSample & samplesToAdd
589  if(tsFromDB_) {
590  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
591  first = param_ts->firstSample();
592  toadd = param_ts->samplesToAdd();
593  }
594  if(toaddMem != toadd) {
595  reco_.initPulseCorr(toadd);
596  toaddMem = toadd;
597  }
598  rec->push_back(reco_.reconstruct(*i,first,toadd,coder,calibrations));
599 
600  /*
601  // Flag setting not available for calibration rechits
602  // Set auxiliary flag
603  int auxflag=0;
604  int fTS = firstAuxTS_;
605  for (int xx=fTS; xx<fTS+4 && xx<i->size();++xx)
606  auxflag+=(i->sample(xx).adc())<<(7*(xx-fTS)); // store the time slices in the first 28 bits of aux, a set of 4 7-bit adc values
607  // bits 28 and 29 are reserved for capid of the first time slice saved in aux
608  auxflag+=((i->sample(fTS).capid())<<28);
609  (rec->back()).setAux(auxflag);
610 
611  (rec->back()).setFlags(0); // Not yet implemented for HcalCalibRecHit
612  */
613  }
614  // return result
615  e.put(rec);
616  }
617  }
618 
619  delete myqual;
620 } // void HcalHitReconstructor::produce(...)
unsigned int firstSample() const
Definition: HcalRecoParam.h:21
int i
Definition: DBlmapReader.cc:9
HcalRecoParams * paramTS
HBHERecHit reconstruct(const HBHEDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
void hbheSetTimeFlagsFromDigi(HBHERecHitCollection *, std::vector< HBHEDataFrame >, std::vector< int >)
void setHFTimingTrustFlag(HFRecHit &rechit, const HFDataFrame &digi)
HcalADCSaturationFlag * saturationFlagSetter_
void hfSetFlagFromDigi(HFRecHit &hf, const HFDataFrame &digi, const HcalCoder &coder, const HcalCalibrations &calib)
std::vector< T >::const_iterator const_iterator
#define abs(x)
Definition: mlp_lapack.h:159
bool isRealData() const
Definition: EventBase.h:60
void SetFlagsFromDigi(HBHERecHit &hbhe, const HBHEDataFrame &digi, const HcalCoder &coder, const HcalCalibrations &calib, int firstSample=3, int samplesToAdd=4)
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
void HFSetFlagFromPET(HFRecHit &hf, HFRecHitCollection &rec, HcalChannelQuality *myqual, const HcalSeverityLevelComputer *mySeverity)
void resetFlagTimeSamples(int firstSample, int samplesToAdd, int expectedPeak)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
HcalHFStatusBitFromDigis * hfdigibit_
int j
Definition: DBlmapReader.cc:9
void initPulseCorr(int toadd)
bool dropChannel(const uint32_t &mystatus) const
void setSaturationFlag(HBHERecHit &rechit, const HBHEDataFrame &digi)
unsigned int samplesToAdd() const
Definition: HcalRecoParam.h:22
bool first
Definition: L1TdeRCT.cc:79
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
std::vector< T >::iterator iterator
int k[5][pyjets_maxn]
HcalHF_PETalgorithm * hfPET_
Definition: DetId.h:20
void HFSetFlagFromS9S1(HFRecHit &hf, HFRecHitCollection &rec, HcalChannelQuality *myqual, const HcalSeverityLevelComputer *mySeverity)
HcalHF_S9S1algorithm * hfS9S1_
HBHEPulseShapeFlagSetter * hbhePulseShapeFlagSetter_
void SetTimingShapedFlags(HBHERecHit &hbhe)
T const * product() const
Definition: ESHandle.h:62
HBHEStatusBitSetter * hbheFlagSetter_
HBHETimeProfileStatusBitSetter * hbheHSCPFlagSetter_
HBHETimingShapedFlagSetter * hbheTimingShapedFlagSetter_
HcalHF_S9S1algorithm * hfS8S1_
HcalOtherSubdetector subdetOther_
static void Correct(HBHERecHit &rechit, const HBHEDataFrame &digi, int favorite_capid)
void SetPulseShapeFlags(HBHERecHit &hbhe, const HBHEDataFrame &digi, const HcalCoder &coder, const HcalCalibrations &calib)
HFTimingTrustFlag * HFTimingTrustFlagSetter_
uint32_t getValue() const
const Item * getValues(DetId fId) const
void SetFlagsFromRecHits(HBHERecHitCollection &rec)
HcalSimpleRecAlgo reco_

Member Data Documentation

bool HcalHitReconstructor::correctTiming_
private

Definition at line 62 of file HcalHitReconstructor.h.

Referenced by produce().

DetId::Detector HcalHitReconstructor::det_
private

Definition at line 57 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

bool HcalHitReconstructor::dropZSmarkedPassed_
private

Definition at line 68 of file HcalHitReconstructor.h.

Referenced by produce().

int HcalHitReconstructor::firstAuxTS_
private

Definition at line 70 of file HcalHitReconstructor.h.

Referenced by produce().

int HcalHitReconstructor::firstSample_
private

Definition at line 74 of file HcalHitReconstructor.h.

Referenced by produce().

HBHEStatusBitSetter* HcalHitReconstructor::hbheFlagSetter_
private

Definition at line 48 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), produce(), and ~HcalHitReconstructor().

HBHETimeProfileStatusBitSetter* HcalHitReconstructor::hbheHSCPFlagSetter_
private

Definition at line 49 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), produce(), and ~HcalHitReconstructor().

HBHEPulseShapeFlagSetter* HcalHitReconstructor::hbhePulseShapeFlagSetter_
private

Definition at line 51 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), produce(), and ~HcalHitReconstructor().

HBHETimingShapedFlagSetter* HcalHitReconstructor::hbheTimingShapedFlagSetter_
private

Definition at line 50 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

HcalHFStatusBitFromDigis* HcalHitReconstructor::hfdigibit_
private

Definition at line 52 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), produce(), and ~HcalHitReconstructor().

HcalHF_PETalgorithm* HcalHitReconstructor::hfPET_
private

Definition at line 55 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), produce(), and ~HcalHitReconstructor().

HcalHF_S9S1algorithm* HcalHitReconstructor::hfS8S1_
private

Definition at line 54 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

HcalHF_S9S1algorithm* HcalHitReconstructor::hfS9S1_
private

Definition at line 53 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), produce(), and ~HcalHitReconstructor().

HFTimingTrustFlag* HcalHitReconstructor::HFTimingTrustFlagSetter_
private

Definition at line 47 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

edm::InputTag HcalHitReconstructor::inputLabel_
private

Definition at line 60 of file HcalHitReconstructor.h.

Referenced by produce().

HcalRecoParams* HcalHitReconstructor::paramTS
private

Definition at line 78 of file HcalHitReconstructor.h.

Referenced by beginRun(), endRun(), and produce().

HcalSimpleRecAlgo HcalHitReconstructor::reco_
private

Definition at line 45 of file HcalHitReconstructor.h.

Referenced by produce().

int HcalHitReconstructor::samplesToAdd_
private

Definition at line 75 of file HcalHitReconstructor.h.

Referenced by produce().

HcalADCSaturationFlag* HcalHitReconstructor::saturationFlagSetter_
private

Definition at line 46 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

bool HcalHitReconstructor::setHSCPFlags_
private

Definition at line 64 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

bool HcalHitReconstructor::setNoiseFlags_
private

Definition at line 63 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

bool HcalHitReconstructor::setPulseShapeFlags_
private

Definition at line 67 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

bool HcalHitReconstructor::setSaturationFlags_
private

Definition at line 65 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

bool HcalHitReconstructor::setTimingTrustFlags_
private

Definition at line 66 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

int HcalHitReconstructor::subdet_
private

Definition at line 58 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

HcalOtherSubdetector HcalHitReconstructor::subdetOther_
private

Definition at line 59 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

bool HcalHitReconstructor::tsFromDB_
private

Definition at line 76 of file HcalHitReconstructor.h.

Referenced by beginRun(), endRun(), and produce().