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.
2 
7 
18 
20  theParameterMap(new HcalTBSimParameterMap(ps)),
21  theHcalShape(new HcalShape()),
22  theHcalIntegratedShape(new CaloShapeIntegrator(theHcalShape)),
23  theHBHEResponse(new CaloHitResponse(theParameterMap, theHcalIntegratedShape)),
24  theHOResponse(new CaloHitResponse(theParameterMap, theHcalIntegratedShape)),
25  theAmplifier(0), theCoderFactory(0), theElectronicsSim(0),
26  theHitCorrection(0), theHBHEDigitizer(0), theHODigitizer(0), theHBHEHits(),
27  theHOHits(), thisPhaseShift(0) {
28 
29  produces<HBHEDigiCollection>();
30  produces<HODigiCollection>();
31 
32  DetId detId(DetId::Hcal, 1);
33  bool syncPhase = (theParameterMap->simParameters(detId)).syncPhase();
34  doPhaseShift = !syncPhase;
35 
38 
39  bool doTimeSlew = ps.getParameter<bool>("doTimeSlew");
40  if(doTimeSlew) {
41  // no time slewing for HF
45  }
46 
47  bool doNoise = ps.getParameter<bool>("doNoise");
51 
54 
55  tunePhaseShift = ps.getUntrackedParameter<double>("tunePhaseShiftTB", 1.);
56  ecalTBInfoLabel = ps.getUntrackedParameter<std::string>("EcalTBInfoLabel","SimEcalTBG4Object");
57  edm::LogInfo("HcalSim") << "HcalTBDigiProducer initialized with doNoise = "
58  << doNoise << ", doTimeSlew = " << doTimeSlew
59  << " and doPhaseShift = " << doPhaseShift
60  << " tunePhasShift = " << tunePhaseShift;
61 
62 }
63 
65 
67  if (theHODigitizer) delete theHODigitizer;
68  if (theParameterMap) delete theParameterMap;
69  if (theHcalShape) delete theHcalShape;
71  if (theHBHEResponse) delete theHBHEResponse;
72  if (theHOResponse) delete theHOResponse;
74  if (theAmplifier) delete theAmplifier;
75  if (theCoderFactory) delete theCoderFactory;
77 }
78 
79 
81 
82  // get the appropriate gains, noises, & widths for this event
84  eventSetup.get<HcalDbRecord>().get(conditions);
85  theAmplifier->setDbService(conditions.product());
86  theCoderFactory->setDbService(conditions.product());
87 
88  // get the correct geometry
89  checkGeometry(eventSetup);
90 
91  theHBHEHits.clear();
92  theHOHits.clear();
93 
94  // Step A: Get Inputs
96  // e.getByType(cf);
97 
98  LogDebug("HcalSim") << "HcalTBDigiProducer::produce trying to ger SimHit";
99  // test access to SimHits
100  const std::string subdet("HcalHits");
101  // std::auto_ptr<MixCollection<PCaloHit> > col(new MixCollection<PCaloHit>(cf.product(), subdet));
102  e.getByLabel("mix", subdet, cf);
103  std::auto_ptr<MixCollection<PCaloHit> > col(new MixCollection<PCaloHit>(cf.product() ));
104 
105  LogDebug("HcalSim") << "HcalTBDigiProducer::produce Collection of SimHit found";
106  if(theHitCorrection != 0) {
108  }
109  LogDebug("HcalSim") << "HcalTBDigiProducer::produce Hits corrected";
110 
111  // Step B: Create empty output
112  std::auto_ptr<HBHEDigiCollection> hbheResult(new HBHEDigiCollection());
113  std::auto_ptr<HODigiCollection> hoResult(new HODigiCollection());
114  LogDebug("HcalSim") << "HcalTBDigiProducer::produce Empty collection created";
115  if (doPhaseShift) {
116 
117  edm::Handle<PEcalTBInfo> theEcalTBInfo;
118  e.getByLabel(ecalTBInfoLabel,theEcalTBInfo);
119  thisPhaseShift = theEcalTBInfo->phaseShift();
120 
121  DetId detIdHB(DetId::Hcal, 1);
122  setPhaseShift(detIdHB);
123  DetId detIdHO(DetId::Hcal, 3);
124  setPhaseShift(detIdHO);
125  }
126 
127  // Step C: Invoke the algorithm, passing in inputs and getting back outputs.
128  theHBHEDigitizer->run(*col, *hbheResult);
129  edm::LogInfo("HcalSim") << "HcalTBDigiProducer: HBHE digis : " << hbheResult->size();
130  theHODigitizer->run(*col, *hoResult);
131  edm::LogInfo("HcalSim") << "HcalTBDigiProducer: HO digis : " << hoResult->size();
132 
133  // Step D: Put outputs into event
134  e.put(hbheResult);
135  e.put(hoResult);
136 
137 }
138 
140 
141  for (edm::PCaloHitContainer::const_iterator hitItr = hits.begin();
142  hitItr != hits.end(); ++hitItr) {
143  HcalSubdetector subdet = HcalDetId(hitItr->id()).subdet();
144  if(subdet == HcalBarrel || subdet == HcalEndcap) {
145  theHBHEHits.push_back(*hitItr);
146  } else if(subdet == HcalOuter) {
147  theHOHits.push_back(*hitItr);
148  } else {
149  edm::LogError("HcalSim") << "Bad HcalHit subdetector " << subdet;
150  }
151  }
152 }
153 
155 
156  // TODO find a way to avoid doing this every event
158  eventSetup.get<CaloGeometryRecord>().get(geometry);
159 
160  const CaloGeometry * pGeometry = &*geometry;
161 
162  // see if we need to update
163  if(pGeometry != theGeometry) {
164  theGeometry = pGeometry;
165  updateGeometry();
166  }
167 }
168 
170 
173 
174  // Get cells for HB and HE
175  hbheCells.clear();
177  std::vector<DetId> heCells = theGeometry->getValidDetIds(DetId::Hcal, HcalEndcap);
178  // combine HB & HE
179  hbheCells.insert(hbheCells.end(), heCells.begin(), heCells.end());
180 
181  // Get cells for HO
182  hoCells.clear();
184 
185  edm::LogInfo("HcalSim") << "HcalTBDigiProducer update Geometry with "
186  << hbheCells.size() << " cells in HB/HE and "
187  << hoCells.size() << " cells in HO";
188 
190  LogDebug("HcalSim") << "HcalTBDigiProducer: Set DetID's for HB/HE";
192  LogDebug("HcalSim") << "HcalTBDigiProducer: Set DetID's for HO";
193 }
194 
196 
198  if ( !parameters.syncPhase() ) {
199  int myDet = detId.subdetId();
200  double passPhaseShift = thisPhaseShift + tunePhaseShift;
201  if (myDet <= 2) {
202  theHBHEResponse->setPhaseShift(passPhaseShift);
203  } else {
204  theHOResponse->setPhaseShift(passPhaseShift);
205  }
206  }
207 }
#define LogDebug(id)
void setPhaseShift(const DetId &detId)
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
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
HBHEHitFilter theHBHEHitFilter
HODigitizer * theHODigitizer
HcalElectronicsSim * theElectronicsSim
HcalTBDigiProducer(const edm::ParameterSet &ps)
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
virtual void produce(edm::Event &e, const edm::EventSetup &c)
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:85
void run(MixCollection< PCaloHit > &input, DigiCollection &output)
turns hits into digis
HBHEDigitizer * theHBHEDigitizer
void fillChargeSums(MixCollection< PCaloHit > &hits)
HcalSubdetector
Definition: HcalAssistant.h:32
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:39
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::vector< PCaloHit > theHOHits
Definition: DetId.h:20
CaloHitResponse * theHOResponse
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
T const * product() const
Definition: Handle.h:74
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
void setHitCorrection(const CaloVHitCorrection *hitCorrection)
If you want to correct hits, for attenuation or delay, set this.
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) ...