CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
78 
80 
84 
85  // create the collection of Ecal Digis
86  auto productEb = std::make_unique<EBDigiCollection>();
87 
88  // create the collection of Matacq Digi
89  auto productMatacq = std::make_unique<EcalMatacqDigiCollection>();
90 
91  // create the collection of Ecal PN's
92  auto productPN = std::make_unique<EcalPnDiodeDigiCollection>();
93 
94  //create the collection of Ecal DCC Header
95  auto productDCCHeader = std::make_unique<EcalRawDataCollection>();
96 
97  // create the collection with trigger primitives, bits and flags
98  auto productTriggerPrimitives = std::make_unique<EcalTrigPrimDigiCollection>();
99 
100  // create the collection of Ecal Integrity DCC Size
101  auto productDCCSize = std::make_unique<EBDetIdCollection>();
102 
103  // create the collection of Ecal Integrity TT Id
104  auto productTTId = std::make_unique<EcalElectronicsIdCollection>();
105 
106  // create the collection of Ecal Integrity TT Block Size
107  auto productBlockSize = std::make_unique<EcalElectronicsIdCollection>();
108 
109  // create the collection of Ecal Integrity Ch Id
110  auto productChId = std::make_unique<EBDetIdCollection>();
111 
112  // create the collection of Ecal Integrity Gain
113  auto productGain = std::make_unique<EBDetIdCollection>();
114 
115  // create the collection of Ecal Integrity Gain Switch
116  auto productGainSwitch = std::make_unique<EBDetIdCollection>();
117 
118  // create the collection of Ecal Integrity Mem towerBlock_id errors
119  auto productMemTtId = std::make_unique<EcalElectronicsIdCollection>();
120 
121  // create the collection of Ecal Integrity Mem gain errors
122  auto productMemBlockSize = std::make_unique<EcalElectronicsIdCollection>();
123 
124  // create the collection of Ecal Integrity Mem gain errors
125  auto productMemGain = std::make_unique<EcalElectronicsIdCollection>();
126 
127  // create the collection of Ecal Integrity Mem ch_id errors
128  auto productMemChIdErrors = std::make_unique<EcalElectronicsIdCollection>();
129 
130  // create the collection of TB specifics data
131  auto productHodo = std::make_unique<EcalTBHodoscopeRawInfo>();
132  auto productTdc = std::make_unique<EcalTBTDCRawInfo>();
133  auto productHeader = std::make_unique<EcalTBEventHeader>();
134 
135  try {
136  for (int id = 0; id <= FEDNumbering::MAXFEDID; ++id) {
137  // edm::LogInfo("EcalDCCTBUnpackingModule") << "EcalDCCTBUnpackingModule::Got FED ID "<< id <<" ";
138  const FEDRawData& data = rawdata->FEDData(id);
139  // edm::LogInfo("EcalDCCTBUnpackingModule") << " Fed data size " << data.size() ;
140 
141  //std::cout <<"1 Fed id: "<<dec<<id<< " Fed data size: " <<data.size() << std::endl;
142  // const unsigned char * pData = data.data();
143  // int length = data.size();
144  // if(length >0 ){
145  // if(length >= 40){length = 40;}
146  // std::cout<<"##############################################################"<<std::endl;
147  // for( int i=0; i<length; i++ ) {
148  // std::cout << std::hex << std::setw(8) << int(pData[i]) << " ";
149  // if( (i+1)%8 == 0 ) std::cout << std::endl;
150  // }
151  // std::cout<<"##############################################################"<<std::endl;
152  // }
153  if (data.size() > 16) {
154  if ((id >= BEG_DCC_FED_ID && id <= END_DCC_FED_ID) ||
155  (id >= BEG_DCC_FED_ID_GLOBAL &&
156  id <= END_DCC_FED_ID_GLOBAL)) { // do the DCC data unpacking and fill the collections
157 
158  (*productHeader).setSmInBeam(id);
160  *productEb,
161  *productPN,
162  *productDCCHeader,
163  *productDCCSize,
164  *productTTId,
165  *productBlockSize,
166  *productChId,
167  *productGain,
168  *productGainSwitch,
169  *productMemTtId,
170  *productMemBlockSize,
171  *productMemGain,
172  *productMemChIdErrors,
173  *productTriggerPrimitives);
174  int runType = (*productDCCHeader)[0].getRunType();
175  if (runType == EcalDCCHeaderBlock::COSMIC || runType == EcalDCCHeaderBlock::BEAMH4)
176  (*productHeader).setTriggerMask(0x1);
177  else if (runType == 4 || runType == 5 || runType == 6) //laser runs
178  (*productHeader).setTriggerMask(0x2000);
179  else if (runType == 9 || runType == 10 || runType == 11) //pedestal runs
180  (*productHeader).setTriggerMask(0x800);
181  LogDebug("EcalDCCTBUnpackingModule")
182  << "Event type is " << (*productHeader).eventType() << " dbEventType " << (*productHeader).dbEventType();
183  } else if (id == ECAL_SUPERVISOR_FED_ID)
184  ecalSupervisorFormatter_->interpretRawData(data, *productHeader);
185  else if (id == TBCAMAC_FED_ID)
186  camacTBformatter_->interpretRawData(data, *productHeader, *productHodo, *productTdc);
187  else if (id == TABLE_FED_ID)
188  tableFormatter_->interpretRawData(data, *productHeader);
189  else if (id == MATACQ_FED_ID)
190  matacqFormatter_->interpretRawData(data, *productMatacq);
191  } // endif
192  } //endfor
193 
194  // commit to the event
195  e.put(std::move(productPN));
196  e.put(std::move(productEb), "ebDigis");
197  e.put(std::move(productMatacq));
198  e.put(std::move(productDCCHeader));
199  e.put(std::move(productTriggerPrimitives), "EBTT");
200 
201  e.put(std::move(productDCCSize), "EcalIntegrityDCCSizeErrors");
202  e.put(std::move(productTTId), "EcalIntegrityTTIdErrors");
203  e.put(std::move(productBlockSize), "EcalIntegrityBlockSizeErrors");
204  e.put(std::move(productChId), "EcalIntegrityChIdErrors");
205  e.put(std::move(productGain), "EcalIntegrityGainErrors");
206  e.put(std::move(productGainSwitch), "EcalIntegrityGainSwitchErrors");
207 
208  e.put(std::move(productMemTtId), "EcalIntegrityMemTtIdErrors");
209  e.put(std::move(productMemBlockSize), "EcalIntegrityMemBlockSize");
210  e.put(std::move(productMemChIdErrors), "EcalIntegrityMemChIdErrors");
211  e.put(std::move(productMemGain), "EcalIntegrityMemGainErrors");
212 
213  e.put(std::move(productHodo));
214  e.put(std::move(productTdc));
215  e.put(std::move(productHeader));
216 
217  } catch (ECALTBParserException& e) {
218  std::cout << "[EcalDCCTBUnpackingModule] " << e.what() << std::endl;
219  } catch (ECALTBParserBlockException& e) {
220  std::cout << "[EcalDCCTBUnpackingModule] " << e.what() << std::endl;
221  } catch (cms::Exception& e) {
222  std::cout << "[EcalDCCTBUnpackingModule] " << e.what() << std::endl;
223  } catch (...) {
224  std::cout << "[EcalDCCTBUnpackingModule] Unknown exception ..." << std::endl;
225  }
226 }
void produce(edm::Event &e, const edm::EventSetup &c) override
Produce digis out of raw data.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const edm::EventSetup & c
~EcalDCCTBUnpackingModule() override
Destructor.
uint16_t *__restrict__ id
#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)
tuple runType
Definition: runPedHist.py:37
MatacqTBDataFormatter * matacqFormatter_
#define MATACQ_FED_ID
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
#define END_DCC_FED_ID
void interpretRawData(const FEDRawData &data, EcalMatacqDigiCollection &matacqDigiCollection)
EcalDCCTBUnpackingModule(const edm::ParameterSet &pset)
Constructor.
TableDataFormatter * tableFormatter_
def move
Definition: eostools.py:511
char const * what() const noexceptoverride
Definition: Exception.cc:103
EcalSupervisorTBDataFormatter * ecalSupervisorFormatter_
EcalTBDaqFormatter * formatter_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:500
void interpretRawData(const FEDRawData &data, EcalTBEventHeader &tbEventHeader)
void interpretRawData(const FEDRawData &data, EcalTBEventHeader &tbEventHeader)
#define BEG_DCC_FED_ID_GLOBAL
CamacTBDataFormatter * camacTBformatter_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
const char * what() const
tuple cout
Definition: gather_cfg.py:144
#define ECAL_SUPERVISOR_FED_ID
#define TBCAMAC_FED_ID
#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)