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  iC.consumes<std::vector<PCaloHit> >(edm::InputTag("g4SimHits", "CastorFI"));
34 
35  mixMod.produces<CastorDigiCollection>();
36 
38 
39  bool doTimeSlew = ps.getParameter<bool>("doTimeSlew");
40  if(doTimeSlew) {
41  // no time slewing for HF
43  }
44 
45  bool doNoise = ps.getParameter<bool>("doNoise");
49 
51 
53  if ( ! rng.isAvailable()) {
54  throw cms::Exception("Configuration")
55  << "CastorDigiProducer requires the RandomNumberGeneratorService\n"
56  "which is not present in the configuration file. You must add the service\n"
57  "in the configuration file or remove the modules that require it.";
58  }
59 
60  CLHEP::HepRandomEngine& engine = rng->getEngine();
61  theAmplifier->setRandomEngine(engine);
63 }
64 
65 
67  delete theCastorDigitizer;
68  delete theParameterMap;
69  delete theCastorShape;
71  delete theCastorResponse;
72  delete theElectronicsSim;
73  delete theAmplifier;
74  delete theCoderFactory;
75  delete theHitCorrection;
76 }
77 
79  // get the appropriate gains, noises, & widths for this event
81  eventSetup.get<CastorDbRecord>().get(conditions);
82  theAmplifier->setDbService(conditions.product());
83  theCoderFactory->setDbService(conditions.product());
84  theParameterMap->setDbService(conditions.product());
85 
86  edm::LogInfo("CastorDigiProducer") << "checking the geometry...";
87 
88  // get the correct geometry
89  checkGeometry(eventSetup);
90 
91  theCastorHits.clear();
92 
94 }
95 
96 void CastorDigiProducer::accumulateCaloHits(std::vector<PCaloHit> const& hcalHits, int bunchCrossing) {
97  //fillFakeHits();
98 
99  if(theHitCorrection != 0) {
100  theHitCorrection->fillChargeSums(hcalHits);
101  }
102  theCastorDigitizer->add(hcalHits, bunchCrossing);
103 }
104 
106  // Step A: Get and accumulate digitized hits
107  edm::Handle<std::vector<PCaloHit> > castorHandle;
108  e.getByLabel(edm::InputTag("g4SimHits", "CastorFI"), castorHandle);
109 
110  accumulateCaloHits(*castorHandle.product(), 0);
111 }
112 
114  // Step A: Get and accumulate digitized hits
115  edm::Handle<std::vector<PCaloHit> > castorHandle;
116  e.getByLabel(edm::InputTag("g4SimHits", "CastorFI"), castorHandle);
117 
118  accumulateCaloHits(*castorHandle.product(), e.bunchCrossing());
119 }
120 
122  // Step B: Create empty output
123 
124  std::auto_ptr<CastorDigiCollection> castorResult(new CastorDigiCollection());
125 
126  // Step C: Invoke the algorithm, getting back outputs.
127  theCastorDigitizer->run(*castorResult);
128 
129  edm::LogInfo("CastorDigiProducer") << "HCAL/Castor digis : " << castorResult->size();
130 
131  // Step D: Put outputs into event
132  e.put(castorResult);
133 }
134 
135 
137  for(edm::PCaloHitContainer::const_iterator hitItr = hits.begin();
138  hitItr != hits.end(); ++hitItr){
139  DetId detId = hitItr->id();
140  if (detId.det()==DetId::Calo && detId.subdetId()==HcalCastorDetId::SubdetectorId){
141  theCastorHits.push_back(*hitItr);
142  }
143  else {
144  edm::LogError("CastorDigiProducer") << "Bad Hit subdetector " << detId.subdetId();
145  }
146  }
147 }
148 
150  HcalCastorDetId castorDetId(HcalCastorDetId::Section(2),true,1,1);
151 
152  theCastorHits.emplace_back(castorDetId.rawId(), 50.0, 0.);
153 }
154 
155 
157  // TODO find a way to avoid doing this every event
159  eventSetup.get<CaloGeometryRecord>().get(geometry);
160  theCastorResponse->setGeometry(&*geometry);
161 
162  const std::vector<DetId>& castorCells = geometry->getValidDetIds(DetId::Calo, HcalCastorDetId::SubdetectorId);
163 
164  //std::cout<<"CastorDigiProducer::CheckGeometry number of cells: "<<castorCells.size()<<std::endl;
165  theCastorDigitizer->setDetIds(castorCells);
166 }
167 
168 
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)
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: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:116
CaloHitResponse * theCastorResponse
bool isAvailable() const
Definition: Service.h:46
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:37
static const int SubdetectorId
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
void accumulateCaloHits(std::vector< PCaloHit > const &, int bunchCrossing)
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
const T & get() const
Definition: EventSetup.h:55
CastorHitCorrection * theHitCorrection
T const * product() const
Definition: ESHandle.h:62
CastorDigiProducer(const edm::ParameterSet &ps, edm::one::EDProducerBase &mixMod, edm::ConsumesCollector &iC)
T const * product() const
Definition: Handle.h:81
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:35
void setDbService(const CastorDbService *service)
CaloVShape * theCastorIntegratedShape