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 #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 
83  e.getByLabel(fedRawDataCollectionTag_, rawdata);
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();
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)
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 }
TableDataFormatter.h
MatacqDataFormatter.h
FEDNumbering.h
TABLE_FED_ID
#define TABLE_FED_ID
Definition: EcalDCCUnpackingModule.cc:37
Handle.h
EcalSupervisorDataFormatter.h
MatacqTBDataFormatter::interpretRawData
void interpretRawData(const FEDRawData &data, EcalMatacqDigiCollection &matacqDigiCollection)
Definition: MatacqDataFormatter.cc:16
TBCAMAC_FED_ID
#define TBCAMAC_FED_ID
Definition: EcalDCCUnpackingModule.cc:36
ECALTBParserException
Definition: ECALParserException.h:10
BEG_DCC_FED_ID_GLOBAL
#define BEG_DCC_FED_ID_GLOBAL
Definition: EcalDCCUnpackingModule.cc:32
EcalDCCTBUnpackingModule::matacqFormatter_
MatacqTBDataFormatter * matacqFormatter_
Definition: EcalDCCUnpackingModule.h:46
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
EcalSupervisorTBDataFormatter
Definition: EcalSupervisorDataFormatter.h:14
ECAL_SUPERVISOR_FED_ID
#define ECAL_SUPERVISOR_FED_ID
Definition: EcalDCCUnpackingModule.cc:35
EcalTBDaqFormatter
Definition: EcalTBDaqFormatter.h:26
FEDNumbering::MAXFEDID
Definition: FEDNumbering.h:26
EcalDCCTBUnpackingModule::~EcalDCCTBUnpackingModule
~EcalDCCTBUnpackingModule() override
Destructor.
Definition: EcalDCCUnpackingModule.cc:75
FEDRawData.h
edm::Handle< FEDRawDataCollection >
FEDRawData
Definition: FEDRawData.h:19
ECALParserException.h
CamacTBDataFormatter::interpretRawData
void interpretRawData(const FEDRawData &data, EcalTBEventHeader &tbEventHeader, EcalTBHodoscopeRawInfo &hodoRaw, EcalTBTDCRawInfo &tdcRawInfo)
Definition: CamacTBDataFormatter.cc:162
EcalRawDataCollections.h
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
MATACQ_FED_ID
#define MATACQ_FED_ID
Definition: EcalDCCUnpackingModule.cc:38
ECALParserBlockException.h
EcalDCCTBUnpackingModule::beginJob
void beginJob() override
Definition: EcalDCCUnpackingModule.cc:77
EcalDigiCollections.h
TableDataFormatter::interpretRawData
void interpretRawData(const FEDRawData &data, EcalTBEventHeader &tbEventHeader)
Definition: TableDataFormatter.cc:7
CamacTBDataFormatter.h
EcalTBDaqFormatter.h
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
EcalDCCTBUnpackingModule::EcalDCCTBUnpackingModule
EcalDCCTBUnpackingModule(const edm::ParameterSet &pset)
Constructor.
Definition: EcalDCCUnpackingModule.cc:40
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
EcalDCCHeaderBlock::BEAMH4
Definition: EcalDCCHeaderBlock.h:23
FEDRawDataCollection.h
TableDataFormatter
Definition: TableDataFormatter.h:13
edm::EventSetup
Definition: EventSetup.h:58
END_DCC_FED_ID
#define END_DCC_FED_ID
Definition: EcalDCCUnpackingModule.cc:31
EcalSupervisorTBDataFormatter::interpretRawData
void interpretRawData(const FEDRawData &data, EcalTBEventHeader &tbEventHeader)
Definition: EcalSupervisorDataFormatter.cc:7
BEG_DCC_FED_ID
#define BEG_DCC_FED_ID
Definition: EcalDCCUnpackingModule.cc:30
EcalDCCTBUnpackingModule::tableFormatter_
TableDataFormatter * tableFormatter_
Definition: EcalDCCUnpackingModule.h:45
EcalDCCTBUnpackingModule::formatter_
EcalTBDaqFormatter * formatter_
Definition: EcalDCCUnpackingModule.h:42
EcalDCCTBUnpackingModule::endJob
void endJob(void) override
Definition: EcalDCCUnpackingModule.cc:79
eostools.move
def move(src, dest)
Definition: eostools.py:511
EcalDCCTBUnpackingModule::ecalSupervisorFormatter_
EcalSupervisorTBDataFormatter * ecalSupervisorFormatter_
Definition: EcalDCCUnpackingModule.h:43
MatacqTBDataFormatter
Definition: MatacqDataFormatter.h:14
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
EcalTBDaqFormatter::interpretRawData
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)
Definition: EcalTBDaqFormatter.cc:47
EcalDCCHeaderBlock::COSMIC
Definition: EcalDCCHeaderBlock.h:22
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
END_DCC_FED_ID_GLOBAL
#define END_DCC_FED_ID_GLOBAL
Definition: EcalDCCUnpackingModule.cc:33
cms::Exception
Definition: Exception.h:70
EcalDCCTBUnpackingModule::fedRawDataCollectionTag_
edm::InputTag fedRawDataCollectionTag_
Definition: EcalDCCUnpackingModule.h:47
EcalCondDBWriter_cfi.runType
runType
Definition: EcalCondDBWriter_cfi.py:64
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
EcalDCCTBUnpackingModule::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
Produce digis out of raw data.
Definition: EcalDCCUnpackingModule.cc:81
EcalTBCollections.h
EcalDCCUnpackingModule.h
edm::Event
Definition: Event.h:73
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
CamacTBDataFormatter
Definition: CamacTBDataFormatter.h:23
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
ECALTBParserBlockException
Definition: ECALParserBlockException.h:10
EcalDCCTBUnpackingModule::camacTBformatter_
CamacTBDataFormatter * camacTBformatter_
Definition: EcalDCCUnpackingModule.h:44