1 #include "HGCal/Reco/plugins/HGCalTBRecHitProducer.h"
4 : outputCollectionName(cfg.getParameter<std::string>(
"OutputCollectionName")),
6 _pedestalLow_filename(cfg.getParameter<std::string>(
"pedestalLow")),
7 _pedestalHigh_filename(cfg.getParameter<std::string>(
"pedestalHigh")),
8 _gainsLow_filename(cfg.getParameter<std::string>(
"gainLow")),
9 _gainsHigh_filename(cfg.getParameter<std::string>(
"gainHigh")),
10 _adcSaturation(cfg.getParameter<unsigned int>(
"adcSaturation"))
12 produces <HGCalTBRecHitCollection>(outputCollectionName);
21 edm::Handle<HGCalTBDigiCollection> digisHandle;
22 event.getByToken(_digisToken, digisHandle);
26 edm::ESHandle<HGCalCondPedestals> pedestalsHandle;
30 edm::ESHandle<HGCalCondGains> adcToGeVHandle;
39 if(_pedestalLow_filename !=
"") assert(condIO.
load(_pedestalLow_filename, pedestals_low));
40 if(_pedestalHigh_filename !=
"") assert(condIO.
load(_pedestalHigh_filename, pedestals_high));
41 if(_gainsLow_filename !=
"") assert(condIO.
load(_gainsLow_filename, adcToGeV_low));
42 if(_gainsHigh_filename !=
"") assert(condIO.
load(_gainsHigh_filename, adcToGeV_high));
46 for(
auto digi_itr = digisHandle->begin(); digi_itr != digisHandle->end(); ++digi_itr) {
48 std::cout <<
"[RECHIT PRODUCER: digi]" << *digi_itr << std::endl;
54 unsigned int nSamples = digi.
samples();
58 for(
unsigned int iSample = 0; iSample < nSamples; ++iSample) {
60 float pedestal_low_value = (pedestals_low.
size() > 0) ? pedestals_low.
get(digi.
detid())->value : 0;
61 float pedestal_high_value = (pedestals_high.
size() > 0) ? pedestals_high.
get(digi.
detid())->value : 0;
62 float adcToGeV_low_value = (adcToGeV_low.size() > 0) ? adcToGeV_low.get(digi.
detid())->value : 1;
63 float adcToGeV_high_value = (adcToGeV_high.size() > 0) ? adcToGeV_high.get(digi.
detid())->value : 1;
65 float energyLow = digi[iSample].adcLow() - pedestal_low_value * adcToGeV_low_value;
66 float energyHigh = digi[iSample].adcHigh() - pedestal_high_value * adcToGeV_high_value;
75 std::cout << recHit << std::endl;
77 if(iSample == 0) rechits->push_back(recHit);
80 event.put(rechits, outputCollectionName);
DEFINE_FWK_MODULE(Pedestals)
edm::SortedCollection< HGCalTBRecHit > HGCalTBRecHitCollection
HGCalTBDetId detid() const
Get the detector id.
static const HGCalCondObjectNumberingScheme * scheme()
bool load(const std::string &filename, HGCalCondObjectContainer< float > &)
load conditions from file
const Item * get(DetId id) const
HGCalTBRecHitProducer(const edm::ParameterSet &)
virtual void produce(edm::Event &, const edm::EventSetup &)
int samples() const
total number of samples in the digi