File indexing completed on 2024-09-07 04:36:10
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <EventFilter/EcalTBRawToDigi/interface/EcalDCCUnpackingModule.h>
0010 #include <EventFilter/EcalTBRawToDigi/src/EcalTBDaqFormatter.h>
0011 #include <EventFilter/EcalTBRawToDigi/src/EcalSupervisorDataFormatter.h>
0012 #include <EventFilter/EcalTBRawToDigi/src/CamacTBDataFormatter.h>
0013 #include <EventFilter/EcalTBRawToDigi/src/TableDataFormatter.h>
0014 #include <EventFilter/EcalTBRawToDigi/src/MatacqDataFormatter.h>
0015 #include <EventFilter/EcalTBRawToDigi/src/ECALParserException.h>
0016 #include <EventFilter/EcalTBRawToDigi/src/ECALParserBlockException.h>
0017 #include <DataFormats/FEDRawData/interface/FEDRawData.h>
0018 #include <DataFormats/FEDRawData/interface/FEDNumbering.h>
0019 #include <DataFormats/FEDRawData/interface/FEDRawDataCollection.h>
0020 #include <DataFormats/EcalDigi/interface/EcalDigiCollections.h>
0021 #include <DataFormats/EcalRawData/interface/EcalRawDataCollections.h>
0022 #include <TBDataFormats/EcalTBObjects/interface/EcalTBCollections.h>
0023 #include <DataFormats/Common/interface/Handle.h>
0024 #include <FWCore/Framework/interface/Event.h>
0025
0026 #include <iostream>
0027 #include <iomanip>
0028
0029
0030 #define BEG_DCC_FED_ID 0
0031 #define END_DCC_FED_ID 35
0032 #define BEG_DCC_FED_ID_GLOBAL 600
0033 #define END_DCC_FED_ID_GLOBAL 670
0034
0035 #define ECAL_SUPERVISOR_FED_ID 40
0036 #define TBCAMAC_FED_ID 41
0037 #define TABLE_FED_ID 42
0038 #define MATACQ_FED_ID 43
0039
0040 EcalDCCTBUnpackingModule::EcalDCCTBUnpackingModule(const edm::ParameterSet& pset)
0041 : fedRawDataCollectionTag_(pset.getParameter<edm::InputTag>("fedRawDataCollectionTag")) {
0042 formatter_ = new EcalTBDaqFormatter();
0043 ecalSupervisorFormatter_ = new EcalSupervisorTBDataFormatter();
0044 camacTBformatter_ = new CamacTBDataFormatter();
0045 tableFormatter_ = new TableDataFormatter();
0046 matacqFormatter_ = new MatacqTBDataFormatter();
0047
0048
0049 produces<EBDigiCollection>("ebDigis");
0050 produces<EcalMatacqDigiCollection>();
0051 produces<EcalPnDiodeDigiCollection>();
0052 produces<EcalRawDataCollection>();
0053 produces<EcalTrigPrimDigiCollection>("EBTT");
0054
0055
0056 produces<EcalTBHodoscopeRawInfo>();
0057 produces<EcalTBTDCRawInfo>();
0058 produces<EcalTBEventHeader>();
0059
0060
0061 produces<EBDetIdCollection>("EcalIntegrityDCCSizeErrors");
0062 produces<EcalElectronicsIdCollection>("EcalIntegrityTTIdErrors");
0063 produces<EcalElectronicsIdCollection>("EcalIntegrityBlockSizeErrors");
0064 produces<EBDetIdCollection>("EcalIntegrityChIdErrors");
0065 produces<EBDetIdCollection>("EcalIntegrityGainErrors");
0066 produces<EBDetIdCollection>("EcalIntegrityGainSwitchErrors");
0067
0068
0069 produces<EcalElectronicsIdCollection>("EcalIntegrityMemTtIdErrors");
0070 produces<EcalElectronicsIdCollection>("EcalIntegrityMemBlockSize");
0071 produces<EcalElectronicsIdCollection>("EcalIntegrityMemChIdErrors");
0072 produces<EcalElectronicsIdCollection>("EcalIntegrityMemGainErrors");
0073 }
0074
0075 EcalDCCTBUnpackingModule::~EcalDCCTBUnpackingModule() { delete formatter_; }
0076
0077 void EcalDCCTBUnpackingModule::produce(edm::Event& e, const edm::EventSetup& c) {
0078 edm::Handle<FEDRawDataCollection> rawdata;
0079 e.getByLabel(fedRawDataCollectionTag_, rawdata);
0080
0081
0082 auto productEb = std::make_unique<EBDigiCollection>();
0083
0084
0085 auto productMatacq = std::make_unique<EcalMatacqDigiCollection>();
0086
0087
0088 auto productPN = std::make_unique<EcalPnDiodeDigiCollection>();
0089
0090
0091 auto productDCCHeader = std::make_unique<EcalRawDataCollection>();
0092
0093
0094 auto productTriggerPrimitives = std::make_unique<EcalTrigPrimDigiCollection>();
0095
0096
0097 auto productDCCSize = std::make_unique<EBDetIdCollection>();
0098
0099
0100 auto productTTId = std::make_unique<EcalElectronicsIdCollection>();
0101
0102
0103 auto productBlockSize = std::make_unique<EcalElectronicsIdCollection>();
0104
0105
0106 auto productChId = std::make_unique<EBDetIdCollection>();
0107
0108
0109 auto productGain = std::make_unique<EBDetIdCollection>();
0110
0111
0112 auto productGainSwitch = std::make_unique<EBDetIdCollection>();
0113
0114
0115 auto productMemTtId = std::make_unique<EcalElectronicsIdCollection>();
0116
0117
0118 auto productMemBlockSize = std::make_unique<EcalElectronicsIdCollection>();
0119
0120
0121 auto productMemGain = std::make_unique<EcalElectronicsIdCollection>();
0122
0123
0124 auto productMemChIdErrors = std::make_unique<EcalElectronicsIdCollection>();
0125
0126
0127 auto productHodo = std::make_unique<EcalTBHodoscopeRawInfo>();
0128 auto productTdc = std::make_unique<EcalTBTDCRawInfo>();
0129 auto productHeader = std::make_unique<EcalTBEventHeader>();
0130
0131 try {
0132 for (int id = 0; id <= FEDNumbering::MAXFEDID; ++id) {
0133
0134 const FEDRawData& data = rawdata->FEDData(id);
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149 if (data.size() > 16) {
0150 if ((id >= BEG_DCC_FED_ID && id <= END_DCC_FED_ID) ||
0151 (id >= BEG_DCC_FED_ID_GLOBAL &&
0152 id <= END_DCC_FED_ID_GLOBAL)) {
0153
0154 (*productHeader).setSmInBeam(id);
0155 formatter_->interpretRawData(data,
0156 *productEb,
0157 *productPN,
0158 *productDCCHeader,
0159 *productDCCSize,
0160 *productTTId,
0161 *productBlockSize,
0162 *productChId,
0163 *productGain,
0164 *productGainSwitch,
0165 *productMemTtId,
0166 *productMemBlockSize,
0167 *productMemGain,
0168 *productMemChIdErrors,
0169 *productTriggerPrimitives);
0170 int runType = (*productDCCHeader)[0].getRunType();
0171 if (runType == EcalDCCHeaderBlock::COSMIC || runType == EcalDCCHeaderBlock::BEAMH4)
0172 (*productHeader).setTriggerMask(0x1);
0173 else if (runType == 4 || runType == 5 || runType == 6)
0174 (*productHeader).setTriggerMask(0x2000);
0175 else if (runType == 9 || runType == 10 || runType == 11)
0176 (*productHeader).setTriggerMask(0x800);
0177 LogDebug("EcalDCCTBUnpackingModule")
0178 << "Event type is " << (*productHeader).eventType() << " dbEventType " << (*productHeader).dbEventType();
0179 } else if (id == ECAL_SUPERVISOR_FED_ID)
0180 ecalSupervisorFormatter_->interpretRawData(data, *productHeader);
0181 else if (id == TBCAMAC_FED_ID)
0182 camacTBformatter_->interpretRawData(data, *productHeader, *productHodo, *productTdc);
0183 else if (id == TABLE_FED_ID)
0184 tableFormatter_->interpretRawData(data, *productHeader);
0185 else if (id == MATACQ_FED_ID)
0186 matacqFormatter_->interpretRawData(data, *productMatacq);
0187 }
0188 }
0189
0190
0191 e.put(std::move(productPN));
0192 e.put(std::move(productEb), "ebDigis");
0193 e.put(std::move(productMatacq));
0194 e.put(std::move(productDCCHeader));
0195 e.put(std::move(productTriggerPrimitives), "EBTT");
0196
0197 e.put(std::move(productDCCSize), "EcalIntegrityDCCSizeErrors");
0198 e.put(std::move(productTTId), "EcalIntegrityTTIdErrors");
0199 e.put(std::move(productBlockSize), "EcalIntegrityBlockSizeErrors");
0200 e.put(std::move(productChId), "EcalIntegrityChIdErrors");
0201 e.put(std::move(productGain), "EcalIntegrityGainErrors");
0202 e.put(std::move(productGainSwitch), "EcalIntegrityGainSwitchErrors");
0203
0204 e.put(std::move(productMemTtId), "EcalIntegrityMemTtIdErrors");
0205 e.put(std::move(productMemBlockSize), "EcalIntegrityMemBlockSize");
0206 e.put(std::move(productMemChIdErrors), "EcalIntegrityMemChIdErrors");
0207 e.put(std::move(productMemGain), "EcalIntegrityMemGainErrors");
0208
0209 e.put(std::move(productHodo));
0210 e.put(std::move(productTdc));
0211 e.put(std::move(productHeader));
0212
0213 } catch (ECALTBParserException& e) {
0214 std::cout << "[EcalDCCTBUnpackingModule] " << e.what() << std::endl;
0215 } catch (ECALTBParserBlockException& e) {
0216 std::cout << "[EcalDCCTBUnpackingModule] " << e.what() << std::endl;
0217 } catch (cms::Exception& e) {
0218 std::cout << "[EcalDCCTBUnpackingModule] " << e.what() << std::endl;
0219 } catch (...) {
0220 std::cout << "[EcalDCCTBUnpackingModule] Unknown exception ..." << std::endl;
0221 }
0222 }