CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorDigiProducer.cc
Go to the documentation of this file.
21 
23 : theParameterMap(new CastorSimParameterMap(ps)),
24  theCastorShape(new CastorShape()),
25  theCastorIntegratedShape(new CaloShapeIntegrator(theCastorShape)),
26  theCastorResponse(new CaloHitResponse(theParameterMap, theCastorIntegratedShape)),
27  theAmplifier(0),
28  theCoderFactory(0),
29  theElectronicsSim(0),
30  theHitCorrection(0),
31  theCastorDigitizer(0),
32  theCastorHits()
33 {
34  iC.consumes<std::vector<PCaloHit> >(edm::InputTag("g4SimHits", "CastorFI"));
35 
36  mixMod.produces<CastorDigiCollection>();
37 
39 
40  bool doTimeSlew = ps.getParameter<bool>("doTimeSlew");
41  if(doTimeSlew) {
42  // no time slewing for HF
44  }
45 
46  bool doNoise = ps.getParameter<bool>("doNoise");
50 
52 
54  if ( ! rng.isAvailable()) {
55  throw cms::Exception("Configuration")
56  << "CastorDigiProducer requires the RandomNumberGeneratorService\n"
57  "which is not present in the configuration file. You must add the service\n"
58  "in the configuration file or remove the modules that require it.";
59  }
60 }
61 
62 
64  delete theCastorDigitizer;
65  delete theParameterMap;
66  delete theCastorShape;
68  delete theCastorResponse;
69  delete theElectronicsSim;
70  delete theAmplifier;
71  delete theCoderFactory;
72  delete theHitCorrection;
73 }
74 
76  // get the appropriate gains, noises, & widths for this event
78  eventSetup.get<CastorDbRecord>().get(conditions);
79  theAmplifier->setDbService(conditions.product());
80  theCoderFactory->setDbService(conditions.product());
81  theParameterMap->setDbService(conditions.product());
82 
83  edm::LogInfo("CastorDigiProducer") << "checking the geometry...";
84 
85  // get the correct geometry
86  checkGeometry(eventSetup);
87 
88  theCastorHits.clear();
89 
91 }
92 
93 void CastorDigiProducer::accumulateCaloHits(std::vector<PCaloHit> const& hcalHits, int bunchCrossing, CLHEP::HepRandomEngine* engine) {
94  //fillFakeHits();
95 
96  if(theHitCorrection != 0) {
98  }
99  theCastorDigitizer->add(hcalHits, bunchCrossing, engine);
100 }
101 
103  // Step A: Get and accumulate digitized hits
104  edm::Handle<std::vector<PCaloHit> > castorHandle;
105  e.getByLabel(edm::InputTag("g4SimHits", "CastorFI"), castorHandle);
106 
107  accumulateCaloHits(*castorHandle.product(), 0, randomEngine(e.streamID()));
108 }
109 
111  // Step A: Get and accumulate digitized hits
112  edm::Handle<std::vector<PCaloHit> > castorHandle;
113  e.getByLabel(edm::InputTag("g4SimHits", "CastorFI"), castorHandle);
114 
115  accumulateCaloHits(*castorHandle.product(), e.bunchCrossing(), randomEngine(streamID));
116 }
117 
119  // Step B: Create empty output
120 
121  std::auto_ptr<CastorDigiCollection> castorResult(new CastorDigiCollection());
122 
123  // Step C: Invoke the algorithm, getting back outputs.
124  theCastorDigitizer->run(*castorResult, randomEngine(e.streamID()));
125 
126  edm::LogInfo("CastorDigiProducer") << "HCAL/Castor digis : " << castorResult->size();
127 
128  // Step D: Put outputs into event
129  e.put(castorResult);
130 }
131 
132 
134  for(edm::PCaloHitContainer::const_iterator hitItr = hits.begin();
135  hitItr != hits.end(); ++hitItr){
136  DetId detId = hitItr->id();
137  if (detId.det()==DetId::Calo && detId.subdetId()==HcalCastorDetId::SubdetectorId){
138  theCastorHits.push_back(*hitItr);
139  }
140  else {
141  edm::LogError("CastorDigiProducer") << "Bad Hit subdetector " << detId.subdetId();
142  }
143  }
144 }
145 
147  HcalCastorDetId castorDetId(HcalCastorDetId::Section(2),true,1,1);
148 
149  theCastorHits.emplace_back(castorDetId.rawId(), 50.0, 0.);
150 }
151 
152 
154  // TODO find a way to avoid doing this every event
156  eventSetup.get<CaloGeometryRecord>().get(geometry);
157  theCastorResponse->setGeometry(&*geometry);
158 
159  const std::vector<DetId>& castorCells = geometry->getValidDetIds(DetId::Calo, HcalCastorDetId::SubdetectorId);
160 
161  //std::cout<<"CastorDigiProducer::CheckGeometry number of cells: "<<castorCells.size()<<std::endl;
162  theCastorDigitizer->setDetIds(castorCells);
163 }
164 
165 CLHEP::HepRandomEngine* CastorDigiProducer::randomEngine(edm::StreamID const& streamID) {
166  unsigned int index = streamID.value();
167  if(index >= randomEngines_.size()) {
168  randomEngines_.resize(index + 1, nullptr);
169  }
170  CLHEP::HepRandomEngine* ptr = randomEngines_[index];
171  if(!ptr) {
173  ptr = &rng->getEngine(streamID);
174  randomEngines_[index] = ptr;
175  }
176  return ptr;
177 }
178 
virtual void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
void setGeometry(const CaloGeometry *geometry)
geometry needed for time-of-flight
virtual void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
CastorAmplifier * theAmplifier
CaloVShape * theCastorShape
std::vector< PCaloHit > PCaloHitContainer
void initializeHits()
void fillChargeSums(MixCollection< PCaloHit > &hits)
CaloTDigitizer< CastorDigitizerTraits > CastorDigitizer
void checkGeometry(const edm::EventSetup &eventSetup)
std::vector< CLHEP::HepRandomEngine * > randomEngines_
void setDbService(const CastorDbService *service)
void add(const std::vector< PCaloHit > &hits, int bunchCrossing, CLHEP::HepRandomEngine *engine)
CastorSimParameterMap * theParameterMap
void sortHits(const edm::PCaloHitContainer &hits)
fills the vectors for each subdetector
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
CastorElectronicsSim * theElectronicsSim
CastorHitFilter theCastorHitFilter
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:113
CaloHitResponse * theCastorResponse
bool isAvailable() const
Definition: Service.h:46
std::vector< PCaloHit > theCastorHits
void fillFakeHits()
some hits in each subdetector, just for testing purposes
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
static const int SubdetectorId
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:405
void accumulateCaloHits(std::vector< PCaloHit > const &, int bunchCrossing, CLHEP::HepRandomEngine *)
virtual void accumulate(edm::Event const &e, edm::EventSetup const &c) override
Definition: DetId.h:18
void run(MixCollection< PCaloHit > &, DigiCollection &)
turns hits into digis
unsigned int value() const
Definition: StreamID.h:46
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:55
CastorHitCorrection * theHitCorrection
T const * product() const
Definition: ESHandle.h:86
CastorDigiProducer(const edm::ParameterSet &ps, edm::one::EDProducerBase &mixMod, edm::ConsumesCollector &iC)
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &) const =0
Use this engine in event methods.
ESHandle< TrackerGeometry > geometry
CastorDigitizer * theCastorDigitizer
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
StreamID streamID() const
Definition: Event.h:72
CastorCoderFactory * theCoderFactory
void setDetIds(const std::vector< DetId > &detIds)
shaper for Castor
Definition: CastorShape.h:16
edm::SortedCollection< CastorDataFrame > CastorDigiCollection
void setDbService(const CastorDbService *service)
the Producer will probably update this every event
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
void setDbService(const CastorDbService *service)
CaloVShape * theCastorIntegratedShape
CLHEP::HepRandomEngine * randomEngine(edm::StreamID const &streamID)