diff --git a/EventFilter/EcalDigiToRaw/interface/BlockFormatter.h b/EventFilter/EcalDigiToRaw/interface/BlockFormatter.h index 335d184856805..40e4d280177fd 100644 --- a/EventFilter/EcalDigiToRaw/interface/BlockFormatter.h +++ b/EventFilter/EcalDigiToRaw/interface/BlockFormatter.h @@ -20,34 +20,24 @@ class BlockFormatter { typedef uint64_t Word64; typedef uint16_t Word16; - BlockFormatter(); - ~BlockFormatter(); - void SetParam(EcalDigiToRaw* base); + BlockFormatter(EcalDigiToRaw* base); static const int kCardsPerTower = 5; // Number of VFE cards per trigger tower - void DigiToRaw(FEDRawDataCollection* productRawData); - void print(FEDRawData& rawdata); - // void CleanUp(FEDRawDataCollection* productRawData); - void CleanUp(FEDRawDataCollection* productRawData, - std::map >* FEDorder); - void PrintSizes(FEDRawDataCollection* productRawData); + void DigiToRaw(FEDRawDataCollection* productRawData, int run_number, int orbit_number, int bx, int lv1) const; + void print(FEDRawData& rawdata) const; + void CleanUp(FEDRawDataCollection& productRawData, + std::map >& FEDorder); + void PrintSizes(FEDRawDataCollection* productRawData) const; protected : - bool debug_; - bool doBarrel_; - bool doEndCap_; - bool doTCC_; - bool doSR_; - bool doTower_; - - std::vector * plistDCCId_; - - int* pcounter_; - int* porbit_number_; - int* pbx_; - int* plv1_; - int* prunnumber_; + const bool debug_; + const bool doBarrel_; + const bool doEndCap_; + const std::vector * plistDCCId_; + const bool doTCC_; + const bool doSR_; + const bool doTower_; }; diff --git a/EventFilter/EcalDigiToRaw/interface/EcalDigiToRaw.h b/EventFilter/EcalDigiToRaw/interface/EcalDigiToRaw.h index a350c19a8f894..eed2a6b9b7d9d 100644 --- a/EventFilter/EcalDigiToRaw/interface/EcalDigiToRaw.h +++ b/EventFilter/EcalDigiToRaw/interface/EcalDigiToRaw.h @@ -27,11 +27,11 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" - +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "EventFilter/EcalDigiToRaw/interface/TowerBlockFormatter.h" @@ -47,31 +47,22 @@ // class decleration // -class EcalDigiToRaw : public edm::EDProducer { +class EcalDigiToRaw : public edm::global::EDProducer<> { public: EcalDigiToRaw(const edm::ParameterSet& pset); - virtual ~EcalDigiToRaw(); - - void beginJob(); - void produce(edm::Event& e, const edm::EventSetup& c); - void endJob() ; - - typedef long long Word64; - typedef unsigned int Word32; - - int* GetCounter() {return &counter_ ;} - bool GetDebug() {return debug_ ;} - int* GetOrbit() {return &orbit_number_ ;} - int* GetBX() {return &bx_ ;} - int* GetLV1() {return &lv1_ ;} - int* GetRunNumber() {return &runnumber_ ;} - bool GetDoBarrel() {return doBarrel_ ;} - bool GetDoEndCap() {return doEndCap_ ;} - bool GetDoSR() {return doSR_ ;} - bool GetDoTower() {return doTower_ ;} - bool GetDoTCC() {return doTCC_ ;} - - std::vector* GetListDCCId() {return &listDCCId_ ;} + virtual void produce(edm::StreamID, edm::Event& e, const edm::EventSetup& c) const override; + + typedef long long Word64; + typedef unsigned int Word32; + + bool GetDebug() const {return debug_ ;} + bool GetDoBarrel() const {return doBarrel_ ;} + bool GetDoEndCap() const {return doEndCap_ ;} + bool GetDoSR() const {return doSR_ ;} + bool GetDoTower() const{return doTower_ ;} + bool GetDoTCC() const {return doTCC_ ;} + + const std::vector* GetListDCCId() const {return &listDCCId_ ;} static const int BXMAX = 2808; @@ -81,36 +72,29 @@ class EcalDigiToRaw : public edm::EDProducer { // ----------member data --------------------------- - int counter_; - int orbit_number_; - bool debug_; - int runnumber_; - int bx_; - int lv1_; - - bool doTCC_; - bool doSR_; - bool doTower_; - - edm::EDGetTokenT labelTT_ ; - edm::EDGetTokenT labelEBSR_ ; - edm::EDGetTokenT labelEESR_ ; - edm::EDGetTokenT EBDigiToken_ ; - edm::EDGetTokenT EEDigiToken_; + const bool doTCC_; + const bool doSR_; + const bool doTower_; - bool doBarrel_; - bool doEndCap_; + const bool doBarrel_; + const bool doEndCap_; - std::vector listDCCId_; + const std::vector listDCCId_; - std::string label_; - std::string instanceNameEB_; - std::string instanceNameEE_; - - TowerBlockFormatter* Towerblockformatter_; - TCCBlockFormatter* TCCblockformatter_; - BlockFormatter* Headerblockformatter_; - SRBlockFormatter* SRblockformatter_; + const std::string label_; + const std::string instanceNameEB_; + const std::string instanceNameEE_; + + const edm::EDGetTokenT EBDigiToken_ ; + const edm::EDGetTokenT EEDigiToken_; + const edm::EDGetTokenT labelTT_ ; + const edm::EDGetTokenT labelEBSR_ ; + const edm::EDGetTokenT labelEESR_ ; + const bool debug_; + const std::unique_ptr Towerblockformatter_; + const std::unique_ptr TCCblockformatter_; + const std::unique_ptr Headerblockformatter_; + const std::unique_ptr SRblockformatter_; }; diff --git a/EventFilter/EcalDigiToRaw/interface/SRBlockFormatter.h b/EventFilter/EcalDigiToRaw/interface/SRBlockFormatter.h index 63b7021cdd3b8..1e5816e16ddb5 100644 --- a/EventFilter/EcalDigiToRaw/interface/SRBlockFormatter.h +++ b/EventFilter/EcalDigiToRaw/interface/SRBlockFormatter.h @@ -9,21 +9,21 @@ #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" #include "DataFormats/FEDRawData/interface/FEDRawData.h" #include "EventFilter/EcalDigiToRaw/interface/BlockFormatter.h" - +#include "FWCore/MessageLogger/interface/MessageLogger.h" class SRBlockFormatter : public BlockFormatter { - public : - - SRBlockFormatter(); - ~SRBlockFormatter(); - void DigiToRaw(int dccid, int dcc_channel, int flag, FEDRawData& rawdata); - - void StartEvent(); - - private : - std::map header_; + public : + SRBlockFormatter(EcalDigiToRaw* es): BlockFormatter(es) {}; + void DigiToRaw(int dccid, int dcc_channel, int flag, FEDRawData& rawdata, int bx, int lv1, std::map& header_) const; + + inline std::map StartEvent() const { + std::map header; + header.clear(); + return header; + } + private : }; diff --git a/EventFilter/EcalDigiToRaw/interface/TCCBlockFormatter.h b/EventFilter/EcalDigiToRaw/interface/TCCBlockFormatter.h index e0d541c3c79cb..c2c85a1cb33f3 100644 --- a/EventFilter/EcalDigiToRaw/interface/TCCBlockFormatter.h +++ b/EventFilter/EcalDigiToRaw/interface/TCCBlockFormatter.h @@ -9,7 +9,7 @@ #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" #include "DataFormats/FEDRawData/interface/FEDRawData.h" #include "EventFilter/EcalDigiToRaw/interface/BlockFormatter.h" - +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h" @@ -19,16 +19,13 @@ -class TCCBlockFormatter : public BlockFormatter { - public : - - TCCBlockFormatter(); - ~TCCBlockFormatter(); - static const int kCardsPerTower = 5; // Number of VFE cards per trigger tower - void DigiToRaw(const EcalTriggerPrimitiveDigi& trigprim, FEDRawData& rawdata, const EcalElectronicsMapping* TheMapping); +class TCCBlockFormatter : public BlockFormatter { + public : + TCCBlockFormatter(EcalDigiToRaw* es) : BlockFormatter(es) {}; + static const int kCardsPerTower = 5; // Number of VFE cards per trigger tower + void DigiToRaw(const EcalTriggerPrimitiveDigi& trigprim, FEDRawData& rawdata, const EcalElectronicsMapping* TheMapping, int bx, int lv1) const; - private : - bool AllTPsamples_; + private : }; diff --git a/EventFilter/EcalDigiToRaw/interface/TowerBlockFormatter.h b/EventFilter/EcalDigiToRaw/interface/TowerBlockFormatter.h index ffee456b13b1c..64a90c3e90ad2 100644 --- a/EventFilter/EcalDigiToRaw/interface/TowerBlockFormatter.h +++ b/EventFilter/EcalDigiToRaw/interface/TowerBlockFormatter.h @@ -9,7 +9,7 @@ #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" #include "DataFormats/FEDRawData/interface/FEDRawData.h" #include "EventFilter/EcalDigiToRaw/interface/BlockFormatter.h" - +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h" @@ -17,25 +17,22 @@ // The crystals corresponding to a given FE in a given FED // - - class TowerBlockFormatter : public BlockFormatter { - public : - - TowerBlockFormatter(); - ~TowerBlockFormatter(); - static const int kCardsPerTower = 5; // Number of VFE cards per trigger tower - void DigiToRaw(const EBDataFrame& dataframe, FEDRawData& rawdata, const EcalElectronicsMapping* TheMapping); - void DigiToRaw(const EEDataFrame& dataframe, FEDRawData& rawdata, const EcalElectronicsMapping* TheMapping); - void StartEvent(); - void EndEvent(FEDRawDataCollection* productRawData); - - std::map >* GetFEDorder() {return FEDorder; } - - private : - std::map >* FEDmap; - std::map >* FEDorder; - + public : + struct FEDMapOrder { + std::map > fedmap {}; + std::map > fedorder {}; + FEDMapOrder() = default; + }; + + TowerBlockFormatter(EcalDigiToRaw *es) : BlockFormatter(es) {}; + static const int kCardsPerTower = 5; // Number of VFE cards per trigger tower + void DigiToRaw(const EBDataFrame& dataframe, FEDRawData& rawdata, const EcalElectronicsMapping* TheMapping, int bx, int lv1, FEDMapOrder &local) const; + void DigiToRaw(const EEDataFrame& dataframe, FEDRawData& rawdata, const EcalElectronicsMapping* TheMapping, int bx, int lv1, FEDMapOrder &local) const; + inline FEDMapOrder StartEvent() const {return FEDMapOrder();} + void EndEvent(FEDRawDataCollection* productRawData); + + private : }; diff --git a/EventFilter/EcalDigiToRaw/src/BlockFormatter.cc b/EventFilter/EcalDigiToRaw/src/BlockFormatter.cc index c4f4941923b7a..ed365216af58d 100644 --- a/EventFilter/EcalDigiToRaw/src/BlockFormatter.cc +++ b/EventFilter/EcalDigiToRaw/src/BlockFormatter.cc @@ -10,40 +10,21 @@ using namespace std; +using namespace edm; -BlockFormatter::BlockFormatter() { -} - -BlockFormatter::~BlockFormatter() { -} +BlockFormatter::BlockFormatter(EcalDigiToRaw* base) : + debug_(base -> GetDebug()), + doBarrel_(base -> GetDoBarrel()), + doEndCap_(base -> GetDoEndCap()), + plistDCCId_(base -> GetListDCCId()), + doTCC_(base -> GetDoTCC()), + doSR_(base -> GetDoSR()), + doTower_(base -> GetDoTower()) +{} +void BlockFormatter::DigiToRaw(FEDRawDataCollection* productRawData, int run_number, int orbit_number_, int bx, int lv1) const { -void BlockFormatter::SetParam(EcalDigiToRaw* base) { - - pcounter_ = (base -> GetCounter()); - debug_ = base -> GetDebug(); - porbit_number_ = (base -> GetOrbit()); - plv1_ = (base -> GetLV1()); - pbx_ = (base -> GetBX()); - prunnumber_ = (base -> GetRunNumber()); - doBarrel_ = base -> GetDoBarrel(); - doEndCap_ = base -> GetDoEndCap(); - plistDCCId_ = base -> GetListDCCId(); - doTCC_ = base -> GetDoTCC(); - doSR_ = base -> GetDoSR(); - doTower_ = base -> GetDoTower(); - -} - - -void BlockFormatter::DigiToRaw(FEDRawDataCollection* productRawData) { - - int run_number = *prunnumber_; - int orbit_number_ = *porbit_number_; - int bx = *pbx_; - int lv1 = *plv1_; - - if (debug_) cout << "in BlockFormatter::DigiToRaw run_number orbit_number bx lv1 " << dec << run_number << " " << + if (debug_) LogInfo("EcalDigiToRaw: ") << "in BlockFormatter::DigiToRaw run_number orbit_number bx lv1 " << dec << run_number << " " << orbit_number_ << " " << bx << " " << lv1 << endl; for (int idcc=1; idcc <= 54; idcc++) { @@ -106,9 +87,9 @@ void BlockFormatter::DigiToRaw(FEDRawDataCollection* productRawData) { -void BlockFormatter::print(FEDRawData& rawdata) { +void BlockFormatter::print(FEDRawData& rawdata) const{ int size = rawdata.size(); - cout << "Print RawData size " << dec << size << endl; + LogInfo("EcalDigiToRaw: ") << "Print RawData size " << dec << size << endl; unsigned char* pData = rawdata.data(); int n = size/8; @@ -122,8 +103,8 @@ void BlockFormatter::print(FEDRawData& rawdata) { -void BlockFormatter::CleanUp(FEDRawDataCollection* productRawData, - map >* FEDorder ) { +void BlockFormatter::CleanUp(FEDRawDataCollection& productRawData, + map >& FEDorder ) { for (int id=0; id < 36 + 18; id++) { @@ -131,7 +112,7 @@ void BlockFormatter::CleanUp(FEDRawDataCollection* productRawData, if ( (! doEndCap_) && (id <= 8 || id >= 45)) continue; int FEDid = FEDNumbering::MINECALFEDID + id +1; - FEDRawData& rawdata = productRawData -> FEDData(FEDid); + FEDRawData& rawdata = productRawData.FEDData(FEDid); // ---- if raw need not be made for a given fed, set its size to empty and return if ( find( (*plistDCCId_).begin(), (*plistDCCId_).end(), (id+1) ) == (*plistDCCId_).end() ) @@ -164,11 +145,11 @@ void BlockFormatter::CleanUp(FEDRawDataCollection* productRawData, // cout << " in BlockFormatter::CleanUp. FEDid = " << FEDid << " event_length*8 " << dec << event_length*8 << endl; - map >::iterator fen = FEDorder -> find(FEDid); + map >::iterator fen = FEDorder.find(FEDid); bool FED_has_data = true; - if (fen == FEDorder->end()) FED_has_data = false; - if (debug_ && (! FED_has_data)) cout << " FEDid is not in FEDorder ! " << endl; + if (fen == FEDorder.end()) FED_has_data = false; + if (debug_ && (! FED_has_data)) LogInfo("EcalDigiToRaw: ") << " FEDid is not in FEDorder ! " << endl; if ( ! FED_has_data) { int ch_status = 7; for (int iFE=1; iFE <= 68; iFE++) { @@ -199,7 +180,7 @@ void BlockFormatter::CleanUp(FEDRawDataCollection* productRawData, } -void BlockFormatter::PrintSizes(FEDRawDataCollection* productRawData) { +void BlockFormatter::PrintSizes(FEDRawDataCollection* productRawData) const { for (int id=0; id < 36 + 18; id++) { @@ -211,7 +192,7 @@ void BlockFormatter::PrintSizes(FEDRawDataCollection* productRawData) { int FEDid = FEDNumbering::MINECALFEDID + id; FEDRawData& rawdata = productRawData -> FEDData(FEDid); if (rawdata.size() > 0) - cout << "Size of FED id " << dec << FEDid << " is : " << dec << rawdata.size() << endl; + LogInfo("EcalDigiToRaw: ") << "Size of FED id " << dec << FEDid << " is : " << dec << rawdata.size() << endl; } } diff --git a/EventFilter/EcalDigiToRaw/src/EcalDigiToRaw.cc b/EventFilter/EcalDigiToRaw/src/EcalDigiToRaw.cc index 3654bcb783647..909c216653a4a 100644 --- a/EventFilter/EcalDigiToRaw/src/EcalDigiToRaw.cc +++ b/EventFilter/EcalDigiToRaw/src/EcalDigiToRaw.cc @@ -29,7 +29,6 @@ #include "DataFormats/FEDRawData/interface/FEDRawData.h" #include "DataFormats/FEDRawData/interface/FEDNumbering.h" - // #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/Common/interface/Handle.h" #include "FWCore/Framework/interface/EventSetup.h" @@ -39,65 +38,36 @@ #include "Geometry/EcalMapping/interface/EcalMappingRcd.h" - +//use make_unique using namespace edm; using namespace std; -EcalDigiToRaw::EcalDigiToRaw(const edm::ParameterSet& iConfig) +EcalDigiToRaw::EcalDigiToRaw(const edm::ParameterSet& iConfig) : + doTCC_(iConfig.getUntrackedParameter("WriteTCCBlock")), + doSR_(iConfig.getUntrackedParameter("WriteSRFlags")), + doTower_(iConfig.getUntrackedParameter("WriteTowerBlock")), + doBarrel_(iConfig.getUntrackedParameter("DoBarrel")), + doEndCap_(iConfig.getUntrackedParameter("DoEndCap")), + listDCCId_(iConfig.getUntrackedParameter< std::vector >("listDCCId")), + label_(iConfig.getParameter("Label")), + instanceNameEB_(iConfig.getParameter("InstanceEB")), + instanceNameEE_(iConfig.getParameter("InstanceEE")), + EBDigiToken_(consumes(edm::InputTag(label_,instanceNameEB_))), + EEDigiToken_(consumes(edm::InputTag(label_,instanceNameEE_))), + labelTT_(consumes(iConfig.getParameter("labelTT"))), + labelEBSR_(consumes(iConfig.getParameter("labelEBSRFlags"))), + labelEESR_(consumes(iConfig.getParameter("labelEESRFlags"))), + debug_(iConfig.getUntrackedParameter("debug")), + Towerblockformatter_(std::make_unique(this)), + TCCblockformatter_(std::make_unique(this)), + Headerblockformatter_(std::make_unique(this)), + SRblockformatter_(std::make_unique(this)) { - - doTCC_ = iConfig.getUntrackedParameter("WriteTCCBlock"); - doSR_ = iConfig.getUntrackedParameter("WriteSRFlags"); - doTower_ = iConfig.getUntrackedParameter("WriteTowerBlock"); - - doBarrel_ = iConfig.getUntrackedParameter("DoBarrel"); - doEndCap_ = iConfig.getUntrackedParameter("DoEndCap"); - - listDCCId_ = iConfig.getUntrackedParameter< std::vector >("listDCCId"); - label_= iConfig.getParameter("Label"); - instanceNameEB_ = iConfig.getParameter("InstanceEB"); - instanceNameEE_ = iConfig.getParameter("InstanceEE"); - - edm::InputTag EBlabel = edm::InputTag(label_,instanceNameEB_); - edm::InputTag EElabel = edm::InputTag(label_,instanceNameEE_); - - EBDigiToken_ = consumes(EBlabel); - EEDigiToken_ = consumes(EElabel); - - labelTT_ = consumes(iConfig.getParameter("labelTT")); - - labelEBSR_ = consumes(iConfig.getParameter("labelEBSRFlags")); - labelEESR_ = consumes(iConfig.getParameter("labelEESRFlags")); - - counter_ = 0; - debug_ = iConfig.getUntrackedParameter("debug"); - - - Towerblockformatter_ = new TowerBlockFormatter; - TCCblockformatter_ = new TCCBlockFormatter(); - SRblockformatter_ = new SRBlockFormatter(); - Headerblockformatter_= new BlockFormatter; - produces(); - - } -EcalDigiToRaw::~EcalDigiToRaw() -{ - - // do anything here that needs to be done at desctruction time - // (e.g. close files, deallocate resources etc.) - - delete Towerblockformatter_; - delete TCCblockformatter_; - delete SRblockformatter_; - delete Headerblockformatter_; - -} - // // member functions @@ -105,34 +75,31 @@ EcalDigiToRaw::~EcalDigiToRaw() // ------------ method called to for each event ------------ void -EcalDigiToRaw::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) +EcalDigiToRaw::produce(edm::StreamID id, edm::Event& iEvent, const edm::EventSetup& iSetup) const { - - if (debug_) cout << "Enter in EcalDigiToRaw::produce ... " << endl; +// change to loginfo + if (debug_) LogInfo("EcalDigiToRaw: ") << "Enter in EcalDigiToRaw::produce ... " << endl; ESHandle< EcalElectronicsMapping > ecalmapping; iSetup.get< EcalMappingRcd >().get(ecalmapping); const EcalElectronicsMapping* TheMapping = ecalmapping.product(); - Towerblockformatter_ -> StartEvent(); - SRblockformatter_ -> StartEvent(); + auto local = Towerblockformatter_ -> StartEvent(); + auto header = SRblockformatter_ -> StartEvent(); - runnumber_ = iEvent.id().run(); + auto runnum = iEvent.id().run(); - // bx_ = (counter_ % BXMAX); - // orbit_number_ = counter_ / BXMAX; - // counter_ ++; - counter_ = iEvent.id().event(); - bx_ = iEvent.bunchCrossing(); - orbit_number_ = iEvent.orbitNumber(); + auto counter = iEvent.id().event(); + auto bx = iEvent.bunchCrossing(); + auto orbitnumber = iEvent.orbitNumber(); - lv1_ = counter_ % (0x1<<24); + auto lv1 = counter % (0x1<<24); auto productRawData = std::make_unique(); - Headerblockformatter_ -> DigiToRaw(productRawData.get()); + Headerblockformatter_ -> DigiToRaw(productRawData.get(), runnum, orbitnumber, bx, lv1); // --------- Now the Trigger Block part @@ -145,7 +112,7 @@ EcalDigiToRaw::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) if (doTCC_) { - if (debug_) cout << "Creation of the TCC block " << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "Creation of the TCC block " << endl; // iEvent.getByType(ecalTrigPrim); iEvent.getByToken(labelTT_, ecalTrigPrim); @@ -165,7 +132,7 @@ EcalDigiToRaw::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) FEDRawData& rawdata = productRawData.get() -> FEDData(FEDid); // adding the primitive to the block - TCCblockformatter_ -> DigiToRaw(trigprim, rawdata, TheMapping); + TCCblockformatter_ -> DigiToRaw(trigprim, rawdata, TheMapping, bx, lv1); } // end loop on ecalTrigPrim @@ -173,7 +140,7 @@ EcalDigiToRaw::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) if (doSR_) { - if (debug_) cout << " Process the SR flags " << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << " Process the SR flags " << endl; if (doBarrel_) { @@ -189,11 +156,11 @@ EcalDigiToRaw::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) int Dccid = TheMapping -> DCCid(id); int DCC_Channel = TheMapping -> iTT(id); int FEDid = FEDNumbering::MINECALFEDID + Dccid; - // if (Dccid == 10) cout << "Dcc " << Dccid << " DCC_Channel " << DCC_Channel << " flag " << flag << endl; - if (debug_) cout << "will process SRblockformatter_ for FEDid " << dec << FEDid << endl; + // if (Dccid == 10) LogInfo("EcalDigiToRaw: ") << "Dcc " << Dccid << " DCC_Channel " << DCC_Channel << " flag " << flag << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "will process SRblockformatter_ for FEDid " << dec << FEDid << endl; FEDRawData& rawdata = productRawData.get() -> FEDData(FEDid); if (debug_) Headerblockformatter_ -> print(rawdata); - SRblockformatter_ -> DigiToRaw(Dccid,DCC_Channel,flag, rawdata); + SRblockformatter_ -> DigiToRaw(Dccid,DCC_Channel,flag, rawdata, bx, lv1, header); } } // end DoBarrel @@ -214,7 +181,7 @@ EcalDigiToRaw::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) int FEDid = FEDNumbering::MINECALFEDID + Dccid; FEDRawData& rawdata = productRawData.get() -> FEDData(FEDid); - SRblockformatter_ -> DigiToRaw(Dccid,DCC_Channel,flag, rawdata); + SRblockformatter_ -> DigiToRaw(Dccid,DCC_Channel,flag, rawdata, bx, lv1, header); } } // end doEndCap @@ -229,7 +196,7 @@ EcalDigiToRaw::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) if (doTower_) { if (doBarrel_) { - if (debug_) cout << "Creation of the TowerBlock ... Barrel case " << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "Creation of the TowerBlock ... Barrel case " << endl; iEvent.getByToken(EBDigiToken_,ebDigis); for (EBDigiCollection::const_iterator it=ebDigis -> begin(); it != ebDigis->end(); it++) { @@ -238,13 +205,13 @@ EcalDigiToRaw::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) int DCCid = TheMapping -> DCCid(ebdetid); int FEDid = FEDNumbering::MINECALFEDID + DCCid ; FEDRawData& rawdata = productRawData.get() -> FEDData(FEDid); - Towerblockformatter_ -> DigiToRaw(dataframe, rawdata, TheMapping); + Towerblockformatter_ -> DigiToRaw(dataframe, rawdata, TheMapping, bx, lv1-1, local); } } if (doEndCap_) { - if (debug_) cout << "Creation of the TowerBlock ... EndCap case " << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "Creation of the TowerBlock ... EndCap case " << endl; iEvent.getByToken(EEDigiToken_,eeDigis); for (EEDigiCollection::const_iterator it=eeDigis -> begin(); it != eeDigis->end(); it++) { @@ -254,7 +221,7 @@ EcalDigiToRaw::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) int DCCid = elid.dccId() ; int FEDid = FEDNumbering::MINECALFEDID + DCCid; FEDRawData& rawdata = productRawData.get() -> FEDData(FEDid); - Towerblockformatter_ -> DigiToRaw(dataframe, rawdata, TheMapping); + Towerblockformatter_ -> DigiToRaw(dataframe, rawdata, TheMapping, bx, lv1-1, local); } } @@ -264,13 +231,13 @@ EcalDigiToRaw::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) // -------- Clean up things ... - map >* FEDorder = Towerblockformatter_ -> GetFEDorder(); + //map > FEDorder = local.FEDorder; - Headerblockformatter_ -> CleanUp(productRawData.get(), FEDorder); + Headerblockformatter_ -> CleanUp(*(productRawData.get()), local.fedorder); /* - cout << "For FED 633 " << endl; + LogInfo("EcalDigiToRaw: ") << "For FED 633 " << endl; FEDRawData& rawdata = productRawData -> FEDData(633); Headerblockformatter_ -> print(rawdata); */ @@ -288,22 +255,8 @@ EcalDigiToRaw::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) } - -// ------------ method called once each job just before starting event loop ------------ -void -EcalDigiToRaw::beginJob() -{ - Headerblockformatter_ -> SetParam(this); - Towerblockformatter_ -> SetParam(this); - TCCblockformatter_ -> SetParam(this); - SRblockformatter_ -> SetParam(this); -} - -// ------------ method called once each job just after ending the event loop ------------ -void -EcalDigiToRaw::endJob() { -} - +// +// diff --git a/EventFilter/EcalDigiToRaw/src/SRBlockFormatter.cc b/EventFilter/EcalDigiToRaw/src/SRBlockFormatter.cc index 40a5afb85cbd4..99afae4b5e0ac 100644 --- a/EventFilter/EcalDigiToRaw/src/SRBlockFormatter.cc +++ b/EventFilter/EcalDigiToRaw/src/SRBlockFormatter.cc @@ -4,33 +4,14 @@ using namespace std; +using namespace edm; - -SRBlockFormatter::SRBlockFormatter() { - -} - -SRBlockFormatter::~SRBlockFormatter() { - -} - - -void SRBlockFormatter::StartEvent() { - if (debug_) cout << "enter in StartEvent. header_ size is " << header_.size() << endl; - header_ .clear() ; - if (debug_) cout << "after empty : header_ size is " << header_.size() << endl; - return; -} - -void SRBlockFormatter::DigiToRaw(int dccid, int dcc_channel, int flag, FEDRawData& rawdata) +void SRBlockFormatter::DigiToRaw(int dccid, int dcc_channel, int flag, FEDRawData& rawdata, int bx, int lv1, std::map& header) const { - if (debug_) cout << "enter in SRBlockFormatter::DigiToRaw " << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "enter in SRBlockFormatter::DigiToRaw " << endl; if (debug_) print(rawdata); - int bx = *pbx_; - int lv1 = *plv1_; - int Nrows_SRP = 5; // Both for Barrel and EndCap (without the header row) int SRid = (dccid -1) / 3 +1; @@ -39,17 +20,17 @@ void SRBlockFormatter::DigiToRaw(int dccid, int dcc_channel, int flag, FEDRawDat int SRP_index; int icode = 1000 * dccid + SRid; - if (debug_) cout << "size of header_ map is " << header_.size() << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "size of header map is " << header.size() << endl; - std::map::const_iterator it_header = header_.find(icode); + std::map::const_iterator it_header = header.find(icode); - if ( it_header != header_.end() ) { + if ( it_header != header.end() ) { SRP_index = rawdata.size() / 8 - Nrows_SRP; - if (debug_) cout << "This SRid is already there." << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "This SRid is already there." << endl; } else { - if (debug_) cout << "New SR Block added on Raw data " << endl; - header_[icode] = 1; + if (debug_) LogInfo("EcalDigiToRaw: ") << "New SR Block added on Raw data " << endl; + header[icode] = 1; SRP_index = rawdata.size() / 8; rawdata.resize (rawdata.size() + 8 + 8*Nrows_SRP); // 1 line for SRP header, 5 lines of data unsigned char* ppData = rawdata.data(); @@ -63,7 +44,7 @@ void SRBlockFormatter::DigiToRaw(int dccid, int dcc_channel, int flag, FEDRawDat ppData[8*SRP_index+6] = 0; ppData[8*SRP_index+7] = 0x80; SRP_index ++; - if (debug_) cout << "Added headers and empty lines : " << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "Added headers and empty lines : " << endl; if (debug_) print(rawdata); // -- put the B011 and B100 already, since for Endcap there can be empty @@ -89,8 +70,8 @@ void SRBlockFormatter::DigiToRaw(int dccid, int dcc_channel, int flag, FEDRawDat int kval = (jTT % 16) / 4; SRP_index += irow; - if (debug_) cout << "Now add SC to SRBlock " << dec << dcc_channel << " irow ival " << dec << irow << " " << dec << ival << endl; - if (debug_) cout << "new data will be added at line " << dec << SRP_index << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "Now add SC to SRBlock " << dec << dcc_channel << " irow ival " << dec << irow << " " << dec << ival << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "new data will be added at line " << dec << SRP_index << endl; unsigned char* buff = &pData[8*SRP_index]; diff --git a/EventFilter/EcalDigiToRaw/src/TCCBlockFormatter.cc b/EventFilter/EcalDigiToRaw/src/TCCBlockFormatter.cc index fe53701be50ed..2f59a5572e42b 100644 --- a/EventFilter/EcalDigiToRaw/src/TCCBlockFormatter.cc +++ b/EventFilter/EcalDigiToRaw/src/TCCBlockFormatter.cc @@ -10,27 +10,15 @@ using namespace std; - - -TCCBlockFormatter::TCCBlockFormatter() { - - AllTPsamples_ = false; -} - -TCCBlockFormatter::~TCCBlockFormatter() { - -} +using namespace edm; void TCCBlockFormatter::DigiToRaw(const EcalTriggerPrimitiveDigi& trigprim, - FEDRawData& rawdata, const EcalElectronicsMapping* TheMapping) + FEDRawData& rawdata, const EcalElectronicsMapping* TheMapping, int bx, int lv1) const { - if (debug_) cout << "enter in TCCBlockFormatter::DigiToRaw " << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "enter in TCCBlockFormatter::DigiToRaw " << endl; int HEADER_SIZE = 8 * 9; - int bx = *pbx_; - int lv1 = *plv1_; - const EcalTrigTowerDetId& detid = trigprim.id(); @@ -42,7 +30,7 @@ void TCCBlockFormatter::DigiToRaw(const EcalTriggerPrimitiveDigi& trigprim, if (TCCid < EcalElectronicsMapping::MIN_TCCID || TCCid > EcalElectronicsMapping::MAX_TCCID) - cout << "Wrong TCCid in TCCBlockFormatter::DigiToRaw " << endl; + LogInfo("EcalDigiToRaw: ") << "Wrong TCCid in TCCBlockFormatter::DigiToRaw " << endl; bool IsEndCap = ( (EcalElectronicsId::MIN_DCCID_EEM <= iDCC && iDCC <= EcalElectronicsId::MAX_DCCID_EEM) || (EcalElectronicsId::MIN_DCCID_EEP <= iDCC && iDCC <= EcalElectronicsId::MAX_DCCID_EEP) ); @@ -66,14 +54,13 @@ void TCCBlockFormatter::DigiToRaw(const EcalTriggerPrimitiveDigi& trigprim, int nsamples = trigprim.size(); - if (! AllTPsamples_) nsamples = 1; int iTT = TheMapping -> iTT(detid); // number of tp inside a fed - if (debug_) cout << "This is a TrigTower iDCC iTT iTCCBlock TCCid " << dec << + if (debug_) LogInfo("EcalDigiToRaw: ") << "This is a TrigTower iDCC iTT iTCCBlock TCCid " << dec << iDCC << " " << iTT << " " << itcc_block << " " << TCCid << endl; - if (debug_) cout << "ieta iphi " << dec << detid.ieta() << " " << detid.iphi() << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "ieta iphi " << dec << detid.ieta() << " " << detid.iphi() << endl; if (iTT <= 0 || iTT > NTT_max) { - cout << "invalid iTT " << iTT << endl; + LogInfo("EcalDigiToRaw: ") << "invalid iTT " << iTT << endl; return; } @@ -83,10 +70,10 @@ void TCCBlockFormatter::DigiToRaw(const EcalTriggerPrimitiveDigi& trigprim, if ((int)rawdata.size() != HEADER_SIZE) { FE_index = rawdata.size() / 8 - NTCC*(Nrows_TCC+1); // as far as raw data have been generated FE_index ++; // infer position in TCC block - if (debug_) cout << "TCCid already there. FE_index = " << FE_index << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "TCCid already there. FE_index = " << FE_index << endl; } else { - if (debug_) cout << "New TTCid added on Raw data, TTCid = " << dec << TCCid << " 0x" << hex << TCCid << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "New TTCid added on Raw data, TTCid = " << dec << TCCid << " 0x" << hex << TCCid << endl; FE_index = rawdata.size() / 8; // size in unites of 64 bits word int fe_index = FE_index; for (int iblock=0; iblock < NTCC; iblock++) { // do this once per fed in EB, four times in EE @@ -106,7 +93,7 @@ void TCCBlockFormatter::DigiToRaw(const EcalTriggerPrimitiveDigi& trigprim, fe_index += Nrows_TCC+1; rawdata.resize (rawdata.size() + 8*Nrows_TCC); // 17 lines of TPG data in EB, 8 in EE } - if (debug_) cout << "Added headers and empty lines : " << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "Added headers and empty lines : " << endl; if (debug_) print(rawdata); // -- put the B011 already, since for Endcap there can be empty @@ -133,16 +120,16 @@ void TCCBlockFormatter::DigiToRaw(const EcalTriggerPrimitiveDigi& trigprim, FE_index += irow; // ival is location inside a TP row; varies between 0-3 - if (debug_) cout << "Now add tower " << dec << iTT << " irow ival " << dec << irow << " " << dec << ival << endl; - if (debug_) cout << "new data will be added at line " << dec << FE_index << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "Now add tower " << dec << iTT << " irow ival " << dec << irow << " " << dec << ival << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "new data will be added at line " << dec << FE_index << endl; int fg = trigprim.fineGrain(); int et = trigprim.compressedEt(); int ttflag = trigprim.ttFlag(); if (debug_ && (ttflag != 0)) { - cout << "in TCCBlock : this tower has a non zero flag" << endl; - cout << "Fedid iTT flag " << dec << FEDid << " " << iTT << " " << "0x" << hex << ttflag << endl; + LogInfo("EcalDigiToRaw: ") << "in TCCBlock : this tower has a non zero flag" << endl; + LogInfo("EcalDigiToRaw: ") << "Fedid iTT flag " << dec << FEDid << " " << iTT << " " << "0x" << hex << ttflag << endl; } pData[8*FE_index + ival*2] = et & 0xFF; // ival is location inside a TP row; varies between 0-3; tp goes in bits 0-7 pData[8*FE_index + ival*2+1] = (ttflag<<1) + (fg&0x1); // fg follows in bit 8; ttfg is in bits 9-11 @@ -154,12 +141,12 @@ void TCCBlockFormatter::DigiToRaw(const EcalTriggerPrimitiveDigi& trigprim, pData[ibase+6] |= ((nsamples & 0x1)<<7); pData[ibase+7] |= ((nsamples & 0xE)>>1); } - if (debug_) cout << "pData[8*FE_index + ival*2+1] = " << hex << (int)pData[8*FE_index + ival*2+1] << endl; - if (debug_) cout << "ttflag ttflag<<1 " << hex << ttflag << " " << hex << (ttflag<<1) << endl; - if (debug_) cout << "fg&0x1 " << hex << (fg&0x1) << endl; - if (debug_) cout << "sum " << hex << ( (ttflag<<1) + (fg&0x1) ) << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "pData[8*FE_index + ival*2+1] = " << hex << (int)pData[8*FE_index + ival*2+1] << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "ttflag ttflag<<1 " << hex << ttflag << " " << hex << (ttflag<<1) << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "fg&0x1 " << hex << (fg&0x1) << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "sum " << hex << ( (ttflag<<1) + (fg&0x1) ) << endl; if (ival %2 == 1) pData[8*FE_index + ival*2+1] |= 0x60; - if (debug_) cout << "ttflag et fgbit " << hex << ttflag << " " << hex << et << " " << hex << fg << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "ttflag et fgbit " << hex << ttflag << " " << hex << et << " " << hex << fg << endl; if (debug_) print(rawdata); diff --git a/EventFilter/EcalDigiToRaw/src/TowerBlockFormatter.cc b/EventFilter/EcalDigiToRaw/src/TowerBlockFormatter.cc index 3b2ce3629cc68..b1a535aef7908 100644 --- a/EventFilter/EcalDigiToRaw/src/TowerBlockFormatter.cc +++ b/EventFilter/EcalDigiToRaw/src/TowerBlockFormatter.cc @@ -10,27 +10,12 @@ #include "DataFormats/FEDRawData/interface/FEDNumbering.h" using namespace std; - - -TowerBlockFormatter::TowerBlockFormatter() { - -} - -TowerBlockFormatter::~TowerBlockFormatter() { - -} - - +using namespace edm; void TowerBlockFormatter::DigiToRaw(const EBDataFrame& dataframe, FEDRawData& rawdata, - const EcalElectronicsMapping* TheMapping) + const EcalElectronicsMapping* TheMapping, int bx, int lv1, FEDMapOrder &local) const { - - int bx = *pbx_; - int lv1 = *plv1_ - 1; - - int rdsize = rawdata.size() / 8; // size in Word64 const EBDetId& ebdetid = dataframe.id(); @@ -47,15 +32,15 @@ void TowerBlockFormatter::DigiToRaw(const EBDataFrame& dataframe, FEDRawData& ra "TowerBlockFormatter::DigiToRaw : Invalid iFE " << iFE << endl; - map >::iterator fen = FEDorder -> find(FEDid); - map >::iterator fed = FEDmap -> find(FEDid); + map >::iterator fen = local.fedorder.find(FEDid); + map >::iterator fed = local.fedmap.find(FEDid); - if (fen == FEDorder -> end()) { - if (debug_) cout << "New FED in TowerBlockFormatter " << dec << FEDid << " 0x" << hex << FEDid << endl; + if (fen == local.fedorder.end()) { + if (debug_) LogInfo("EcalDigiToRaw: ") << "New FED in TowerBlockFormatter " << dec << FEDid << " 0x" << hex << FEDid << endl; map FEorder; - pair >::iterator, bool> t1 = FEDorder -> insert(map >::value_type(FEDid,FEorder)); + pair >::iterator, bool> t1 = local.fedorder.insert(map >::value_type(FEDid,FEorder)); map FEmap; - pair >::iterator, bool> t2 = FEDmap -> insert(map >::value_type(FEDid,FEmap)); + pair >::iterator, bool> t2 = local.fedmap.insert(map >::value_type(FEDid,FEmap)); fen = t1.first; fed = t2.first; } @@ -69,22 +54,22 @@ void TowerBlockFormatter::DigiToRaw(const EBDataFrame& dataframe, FEDRawData& ra if (fe != FEorder.end()) { FE_order = (*fe).second; map::iterator ff = FEmap.find(FE_order); - if (ff == FEmap.end()) cout << "Error with maps... " << endl; + if (ff == FEmap.end()) LogInfo("EcalDigiToRaw: ") << "Error with maps... " << endl; FE_index = (*ff).second; - if (debug_) cout << "FE already there, FE_index = " << dec << FE_index << " FEorder " << FE_order << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "FE already there, FE_index = " << dec << FE_index << " FEorder " << FE_order << endl; } else { - if (debug_) cout << "New FE in TowerBlockFormatter FE " << dec << iFE << " 0x" << hex << iFE << " in FED id " << dec << FEDid << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "New FE in TowerBlockFormatter FE " << dec << iFE << " 0x" << hex << iFE << " in FED id " << dec << FEDid << endl; int inser = rdsize; int number_FEs = FEorder.size() -1; FE_order = number_FEs+1; pair::iterator, bool> t2 = FEorder.insert(map::value_type(iFE,FE_order)); - if (! t2.second) cout << " FE insertion failed..."; + if (! t2.second) LogInfo("EcalDigiToRaw: ") << " FE insertion failed..."; pair::iterator, bool> tt = FEmap.insert(map::value_type(FE_order,inser)); fe = tt.first; FE_index = (*fe).second; - if (debug_) cout << "Build the Tower Block header for FE id " << iFE << " start at line " << rdsize << endl; - if (debug_) cout << "This is the Fe number (order) " << number_FEs+1 << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "Build the Tower Block header for FE id " << iFE << " start at line " << rdsize << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "This is the Fe number (order) " << number_FEs+1 << endl; rawdata.resize( 8*rdsize + 8); unsigned char* pData = rawdata.data(); pData[8*FE_index] = iFE & 0xFF; @@ -106,7 +91,7 @@ void TowerBlockFormatter::DigiToRaw(const EBDataFrame& dataframe, FEDRawData& ra int istrip = elid.stripId(); int ichannel = elid.xtalId(); - if (debug_) cout << "Now add crystal : strip channel " << dec << istrip << " " << ichannel << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "Now add crystal : strip channel " << dec << istrip << " " << ichannel << endl; unsigned char* pData = rawdata.data(); @@ -118,7 +103,7 @@ void TowerBlockFormatter::DigiToRaw(const EBDataFrame& dataframe, FEDRawData& ra if (n_add % 8 != 0) n_add = n_add/8 +1; else n_add = n_add/8; - if (debug_) cout << "will add " << n_add << " lines of 64 bits at line " << (FE_index+1) << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "will add " << n_add << " lines of 64 bits at line " << (FE_index+1) << endl; rawdata.resize( rawdata.size() + 8*n_add ); unsigned char* ppData = rawdata.data(); @@ -153,15 +138,15 @@ void TowerBlockFormatter::DigiToRaw(const EBDataFrame& dataframe, FEDRawData& ra } if (debug_) { - cout << "pData for this FED is now " << endl; + LogInfo("EcalDigiToRaw: ") << "pData for this FED is now " << endl; print(rawdata); } // and update the FEmap for this FED : for (int i=FE_order+1; i < (int)FEorder.size(); i++) { FEmap[i] += n_add; - if (debug_) cout << "FEmap updated for fe number " << dec << i << endl; - if (debug_) cout << " FEmap[" << i << "] = " << FEmap[i] << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "FEmap updated for fe number " << dec << i << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << " FEmap[" << i << "] = " << FEmap[i] << endl; } // update the block length @@ -183,7 +168,7 @@ void TowerBlockFormatter::EndEvent(FEDRawDataCollection* productRawData) { // order when reading the unsuppressed digis, but ganz durcheinander // when reading the SelectiveReadout_Suppressed digis. - if (debug_) cout << "enter in TowerBlockFormatter::EndEvent. First reorder the FE's. " << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "enter in TowerBlockFormatter::EndEvent. First reorder the FE's. " << endl; for (int idcc=1; idcc <= 54; idcc++) { @@ -192,11 +177,11 @@ void TowerBlockFormatter::EndEvent(FEDRawDataCollection* productRawData) { //if (idcc != 34) continue; int FEDid = FEDNumbering::MINECALFEDID + idcc; - // cout << "Process FED " << FEDid << endl; + // LogInfo("EcalDigiToRaw: ") << "Process FED " << FEDid << endl; FEDRawData& fedData = productRawData -> FEDData(FEDid); if (fedData.size() <= 16) continue; - if (debug_) cout << "This is FEDid = " << FEDid << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "This is FEDid = " << FEDid << endl; unsigned char * pData = fedData.data(); // Word64* words = reinterpret_cast(const_cast(pData)); @@ -220,12 +205,12 @@ void TowerBlockFormatter::EndEvent(FEDRawDataCollection* productRawData) { if (iTCCBlock_header < 0) iTCCBlock_header = iSRBlock_header; if (debug_) { - cout << "iDAQ_header = " << iDAQ_header << endl; - cout << " iDCC_header = " << iDCC_header << endl; - cout << " iTCCBlock_header = " << iTCCBlock_header << endl; - cout << " iSRBlock_header = " << iSRBlock_header << endl; - cout << " iTowerBlock_header = " << iTowerBlock_header << endl; - cout << " iDAQ_trailer = " << iDAQ_trailer << endl; + LogInfo("EcalDigiToRaw: ") << "iDAQ_header = " << iDAQ_header << endl; + LogInfo("EcalDigiToRaw: ") << " iDCC_header = " << iDCC_header << endl; + LogInfo("EcalDigiToRaw: ") << " iTCCBlock_header = " << iTCCBlock_header << endl; + LogInfo("EcalDigiToRaw: ") << " iSRBlock_header = " << iSRBlock_header << endl; + LogInfo("EcalDigiToRaw: ") << " iTowerBlock_header = " << iTowerBlock_header << endl; + LogInfo("EcalDigiToRaw: ") << " iDAQ_trailer = " << iDAQ_trailer << endl; } std::map FrontEnd; @@ -236,7 +221,7 @@ void TowerBlockFormatter::EndEvent(FEDRawDataCollection* productRawData) { while (iTowerBlock_header < iDAQ_trailer) { int fe = words[iTowerBlock_header] & 0xFF; int nlines = (words[iTowerBlock_header] >> 48) & 0x1FF; - if (debug_) cout << "This is FE number " << fe << "needs nlines = " << nlines << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "This is FE number " << fe << "needs nlines = " << nlines << endl; FrontEnd[fe] = nlines; std::vector xtal_data; for (int j=0; j < nlines; j++) { @@ -248,12 +233,12 @@ void TowerBlockFormatter::EndEvent(FEDRawDataCollection* productRawData) { } if (debug_) { - cout << "vector of FrontEnd : " << FrontEnd.size() << endl; + LogInfo("EcalDigiToRaw: ") << "vector of FrontEnd : " << FrontEnd.size() << endl; for (std::map::const_iterator it=FrontEnd.begin(); it != FrontEnd.end(); it++) { int fe = it -> first; int l = it -> second; - cout << "FE line " << fe << " " << l << endl; + LogInfo("EcalDigiToRaw: ") << "FE line " << fe << " " << l << endl; } } @@ -262,15 +247,15 @@ void TowerBlockFormatter::EndEvent(FEDRawDataCollection* productRawData) { it != FrontEnd.end(); it++) { int fe = it -> first; int nlines = it -> second; - if (debug_) cout << "iTowerBlock_header = " << iTowerBlock_header << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "iTowerBlock_header = " << iTowerBlock_header << endl; vector xtal_data = Map_xtal_data[fe]; for (int j=0; j < nlines; j++) { words[iTowerBlock_header+j] = xtal_data[j]; - if (debug_) cout << "update line " << iTowerBlock_header+j << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "update line " << iTowerBlock_header+j << endl; } if (debug_) { int jFE = pData[8*(iTowerBlock_header)]; - cout << "Front End on RD : " << jFE << endl; + LogInfo("EcalDigiToRaw: ") << "Front End on RD : " << jFE << endl; } iTowerBlock_header += nlines; } @@ -279,7 +264,7 @@ void TowerBlockFormatter::EndEvent(FEDRawDataCollection* productRawData) { // need : xtal 1,2,3,4, 5 in strip 1, xtal 1,2,3,4,5 in strip 2 etc.. // with possibly missing ones. - if (debug_) cout << "now reorder the xtals within the FEs" << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "now reorder the xtals within the FEs" << endl; iTowerBlock_header = iTowerBlock_header_keep; @@ -287,8 +272,8 @@ void TowerBlockFormatter::EndEvent(FEDRawDataCollection* productRawData) { it != FrontEnd.end(); it++) { int fe = it -> first; - if (fe > 68) cout << "Problem... fe = " << fe << " in FEDid = " << FEDid << endl; - if (debug_) cout << " This is for FE = " << fe << endl; + if (fe > 68) LogInfo("EcalDigiToRaw: ") << "Problem... fe = " << fe << " in FEDid = " << FEDid << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << " This is for FE = " << fe << endl; int nlines = it -> second; int timesamples = pData[8*iTowerBlock_header+1] & 0x7F; int n4=timesamples-3; @@ -336,22 +321,22 @@ void TowerBlockFormatter::EndEvent(FEDRawDataCollection* productRawData) { jt != Strip_Map.end(); jt++) { int strip = jt -> first; - if (debug_) cout << " this is strip number " << strip << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << " this is strip number " << strip << endl; map > Xtal_Map = jt -> second; for (map >::const_iterator kt = Xtal_Map.begin(); kt != Xtal_Map.end(); kt++) { int xtal = kt -> first; - if (debug_) cout << " this is xtal number " << xtal << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << " this is xtal number " << xtal << endl; vector xtal_data = kt -> second; int mlines = (int)xtal_data.size(); - if (debug_) cout << " mlines = " << mlines << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << " mlines = " << mlines << endl; for (int j=0; j < mlines; j++) { int line = iTowerBlock_header+1+idx+j; - if (line >= iDAQ_trailer) cout << "smth wrong... line " << line << " trailer " << iDAQ_trailer << endl; + if (line >= iDAQ_trailer) LogInfo("EcalDigiToRaw: ") << "smth wrong... line " << line << " trailer " << iDAQ_trailer << endl; words[line] = xtal_data[j] ; - if (debug_) cout << " updated line " << iTowerBlock_header+idx+j << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << " updated line " << iTowerBlock_header+idx+j << endl; } idx += mlines; @@ -366,41 +351,23 @@ void TowerBlockFormatter::EndEvent(FEDRawDataCollection* productRawData) { } // end loop on FEs - if (debug_) cout << " DONE FOR FED " << FEDid << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << " DONE FOR FED " << FEDid << endl; FrontEnd.clear(); Map_xtal_data.clear(); } // end loop on DCC - // cout << " finished reorder, now clean up " << endl; + // LogInfo("EcalDigiToRaw: ") << " finished reorder, now clean up " << endl; // -- clean up - // FEDmap -> empty(); - // FEDorder -> empty(); - FEDmap -> clear(); - FEDorder -> clear(); - delete FEDmap; - delete FEDorder; - FEDmap = 0; - FEDorder = 0; - - debug_ = false; - - // cout << "end of EndEvent " << endl; -} - -void TowerBlockFormatter::StartEvent() { + //debug_ = false; - FEDmap = new map >; - FEDorder = new map >; - + // LogInfo("EcalDigiToRaw: ") << "end of EndEvent " << endl; } - - -void TowerBlockFormatter::DigiToRaw(const EEDataFrame& dataframe, FEDRawData& rawdata, const EcalElectronicsMapping* TheMapping) +void TowerBlockFormatter::DigiToRaw(const EEDataFrame& dataframe, FEDRawData& rawdata, const EcalElectronicsMapping* TheMapping, int bx, int lv1, FEDMapOrder& local) const // -- now that we have the EcalElectronicsMapping, this method could probably be // merged with DigiToRaw(EBdataframe). @@ -409,10 +376,6 @@ void TowerBlockFormatter::DigiToRaw(const EEDataFrame& dataframe, FEDRawData& ra // debug_ = false; - int bx = *pbx_; - int lv1 = *plv1_; - - int rdsize = rawdata.size() / 8; // size in Word64 const EEDetId& eedetid = dataframe.id(); @@ -421,26 +384,26 @@ void TowerBlockFormatter::DigiToRaw(const EEDataFrame& dataframe, FEDRawData& ra int FEDid = FEDNumbering::MINECALFEDID + DCCid ; int iFE = elid.towerId(); - if (debug_) cout << "enter in TowerBlockFormatter::DigiToRaw DCCid FEDid iFE " << + if (debug_) LogInfo("EcalDigiToRaw: ") << "enter in TowerBlockFormatter::DigiToRaw DCCid FEDid iFE " << dec << DCCid << " " << FEDid << " " << iFE << endl; int nsamples = dataframe.size(); if (iFE <= 0 || iFE > 68) { - cout << "invalid iFE for EndCap DCCid iFE " << DCCid << " " << iFE << endl; + LogInfo("EcalDigiToRaw: ") << "invalid iFE for EndCap DCCid iFE " << DCCid << " " << iFE << endl; return; } - map >::iterator fen = FEDorder -> find(FEDid); - map >::iterator fed = FEDmap -> find(FEDid); + map >::iterator fen = local.fedorder.find(FEDid); + map >::iterator fed = local.fedmap.find(FEDid); - if (fen == FEDorder -> end()) { - if (debug_) cout << "New FED in TowerBlockFormatter " << dec << FEDid << " 0x" << hex << FEDid << endl; + if (fen == local.fedorder.end()) { + if (debug_) LogInfo("EcalDigiToRaw: ") << "New FED in TowerBlockFormatter " << dec << FEDid << " 0x" << hex << FEDid << endl; map FEorder; - pair >::iterator, bool> t1 = FEDorder -> insert(map >::value_type(FEDid,FEorder)); + pair >::iterator, bool> t1 = local.fedorder.insert(map >::value_type(FEDid,FEorder)); map FEmap; - pair >::iterator, bool> t2 = FEDmap -> insert(map >::value_type(FEDid,FEmap)); + pair >::iterator, bool> t2 = local.fedmap.insert(map >::value_type(FEDid,FEmap)); fen = t1.first; fed = t2.first; } @@ -454,22 +417,22 @@ void TowerBlockFormatter::DigiToRaw(const EEDataFrame& dataframe, FEDRawData& ra if (fe != FEorder.end()) { FE_order = (*fe).second; map::iterator ff = FEmap.find(FE_order); - if (ff == FEmap.end()) cout << "Error with maps... " << endl; + if (ff == FEmap.end()) LogInfo("EcalDigiToRaw: ") << "Error with maps... " << endl; FE_index = (*ff).second; - if (debug_) cout << "FE already there, FE_index = " << dec << FE_index << " FEorder " << FE_order << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "FE already there, FE_index = " << dec << FE_index << " FEorder " << FE_order << endl; } else { - if (debug_) cout << "New FE in TowerBlockFormatter FE " << dec << iFE << " 0x" << hex << iFE << " in FED id " << dec << FEDid << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "New FE in TowerBlockFormatter FE " << dec << iFE << " 0x" << hex << iFE << " in FED id " << dec << FEDid << endl; int inser = rdsize; int number_FEs = FEorder.size() -1; FE_order = number_FEs+1; pair::iterator, bool> t2 = FEorder.insert(map::value_type(iFE,FE_order)); - if (! t2.second) cout << " FE insertion failed..."; + if (! t2.second) LogInfo("EcalDigiToRaw: ") << " FE insertion failed..."; pair::iterator, bool> tt = FEmap.insert(map::value_type(FE_order,inser)); fe = tt.first; FE_index = (*fe).second; - if (debug_) cout << "Build the Tower Block header for FE id " << iFE << " start at line " << rdsize << endl; - if (debug_) cout << "This is the Fe number (order) " << number_FEs+1 << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "Build the Tower Block header for FE id " << iFE << " start at line " << rdsize << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "This is the Fe number (order) " << number_FEs+1 << endl; rawdata.resize( 8*rdsize + 8); unsigned char* pData = rawdata.data(); @@ -492,7 +455,7 @@ void TowerBlockFormatter::DigiToRaw(const EEDataFrame& dataframe, FEDRawData& ra int istrip = elid.stripId(); int ichannel = elid.xtalId(); - if (debug_) cout << "Now add crystal strip channel " << dec << istrip << " " << ichannel << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "Now add crystal strip channel " << dec << istrip << " " << ichannel << endl; unsigned char* pData = rawdata.data(); @@ -503,8 +466,8 @@ void TowerBlockFormatter::DigiToRaw(const EEDataFrame& dataframe, FEDRawData& ra if (n_add % 8 != 0) n_add = n_add/8 +1; else n_add = n_add/8; - if (debug_) cout << "nsamples = " << dec << nsamples << endl; - if (debug_) cout << "will add " << n_add << " lines of 64 bits at line " << (FE_index+1) << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "nsamples = " << dec << nsamples << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "will add " << n_add << " lines of 64 bits at line " << (FE_index+1) << endl; rawdata.resize( rawdata.size() + 8*n_add ); unsigned char* ppData = rawdata.data(); @@ -539,15 +502,15 @@ void TowerBlockFormatter::DigiToRaw(const EEDataFrame& dataframe, FEDRawData& ra } if (debug_) { - cout << "pData for this FED is now " << endl; + LogInfo("EcalDigiToRaw: ") << "pData for this FED is now " << endl; print(rawdata); } // and update the FEmap for this FED : for (int i=FE_order+1; i < (int)FEorder.size(); i++) { FEmap[i] += n_add; - if (debug_) cout << "FEmap updated for fe number " << dec << i << endl; - if (debug_) cout << " FEmap[" << i << "] = " << FEmap[i] << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << "FEmap updated for fe number " << dec << i << endl; + if (debug_) LogInfo("EcalDigiToRaw: ") << " FEmap[" << i << "] = " << FEmap[i] << endl; } // update the block length