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