CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorSimpleReconstructor.cc
Go to the documentation of this file.
1 using namespace std;
21 
23 #include <iostream>
24 
25 
27 reco_(conf.getParameter<int>("firstSample"),conf.getParameter<int>("samplesToAdd"),conf.getParameter<bool>("correctForTimeslew"),
28  conf.getParameter<bool>("correctForPhaseContainment"),conf.getParameter<double>("correctionPhaseNS")),
29 det_(DetId::Hcal),
30 inputLabel_(conf.getParameter<edm::InputTag>("digiLabel")),
31 firstSample_(conf.getParameter<int>("firstSample")),
32 samplesToAdd_(conf.getParameter<int>("samplesToAdd")),
33 maxADCvalue_(conf.getParameter<int>("maxADCvalue")),
34 tsFromDB_(conf.getParameter<bool>("tsFromDB")),
35 setSaturationFlag_(conf.getParameter<bool>("setSaturationFlag")),
36 doSaturationCorr_(conf.getParameter<bool>("doSaturationCorr"))
37 {
38  std::string subd=conf.getParameter<std::string>("Subdetector");
39  if (!strcasecmp(subd.c_str(),"CASTOR")) {
42  produces<CastorRecHitCollection>();
43  } else {
44  edm::LogWarning("CastorSimpleReconstructor") << "CastorSimpleReconstructor is not associated with CASTOR subdetector!" << std::endl;
45  }
46 
47 }
48 
50 }
51 
53 {
54  // get conditions
56  eventSetup.get<CastorDbRecord>().get(conditions);
57  const CastorQIEShape* shape = conditions->getCastorShape (); // this one is generic
58 
59  CastorCalibrations calibrations;
60 
61  // try to get the TS windows from the db
63  if (tsFromDB_) {
64  eventSetup.get<CastorRecoParamsRcd>().get(recoparams);
65  if (!recoparams.isValid()) {
66  tsFromDB_ = false;
67  edm::LogWarning("CastorSimpleReconstructor") << "Could not handle the CastorRecoParamsRcd correctly, using parameters from cfg file from this event onwards... These parameters could be wrong for this run... please check" << std::endl;
68  }
69  }
70 
71  // try to get the saturation correction constants from the db
73  if (doSaturationCorr_) {
74  eventSetup.get<CastorSaturationCorrsRcd>().get(satcorr);
75  if (!satcorr.isValid()) {
76  doSaturationCorr_ = false;
77  edm::LogWarning("CastorSimpleReconstructor") << "Could not handle the CastorSaturationCorrsRcd correctly. We'll not try the saturation correction from this event onwards..." << std::endl;
78  }
79  }
80 
81 
84  e.getByLabel(inputLabel_,digi);
85 
86  // create empty output
87  std::auto_ptr<CastorRecHitCollection> rec(new CastorRecHitCollection);
88  // run the algorithm
90  for (i=digi->begin(); i!=digi->end(); i++) {
91  HcalCastorDetId cell = i->id();
92  DetId detcell=(DetId)cell;
93  const CastorCalibrations& calibrations=conditions->getCastorCalibrations(cell);
94 
95  if (tsFromDB_) {
96  const CastorRecoParam* param_ts = recoparams->getValues(detcell.rawId());
97  reco_.resetTimeSamples(param_ts->firstSample(),param_ts->samplesToAdd());
98  }
99  const CastorQIECoder* channelCoder = conditions->getCastorCoder (cell);
100  CastorCoderDb coder (*channelCoder, *shape);
101 
102  // reconstruct the rechit
103  rec->push_back(reco_.reconstruct(*i,coder,calibrations));
104 
105  // set the saturation flag if needed
106  if (setSaturationFlag_) {
107  reco_.checkADCSaturation(rec->back(),*i,maxADCvalue_);
108 
109  //++++ Saturation Correction +++++
110  if (doSaturationCorr_ && rec->back().flagField(HcalCaloFlagLabels::ADCSaturationBit)) {
111  // get saturation correction value
112  const CastorSaturationCorr* saturationCorr = satcorr->getValues(detcell.rawId());
113  double satCorrConst = 1.;
114  satCorrConst = saturationCorr->getValue();
115  reco_.recoverADCSaturation(rec->back(),coder,calibrations,*i,maxADCvalue_,satCorrConst);
116  }
117  }
118  }
119  // return result
120  e.put(rec);
121  }
122 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
void resetTimeSamples(int f, int t)
std::vector< T >::const_iterator const_iterator
virtual void produce(edm::Event &e, const edm::EventSetup &c)
CastorSimpleReconstructor(const edm::ParameterSet &ps)
CastorRecHit reconstruct(const CastorDataFrame &digi, const CastorCoder &coder, const CastorCalibrations &calibs) const
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
unsigned int samplesToAdd() const
static const int SubdetectorId
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
tuple conf
Definition: dbtoconf.py:185
Definition: DetId.h:20
unsigned int firstSample() const
void recoverADCSaturation(CastorRecHit &rechit, const CastorCoder &coder, const CastorCalibrations &calibs, const CastorDataFrame &digi, const int &maxADCvalue, const double &satCorrConst) const
const T & get() const
Definition: EventSetup.h:55
void checkADCSaturation(CastorRecHit &rechit, const CastorDataFrame &digi, const int &maxADCvalue) const
bool isValid() const
Definition: ESHandle.h:37