CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
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  std::auto_ptr<EBDigiCollection> productEb(new EBDigiCollection);
101 
102  // create the collection of Matacq Digi
103  std::auto_ptr<EcalMatacqDigiCollection> productMatacq(new EcalMatacqDigiCollection());
104 
105  // create the collection of Ecal PN's
106  std::auto_ptr<EcalPnDiodeDigiCollection> productPN(new EcalPnDiodeDigiCollection);
107 
108  //create the collection of Ecal DCC Header
109  std::auto_ptr<EcalRawDataCollection> productDCCHeader(new EcalRawDataCollection);
110 
111  // create the collection with trigger primitives, bits and flags
112  std::auto_ptr<EcalTrigPrimDigiCollection> productTriggerPrimitives(new EcalTrigPrimDigiCollection);
113 
114  // create the collection of Ecal Integrity DCC Size
115  std::auto_ptr<EBDetIdCollection> productDCCSize(new EBDetIdCollection);
116 
117  // create the collection of Ecal Integrity TT Id
118  std::auto_ptr<EcalElectronicsIdCollection> productTTId(new EcalElectronicsIdCollection);
119 
120  // create the collection of Ecal Integrity TT Block Size
121  std::auto_ptr<EcalElectronicsIdCollection> productBlockSize(new EcalElectronicsIdCollection);
122 
123  // create the collection of Ecal Integrity Ch Id
124  std::auto_ptr<EBDetIdCollection> productChId(new EBDetIdCollection);
125 
126  // create the collection of Ecal Integrity Gain
127  std::auto_ptr<EBDetIdCollection> productGain(new EBDetIdCollection);
128 
129  // create the collection of Ecal Integrity Gain Switch
130  std::auto_ptr<EBDetIdCollection> productGainSwitch(new EBDetIdCollection);
131 
132  // create the collection of Ecal Integrity Mem towerBlock_id errors
133  std::auto_ptr<EcalElectronicsIdCollection> productMemTtId(new EcalElectronicsIdCollection);
134 
135  // create the collection of Ecal Integrity Mem gain errors
136  std::auto_ptr< EcalElectronicsIdCollection> productMemBlockSize(new EcalElectronicsIdCollection);
137 
138  // create the collection of Ecal Integrity Mem gain errors
139  std::auto_ptr< EcalElectronicsIdCollection> productMemGain(new EcalElectronicsIdCollection);
140 
141  // create the collection of Ecal Integrity Mem ch_id errors
142  std::auto_ptr<EcalElectronicsIdCollection> productMemChIdErrors(new EcalElectronicsIdCollection);
143 
144  // create the collection of TB specifics data
145  std::auto_ptr<EcalTBHodoscopeRawInfo> productHodo(new EcalTBHodoscopeRawInfo());
146  std::auto_ptr<EcalTBTDCRawInfo> productTdc(new EcalTBTDCRawInfo());
147  std::auto_ptr<EcalTBEventHeader> productHeader(new 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(productPN);
209  e.put(productEb,"ebDigis");
210  e.put(productMatacq);
211  e.put(productDCCHeader);
212  e.put(productTriggerPrimitives,"EBTT");
213 
214  e.put(productDCCSize,"EcalIntegrityDCCSizeErrors");
215  e.put(productTTId,"EcalIntegrityTTIdErrors");
216  e.put(productBlockSize,"EcalIntegrityBlockSizeErrors");
217  e.put(productChId,"EcalIntegrityChIdErrors");
218  e.put(productGain,"EcalIntegrityGainErrors");
219  e.put(productGainSwitch,"EcalIntegrityGainSwitchErrors");
220 
221  e.put(productMemTtId,"EcalIntegrityMemTtIdErrors");
222  e.put(productMemBlockSize,"EcalIntegrityMemBlockSize");
223  e.put(productMemChIdErrors,"EcalIntegrityMemChIdErrors");
224  e.put(productMemGain,"EcalIntegrityMemGainErrors");
225 
226  e.put(productHodo);
227  e.put(productTdc);
228  e.put(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
edm::SortedCollection< EcalMatacqDigi > EcalMatacqDigiCollection
#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
void interpretRawData(const FEDRawData &data, EcalMatacqDigiCollection &matacqDigiCollection)
EcalDCCTBUnpackingModule(const edm::ParameterSet &pset)
Constructor.
TableDataFormatter * tableFormatter_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
EcalSupervisorTBDataFormatter * ecalSupervisorFormatter_
virtual ~EcalDCCTBUnpackingModule()
Destructor.
EcalTBDaqFormatter * formatter_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:420
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:82
const char * what() const
tuple cout
Definition: gather_cfg.py:121
dictionary rawdata
Definition: lumiPlot.py:393
#define ECAL_SUPERVISOR_FED_ID
#define TBCAMAC_FED_ID
#define END_DCC_FED_ID_GLOBAL
#define BEG_DCC_FED_ID
void interpretRawData(const FEDRawData &data, EcalTBEventHeader &tbEventHeader, EcalTBHodoscopeRawInfo &hodoRaw, EcalTBTDCRawInfo &tdcRawInfo)