CMS 3D CMS Logo

EcalDCCUnpackingModule.cc
Go to the documentation of this file.
1 /* \file EcalDCCUnpackingModule.h
2  *
3  * \author N. Marinelli
4  * \author G. Della Ricca
5  * \author G. Franzoni
6  * \author A. Ghezzi
7  */
8 
25 
26 #include <iostream>
27 #include <iomanip>
28 
29 // in full CMS this range cannot be used (allocated to pixel, see DataFormats/ FEDRawData/ src/ FEDNumbering.cc)
30 #define BEG_DCC_FED_ID 0
31 #define END_DCC_FED_ID 35
32 #define BEG_DCC_FED_ID_GLOBAL 600
33 #define END_DCC_FED_ID_GLOBAL 670
34 
35 #define ECAL_SUPERVISOR_FED_ID 40
36 #define TBCAMAC_FED_ID 41
37 #define TABLE_FED_ID 42
38 #define MATACQ_FED_ID 43
39 
41  : fedRawDataCollectionTag_(pset.getParameter<edm::InputTag>("fedRawDataCollectionTag")) {
47 
48  // digis
49  produces<EBDigiCollection>("ebDigis");
50  produces<EcalMatacqDigiCollection>();
51  produces<EcalPnDiodeDigiCollection>();
52  produces<EcalRawDataCollection>();
53  produces<EcalTrigPrimDigiCollection>("EBTT");
54 
55  //TB specifics data
56  produces<EcalTBHodoscopeRawInfo>();
57  produces<EcalTBTDCRawInfo>();
58  produces<EcalTBEventHeader>();
59 
60  // crystals' integrity
61  produces<EBDetIdCollection>("EcalIntegrityDCCSizeErrors");
62  produces<EcalElectronicsIdCollection>("EcalIntegrityTTIdErrors");
63  produces<EcalElectronicsIdCollection>("EcalIntegrityBlockSizeErrors");
64  produces<EBDetIdCollection>("EcalIntegrityChIdErrors");
65  produces<EBDetIdCollection>("EcalIntegrityGainErrors");
66  produces<EBDetIdCollection>("EcalIntegrityGainSwitchErrors");
67 
68  // mem channels' integrity
69  produces<EcalElectronicsIdCollection>("EcalIntegrityMemTtIdErrors");
70  produces<EcalElectronicsIdCollection>("EcalIntegrityMemBlockSize");
71  produces<EcalElectronicsIdCollection>("EcalIntegrityMemChIdErrors");
72  produces<EcalElectronicsIdCollection>("EcalIntegrityMemGainErrors");
73 }
74 
76 
79  e.getByLabel(fedRawDataCollectionTag_, rawdata);
80 
81  // create the collection of Ecal Digis
82  auto productEb = std::make_unique<EBDigiCollection>();
83 
84  // create the collection of Matacq Digi
85  auto productMatacq = std::make_unique<EcalMatacqDigiCollection>();
86 
87  // create the collection of Ecal PN's
88  auto productPN = std::make_unique<EcalPnDiodeDigiCollection>();
89 
90  //create the collection of Ecal DCC Header
91  auto productDCCHeader = std::make_unique<EcalRawDataCollection>();
92 
93  // create the collection with trigger primitives, bits and flags
94  auto productTriggerPrimitives = std::make_unique<EcalTrigPrimDigiCollection>();
95 
96  // create the collection of Ecal Integrity DCC Size
97  auto productDCCSize = std::make_unique<EBDetIdCollection>();
98 
99  // create the collection of Ecal Integrity TT Id
100  auto productTTId = std::make_unique<EcalElectronicsIdCollection>();
101 
102  // create the collection of Ecal Integrity TT Block Size
103  auto productBlockSize = std::make_unique<EcalElectronicsIdCollection>();
104 
105  // create the collection of Ecal Integrity Ch Id
106  auto productChId = std::make_unique<EBDetIdCollection>();
107 
108  // create the collection of Ecal Integrity Gain
109  auto productGain = std::make_unique<EBDetIdCollection>();
110 
111  // create the collection of Ecal Integrity Gain Switch
112  auto productGainSwitch = std::make_unique<EBDetIdCollection>();
113 
114  // create the collection of Ecal Integrity Mem towerBlock_id errors
115  auto productMemTtId = std::make_unique<EcalElectronicsIdCollection>();
116 
117  // create the collection of Ecal Integrity Mem gain errors
118  auto productMemBlockSize = std::make_unique<EcalElectronicsIdCollection>();
119 
120  // create the collection of Ecal Integrity Mem gain errors
121  auto productMemGain = std::make_unique<EcalElectronicsIdCollection>();
122 
123  // create the collection of Ecal Integrity Mem ch_id errors
124  auto productMemChIdErrors = std::make_unique<EcalElectronicsIdCollection>();
125 
126  // create the collection of TB specifics data
127  auto productHodo = std::make_unique<EcalTBHodoscopeRawInfo>();
128  auto productTdc = std::make_unique<EcalTBTDCRawInfo>();
129  auto productHeader = std::make_unique<EcalTBEventHeader>();
130 
131  try {
132  for (int id = 0; id <= FEDNumbering::MAXFEDID; ++id) {
133  // edm::LogInfo("EcalDCCTBUnpackingModule") << "EcalDCCTBUnpackingModule::Got FED ID "<< id <<" ";
134  const FEDRawData& data = rawdata->FEDData(id);
135  // edm::LogInfo("EcalDCCTBUnpackingModule") << " Fed data size " << data.size() ;
136 
137  //std::cout <<"1 Fed id: "<<dec<<id<< " Fed data size: " <<data.size() << std::endl;
138  // const unsigned char * pData = data.data();
139  // int length = data.size();
140  // if(length >0 ){
141  // if(length >= 40){length = 40;}
142  // std::cout<<"##############################################################"<<std::endl;
143  // for( int i=0; i<length; i++ ) {
144  // std::cout << std::hex << std::setw(8) << int(pData[i]) << " ";
145  // if( (i+1)%8 == 0 ) std::cout << std::endl;
146  // }
147  // std::cout<<"##############################################################"<<std::endl;
148  // }
149  if (data.size() > 16) {
150  if ((id >= BEG_DCC_FED_ID && id <= END_DCC_FED_ID) ||
151  (id >= BEG_DCC_FED_ID_GLOBAL &&
152  id <= END_DCC_FED_ID_GLOBAL)) { // do the DCC data unpacking and fill the collections
153 
154  (*productHeader).setSmInBeam(id);
156  *productEb,
157  *productPN,
158  *productDCCHeader,
159  *productDCCSize,
160  *productTTId,
161  *productBlockSize,
162  *productChId,
163  *productGain,
164  *productGainSwitch,
165  *productMemTtId,
166  *productMemBlockSize,
167  *productMemGain,
168  *productMemChIdErrors,
169  *productTriggerPrimitives);
170  int runType = (*productDCCHeader)[0].getRunType();
172  (*productHeader).setTriggerMask(0x1);
173  else if (runType == 4 || runType == 5 || runType == 6) //laser runs
174  (*productHeader).setTriggerMask(0x2000);
175  else if (runType == 9 || runType == 10 || runType == 11) //pedestal runs
176  (*productHeader).setTriggerMask(0x800);
177  LogDebug("EcalDCCTBUnpackingModule")
178  << "Event type is " << (*productHeader).eventType() << " dbEventType " << (*productHeader).dbEventType();
179  } else if (id == ECAL_SUPERVISOR_FED_ID)
181  else if (id == TBCAMAC_FED_ID)
182  camacTBformatter_->interpretRawData(data, *productHeader, *productHodo, *productTdc);
183  else if (id == TABLE_FED_ID)
184  tableFormatter_->interpretRawData(data, *productHeader);
185  else if (id == MATACQ_FED_ID)
186  matacqFormatter_->interpretRawData(data, *productMatacq);
187  } // endif
188  } //endfor
189 
190  // commit to the event
191  e.put(std::move(productPN));
192  e.put(std::move(productEb), "ebDigis");
193  e.put(std::move(productMatacq));
194  e.put(std::move(productDCCHeader));
195  e.put(std::move(productTriggerPrimitives), "EBTT");
196 
197  e.put(std::move(productDCCSize), "EcalIntegrityDCCSizeErrors");
198  e.put(std::move(productTTId), "EcalIntegrityTTIdErrors");
199  e.put(std::move(productBlockSize), "EcalIntegrityBlockSizeErrors");
200  e.put(std::move(productChId), "EcalIntegrityChIdErrors");
201  e.put(std::move(productGain), "EcalIntegrityGainErrors");
202  e.put(std::move(productGainSwitch), "EcalIntegrityGainSwitchErrors");
203 
204  e.put(std::move(productMemTtId), "EcalIntegrityMemTtIdErrors");
205  e.put(std::move(productMemBlockSize), "EcalIntegrityMemBlockSize");
206  e.put(std::move(productMemChIdErrors), "EcalIntegrityMemChIdErrors");
207  e.put(std::move(productMemGain), "EcalIntegrityMemGainErrors");
208 
209  e.put(std::move(productHodo));
210  e.put(std::move(productTdc));
211  e.put(std::move(productHeader));
212 
213  } catch (ECALTBParserException& e) {
214  std::cout << "[EcalDCCTBUnpackingModule] " << e.what() << std::endl;
215  } catch (ECALTBParserBlockException& e) {
216  std::cout << "[EcalDCCTBUnpackingModule] " << e.what() << std::endl;
217  } catch (cms::Exception& e) {
218  std::cout << "[EcalDCCTBUnpackingModule] " << e.what() << std::endl;
219  } catch (...) {
220  std::cout << "[EcalDCCTBUnpackingModule] Unknown exception ..." << std::endl;
221  }
222 }
void produce(edm::Event &e, const edm::EventSetup &c) override
Produce digis out of raw data.
~EcalDCCTBUnpackingModule() override
Destructor.
#define TABLE_FED_ID
void interpretRawData(const FEDRawData &data, EBDigiCollection &digicollection, EcalPnDiodeDigiCollection &pndigicollection, EcalRawDataCollection &DCCheaderCollection, EBDetIdCollection &dccsizecollection, EcalElectronicsIdCollection &ttidcollection, EcalElectronicsIdCollection &blocksizecollection, EBDetIdCollection &chidcollection, EBDetIdCollection &gaincollection, EBDetIdCollection &gainswitchcollection, EcalElectronicsIdCollection &memttidcollection, EcalElectronicsIdCollection &memblocksizecollection, EcalElectronicsIdCollection &memgaincollection, EcalElectronicsIdCollection &memchidcollection, EcalTrigPrimDigiCollection &tpcollection)
MatacqTBDataFormatter * matacqFormatter_
#define MATACQ_FED_ID
#define END_DCC_FED_ID
void interpretRawData(const FEDRawData &data, EcalMatacqDigiCollection &matacqDigiCollection)
EcalDCCTBUnpackingModule(const edm::ParameterSet &pset)
Constructor.
TableDataFormatter * tableFormatter_
EcalSupervisorTBDataFormatter * ecalSupervisorFormatter_
EcalTBDaqFormatter * formatter_
void interpretRawData(const FEDRawData &data, EcalTBEventHeader &tbEventHeader)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void interpretRawData(const FEDRawData &data, EcalTBEventHeader &tbEventHeader)
#define BEG_DCC_FED_ID_GLOBAL
CamacTBDataFormatter * camacTBformatter_
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
#define ECAL_SUPERVISOR_FED_ID
#define TBCAMAC_FED_ID
def move(src, dest)
Definition: eostools.py:511
#define END_DCC_FED_ID_GLOBAL
#define BEG_DCC_FED_ID
#define LogDebug(id)
void interpretRawData(const FEDRawData &data, EcalTBEventHeader &tbEventHeader, EcalTBHodoscopeRawInfo &hodoRaw, EcalTBTDCRawInfo &tdcRawInfo)