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.
20 
22 : theParameterMap(new CastorSimParameterMap(ps)),
23  theCastorShape(new CastorShape()),
24  theCastorIntegratedShape(new CaloShapeIntegrator(theCastorShape)),
25  theCastorResponse(new CaloHitResponse(theParameterMap, theCastorIntegratedShape)),
26  theAmplifier(0),
27  theCoderFactory(0),
28  theElectronicsSim(0),
29  theHitCorrection(0),
30  theCastorDigitizer(0),
31  theCastorHits()
32 {
33 
34  mixMod.produces<CastorDigiCollection>();
35 
37 
38  bool doTimeSlew = ps.getParameter<bool>("doTimeSlew");
39  if(doTimeSlew) {
40  // no time slewing for HF
42  }
43 
44  bool doNoise = ps.getParameter<bool>("doNoise");
48 
50 
52  if ( ! rng.isAvailable()) {
53  throw cms::Exception("Configuration")
54  << "CastorDigiProducer requires the RandomNumberGeneratorService\n"
55  "which is not present in the configuration file. You must add the service\n"
56  "in the configuration file or remove the modules that require it.";
57  }
58 
59  CLHEP::HepRandomEngine& engine = rng->getEngine();
60  theAmplifier->setRandomEngine(engine);
62 }
63 
64 
66  delete theCastorDigitizer;
67  delete theParameterMap;
68  delete theCastorShape;
70  delete theCastorResponse;
71  delete theElectronicsSim;
72  delete theAmplifier;
73  delete theCoderFactory;
74  delete theHitCorrection;
75 }
76 
78  // get the appropriate gains, noises, & widths for this event
80  eventSetup.get<CastorDbRecord>().get(conditions);
81  theAmplifier->setDbService(conditions.product());
82  theCoderFactory->setDbService(conditions.product());
83  theParameterMap->setDbService(conditions.product());
84 
85  edm::LogInfo("CastorDigiProducer") << "checking the geometry...";
86 
87  // get the correct geometry
88  checkGeometry(eventSetup);
89 
90  theCastorHits.clear();
91 
93 }
94 
95 void CastorDigiProducer::accumulateCaloHits(std::vector<PCaloHit> const& hcalHits, int bunchCrossing) {
96  //fillFakeHits();
97 
98  if(theHitCorrection != 0) {
100  }
101  theCastorDigitizer->add(hcalHits, bunchCrossing);
102 }
103 
105  // Step A: Get and accumulate digitized hits
106  edm::InputTag castorTag("g4SimHits", "CastorFI");
107  edm::Handle<std::vector<PCaloHit> > castorHandle;
108  e.getByLabel(castorTag, castorHandle);
109 
110  accumulateCaloHits(*castorHandle.product(), 0);
111 }
112 
114  // Step A: Get and accumulate digitized hits
115  edm::InputTag castorTag("g4SimHits", "CastorFI");
116  edm::Handle<std::vector<PCaloHit> > castorHandle;
117  e.getByLabel(castorTag, castorHandle);
118 
119  accumulateCaloHits(*castorHandle.product(), e.bunchCrossing());
120 }
121 
123  // Step B: Create empty output
124 
125  std::auto_ptr<CastorDigiCollection> castorResult(new CastorDigiCollection());
126 
127  // Step C: Invoke the algorithm, getting back outputs.
128  theCastorDigitizer->run(*castorResult);
129 
130  edm::LogInfo("CastorDigiProducer") << "HCAL/Castor digis : " << castorResult->size();
131 
132  // Step D: Put outputs into event
133  e.put(castorResult);
134 }
135 
136 
138  for(edm::PCaloHitContainer::const_iterator hitItr = hits.begin();
139  hitItr != hits.end(); ++hitItr){
140  DetId detId = hitItr->id();
141  if (detId.det()==DetId::Calo && detId.subdetId()==HcalCastorDetId::SubdetectorId){
142  theCastorHits.push_back(*hitItr);
143  }
144  else {
145  edm::LogError("CastorDigiProducer") << "Bad Hit subdetector " << detId.subdetId();
146  }
147  }
148 }
149 
151  HcalCastorDetId castorDetId(HcalCastorDetId::Section(2),true,1,1);
152 
153  theCastorHits.emplace_back(castorDetId.rawId(), 50.0, 0.);
154 }
155 
156 
158  // TODO find a way to avoid doing this every event
160  eventSetup.get<CaloGeometryRecord>().get(geometry);
161  theCastorResponse->setGeometry(&*geometry);
162 
163  const std::vector<DetId>& castorCells = geometry->getValidDetIds(DetId::Calo, HcalCastorDetId::SubdetectorId);
164 
165  //std::cout<<"CastorDigiProducer::CheckGeometry number of cells: "<<castorCells.size()<<std::endl;
166  theCastorDigitizer->setDetIds(castorCells);
167 }
168 
169 
virtual void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
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)
void add(const std::vector< PCaloHit > &hits, int bunchCrossing)
void setDbService(const CastorDbService *service)
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:45
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:94
CaloHitResponse * theCastorResponse
bool isAvailable() const
Definition: Service.h:47
std::vector< PCaloHit > theCastorHits
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
void fillFakeHits()
some hits in each subdetector, just for testing purposes
void setRandomEngine(CLHEP::HepRandomEngine &engine)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
static const int SubdetectorId
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
void accumulateCaloHits(std::vector< PCaloHit > const &, int bunchCrossing)
virtual void accumulate(edm::Event const &e, edm::EventSetup const &c) override
Definition: DetId.h:20
void run(MixCollection< PCaloHit > &, DigiCollection &)
turns hits into digis
const T & get() const
Definition: EventSetup.h:55
CastorHitCorrection * theHitCorrection
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:74
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
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:37
void setDbService(const CastorDbService *service)
CaloVShape * theCastorIntegratedShape
CastorDigiProducer(const edm::ParameterSet &ps, edm::EDProducer &mixMod)