CMS 3D CMS Logo

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  theHitsProducerTag = ps.getParameter<edm::InputTag>("hitsProducer");
35  iC.consumes<std::vector<PCaloHit> >(theHitsProducerTag);
36 
37  mixMod.produces<CastorDigiCollection>();
38 
40 
41  bool doTimeSlew = ps.getParameter<bool>("doTimeSlew");
42  if(doTimeSlew) {
43  // no time slewing for HF
45  }
46 
47  bool doNoise = ps.getParameter<bool>("doNoise");
51 
53 
55  if ( ! rng.isAvailable()) {
56  throw cms::Exception("Configuration")
57  << "CastorDigiProducer requires the RandomNumberGeneratorService\n"
58  "which is not present in the configuration file. You must add the service\n"
59  "in the configuration file or remove the modules that require it.";
60  }
61 }
62 
63 
65  delete theCastorDigitizer;
66  delete theParameterMap;
67  delete theCastorShape;
69  delete theCastorResponse;
70  delete theElectronicsSim;
71  delete theAmplifier;
72  delete theCoderFactory;
73  delete theHitCorrection;
74 }
75 
77  // get the appropriate gains, noises, & widths for this event
79  eventSetup.get<CastorDbRecord>().get(conditions);
80  theAmplifier->setDbService(conditions.product());
81  theCoderFactory->setDbService(conditions.product());
82  theParameterMap->setDbService(conditions.product());
83 
84  edm::LogInfo("CastorDigiProducer") << "checking the geometry...";
85 
86  // get the correct geometry
87  checkGeometry(eventSetup);
88 
89  theCastorHits.clear();
90 
92 }
93 
94 void CastorDigiProducer::accumulateCaloHits(std::vector<PCaloHit> const& hcalHits, int bunchCrossing, CLHEP::HepRandomEngine* engine) {
95  //fillFakeHits();
96 
97  if(theHitCorrection != 0) {
99  }
100  theCastorDigitizer->add(hcalHits, bunchCrossing, engine);
101 }
102 
104  // Step A: Get and accumulate digitized hits
105  edm::Handle<std::vector<PCaloHit> > castorHandle;
106  e.getByLabel(theHitsProducerTag, castorHandle);
107 
108  accumulateCaloHits(*castorHandle.product(), 0, randomEngine(e.streamID()));
109 }
110 
112  // Step A: Get and accumulate digitized hits
113  edm::Handle<std::vector<PCaloHit> > castorHandle;
114  e.getByLabel(theHitsProducerTag, castorHandle);
115 
116  accumulateCaloHits(*castorHandle.product(), e.bunchCrossing(), randomEngine(streamID));
117 }
118 
120  // Step B: Create empty output
121 
122  std::unique_ptr<CastorDigiCollection> castorResult(new CastorDigiCollection());
123 
124  // Step C: Invoke the algorithm, getting back outputs.
125  theCastorDigitizer->run(*castorResult, randomEngine(e.streamID()));
126 
127  edm::LogInfo("CastorDigiProducer") << "HCAL/Castor digis : " << castorResult->size();
128 
129  // Step D: Put outputs into event
130  e.put(std::move(castorResult));
131 }
132 
133 
135  for(edm::PCaloHitContainer::const_iterator hitItr = hits.begin();
136  hitItr != hits.end(); ++hitItr){
137  DetId detId = hitItr->id();
138  if (detId.det()==DetId::Calo && detId.subdetId()==HcalCastorDetId::SubdetectorId){
139  theCastorHits.push_back(*hitItr);
140  }
141  else {
142  edm::LogError("CastorDigiProducer") << "Bad Hit subdetector " << detId.subdetId();
143  }
144  }
145 }
146 
148  HcalCastorDetId castorDetId(HcalCastorDetId::Section(2),true,1,1);
149 
150  theCastorHits.emplace_back(castorDetId.rawId(), 50.0, 0.);
151 }
152 
153 
155  // TODO find a way to avoid doing this every event
157  eventSetup.get<CaloGeometryRecord>().get(geometry);
158  theCastorResponse->setGeometry(&*geometry);
159 
160  const std::vector<DetId>& castorCells = geometry->getValidDetIds(DetId::Calo, HcalCastorDetId::SubdetectorId);
161 
162  //std::cout<<"CastorDigiProducer::CheckGeometry number of cells: "<<castorCells.size()<<std::endl;
163  theCastorDigitizer->setDetIds(castorCells);
164 }
165 
166 CLHEP::HepRandomEngine* CastorDigiProducer::randomEngine(edm::StreamID const& streamID) {
167  unsigned int index = streamID.value();
168  if(index >= randomEngines_.size()) {
169  randomEngines_.resize(index + 1, nullptr);
170  }
171  CLHEP::HepRandomEngine* ptr = randomEngines_[index];
172  if(!ptr) {
174  ptr = &rng->getEngine(streamID);
175  randomEngines_[index] = ptr;
176  }
177  return ptr;
178 }
179 
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
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
void add(const std::vector< PCaloHit > &hits, int bunchCrossing, CLHEP::HepRandomEngine *engine)
void fillChargeSums(MixCollection< PCaloHit > &hits)
CaloTDigitizer< CastorDigitizerTraits > CastorDigitizer
void checkGeometry(const edm::EventSetup &eventSetup)
std::vector< CLHEP::HepRandomEngine * > randomEngines_
void setDbService(const CastorDbService *service)
CastorSimParameterMap * theParameterMap
void sortHits(const edm::PCaloHitContainer &hits)
fills the vectors for each subdetector
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
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.
void initializeHits()
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:416
void accumulateCaloHits(std::vector< PCaloHit > const &, int bunchCrossing, CLHEP::HepRandomEngine *)
virtual void accumulate(edm::Event const &e, edm::EventSetup const &c) override
CastorDigiProducer(const edm::ParameterSet &ps, edm::stream::EDProducerBase &mixMod, edm::ConsumesCollector &iC)
Definition: DetId.h:18
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
void run(MixCollection< PCaloHit > &, DigiCollection &)
turns hits into digis
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:92
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:81
CastorCoderFactory * theCoderFactory
shaper for Castor
Definition: CastorShape.h:16
edm::SortedCollection< CastorDataFrame > CastorDigiCollection
void setDbService(const CastorDbService *service)
the Producer will probably update this every event
edm::InputTag theHitsProducerTag
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
void setDbService(const CastorDbService *service)
T const * product() const
Definition: ESHandle.h:86
CaloVShape * theCastorIntegratedShape
def move(src, dest)
Definition: eostools.py:510
CLHEP::HepRandomEngine * randomEngine(edm::StreamID const &streamID)
void setDetIds(const std::vector< DetId > &detIds)