CMS 3D CMS Logo

L1RCTTPGProvider.cc
Go to the documentation of this file.
4 
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  // Output :The new manipulated TPGs
15  // make it smart - to name the collections
16  // correctly
17  char ecal_label[200];
18  char hcal_label[200];
19 
20  for (int i = preSamples; i > 0; --i) {
21  sprintf(ecal_label, "ECALBxminus%d", i);
22  sprintf(hcal_label, "HCALBxminus%d", i);
23  produces<EcalTrigPrimDigiCollection>(ecal_label);
24  produces<HcalTrigPrimDigiCollection>(hcal_label);
25  }
26 
27  produces<EcalTrigPrimDigiCollection>("ECALBx0");
28  produces<HcalTrigPrimDigiCollection>("HCALBx0");
29 
30  for (int i = 0; i < postSamples; ++i) {
31  sprintf(ecal_label, "ECALBxplus%d", i + 1);
32  sprintf(hcal_label, "HCALBxplus%d", i + 1);
33  produces<EcalTrigPrimDigiCollection>(ecal_label);
34  produces<HcalTrigPrimDigiCollection>(hcal_label);
35  }
36 }
37 
39  // do anything here that needs to be done at desctruction time
40  // (e.g. close files, deallocate resources etc.)
41 }
42 
43 //
44 // member functions
45 //
46 
47 // ------------ method called to produce the data ------------
49  using namespace edm;
50  // Declare handles
53 
54  // Declare vector of collection to send for output !
55 
56  std::vector<EcalTrigPrimDigiCollection> ecalColl(preSamples + 1 + postSamples);
57  std::vector<HcalTrigPrimDigiCollection> hcalColl(preSamples + 1 + postSamples);
58 
59  unsigned nSamples = preSamples + postSamples + 1;
60 
61  if (iEvent.getByLabel(ecalTPG_, ecal))
62  if (ecal.isValid()) {
63  // loop through all ecal digis
64  for (EcalTrigPrimDigiCollection::const_iterator ecal_it = ecal->begin(); ecal_it != ecal->end(); ecal_it++) {
65  short zside = ecal_it->id().zside();
66  unsigned short ietaAbs = ecal_it->id().ietaAbs();
67  short iphi = ecal_it->id().iphi();
68  unsigned short digiSize = ecal_it->size();
69  unsigned short nSOI = (unsigned short)(ecal_it->sampleOfInterest());
70  if (digiSize < nSamples || nSOI < preSamples || ((int)(digiSize - nSOI) < (int)(nSamples - preSamples))) {
71  unsigned short preLoopsZero = (unsigned short)(preSamples)-nSOI;
72 
73  // fill extra bx's at beginning with zeros
74  for (int sample = 0; sample < preLoopsZero; sample++) {
75  // fill first few with zeros
76  EcalTriggerPrimitiveDigi ecalDigi(
77  EcalTrigTowerDetId((int)zside, EcalTriggerTower, (int)ietaAbs, (int)iphi));
78  ecalDigi.setSize(1);
79  ecalDigi.setSample(0, EcalTriggerPrimitiveSample(0, false, 0));
80  ecalColl[sample].push_back(ecalDigi);
81  }
82 
83  // loop through existing data
84  for (int sample = preLoopsZero; sample < (preLoopsZero + digiSize); sample++) {
85  // go through data
86  EcalTriggerPrimitiveDigi ecalDigi(
87  EcalTrigTowerDetId((int)zside, EcalTriggerTower, (int)ietaAbs, (int)iphi));
88  ecalDigi.setSize(1);
89  if (useEcalCosmicTiming && iphi >= 1 && iphi <= 36) {
90  if (nSOI < (preSamples + 1)) {
91  edm::LogWarning("TooLittleData") << "ECAL data needs at least one presample "
92  << "more than the number requested "
93  << "to use ecal cosmic timing mod! "
94  << "reverting to useEcalCosmicTiming = false "
95  << "for rest of job.";
96  useEcalCosmicTiming = false;
97  } else {
98  ecalDigi.setSample(0,
99  EcalTriggerPrimitiveSample(ecal_it->sample(nSOI + sample - preSamples - 1).raw()));
100  }
101  }
102  // else
103  if ((!useEcalCosmicTiming) || (iphi >= 37 && iphi <= 72)) {
104  ecalDigi.setSample(0, EcalTriggerPrimitiveSample(ecal_it->sample(nSOI + sample - preSamples).raw()));
105  }
106  ecalColl[sample].push_back(ecalDigi);
107  }
108 
109  // fill extra bx's at end with zeros
110  for (unsigned int sample = (preLoopsZero + digiSize); sample < nSamples; sample++) {
111  // fill zeros!
112  EcalTriggerPrimitiveDigi ecalDigi(
113  EcalTrigTowerDetId((int)zside, EcalTriggerTower, (int)ietaAbs, (int)iphi));
114  ecalDigi.setSize(1);
115  ecalDigi.setSample(0, EcalTriggerPrimitiveSample(0, false, 0));
116  ecalColl[sample].push_back(ecalDigi);
117  }
118  } else {
119  for (unsigned short sample = 0; sample < nSamples; sample++) {
120  // put each time sample into its own digi
121  short zside = ecal_it->id().zside();
122  unsigned short ietaAbs = ecal_it->id().ietaAbs();
123  short iphi = ecal_it->id().iphi();
124  EcalTriggerPrimitiveDigi ecalDigi(
125  EcalTrigTowerDetId((int)zside, EcalTriggerTower, (int)ietaAbs, (int)iphi));
126  ecalDigi.setSize(1);
127 
128  if (useEcalCosmicTiming && iphi >= 1 && iphi <= 36) {
129  if (nSOI < (preSamples + 1)) {
130  edm::LogWarning("TooLittleData") << "ECAL data needs at least one presample "
131  << "more than the number requested "
132  << "to use ecal cosmic timing mod! "
133  << "reverting to useEcalCosmicTiming = false "
134  << "for rest of job.";
135  useEcalCosmicTiming = false;
136  } else {
137  ecalDigi.setSample(0,
139  ecal_it->sample(ecal_it->sampleOfInterest() + sample - preSamples - 1).raw()));
140  }
141  }
142  // else
143  if ((!useEcalCosmicTiming) || (iphi >= 37 && iphi <= 72)) {
144  ecalDigi.setSample(
145  0,
146  EcalTriggerPrimitiveSample(ecal_it->sample(ecal_it->sampleOfInterest() + sample - preSamples).raw()));
147  }
148  // push back each digi into correct "time sample" of coll
149  ecalColl[sample].push_back(ecalDigi);
150  }
151  }
152  }
153  }
154 
155  if (iEvent.getByLabel(hcalTPG_, hcal))
156  if (hcal.isValid()) {
157  // loop through all hcal digis
158  for (HcalTrigPrimDigiCollection::const_iterator hcal_it = hcal->begin(); hcal_it != hcal->end(); hcal_it++) {
159  short ieta = hcal_it->id().ieta();
160  short iphi = hcal_it->id().iphi();
161  // loop through time samples for each digi
162  unsigned short digiSize = hcal_it->size();
163  // (size of each digi must be no less than nSamples)
164  unsigned short nSOI = (unsigned short)(hcal_it->presamples());
165  if (digiSize < nSamples || nSOI < preSamples || ((int)(digiSize - nSOI) < (int)(nSamples - preSamples))) {
166  unsigned short preLoopsZero = (unsigned short)(preSamples)-nSOI;
167  // fill extra bx's at beginning with zeros
168  for (int sample = 0; sample < preLoopsZero; sample++) {
169  // fill first few with zeros
171  hcalDigi.setSize(1);
172  hcalDigi.setPresamples(0);
173  hcalDigi.setSample(0, HcalTriggerPrimitiveSample(0, false, 0, 0));
174  hcalColl[sample].push_back(hcalDigi);
175  }
176 
177  // loop through existing data
178  for (int sample = preLoopsZero; sample < (preLoopsZero + digiSize); sample++) {
179  // go through data
181  hcalDigi.setSize(1);
182  hcalDigi.setPresamples(0);
183 
184  if (useHcalCosmicTiming && iphi >= 1 && iphi <= 36) {
185  if (nSOI < (preSamples + 1)) {
186  edm::LogWarning("TooLittleData") << "HCAL data needs at least one presample "
187  << "more than the number requested "
188  << "to use hcal cosmic timing mod! "
189  << "reverting to useHcalCosmicTiming = false "
190  << "for rest of job.";
191  useHcalCosmicTiming = false;
192  } else {
193  hcalDigi.setSample(
194  0,
195  HcalTriggerPrimitiveSample(hcal_it->sample(hcal_it->presamples() + sample - preSamples - 1).raw()));
196  }
197  }
198  // else
199  if ((!useHcalCosmicTiming) || (iphi >= 37 && iphi <= 72)) {
200  hcalDigi.setSample(
201  0, HcalTriggerPrimitiveSample(hcal_it->sample(hcal_it->presamples() + sample - preSamples).raw()));
202  }
203  hcalColl[sample].push_back(hcalDigi);
204  }
205 
206  // fill extra bx's at end with zeros
207  for (unsigned int sample = (preLoopsZero + digiSize); sample < nSamples; sample++) {
208  // fill zeros!
210  hcalDigi.setSize(1);
211  hcalDigi.setPresamples(0);
212  hcalDigi.setSample(0, HcalTriggerPrimitiveSample(0, false, 0, 0));
213  hcalColl[sample].push_back(hcalDigi);
214  }
215  } else {
216  for (unsigned short sample = 0; sample < nSamples; sample++) {
217  // put each (relevant) time sample into its own digi
219  hcalDigi.setSize(1);
220  hcalDigi.setPresamples(0);
221 
222  if (useHcalCosmicTiming && iphi >= 1 && iphi <= 36) {
223  if (nSOI < (preSamples + 1)) {
224  edm::LogWarning("TooLittleData") << "HCAL data needs at least one presample "
225  << "more than the number requested "
226  << "to use hcal cosmic timing mod! "
227  << "reverting to useHcalCosmicTiming = false "
228  << "for rest of job.";
229  useHcalCosmicTiming = false;
230  } else {
231  hcalDigi.setSample(
232  0,
233  HcalTriggerPrimitiveSample(hcal_it->sample(hcal_it->presamples() + sample - preSamples - 1).raw()));
234  }
235  }
236  // else
237  if ((!useHcalCosmicTiming) || (iphi >= 37 && iphi <= 72)) {
238  if (ieta > -29 && ieta < 29)
239  hcalDigi.setSample(0,
241  hcal_it->sample(hcal_it->presamples() + sample - preSamples + hbShift).raw()));
242  if (ieta <= -29 || ieta >= 29)
243  hcalDigi.setSample(0,
245  hcal_it->sample(hcal_it->presamples() + sample - preSamples + hfShift).raw()));
246  }
247  hcalColl[sample].push_back(hcalDigi);
248  }
249  }
250  }
251  }
252 
253  // Now put the events back to file
254 
255  for (int i = 0; i < preSamples; ++i) {
256  char ecal_label[200];
257  char hcal_label[200];
258 
259  sprintf(ecal_label, "ECALBxminus%d", preSamples - i);
260  sprintf(hcal_label, "HCALBxminus%d", preSamples - i);
261 
262  std::unique_ptr<EcalTrigPrimDigiCollection> ecalIn(new EcalTrigPrimDigiCollection);
263  std::unique_ptr<HcalTrigPrimDigiCollection> hcalIn(new HcalTrigPrimDigiCollection);
264  for (unsigned int j = 0; j < ecalColl[i].size(); ++j) {
265  ecalIn->push_back((ecalColl[i])[j]);
266  }
267  for (unsigned int j = 0; j < hcalColl[i].size(); ++j)
268  hcalIn->push_back((hcalColl[i])[j]);
269 
270  iEvent.put(std::move(ecalIn), ecal_label);
271  iEvent.put(std::move(hcalIn), hcal_label);
272  }
273 
274  std::unique_ptr<EcalTrigPrimDigiCollection> ecal0(new EcalTrigPrimDigiCollection);
275  std::unique_ptr<HcalTrigPrimDigiCollection> hcal0(new HcalTrigPrimDigiCollection);
276  for (unsigned int j = 0; j < ecalColl[preSamples].size(); ++j)
277  ecal0->push_back((ecalColl[preSamples])[j]);
278  for (unsigned int j = 0; j < hcalColl[preSamples].size(); ++j)
279  hcal0->push_back((hcalColl[preSamples])[j]);
280 
281  iEvent.put(std::move(ecal0), "ECALBx0");
282  iEvent.put(std::move(hcal0), "HCALBx0");
283 
284  for (int i = preSamples + 1; i < preSamples + postSamples + 1; ++i) {
285  char ecal_label[200];
286  char hcal_label[200];
287 
288  sprintf(ecal_label, "ECALBxplus%d", i - preSamples);
289  sprintf(hcal_label, "HCALBxplus%d", i - preSamples);
290 
291  std::unique_ptr<EcalTrigPrimDigiCollection> ecalIn2(new EcalTrigPrimDigiCollection);
292  std::unique_ptr<HcalTrigPrimDigiCollection> hcalIn2(new HcalTrigPrimDigiCollection);
293 
294  for (unsigned int j = 0; j < ecalColl[i].size(); ++j)
295  ecalIn2->push_back((ecalColl[i])[j]);
296 
297  for (unsigned int j = 0; j < hcalColl[i].size(); ++j)
298  hcalIn2->push_back((hcalColl[i])[j]);
299 
300  iEvent.put(std::move(ecalIn2), ecal_label);
301  iEvent.put(std::move(hcalIn2), hcal_label);
302  }
303 }
304 
305 // ------------ method called once each job just before starting event loop
306 // ------------
307 
308 // ------------ method called once each job just after ending the event loop
309 // ------------
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
simplePhotonAnalyzer_cfi.sample
sample
Definition: simplePhotonAnalyzer_cfi.py:12
l1RctEmulDigis_ECALGREN1_cff.useEcalCosmicTiming
useEcalCosmicTiming
Definition: l1RctEmulDigis_ECALGREN1_cff.py:15
L1RCTTPGProvider::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: L1RCTTPGProvider.cc:48
HcalTriggerPrimitiveSample
Definition: HcalTriggerPrimitiveSample.h:11
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
hcal
Definition: ConfigurationDatabase.cc:13
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::SortedCollection
Definition: SortedCollection.h:49
L1RCTTPGProvider::hbShift
int hbShift
Definition: L1RCTTPGProvider.h:52
L1RCTTPGProvider::hcalTPG_
edm::InputTag hcalTPG_
Definition: L1RCTTPGProvider.h:46
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
HcalTriggerPrimitiveDigi::setSample
void setSample(int i, const HcalTriggerPrimitiveSample &sam)
Definition: HcalTriggerPrimitiveDigi.h:43
L1RCTTPGProvider::endJob
void endJob() override
Definition: L1RCTTPGProvider.cc:310
edm::Handle
Definition: AssociativeIterator.h:50
PresampleTask_cfi.nSamples
nSamples
Definition: PresampleTask_cfi.py:7
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
patCandidatesForDimuonsSequences_cff.hcal
hcal
Definition: patCandidatesForDimuonsSequences_cff.py:37
L1RCTTPGProvider::useEcalCosmicTiming
bool useEcalCosmicTiming
Definition: L1RCTTPGProvider.h:48
L1RCTTPGProvider::hfShift
int hfShift
Definition: L1RCTTPGProvider.h:51
HcalDigiCollections.h
L1RCTTPGProvider::postSamples
int postSamples
Definition: L1RCTTPGProvider.h:50
EcalDigiCollections.h
L1RCTTPGProvider.h
ValL1Emulator_cff.postSamples
postSamples
Definition: ValL1Emulator_cff.py:57
L1RCTTPGProvider::useHcalCosmicTiming
bool useHcalCosmicTiming
Definition: L1RCTTPGProvider.h:47
edm::LogWarning
Definition: MessageLogger.h:141
EcalTriggerPrimitiveDigi::setSize
void setSize(int size)
Definition: EcalTriggerPrimitiveDigi.cc:60
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
HcalTriggerPrimitiveDigi
Definition: HcalTriggerPrimitiveDigi.h:13
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
L1RCTTPGProvider::ecalTPG_
edm::InputTag ecalTPG_
Definition: L1RCTTPGProvider.h:45
EcalTriggerPrimitiveDigi::setSample
void setSample(int i, const EcalTriggerPrimitiveSample &sam)
Definition: EcalTriggerPrimitiveDigi.h:36
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
HcalTriggerPrimitiveDigi::setPresamples
void setPresamples(int ps)
Definition: HcalTriggerPrimitiveDigi.cc:15
edm::EventSetup
Definition: EventSetup.h:57
L1RCTTPGProvider::preSamples
int preSamples
Definition: L1RCTTPGProvider.h:49
l1RctEmulDigis_ECALGREN1_cff.useHcalCosmicTiming
useHcalCosmicTiming
Definition: l1RctEmulDigis_ECALGREN1_cff.py:18
eostools.move
def move(src, dest)
Definition: eostools.py:511
EcalTriggerTower
Definition: EcalSubdetector.h:10
ValL1Emulator_cff.preSamples
preSamples
Definition: ValL1Emulator_cff.py:56
EcalTriggerPrimitiveDigi
Definition: EcalTriggerPrimitiveDigi.h:16
bsc_activity_cfg.ecal
ecal
Definition: bsc_activity_cfg.py:25
EcalTriggerPrimitiveSample
Definition: EcalTriggerPrimitiveSample.h:12
L1RCTTPGProvider::~L1RCTTPGProvider
~L1RCTTPGProvider() override
Definition: L1RCTTPGProvider.cc:38
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
L1RCTTPGProvider::L1RCTTPGProvider
L1RCTTPGProvider(const edm::ParameterSet &)
Definition: L1RCTTPGProvider.cc:5
edm::Event
Definition: Event.h:73
HcalTriggerPrimitiveDigi::setSize
void setSize(int size)
Definition: HcalTriggerPrimitiveDigi.cc:7
HcalTrigTowerDetId
Definition: HcalTrigTowerDetId.h:14