CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
HcalHitReconstructor Class Reference

#include <HcalHitReconstructor.h>

Inheritance diagram for HcalHitReconstructor:
edm::stream::EDProducer<>

Public Member Functions

void beginRun (edm::Run const &r, edm::EventSetup const &es) final
 
void endRun (edm::Run const &r, edm::EventSetup const &es) final
 
 HcalHitReconstructor (const edm::ParameterSet &ps)
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 
 ~HcalHitReconstructor () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Types

typedef void(HcalSimpleRecAlgo::* SetCorrectionFcn) (boost::shared_ptr< AbsOOTPileupCorrection >)
 

Private Attributes

std::string cat_
 
bool correctTiming_
 
std::string corrName_
 
std::string dataOOTCorrectionCategory_
 
std::string dataOOTCorrectionName_
 
DetId::Detector det_
 
bool digiTimeFromDB_
 
bool dropZSmarkedPassed_
 
int firstAuxTS_
 
int firstSample_
 
HcalHFStatusBitFromDigishfdigibit_
 
std::unique_ptr< HcalFlagHFDigiTimeParamsHFDigiTimeParams
 
HcalHF_PETalgorithmhfPET_
 
HcalHF_S9S1algorithmhfS8S1_
 
HcalHF_S9S1algorithmhfS9S1_
 
HFTimingTrustFlagHFTimingTrustFlagSetter_
 
edm::InputTag inputLabel_
 
std::string mcOOTCorrectionCategory_
 
std::string mcOOTCorrectionName_
 
HcalRecoParamsparamTS
 
HcalSimpleRecAlgo reco_
 
bool recoParamsFromDB_
 
int samplesToAdd_
 
HcalADCSaturationFlagsaturationFlagSetter_
 
bool setHSCPFlags_
 
bool setNegativeFlags_
 
bool setNoiseFlags_
 
SetCorrectionFcn setPileupCorrection_
 
bool setPulseShapeFlags_
 
bool setSaturationFlags_
 
bool setTimingTrustFlags_
 
int subdet_
 
HcalOtherSubdetector subdetOther_
 
edm::EDGetTokenT< HcalCalibDigiCollectiontok_calib_
 
edm::EDGetTokenT< HFDigiCollectiontok_hf_
 
edm::EDGetTokenT< HODigiCollectiontok_ho_
 
bool tsFromDB_
 
bool useLeakCorrection_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Author
J. Temple & E. Yazgan Based on HcalSimpleReconstructor.h by J. Mans

Definition at line 41 of file HcalHitReconstructor.h.

Member Typedef Documentation

typedef void(HcalSimpleRecAlgo::* HcalHitReconstructor::SetCorrectionFcn) (boost::shared_ptr< AbsOOTPileupCorrection >)
private

Definition at line 51 of file HcalHitReconstructor.h.

Constructor & Destructor Documentation

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

Definition at line 27 of file HcalHitReconstructor.cc.

References DetId::Calo, dataOOTCorrectionCategory_, dataOOTCorrectionName_, det_, digiTimeFromDB_, edm::ParameterSet::existsAs(), edm::ParameterSet::getParameter(), HcalCalibration, HcalForward, HcalOther, HcalOuter, hfdigibit_, hfPET_, hfS8S1_, hfS9S1_, HFTimingTrustFlagSetter_, inputLabel_, mcOOTCorrectionCategory_, mcOOTCorrectionName_, recoParamsFromDB_, saturationFlagSetter_, setNegativeFlags_, setNoiseFlags_, setPileupCorrection_, setSaturationFlags_, setTimingTrustFlags_, AlCaHLTBitMon_QueryRunRegistry::string, subdet_, HcalZDCDetId::SubdetectorId, subdetOther_, tok_calib_, tok_hf_, and tok_ho_.

