1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
|
/*
*\ Class EcalRawToDigi
*
* This class takes unpacks ECAL raw data
* produces digis and raw data format prolblems reports
*
* \file EcalRawToDigi.h
*
* \author N. Almeida
* \author G. Franzoni
*
*/
#include <iostream>
#include "EventFilter/EcalRawToDigi/interface/DCCRawDataDefinitions.h"
#include <DataFormats/FEDRawData/interface/FEDRawData.h>
#include <DataFormats/FEDRawData/interface/FEDNumbering.h>
#include <DataFormats/FEDRawData/interface/FEDRawDataCollection.h>
#include <DataFormats/EcalDigi/interface/EcalDigiCollections.h>
#include <DataFormats/EcalRawData/interface/EcalRawDataCollections.h>
#include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
#include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
#include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
#include <DataFormats/Common/interface/Handle.h>
#include <FWCore/Framework/interface/Event.h>
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include <FWCore/MessageLogger/interface/MessageLogger.h>
#include <FWCore/ParameterSet/interface/ParameterSet.h>
#include <FWCore/Framework/interface/ESWatcher.h>
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "DataFormats/EcalRawData/interface/EcalListOfFEDS.h"
#include <sys/time.h>
class EcalElectronicsMapper;
class EcalElectronicsMapping;
class DCCDataUnpacker;
class EcalRawToDigi : public edm::stream::EDProducer<> {
public:
/**
* Class constructor
*/
explicit EcalRawToDigi(const edm::ParameterSet& ps);
/**
* Functions that are called by framework at each event
*/
void produce(edm::Event& e, const edm::EventSetup& c) override;
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
// function called at start of each run
void beginRun(const edm::Run& run, const edm::EventSetup& es) override;
/**
* Class destructor
*/
~EcalRawToDigi() override;
edm::ESWatcher<EcalMappingRcd> watcher_;
private:
//list of FEDs to unpack
std::vector<int> fedUnpackList_;
std::vector<int> orderedFedUnpackList_;
std::vector<int> orderedDCCIdList_;
unsigned int numbXtalTSamples_;
unsigned int numbTriggerTSamples_;
bool headerUnpacking_;
bool srpUnpacking_;
bool tccUnpacking_;
bool feUnpacking_;
bool memUnpacking_;
bool syncCheck_;
bool feIdCheck_;
bool forceToKeepFRdata_;
bool first_;
bool put_;
edm::EDGetTokenT<FEDRawDataCollection> dataToken_;
edm::EDGetTokenT<EcalListOfFEDS> fedsToken_;
edm::ESGetToken<EcalChannelStatusMap, EcalChannelStatusRcd> chStatusToken_;
edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> ecalMappingToken_;
// -- For regional unacking :
bool REGIONAL_;
//an electronics mapper class
EcalElectronicsMapper* myMap_;
//Ecal unpacker
DCCDataUnpacker* theUnpacker_;
unsigned int nevts_; // NA: for testing
double RUNNING_TIME_, SETUP_TIME_;
};
#include "EventFilter/EcalRawToDigi/interface/EcalElectronicsMapper.h"
#include "EventFilter/EcalRawToDigi/interface/DCCDataUnpacker.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
EcalRawToDigi::EcalRawToDigi(edm::ParameterSet const& conf)
:
//define the list of FED to be unpacked
fedUnpackList_(conf.getParameter<std::vector<int> >("FEDs")),
//define the ordered FED list
orderedFedUnpackList_(conf.getParameter<std::vector<int> >("orderedFedList")),
//define the ordered DCCId list
orderedDCCIdList_(conf.getParameter<std::vector<int> >("orderedDCCIdList")),
//get number of Xtal Time Samples
numbXtalTSamples_(conf.getParameter<int>("numbXtalTSamples")),
//Get number of Trigger Time Samples
numbTriggerTSamples_(conf.getParameter<int>("numbTriggerTSamples")),
//See if header unpacking is enabled
headerUnpacking_(conf.getParameter<bool>("headerUnpacking")),
//See if srp unpacking is enabled
srpUnpacking_(conf.getParameter<bool>("srpUnpacking")),
//See if tcc unpacking is enabled
tccUnpacking_(conf.getParameter<bool>("tccUnpacking")),
//See if fe unpacking is enabled
feUnpacking_(conf.getParameter<bool>("feUnpacking")),
//See if fe unpacking is enabled for mem box
memUnpacking_(conf.getParameter<bool>("memUnpacking")),
//See if syncCheck is enabled
syncCheck_(conf.getParameter<bool>("syncCheck")),
//See if feIdCheck is enabled
feIdCheck_(conf.getParameter<bool>("feIdCheck")),
// See if we want to keep data even if we have a mismatch between SR decision and block length
forceToKeepFRdata_(conf.getParameter<bool>("forceToKeepFRData")),
put_(conf.getParameter<bool>("eventPut")),
REGIONAL_(conf.getParameter<bool>("DoRegional")),
myMap_(nullptr),
theUnpacker_(nullptr)
{
first_ = true;
DCCDataUnpacker::silentMode_ = conf.getUntrackedParameter<bool>("silentMode", false);
if (numbXtalTSamples_ < 6 || numbXtalTSamples_ > 64 || (numbXtalTSamples_ - 2) % 4) {
std::ostringstream output;
output << "\n Unsuported number of xtal time samples : " << numbXtalTSamples_
<< "\n Valid Number of xtal time samples are : 6,10,14,18,...,62";
edm::LogError("IncorrectConfiguration") << output.str();
// todo : throw an execption
}
if (numbTriggerTSamples_ != 1 && numbTriggerTSamples_ != 4 && numbTriggerTSamples_ != 8) {
std::ostringstream output;
output << "\n Unsuported number of trigger time samples : " << numbTriggerTSamples_
<< "\n Valid number of trigger time samples are : 1, 4 or 8";
edm::LogError("IncorrectConfiguration") << output.str();
// todo : throw an execption
}
//NA : testing
//nevts_=0;
//RUNNING_TIME_=0;
// if there are FEDs specified to unpack fill the vector of the fedUnpackList_
// else fill with the entire ECAL fed range (600-670)
if (fedUnpackList_.empty())
for (int i = FEDNumbering::MINECALFEDID; i <= FEDNumbering::MAXECALFEDID; i++)
fedUnpackList_.push_back(i);
//print the FEDs to unpack to the logger
std::ostringstream loggerOutput_;
if (!fedUnpackList_.empty()) {
for (unsigned int i = 0; i < fedUnpackList_.size(); i++)
loggerOutput_ << fedUnpackList_[i] << " ";
edm::LogInfo("EcalRawToDigi") << "EcalRawToDigi will unpack FEDs ( " << loggerOutput_.str() << ")";
LogDebug("EcalRawToDigi") << "EcalRawToDigi will unpack FEDs ( " << loggerOutput_.str() << ")";
}
edm::LogInfo("EcalRawToDigi") << "\n ECAL RawToDigi configuration:"
<< "\n Header unpacking is " << headerUnpacking_ << "\n SRP Bl. unpacking is "
<< srpUnpacking_ << "\n TCC Bl. unpacking is " << tccUnpacking_
<< "\n FE Bl. unpacking is " << feUnpacking_ << "\n MEM Bl. unpacking is "
<< memUnpacking_ << "\n sync check is " << syncCheck_ << "\n feID check is "
<< feIdCheck_ << "\n force keep FR data is " << forceToKeepFRdata_ << "\n";
edm::InputTag dataLabel = conf.getParameter<edm::InputTag>("InputLabel");
edm::InputTag fedsLabel = conf.getParameter<edm::InputTag>("FedLabel");
// Producer products
if (headerUnpacking_) {
produces<EcalRawDataCollection>();
}
if (feUnpacking_) {
produces<EBDigiCollection>("ebDigis");
produces<EEDigiCollection>("eeDigis");
// Integrity for xtal data
produces<EBDetIdCollection>("EcalIntegrityGainErrors");
produces<EBDetIdCollection>("EcalIntegrityGainSwitchErrors");
produces<EBDetIdCollection>("EcalIntegrityChIdErrors");
// Integrity for xtal data - EE specific (to be rivisited towards EB+EE common collection)
produces<EEDetIdCollection>("EcalIntegrityGainErrors");
produces<EEDetIdCollection>("EcalIntegrityGainSwitchErrors");
produces<EEDetIdCollection>("EcalIntegrityChIdErrors");
// Integrity Errors
produces<EcalElectronicsIdCollection>("EcalIntegrityTTIdErrors");
produces<EcalElectronicsIdCollection>("EcalIntegrityZSXtalIdErrors");
produces<EcalElectronicsIdCollection>("EcalIntegrityBlockSizeErrors");
//
produces<EcalPnDiodeDigiCollection>();
}
if (srpUnpacking_) {
produces<EBSrFlagCollection>();
produces<EESrFlagCollection>();
}
if (tccUnpacking_) {
produces<EcalTrigPrimDigiCollection>("EcalTriggerPrimitives");
produces<EcalPSInputDigiCollection>("EcalPseudoStripInputs");
}
// Mem channels' integrity
if (memUnpacking_) {
produces<EcalElectronicsIdCollection>("EcalIntegrityMemTtIdErrors");
produces<EcalElectronicsIdCollection>("EcalIntegrityMemBlockSizeErrors");
produces<EcalElectronicsIdCollection>("EcalIntegrityMemChIdErrors");
produces<EcalElectronicsIdCollection>("EcalIntegrityMemGainErrors");
}
dataToken_ = consumes<FEDRawDataCollection>(dataLabel);
if (REGIONAL_) {
fedsToken_ = consumes<EcalListOfFEDS>(fedsLabel);
}
chStatusToken_ = esConsumes<EcalChannelStatusMap, EcalChannelStatusRcd, edm::Transition::BeginRun>();
ecalMappingToken_ = esConsumes<EcalElectronicsMapping, EcalMappingRcd>();
// Build a new Electronics mapper and parse default map file
myMap_ = new EcalElectronicsMapper(numbXtalTSamples_, numbTriggerTSamples_);
// in case of external tsext file (deprecated by HLT environment)
// bool readResult = myMap_->readDCCMapFile(conf.getParameter<std::string>("DCCMapFile",""));
// use two arrays from cfg to establish DCCId:FedId. If they are empy, than use hard coded correspondence
bool readResult = myMap_->makeMapFromVectors(orderedFedUnpackList_, orderedDCCIdList_);
// myMap::makeMapFromVectors() returns "true" always
// need to be fixed?
if (!readResult) {
edm::LogWarning("IncorrectConfiguration") << "Arrays orderedFedList and orderedDCCIdList are emply. "
"Hard coded correspondence for DCCId:FedId will be used.";
// edm::LogError("EcalRawToDigi")<<"\n unable to read file : "
// <<conf.getParameter<std::string>("DCCMapFile");
}
// Build a new ECAL DCC data unpacker
theUnpacker_ = new DCCDataUnpacker(myMap_,
headerUnpacking_,
srpUnpacking_,
tccUnpacking_,
feUnpacking_,
memUnpacking_,
syncCheck_,
feIdCheck_,
forceToKeepFRdata_);
}
// print list of crystals with non-zero statuses
// this functions is only for debug purposes
void printStatusRecords(const DCCDataUnpacker* unpacker, const EcalElectronicsMapping* mapping) {
// Endcap
std::cout << "===> ENDCAP" << std::endl;
for (int i = 0; i < EEDetId::kSizeForDenseIndexing; ++i) {
const EEDetId id = EEDetId::unhashIndex(i);
if (!id.null()) {
// channel status
const uint16_t code = unpacker->getChannelValue(id);
if (code) {
const EcalElectronicsId ei = mapping->getElectronicsId(id);
// convert DCC ID (1 - 54) to FED ID (601 - 654)
const int fed_id = unpacker->electronicsMapper()->getDCCId(ei.dccId());
std::cout << " id " << id.rawId() << " -> (" << id.ix() << ", " << id.iy() << ", " << id.zside() << ") "
<< "(" << ei.dccId() << " : " << fed_id << ", " << ei.towerId() << ", " << ei.stripId() << ", "
<< ei.xtalId() << ") "
<< "status = " << code << std::endl;
}
}
}
std::cout << "<=== ENDCAP" << std::endl;
std::cout << "===> BARREL" << std::endl;
for (int i = 0; i < EBDetId::kSizeForDenseIndexing; ++i) {
const EBDetId id = EBDetId::unhashIndex(i);
if (!id.null()) {
// channel status
const uint16_t code = unpacker->getChannelValue(id);
if (code) {
const EcalElectronicsId ei = mapping->getElectronicsId(id);
// convert DCC ID (1 - 54) to FED ID (601 - 654)
const int fed_id = unpacker->electronicsMapper()->getDCCId(ei.dccId());
std::cout << " id " << id.rawId() << " -> (" << id.ieta() << ", " << id.iphi() << ", " << id.zside() << ") "
<< "(" << ei.dccId() << " : " << fed_id << ", " << ei.towerId() << ", " << ei.stripId() << ", "
<< ei.xtalId() << ") "
<< "status = " << code << std::endl;
}
}
}
std::cout << "<=== BARREL" << std::endl;
}
void EcalRawToDigi::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<bool>("tccUnpacking", true);
desc.add<edm::InputTag>("FedLabel", edm::InputTag("listfeds"));
desc.add<bool>("srpUnpacking", true);
desc.add<bool>("syncCheck", true);
desc.add<bool>("feIdCheck", true);
desc.addUntracked<bool>("silentMode", true);
desc.add<edm::InputTag>("InputLabel", edm::InputTag("rawDataCollector"));
{
std::vector<int> temp1;
unsigned int nvec = 54;
temp1.reserve(nvec);
for (unsigned int i = 0; i < nvec; i++)
temp1.push_back(601 + i);
desc.add<std::vector<int> >("orderedFedList", temp1);
}
desc.add<bool>("eventPut", true);
desc.add<int>("numbTriggerTSamples", 1);
desc.add<int>("numbXtalTSamples", 10);
{
std::vector<int> temp1;
unsigned int nvec = 54;
temp1.reserve(nvec);
for (unsigned int i = 0; i < nvec; i++)
temp1.push_back(1 + i);
desc.add<std::vector<int> >("orderedDCCIdList", temp1);
}
{
std::vector<int> temp1;
unsigned int nvec = 54;
temp1.reserve(nvec);
for (unsigned int i = 0; i < nvec; i++)
temp1.push_back(601 + i);
desc.add<std::vector<int> >("FEDs", temp1);
}
desc.add<bool>("DoRegional", false);
desc.add<bool>("feUnpacking", true);
desc.add<bool>("forceToKeepFRData", false);
desc.add<bool>("headerUnpacking", true);
desc.add<bool>("memUnpacking", true);
descriptions.add("ecalRawToDigi", desc);
}
void EcalRawToDigi::beginRun(const edm::Run&, const edm::EventSetup& es) {
// channel status database
edm::ESHandle<EcalChannelStatusMap> pChStatus = es.getHandle(chStatusToken_);
theUnpacker_->setChannelStatusDB(pChStatus.product());
// uncomment following line to print list of crystals with bad status
//edm::ESHandle<EcalElectronicsMapping> pEcalMapping;
//es.get<EcalMappingRcd>().get(pEcalMapping);
//const EcalElectronicsMapping* mapping = pEcalMapping.product();
//printStatusRecords(theUnpacker_, mapping);
}
void EcalRawToDigi::produce(edm::Event& e, const edm::EventSetup& es) {
//double TIME_START = clock();
//nevts_++; //NUNO
if (first_) {
watcher_.check(es);
edm::ESHandle<EcalElectronicsMapping> ecalmapping = es.getHandle(ecalMappingToken_);
myMap_->setEcalElectronicsMapping(ecalmapping.product());
first_ = false;
} else {
if (watcher_.check(es)) {
edm::ESHandle<EcalElectronicsMapping> ecalmapping = es.getHandle(ecalMappingToken_);
myMap_->deletePointers();
myMap_->resetPointers();
myMap_->setEcalElectronicsMapping(ecalmapping.product());
}
}
// Get list of FEDS :
std::vector<int> FEDS_to_unpack;
if (REGIONAL_) {
edm::Handle<EcalListOfFEDS> listoffeds;
e.getByToken(fedsToken_, listoffeds);
FEDS_to_unpack = listoffeds->GetList();
}
// Step A: Get Inputs
edm::Handle<FEDRawDataCollection> rawdata;
e.getByToken(dataToken_, rawdata);
// Step B: encapsulate vectors in actual collections and set unpacker pointers
// create the collection of Ecal Digis
auto productDigisEB = std::make_unique<EBDigiCollection>();
productDigisEB->reserve(1700);
theUnpacker_->setEBDigisCollection(&productDigisEB);
// create the collection of Ecal Digis
auto productDigisEE = std::make_unique<EEDigiCollection>();
theUnpacker_->setEEDigisCollection(&productDigisEE);
// create the collection for headers
auto productDccHeaders = std::make_unique<EcalRawDataCollection>();
theUnpacker_->setDccHeadersCollection(&productDccHeaders);
// create the collection for invalid gains
auto productInvalidGains = std::make_unique<EBDetIdCollection>();
theUnpacker_->setInvalidGainsCollection(&productInvalidGains);
// create the collection for invalid gain Switch
auto productInvalidGainsSwitch = std::make_unique<EBDetIdCollection>();
theUnpacker_->setInvalidGainsSwitchCollection(&productInvalidGainsSwitch);
// create the collection for invalid chids
auto productInvalidChIds = std::make_unique<EBDetIdCollection>();
theUnpacker_->setInvalidChIdsCollection(&productInvalidChIds);
///////////////// make EEDetIdCollections for these ones
// create the collection for invalid gains
auto productInvalidEEGains = std::make_unique<EEDetIdCollection>();
theUnpacker_->setInvalidEEGainsCollection(&productInvalidEEGains);
// create the collection for invalid gain Switch
auto productInvalidEEGainsSwitch = std::make_unique<EEDetIdCollection>();
theUnpacker_->setInvalidEEGainsSwitchCollection(&productInvalidEEGainsSwitch);
// create the collection for invalid chids
auto productInvalidEEChIds = std::make_unique<EEDetIdCollection>();
theUnpacker_->setInvalidEEChIdsCollection(&productInvalidEEChIds);
///////////////// make EEDetIdCollections for these ones
// create the collection for EB srflags
auto productEBSrFlags = std::make_unique<EBSrFlagCollection>();
theUnpacker_->setEBSrFlagsCollection(&productEBSrFlags);
// create the collection for EB srflags
auto productEESrFlags = std::make_unique<EESrFlagCollection>();
theUnpacker_->setEESrFlagsCollection(&productEESrFlags);
// create the collection for ecal trigger primitives
auto productEcalTps = std::make_unique<EcalTrigPrimDigiCollection>();
theUnpacker_->setEcalTpsCollection(&productEcalTps);
/////////////////////// collections for problems pertaining towers are already EE+EB communal
// create the collection for ecal trigger primitives
auto productEcalPSs = std::make_unique<EcalPSInputDigiCollection>();
theUnpacker_->setEcalPSsCollection(&productEcalPSs);
/////////////////////// collections for problems pertaining towers are already EE+EB communal
// create the collection for invalid TTIds
auto productInvalidTTIds = std::make_unique<EcalElectronicsIdCollection>();
theUnpacker_->setInvalidTTIdsCollection(&productInvalidTTIds);
// create the collection for invalid TTIds
auto productInvalidZSXtalIds = std::make_unique<EcalElectronicsIdCollection>();
theUnpacker_->setInvalidZSXtalIdsCollection(&productInvalidZSXtalIds);
// create the collection for invalid BlockLengths
auto productInvalidBlockLengths = std::make_unique<EcalElectronicsIdCollection>();
theUnpacker_->setInvalidBlockLengthsCollection(&productInvalidBlockLengths);
// MEMs Collections
// create the collection for the Pn Diode Digis
auto productPnDiodeDigis = std::make_unique<EcalPnDiodeDigiCollection>();
theUnpacker_->setPnDiodeDigisCollection(&productPnDiodeDigis);
// create the collection for invalid Mem Tt id
auto productInvalidMemTtIds = std::make_unique<EcalElectronicsIdCollection>();
theUnpacker_->setInvalidMemTtIdsCollection(&productInvalidMemTtIds);
// create the collection for invalid Mem Block Size
auto productInvalidMemBlockSizes = std::make_unique<EcalElectronicsIdCollection>();
theUnpacker_->setInvalidMemBlockSizesCollection(&productInvalidMemBlockSizes);
// create the collection for invalid Mem Block Size
auto productInvalidMemChIds = std::make_unique<EcalElectronicsIdCollection>();
theUnpacker_->setInvalidMemChIdsCollection(&productInvalidMemChIds);
// create the collection for invalid Mem Gain Errors
auto productInvalidMemGains = std::make_unique<EcalElectronicsIdCollection>();
theUnpacker_->setInvalidMemGainsCollection(&productInvalidMemGains);
// double TIME_START = clock();
// Step C: unpack all requested FEDs
for (std::vector<int>::const_iterator i = fedUnpackList_.begin(); i != fedUnpackList_.end(); i++) {
if (REGIONAL_) {
std::vector<int>::const_iterator fed_it = find(FEDS_to_unpack.begin(), FEDS_to_unpack.end(), *i);
if (fed_it == FEDS_to_unpack.end())
continue;
}
// get fed raw data and SM id
const FEDRawData& fedData = rawdata->FEDData(*i);
const size_t length = fedData.size();
LogDebug("EcalRawToDigi") << "raw data length: " << length;
//if data size is not null interpret data
if (length >= EMPTYEVENTSIZE) {
if (myMap_->setActiveDCC(*i)) {
const int smId = myMap_->getActiveSM();
LogDebug("EcalRawToDigi") << "Getting FED = " << *i << "(SM = " << smId << ")"
<< " data size is: " << length;
const uint64_t* data = (uint64_t*)fedData.data();
theUnpacker_->unpack(data, length, smId, *i);
LogDebug("EcalRawToDigi") << " in EE :" << productDigisEE->size() << " in EB :" << productDigisEB->size();
}
}
} // loop on FEDs
//if(nevts_>1){ //NUNO
// double TIME_END = clock(); //NUNO
// RUNNING_TIME_ += TIME_END-TIME_START; //NUNO
// }
// Add collections to the event
if (put_) {
if (headerUnpacking_) {
e.put(std::move(productDccHeaders));
}
if (feUnpacking_) {
productDigisEB->sort();
e.put(std::move(productDigisEB), "ebDigis");
productDigisEE->sort();
e.put(std::move(productDigisEE), "eeDigis");
e.put(std::move(productInvalidGains), "EcalIntegrityGainErrors");
e.put(std::move(productInvalidGainsSwitch), "EcalIntegrityGainSwitchErrors");
e.put(std::move(productInvalidChIds), "EcalIntegrityChIdErrors");
// EE (leaving for now the same names as in EB)
e.put(std::move(productInvalidEEGains), "EcalIntegrityGainErrors");
e.put(std::move(productInvalidEEGainsSwitch), "EcalIntegrityGainSwitchErrors");
e.put(std::move(productInvalidEEChIds), "EcalIntegrityChIdErrors");
// EE
e.put(std::move(productInvalidTTIds), "EcalIntegrityTTIdErrors");
e.put(std::move(productInvalidZSXtalIds), "EcalIntegrityZSXtalIdErrors");
e.put(std::move(productInvalidBlockLengths), "EcalIntegrityBlockSizeErrors");
e.put(std::move(productPnDiodeDigis));
}
if (memUnpacking_) {
e.put(std::move(productInvalidMemTtIds), "EcalIntegrityMemTtIdErrors");
e.put(std::move(productInvalidMemBlockSizes), "EcalIntegrityMemBlockSizeErrors");
e.put(std::move(productInvalidMemChIds), "EcalIntegrityMemChIdErrors");
e.put(std::move(productInvalidMemGains), "EcalIntegrityMemGainErrors");
}
if (srpUnpacking_) {
e.put(std::move(productEBSrFlags));
e.put(std::move(productEESrFlags));
}
if (tccUnpacking_) {
e.put(std::move(productEcalTps), "EcalTriggerPrimitives");
e.put(std::move(productEcalPSs), "EcalPseudoStripInputs");
}
}
//if(nevts_>1){ //NUNO
// double TIME_END = clock(); //NUNO
// RUNNING_TIME_ += TIME_END-TIME_START; //NUNO
//}
}
EcalRawToDigi::~EcalRawToDigi() {
//cout << "EcalDCCUnpackingModule " << "N events " << (nevts_-1)<<endl;
//cout << "EcalDCCUnpackingModule " << " --- SETUP time " << endl;
//cout << "EcalDCCUnpackingModule " << "Time (sys) " << SETUP_TIME_ << endl;
//cout << "EcalDCCUnpackingModule " << "Time in sec. " << SETUP_TIME_/ CLOCKS_PER_SEC << endl;
//cout << "EcalDCCUnpackingModule " << " --- Per event " << endl;
//RUNNING_TIME_ = RUNNING_TIME_ / (nevts_-1);
//cout << "EcalDCCUnpackingModule "<< "Time (sys) " << RUNNING_TIME_ << endl;
//cout << "EcalDCCUnpackingModule "<< "Time in sec. " << RUNNING_TIME_ / CLOCKS_PER_SEC << endl;
if (myMap_)
delete myMap_;
if (theUnpacker_)
delete theUnpacker_;
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(EcalRawToDigi);
|