Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <EventFilter/EcalTBRawToDigi/interface/EcalDCCUnpackingModule.h>
00012 #include <EventFilter/EcalTBRawToDigi/src/EcalTBDaqFormatter.h>
00013 #include <EventFilter/EcalTBRawToDigi/src/EcalSupervisorDataFormatter.h>
00014 #include <EventFilter/EcalTBRawToDigi/src/CamacTBDataFormatter.h>
00015 #include <EventFilter/EcalTBRawToDigi/src/TableDataFormatter.h>
00016 #include <EventFilter/EcalTBRawToDigi/src/MatacqDataFormatter.h>
00017 #include <EventFilter/EcalTBRawToDigi/src/ECALParserException.h>
00018 #include <EventFilter/EcalTBRawToDigi/src/ECALParserBlockException.h>
00019 #include <DataFormats/FEDRawData/interface/FEDRawData.h>
00020 #include <DataFormats/FEDRawData/interface/FEDNumbering.h>
00021 #include <DataFormats/FEDRawData/interface/FEDRawDataCollection.h>
00022 #include <DataFormats/EcalDigi/interface/EcalDigiCollections.h>
00023 #include <DataFormats/EcalRawData/interface/EcalRawDataCollections.h>
00024 #include <TBDataFormats/EcalTBObjects/interface/EcalTBCollections.h>
00025 #include <DataFormats/Common/interface/Handle.h>
00026 #include <FWCore/Framework/interface/Event.h>
00027
00028
00029
00030 #include <iostream>
00031 #include <iomanip>
00032
00033
00034 #define BEG_DCC_FED_ID 0
00035 #define END_DCC_FED_ID 35
00036 #define BEG_DCC_FED_ID_GLOBAL 600
00037 #define END_DCC_FED_ID_GLOBAL 670
00038
00039 #define ECAL_SUPERVISOR_FED_ID 40
00040 #define TBCAMAC_FED_ID 41
00041 #define TABLE_FED_ID 42
00042 #define MATACQ_FED_ID 43
00043
00044 EcalDCCTBUnpackingModule::EcalDCCTBUnpackingModule(const edm::ParameterSet& pset){
00045
00046 formatter_ = new EcalTBDaqFormatter();
00047 ecalSupervisorFormatter_ = new EcalSupervisorTBDataFormatter();
00048 camacTBformatter_ = new CamacTBDataFormatter();
00049 tableFormatter_ = new TableDataFormatter();
00050 matacqFormatter_ = new MatacqTBDataFormatter();
00051
00052
00053 produces<EBDigiCollection>("ebDigis");
00054 produces<EcalMatacqDigiCollection>();
00055 produces<EcalPnDiodeDigiCollection>();
00056 produces<EcalRawDataCollection>();
00057 produces<EcalTrigPrimDigiCollection>("EBTT");
00058
00059
00060 produces<EcalTBHodoscopeRawInfo>();
00061 produces<EcalTBTDCRawInfo>();
00062 produces<EcalTBEventHeader>();
00063
00064
00065 produces<EBDetIdCollection>("EcalIntegrityDCCSizeErrors");
00066 produces<EcalElectronicsIdCollection>("EcalIntegrityTTIdErrors");
00067 produces<EcalElectronicsIdCollection>("EcalIntegrityBlockSizeErrors");
00068 produces<EBDetIdCollection>("EcalIntegrityChIdErrors");
00069 produces<EBDetIdCollection>("EcalIntegrityGainErrors");
00070 produces<EBDetIdCollection>("EcalIntegrityGainSwitchErrors");
00071
00072
00073 produces<EcalElectronicsIdCollection>("EcalIntegrityMemTtIdErrors");
00074 produces<EcalElectronicsIdCollection>("EcalIntegrityMemBlockSize");
00075 produces<EcalElectronicsIdCollection>("EcalIntegrityMemChIdErrors");
00076 produces<EcalElectronicsIdCollection>("EcalIntegrityMemGainErrors");
00077 }
00078
00079
00080 EcalDCCTBUnpackingModule::~EcalDCCTBUnpackingModule(){
00081
00082 delete formatter_;
00083
00084 }
00085
00086 void EcalDCCTBUnpackingModule::beginJob(){
00087
00088 }
00089
00090 void EcalDCCTBUnpackingModule::endJob(){
00091
00092 }
00093
00094 void EcalDCCTBUnpackingModule::produce(edm::Event & e, const edm::EventSetup& c){
00095
00096 edm::Handle<FEDRawDataCollection> rawdata;
00097 e.getByType(rawdata);
00098
00099
00100
00101 std::auto_ptr<EBDigiCollection> productEb(new EBDigiCollection);
00102
00103
00104 std::auto_ptr<EcalMatacqDigiCollection> productMatacq(new EcalMatacqDigiCollection());
00105
00106
00107 std::auto_ptr<EcalPnDiodeDigiCollection> productPN(new EcalPnDiodeDigiCollection);
00108
00109
00110 std::auto_ptr<EcalRawDataCollection> productDCCHeader(new EcalRawDataCollection);
00111
00112
00113 std::auto_ptr<EcalTrigPrimDigiCollection> productTriggerPrimitives(new EcalTrigPrimDigiCollection);
00114
00115
00116 std::auto_ptr<EBDetIdCollection> productDCCSize(new EBDetIdCollection);
00117
00118
00119 std::auto_ptr<EcalElectronicsIdCollection> productTTId(new EcalElectronicsIdCollection);
00120
00121
00122 std::auto_ptr<EcalElectronicsIdCollection> productBlockSize(new EcalElectronicsIdCollection);
00123
00124
00125 std::auto_ptr<EBDetIdCollection> productChId(new EBDetIdCollection);
00126
00127
00128 std::auto_ptr<EBDetIdCollection> productGain(new EBDetIdCollection);
00129
00130
00131 std::auto_ptr<EBDetIdCollection> productGainSwitch(new EBDetIdCollection);
00132
00133
00134 std::auto_ptr<EcalElectronicsIdCollection> productMemTtId(new EcalElectronicsIdCollection);
00135
00136
00137 std::auto_ptr< EcalElectronicsIdCollection> productMemBlockSize(new EcalElectronicsIdCollection);
00138
00139
00140 std::auto_ptr< EcalElectronicsIdCollection> productMemGain(new EcalElectronicsIdCollection);
00141
00142
00143 std::auto_ptr<EcalElectronicsIdCollection> productMemChIdErrors(new EcalElectronicsIdCollection);
00144
00145
00146 std::auto_ptr<EcalTBHodoscopeRawInfo> productHodo(new EcalTBHodoscopeRawInfo());
00147 std::auto_ptr<EcalTBTDCRawInfo> productTdc(new EcalTBTDCRawInfo());
00148 std::auto_ptr<EcalTBEventHeader> productHeader(new EcalTBEventHeader());
00149
00150
00151 try {
00152
00153 for (int id= 0; id<=FEDNumbering::MAXFEDID; ++id){
00154
00155
00156 const FEDRawData& data = rawdata->FEDData(id);
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 if (data.size()>16){
00172
00173 if ( (id >= BEG_DCC_FED_ID && id <= END_DCC_FED_ID) ||
00174 (id >= BEG_DCC_FED_ID_GLOBAL && id <= END_DCC_FED_ID_GLOBAL)
00175 )
00176 {
00177
00178 (*productHeader).setSmInBeam(id);
00179 formatter_->interpretRawData(data, *productEb, *productPN,
00180 *productDCCHeader,
00181 *productDCCSize,
00182 *productTTId, *productBlockSize,
00183 *productChId, *productGain, *productGainSwitch,
00184 *productMemTtId, *productMemBlockSize,
00185 *productMemGain, *productMemChIdErrors,
00186 *productTriggerPrimitives);
00187 int runType = (*productDCCHeader)[0].getRunType();
00188 if ( runType == EcalDCCHeaderBlock::COSMIC || runType == EcalDCCHeaderBlock::BEAMH4 )
00189 (*productHeader).setTriggerMask(0x1);
00190 else if ( runType == 4 || runType == 5 || runType == 6 )
00191 (*productHeader).setTriggerMask(0x2000);
00192 else if ( runType == 9 || runType == 10 || runType == 11 )
00193 (*productHeader).setTriggerMask(0x800);
00194 LogDebug("EcalDCCTBUnpackingModule") << "Event type is " << (*productHeader).eventType() << " dbEventType " << (*productHeader).dbEventType();
00195 }
00196 else if ( id == ECAL_SUPERVISOR_FED_ID )
00197 ecalSupervisorFormatter_->interpretRawData(data, *productHeader);
00198 else if ( id == TBCAMAC_FED_ID )
00199 camacTBformatter_->interpretRawData(data, *productHeader,*productHodo, *productTdc );
00200 else if ( id == TABLE_FED_ID )
00201 tableFormatter_->interpretRawData(data, *productHeader);
00202 else if ( id == MATACQ_FED_ID )
00203 matacqFormatter_->interpretRawData(data, *productMatacq);
00204 }
00205 }
00206
00207
00208
00209 e.put(productPN);
00210 e.put(productEb,"ebDigis");
00211 e.put(productMatacq);
00212 e.put(productDCCHeader);
00213 e.put(productTriggerPrimitives,"EBTT");
00214
00215 e.put(productDCCSize,"EcalIntegrityDCCSizeErrors");
00216 e.put(productTTId,"EcalIntegrityTTIdErrors");
00217 e.put(productBlockSize,"EcalIntegrityBlockSizeErrors");
00218 e.put(productChId,"EcalIntegrityChIdErrors");
00219 e.put(productGain,"EcalIntegrityGainErrors");
00220 e.put(productGainSwitch,"EcalIntegrityGainSwitchErrors");
00221
00222 e.put(productMemTtId,"EcalIntegrityMemTtIdErrors");
00223 e.put(productMemBlockSize,"EcalIntegrityMemBlockSize");
00224 e.put(productMemChIdErrors,"EcalIntegrityMemChIdErrors");
00225 e.put(productMemGain,"EcalIntegrityMemGainErrors");
00226
00227 e.put(productHodo);
00228 e.put(productTdc);
00229 e.put(productHeader);
00230
00231 } catch (ECALTBParserException &e) {
00232 std::cout << "[EcalDCCTBUnpackingModule] " << e.what() << std::endl;
00233 } catch (ECALTBParserBlockException &e) {
00234 std::cout << "[EcalDCCTBUnpackingModule] " << e.what() << std::endl;
00235 } catch (cms::Exception &e) {
00236 std::cout << "[EcalDCCTBUnpackingModule] " << e.what() << std::endl;
00237 } catch (...) {
00238 std::cout << "[EcalDCCTBUnpackingModule] Unknown exception ..." << std::endl;
00239 }
00240
00241 }