27  :
28  reco_(conf.getParameter<bool>("correctForTimeslew"),
29  conf.getParameter<bool>("correctForPhaseContainment"),
30  conf.getParameter<double>("correctionPhaseNS")),
32  inputLabel_(conf.getParameter<edm::InputTag>("digiLabel")),
33  correctTiming_(conf.getParameter<bool>("correctTiming")),
34  setNoiseFlags_(conf.getParameter<bool>("setNoiseFlags")),
35  setHSCPFlags_(conf.getParameter<bool>("setHSCPFlags")),
36  setSaturationFlags_(conf.getParameter<bool>("setSaturationFlags")),
37  setTimingTrustFlags_(conf.getParameter<bool>("setTimingTrustFlags")),
38  setPulseShapeFlags_(conf.getParameter<bool>("setPulseShapeFlags")),
39  setNegativeFlags_(false),
40  dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed")),
41  firstAuxTS_(conf.getParameter<int>("firstAuxTS")),
42  firstSample_(conf.getParameter<int>("firstSample")),
43  samplesToAdd_(conf.getParameter<int>("samplesToAdd")),
44  tsFromDB_(conf.getParameter<bool>("tsFromDB")),
45  useLeakCorrection_(conf.getParameter<bool>("useLeakCorrection")),
50  setPileupCorrection_(nullptr),
51  paramTS(nullptr)
52 
53 {
54  // register for data access
55  tok_ho_ = consumes<HODigiCollection>(inputLabel_);
56  tok_hf_ = consumes<HFDigiCollection>(inputLabel_);
57  tok_calib_ = consumes<HcalCalibDigiCollection>(inputLabel_);
58 
59  std::string subd=conf.getParameter<std::string>("Subdetector");
60  //Set all FlagSetters to 0
61  /* Important to do this! Otherwise, if the setters are turned off,
62  the "if (XSetter_) delete XSetter_;" commands can crash
63  */
64 
65  recoParamsFromDB_ = conf.getParameter<bool>("recoParamsFromDB");
66  // recoParamsFromDB_ = false ; // trun off for now.
67 
68  // std::cout<<" HcalHitReconstructor recoParamsFromDB_ "<<recoParamsFromDB_<<std::endl;
69 
70  if (conf.existsAs<bool>("setNegativeFlags"))
71  setNegativeFlags_ = conf.getParameter<bool>("setNegativeFlags");
72 
73  hfdigibit_ = nullptr;
74 
75  hfS9S1_ = nullptr;
76  hfS8S1_ = nullptr;
77  hfPET_ = nullptr;
78  saturationFlagSetter_ = nullptr;
79  HFTimingTrustFlagSetter_ = nullptr;
80  digiTimeFromDB_ = false; // only need for HF
81 
83  {
84  const edm::ParameterSet& pssat = conf.getParameter<edm::ParameterSet>("saturationParameters");
85  saturationFlagSetter_ = new HcalADCSaturationFlag(pssat.getParameter<int>("maxADCvalue"));
86  }
87 
88 
89  if (!strcasecmp(subd.c_str(),"HO")) {
91  // setPileupCorrection_ = &HcalSimpleRecAlgo::setHOPileupCorrection;
92  setPileupCorrection_ = nullptr;
93  produces<HORecHitCollection>();
94  } else if (!strcasecmp(subd.c_str(),"HF")) {
96  // setPileupCorrection_ = &HcalSimpleRecAlgo::setHFPileupCorrection;
97  setPileupCorrection_ = nullptr;
98  digiTimeFromDB_=conf.getParameter<bool>("digiTimeFromDB");
99 
100  if (setTimingTrustFlags_) {
101 
102  const edm::ParameterSet& pstrust = conf.getParameter<edm::ParameterSet>("hfTimingTrustParameters");
103  HFTimingTrustFlagSetter_=new HFTimingTrustFlag(pstrust.getParameter<int>("hfTimingTrustLevel1"),
104  pstrust.getParameter<int>("hfTimingTrustLevel2"));
105  }
106 
107  if (setNoiseFlags_)
108  {
109  const edm::ParameterSet& psdigi =conf.getParameter<edm::ParameterSet>("digistat");
110  const edm::ParameterSet& psTimeWin =conf.getParameter<edm::ParameterSet>("HFInWindowStat");
111  hfdigibit_=new HcalHFStatusBitFromDigis(psdigi,psTimeWin);
112 
113  const edm::ParameterSet& psS9S1 = conf.getParameter<edm::ParameterSet>("S9S1stat");
114  hfS9S1_ = new HcalHF_S9S1algorithm(psS9S1.getParameter<std::vector<double> >("short_optimumSlope"),
115  psS9S1.getParameter<std::vector<double> >("shortEnergyParams"),
116  psS9S1.getParameter<std::vector<double> >("shortETParams"),
117  psS9S1.getParameter<std::vector<double> >("long_optimumSlope"),
118  psS9S1.getParameter<std::vector<double> >("longEnergyParams"),
119  psS9S1.getParameter<std::vector<double> >("longETParams"),
120  psS9S1.getParameter<int>("HcalAcceptSeverityLevel"),
121  psS9S1.getParameter<bool>("isS8S1")
122  );
123 
124  const edm::ParameterSet& psS8S1 = conf.getParameter<edm::ParameterSet>("S8S1stat");
125  hfS8S1_ = new HcalHF_S9S1algorithm(psS8S1.getParameter<std::vector<double> >("short_optimumSlope"),
126  psS8S1.getParameter<std::vector<double> >("shortEnergyParams"),
127  psS8S1.getParameter<std::vector<double> >("shortETParams"),
128  psS8S1.getParameter<std::vector<double> >("long_optimumSlope"),
129  psS8S1.getParameter<std::vector<double> >("longEnergyParams"),
130  psS8S1.getParameter<std::vector<double> >("longETParams"),
131  psS8S1.getParameter<int>("HcalAcceptSeverityLevel"),
132  psS8S1.getParameter<bool>("isS8S1")
133  );
134 
135  const edm::ParameterSet& psPET = conf.getParameter<edm::ParameterSet>("PETstat");
136  hfPET_ = new HcalHF_PETalgorithm(psPET.getParameter<std::vector<double> >("short_R"),
137  psPET.getParameter<std::vector<double> >("shortEnergyParams"),
138  psPET.getParameter<std::vector<double> >("shortETParams"),
139  psPET.getParameter<std::vector<double> >("long_R"),
140  psPET.getParameter<std::vector<double> >("longEnergyParams"),
141  psPET.getParameter<std::vector<double> >("longETParams"),
142  psPET.getParameter<int>("HcalAcceptSeverityLevel"),
143  psPET.getParameter<std::vector<double> >("short_R_29"),
144  psPET.getParameter<std::vector<double> >("long_R_29")
145  );
146  }
147  produces<HFRecHitCollection>();
148  } else if (!strcasecmp(subd.c_str(),"ZDC")) {
151  produces<ZDCRecHitCollection>();
152  } else if (!strcasecmp(subd.c_str(),"CALIB")) {
155  produces<HcalCalibRecHitCollection>();
156  } else {
157  edm::LogWarning("Configuration") << "HcalHitReconstructor is not associated with a specific subdetector!" << std::endl;
158  }
159 
160  // If no valid OOT pileup correction name specified,
161  // disable the correction
162  if (conf.existsAs<std::string>("dataOOTCorrectionName"))
163  dataOOTCorrectionName_ = conf.getParameter<std::string>("dataOOTCorrectionName");
164  if (conf.existsAs<std::string>("dataOOTCorrectionCategory"))
165  dataOOTCorrectionCategory_ = conf.getParameter<std::string>("dataOOTCorrectionCategory");
166  if (conf.existsAs<std::string>("mcOOTCorrectionName"))
167  mcOOTCorrectionName_ = conf.getParameter<std::string>("mcOOTCorrectionName");
168  if (conf.existsAs<std::string>("mcOOTCorrectionCategory"))
169  mcOOTCorrectionCategory_ = conf.getParameter<std::string>("mcOOTCorrectionCategory");
170  if (dataOOTCorrectionName_.empty() && mcOOTCorrectionName_.empty())
171  setPileupCorrection_ = nullptr;
172 
173 }
T getParameter(std::string const &) const
HcalRecoParams * paramTS
HcalADCSaturationFlag * saturationFlagSetter_
SetCorrectionFcn setPileupCorrection_
std::string dataOOTCorrectionCategory_
edm::EDGetTokenT< HcalCalibDigiCollection > tok_calib_
HcalHFStatusBitFromDigis * hfdigibit_
edm::EDGetTokenT< HODigiCollection > tok_ho_
HcalHF_PETalgorithm * hfPET_
HcalHF_S9S1algorithm * hfS9S1_
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
std::string dataOOTCorrectionName_
HcalHF_S9S1algorithm * hfS8S1_
HcalOtherSubdetector subdetOther_
HFTimingTrustFlag * HFTimingTrustFlagSetter_
std::string mcOOTCorrectionCategory_
edm::EDGetTokenT< HFDigiCollection > tok_hf_
HcalSimpleRecAlgo reco_
HcalHitReconstructor::~HcalHitReconstructor ( )
override

