CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloRecHitsProducer.cc
Go to the documentation of this file.
17 
18 // Random engine
20 
21 //#include <iostream>
22 
24  : EcalPreshowerRecHitsMaker_(NULL),EcalBarrelRecHitsMaker_(NULL), EcalEndcapRecHitsMaker_(NULL), HcalRecHitsMaker_(NULL)
25 {
26  theInputRecHitCollectionTypes = p.getParameter<std::vector<unsigned> >("InputRecHitCollectionTypes");
27  theOutputRecHitCollections = p.getParameter<std::vector<std::string> >("OutputRecHitCollections");
28  doDigis_ = p.getParameter<bool>("doDigis");
29  doMiscalib_ = p.getParameter<bool>("doMiscalib");
30  edm::ParameterSet RecHitsParameters = p.getParameter<edm::ParameterSet>("RecHitsFactory");
31 
32  for ( unsigned input=0; input<theInputRecHitCollectionTypes.size(); ++input ) {
33 
35 
36  case 1:
37  {
38  //Preshower
39  if (theOutputRecHitCollections.size()&&theOutputRecHitCollections[input].size())
40  produces<ESRecHitCollection>(theOutputRecHitCollections[input]);
41  else
42  produces<ESRecHitCollection>();
43 
44  if (doDigis_)
45  std::cout << " The digitization of the preshower is not implemented " << std::endl;
46 
48  }
49  break;
50 
51  case 2:
52  {
53  //Ecal Barrel
54  if (theOutputRecHitCollections.size()&&theOutputRecHitCollections[input].size())
55  produces<EBRecHitCollection>(theOutputRecHitCollections[input]);
56  else
57  produces<EBRecHitCollection>();
58 
59  if (doDigis_) produces<EBDigiCollection>();
60  EcalBarrelRecHitsMaker_ = new EcalBarrelRecHitsMaker(RecHitsParameters);
61  }
62  break;
63 
64  case 3:
65  {
66  //EcalEndcap
67  if (theOutputRecHitCollections.size()&&theOutputRecHitCollections[input].size())
68  produces<EERecHitCollection>(theOutputRecHitCollections[input]);
69  else
70  produces<EERecHitCollection>();
71  if (doDigis_) produces<EEDigiCollection>();
72  EcalEndcapRecHitsMaker_ = new EcalEndcapRecHitsMaker(RecHitsParameters);
73  }
74  break;
75 
76  case 4:
77  {
78  //HBHE
79  if (theOutputRecHitCollections.size()&&theOutputRecHitCollections[input].size())
80  produces<HBHERecHitCollection>(theOutputRecHitCollections[input]);
81  else
82  produces<HBHERecHitCollection>();
83 
84  if (doDigis_) produces<HBHEDigiCollection>();
85  HcalRecHitsMaker_ = new HcalRecHitsMaker(RecHitsParameters,4);
86  }
87  break;
88 
89  case 5:
90  {
91  //HO
92  if (theOutputRecHitCollections.size()&&theOutputRecHitCollections[input].size())
93  produces<HORecHitCollection>(theOutputRecHitCollections[input]);
94  else
95  produces<HORecHitCollection>();
96 
97  if (doDigis_) produces<HODigiCollection>();
98 
99  HcalRecHitsMaker_ = new HcalRecHitsMaker(RecHitsParameters,5);
100  }
101  break;
102 
103  case 6:
104  {
105  //HF
106  if (theOutputRecHitCollections.size()&&theOutputRecHitCollections[input].size())
107  produces<HFRecHitCollection>(theOutputRecHitCollections[input]);
108  else
109  produces<HFRecHitCollection>();
110  if(doDigis_) produces<HFDigiCollection>();
111 
112  HcalRecHitsMaker_ = new HcalRecHitsMaker(RecHitsParameters,6);
113  }
114  break;
115 
116  default:
117  // Should not happen
118  break;
119 
120  }
121 
122  }
123 
124 }
125 
127 {
128 }
129 
130 void
132 
133  for ( unsigned input=0; input<theInputRecHitCollectionTypes.size(); ++input ) {
134  switch ( theInputRecHitCollectionTypes[input] ) {
135  case 1:
136  {
137  // preshower
139  }
140  break;
141  case 2:
142  {
143  // ecal barrel
145  }
146  break;
147  case 3:
148  {
149  // ecal endcap
151  }
152  break;
153  case 4:
154  case 5:
155  case 6:
156  {
158  }
159  break;
160  default:
161  break;
162  }
163  }
164 }
165 
167 {
168  //std::cout << " (Fast)RecHitsProducer terminating " << std::endl;
173 }
174 
176 {
178  es.get<IdealGeometryRecord>().get( topo );
179 
181 
182  // create empty outputs for HCAL
183  // see RecoLocalCalo/HcalRecProducers/src/HcalSimpleReconstructor.cc
184  for ( unsigned input=0; input<theInputRecHitCollectionTypes.size(); ++input ) {
185  switch ( theInputRecHitCollectionTypes[input] ) {
186  case 1:
187  {
188  // preshower
189  std::auto_ptr<ESRecHitCollection> reces(new ESRecHitCollection); // ECAL pre-shower
192  iEvent.put(reces,theOutputRecHitCollections[input]);
193  else
194  iEvent.put(reces);
195  break;
196  }
197 
198  case 2:
199  {
200  // ecal barrel
201  std::auto_ptr<EBRecHitCollection> receb(new EBRecHitCollection); // ECAL Barrel
202  std::auto_ptr<EBDigiCollection> digieb(new EBDigiCollection(1));
203  EcalBarrelRecHitsMaker_->loadEcalBarrelRecHits(iEvent,*receb,*digieb, &random);
204  // std::cout << " ECALBarrel " << receb->size() << std::endl;
206  iEvent.put(receb,theOutputRecHitCollections[input]);
207  else
208  iEvent.put(receb);
209 
210  if(doDigis_)
211  iEvent.put(digieb);
212  }
213  break;
214  case 3:
215  {
216  // ecal endcap
217  std::auto_ptr<EERecHitCollection> recee(new EERecHitCollection); // ECAL Endcap
218  std::auto_ptr<EEDigiCollection> digiee(new EEDigiCollection(1));
219  EcalEndcapRecHitsMaker_->loadEcalEndcapRecHits(iEvent,*recee,*digiee, &random);
220  // std::cout << " ECALEndcap " << recee->size() << std::endl;
222  iEvent.put(recee,theOutputRecHitCollections[input]);
223  else
224  iEvent.put(recee);
225 
226  if(doDigis_)
227  iEvent.put(digiee);
228  }
229  break;
230  case 4:
231  {
232  // hbhe
233  std::auto_ptr<HBHERecHitCollection> rec1(new HBHERecHitCollection); // Barrel+Endcap
234  std::auto_ptr<HBHEDigiCollection> digihbhe(new HBHEDigiCollection);
235  HcalRecHitsMaker_->loadHcalRecHits(iEvent,(*topo),*rec1,*digihbhe, &random);
237  iEvent.put(rec1,theOutputRecHitCollections[input]);
238  else
239  iEvent.put(rec1);
240 
241  if(doDigis_)
242  iEvent.put(digihbhe);
243  }
244  break;
245  case 5:
246  {
247  //ho
248  std::auto_ptr<HORecHitCollection> rec2(new HORecHitCollection); // Outer
249  std::auto_ptr<HODigiCollection> digiho(new HODigiCollection);
250 
251  HcalRecHitsMaker_->loadHcalRecHits(iEvent,(*topo),*rec2,*digiho, &random);
253  iEvent.put(rec2,theOutputRecHitCollections[input]);
254  else
255  iEvent.put(rec2);
256  if(doDigis_)
257  iEvent.put(digiho);
258  }
259  break;
260  case 6:
261  {
262  //hf
263  std::auto_ptr<HFRecHitCollection> rec3(new HFRecHitCollection); // Forward
264  std::auto_ptr<HFDigiCollection> digihf(new HFDigiCollection);
265  HcalRecHitsMaker_->loadHcalRecHits(iEvent,(*topo),*rec3,*digihf, &random);
267  iEvent.put(rec3,theOutputRecHitCollections[input]);
268  else
269  iEvent.put(rec3);
270  if(doDigis_)
271  iEvent.put(digihf);
272  }
273  break;
274  default:
275  break;
276  }
277  }
278 }
279 
void loadHcalRecHits(edm::Event &iEvent, const HcalTopology &, HBHERecHitCollection &hbheHits, HBHEDigiCollection &hbheDigis, RandomEngineAndDistribution const *)
T getParameter(std::string const &) const
EcalEndcapRecHitsMaker * EcalEndcapRecHitsMaker_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void beginRun(const edm::Run &run, const edm::EventSetup &es) override
#define NULL
Definition: scimark2.h:8
TRandom random
Definition: MVATrainer.cc:138
EcalPreshowerRecHitsMaker * EcalPreshowerRecHitsMaker_
void loadEcalPreshowerRecHits(edm::Event &iEvent, ESRecHitCollection &esRecHits, RandomEngineAndDistribution const *)
static std::string const input
Definition: EdmProvDump.cc:44
HcalRecHitsMaker * HcalRecHitsMaker_
int iEvent
Definition: GenABIO.cc:230
std::vector< std::string > theOutputRecHitCollections
void loadEcalEndcapRecHits(edm::Event &iEvent, EERecHitCollection &ecalHits, EEDigiCollection &ecalDigis, RandomEngineAndDistribution const *)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
std::vector< unsigned int > theInputRecHitCollectionTypes
const T & get() const
Definition: EventSetup.h:55
void init(const edm::EventSetup &es, bool dodigis, bool domiscalib)
EcalBarrelRecHitsMaker * EcalBarrelRecHitsMaker_
virtual void endJob() override
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
void init(const edm::EventSetup &es)
StreamID streamID() const
Definition: Event.h:72
tuple cout
Definition: gather_cfg.py:121
CaloRecHitsProducer(edm::ParameterSet const &p)
void loadEcalBarrelRecHits(edm::Event &iEvent, EBRecHitCollection &ecalHits, EBDigiCollection &ecaldigis, RandomEngineAndDistribution const *)
void init(const edm::EventSetup &es, bool dodigis, bool domiscalib)
void init(const edm::EventSetup &es, bool dodigis, bool doMiscalib)
Definition: Run.h:41