37 #include <boost/foreach.hpp>
42 namespace HcalDigitizerImpl {
44 template<
typename SIPMDIGITIZER>
45 void fillSiPMCells(std::vector<int> & siPMCells, SIPMDIGITIZER * siPMDigitizer)
47 std::vector<DetId> siPMDetIds;
48 siPMDetIds.reserve(siPMCells.size());
49 for(std::vector<int>::const_iterator idItr = siPMCells.begin();
50 idItr != siPMCells.end(); ++idItr)
52 siPMDetIds.emplace_back(*idItr);
54 siPMDigitizer->setDetIds(siPMDetIds);
59 template<
typename HPDDIGITIZER,
typename SIPMDIGITIZER>
61 HPDDIGITIZER * hpdDigitizer,
62 SIPMDIGITIZER * siPMDigitizer)
65 if(siPMDigitizer && hpdDigitizer)
67 std::vector<DetId> siPMDetIds = siPMDigitizer->detIds();
68 std::sort(siPMDetIds.begin(), siPMDetIds.end());
69 std::vector<DetId> sortedCells = allCells;
70 std::sort(sortedCells.begin(), sortedCells.end());
71 std::vector<DetId> hpdCells;
72 std::set_difference(sortedCells.begin(), sortedCells.end(),
73 siPMDetIds.begin(), siPMDetIds.end(),
74 std::back_inserter(hpdCells) );
75 hpdDigitizer->setDetIds(hpdCells);
79 if(siPMDigitizer) siPMDigitizer->setDetIds(allCells);
80 if(hpdDigitizer) hpdDigitizer->setDetIds(allCells);
91 theHBHESiPMResponse(0),
102 theUpgradeCoderFactory(0),
103 theHBHEElectronicsSim(0),
104 theHFElectronicsSim(0),
105 theHOElectronicsSim(0),
106 theZDCElectronicsSim(0),
107 theUpgradeHBHEElectronicsSim(0),
108 theUpgradeHFElectronicsSim(0),
110 theHFHitFilter(ps.getParameter<bool>(
"doHFWindow")),
115 theNoiseGenerator(0),
116 theNoiseHitGenerator(0),
118 theHBHESiPMDigitizer(0),
120 theHOSiPMDigitizer(0),
123 theHBHEUpgradeDigitizer(0),
124 theHFUpgradeDigitizer(0),
132 hitsProducer_(ps.getParameter<std::
string>(
"hitsProducer")),
133 theHOSiPMCode(ps.getParameter<edm::
ParameterSet>(
"ho").getParameter<int>(
"siPMCode")),
142 bool PreMix1 = ps.
getParameter<
bool>(
"HcalPreMixStage1");
143 bool PreMix2 = ps.
getParameter<
bool>(
"HcalPreMixStage2");
149 double HBtp = ps.
getParameter<
double>(
"HBTuningParameter");
150 double HEtp = ps.
getParameter<
double>(
"HETuningParameter");
151 double HFtp = ps.
getParameter<
double>(
"HFTuningParameter");
152 double HOtp = ps.
getParameter<
double>(
"HOTuningParameter");
153 bool doHBHEUpgrade = ps.
getParameter<
bool>(
"HBHEUpgradeQIE");
154 bool doHFUpgrade = ps.
getParameter<
bool>(
"HFUpgradeQIE");
156 bool agingFlagHE = ps.
getParameter<
bool>(
"HEDarkening");
157 bool agingFlagHF = ps.
getParameter<
bool>(
"HFDarkening");
160 if(PreMix1 && PreMix2) {
162 <<
"HcalDigitizer cannot operate in PreMixing digitization and PreMixing\n"
163 "digi combination modes at the same time. Please set one mode to False\n"
164 "in the configuration file.";
203 bool doHBHEHPD = hbSiPMCells.empty() || (hbSiPMCells[0] != 1);
205 bool doHBHESiPM = !hbSiPMCells.empty();
209 edm::LogInfo(
"HcalDigitizer") <<
"Set scale for HB towers";
214 bool changeResponse = ps.
getParameter<
bool>(
"ChangeResponse");
216 if (changeResponse) {
218 edm::LogInfo(
"HcalDigitizer") <<
"Set scale for HB towers from " << corrFileName;
247 if(doHBHEHPD && doHBHESiPM) {
325 <<
"HcalDigitizer requires the RandomNumberGeneratorService\n"
326 "which is not present in the configuration file. You must add the service\n"
327 "in the configuration file or remove the modules that require it.";
330 CLHEP::HepRandomEngine& engine = rng->
getEngine();
337 if(theTimeSlewSim) theTimeSlewSim->setRandomEngine(engine);
462 std::vector<PCaloHit> hcalHits = *hcalHandle.product();
494 edm::LogInfo(
"HcalDigitizer") <<
"We don't have HCAL hit collection available ";
502 edm::LogInfo(
"HcalDigitizer") <<
"We don't have ZDC hit collection available ";
568 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HBHE digis : " << hbheResult->size();
569 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HO digis : " << hoResult->size();
570 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HF digis : " << hfResult->size();
571 edm::LogInfo(
"HcalDigitizer") <<
"HCAL ZDC digis : " << zdcResult->size();
572 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HBHE upgrade digis : " << hbheupgradeResult->size();
573 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HF upgrade digis : " << hfupgradeResult->size();
592 e.
put(hbheupgradeResult,
"HBHEUpgradeDigiCollection");
593 e.
put(hfupgradeResult,
"HFUpgradeDigiCollection");
645 if(zdcCells.empty())
zdcgeo =
false;
646 if(hbCells.empty() && heCells.empty())
hbhegeo =
false;
647 if(hoCells.empty())
hogeo =
false;
648 if(hfCells.empty())
hfgeo =
false;
677 std::vector<HcalDetId> zecotekDetIds, hamamatsuDetIds;
684 if (mcParams.topo()==0) {
688 for(std::vector<DetId>::const_iterator detItr = allCells.begin();
689 detItr != allCells.end(); ++detItr) {
690 int shapeType = mcParams.getValues(*detItr)->signalShape();
692 zecotekDetIds.emplace_back(*detItr);
695 hamamatsuDetIds.emplace_back(*detItr);
718 for (
unsigned int ii=0;
ii<hcalHits.size(); ++
ii) {
719 uint32_t tmpId = hcalHits[
ii].id();
720 int det,
z, depth, ieta,
phi, lay;
723 bool darkened =
false;
742 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 setRandomEngine(CLHEP::HepRandomEngine &engine)
void add(const std::vector< PCaloHit > &hits, int bunchCrossing)
void setUseOldHF(bool useOld)
void darkening(std::vector< PCaloHit > &hcalHits)
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
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 setRandomEngine(CLHEP::HepRandomEngine &engine)
need a shaper in order to set thermal noise
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
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
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 setNoiseSignalGenerator(const CaloVNoiseSignalGenerator *noiseSignalGenerator)
void accumulateCaloHits(edm::Handle< std::vector< PCaloHit > > const &hcalHits, edm::Handle< std::vector< PCaloHit > > const &zdcHits, int bunchCrossing)
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 accumulate(edm::Event const &e, edm::EventSetup const &c)
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 setRandomEngine(CLHEP::HepRandomEngine &engine)
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)
UpgradeDigitizer * theHBHEUpgradeDigitizer
void setHONoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator)
CaloTDigitizer< HBHEDigitizerTraits > HBHEDigitizer
HcalDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector &iC)
CaloVNoiseSignalGenerator * theNoiseGenerator