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 {
132 }
133 
134 void
136 
137  for ( unsigned input=0; input<theInputRecHitCollectionTypes.size(); ++input ) {
138  switch ( theInputRecHitCollectionTypes[input] ) {
139  case 1:
140  {
141  // preshower
143  }
144  break;
145  case 2:
146  {
147  // ecal barrel
149  }
150  break;
151  case 3:
152  {
153  // ecal endcap
155  }
156  break;
157  case 4:
158  case 5:
159  case 6:
160  {
162  }
163  break;
164  default:
165  break;
166  }
167  }
168 }
169 
171 {
173  es.get<IdealGeometryRecord>().get( topo );
174 
176 
177  // create empty outputs for HCAL
178  // see RecoLocalCalo/HcalRecProducers/src/HcalSimpleReconstructor.cc
179  for ( unsigned input=0; input<theInputRecHitCollectionTypes.size(); ++input ) {
180  switch ( theInputRecHitCollectionTypes[input] ) {
181  case 1:
182  {
183  // preshower
184  std::auto_ptr<ESRecHitCollection> reces(new ESRecHitCollection); // ECAL pre-shower
187  iEvent.put(reces,theOutputRecHitCollections[input]);
188  else
189  iEvent.put(reces);
190  break;
191  }
192 
193  case 2:
194  {
195  // ecal barrel
196  std::auto_ptr<EBRecHitCollection> receb(new EBRecHitCollection); // ECAL Barrel
197  std::auto_ptr<EBDigiCollection> digieb(new EBDigiCollection(1));
198  EcalBarrelRecHitsMaker_->loadEcalBarrelRecHits(iEvent,*receb,*digieb, &random);
199  // std::cout << " ECALBarrel " << receb->size() << std::endl;
201  iEvent.put(receb,theOutputRecHitCollections[input]);
202  else
203  iEvent.put(receb);
204 
205  if(doDigis_)
206  iEvent.put(digieb);
207  }
208  break;
209  case 3:
210  {
211  // ecal endcap
212  std::auto_ptr<EERecHitCollection> recee(new EERecHitCollection); // ECAL Endcap
213  std::auto_ptr<EEDigiCollection> digiee(new EEDigiCollection(1));
214  EcalEndcapRecHitsMaker_->loadEcalEndcapRecHits(iEvent,*recee,*digiee, &random);
215  // std::cout << " ECALEndcap " << recee->size() << std::endl;
217  iEvent.put(recee,theOutputRecHitCollections[input]);
218  else
219  iEvent.put(recee);
220 
221  if(doDigis_)
222  iEvent.put(digiee);
223  }
224  break;
225  case 4:
226  {
227  // hbhe
228  std::auto_ptr<HBHERecHitCollection> rec1(new HBHERecHitCollection); // Barrel+Endcap
229  std::auto_ptr<HBHEDigiCollection> digihbhe(new HBHEDigiCollection);
230  HcalRecHitsMaker_->loadHcalRecHits(iEvent,(*topo),*rec1,*digihbhe, &random);
232  iEvent.put(rec1,theOutputRecHitCollections[input]);
233  else
234  iEvent.put(rec1);
235 
236  if(doDigis_)
237  iEvent.put(digihbhe);
238  }
239  break;
240  case 5:
241  {
242  //ho
243  std::auto_ptr<HORecHitCollection> rec2(new HORecHitCollection); // Outer
244  std::auto_ptr<HODigiCollection> digiho(new HODigiCollection);
245 
246  HcalRecHitsMaker_->loadHcalRecHits(iEvent,(*topo),*rec2,*digiho, &random);
248  iEvent.put(rec2,theOutputRecHitCollections[input]);
249  else
250  iEvent.put(rec2);
251  if(doDigis_)
252  iEvent.put(digiho);
253  }
254  break;
255  case 6:
256  {
257  //hf
258  std::auto_ptr<HFRecHitCollection> rec3(new HFRecHitCollection); // Forward
259  std::auto_ptr<HFDigiCollection> digihf(new HFDigiCollection);
260  HcalRecHitsMaker_->loadHcalRecHits(iEvent,(*topo),*rec3,*digihf, &random);
262  iEvent.put(rec3,theOutputRecHitCollections[input]);
263  else
264  iEvent.put(rec3);
265  if(doDigis_)
266  iEvent.put(digihf);
267  }
268  break;
269  default:
270  break;
271  }
272  }
273 }
274 
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:43
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 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