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 tsFromDB_(conf.getParameter<bool>("tsFromDB")),
34 setSaturationFlag_(conf.getParameter<bool>("setSaturationFlag")),
35 maxADCvalue_(conf.getParameter<int>("maxADCvalue")),
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 
55 }
57 {
58  // get conditions
60  eventSetup.get<CastorDbRecord>().get(conditions);
61  const CastorQIEShape* shape = conditions->getCastorShape (); // this one is generic
62 
63  CastorCalibrations calibrations;
64 
65  // try to get the TS windows from the db
67  if (tsFromDB_) {
68  eventSetup.get<CastorRecoParamsRcd>().get(recoparams);
69  if (!recoparams.isValid()) {
70  tsFromDB_ = false;
71  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;
72  }
73  }
74 
75  // try to get the saturation correction constants from the db
77  if (doSaturationCorr_) {
78  eventSetup.get<CastorSaturationCorrsRcd>().get(satcorr);
79  if (!satcorr.isValid()) {
80  doSaturationCorr_ = false;
81  edm::LogWarning("CastorSimpleReconstructor") << "Could not handle the CastorSaturationCorrsRcd correctly. We'll not try the saturation correction from this event onwards..." << std::endl;
82  }
83  }
84 
85 
88  e.getByLabel(inputLabel_,digi);
89 
90  // create empty output
91  std::auto_ptr<CastorRecHitCollection> rec(new CastorRecHitCollection);
92  // run the algorithm
94  for (i=digi->begin(); i!=digi->end(); i++) {
95  HcalCastorDetId cell = i->id();
96  DetId detcell=(DetId)cell;
97  const CastorCalibrations& calibrations=conditions->getCastorCalibrations(cell);
98 
99  if (tsFromDB_) {
100  const CastorRecoParam* param_ts = recoparams->getValues(detcell.rawId());
101  reco_.resetTimeSamples(param_ts->firstSample(),param_ts->samplesToAdd());
102  }
103  const CastorQIECoder* channelCoder = conditions->getCastorCoder (cell);
104  CastorCoderDb coder (*channelCoder, *shape);
105 
106  // reconstruct the rechit
107  rec->push_back(reco_.reconstruct(*i,coder,calibrations));
108 
109  // set the saturation flag if needed
110  if (setSaturationFlag_) {
111  reco_.checkADCSaturation(rec->back(),*i,maxADCvalue_);
112 
113  //++++ Saturation Correction +++++
114  if (doSaturationCorr_ && rec->back().flagField(HcalCaloFlagLabels::ADCSaturationBit)) {
115  // get saturation correction value
116  const CastorSaturationCorr* saturationCorr = satcorr->getValues(detcell.rawId());
117  double satCorrConst = 1.;
118  satCorrConst = saturationCorr->getValue();
119  reco_.recoverADCSaturation(rec->back(),coder,calibrations,*i,maxADCvalue_,satCorrConst);
120  }
121  }
122  }
123  // return result
124  e.put(rec);
125  }
126 }
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:85
unsigned int samplesToAdd() const
static const int SubdetectorId
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
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
virtual void beginRun(edm::Run &r, edm::EventSetup const &es)
void checkADCSaturation(CastorRecHit &rechit, const CastorDataFrame &digi, const int &maxADCvalue) const
bool isValid() const
Definition: ESHandle.h:37
Definition: Run.h:33