Definition at line 175 of file HcalHitReconstructor.cc.

References hfdigibit_, hfPET_, hfS8S1_, hfS9S1_, HFTimingTrustFlagSetter_, paramTS, and saturationFlagSetter_.

175  {
176  delete hfdigibit_;
177 
178  delete hfS9S1_;
179  delete hfS8S1_;
180  delete hfPET_;
181  delete saturationFlagSetter_;
183 
184  delete paramTS;
185 }
HcalRecoParams * paramTS
HcalADCSaturationFlag * saturationFlagSetter_
HcalHFStatusBitFromDigis * hfdigibit_
HcalHF_PETalgorithm * hfPET_
HcalHF_S9S1algorithm * hfS9S1_
HcalHF_S9S1algorithm * hfS8S1_
HFTimingTrustFlag * HFTimingTrustFlagSetter_

Member Function Documentation

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

Definition at line 187 of file HcalHitReconstructor.cc.

References HcalSimpleRecAlgo::beginRun(), digiTimeFromDB_, edm::EventSetup::get(), HFDigiTimeParams, AlCaHLTBitMon_ParallelJobs::p, paramTS, edm::ESHandle< T >::product(), reco_, recoParamsFromDB_, HcalCondObjectContainerBase::setTopo(), and tsFromDB_.

187  {
188 
190  es.get<HcalRecNumberingRecord>().get(htopo);
191 
192  if ( tsFromDB_== true || recoParamsFromDB_ == true )
193  {
195  es.get<HcalRecoParamsRcd>().get(p);
196  paramTS = new HcalRecoParams(*p.product());
197  paramTS->setTopo(htopo.product());
198 
199 
200 
201 
202  // std::cout<<" skdump in HcalHitReconstructor::beginRun dupm RecoParams "<<std::endl;
203  // std::ofstream skfile("skdumpRecoParamsNewFormat.txt");
204  // HcalDbASCIIIO::dumpObject(skfile, (*paramTS) );
205  }
206 
207  if (digiTimeFromDB_==true)
208  {
210  es.get<HcalFlagHFDigiTimeParamsRcd>().get(p);
211  HFDigiTimeParams.reset( new HcalFlagHFDigiTimeParams( *p ) );
212  HFDigiTimeParams->setTopo(htopo.product());
213  }
214 
215  reco_.beginRun(es);
216 }
HcalRecoParams * paramTS
void beginRun(edm::EventSetup const &es)
std::unique_ptr< HcalFlagHFDigiTimeParams > HFDigiTimeParams
T const * product() const
Definition: ESHandle.h:86
void setTopo(const HcalTopology *topo)
HcalSimpleRecAlgo reco_
void HcalHitReconstructor::endRun ( edm::Run const &  r,
edm::EventSetup const &  es 
)
final

