CMS 3D CMS Logo

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 () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

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
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 mps_fire::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
edm::InputTag ecalTPG_
edm::InputTag hcalTPG_
L1RCTTPGProvider::~L1RCTTPGProvider ( )
override

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  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 404 of file L1RCTTPGProvider.cc.

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

Definition at line 57 of file L1RCTTPGProvider.cc.

References edm::SortedCollection< T, SORT >::begin(), digitizers_cfi::ecal, ecalTPG_, EcalTriggerTower, edm::SortedCollection< T, SORT >::end(), edm::Event::getByLabel(), hbShift, digitizers_cfi::hcal, hcalTPG_, hfShift, mps_fire::i, edm::HandleBase::isValid(), eostools::move(), hgc_digi::nSamples, postSamples, hcalTTPDigis_cfi::presamples, preSamples, edm::Event::put(), simplePhotonAnalyzer_cfi::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::unique_ptr<EcalTrigPrimDigiCollection> ecalIn(new EcalTrigPrimDigiCollection);
351  std::unique_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(std::move(ecalIn),ecal_label);
360  iEvent.put(std::move(hcalIn),hcal_label);
361 
362  }
363 
364 
365  std::unique_ptr<EcalTrigPrimDigiCollection> ecal0(new EcalTrigPrimDigiCollection);
366  std::unique_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(std::move(ecal0),"ECALBx0");
373  iEvent.put(std::move(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::unique_ptr<EcalTrigPrimDigiCollection> ecalIn2(new EcalTrigPrimDigiCollection);
385  std::unique_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(std::move(ecalIn2),ecal_label);
395  iEvent.put(std::move(hcalIn2),hcal_label);
396  }
397 }
edm::InputTag ecalTPG_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
std::vector< EcalTriggerPrimitiveDigi >::const_iterator const_iterator
int zside(DetId const &)
bool isValid() const
Definition: HandleBase.h:74
constexpr size_t nSamples
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:535
edm::InputTag hcalTPG_
const_iterator end() const
HLT enums.
def move(src, dest)
Definition: eostools.py:511
const_iterator begin() const

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().