35 #include <boost/foreach.hpp>
40 namespace HcalDigitizerImpl {
42 template<
typename SIPMDIGITIZER>
43 void fillSiPMCells(std::vector<int> & siPMCells, SIPMDIGITIZER * siPMDigitizer)
45 std::vector<DetId> siPMDetIds;
46 siPMDetIds.reserve(siPMCells.size());
47 for(std::vector<int>::const_iterator idItr = siPMCells.begin();
48 idItr != siPMCells.end(); ++idItr)
50 siPMDetIds.emplace_back(*idItr);
52 siPMDigitizer->setDetIds(siPMDetIds);
57 template<
typename HPDDIGITIZER,
typename SIPMDIGITIZER>
59 HPDDIGITIZER * hpdDigitizer,
60 SIPMDIGITIZER * siPMDigitizer)
63 if(siPMDigitizer && hpdDigitizer)
65 std::vector<DetId> siPMDetIds = siPMDigitizer->detIds();
66 std::sort(siPMDetIds.begin(), siPMDetIds.end());
67 std::vector<DetId> sortedCells = allCells;
68 std::sort(sortedCells.begin(), sortedCells.end());
69 std::vector<DetId> hpdCells;
70 std::set_difference(sortedCells.begin(), sortedCells.end(),
71 siPMDetIds.begin(), siPMDetIds.end(),
72 std::back_inserter(hpdCells) );
73 hpdDigitizer->setDetIds(hpdCells);
77 if(siPMDigitizer) siPMDigitizer->setDetIds(allCells);
78 if(hpdDigitizer) hpdDigitizer->setDetIds(allCells);
89 theHBHESiPMResponse(0),
100 theUpgradeCoderFactory(0),
101 theHBHEElectronicsSim(0),
102 theHFElectronicsSim(0),
103 theHOElectronicsSim(0),
104 theZDCElectronicsSim(0),
105 theUpgradeHBHEElectronicsSim(0),
106 theUpgradeHFElectronicsSim(0),
108 theHFHitFilter(ps.getParameter<bool>(
"doHFWindow")),
113 theNoiseGenerator(0),
114 theNoiseHitGenerator(0),
116 theHBHESiPMDigitizer(0),
118 theHOSiPMDigitizer(0),
121 theHBHEUpgradeDigitizer(0),
122 theHFUpgradeDigitizer(0),
130 hitsProducer_(ps.getParameter<std::
string>(
"hitsProducer")),
131 theHOSiPMCode(ps.getParameter<edm::
ParameterSet>(
"ho").getParameter<int>(
"siPMCode")),
140 bool PreMix1 = ps.
getParameter<
bool>(
"HcalPreMixStage1");
141 bool PreMix2 = ps.
getParameter<
bool>(
"HcalPreMixStage2");
147 double HBtp = ps.
getParameter<
double>(
"HBTuningParameter");
148 double HEtp = ps.
getParameter<
double>(
"HETuningParameter");
149 double HFtp = ps.
getParameter<
double>(
"HFTuningParameter");
150 double HOtp = ps.
getParameter<
double>(
"HOTuningParameter");
151 bool doHBHEUpgrade = ps.
getParameter<
bool>(
"HBHEUpgradeQIE");
152 bool doHFUpgrade = ps.
getParameter<
bool>(
"HFUpgradeQIE");
154 bool agingFlagHE = ps.
getParameter<
bool>(
"HEDarkening");
155 bool agingFlagHF = ps.
getParameter<
bool>(
"HFDarkening");
158 if(PreMix1 && PreMix2) {
160 <<
"HcalDigitizer cannot operate in PreMixing digitization and PreMixing\n"
161 "digi combination modes at the same time. Please set one mode to False\n"
162 "in the configuration file.";
201 bool doHBHEHPD = hbSiPMCells.empty() || (hbSiPMCells[0] != 1);
203 bool doHBHESiPM = !hbSiPMCells.empty();
207 edm::LogInfo(
"HcalDigitizer") <<
"Set scale for HB towers";
212 bool changeResponse = ps.
getParameter<
bool>(
"ChangeResponse");
214 if (changeResponse) {
216 edm::LogInfo(
"HcalDigitizer") <<
"Set scale for HB towers from " << corrFileName;
245 if(doHBHEHPD && doHBHESiPM) {
438 std::vector<PCaloHit> hcalHits = *hcalHandle.product();
470 edm::LogInfo(
"HcalDigitizer") <<
"We don't have HCAL hit collection available ";
478 edm::LogInfo(
"HcalDigitizer") <<
"We don't have ZDC hit collection available ";
544 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HBHE digis : " << hbheResult->size();
545 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HO digis : " << hoResult->size();
546 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HF digis : " << hfResult->size();
547 edm::LogInfo(
"HcalDigitizer") <<
"HCAL ZDC digis : " << zdcResult->size();
548 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HBHE upgrade digis : " << hbheupgradeResult->size();
549 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HF upgrade digis : " << hfupgradeResult->size();
568 e.
put(hbheupgradeResult,
"HBHEUpgradeDigiCollection");
569 e.
put(hfupgradeResult,
"HFUpgradeDigiCollection");
621 if(zdcCells.empty())
zdcgeo =
false;
622 if(hbCells.empty() && heCells.empty())
hbhegeo =
false;
623 if(hoCells.empty())
hogeo =
false;
624 if(hfCells.empty())
hfgeo =
false;
653 std::vector<HcalDetId> zecotekDetIds, hamamatsuDetIds;
660 if (mcParams.topo()==0) {
664 for(std::vector<DetId>::const_iterator detItr = allCells.begin();
665 detItr != allCells.end(); ++detItr) {
666 int shapeType = mcParams.getValues(*detItr)->signalShape();
668 zecotekDetIds.emplace_back(*detItr);
671 hamamatsuDetIds.emplace_back(*detItr);
694 for (
unsigned int ii=0;
ii<hcalHits.size(); ++
ii) {
695 uint32_t tmpId = hcalHits[
ii].id();
696 int det,
z, depth, ieta,
phi, lay;
699 bool darkened =
false;
718 if(darkened) hcalHits[
ii].setEnergy(hcalHits[
ii].
energy()*dweight);
void setUseOldHB(bool useOld)
void setNoiseHitGenerator(CaloVNoiseHitGenerator *generator)
int bunchCrossing() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void setHOtuningParameter(double tp)
T getParameter(std::string const &) const
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
void setParameterMap(HcalSimParameterMap *map)
void setDetIds(const std::vector< DetId > &detIds)
HcalElectronicsSim * theHFElectronicsSim
HBHEDigitizer * theHBHEDigitizer
HOHitFilter theHOHitFilter
CaloTDigitizer< HcalUpgradeDigitizerTraits > UpgradeDigitizer
void setUseOldHF(bool useOld)
void darkening(std::vector< PCaloHit > &hcalHits)
void add(const std::vector< PCaloHit > &hits, int bunchCrossing, CLHEP::HepRandomEngine *engine)
void setTopo(const HcalTopology *topo) const
HFDigitizer * theHFDigitizer
HFHitFilter theHFHitFilter
void checkGeometry(const edm::EventSetup &eventSetup)
HcalSimParameterMap * theParameterMap
void setHFtuningParameter(double tp)
void setPECorrection(const CaloVPECorrection *peCorrection)
if you want to correct the photoelectrons
HcalTimeSlewSim * theTimeSlewSim
void setADCPeds(const HcalPedestals *ADCPeds)
void setGeometry(const CaloGeometry *&theGeometry)
HcalAmplifier * theHFAmplifier
HcalElectronicsSim * theUpgradeHFElectronicsSim
void fillSiPMCells(std::vector< int > &siPMCells, SIPMDIGITIZER *siPMDigitizer)
HcalCoderFactory * theCoderFactory
HcalHitRelabeller * theRelabeller
edm::SortedCollection< ZDCDataFrame > ZDCDigiCollection
HcalCoderFactory * theUpgradeCoderFactory
void initializeEvent(edm::Event const &e, edm::EventSetup const &c)
void setDbService(const HcalDbService *service)
void setIonFeedbackSim(HPDIonFeedbackSim *feedbackSim)
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 &)
void setNoiseSignalGenerator(CaloVNoiseSignalGenerator *generator)
ZDCDigitizer * theZDCDigitizer
edm::SortedCollection< HcalUpgradeDataFrame > HFUpgradeDigiCollection
std::vector< DetId > theHOHPDDetIds
edm::SortedCollection< HcalUpgradeDataFrame > HBHEUpgradeDigiCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
HcalHitCorrection * theHitCorrection
CaloHitResponse * theZDCResponse
void accumulateCaloHits(edm::Handle< std::vector< PCaloHit > > const &hcalHits, edm::Handle< std::vector< PCaloHit > > const &zdcHits, int bunchCrossing, CLHEP::HepRandomEngine *)
void setNoiseSignalGenerator(const CaloVNoiseSignalGenerator *noiseSignalGenerator)
HcalElectronicsSim * theZDCElectronicsSim
HcalElectronicsSim * theUpgradeHBHEElectronicsSim
void run(MixCollection< PCaloHit > &, DigiCollection &)
turns hits into digis
static const int SubdetectorId
void beginRun(const edm::EventSetup &es)
void process(std::vector< PCaloHit > &hcalHits)
CaloTDigitizer< HODigitizerTraits > HODigitizer
void setTimeSlewSim(HcalTimeSlewSim *timeSlewSim)
void setHOHamamatsuDetIds(const std::vector< HcalDetId > &ids)
HcalAmplifier * theHOAmplifier
void setDbService(const HcalDbService *service)
HFRecalibration * m_HFRecalibration
HcalElectronicsSim * theHBHEElectronicsSim
T const * product() const
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
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 setDetIds(const std::vector< DetId > &detIds)
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 setDbService(const HcalDbService *service)
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