Definition at line 218 of file HcalHitReconstructor.cc.

References digiTimeFromDB_, HcalSimpleRecAlgo::endRun(), paramTS, reco_, and tsFromDB_.

218  {
219  if (tsFromDB_==true)
220  {
221  delete paramTS; paramTS=nullptr;
222  }
223  if (digiTimeFromDB_==true)
224  {
225  //DL delete HFDigiTimeParams; HFDigiTimeParams = 0;
226  }
227  reco_.endRun();
228 }
HcalRecoParams * paramTS
HcalSimpleRecAlgo reco_
void HcalHitReconstructor::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 230 of file HcalHitReconstructor.cc.

References funct::abs(), edm::SortedCollection< T, SORT >::begin(), AlignmentProducer_cff::calibrations, HcalTimingCorrector::Correct(), CastorSimpleReconstructor_cfi::correctForPhaseContainment, HcalRecoParam::correctForPhaseContainment(), CastorSimpleReconstructor_cfi::correctForTimeslew, HcalRecoParam::correctForTimeslew(), HcalRecoParam::correctionPhaseNS(), HcalRecoParam::correctTiming(), correctTiming_, egammaForCoreTracking_cff::depth, det_, digiTimeFromDB_, HcalSeverityLevelComputer::dropChannel(), dropZSmarkedPassed_, edm::SortedCollection< T, SORT >::end(), plotBeamSpotDB::first, HcalRecoParam::firstAuxTS(), firstAuxTS_, HcalRecoParam::firstSample(), firstSample_, edm::EventSetup::get(), edm::Event::getByToken(), HcalDbService::getHcalCalibrations(), HcalDbService::getHcalCoder(), HcalDbService::getHcalShape(), HcalChannelStatus::getValue(), HcalCondObjectContainer< Item >::getValues(), DetId::Hcal, HcalCalibration, HcalForward, HcalOther, HcalOuter, hfdigibit_, HcalFlagHFDigiTimeParam::HFdigiflagCoefficients(), HcalFlagHFDigiTimeParam::HFdigiflagExpectedPeak(), HcalFlagHFDigiTimeParam::HFdigiflagFirstSample(), HcalFlagHFDigiTimeParam::HFdigiflagMinEThreshold(), HcalFlagHFDigiTimeParam::HFdigiflagSamplesToAdd(), HFDigiTimeParams, hfPET_, hfS8S1_, hfS9S1_, HcalHFStatusBitFromDigis::hfSetFlagFromDigi(), HcalHF_PETalgorithm::HFSetFlagFromPET(), HcalHF_S9S1algorithm::HFSetFlagFromS9S1(), HFTimingTrustFlagSetter_, mps_fire::i, gen::k, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, paramTS, HcalRecoParam::pileupCleaningID(), HcalCaloFlagLabels::PresampleADC, edm::ESHandle< T >::product(), edm::Event::put(), DetId::rawId(), reco_, HcalSimpleRecAlgo::reconstruct(), recoParamsFromDB_, HcalHFStatusBitFromDigis::resetParamsFromDB(), HcalRecoParam::samplesToAdd(), samplesToAdd_, saturationFlagSetter_, HFTimingTrustFlag::setHFTimingTrustFlag(), HcalSimpleRecAlgo::setLeakCorrection(), setNoiseFlags_, HcalSimpleRecAlgo::setRecoParams(), HcalADCSaturationFlag::setSaturationFlag(), setSaturationFlags_, setTimingTrustFlags_, edm::SortedCollection< T, SORT >::size(), subdet_, subdetOther_, tok_calib_, tok_hf_, tok_ho_, tsFromDB_, HcalRecoParam::useLeakCorrection(), useLeakCorrection_, and geometryCSVtoXML::xx.

