CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalTBDigiProducer.cc
Go to the documentation of this file.
6 
16 
18  theParameterMap(new HcalTBSimParameterMap(ps)),
19  theHcalShape(new HcalShape()),
20  theHcalIntegratedShape(new CaloShapeIntegrator(theHcalShape)),
21  theHBHEResponse(new CaloHitResponse(theParameterMap, theHcalIntegratedShape)),
22  theHOResponse(new CaloHitResponse(theParameterMap, theHcalIntegratedShape)),
23  theAmplifier(0), theCoderFactory(0), theElectronicsSim(0),
24  theHitCorrection(0), theHBHEDigitizer(0), theHODigitizer(0), theHBHEHits(),
25  theHOHits(), thisPhaseShift(0) {
26  std::string const instance("simHcalDigis");
27  mixMod.produces<HBHEDigiCollection>(instance);
28  mixMod.produces<HODigiCollection>(instance);
29  iC.consumes<std::vector<PCaloHit> >(edm::InputTag("g4SimHits", "HcalHits"));
30 
31  DetId detId(DetId::Hcal, 1);
32  bool syncPhase = (theParameterMap->simParameters(detId)).syncPhase();
33  doPhaseShift = !syncPhase;
34 
37 
38  bool doTimeSlew = ps.getParameter<bool>("doTimeSlew");
39  if(doTimeSlew) {
40  // no time slewing for HF
44  }
45 
46  bool doNoise = ps.getParameter<bool>("doNoise");
50 
53 
54  tunePhaseShift = ps.getUntrackedParameter<double>("tunePhaseShiftTB", 1.);
55  ecalTBInfoLabel = ps.getUntrackedParameter<std::string>("EcalTBInfoLabel","SimEcalTBG4Object");
56  edm::LogInfo("HcalSim") << "HcalTBDigiProducer initialized with doNoise = "
57  << doNoise << ", doTimeSlew = " << doTimeSlew
58  << " and doPhaseShift = " << doPhaseShift
59  << " tunePhasShift = " << tunePhaseShift;
60 
61  if (doPhaseShift) {
63  }
64 }
65 
67 
69  if (theHODigitizer) delete theHODigitizer;
70  if (theParameterMap) delete theParameterMap;
71  if (theHcalShape) delete theHcalShape;
73  if (theHBHEResponse) delete theHBHEResponse;
74  if (theHOResponse) delete theHOResponse;
76  if (theAmplifier) delete theAmplifier;
77  if (theCoderFactory) delete theCoderFactory;
79 }
80 
81 
83  // get the appropriate gains, noises, & widths for this event
85  eventSetup.get<HcalDbRecord>().get(conditions);
86  theAmplifier->setDbService(conditions.product());
87  theCoderFactory->setDbService(conditions.product());
88 
89  // get the correct geometry
90  checkGeometry(eventSetup);
91 
92  theHBHEHits.clear();
93  theHOHits.clear();
94  if (doPhaseShift) {
95 
96  edm::Handle<PEcalTBInfo> theEcalTBInfo;
97  e.getByLabel(ecalTBInfoLabel,theEcalTBInfo);
98  thisPhaseShift = theEcalTBInfo->phaseShift();
99 
100  DetId detIdHB(DetId::Hcal, 1);
101  setPhaseShift(detIdHB);
102  DetId detIdHO(DetId::Hcal, 3);
103  setPhaseShift(detIdHO);
104  }
105 
108 }
109 
110 void HcalTBDigiProducer::accumulateCaloHits(edm::Handle<std::vector<PCaloHit> > const& hcalHandle, int bunchCrossing) {
111 
112  LogDebug("HcalSim") << "HcalTBDigiProducer::accumulate trying to get SimHit";
113 
114  if(hcalHandle.isValid()) {
115  std::vector<PCaloHit> hits = *hcalHandle.product();
116  if(theHitCorrection != 0) {
118  }
119  LogDebug("HcalSim") << "HcalTBDigiProducer::accumulate Hits corrected";
120  theHBHEDigitizer->add(hits, bunchCrossing);
121  theHODigitizer->add(hits, bunchCrossing);
122  }
123 }
124 
126  // Step A: Get Inputs, and accumulate digis
127 
128  edm::InputTag hcalTag("g4SimHits", "HcalHits");
130  e.getByLabel(hcalTag, hcalHandle);
131 
132  accumulateCaloHits(hcalHandle, 0);
133 }
134 
136  // Step A: Get Inputs, and accumulate digis
137 
138  edm::InputTag hcalTag("g4SimHits", "HcalHits");
140  e.getByLabel(hcalTag, hcalHandle);
141 
142  accumulateCaloHits(hcalHandle, e.bunchCrossing());
143 }
144 
146  // Step B: Create empty output
147  std::auto_ptr<HBHEDigiCollection> hbheResult(new HBHEDigiCollection());
148  std::auto_ptr<HODigiCollection> hoResult(new HODigiCollection());
149  LogDebug("HcalSim") << "HcalTBDigiProducer::produce Empty collection created";
150  // Step C: Invoke the algorithm, getting back outputs.
151  theHBHEDigitizer->run(*hbheResult);
152  edm::LogInfo("HcalSim") << "HcalTBDigiProducer: HBHE digis : " << hbheResult->size();
153  theHODigitizer->run(*hoResult);
154  edm::LogInfo("HcalSim") << "HcalTBDigiProducer: HO digis : " << hoResult->size();
155 
156  // Step D: Put outputs into event
157  std::string const instance("simHcalDigis");
158  e.put(hbheResult, instance);
159  e.put(hoResult, instance);
160 
161 }
162 
164 
165  for (edm::PCaloHitContainer::const_iterator hitItr = hits.begin();
166  hitItr != hits.end(); ++hitItr) {
167  HcalSubdetector subdet = HcalDetId(hitItr->id()).subdet();
168  if(subdet == HcalBarrel || subdet == HcalEndcap) {
169  theHBHEHits.push_back(*hitItr);
170  } else if(subdet == HcalOuter) {
171  theHOHits.push_back(*hitItr);
172  } else {
173  edm::LogError("HcalSim") << "Bad HcalHit subdetector " << subdet;
174  }
175  }
176 }
177 
179 
180  // TODO find a way to avoid doing this every event
182  eventSetup.get<CaloGeometryRecord>().get(geometry);
183 
184  const CaloGeometry * pGeometry = &*geometry;
185 
186  // see if we need to update
187  if(pGeometry != theGeometry) {
188  theGeometry = pGeometry;
189  updateGeometry();
190  }
191 }
192 
194 
197 
198  // Get cells for HB and HE
199  hbheCells.clear();
201  std::vector<DetId> heCells = theGeometry->getValidDetIds(DetId::Hcal, HcalEndcap);
202  // combine HB & HE
203  hbheCells.insert(hbheCells.end(), heCells.begin(), heCells.end());
204 
205  // Get cells for HO
206  hoCells.clear();
208 
209  edm::LogInfo("HcalSim") << "HcalTBDigiProducer update Geometry with "
210  << hbheCells.size() << " cells in HB/HE and "
211  << hoCells.size() << " cells in HO";
212 
214  LogDebug("HcalSim") << "HcalTBDigiProducer: Set DetID's for HB/HE";
216  LogDebug("HcalSim") << "HcalTBDigiProducer: Set DetID's for HO";
217 }
218 
220 
222  if ( !parameters.syncPhase() ) {
223  int myDet = detId.subdetId();
224  double passPhaseShift = thisPhaseShift + tunePhaseShift;
225  if (myDet <= 2) {
226  theHBHEResponse->setPhaseShift(passPhaseShift);
227  } else {
228  theHOResponse->setPhaseShift(passPhaseShift);
229  }
230  }
231 }
#define LogDebug(id)
void setPhaseShift(const DetId &detId)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
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
virtual void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
dictionary parameters
Definition: Parameters.py:2
void sortHits(const edm::PCaloHitContainer &hits)
fills the vectors for each subdetector
std::vector< PCaloHit > PCaloHitContainer
std::vector< DetId > hoCells
virtual const CaloSimParameters & simParameters(const DetId &id) const
CaloHitResponse * theHBHEResponse
HcalTBDigiProducer(const edm::ParameterSet &ps, edm::one::EDProducerBase &mixMod, edm::ConsumesCollector &iC)
void initializeHits()
static PFTauRenderPlugin instance
HBHEHitFilter theHBHEHitFilter
HODigitizer * theHODigitizer
void add(const std::vector< PCaloHit > &hits, int bunchCrossing)
HcalElectronicsSim * theElectronicsSim
HOHitFilter theHOHitFilter
HcalTBSimParameterMap * theParameterMap
Main class for Parameters in different subdetectors.
const CaloGeometry * theGeometry
void setPhaseShift(const double &thePhaseShift)
setting the phase shift for asynchronous trigger (e.g. test beams)
CaloTDigitizer< HBHEDigitizerTraits > HBHEDigitizer
std::vector< PCaloHit > theHBHEHits
CaloTDigitizer< HODigitizerTraits > HODigitizer
edm::SortedCollection< HODataFrame > HODigiCollection
CaloVShape * theHcalIntegratedShape
void setHitFilter(const CaloVHitFilter *filter)
if you want to reject hits, for example, from a certain subdetector, set this
Creates electronics signals from hits.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
HBHEDigitizer * theHBHEDigitizer
void fillChargeSums(MixCollection< PCaloHit > &hits)
HcalSubdetector
Definition: HcalAssistant.h:31
void accumulateCaloHits(edm::Handle< std::vector< PCaloHit > > const &hits, int bunchCrossing)
void checkGeometry(const edm::EventSetup &eventSetup)
shaper for Hcal (not for HF)
Definition: HcalShape.h:15
std::vector< DetId > hbheCells
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
virtual void accumulate(edm::Event const &e, edm::EventSetup const &c) override
std::vector< PCaloHit > theHOHits
Definition: DetId.h:18
CaloHitResponse * theHOResponse
void run(MixCollection< PCaloHit > &, DigiCollection &)
turns hits into digis
HcalHitCorrection * theHitCorrection
void setDbService(const HcalDbService *service)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
HcalAmplifier * theAmplifier
std::string ecalTBInfoLabel
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:90
HcalCoderFactory * theCoderFactory
ESHandle< TrackerGeometry > geometry
CaloVShape * theHcalShape
virtual void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
void setHitCorrection(const CaloVHitCorrection *hitCorrection)
If you want to correct hits, for attenuation or delay, set this.
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
void setDetIds(const std::vector< DetId > &detIds)
edm::SortedCollection< HBHEDataFrame > HBHEDigiCollection
bool syncPhase() const
choice of the ADC time alignment (synchronous for LHC, asynchronous for test beams) ...