35 #include <boost/foreach.hpp>
43 namespace HcalDigitizerImpl {
45 template<
typename SIPMDIGITIZER>
46 void fillSiPMCells(std::vector<int> & siPMCells, SIPMDIGITIZER * siPMDigitizer)
48 std::vector<DetId> siPMDetIds;
49 siPMDetIds.reserve(siPMCells.size());
50 for(std::vector<int>::const_iterator idItr = siPMCells.begin();
51 idItr != siPMCells.end(); ++idItr)
53 siPMDetIds.emplace_back(*idItr);
55 siPMDigitizer->setDetIds(siPMDetIds);
60 template<
typename HPDDIGITIZER,
typename SIPMDIGITIZER>
62 HPDDIGITIZER * hpdDigitizer,
63 SIPMDIGITIZER * siPMDigitizer)
66 if(siPMDigitizer && hpdDigitizer)
68 std::vector<DetId> siPMDetIds = siPMDigitizer->detIds();
69 std::sort(siPMDetIds.begin(), siPMDetIds.end());
70 std::vector<DetId> sortedCells = allCells;
71 std::sort(sortedCells.begin(), sortedCells.end());
72 std::vector<DetId> hpdCells;
73 std::set_difference(sortedCells.begin(), sortedCells.end(),
74 siPMDetIds.begin(), siPMDetIds.end(),
75 std::back_inserter(hpdCells) );
76 hpdDigitizer->setDetIds(hpdCells);
80 if(siPMDigitizer) siPMDigitizer->setDetIds(allCells);
81 if(hpdDigitizer) hpdDigitizer->setDetIds(allCells);
93 theHBHESiPMResponse(0),
105 theUpgradeCoderFactory(0),
106 theHBHEElectronicsSim(0),
107 theHFElectronicsSim(0),
108 theHOElectronicsSim(0),
109 theZDCElectronicsSim(0),
110 theUpgradeHBHEElectronicsSim(0),
111 theUpgradeHFElectronicsSim(0),
112 theHFQIE10ElectronicsSim(0),
114 theHFHitFilter(ps.getParameter<bool>(
"doHFWindow")),
119 theNoiseGenerator(0),
120 theNoiseHitGenerator(0),
122 theHBHESiPMDigitizer(0),
124 theHOSiPMDigitizer(0),
127 theHBHEUpgradeDigitizer(0),
128 theHFUpgradeDigitizer(0),
129 theHFQIE10Digitizer(0),
137 hitsProducer_(ps.getParameter<std::
string>(
"hitsProducer")),
138 theHOSiPMCode(ps.getParameter<edm::
ParameterSet>(
"ho").getParameter<int>(
"siPMCode")),
147 bool PreMix1 = ps.
getParameter<
bool>(
"HcalPreMixStage1");
148 bool PreMix2 = ps.
getParameter<
bool>(
"HcalPreMixStage2");
154 double HBtp = ps.
getParameter<
double>(
"HBTuningParameter");
155 double HEtp = ps.
getParameter<
double>(
"HETuningParameter");
156 double HFtp = ps.
getParameter<
double>(
"HFTuningParameter");
157 double HOtp = ps.
getParameter<
double>(
"HOTuningParameter");
158 bool doHBHEUpgrade = ps.
getParameter<
bool>(
"HBHEUpgradeQIE");
159 bool doHFUpgrade = ps.
getParameter<
bool>(
"HFUpgradeQIE");
161 bool agingFlagHE = ps.
getParameter<
bool>(
"HEDarkening");
162 bool agingFlagHF = ps.
getParameter<
bool>(
"HFDarkening");
163 double minFCToDelay= ps.
getParameter<
double>(
"minFCToDelay");
167 if(PreMix1 && PreMix2) {
169 <<
"HcalDigitizer cannot operate in PreMixing digitization and PreMixing\n"
170 "digi combination modes at the same time. Please set one mode to False\n"
171 "in the configuration file.";
210 bool doHBHEHPD = hbSiPMCells.empty() || (hbSiPMCells[0] != 1);
212 bool doHBHESiPM = !hbSiPMCells.empty();
216 edm::LogInfo(
"HcalDigitizer") <<
"Set scale for HB towers";
221 bool changeResponse = ps.
getParameter<
bool>(
"ChangeResponse");
223 if (changeResponse) {
225 edm::LogInfo(
"HcalDigitizer") <<
"Set scale for HB towers from " << corrFileName;
254 if(doHBHEHPD && doHBHESiPM) {
276 if (doHFQIE10 || doHFQIE8) {
280 else if (doHFUpgrade) {
422 if (eventSetup.
find(edm::eventsetup::EventSetupRecordKey::makeKey<HcalCholeskyMatricesRcd>())) {
458 std::vector<PCaloHit> hcalHitsOrig = *hcalHandle.product();
459 std::vector<PCaloHit> hcalHits;
460 hcalHits.reserve(hcalHitsOrig.size());
473 for (
unsigned int i=0;
i< hcalHitsOrig.size();
i++) {
474 DetId id(hcalHitsOrig[
i].
id());
477 edm::LogError(
"HcalDigitizer") <<
"bad hcal id found in digitizer. Skipping " <<
id.rawId() <<
" " << hid << std::endl;
480 std::cout <<
"HcalDigitizer format " << hid.
oldFormat() <<
" for " << hid << std::endl;
486 hcalHitsOrig[
i].setID(newid.
rawId());
487 hcalHits.push_back(hcalHitsOrig[
i]);
513 edm::LogInfo(
"HcalDigitizer") <<
"We don't have HCAL hit collection available ";
521 edm::LogInfo(
"HcalDigitizer") <<
"We don't have ZDC hit collection available ";
581 std::cout <<
"HcalDigitizer::finalizeEvent theHBHEUpgradeDigitizer->run" << std::endl;
598 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HBHE digis : " << hbheResult->size();
599 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HO digis : " << hoResult->size();
600 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HF digis : " << hfResult->size();
601 edm::LogInfo(
"HcalDigitizer") <<
"HCAL ZDC digis : " << zdcResult->size();
602 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HBHE upgrade digis : " << hbheupgradeResult->size();
603 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HF upgrade digis : " << hfupgradeResult->size();
604 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HF QIE10 digis : " << hfQIE10Result->size();
608 std::cout <<
"HCAL HBHE digis : " << hbheResult->size() << std::endl;
609 std::cout <<
"HCAL HO digis : " << hoResult->size() << std::endl;
610 std::cout <<
"HCAL HF digis : " << hfResult->size() << std::endl;
612 std::cout <<
"HCAL HBHE upgrade digis : " << hbheupgradeResult->size()
614 std::cout <<
"HCAL HF upgrade digis : " << hfupgradeResult->size()
623 e.
put(hbheupgradeResult,
"HBHEUpgradeDigiCollection");
624 e.
put(hfupgradeResult,
"HFUpgradeDigiCollection");
625 e.
put(hfQIE10Result,
"HFQIE10DigiCollection");
628 std::cout << std::endl <<
"========> HcalDigitizer e.put " << std::endl << std::endl;
682 if(zdcCells.empty())
zdcgeo =
false;
683 if(hbCells.empty() && heCells.empty())
hbhegeo =
false;
684 if(hoCells.empty())
hogeo =
false;
685 if(hfCells.empty())
hfgeo =
false;
703 std::cout <<
" HcalDigitizer::updateGeometry theHBHEUpgradeDigitizer->setDetIds(theHBHEDetIds)"<< std::endl;
720 if (qieTypes.topo()==0) {
724 for(std::vector<DetId>::const_iterator detItr = allCells.begin(); detItr != allCells.end(); ++detItr) {
726 if(qieType ==
QIE8) {
728 }
else if(qieType ==
QIE10) {
757 std::vector<HcalDetId> zecotekDetIds, hamamatsuDetIds;
764 if (mcParams.topo()==0) {
768 for(std::vector<DetId>::const_iterator detItr = allCells.begin();
769 detItr != allCells.end(); ++detItr) {
770 int shapeType = mcParams.getValues(*detItr)->signalShape();
772 zecotekDetIds.emplace_back(*detItr);
775 hamamatsuDetIds.emplace_back(*detItr);
798 for (
unsigned int ii=0;
ii<hcalHits.size(); ++
ii) {
799 uint32_t tmpId = hcalHits[
ii].id();
803 bool darkened =
false;
820 if(darkened) hcalHits[
ii].setEnergy(hcalHits[
ii].
energy()*dweight);
std::vector< DetId > theHFQIE10DetIds
void setUseOldHB(bool useOld)
int bunchCrossing() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void setHOtuningParameter(double tp)
QIE10Digitizer * theHFQIE10Digitizer
T getParameter(std::string const &) const
void setNoiseHitGenerator(CaloVNoiseHitGenerator *generator)
void setGeometry(const CaloGeometry *geometry)
geometry needed for time-of-flight
void setDbService(const HcalDbService *service)
the Producer will probably update this every event
T getUntrackedParameter(std::string const &, T const &) const
HBHEHitFilter theHBHEHitFilter
CaloHitResponse * theHFQIE10Response
void setGeometry(const CaloGeometry *&, const HcalDDDRecConstants *&)
const HcalDDDRecConstants * theRecNumber
void add(const std::vector< PCaloHit > &hits, int bunchCrossing, CLHEP::HepRandomEngine *engine)
void setParameterMap(HcalSimParameterMap *map)
void setDetIds(const std::vector< DetId > &detIds)
HcalElectronicsSim * theHFElectronicsSim
void buildHFQIECells(const std::vector< DetId > &allCells, const edm::EventSetup &eventSetup)
HBHEDigitizer * theHBHEDigitizer
HOHitFilter theHOHitFilter
CaloTDigitizer< HcalUpgradeDigitizerTraits > UpgradeDigitizer
void setUseOldHF(bool useOld)
void darkening(std::vector< PCaloHit > &hcalHits)
HFDigitizer * theHFDigitizer
HFHitFilter theHFHitFilter
void checkGeometry(const edm::EventSetup &eventSetup)
HcalSimParameterMap * theParameterMap
void setHFtuningParameter(double tp)
bool validHcal(const HcalDetId &id) const
void setPECorrection(const CaloVPECorrection *peCorrection)
if you want to correct the photoelectrons
HcalTimeSlewSim * theTimeSlewSim
void setADCPeds(const HcalPedestals *ADCPeds)
HcalAmplifier * theHFAmplifier
HcalElectronicsSim * theUpgradeHFElectronicsSim
void fillSiPMCells(std::vector< int > &siPMCells, SIPMDIGITIZER *siPMDigitizer)
HcalCoderFactory * theCoderFactory
HcalHitRelabeller * theRelabeller
edm::SortedCollection< ZDCDataFrame > ZDCDigiCollection
HcalCoderFactory * theUpgradeCoderFactory
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
HcalDataFrameContainer< QIE10DataFrame > QIE10DigiCollection
void initializeEvent(edm::Event const &e, edm::EventSetup const &c)
void setDbService(const HcalDbService *service)
void setIonFeedbackSim(HPDIonFeedbackSim *feedbackSim)
uint32_t rawId() const
get the raw id
UpgradeDigitizer * theHFUpgradeDigitizer
void accumulate(edm::Event const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *)
CaloTDigitizer< HFDigitizerTraits > HFDigitizer
void setHOZecotekDetIds(const std::vector< HcalDetId > &ids)
HcalAmplifier * theHBHEAmplifier
void setUseOldHO(bool useOld)
edm::SortedCollection< HODataFrame > HODigiCollection
CaloTDigitizer< ZDCDigitizerTraits > ZDCDigitizer
std::string hitsProducer_
HcalElectronicsSim * theHOElectronicsSim
void setHEtuningParameter(double tp)
void setUseOldHE(bool useOld)
void setElectronicsSim(HcalElectronicsSim *electronicsSim)
void setHitFilter(const CaloVHitFilter *filter)
if you want to reject hits, for example, from a certain subdetector, set this
double getCorr(int ieta, int idepth, double lumi)
Creates electronics signals from hits.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
void setHFNoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator)
std::vector< DetId > theHBHEDetIds
void buildHOSiPMCells(const std::vector< DetId > &allCells, const edm::EventSetup &eventSetup)
ZDCHitFilter theZDCHitFilter
HPDIonFeedbackSim * theIonFeedback
void fillChargeSums(MixCollection< PCaloHit > &hits)
CaloHitResponse * theHOResponse
HcalHitFilter theHOSiPMHitFilter
CaloHitResponse * theHOSiPMResponse
static void unpackHcalIndex(const uint32_t &idx, int &det, int &z, int &depth, int &eta, int &phi, int &lay)
void setHBHEScale(std::string &)
ZDCDigitizer * theZDCDigitizer
edm::SortedCollection< HcalUpgradeDataFrame > HFUpgradeDigiCollection
void setNoiseSignalGenerator(CaloVNoiseSignalGenerator *generator)
std::vector< DetId > theHOHPDDetIds
edm::SortedCollection< HcalUpgradeDataFrame > HBHEUpgradeDigiCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
HcalHitCorrection * theHitCorrection
CaloHitResponse * theZDCResponse
void setNoiseSignalGenerator(const CaloVNoiseSignalGenerator *noiseSignalGenerator)
HcalElectronicsSim * theZDCElectronicsSim
HcalElectronicsSim * theUpgradeHBHEElectronicsSim
static const int SubdetectorId
void beginRun(const edm::EventSetup &es)
CaloTDigitizer< HcalQIE10DigitizerTraits, CaloTDigitizerQIE10Run > QIE10Digitizer
void process(std::vector< PCaloHit > &hcalHits)
CaloTDigitizer< HODigitizerTraits > HODigitizer
void setTimeSlewSim(HcalTimeSlewSim *timeSlewSim)
void setHOHamamatsuDetIds(const std::vector< HcalDetId > &ids)
void accumulateCaloHits(edm::Handle< std::vector< PCaloHit > > const &hcalHits, edm::Handle< std::vector< PCaloHit > > const &zdcHits, int bunchCrossing, CLHEP::HepRandomEngine *, const HcalTopology *h)
HcalAmplifier * theHOAmplifier
std::vector< DetId > theHFQIE8DetIds
void setDbService(const HcalDbService *service)
HFRecalibration * m_HFRecalibration
HcalElectronicsSim * theHBHEElectronicsSim
T const * product() const
void run(MixCollection< PCaloHit > &, DigiCollection &)
turns hits into digis
void fillCells(std::vector< DetId > &allCells, HPDDIGITIZER *hpdDigitizer, SIPMDIGITIZER *siPMDigitizer)
CaloHitResponse * theHBHEResponse
HODigitizer * theHODigitizer
std::vector< DetId > theHOSiPMDetIds
const CaloGeometry * theGeometry
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
void setCholesky(const HcalCholeskyMatrices *Cholesky)
ESHandle< TrackerGeometry > geometry
CaloHitResponse * theHFResponse
HcalElectronicsSim * theHFQIE10ElectronicsSim
HODigitizer * theHOSiPMDigitizer
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
void setZDCNoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator)
HBHEDigitizer * theHBHESiPMDigitizer
HEDarkening * m_HEDarkening
edm::SortedCollection< HFDataFrame > HFDigiCollection
void beginRun(edm::EventSetup const &es)
CaloHitResponse * theHBHESiPMResponse
void setHBtuningParameter(double tp)
void updateGeometry(const edm::EventSetup &eventSetup)
float degradation(float intlumi, int ieta, int lay)
void setHBHENoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator)
CaloVNoiseHitGenerator * theNoiseHitGenerator
HcalAmplifier * theZDCAmplifier
void setTopo(const HcalTopology *topo)
void setDbService(const HcalDbService *service)
void setDetIds(const std::vector< DetId > &detIds)
edm::SortedCollection< HBHEDataFrame > HBHEDigiCollection
void finalizeEvent(edm::Event &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *)
UpgradeDigitizer * theHBHEUpgradeDigitizer
void setHONoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator)
CaloTDigitizer< HBHEDigitizerTraits > HBHEDigitizer
HcalDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector &iC)
CaloVNoiseSignalGenerator * theNoiseGenerator