231 {
232 
233  // get conditions
235  eventSetup.get<HcalRecNumberingRecord>().get(topo);
236 
237  edm::ESHandle<HcalDbService> conditions;
238  eventSetup.get<HcalDbRecord>().get(conditions);
239 
241 
243  eventSetup.get<HcalChannelQualityRcd>().get("withTopo",p);
244  const HcalChannelQuality* myqual = p.product();
245 
247  eventSetup.get<HcalSeverityLevelComputerRcd>().get(mycomputer);
248  const HcalSeverityLevelComputer* mySeverity = mycomputer.product();
249 
250 
251  // GET THE BEAM CROSSING INFO HERE, WHEN WE UNDERSTAND HOW THINGS WORK.
252  // Then, call "setBXInfo" method of the reco_ object.
253  // Also remember to call SetBXInfo in the negative energy flag setter.
254 
255  if (det_==DetId::Hcal) {
256 
257  // HO ------------------------------------------------------------------
258  if (subdet_==HcalOuter) {
260  e.getByToken(tok_ho_,digi);
261 
262  // create empty output
263  auto rec = std::make_unique<HORecHitCollection>();
264  rec->reserve(digi->size());
265  // run the algorithm
267 
268  // Vote on majority TS0 CapId
269  int favorite_capid = 0;
270  if (correctTiming_) {
271  long capid_votes[4] = {0,0,0,0};
272  for (i=digi->begin(); i!=digi->end(); i++) {
273  capid_votes[(*i)[0].capid()]++;
274  }
275  for (int k = 0; k < 4; k++)
276  if (capid_votes[k] > capid_votes[favorite_capid])
277  favorite_capid = k;
278  }
279 
280  for (i=digi->begin(); i!=digi->end(); i++) {
281  HcalDetId cell = i->id();
282  DetId detcell=(DetId)cell;
283  // firstSample & samplesToAdd
285  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
286  if(tsFromDB_) {
287  firstSample_ = param_ts->firstSample();
288  samplesToAdd_ = param_ts->samplesToAdd();
289  }
290  if(recoParamsFromDB_) {
291  bool correctForTimeslew=param_ts->correctForTimeslew();
293  float phaseNS=param_ts->correctionPhaseNS();
295  correctTiming_ = param_ts->correctTiming();
296  firstAuxTS_ = param_ts->firstAuxTS();
297  int pileupCleaningID = param_ts->pileupCleaningID();
298  reco_.setRecoParams(correctForTimeslew,correctForPhaseContainment,useLeakCorrection_,pileupCleaningID,phaseNS);
299  }
300  }
301 
302  int first = firstSample_;
303  int toadd = samplesToAdd_;
304 
305  if(first >= i->size() || first < 0)
306  edm::LogWarning("Configuration") << "HcalHitReconstructor: illegal firstSample" << first << " in subdet " << subdet_ << std::endl;
307 
308  // check on cells to be ignored and dropped: (rof,20.Feb.09)
309  const HcalChannelStatus* mydigistatus=myqual->getValues(detcell.rawId());
310  if (mySeverity->dropChannel(mydigistatus->getValue() ) ) continue;
312  if (i->zsMarkAndPass()) continue;
313 
314  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
315  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
316  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
317  HcalCoderDb coder (*channelCoder, *shape);
318 
319  rec->push_back(reco_.reconstruct(*i,first,toadd,coder,calibrations));
320 
321  // Set auxiliary flag
322  int auxflag=0;
323  int fTS = firstAuxTS_;
324  if (fTS<0) fTS=0; //silly protection against negative time slice values
325  for (int xx=fTS; xx<fTS+4 && xx<i->size();++xx)
326  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
327  // bits 28 and 29 are reserved for capid of the first time slice saved in aux
328  auxflag+=((i->sample(fTS).capid())<<28);
329  (rec->back()).setAux(auxflag);
330  // (rec->back()).setFlags(0); Don't want to do this because the algorithm
331  // can already set some flags
332  // Fill Presample ADC flag
333  if (fTS>0)
334  (rec->back()).setFlagField((i->sample(fTS-1).adc()), HcalCaloFlagLabels::PresampleADC,7);
335 
338  if (correctTiming_)
339  HcalTimingCorrector::Correct(rec->back(), *i, favorite_capid);
340  }
341  // return result
342  e.put(std::move(rec));
343 
344  // HF -------------------------------------------------------------------
345  } else if (subdet_==HcalForward) {
347  e.getByToken(tok_hf_,digi);
348 
349 
351  // create empty output
352  auto rec = std::make_unique<HFRecHitCollection>();
353  rec->reserve(digi->size());
354  // run the algorithm
356 
357  // Vote on majority TS0 CapId
358  int favorite_capid = 0;
359  if (correctTiming_) {
360  long capid_votes[4] = {0,0,0,0};
361  for (i=digi->begin(); i!=digi->end(); i++) {
362  capid_votes[(*i)[0].capid()]++;
363  }
364  for (int k = 0; k < 4; k++)
365  if (capid_votes[k] > capid_votes[favorite_capid])
366  favorite_capid = k;
367  }
368 
369  for (i=digi->begin(); i!=digi->end(); i++) {
370  HcalDetId cell = i->id();
371  DetId detcell=(DetId)cell;
372 
374  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
375  if(tsFromDB_) {
376  firstSample_ = param_ts->firstSample();
377  samplesToAdd_ = param_ts->samplesToAdd();
378  }
379  if(recoParamsFromDB_) {
380  bool correctForTimeslew=param_ts->correctForTimeslew();
381  bool correctForPhaseContainment= param_ts->correctForPhaseContainment();
382  float phaseNS=param_ts->correctionPhaseNS();
384  correctTiming_ = param_ts->correctTiming();
385  firstAuxTS_ = param_ts->firstAuxTS();
386  int pileupCleaningID = param_ts->pileupCleaningID();
387  reco_.setRecoParams(correctForTimeslew,correctForPhaseContainment,useLeakCorrection_,pileupCleaningID,phaseNS);
388  }
389  }
390 
391  int first = firstSample_;
392  int toadd = samplesToAdd_;
393 
394  if(first >= i->size() || first < 0)
395  edm::LogWarning("Configuration") << "HcalHitReconstructor: illegal firstSample" << first << " in subdet " << subdet_ << std::endl;
396 
397  // check on cells to be ignored and dropped: (rof,20.Feb.09)
398  const HcalChannelStatus* mydigistatus=myqual->getValues(detcell.rawId());
399  if (mySeverity->dropChannel(mydigistatus->getValue() ) ) continue;
401  if (i->zsMarkAndPass()) continue;
402 
403  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
404  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
405  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
406  HcalCoderDb coder (*channelCoder, *shape);
407 
408  // Set HFDigiTime flag values from digiTimeFromDB_
409  if (digiTimeFromDB_==true && hfdigibit_!=nullptr)
410  {
411  const HcalFlagHFDigiTimeParam* hfDTparam = HFDigiTimeParams->getValues(detcell.rawId());
413  hfDTparam->HFdigiflagSamplesToAdd(),
414  hfDTparam->HFdigiflagExpectedPeak(),
415  hfDTparam->HFdigiflagMinEThreshold(),
416  hfDTparam->HFdigiflagCoefficients()
417  );
418  }
419 
420  //std::cout << "TOADDHF " << toadd << " " << first << " " << std::endl;
421  rec->push_back(reco_.reconstruct(*i,first,toadd,coder,calibrations));
422 
423  // Set auxiliary flag
424  int auxflag=0;
425  int fTS = firstAuxTS_;
426  if (fTS<0) fTS=0; // silly protection against negative time slice values
427  for (int xx=fTS; xx<fTS+4 && xx<i->size();++xx)
428  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
429  // bits 28 and 29 are reserved for capid of the first time slice saved in aux
430  auxflag+=((i->sample(fTS).capid())<<28);
431  (rec->back()).setAux(auxflag);
432 
433  // (rec->back()).setFlags(0); Don't want to do this because the algorithm
434  // can already set some flags
435 
436  // Fill Presample ADC flag
437  if (fTS>0)
438  (rec->back()).setFlagField((i->sample(fTS-1).adc()), HcalCaloFlagLabels::PresampleADC,7);
439 
440  // This calls the code for setting the HF noise bit determined from digi shape
441  if (setNoiseFlags_)
442  hfdigibit_->hfSetFlagFromDigi(rec->back(),*i,coder,calibrations);
447  if (correctTiming_)
448  HcalTimingCorrector::Correct(rec->back(), *i, favorite_capid);
449  } // for (i=digi->begin(); i!=digi->end(); i++) -- loop on all HF digis
450 
451  // The following flags require the full set of rechits
452  // These need to be set consecutively, so an energy check should be the first
453  // test performed on these hits (to minimize the loop time)
454  if (setNoiseFlags_)
455  {
456  // Step 1: Set PET flag (short fibers of |ieta|==29)
457  // Neighbor/partner channels that are flagged by Pulse Shape algorithm (HFDigiTime)
458  // won't be considered in these calculations
459  for (HFRecHitCollection::iterator i = rec->begin();i!=rec->end();++i)
460  {
461  int depth=i->id().depth();
462  int ieta=i->id().ieta();
463  // Short fibers and all channels at |ieta|=29 use PET settings in Algo 3
464  if (depth==2 || abs(ieta)==29 )
465  hfPET_->HFSetFlagFromPET(*i,*rec,myqual,mySeverity);
466  }
467 
468  // Step 2: Set S8S1 flag (short fibers or |ieta|==29)
469  for (HFRecHitCollection::iterator i = rec->begin();i!=rec->end();++i)
470  {
471  int depth=i->id().depth();
472  int ieta=i->id().ieta();
473  // Short fibers and all channels at |ieta|=29 use PET settings in Algo 3
474  if (depth==2 || abs(ieta)==29 )
475  hfS8S1_->HFSetFlagFromS9S1(*i,*rec,myqual,mySeverity);
476  }
477 
478  // Set 3: Set S9S1 flag (long fibers)
479  for (HFRecHitCollection::iterator i = rec->begin();i!=rec->end();++i)
480  {
481  int depth=i->id().depth();
482  int ieta=i->id().ieta();
483  // Short fibers and all channels at |ieta|=29 use PET settings in Algo 3
484  if (depth==1 && abs(ieta)!=29 )
485  hfS9S1_->HFSetFlagFromS9S1(*i,*rec,myqual, mySeverity);
486  }
487  }
488 
489  // return result
490  e.put(std::move(rec));
491  } else if (subdet_==HcalOther && subdetOther_==HcalCalibration) {
493  e.getByToken(tok_calib_,digi);
494 
495  // create empty output
496  auto rec = std::make_unique<HcalCalibRecHitCollection>();
497  rec->reserve(digi->size());
498  // run the algorithm
499  int first = firstSample_;
500  int toadd = samplesToAdd_;
501 
503  for (i=digi->begin(); i!=digi->end(); i++) {
504  HcalCalibDetId cell = i->id();
505  // HcalDetId cellh = i->id();
506  DetId detcell=(DetId)cell;
507  // check on cells to be ignored and dropped: (rof,20.Feb.09)
508  const HcalChannelStatus* mydigistatus=myqual->getValues(detcell.rawId());
509  if (mySeverity->dropChannel(mydigistatus->getValue() ) ) continue;
511  if (i->zsMarkAndPass()) continue;
512 
513  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
514  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
515  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
516  HcalCoderDb coder (*channelCoder, *shape);
517 
518  // firstSample & samplesToAdd
519  if(tsFromDB_) {
520  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
521  first = param_ts->firstSample();
522  toadd = param_ts->samplesToAdd();
523  }
524  rec->push_back(reco_.reconstruct(*i,first,toadd,coder,calibrations));
525 
526  /*
527  // Flag setting not available for calibration rechits
528  // Set auxiliary flag
529  int auxflag=0;
530  int fTS = firstAuxTS_;
531  for (int xx=fTS; xx<fTS+4 && xx<i->size();++xx)
532  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
533  // bits 28 and 29 are reserved for capid of the first time slice saved in aux
534  auxflag+=((i->sample(fTS).capid())<<28);
535  (rec->back()).setAux(auxflag);
536 
537  (rec->back()).setFlags(0); // Not yet implemented for HcalCalibRecHit
538  */
539  }
540  // return result
541  e.put(std::move(rec));
542  }
543  }
544  //DL delete myqual;
545 } // void HcalHitReconstructor::produce(...)
void HFSetFlagFromS9S1(HFRecHit &hf, HFRecHitCollection &rec, const HcalChannelQuality *myqual, const HcalSeverityLevelComputer *mySeverity)
HcalRecoParams * paramTS
constexpr unsigned int samplesToAdd() const
Definition: HcalRecoParam.h:33
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
constexpr unsigned int pileupCleaningID() const
Definition: HcalRecoParam.h:44
void setHFTimingTrustFlag(HFRecHit &rechit, const HFDataFrame &digi)
HcalADCSaturationFlag * saturationFlagSetter_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
uint32_t HFdigiflagSamplesToAdd() const
void hfSetFlagFromDigi(HFRecHit &hf, const HFDataFrame &digi, const HcalCoder &coder, const HcalCalibrations &calib)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
std::vector< T >::const_iterator const_iterator
const Item * getValues(DetId fId, bool throwOnFail=true) const
void resetParamsFromDB(int firstSample, int samplesToAdd, int expectedPeak, double minthreshold, const std::vector< double > &coef)
void HFSetFlagFromPET(HFRecHit &hf, HFRecHitCollection &rec, const HcalChannelQuality *myqual, const HcalSeverityLevelComputer *mySeverity)
constexpr float correctionPhaseNS() const
Definition: HcalRecoParam.h:31
std::unique_ptr< HcalFlagHFDigiTimeParams > HFDigiTimeParams
edm::EDGetTokenT< HcalCalibDigiCollection > tok_calib_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HcalHFStatusBitFromDigis * hfdigibit_
constexpr unsigned int firstAuxTS() const
Definition: HcalRecoParam.h:41
bool dropChannel(const uint32_t &mystatus) const
uint32_t HFdigiflagExpectedPeak() const
constexpr bool correctTiming() const
Definition: HcalRecoParam.h:40
HFRecHit reconstruct(const HFDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
void setSaturationFlag(HBHERecHit &rechit, const HBHEDataFrame &digi)
constexpr bool useLeakCorrection() const
Definition: HcalRecoParam.h:36
edm::EDGetTokenT< HODigiCollection > tok_ho_
std::vector< T >::iterator iterator
int k[5][pyjets_maxn]
const_iterator end() const
std::vector< double > HFdigiflagCoefficients() const
HcalHF_PETalgorithm * hfPET_
Definition: DetId.h:18
constexpr bool correctForPhaseContainment() const
Definition: HcalRecoParam.h:29
constexpr bool correctForTimeslew() const
Definition: HcalRecoParam.h:38
HcalHF_S9S1algorithm * hfS9S1_
void setRecoParams(bool correctForTimeslew, bool correctForPulse, bool setLeakCorrection, int pileupCleaningID, float phaseNS)
uint32_t HFdigiflagFirstSample() const
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
HcalHF_S9S1algorithm * hfS8S1_
size_type size() const
HcalOtherSubdetector subdetOther_
static void Correct(HBHERecHit &rechit, const HBHEDataFrame &digi, int favorite_capid)
HFTimingTrustFlag * HFTimingTrustFlagSetter_
uint32_t getValue() const
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
edm::EDGetTokenT< HFDigiCollection > tok_hf_
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511
constexpr unsigned int firstSample() const
Definition: HcalRecoParam.h:32
const_iterator begin() const
HcalSimpleRecAlgo reco_
double HFdigiflagMinEThreshold() const

Member Data Documentation

std::string HcalHitReconstructor::cat_
private

Definition at line 101 of file HcalHitReconstructor.h.

bool HcalHitReconstructor::correctTiming_
private

Definition at line 69 of file HcalHitReconstructor.h.

Referenced by produce().

std::string HcalHitReconstructor::corrName_
private

Definition at line 101 of file HcalHitReconstructor.h.

std::string HcalHitReconstructor::dataOOTCorrectionCategory_
private

Definition at line 93 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor().

std::string HcalHitReconstructor::dataOOTCorrectionName_
private

Definition at line 92 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor().

DetId::Detector HcalHitReconstructor::det_
private

Definition at line 61 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

bool HcalHitReconstructor::digiTimeFromDB_
private

Definition at line 85 of file HcalHitReconstructor.h.

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

bool HcalHitReconstructor::dropZSmarkedPassed_
private

Definition at line 76 of file HcalHitReconstructor.h.

Referenced by produce().

int HcalHitReconstructor::firstAuxTS_
private

Definition at line 78 of file HcalHitReconstructor.h.

Referenced by produce().

int HcalHitReconstructor::firstSample_
private

Definition at line 81 of file HcalHitReconstructor.h.

Referenced by produce().

HcalHFStatusBitFromDigis* HcalHitReconstructor::hfdigibit_
private

Definition at line 56 of file HcalHitReconstructor.h.

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

std::unique_ptr<HcalFlagHFDigiTimeParams> HcalHitReconstructor::HFDigiTimeParams
private

Definition at line 99 of file HcalHitReconstructor.h.

Referenced by beginRun(), and produce().

HcalHF_PETalgorithm* HcalHitReconstructor::hfPET_
private

Definition at line 59 of file HcalHitReconstructor.h.

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

HcalHF_S9S1algorithm* HcalHitReconstructor::hfS8S1_
private

Definition at line 58 of file HcalHitReconstructor.h.

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

HcalHF_S9S1algorithm* HcalHitReconstructor::hfS9S1_
private

Definition at line 57 of file HcalHitReconstructor.h.

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

HFTimingTrustFlag* HcalHitReconstructor::HFTimingTrustFlagSetter_
private

Definition at line 55 of file HcalHitReconstructor.h.

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

edm::InputTag HcalHitReconstructor::inputLabel_
private

Definition at line 64 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor().

std::string HcalHitReconstructor::mcOOTCorrectionCategory_
private

Definition at line 95 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor().

std::string HcalHitReconstructor::mcOOTCorrectionName_
private

Definition at line 94 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor().

HcalRecoParams* HcalHitReconstructor::paramTS
private

Definition at line 98 of file HcalHitReconstructor.h.

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

HcalSimpleRecAlgo HcalHitReconstructor::reco_
private

Definition at line 53 of file HcalHitReconstructor.h.

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

bool HcalHitReconstructor::recoParamsFromDB_
private

Definition at line 84 of file HcalHitReconstructor.h.

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

int HcalHitReconstructor::samplesToAdd_
private

Definition at line 82 of file HcalHitReconstructor.h.

Referenced by produce().

HcalADCSaturationFlag* HcalHitReconstructor::saturationFlagSetter_
private

Definition at line 54 of file HcalHitReconstructor.h.

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

bool HcalHitReconstructor::setHSCPFlags_
private

Definition at line 71 of file HcalHitReconstructor.h.

bool HcalHitReconstructor::setNegativeFlags_
private

Definition at line 75 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor().

bool HcalHitReconstructor::setNoiseFlags_
private

Definition at line 70 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

SetCorrectionFcn HcalHitReconstructor::setPileupCorrection_
private

Definition at line 96 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor().

bool HcalHitReconstructor::setPulseShapeFlags_
private

Definition at line 74 of file HcalHitReconstructor.h.

bool HcalHitReconstructor::setSaturationFlags_
private

Definition at line 72 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

bool HcalHitReconstructor::setTimingTrustFlags_
private

Definition at line 73 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

int HcalHitReconstructor::subdet_
private

Definition at line 62 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

HcalOtherSubdetector HcalHitReconstructor::subdetOther_
private

Definition at line 63 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

edm::EDGetTokenT<HcalCalibDigiCollection> HcalHitReconstructor::tok_calib_
private

Definition at line 67 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

edm::EDGetTokenT<HFDigiCollection> HcalHitReconstructor::tok_hf_
private

Definition at line 66 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

edm::EDGetTokenT<HODigiCollection> HcalHitReconstructor::tok_ho_
private

Definition at line 65 of file HcalHitReconstructor.h.

Referenced by HcalHitReconstructor(), and produce().

bool HcalHitReconstructor::tsFromDB_
private

Definition at line 83 of file HcalHitReconstructor.h.

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

bool HcalHitReconstructor::useLeakCorrection_
private

Definition at line 89 of file HcalHitReconstructor.h.

Referenced by produce().