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 fedRawDataCollectionTag_(pset.getParameter<edm::InputTag>("fedRawDataCollectionTag")) {
00046
00047 formatter_ = new EcalTBDaqFormatter();
00048 ecalSupervisorFormatter_ = new EcalSupervisorTBDataFormatter();
00049 camacTBformatter_ = new CamacTBDataFormatter();
00050 tableFormatter_ = new TableDataFormatter();
00051 matacqFormatter_ = new MatacqTBDataFormatter();
00052
00053
00054 produces<EBDigiCollection>("ebDigis");
00055 produces<EcalMatacqDigiCollection>();
00056 produces<EcalPnDiodeDigiCollection>();
00057 produces<EcalRawDataCollection>();
00058 produces<EcalTrigPrimDigiCollection>("EBTT");
00059
00060
00061 produces<EcalTBHodoscopeRawInfo>();
00062 produces<EcalTBTDCRawInfo>();
00063 produces<EcalTBEventHeader>();
00064
00065
00066 produces<EBDetIdCollection>("EcalIntegrityDCCSizeErrors");
00067 produces<EcalElectronicsIdCollection>("EcalIntegrityTTIdErrors");
00068 produces<EcalElectronicsIdCollection>("EcalIntegrityBlockSizeErrors");
00069 produces<EBDetIdCollection>("EcalIntegrityChIdErrors");
00070 produces<EBDetIdCollection>("EcalIntegrityGainErrors");
00071 produces<EBDetIdCollection>("EcalIntegrityGainSwitchErrors");
00072
00073
00074 produces<EcalElectronicsIdCollection>("EcalIntegrityMemTtIdErrors");
00075 produces<EcalElectronicsIdCollection>("EcalIntegrityMemBlockSize");
00076 produces<EcalElectronicsIdCollection>("EcalIntegrityMemChIdErrors");
00077 produces<EcalElectronicsIdCollection>("EcalIntegrityMemGainErrors");
00078 }
00079
00080
00081 EcalDCCTBUnpackingModule::~EcalDCCTBUnpackingModule(){
00082
00083 delete formatter_;
00084
00085 }
00086
00087 void EcalDCCTBUnpackingModule::beginJob(){
00088
00089 }
00090
00091 void EcalDCCTBUnpackingModule::endJob(){
00092
00093 }
00094
00095 void EcalDCCTBUnpackingModule::produce(edm::Event & e, const edm::EventSetup& c){
00096
00097 edm::Handle<FEDRawDataCollection> rawdata;
00098 e.getByLabel(fedRawDataCollectionTag_, rawdata);
00099
00100
00101
00102 std::auto_ptr<EBDigiCollection> productEb(new EBDigiCollection);
00103
00104
00105 std::auto_ptr<EcalMatacqDigiCollection> productMatacq(new EcalMatacqDigiCollection());
00106
00107
00108 std::auto_ptr<EcalPnDiodeDigiCollection> productPN(new EcalPnDiodeDigiCollection);
00109
00110
00111 std::auto_ptr<EcalRawDataCollection> productDCCHeader(new EcalRawDataCollection);
00112
00113
00114 std::auto_ptr<EcalTrigPrimDigiCollection> productTriggerPrimitives(new EcalTrigPrimDigiCollection);
00115
00116
00117 std::auto_ptr<EBDetIdCollection> productDCCSize(new EBDetIdCollection);
00118
00119
00120 std::auto_ptr<EcalElectronicsIdCollection> productTTId(new EcalElectronicsIdCollection);
00121
00122
00123 std::auto_ptr<EcalElectronicsIdCollection> productBlockSize(new EcalElectronicsIdCollection);
00124
00125
00126 std::auto_ptr<EBDetIdCollection> productChId(new EBDetIdCollection);
00127
00128
00129 std::auto_ptr<EBDetIdCollection> productGain(new EBDetIdCollection);
00130
00131
00132 std::auto_ptr<EBDetIdCollection> productGainSwitch(new EBDetIdCollection);
00133
00134
00135 std::auto_ptr<EcalElectronicsIdCollection> productMemTtId(new EcalElectronicsIdCollection);
00136
00137
00138 std::auto_ptr< EcalElectronicsIdCollection> productMemBlockSize(new EcalElectronicsIdCollection);
00139
00140
00141 std::auto_ptr< EcalElectronicsIdCollection> productMemGain(new EcalElectronicsIdCollection);
00142
00143
00144 std::auto_ptr<EcalElectronicsIdCollection> productMemChIdErrors(new EcalElectronicsIdCollection);
00145
00146
00147 std::auto_ptr<EcalTBHodoscopeRawInfo> productHodo(new EcalTBHodoscopeRawInfo());
00148 std::auto_ptr<EcalTBTDCRawInfo> productTdc(new EcalTBTDCRawInfo());
00149 std::auto_ptr<EcalTBEventHeader> productHeader(new EcalTBEventHeader());
00150
00151
00152 try {
00153
00154 for (int id= 0; id<=FEDNumbering::MAXFEDID; ++id){
00155
00156
00157 const FEDRawData& data = rawdata->FEDData(id);
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172 if (data.size()>16){
00173
00174 if ( (id >= BEG_DCC_FED_ID && id <= END_DCC_FED_ID) ||
00175 (id >= BEG_DCC_FED_ID_GLOBAL && id <= END_DCC_FED_ID_GLOBAL)
00176 )
00177 {
00178
00179 (*productHeader).setSmInBeam(id);
00180 formatter_->interpretRawData(data, *productEb, *productPN,
00181 *productDCCHeader,
00182 *productDCCSize,
00183 *productTTId, *productBlockSize,
00184 *productChId, *productGain, *productGainSwitch,
00185 *productMemTtId, *productMemBlockSize,
00186 *productMemGain, *productMemChIdErrors,
00187 *productTriggerPrimitives);
00188 int runType = (*productDCCHeader)[0].getRunType();
00189 if ( runType == EcalDCCHeaderBlock::COSMIC || runType == EcalDCCHeaderBlock::BEAMH4 )
00190 (*productHeader).setTriggerMask(0x1);
00191 else if ( runType == 4 || runType == 5 || runType == 6 )
00192 (*productHeader).setTriggerMask(0x2000);
00193 else if ( runType == 9 || runType == 10 || runType == 11 )
00194 (*productHeader).setTriggerMask(0x800);
00195 LogDebug("EcalDCCTBUnpackingModule") << "Event type is " << (*productHeader).eventType() << " dbEventType " << (*productHeader).dbEventType();
00196 }
00197 else if ( id == ECAL_SUPERVISOR_FED_ID )
00198 ecalSupervisorFormatter_->interpretRawData(data, *productHeader);
00199 else if ( id == TBCAMAC_FED_ID )
00200 camacTBformatter_->interpretRawData(data, *productHeader,*productHodo, *productTdc );
00201 else if ( id == TABLE_FED_ID )
00202 tableFormatter_->interpretRawData(data, *productHeader);
00203 else if ( id == MATACQ_FED_ID )
00204 matacqFormatter_->interpretRawData(data, *productMatacq);
00205 }
00206 }
00207
00208
00209
00210 e.put(productPN);
00211 e.put(productEb,"ebDigis");
00212 e.put(productMatacq);
00213 e.put(productDCCHeader);
00214 e.put(productTriggerPrimitives,"EBTT");
00215
00216 e.put(productDCCSize,"EcalIntegrityDCCSizeErrors");
00217 e.put(productTTId,"EcalIntegrityTTIdErrors");
00218 e.put(productBlockSize,"EcalIntegrityBlockSizeErrors");
00219 e.put(productChId,"EcalIntegrityChIdErrors");
00220 e.put(productGain,"EcalIntegrityGainErrors");
00221 e.put(productGainSwitch,"EcalIntegrityGainSwitchErrors");
00222
00223 e.put(productMemTtId,"EcalIntegrityMemTtIdErrors");
00224 e.put(productMemBlockSize,"EcalIntegrityMemBlockSize");
00225 e.put(productMemChIdErrors,"EcalIntegrityMemChIdErrors");
00226 e.put(productMemGain,"EcalIntegrityMemGainErrors");
00227
00228 e.put(productHodo);
00229 e.put(productTdc);
00230 e.put(productHeader);
00231
00232 } catch (ECALTBParserException &e) {
00233 std::cout << "[EcalDCCTBUnpackingModule] " << e.what() << std::endl;
00234 } catch (ECALTBParserBlockException &e) {
00235 std::cout << "[EcalDCCTBUnpackingModule] " << e.what() << std::endl;
00236 } catch (cms::Exception &e) {
00237 std::cout << "[EcalDCCTBUnpackingModule] " << e.what() << std::endl;
00238 } catch (...) {
00239 std::cout << "[EcalDCCTBUnpackingModule] Unknown exception ..." << std::endl;
00240 }
00241
00242 }