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