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