CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
L1RCTTPGProvider Class Reference

#include <L1Trigger/L1RCTTPGProvider/src/L1RCTTPGProvider.cc>

Inheritance diagram for L1RCTTPGProvider:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 L1RCTTPGProvider (const edm::ParameterSet &)
 
 ~L1RCTTPGProvider ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void endJob ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

edm::InputTag ecalTPG_
 
int hbShift
 
edm::InputTag hcalTPG_
 
int hfShift
 
int postSamples
 
int preSamples
 
bool useEcalCosmicTiming
 
bool useHcalCosmicTiming
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 36 of file L1RCTTPGProvider.h.

Constructor & Destructor Documentation

L1RCTTPGProvider::L1RCTTPGProvider ( const edm::ParameterSet iConfig)
explicit

Definition at line 5 of file L1RCTTPGProvider.cc.

References i, postSamples, and preSamples.

5  :
6  ecalTPG_(iConfig.getParameter<edm::InputTag>("ecalTPGs")),
7  hcalTPG_(iConfig.getParameter<edm::InputTag>("hcalTPGs")),
8  useHcalCosmicTiming(iConfig.getParameter<bool>("useHCALCosmicTiming")),
9  useEcalCosmicTiming(iConfig.getParameter<bool>("useECALCosmicTiming")),
10  preSamples(iConfig.getParameter<int>("preSamples")),
11  postSamples(iConfig.getParameter<int>("postSamples")),
12  hfShift(iConfig.getParameter<int>("HFShift")),
13  hbShift(iConfig.getParameter<int>("HBShift"))
14 {
15 
16  //Output :The new manipulated TPGs
17  //make it smart - to name the collections
18  //correctly
19  char ecal_label[200];
20  char hcal_label[200];
21 
22 
23 
24  for(int i=preSamples;i>0;--i)
25  {
26  sprintf(ecal_label,"ECALBxminus%d",i);
27  sprintf(hcal_label,"HCALBxminus%d",i);
28  produces<EcalTrigPrimDigiCollection>(ecal_label);
29  produces<HcalTrigPrimDigiCollection>(hcal_label);
30  }
31 
32  produces<EcalTrigPrimDigiCollection>("ECALBx0");
33  produces<HcalTrigPrimDigiCollection>("HCALBx0");
34 
35  for(int i=0;i<postSamples;++i)
36  {
37  sprintf(ecal_label,"ECALBxplus%d",i+1);
38  sprintf(hcal_label,"HCALBxplus%d",i+1);
39  produces<EcalTrigPrimDigiCollection>(ecal_label);
40  produces<HcalTrigPrimDigiCollection>(hcal_label);
41  }
42 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
edm::InputTag ecalTPG_
edm::InputTag hcalTPG_
L1RCTTPGProvider::~L1RCTTPGProvider ( )

Definition at line 44 of file L1RCTTPGProvider.cc.

45 {
46  // do anything here that needs to be done at desctruction time
47  // (e.g. close files, deallocate resources etc.)
48 }

Member Function Documentation

void L1RCTTPGProvider::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 404 of file L1RCTTPGProvider.cc.

404  {
405 }
void L1RCTTPGProvider::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 57 of file L1RCTTPGProvider.cc.

References patCandidatesForDimuonsSequences_cff::ecal, ecalTPG_, EcalTriggerTower, edm::Event::getByLabel(), hbShift, patCandidatesForDimuonsSequences_cff::hcal, hcalTPG_, hfShift, i, j, postSamples, preSamples, edm::Event::put(), compare_using_db::sample, HcalTriggerPrimitiveDigi::setPresamples(), EcalTriggerPrimitiveDigi::setSample(), HcalTriggerPrimitiveDigi::setSample(), EcalTriggerPrimitiveDigi::setSize(), HcalTriggerPrimitiveDigi::setSize(), useEcalCosmicTiming, useHcalCosmicTiming, and ecaldqm::zside().

58 {
59  using namespace edm;
60  //Declare handles
63 
64  //Declare vector of collection to send for output !
65 
66  std::vector<EcalTrigPrimDigiCollection> ecalColl(preSamples+1+postSamples);
67  std::vector<HcalTrigPrimDigiCollection> hcalColl(preSamples+1+postSamples);
68 
69  unsigned nSamples = preSamples + postSamples + 1;
70 
71 
72  if(iEvent.getByLabel(ecalTPG_,ecal))
73  if (ecal.isValid())
74  {
75  // loop through all ecal digis
76  for (EcalTrigPrimDigiCollection::const_iterator ecal_it = ecal->begin(); ecal_it != ecal->end(); ecal_it++)
77  {
78  short zside = ecal_it->id().zside();
79  unsigned short ietaAbs = ecal_it->id().ietaAbs();
80  short iphi = ecal_it->id().iphi();
81  unsigned short digiSize = ecal_it->size();
82  unsigned short nSOI = (unsigned short) ( ecal_it->sampleOfInterest() );
83  if (digiSize < nSamples || nSOI < preSamples || ((int)(digiSize - nSOI) < (int)(nSamples - preSamples)))
84  {
85  unsigned short preLoopsZero = (unsigned short) (preSamples)- nSOI;
86 
87  // fill extra bx's at beginning with zeros
88  for (int sample = 0; sample < preLoopsZero; sample++)
89  {
90  // fill first few with zeros
92  ecalDigi(EcalTrigTowerDetId((int) zside, EcalTriggerTower,
93  (int) ietaAbs, (int) iphi));
94  ecalDigi.setSize(1);
95  ecalDigi.setSample(0, EcalTriggerPrimitiveSample(0,false,0));
96  ecalColl[sample].push_back(ecalDigi);
97  }
98 
99  // loop through existing data
100  for (int sample = preLoopsZero;sample < (preLoopsZero + digiSize); sample++)
101  {
102  // go through data
104  ecalDigi(EcalTrigTowerDetId((int) zside, EcalTriggerTower,
105  (int) ietaAbs, (int) iphi));
106  ecalDigi.setSize(1);
107  if (useEcalCosmicTiming && iphi >= 1 && iphi <= 36)
108  {
109  if (nSOI < (preSamples + 1))
110  {
111  edm::LogWarning ("TooLittleData")
112  << "ECAL data needs at least one presample "
113  << "more than the number requested "
114  << "to use ecal cosmic timing mod! "
115  << "reverting to useEcalCosmicTiming = false "
116  << "for rest of job.";
117  useEcalCosmicTiming = false;
118  }
119  else
120  {
121  ecalDigi.setSample(0, EcalTriggerPrimitiveSample
122  (ecal_it->sample(nSOI + sample -
123  preSamples -
124  1).raw()));
125  }
126  }
127  //else
128  if ((!useEcalCosmicTiming) || (iphi >=37 && iphi <= 72))
129  {
130  ecalDigi.setSample(0, EcalTriggerPrimitiveSample
131  (ecal_it->sample(nSOI + sample -
132  preSamples).raw()));
133  }
134  ecalColl[sample].push_back(ecalDigi);
135  }
136 
137  // fill extra bx's at end with zeros
138  for (unsigned int sample = (preLoopsZero + digiSize);
139  sample < nSamples; sample++)
140  {
141  // fill zeros!
143  ecalDigi(EcalTrigTowerDetId((int) zside, EcalTriggerTower,
144  (int) ietaAbs, (int) iphi));
145  ecalDigi.setSize(1);
146  ecalDigi.setSample(0, EcalTriggerPrimitiveSample(0,false,0));
147  ecalColl[sample].push_back(ecalDigi);
148  }
149  }
150  else
151  {
152  for (unsigned short sample = 0; sample < nSamples; sample++)
153  {
154  // put each time sample into its own digi
155  short zside = ecal_it->id().zside();
156  unsigned short ietaAbs = ecal_it->id().ietaAbs();
157  short iphi = ecal_it->id().iphi();
159  ecalDigi(EcalTrigTowerDetId((int) zside, EcalTriggerTower,
160  (int) ietaAbs, (int) iphi));
161  ecalDigi.setSize(1);
162 
163  if (useEcalCosmicTiming && iphi >= 1 && iphi <=36)
164  {
165  if (nSOI < (preSamples + 1))
166  {
167  edm::LogWarning ("TooLittleData")
168  << "ECAL data needs at least one presample "
169  << "more than the number requested "
170  << "to use ecal cosmic timing mod! "
171  << "reverting to useEcalCosmicTiming = false "
172  << "for rest of job.";
173  useEcalCosmicTiming = false;
174  }
175  else
176  {
177  ecalDigi.setSample(0, EcalTriggerPrimitiveSample
178  (ecal_it->sample
179  (ecal_it->sampleOfInterest() +
180  sample - preSamples -
181  1).raw()));
182  }
183  }
184  //else
185  if ((!useEcalCosmicTiming) || (iphi >=37 && iphi <= 72))
186  {
187  ecalDigi.setSample(0, EcalTriggerPrimitiveSample
188  (ecal_it->sample
189  (ecal_it->sampleOfInterest() +
190  sample - preSamples).raw()));
191  }
192  // push back each digi into correct "time sample" of coll
193  ecalColl[sample].push_back(ecalDigi);
194  }
195  }
196  }
197  }
198 
199  if(iEvent.getByLabel(hcalTPG_,hcal))
200  if (hcal.isValid())
201  {
202  // loop through all hcal digis
203  for (HcalTrigPrimDigiCollection::const_iterator hcal_it = hcal->begin(); hcal_it != hcal->end(); hcal_it++)
204  {
205  short ieta = hcal_it->id().ieta();
206  short iphi = hcal_it->id().iphi();
207  // loop through time samples for each digi
208  unsigned short digiSize = hcal_it->size();
209  // (size of each digi must be no less than nSamples)
210  unsigned short nSOI = (unsigned short) (hcal_it->presamples());
211  if (digiSize < nSamples || nSOI < preSamples
212  || ((int)(digiSize - nSOI) < (int)(nSamples - preSamples)))
213  {
214  unsigned short preLoopsZero = (unsigned short) (preSamples)
215  - nSOI;
216  // fill extra bx's at beginning with zeros
217  for (int sample = 0; sample < preLoopsZero; sample++)
218  {
219  // fill first few with zeros
220  HcalTriggerPrimitiveDigi hcalDigi(HcalTrigTowerDetId((int) ieta, (int) iphi));
221  hcalDigi.setSize(1);
222  hcalDigi.setPresamples(0);
223  hcalDigi.setSample(0, HcalTriggerPrimitiveSample(0,false,0,0));
224  hcalColl[sample].push_back(hcalDigi);
225  }
226 
227  // loop through existing data
228  for (int sample = preLoopsZero;
229  sample < (preLoopsZero + digiSize); sample++)
230  {
231  // go through data
232  HcalTriggerPrimitiveDigi hcalDigi(HcalTrigTowerDetId((int) ieta, (int) iphi));
233  hcalDigi.setSize(1);
234  hcalDigi.setPresamples(0);
235 
236  if (useHcalCosmicTiming && iphi >= 1 && iphi <= 36)
237  {
238  if (nSOI < (preSamples + 1))
239  {
240  edm::LogWarning ("TooLittleData")
241  << "HCAL data needs at least one presample "
242  << "more than the number requested "
243  << "to use hcal cosmic timing mod! "
244  << "reverting to useHcalCosmicTiming = false "
245  << "for rest of job.";
246  useHcalCosmicTiming = false;
247  }
248  else
249  {
250  hcalDigi.setSample(0, HcalTriggerPrimitiveSample
251  (hcal_it->sample(hcal_it->
252  presamples() +
253  sample -
254  preSamples -
255  1).raw()));
256  }
257  }
258  //else
259  if ((!useHcalCosmicTiming) || (iphi >= 37 && iphi <= 72))
260  {
261 
262  hcalDigi.setSample(0, HcalTriggerPrimitiveSample
263  (hcal_it->sample(hcal_it->
264  presamples() +
265  sample -
266  preSamples).raw()));
267 
268  }
269  hcalColl[sample].push_back(hcalDigi);
270  }
271 
272  // fill extra bx's at end with zeros
273  for (unsigned int sample = (preLoopsZero + digiSize);
274  sample < nSamples; sample++)
275  {
276  // fill zeros!
278  hcalDigi(HcalTrigTowerDetId((int) ieta, (int) iphi));
279  hcalDigi.setSize(1);
280  hcalDigi.setPresamples(0);
281  hcalDigi.setSample(0, HcalTriggerPrimitiveSample(0,false,0,0));
282  hcalColl[sample].push_back(hcalDigi);
283  }
284  }
285  else
286  {
287  for (unsigned short sample = 0; sample < nSamples; sample++)
288  {
289  // put each (relevant) time sample into its own digi
290  HcalTriggerPrimitiveDigi hcalDigi(HcalTrigTowerDetId((int) ieta, (int) iphi));
291  hcalDigi.setSize(1);
292  hcalDigi.setPresamples(0);
293 
294  if (useHcalCosmicTiming && iphi >= 1 && iphi <= 36)
295  {
296  if (nSOI < (preSamples + 1))
297  {
298  edm::LogWarning ("TooLittleData")
299  << "HCAL data needs at least one presample "
300  << "more than the number requested "
301  << "to use hcal cosmic timing mod! "
302  << "reverting to useHcalCosmicTiming = false "
303  << "for rest of job.";
304  useHcalCosmicTiming = false;
305  }
306  else
307  {
308  hcalDigi.setSample(0, HcalTriggerPrimitiveSample
309  (hcal_it->sample(hcal_it->
310  presamples() +
311  sample -
312  preSamples -
313  1).raw()));
314  }
315  }
316  //else
317  if ((!useHcalCosmicTiming) || (iphi >= 37 && iphi <= 72))
318  {
319  if(ieta>-29 && ieta<29)
320  hcalDigi.setSample(0, HcalTriggerPrimitiveSample
321  (hcal_it->sample(hcal_it->
322  presamples() +
323  sample -
324  preSamples+hbShift).raw()));
325  if(ieta<=-29 || ieta>=29)
326  hcalDigi.setSample(0, HcalTriggerPrimitiveSample
327  (hcal_it->sample(hcal_it->
328  presamples() +
329  sample -
330  preSamples+hfShift).raw()));
331  }
332  hcalColl[sample].push_back(hcalDigi);
333  }
334  }
335  }
336  }
337 
338 
339  //Now put the events back to file
340 
341  for(int i=0;i<preSamples;++i)
342  {
343  char ecal_label[200];
344  char hcal_label[200];
345 
346 
347  sprintf(ecal_label,"ECALBxminus%d",preSamples-i);
348  sprintf(hcal_label,"HCALBxminus%d",preSamples-i);
349 
350  std::auto_ptr<EcalTrigPrimDigiCollection> ecalIn(new EcalTrigPrimDigiCollection);
351  std::auto_ptr<HcalTrigPrimDigiCollection> hcalIn(new HcalTrigPrimDigiCollection);
352  for(unsigned int j=0;j<ecalColl[i].size();++j)
353  {
354  ecalIn->push_back((ecalColl[i])[j]);
355  }
356  for(unsigned int j=0;j<hcalColl[i].size();++j)
357  hcalIn->push_back((hcalColl[i])[j]);
358 
359  iEvent.put(ecalIn,ecal_label);
360  iEvent.put(hcalIn,hcal_label);
361 
362  }
363 
364 
365  std::auto_ptr<EcalTrigPrimDigiCollection> ecal0(new EcalTrigPrimDigiCollection);
366  std::auto_ptr<HcalTrigPrimDigiCollection> hcal0(new HcalTrigPrimDigiCollection);
367  for(unsigned int j=0;j<ecalColl[preSamples].size();++j)
368  ecal0->push_back((ecalColl[preSamples])[j]);
369  for(unsigned int j=0;j<hcalColl[preSamples].size();++j)
370  hcal0->push_back((hcalColl[preSamples])[j]);
371 
372  iEvent.put(ecal0,"ECALBx0");
373  iEvent.put(hcal0,"HCALBx0");
374 
375 
376  for(int i=preSamples+1;i<preSamples+postSamples+1;++i)
377  {
378  char ecal_label[200];
379  char hcal_label[200];
380 
381  sprintf(ecal_label,"ECALBxplus%d",i-preSamples);
382  sprintf(hcal_label,"HCALBxplus%d",i-preSamples);
383 
384  std::auto_ptr<EcalTrigPrimDigiCollection> ecalIn2(new EcalTrigPrimDigiCollection);
385  std::auto_ptr<HcalTrigPrimDigiCollection> hcalIn2(new HcalTrigPrimDigiCollection);
386 
387  for(unsigned int j=0;j<ecalColl[i].size();++j)
388  ecalIn2->push_back((ecalColl[i])[j]);
389 
390  for(unsigned int j=0;j<hcalColl[i].size();++j)
391  hcalIn2->push_back((hcalColl[i])[j]);
392 
393 
394  iEvent.put(ecalIn2,ecal_label);
395  iEvent.put(hcalIn2,hcal_label);
396  }
397 }
int i
Definition: DBlmapReader.cc:9
edm::InputTag ecalTPG_
std::vector< EcalTriggerPrimitiveDigi >::const_iterator const_iterator
int zside(DetId const &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
int j
Definition: DBlmapReader.cc:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
edm::InputTag hcalTPG_

Member Data Documentation

edm::InputTag L1RCTTPGProvider::ecalTPG_
private

Definition at line 46 of file L1RCTTPGProvider.h.

Referenced by produce().

int L1RCTTPGProvider::hbShift
private

Definition at line 53 of file L1RCTTPGProvider.h.

Referenced by produce().

edm::InputTag L1RCTTPGProvider::hcalTPG_
private

Definition at line 47 of file L1RCTTPGProvider.h.

Referenced by produce().

int L1RCTTPGProvider::hfShift
private

Definition at line 52 of file L1RCTTPGProvider.h.

Referenced by produce().

int L1RCTTPGProvider::postSamples
private

Definition at line 51 of file L1RCTTPGProvider.h.

Referenced by L1RCTTPGProvider(), and produce().

int L1RCTTPGProvider::preSamples
private

Definition at line 50 of file L1RCTTPGProvider.h.

Referenced by L1RCTTPGProvider(), and produce().

bool L1RCTTPGProvider::useEcalCosmicTiming
private

Definition at line 49 of file L1RCTTPGProvider.h.

Referenced by produce().

bool L1RCTTPGProvider::useHcalCosmicTiming
private

Definition at line 48 of file L1RCTTPGProvider.h.

Referenced by produce().