CMS 3D CMS Logo

HcalTBDigiProducer.cc
Go to the documentation of this file.
9 
19 
21 
23  edm::ProducesCollector producesCollector,
25  : theParameterMap(new HcalTBSimParameterMap(ps)),
26  paraMap(new HcalSimParameterMap(ps)),
27  theHcalShape(new HcalShape()),
28  theHcalIntegratedShape(new CaloShapeIntegrator(theHcalShape)),
29  theHBHEResponse(new CaloHitResponse(theParameterMap, theHcalIntegratedShape)),
30  theHOResponse(new CaloHitResponse(theParameterMap, theHcalIntegratedShape)),
31  theAmplifier(nullptr),
32  theCoderFactory(nullptr),
33  theElectronicsSim(nullptr),
34  theTimeSlewSim(nullptr),
35  theHBHEDigitizer(nullptr),
36  theHODigitizer(nullptr),
37  theHBHEHits(),
38  theHOHits(),
39  thisPhaseShift(0) {
40  std::string const instance("simHcalDigis");
41  producesCollector.produces<HBHEDigiCollection>(instance);
42  producesCollector.produces<HODigiCollection>(instance);
43  iC.consumes<std::vector<PCaloHit>>(edm::InputTag("g4SimHits", "HcalHits"));
44 
45  DetId detId(DetId::Hcal, 1);
48 
51 
52  bool doNoise = ps.getParameter<bool>("doNoise");
53  bool dummy1 = false;
54  bool dummy2 = false; // extra arguments for premixing
55  theAmplifier = new HcalAmplifier(theParameterMap, doNoise, dummy1, dummy2);
58 
59  double minFCToDelay = ps.getParameter<double>("minFCToDelay");
60  bool doTimeSlew = ps.getParameter<bool>("doTimeSlew");
61 
62  hcalTimeSlew_delay_ = nullptr;
63  if (doTimeSlew) {
64  // no time slewing for HF
67  }
68 
71 
72  tunePhaseShift = ps.getUntrackedParameter<double>("tunePhaseShiftTB", 1.);
73  ecalTBInfoLabel = ps.getUntrackedParameter<std::string>("EcalTBInfoLabel", "SimEcalTBG4Object");
74  edm::LogInfo("HcalSim") << "HcalTBDigiProducer initialized with doNoise = " << doNoise
75  << ", doTimeSlew = " << doTimeSlew << " and doPhaseShift = " << doPhaseShift
76  << " tunePhasShift = " << tunePhaseShift;
77 
78  if (doPhaseShift) {
80  }
81 }
82 
84  if (theHBHEDigitizer)
85  delete theHBHEDigitizer;
86  if (theHODigitizer)
87  delete theHODigitizer;
88  if (theParameterMap)
89  delete theParameterMap;
90  if (theHcalShape)
91  delete theHcalShape;
94  if (theHBHEResponse)
95  delete theHBHEResponse;
96  if (theHOResponse)
97  delete theHOResponse;
99  delete theElectronicsSim;
100  if (theAmplifier)
101  delete theAmplifier;
102  if (theCoderFactory)
103  delete theCoderFactory;
104  if (theTimeSlewSim)
105  delete theTimeSlewSim;
106 }
107 
109  // get the appropriate gains, noises, & widths for this event
110  edm::ESHandle<HcalDbService> conditions;
111  eventSetup.get<HcalDbRecord>().get(conditions);
112  theAmplifier->setDbService(conditions.product());
113  theCoderFactory->setDbService(conditions.product());
114 
115  // get the correct geometry
116  checkGeometry(eventSetup);
117 
118  // Cache random number engine
120  randomEngine_ = &rng->getEngine(e.streamID());
121 
122  theHBHEHits.clear();
123  theHOHits.clear();
124  if (doPhaseShift) {
125  edm::Handle<PEcalTBInfo> theEcalTBInfo;
126  e.getByLabel(ecalTBInfoLabel, theEcalTBInfo);
127  thisPhaseShift = theEcalTBInfo->phaseShift();
128 
129  DetId detIdHB(DetId::Hcal, 1);
130  setPhaseShift(detIdHB);
131  DetId detIdHO(DetId::Hcal, 3);
132  setPhaseShift(detIdHO);
133  }
134 
136  eventSetup.get<HcalTimeSlewRecord>().get("HBHE", delay);
138 
140 
143 }
144 
145 void HcalTBDigiProducer::accumulateCaloHits(edm::Handle<std::vector<PCaloHit>> const &hcalHandle, int bunchCrossing) {
146  LogDebug("HcalSim") << "HcalTBDigiProducer::accumulate trying to get SimHit";
147 
148  if (hcalHandle.isValid()) {
149  std::vector<PCaloHit> hits = *hcalHandle.product();
150  LogDebug("HcalSim") << "HcalTBDigiProducer::accumulate Hits corrected";
151  theHBHEDigitizer->add(hits, bunchCrossing, randomEngine_);
152  theHODigitizer->add(hits, bunchCrossing, randomEngine_);
153  }
154 }
155 
157  // Step A: Get Inputs, and accumulate digis
158 
159  edm::InputTag hcalTag("g4SimHits", "HcalHits");
161  e.getByLabel(hcalTag, hcalHandle);
162 
163  accumulateCaloHits(hcalHandle, 0);
164 }
165 
167  edm::EventSetup const &,
168  edm::StreamID const &streamID) {
169  // Step A: Get Inputs, and accumulate digis
170 
171  edm::InputTag hcalTag("g4SimHits", "HcalHits");
173  e.getByLabel(hcalTag, hcalHandle);
174 
175  accumulateCaloHits(hcalHandle, e.bunchCrossing());
176 }
177 
179  // Step B: Create empty output
180  std::unique_ptr<HBHEDigiCollection> hbheResult(new HBHEDigiCollection());
181  std::unique_ptr<HODigiCollection> hoResult(new HODigiCollection());
182  LogDebug("HcalSim") << "HcalTBDigiProducer::produce Empty collection created";
183  // Step C: Invoke the algorithm, getting back outputs.
184  theHBHEDigitizer->run(*hbheResult, randomEngine_);
185  edm::LogInfo("HcalSim") << "HcalTBDigiProducer: HBHE digis : " << hbheResult->size();
186  theHODigitizer->run(*hoResult, randomEngine_);
187  edm::LogInfo("HcalSim") << "HcalTBDigiProducer: HO digis : " << hoResult->size();
188 
189  // Step D: Put outputs into event
190  std::string const instance("simHcalDigis");
191  e.put(std::move(hbheResult), instance);
192  e.put(std::move(hoResult), instance);
193 
194  randomEngine_ = nullptr; // to prevent access outside event
195 }
196 
198  for (edm::PCaloHitContainer::const_iterator hitItr = hits.begin(); hitItr != hits.end(); ++hitItr) {
199  HcalSubdetector subdet = HcalDetId(hitItr->id()).subdet();
200  if (subdet == HcalBarrel || subdet == HcalEndcap) {
201  theHBHEHits.push_back(*hitItr);
202  } else if (subdet == HcalOuter) {
203  theHOHits.push_back(*hitItr);
204  } else {
205  edm::LogError("HcalSim") << "Bad HcalHit subdetector " << subdet;
206  }
207  }
208 }
209 
211  // TODO find a way to avoid doing this every event
213  eventSetup.get<CaloGeometryRecord>().get(geometry);
214 
215  const CaloGeometry *pGeometry = &*geometry;
216 
217  // see if we need to update
218  if (pGeometry != theGeometry) {
219  theGeometry = pGeometry;
220  updateGeometry();
221  }
222 }
223 
227 
228  // Get cells for HB and HE
229  hbheCells.clear();
231  std::vector<DetId> heCells = theGeometry->getValidDetIds(DetId::Hcal, HcalEndcap);
232  // combine HB & HE
233  hbheCells.insert(hbheCells.end(), heCells.begin(), heCells.end());
234 
235  // Get cells for HO
236  hoCells.clear();
238 
239  edm::LogInfo("HcalSim") << "HcalTBDigiProducer update Geometry with " << hbheCells.size() << " cells in HB/HE and "
240  << hoCells.size() << " cells in HO";
241 
243  LogDebug("HcalSim") << "HcalTBDigiProducer: Set DetID's for HB/HE";
245  LogDebug("HcalSim") << "HcalTBDigiProducer: Set DetID's for HO";
246 }
247 
250  if (!parameters.syncPhase()) {
251  int myDet = detId.subdetId();
252  double passPhaseShift = thisPhaseShift + tunePhaseShift;
253  if (myDet <= 2) {
254  theHBHEResponse->setPhaseShift(passPhaseShift);
255  } else {
256  theHOResponse->setPhaseShift(passPhaseShift);
257  }
258  }
259 }
CaloTDigitizer::add
void add(const std::vector< PCaloHit > &hits, int bunchCrossing, CLHEP::HepRandomEngine *engine)
Definition: CaloTDigitizer.h:75
HcalTBDigiProducer::hoCells
std::vector< DetId > hoCells
Definition: HcalTBDigiProducer.h:87
HcalTBDigiProducer::theElectronicsSim
HcalElectronicsSim * theElectronicsSim
Definition: HcalTBDigiProducer.h:75
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
PEcalTBInfo::phaseShift
double phaseShift() const
Definition: PEcalTBInfo.h:37
edm::StreamID
Definition: StreamID.h:30
CaloShapeIntegrator.h
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
geometry
ESHandle< TrackerGeometry > geometry
Definition: TkLasBeamFitter.cc:200
Handle.h
HcalTBDigiProducer::theHBHEHits
std::vector< PCaloHit > theHBHEHits
Definition: HcalTBDigiProducer.h:89
MessageLogger.h
HcalTBSimParameterMap
Definition: HcalTBSimParameterMap.h:8
ecalSimParameterMap_cff.syncPhase
syncPhase
Definition: ecalSimParameterMap_cff.py:11
HcalTBDigiProducer::doPhaseShift
bool doPhaseShift
Definition: HcalTBDigiProducer.h:94
HcalTBDigiProducer::theTimeSlewSim
HcalTimeSlewSim * theTimeSlewSim
Definition: HcalTBDigiProducer.h:80
HcalTBDigiProducer::theParameterMap
HcalTBSimParameterMap * theParameterMap
Definition: HcalTBDigiProducer.h:65
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
ESHandle.h
HcalTBDigiProducer::theHOHitFilter
HOHitFilter theHOHitFilter
Definition: HcalTBDigiProducer.h:78
HcalTBDigiProducer::theHBHEResponse
CaloHitResponse * theHBHEResponse
Definition: HcalTBDigiProducer.h:70
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
RandomNumberGenerator.h
HcalTBDigiProducer::hcalTimeSlew_delay_
const HcalTimeSlew * hcalTimeSlew_delay_
Definition: HcalTBDigiProducer.h:58
geometry
Definition: geometry.py:1
HcalTBDigiProducer::theHOHits
std::vector< PCaloHit > theHOHits
Definition: HcalTBDigiProducer.h:89
DetId::Hcal
Definition: DetId.h:28
edm::LogInfo
Definition: MessageLogger.h:254
HcalTBDigiProducer::theGeometry
const CaloGeometry * theGeometry
Definition: HcalTBDigiProducer.h:85
HcalTimeSlew.h
CaloTDigitizer::initializeHits
void initializeHits()
Definition: CaloTDigitizer.h:83
edm::SortedCollection
Definition: SortedCollection.h:49
CaloTDigitizer::setDetIds
void setDetIds(const std::vector< DetId > &detIds)
Definition: CaloTDigitizer.h:67
PileUpEventPrincipal
Definition: PileUpEventPrincipal.h:19
HcalTBDigiProducer::finalizeEvent
void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
Definition: HcalTBDigiProducer.cc:178
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
HcalTBDigiProducer::tunePhaseShift
double tunePhaseShift
Definition: HcalTBDigiProducer.h:95
HcalBarrel
Definition: HcalAssistant.h:33
HODigiCollection
edm::SortedCollection< HODataFrame > HODigiCollection
Definition: HcalDigiCollections.h:21
CaloShapeIntegrator
Definition: CaloShapeIntegrator.h:11
edm::Handle
Definition: AssociativeIterator.h:50
HcalTBDigiProducer::HcalTBDigiProducer
HcalTBDigiProducer(const edm::ParameterSet &ps, edm::ProducesCollector, edm::ConsumesCollector &iC)
Definition: HcalTBDigiProducer.cc:22
HcalCoderFactory
Definition: HcalCoderFactory.h:8
parameters
parameters
Definition: BeamSpot_PayloadInspector.cc:14
DigiDM_cff.doNoise
doNoise
Definition: DigiDM_cff.py:32
DetId
Definition: DetId.h:17
HcalCoderFactory::setDbService
void setDbService(const HcalDbService *service)
Definition: HcalCoderFactory.h:14
CaloGeometry
Definition: CaloGeometry.h:21
HcalTBDigiProducer::thisPhaseShift
double thisPhaseShift
Definition: HcalTBDigiProducer.h:92
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
Service.h
HcalDigiCollections.h
CaloSimParameters
Main class for Parameters in different subdetectors.
Definition: CaloSimParameters.h:14
edm::ESHandle< HcalDbService >
PileUpEventPrincipal.h
HcalTimeSlewRecord
Definition: HcalTimeSlewRecord.h:4
HcalSimParameterMap
Definition: HcalSimParameterMap.h:10
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:49
HcalOuter
Definition: HcalAssistant.h:35
CaloHitResponse::setPhaseShift
void setPhaseShift(const double &thePhaseShift)
setting the phase shift for asynchronous trigger (e.g. test beams)
Definition: CaloHitResponse.h:108
HcalTBDigiProducer::HODigitizer
CaloTDigitizer< HODigitizerTraits > HODigitizer
Definition: HcalTBDigiProducer.h:63
HcalDbRecord.h
HcalTBDigiProducer::checkGeometry
void checkGeometry(const edm::EventSetup &eventSetup)
Definition: HcalTBDigiProducer.cc:210
hcalUnsuppressedDigis_cfi.doTimeSlew
doTimeSlew
Definition: hcalUnsuppressedDigis_cfi.py:20
HcalTBDigiProducer::HBHEDigitizer
CaloTDigitizer< HBHEDigitizerTraits > HBHEDigitizer
Definition: HcalTBDigiProducer.h:62
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
CaloGeometryRecord.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalTBDigiProducer::theHOResponse
CaloHitResponse * theHOResponse
Definition: HcalTBDigiProducer.h:71
HcalAmplifier::setTimeSlew
void setTimeSlew(const HcalTimeSlew *timeSlew)
Definition: HcalAmplifier.h:38
PEcalTBInfo.h
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
CaloHitResponse::setHitFilter
void setHitFilter(const CaloVHitFilter *filter)
Definition: CaloHitResponse.h:70
PEcalTBInfo
Definition: PEcalTBInfo.h:18
HcalTBDigiProducer::theHcalIntegratedShape
CaloVShape * theHcalIntegratedShape
Definition: HcalTBDigiProducer.h:68
HcalShape
shaper for Hcal (not for HF)
Definition: HcalShape.h:15
CaloHitResponse
Creates electronics signals from hits.
Definition: CaloHitResponse.h:33
HcalDetId
Definition: HcalDetId.h:12
edm::Service< edm::RandomNumberGenerator >
HcalTBDigiProducer::theCoderFactory
HcalCoderFactory * theCoderFactory
Definition: HcalTBDigiProducer.h:74
edm::ProducesCollector::produces
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
Definition: ProducesCollector.h:52
edm::EventSetup
Definition: EventSetup.h:57
HcalTBDigiProducer::theHODigitizer
HODigitizer * theHODigitizer
Definition: HcalTBDigiProducer.h:83
CaloTDigitizer.h
get
#define get
instance
static PFTauRenderPlugin instance
Definition: PFTauRenderPlugin.cc:70
HcalTBDigiProducer.h
HcalSubdetector
HcalSubdetector
Definition: HcalAssistant.h:31
HcalTBDigiProducer::updateGeometry
void updateGeometry()
Definition: HcalTBDigiProducer.cc:224
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
HcalAmplifier::setTimeSlewSim
void setTimeSlewSim(HcalTimeSlewSim *timeSlewSim)
Definition: HcalAmplifier.h:35
HcalTBDigiProducer::hbheCells
std::vector< DetId > hbheCells
Definition: HcalTBDigiProducer.h:86
HcalTBDigiProducer::theHcalShape
CaloVShape * theHcalShape
Definition: HcalTBDigiProducer.h:67
HcalTBDigiProducer::~HcalTBDigiProducer
~HcalTBDigiProducer() override
Definition: HcalTBDigiProducer.cc:83
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::ProducesCollector
Definition: ProducesCollector.h:43
CaloGeometry::getValidDetIds
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:75
HcalTBDigiProducer::accumulate
void accumulate(edm::Event const &e, edm::EventSetup const &c) override
Definition: HcalTBDigiProducer.cc:156
HcalEndcap
Definition: HcalAssistant.h:34
HcalAmplifier
Definition: HcalAmplifier.h:20
CaloGeometry.h
HcalTimeSlewSim
Definition: HcalTimeSlewSim.h:19
HcalElectronicsSim
Definition: HcalElectronicsSim.h:25
edm::PCaloHitContainer
std::vector< PCaloHit > PCaloHitContainer
Definition: PCaloHitContainer.h:8
HcalTBDigiProducer::setPhaseShift
void setPhaseShift(const DetId &detId)
Definition: HcalTBDigiProducer.cc:248
CaloTDigitizer::run
void run(MixCollection< PCaloHit > &, DigiCollection &)
turns hits into digis
Definition: CaloTDigitizer.h:86
HcalTBDigiProducer::sortHits
void sortHits(const edm::PCaloHitContainer &hits)
fills the vectors for each subdetector
Definition: HcalTBDigiProducer.cc:197
HcalDbService.h
HcalTBSimParameterMap::simParameters
const CaloSimParameters & simParameters(const DetId &id) const override
Definition: HcalTBSimParameterMap.cc:53
phase2TrackerDigitizer_cfi.delay
delay
Definition: phase2TrackerDigitizer_cfi.py:67
ConsumesCollector.h
HcalCoderFactory::DB
Definition: HcalCoderFactory.h:10
HcalDbRecord
Definition: HcalDbRecord.h:30
hcalUnsuppressedDigis_cfi.minFCToDelay
minFCToDelay
Definition: hcalUnsuppressedDigis_cfi.py:29
HcalTBDigiProducer::accumulateCaloHits
void accumulateCaloHits(edm::Handle< std::vector< PCaloHit >> const &hits, int bunchCrossing)
Definition: HcalTBDigiProducer.cc:145
HBHEDigiCollection
edm::SortedCollection< HBHEDataFrame > HBHEDigiCollection
Definition: HcalDigiCollections.h:20
edm::Event
Definition: Event.h:73
HcalTBDigiProducer::ecalTBInfoLabel
std::string ecalTBInfoLabel
Definition: HcalTBDigiProducer.h:91
StreamID.h
HcalTBDigiProducer::randomEngine_
CLHEP::HepRandomEngine * randomEngine_
Definition: HcalTBDigiProducer.h:97
HcalTBDigiProducer::theAmplifier
HcalAmplifier * theAmplifier
Definition: HcalTBDigiProducer.h:73
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
HcalTBDigiProducer::paraMap
HcalSimParameterMap * paraMap
Definition: HcalTBDigiProducer.h:66
CaloHitResponse::setGeometry
void setGeometry(const CaloGeometry *geometry)
geometry needed for time-of-flight
Definition: CaloHitResponse.h:49
HcalTBDigiProducer::initializeEvent
void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
Definition: HcalTBDigiProducer.cc:108
HcalTBDigiProducer::theHBHEHitFilter
HBHEHitFilter theHBHEHitFilter
Definition: HcalTBDigiProducer.h:77
HcalTBDigiProducer::theHBHEDigitizer
HBHEDigitizer * theHBHEDigitizer
Definition: HcalTBDigiProducer.h:82
HcalAmplifier::setDbService
void setDbService(const HcalDbService *service)
the Producer will probably update this every event
Definition: HcalAmplifier.cc:35
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37