diff --git a/EventFilter/SiPixelRawToDigi/interface/ErrorChecker.h b/EventFilter/SiPixelRawToDigi/interface/ErrorChecker.h index afe2b06412575..4152048b887bc 100644 --- a/EventFilter/SiPixelRawToDigi/interface/ErrorChecker.h +++ b/EventFilter/SiPixelRawToDigi/interface/ErrorChecker.h @@ -2,25 +2,16 @@ #define ErrorChecker_H /** \class ErrorChecker * - * + * */ -#include "DataFormats/SiPixelRawData/interface/SiPixelRawDataError.h" +#include "EventFilter/SiPixelRawToDigi/interface/ErrorCheckerBase.h" #include "FWCore/Utilities/interface/typedefs.h" -#include -#include - -class FEDRawData; - -class SiPixelFrameConverter; -class SiPixelFedCabling; - -class ErrorChecker { - +class ErrorChecker : public ErrorCheckerBase { public: -// typedef unsigned int Word32; -// typedef long long Word64; + // typedef unsigned int Word32; + // typedef long long Word64; typedef cms_uint32_t Word32; typedef cms_uint64_t Word64; @@ -29,30 +20,30 @@ class ErrorChecker { ErrorChecker(); - void setErrorStatus(bool ErrorStatus); + void setErrorStatus(bool ErrorStatus) override; - bool checkCRC(bool& errorsInEvent, int fedId, const Word64* trailer, Errors& errors); + bool checkCRC(bool &errorsInEvent, int fedId, const Word64 *trailer, + Errors &errors) override; - bool checkHeader(bool& errorsInEvent, int fedId, const Word64* header, Errors& errors); + bool checkHeader(bool &errorsInEvent, int fedId, const Word64 *header, + Errors &errors) override; - bool checkTrailer(bool& errorsInEvent, int fedId, unsigned int nWords, const Word64* trailer, Errors& errors); + bool checkTrailer(bool &errorsInEvent, int fedId, unsigned int nWords, + const Word64 *trailer, Errors &errors) override; - bool checkROC(bool& errorsInEvent, int fedId, const SiPixelFrameConverter* converter, - const SiPixelFedCabling* theCablingTree, - Word32& errorWord, Errors& errors); + bool checkROC(bool &errorsInEvent, int fedId, + const SiPixelFrameConverter *converter, + const SiPixelFedCabling *theCablingTree, Word32 &errorWord, + Errors &errors) override; - - - void conversionError(int fedId, const SiPixelFrameConverter* converter, - int status, Word32& errorWord, Errors& errors); + void conversionError(int fedId, const SiPixelFrameConverter *converter, + int status, Word32 &errorWord, Errors &errors) override; private: - bool includeErrors; - cms_uint32_t errorDetId(const SiPixelFrameConverter* converter, - int errorType, const Word32 & word) const; - + cms_uint32_t errorDetId(const SiPixelFrameConverter *converter, int errorType, + const Word32 &word) const override; }; #endif diff --git a/EventFilter/SiPixelRawToDigi/interface/ErrorCheckerBase.h b/EventFilter/SiPixelRawToDigi/interface/ErrorCheckerBase.h new file mode 100644 index 0000000000000..f42ecb178d24f --- /dev/null +++ b/EventFilter/SiPixelRawToDigi/interface/ErrorCheckerBase.h @@ -0,0 +1,54 @@ +#ifndef ErrorCheckerBase_H +#define ErrorCheckerBase_H +/** \class ErrorCheckerBase + * + * + */ + +#include "DataFormats/SiPixelRawData/interface/SiPixelRawDataError.h" + +#include +#include + +class SiPixelFrameConverter; +class SiPixelFedCabling; + +class ErrorCheckerBase { +public: + // typedef unsigned int Word32; + // typedef long long Word64; + typedef cms_uint32_t Word32; + typedef cms_uint64_t Word64; + + typedef std::vector DetErrors; + typedef std::map Errors; + + virtual ~ErrorCheckerBase(){}; + + virtual void setErrorStatus(bool ErrorStatus) = 0; + + virtual bool checkCRC(bool &errorsInEvent, int fedId, const Word64 *trailer, + Errors &errors) = 0; + + virtual bool checkHeader(bool &errorsInEvent, int fedId, const Word64 *header, + Errors &errors) = 0; + + virtual bool checkTrailer(bool &errorsInEvent, int fedId, unsigned int nWords, + const Word64 *trailer, Errors &errors) = 0; + + virtual bool checkROC(bool &errorsInEvent, int fedId, + const SiPixelFrameConverter *converter, + const SiPixelFedCabling *theCablingTree, + Word32 &errorWord, Errors &errors) = 0; + + virtual void conversionError(int fedId, + const SiPixelFrameConverter *converter, + int status, Word32 &errorWord, + Errors &errors) = 0; + +private: + virtual cms_uint32_t errorDetId(const SiPixelFrameConverter *converter, + int errorType, const Word32 &word) const = 0; +}; + +#endif diff --git a/EventFilter/SiPixelRawToDigi/interface/ErrorCheckerPhase0.h b/EventFilter/SiPixelRawToDigi/interface/ErrorCheckerPhase0.h new file mode 100644 index 0000000000000..9426b565fa93c --- /dev/null +++ b/EventFilter/SiPixelRawToDigi/interface/ErrorCheckerPhase0.h @@ -0,0 +1,49 @@ +#ifndef ErrorCheckerPhase0_H +#define ErrorCheckerPhase0_H +/** \class ErrorCheckerPhase0 + * + * + */ + +#include "EventFilter/SiPixelRawToDigi/interface/ErrorCheckerBase.h" +#include "FWCore/Utilities/interface/typedefs.h" + +class ErrorCheckerPhase0 : public ErrorCheckerBase { +public: + // typedef unsigned int Word32; + // typedef long long Word64; + typedef cms_uint32_t Word32; + typedef cms_uint64_t Word64; + + typedef std::vector DetErrors; + typedef std::map Errors; + + ErrorCheckerPhase0(); + + void setErrorStatus(bool ErrorStatus) override; + + bool checkCRC(bool &errorsInEvent, int fedId, const Word64 *trailer, + Errors &errors) override; + + bool checkHeader(bool &errorsInEvent, int fedId, const Word64 *header, + Errors &errors) override; + + bool checkTrailer(bool &errorsInEvent, int fedId, unsigned int nWords, + const Word64 *trailer, Errors &errors) override; + + bool checkROC(bool &errorsInEvent, int fedId, + const SiPixelFrameConverter *converter, + const SiPixelFedCabling *theCablingTree, Word32 &errorWord, + Errors &errors) override; + + void conversionError(int fedId, const SiPixelFrameConverter *converter, + int status, Word32 &errorWord, Errors &errors) override; + +private: + bool includeErrors; + + cms_uint32_t errorDetId(const SiPixelFrameConverter *converter, int errorType, + const Word32 &word) const override; +}; + +#endif diff --git a/EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h b/EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h index 47c312a091870..37cc569630126 100644 --- a/EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h +++ b/EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h @@ -34,17 +34,17 @@ // Add the phase1 format // #include "CondFormats/SiPixelObjects/interface/SiPixelFrameReverter.h" -#include "DataFormats/SiPixelDigi/interface/PixelDigi.h" #include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h" +#include "DataFormats/SiPixelDigi/interface/PixelDigi.h" #include "DataFormats/SiPixelRawData/interface/SiPixelRawDataError.h" -#include "DataFormats/Common/interface/DetSetVector.h" #include "EventFilter/SiPixelRawToDigi/interface/ErrorChecker.h" +#include "EventFilter/SiPixelRawToDigi/interface/ErrorCheckerPhase0.h" #include "FWCore/Utilities/interface/typedefs.h" -#include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h" -#include #include #include +#include class FEDRawData; class SiPixelFedCabling; @@ -54,15 +54,13 @@ class SiPixelFrameReverter; class SiPixelFedCablingTree; class PixelDataFormatter { - public: - typedef edm::DetSetVector Collection; typedef std::map RawData; typedef std::vector DetDigis; typedef std::map Digis; - typedef std::pair Range; + typedef std::pair Range; typedef std::vector DetErrors; typedef std::map Errors; typedef std::vector DetBadChannels; @@ -71,68 +69,67 @@ class PixelDataFormatter { typedef cms_uint32_t Word32; typedef cms_uint64_t Word64; - PixelDataFormatter(const SiPixelFedCabling* map, bool phase1=false); + PixelDataFormatter(const SiPixelFedCabling *map, bool phase1 = false); void setErrorStatus(bool ErrorStatus); - void setQualityStatus(bool QualityStatus, const SiPixelQuality* QualityInfo); - void setModulesToUnpack(const std::set * moduleIds); - void passFrameReverter(const SiPixelFrameReverter* reverter); + void setQualityStatus(bool QualityStatus, const SiPixelQuality *QualityInfo); + void setModulesToUnpack(const std::set *moduleIds); + void passFrameReverter(const SiPixelFrameReverter *reverter); int nDigis() const { return theDigiCounter; } int nWords() const { return theWordCounter; } - void interpretRawData(bool& errorsInEvent, int fedId, const FEDRawData & data, Collection & digis, Errors & errors); + void interpretRawData(bool &errorsInEvent, int fedId, const FEDRawData &data, + Collection &digis, Errors &errors); - void formatRawData( unsigned int lvl1_ID, RawData & fedRawData, const Digis & digis, const BadChannels & badChannels); + void formatRawData(unsigned int lvl1_ID, RawData &fedRawData, + const Digis &digis, const BadChannels &badChannels); - cms_uint32_t linkId(cms_uint32_t word32) { return (word32 >> LINK_shift) & LINK_mask; } + cms_uint32_t linkId(cms_uint32_t word32) { + return (word32 >> LINK_shift) & LINK_mask; + } private: mutable int theDigiCounter; mutable int theWordCounter; - SiPixelFedCabling const * theCablingTree; - const SiPixelFrameReverter* theFrameReverter; - const SiPixelQuality* badPixelInfo; - const std::set * modulesToUnpack; + SiPixelFedCabling const *theCablingTree; + const SiPixelFrameReverter *theFrameReverter; + const SiPixelQuality *badPixelInfo; + const std::set *modulesToUnpack; bool includeErrors; bool useQualityInfo; bool debug; int allDetDigis; int hasDetDigis; - ErrorChecker errorcheck; - - // For the 32bit data format (moved from *.cc namespace, keep uppercase for compatibility) - // Add special layer 1 roc for phase1 - int ADC_shift, PXID_shift, DCOL_shift, ROC_shift, LINK_shift, - ROW_shift, COL_shift; - Word32 LINK_mask, ROC_mask, DCOL_mask, PXID_mask, ADC_mask, - ROW_mask, COL_mask; + std::unique_ptr errorcheck; + + // For the 32bit data format (moved from *.cc namespace, keep uppercase for + // compatibility) Add special layer 1 roc for phase1 + int ADC_shift, PXID_shift, DCOL_shift, ROC_shift, LINK_shift, ROW_shift, + COL_shift; + Word32 LINK_mask, ROC_mask, DCOL_mask, PXID_mask, ADC_mask, ROW_mask, + COL_mask; int maxROCIndex; bool phase1; + int checkError(const Word32 &data) const; - int checkError(const Word32& data) const; - - int digi2word( cms_uint32_t detId, const PixelDigi& digi, - std::map > & words) const; - int digi2wordPhase1Layer1( cms_uint32_t detId, const PixelDigi& digi, - std::map > & words) const; - - int word2digi( const int fedId, - const SiPixelFrameConverter* converter, - const bool includeError, - const bool useQuality, - const Word32& word, - Digis & digis) const; + int digi2word(cms_uint32_t detId, const PixelDigi &digi, + std::map> &words) const; + int digi2wordPhase1Layer1(cms_uint32_t detId, const PixelDigi &digi, + std::map> &words) const; - std::string print(const PixelDigi & digi) const; - std::string print(const Word64 & word) const; + int word2digi(const int fedId, const SiPixelFrameConverter *converter, + const bool includeError, const bool useQuality, + const Word32 &word, Digis &digis) const; - cms_uint32_t errorDetId(const SiPixelFrameConverter* converter, - int fedId, int errorType, const Word32 & word) const; + std::string print(const PixelDigi &digi) const; + std::string print(const Word64 &word) const; + cms_uint32_t errorDetId(const SiPixelFrameConverter *converter, int fedId, + int errorType, const Word32 &word) const; }; #endif diff --git a/EventFilter/SiPixelRawToDigi/interface/PixelUnpackingRegions.h b/EventFilter/SiPixelRawToDigi/interface/PixelUnpackingRegions.h index d0b4b5ab95fbb..6844d7fefdbe6 100644 --- a/EventFilter/SiPixelRawToDigi/interface/PixelUnpackingRegions.h +++ b/EventFilter/SiPixelRawToDigi/interface/PixelUnpackingRegions.h @@ -1,13 +1,13 @@ #ifndef PixelUnpackingRegions_H #define PixelUnpackingRegions_H -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/ESWatcher.h" -#include "DataFormats/Math/interface/Point3D.h" -#include "DataFormats/Math/interface/Vector3D.h" #include "DataFormats/BeamSpot/interface/BeamSpot.h" #include "DataFormats/Candidate/interface/LeafCandidate.h" +#include "DataFormats/Math/interface/Point3D.h" +#include "DataFormats/Math/interface/Vector3D.h" +#include "FWCore/Framework/interface/ESWatcher.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" #include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h" #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h" @@ -15,56 +15,51 @@ #include "FWCore/Framework/interface/ConsumesCollector.h" #include -#include #include - +#include /** \class PixelUnpackingRegions * * Input: One or several collections of Candidate-based seeds with their objects - * defining the directions of unpacking regions; separate deltaPhi and maxZ - * tolerances could be given to each input collection. - * Output: FED ids and module detIds that need to be unpacked + * defining the directions of unpacking regions; separate deltaPhi and + * maxZ tolerances could be given to each input collection. Output: FED ids and + * module detIds that need to be unpacked * */ -class PixelUnpackingRegions -{ +class PixelUnpackingRegions { public: - /// container to define regions for objects of interest in each event by: /// object direction /// dphi max distance from region direction to center of a pixel module - /// maxZ max projected z of a pixel module (when projecting along region direction onto beamline) - struct Region - { - Region(const math::XYZVector &dir, float dphi = 0.5f, float maxz = 24.f): - v(dir), dPhi(dphi), maxZ(maxz) - { - cosphi = v.x()/v.rho(); - sinphi = v.y()/v.rho(); - atantheta = v.z()/v.rho(); + /// maxZ max projected z of a pixel module (when projecting along region + /// direction onto beamline) + struct Region { + Region(const math::XYZVector &dir, float dphi = 0.5f, float maxz = 24.f) + : v(dir), dPhi(dphi), maxZ(maxz) { + cosphi = v.x() / v.rho(); + sinphi = v.y() / v.rho(); + atantheta = v.z() / v.rho(); } math::XYZVector v; float dPhi, maxZ; float cosphi, sinphi, atantheta; }; - - PixelUnpackingRegions(const edm::ParameterSet&, edm::ConsumesCollector &&iC); + PixelUnpackingRegions(const edm::ParameterSet &, edm::ConsumesCollector &&iC); ~PixelUnpackingRegions() {} /// has to be run during each event - void run(const edm::Event& e, const edm::EventSetup& es); + void run(const edm::Event &e, const edm::EventSetup &es); /// check whether a FED has to be unpacked bool mayUnpackFED(unsigned int fed_n) const; /// check whether a module has to be unpacked bool mayUnpackModule(unsigned int id) const; - + /// full set of module ids to unpack - const std::set * modulesToUnpack() const {return &modules_;} + const std::set *modulesToUnpack() const { return &modules_; } /// various informational accessors: unsigned int nFEDs() const { return feds_.size(); } @@ -73,8 +68,7 @@ class PixelUnpackingRegions unsigned int nForwardModules() const; unsigned int nRegions() const { return nreg_; } - struct Module - { + struct Module { float phi; float x, y, z; unsigned int id; @@ -83,16 +77,16 @@ class PixelUnpackingRegions Module() {} Module(float ph) : phi(ph), x(0.f), y(0.f), z(0.f), id(0), fed(0) {} - bool operator < (const Module& m) const - { - if(phi < m.phi) return true; - if(phi == m.phi && id < m.id) return true; + bool operator<(const Module &m) const { + if (phi < m.phi) + return true; + if (phi == m.phi && id < m.id) + return true; return false; } }; private: - // input parameters std::vector inputs_; std::vector dPhi_; @@ -107,16 +101,18 @@ class PixelUnpackingRegions unsigned int nreg_; /// run by the run method: (re)initialize the cabling data when it's necessary - void initialize(const edm::EventSetup& es); + void initialize(const edm::EventSetup &es); // add a new direction of a region of interest void addRegion(Region &r); // gather info into feds_ and modules_ from a range of a Module vector - void gatherFromRange(Region &r, std::vector::const_iterator, std::vector::const_iterator); + void gatherFromRange(Region &r, std::vector::const_iterator, + std::vector::const_iterator); // addRegion for a local (BPIX or +-FPIX) container - void addRegionLocal(Region &r, std::vector &container, const Module& lo,const Module& hi); + void addRegionLocal(Region &r, std::vector &container, + const Module &lo, const Module &hi); // local containers of barrel and endcaps Modules sorted by phi std::vector phiBPIX_; diff --git a/EventFilter/SiPixelRawToDigi/plugins/SiPixelDigiToRaw.cc b/EventFilter/SiPixelRawToDigi/plugins/SiPixelDigiToRaw.cc index bd8244d7527db..1bfad2f9c9b74 100644 --- a/EventFilter/SiPixelRawToDigi/plugins/SiPixelDigiToRaw.cc +++ b/EventFilter/SiPixelRawToDigi/plugins/SiPixelDigiToRaw.cc @@ -1,14 +1,14 @@ -#include "FWCore/Framework/interface/ESWatcher.h" -#include "FWCore/Framework/interface/global/EDProducer.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "FWCore/Utilities/interface/CPUTimer.h" #include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h" #include "CondFormats/SiPixelObjects/interface/SiPixelFrameReverter.h" #include "DataFormats/Common/interface/DetSetVector.h" #include "DataFormats/SiPixelDigi/interface/PixelDigi.h" +#include "FWCore/Framework/interface/ESWatcher.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/global/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/CPUTimer.h" +#include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -20,15 +20,15 @@ #include "FWCore/Utilities/interface/thread_safety_macros.h" #include "DataFormats/Common/interface/DetSetVector.h" -#include "DataFormats/SiPixelDigi/interface/PixelDigi.h" -#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" #include "DataFormats/FEDRawData/interface/FEDRawData.h" +#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" +#include "DataFormats/SiPixelDigi/interface/PixelDigi.h" #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h" #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingTree.h" -#include "EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h" #include "CondFormats/SiPixelObjects/interface/PixelFEDCabling.h" +#include "EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h" #include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h" @@ -36,124 +36,129 @@ #include namespace sipixeldigitoraw { - struct Cache { - std::unique_ptr cablingTree_; - std::unique_ptr frameReverter_; - }; -} +struct Cache { + std::unique_ptr cablingTree_; + std::unique_ptr frameReverter_; +}; +} // namespace sipixeldigitoraw namespace pr = sipixeldigitoraw; -class SiPixelDigiToRaw final : public edm::global::EDProducer> { +class SiPixelDigiToRaw final + : public edm::global::EDProducer> { public: - /// ctor - explicit SiPixelDigiToRaw( const edm::ParameterSet& ); - + explicit SiPixelDigiToRaw(const edm::ParameterSet &); /// get data, convert to raw event, attach again to Event - void produce( edm::StreamID, edm::Event&, const edm::EventSetup& ) const final; + void produce(edm::StreamID, edm::Event &, + const edm::EventSetup &) const final; + + std::shared_ptr + globalBeginLuminosityBlock(edm::LuminosityBlock const &, + edm::EventSetup const &iES) const final; - std::shared_ptr globalBeginLuminosityBlock(edm::LuminosityBlock const&, - edm::EventSetup const& iES) const final; + void globalEndLuminosityBlock(edm::LuminosityBlock const &, + edm::EventSetup const &iES) const final {} - void globalEndLuminosityBlock(edm::LuminosityBlock const&, - edm::EventSetup const& iES) const final {} - // Fill parameters descriptions - static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); private: - mutable std::atomic_flag lock_ = ATOMIC_FLAG_INIT; - CMS_THREAD_GUARD(lock_) mutable edm::ESWatcher recordWatcher; + CMS_THREAD_GUARD(lock_) + mutable edm::ESWatcher recordWatcher; CMS_THREAD_GUARD(lock_) mutable std::shared_ptr previousCache_; - const edm::EDGetTokenT> tPixelDigi; + const edm::EDGetTokenT> tPixelDigi; const edm::EDGetTokenT theBadPixelFEDChannelsToken; const edm::EDPutTokenT putToken_; - const bool usePilotBlade = false; // I am not yet sure we need it here? + const bool usePilotBlade = false; // I am not yet sure we need it here? const bool usePhase1; }; using namespace std; -SiPixelDigiToRaw::SiPixelDigiToRaw( const edm::ParameterSet& pset ) : - tPixelDigi{ consumes >(pset.getParameter("InputLabel")) }, - theBadPixelFEDChannelsToken{ consumes(pset.getParameter("InputLabel")) }, - putToken_{produces()}, - usePhase1{ pset.getParameter ("UsePhase1") } -{ - - +SiPixelDigiToRaw::SiPixelDigiToRaw(const edm::ParameterSet &pset) + : tPixelDigi{consumes>( + pset.getParameter("InputLabel"))}, + theBadPixelFEDChannelsToken{consumes( + pset.getParameter("InputLabel"))}, + putToken_{produces()}, usePhase1{ + pset.getParameter( + "UsePhase1")} { // Define EDProduct type - if(usePhase1) edm::LogInfo("SiPixelRawToDigi") << " Use pilot blade data (FED 40)"; - + if (usePhase1) + edm::LogInfo("SiPixelRawToDigi") << " Use pilot blade data (FED 40)"; } // ----------------------------------------------------------------------------- -std::shared_ptr -SiPixelDigiToRaw::globalBeginLuminosityBlock(edm::LuminosityBlock const&, - edm::EventSetup const& es) const { - while(lock_.test_and_set(std::memory_order_acquire)); //spin - auto rel = [](std::atomic_flag* f) { f->clear(std::memory_order_release); }; +std::shared_ptr +SiPixelDigiToRaw::globalBeginLuminosityBlock(edm::LuminosityBlock const &, + edm::EventSetup const &es) const { + while (lock_.test_and_set(std::memory_order_acquire)) + ; // spin + auto rel = [](std::atomic_flag *f) { f->clear(std::memory_order_release); }; std::unique_ptr guard(&lock_, rel); - if (recordWatcher.check( es )) { + if (recordWatcher.check(es)) { edm::ESHandle cablingMap; - es.get().get( cablingMap ); + es.get().get(cablingMap); previousCache_ = std::make_shared(); - previousCache_->cablingTree_= cablingMap->cablingTree(); - previousCache_->frameReverter_ = std::make_unique( es, cablingMap.product() ); + previousCache_->cablingTree_ = cablingMap->cablingTree(); + previousCache_->frameReverter_ = + std::make_unique(es, cablingMap.product()); } return previousCache_; } - - // ----------------------------------------------------------------------------- -void SiPixelDigiToRaw::produce( edm::StreamID, edm::Event& ev, - const edm::EventSetup& es) const -{ +void SiPixelDigiToRaw::produce(edm::StreamID, edm::Event &ev, + const edm::EventSetup &es) const { using namespace sipixelobjects; - edm::Handle< edm::DetSetVector > digiCollection; - ev.getByToken( tPixelDigi, digiCollection); + edm::Handle> digiCollection; + ev.getByToken(tPixelDigi, digiCollection); PixelDataFormatter::RawData rawdata; PixelDataFormatter::Digis digis; - int digiCounter = 0; - for (auto const& di : *digiCollection) { - digiCounter += (di.data).size(); - digis[ di.id] = di.data; + int digiCounter = 0; + for (auto const &di : *digiCollection) { + digiCounter += (di.data).size(); + digis[di.id] = di.data; } - auto cache = luminosityBlockCache(ev.getLuminosityBlock().index()); - + auto cache = luminosityBlockCache(ev.getLuminosityBlock().index()); LogDebug("SiPixelDigiToRaw") << cache->cablingTree_->version(); PixelDataFormatter::BadChannels badChannels; edm::Handle pixelFEDChannelCollectionHandle; - if (ev.getByToken(theBadPixelFEDChannelsToken, pixelFEDChannelCollectionHandle)){ - for (auto const& fedChannels: *pixelFEDChannelCollectionHandle) { + if (usePhase1 == true && ev.getByToken(theBadPixelFEDChannelsToken, + pixelFEDChannelCollectionHandle)) { + for (auto const &fedChannels : *pixelFEDChannelCollectionHandle) { PixelDataFormatter::DetBadChannels detBadChannels; - for(const auto& fedChannel: fedChannels) { - sipixelobjects::CablingPathToDetUnit path={fedChannel.fed, fedChannel.link, 1}; - if (cache->cablingTree_->findItem(path)!=nullptr) { - detBadChannels.push_back(fedChannel); - } else { - edm::LogError("SiPixelDigiToRaw") - <<" FED "<cablingTree_->findItem(path) != nullptr) { + detBadChannels.push_back(fedChannel); + } else { + edm::LogError("SiPixelDigiToRaw") + << " FED " << fedChannel.fed << " Link " << fedChannel.link + << " for module " << fedChannels.detId() + << " marked bad, but this channel does not exist in the cabling " + "map" + << endl; + } } // channels reading a module - if (!detBadChannels.empty()) badChannels.insert({fedChannels.detId(), std::move(detBadChannels)}); + if (!detBadChannels.empty()) + badChannels.insert({fedChannels.detId(), std::move(detBadChannels)}); } // loop on detId-s } - //PixelDataFormatter formatter(cablingTree_.get()); + // PixelDataFormatter formatter(cablingTree_.get()); PixelDataFormatter formatter(cache->cablingTree_.get(), usePhase1); formatter.passFrameReverter(cache->frameReverter_.get()); @@ -162,33 +167,34 @@ void SiPixelDigiToRaw::produce( edm::StreamID, edm::Event& ev, FEDRawDataCollection buffers; // convert data to raw - formatter.formatRawData( ev.id().event(), rawdata, digis, badChannels); + formatter.formatRawData(ev.id().event(), rawdata, digis, badChannels); // pack raw data into collection - for (auto const* fed: cache->cablingTree_->fedList()) { - LogDebug("SiPixelDigiToRaw")<<" PRODUCE DATA FOR FED_id: " << fed->id(); - FEDRawData& fedRawData = buffers.FEDData( fed->id() ); - PixelDataFormatter::RawData::iterator fedbuffer = rawdata.find( fed->id() ); - if( fedbuffer != rawdata.end() ) fedRawData = fedbuffer->second; - LogDebug("SiPixelDigiToRaw")<<"size of data in fedRawData: "<cablingTree_->fedList()) { + LogDebug("SiPixelDigiToRaw") << " PRODUCE DATA FOR FED_id: " << fed->id(); + FEDRawData &fedRawData = buffers.FEDData(fed->id()); + PixelDataFormatter::RawData::iterator fedbuffer = rawdata.find(fed->id()); + if (fedbuffer != rawdata.end()) + fedRawData = fedbuffer->second; + LogDebug("SiPixelDigiToRaw") + << "size of data in fedRawData: " << fedRawData.size(); } LogDebug("SiPixelDigiToRaw").log([&](auto &l) { - - l << "Words/Digis this ev: "<("InputLabel"); desc.add("UsePhase1", false); desc.addUntracked("Timing", false)->setComment("deprecated"); - descriptions.add("siPixelRawData", desc); + descriptions.add("siPixelRawData", desc); } // declare this as a framework plugin diff --git a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc index 1c08c35009918..2e0fc6b8f0b3e 100644 --- a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc +++ b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.cc @@ -21,13 +21,13 @@ #include "DataFormats/SiPixelRawData/interface/SiPixelRawDataError.h" #include "DataFormats/Common/interface/DetSetVector.h" -#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" #include "DataFormats/FEDRawData/interface/FEDRawData.h" +#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" -#include "DataFormats/FEDRawData/interface/FEDNumbering.h" -#include "DataFormats/DetId/interface/DetIdCollection.h" #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h" #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingTree.h" +#include "DataFormats/DetId/interface/DetIdCollection.h" +#include "DataFormats/FEDRawData/interface/FEDNumbering.h" #include "EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h" #include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h" @@ -36,290 +36,326 @@ #include "EventFilter/SiPixelRawToDigi/interface/PixelUnpackingRegions.h" #include "FWCore/Framework/interface/ConsumesCollector.h" -#include "TH1D.h" #include "TFile.h" +#include "TH1D.h" using namespace std; // ----------------------------------------------------------------------------- -SiPixelRawToDigi::SiPixelRawToDigi( const edm::ParameterSet& conf ) - : config_(conf), - badPixelInfo_(nullptr), - regions_(nullptr), - hCPU(nullptr), hDigi(nullptr) -{ - +SiPixelRawToDigi::SiPixelRawToDigi(const edm::ParameterSet &conf) + : config_(conf), badPixelInfo_(nullptr), regions_(nullptr), hCPU(nullptr), + hDigi(nullptr) { includeErrors = config_.getParameter("IncludeErrors"); useQuality = config_.getParameter("UseQualityInfo"); if (config_.exists("ErrorList")) { - tkerrorlist = config_.getParameter > ("ErrorList"); + tkerrorlist = config_.getParameter>("ErrorList"); } if (config_.exists("UserErrorList")) { - usererrorlist = config_.getParameter > ("UserErrorList"); + usererrorlist = config_.getParameter>("UserErrorList"); } - tFEDRawDataCollection = consumes (config_.getParameter("InputLabel")); - - //start counters + tFEDRawDataCollection = consumes( + config_.getParameter("InputLabel")); + + // start counters ndigis = 0; nwords = 0; // Products - produces< edm::DetSetVector >(); - if(includeErrors){ - produces< edm::DetSetVector >(); + produces>(); + if (includeErrors) { + produces>(); produces(); produces("UserErrorModules"); - produces >(); + produces>(); } - + // regions if (config_.exists("Regions")) { - if(!config_.getParameter("Regions").getParameterNames().empty()) - { + if (!config_.getParameter("Regions") + .getParameterNames() + .empty()) { regions_ = new PixelUnpackingRegions(config_, consumesCollector()); } } // Timing - bool timing = config_.getUntrackedParameter("Timing",false); + bool timing = config_.getUntrackedParameter("Timing", false); if (timing) { - theTimer.reset( new edm::CPUTimer ); - hCPU = new TH1D ("hCPU","hCPU",100,0.,0.050); - hDigi = new TH1D("hDigi","hDigi",50,0.,15000.); + theTimer.reset(new edm::CPUTimer); + hCPU = new TH1D("hCPU", "hCPU", 100, 0., 0.050); + hDigi = new TH1D("hDigi", "hDigi", 50, 0., 15000.); } // Control the usage of pilot-blade data, FED=40 - usePilotBlade = false; + usePilotBlade = false; if (config_.exists("UsePilotBlade")) { - usePilotBlade = config_.getParameter ("UsePilotBlade"); - if(usePilotBlade) edm::LogInfo("SiPixelRawToDigi") << " Use pilot blade data (FED 40)"; + usePilotBlade = config_.getParameter("UsePilotBlade"); + if (usePilotBlade) + edm::LogInfo("SiPixelRawToDigi") << " Use pilot blade data (FED 40)"; } // Control the usage of phase1 usePhase1 = false; if (config_.exists("UsePhase1")) { - usePhase1 = config_.getParameter ("UsePhase1"); - if(usePhase1) edm::LogInfo("SiPixelRawToDigi") << " Using phase1"; + usePhase1 = config_.getParameter("UsePhase1"); + if (usePhase1) + edm::LogInfo("SiPixelRawToDigi") << " Using phase1"; } - //CablingMap could have a label //Tav - cablingMapLabel = config_.getParameter ("CablingMapLabel"); - + // CablingMap could have a label //Tav + cablingMapLabel = config_.getParameter("CablingMapLabel"); } - // ----------------------------------------------------------------------------- SiPixelRawToDigi::~SiPixelRawToDigi() { - edm::LogInfo("SiPixelRawToDigi") << " HERE ** SiPixelRawToDigi destructor!"; + edm::LogInfo("SiPixelRawToDigi") << " HERE ** SiPixelRawToDigi destructor!"; - if (regions_) delete regions_; + if (regions_) + delete regions_; if (theTimer) { TFile rootFile("analysis.root", "RECREATE", "my histograms"); hCPU->Write(); hDigi->Write(); } - } -void -SiPixelRawToDigi::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { +void SiPixelRawToDigi::fillDescriptions( + edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; - desc.add("IncludeErrors",true); - desc.add("UseQualityInfo",false); + desc.add("IncludeErrors", true); + desc.add("UseQualityInfo", false); { std::vector temp1; temp1.reserve(1); temp1.push_back(29); - desc.add >("ErrorList",temp1)->setComment("## ErrorList: list of error codes used by tracking to invalidate modules"); + desc.add>("ErrorList", temp1) + ->setComment("## ErrorList: list of error codes used by tracking to " + "invalidate modules"); } { std::vector temp1; temp1.reserve(1); temp1.push_back(40); - desc.add >("UserErrorList",temp1)->setComment("## UserErrorList: list of error codes used by Pixel experts for investigation"); + desc.add>("UserErrorList", temp1) + ->setComment("## UserErrorList: list of error codes used by Pixel " + "experts for investigation"); } - desc.add("InputLabel",edm::InputTag("siPixelRawData")); + desc.add("InputLabel", edm::InputTag("siPixelRawData")); { edm::ParameterSetDescription psd0; psd0.addOptional>("inputs"); psd0.addOptional>("deltaPhi"); psd0.addOptional>("maxZ"); psd0.addOptional("beamSpot"); - desc.add("Regions",psd0)->setComment("## Empty Regions PSet means complete unpacking"); + desc.add("Regions", psd0) + ->setComment("## Empty Regions PSet means complete unpacking"); } - desc.addUntracked("Timing",false); - desc.add("UsePilotBlade",false)->setComment("## Use pilot blades"); - desc.add("UsePhase1",false)->setComment("## Use phase1"); - desc.add("CablingMapLabel","")->setComment("CablingMap label"); //Tav - desc.addOptional("CheckPixelOrder"); // never used, kept for back-compatibility - descriptions.add("siPixelRawToDigi",desc); - + desc.addUntracked("Timing", false); + desc.add("UsePilotBlade", false)->setComment("## Use pilot blades"); + desc.add("UsePhase1", false)->setComment("## Use phase1"); + desc.add("CablingMapLabel", "") + ->setComment("CablingMap label"); // Tav + desc.addOptional( + "CheckPixelOrder"); // never used, kept for back-compatibility + descriptions.add("siPixelRawToDigi", desc); } // ----------------------------------------------------------------------------- - // ----------------------------------------------------------------------------- -void SiPixelRawToDigi::produce( edm::Event& ev, - const edm::EventSetup& es) -{ +void SiPixelRawToDigi::produce(edm::Event &ev, const edm::EventSetup &es) { const uint32_t dummydetid = 0xffffffff; debug = edm::MessageDrop::instance()->debugEnabled; -// initialize cabling map or update if necessary - if (recordWatcher.check( es )) { - // cabling map, which maps online address (fed->link->ROC->local pixel) to offline (DetId->global pixel) + // initialize cabling map or update if necessary + if (recordWatcher.check(es)) { + // cabling map, which maps online address (fed->link->ROC->local pixel) to + // offline (DetId->global pixel) edm::ESTransientHandle cablingMap; - es.get().get( cablingMapLabel, cablingMap ); //Tav - fedIds = cablingMap->fedIds(); + es.get().get(cablingMapLabel, cablingMap); // Tav + fedIds = cablingMap->fedIds(); cabling_ = cablingMap->cablingTree(); - LogDebug("map version:")<< cabling_->version(); + LogDebug("map version:") << cabling_->version(); } -// initialize quality record or update if necessary - if (qualityWatcher.check( es )&&useQuality) { + // initialize quality record or update if necessary + if (qualityWatcher.check(es) && useQuality) { // quality info for dead pixel modules or ROCs edm::ESHandle qualityInfo; - es.get().get( qualityInfo ); + es.get().get(qualityInfo); badPixelInfo_ = qualityInfo.product(); if (!badPixelInfo_) { - edm::LogError("SiPixelQualityNotPresent")<<" Configured to use SiPixelQuality, but SiPixelQuality not present"< buffers; ev.getByToken(tFEDRawDataCollection, buffers); -// create product (digis & errors) + // create product (digis & errors) auto collection = std::make_unique>(); // collection->reserve(8*1024); - auto errorcollection = std::make_unique>(); + auto errorcollection = + std::make_unique>(); auto tkerror_detidcollection = std::make_unique(); auto usererror_detidcollection = std::make_unique(); - auto disabled_channelcollection = std::make_unique >(); + auto disabled_channelcollection = + std::make_unique>(); - //PixelDataFormatter formatter(cabling_.get()); // phase 0 only + // PixelDataFormatter formatter(cabling_.get()); // phase 0 only PixelDataFormatter formatter(cabling_.get(), usePhase1); // for phase 1 & 0 formatter.setErrorStatus(includeErrors); - if (useQuality) formatter.setQualityStatus(useQuality, badPixelInfo_); + if (useQuality) + formatter.setQualityStatus(useQuality, badPixelInfo_); - if (theTimer) theTimer->start(); + if (theTimer) + theTimer->start(); bool errorsInEvent = false; PixelDataFormatter::DetErrors nodeterrors; if (regions_) { regions_->run(ev, es); formatter.setModulesToUnpack(regions_->modulesToUnpack()); - LogDebug("SiPixelRawToDigi") << "region2unpack #feds: "<nFEDs(); - LogDebug("SiPixelRawToDigi") << "region2unpack #modules (BPIX,EPIX,total): "<nBarrelModules()<<" "<nForwardModules()<<" "<nModules(); + LogDebug("SiPixelRawToDigi") + << "region2unpack #feds: " << regions_->nFEDs(); + LogDebug("SiPixelRawToDigi") + << "region2unpack #modules (BPIX,EPIX,total): " + << regions_->nBarrelModules() << " " << regions_->nForwardModules() + << " " << regions_->nModules(); } for (auto aFed = fedIds.begin(); aFed != fedIds.end(); ++aFed) { int fedId = *aFed; - if(!usePilotBlade && (fedId==40) ) continue; // skip pilot blade data + if (!usePilotBlade && (fedId == 40)) + continue; // skip pilot blade data - if (regions_ && !regions_->mayUnpackFED(fedId)) continue; + if (regions_ && !regions_->mayUnpackFED(fedId)) + continue; - if(debug) LogDebug("SiPixelRawToDigi")<< " PRODUCE DIGI FOR FED: " << fedId << endl; + if (debug) + LogDebug("SiPixelRawToDigi") + << " PRODUCE DIGI FOR FED: " << fedId << endl; PixelDataFormatter::Errors errors; - //get event data for this fed - const FEDRawData& fedRawData = buffers->FEDData( fedId ); + // get event data for this fed + const FEDRawData &fedRawData = buffers->FEDData(fedId); - //convert data to digi and strip off errors - formatter.interpretRawData( errorsInEvent, fedId, fedRawData, *collection, errors); + // convert data to digi and strip off errors + formatter.interpretRawData(errorsInEvent, fedId, fedRawData, *collection, + errors); - //pack errors into collection - if(includeErrors) { + // pack errors into collection + if (includeErrors) { typedef PixelDataFormatter::Errors::iterator IE; for (IE is = errors.begin(); is != errors.end(); is++) { - uint32_t errordetid = is->first; - if (errordetid==dummydetid) { // errors given dummy detId must be sorted by Fed - nodeterrors.insert( nodeterrors.end(), errors[errordetid].begin(), errors[errordetid].end() ); - } else { - edm::DetSet& errorDetSet = errorcollection->find_or_insert(errordetid); - errorDetSet.data.insert(errorDetSet.data.end(), is->second.begin(), is->second.end()); - // Fill detid of the detectors where there is error AND the error number is listed - // in the configurable error list in the job option cfi. - // Code needs to be here, because there can be a set of errors for each - // entry in the for loop over PixelDataFormatter::Errors - - std::vector disabledChannelsDetSet; - - for (auto const& aPixelError : errorDetSet) { - // For the time being, we extend the error handling functionality with ErrorType 25 - // In the future, we should sort out how the usage of tkerrorlist can be generalized - if (aPixelError.getType()==25) { - assert(aPixelError.getFedId()==fedId); - const sipixelobjects::PixelFEDCabling* fed = cabling_->fed(fedId); - if (fed) { - cms_uint32_t linkId = formatter.linkId(aPixelError.getWord32()); - const sipixelobjects::PixelFEDLink* link = fed->link(linkId); - if (link) { - // The "offline" 0..15 numbering is fixed by definition, also, the FrameConversion depends on it - // in contrast, the ROC-in-channel numbering is determined by hardware --> better to use the "offline" scheme - PixelFEDChannel ch = {fed->id(), linkId, 25, 0}; - for (unsigned int iRoc=1; iRoc<=link->numberOfROCs(); iRoc++) { - const sipixelobjects::PixelROC * roc = link->roc(iRoc); - if (roc->idInDetUnit()idInDetUnit(); - if (roc->idInDetUnit()>ch.roc_last) ch.roc_last=roc->idInDetUnit(); - } - disabledChannelsDetSet.push_back(ch); - } - } - } else { - // fill list of detIds to be turned off by tracking - if(!tkerrorlist.empty()) { - std::vector::iterator it_find = find(tkerrorlist.begin(), tkerrorlist.end(), aPixelError.getType()); - if(it_find != tkerrorlist.end()){ - tkerror_detidcollection->push_back(errordetid); - } - } - } - - // fill list of detIds with errors to be studied - if(!usererrorlist.empty()) { - std::vector::iterator it_find = find(usererrorlist.begin(), usererrorlist.end(), aPixelError.getType()); - if(it_find != usererrorlist.end()){ - usererror_detidcollection->push_back(errordetid); - } - } - - } // loop on DetSet of errors - - if (!disabledChannelsDetSet.empty()) { - disabled_channelcollection->insert(errordetid, disabledChannelsDetSet.data(), disabledChannelsDetSet.size()); - } - } // if error assigned to a real DetId - } // loop on errors in event for this FED - } // if errors to be included in the event - } // loop on FED data to be unpacked - - if(includeErrors) { - edm::DetSet& errorDetSet = errorcollection->find_or_insert(dummydetid); + uint32_t errordetid = is->first; + if (errordetid == + dummydetid) { // errors given dummy detId must be sorted by Fed + nodeterrors.insert(nodeterrors.end(), errors[errordetid].begin(), + errors[errordetid].end()); + } else { + edm::DetSet &errorDetSet = + errorcollection->find_or_insert(errordetid); + errorDetSet.data.insert(errorDetSet.data.end(), is->second.begin(), + is->second.end()); + // Fill detid of the detectors where there is error AND the error + // number is listed in the configurable error list in the job option + // cfi. Code needs to be here, because there can be a set of errors + // for each entry in the for loop over PixelDataFormatter::Errors + + std::vector disabledChannelsDetSet; + + for (auto const &aPixelError : errorDetSet) { + // For the time being, we extend the error handling functionality + // with ErrorType 25 In the future, we should sort out how the usage + // of tkerrorlist can be generalized + if (usePhase1 == true && aPixelError.getType() == 25) { + assert(aPixelError.getFedId() == fedId); + const sipixelobjects::PixelFEDCabling *fed = cabling_->fed(fedId); + if (fed) { + cms_uint32_t linkId = formatter.linkId(aPixelError.getWord32()); + const sipixelobjects::PixelFEDLink *link = fed->link(linkId); + if (link) { + // The "offline" 0..15 numbering is fixed by definition, also, + // the FrameConversion depends on it in contrast, the + // ROC-in-channel numbering is determined by hardware --> + // better to use the "offline" scheme + PixelFEDChannel ch = {fed->id(), linkId, 25, 0}; + for (unsigned int iRoc = 1; iRoc <= link->numberOfROCs(); + iRoc++) { + const sipixelobjects::PixelROC *roc = link->roc(iRoc); + if (roc->idInDetUnit() < ch.roc_first) + ch.roc_first = roc->idInDetUnit(); + if (roc->idInDetUnit() > ch.roc_last) + ch.roc_last = roc->idInDetUnit(); + } + disabledChannelsDetSet.push_back(ch); + } + } + } else { + // fill list of detIds to be turned off by tracking + if (!tkerrorlist.empty()) { + std::vector::iterator it_find = + find(tkerrorlist.begin(), tkerrorlist.end(), + aPixelError.getType()); + if (it_find != tkerrorlist.end()) { + tkerror_detidcollection->push_back(errordetid); + } + } + } + + // fill list of detIds with errors to be studied + if (!usererrorlist.empty()) { + std::vector::iterator it_find = + find(usererrorlist.begin(), usererrorlist.end(), + aPixelError.getType()); + if (it_find != usererrorlist.end()) { + usererror_detidcollection->push_back(errordetid); + } + } + + } // loop on DetSet of errors + + if (!disabledChannelsDetSet.empty()) { + disabled_channelcollection->insert(errordetid, + disabledChannelsDetSet.data(), + disabledChannelsDetSet.size()); + } + } // if error assigned to a real DetId + } // loop on errors in event for this FED + } // if errors to be included in the event + } // loop on FED data to be unpacked + + if (includeErrors) { + edm::DetSet &errorDetSet = + errorcollection->find_or_insert(dummydetid); errorDetSet.data = nodeterrors; } - if (errorsInEvent) LogDebug("SiPixelRawToDigi") << "Error words were stored in this event"; + if (errorsInEvent) + LogDebug("SiPixelRawToDigi") << "Error words were stored in this event"; if (theTimer) { theTimer->stop(); - LogDebug("SiPixelRawToDigi") << "TIMING IS: (real)" << theTimer->realTime() ; + LogDebug("SiPixelRawToDigi") << "TIMING IS: (real)" << theTimer->realTime(); ndigis += formatter.nDigis(); nwords += formatter.nWords(); - LogDebug("SiPixelRawToDigi") << " (Words/Digis) this ev: " - <Fill( theTimer->realTime() ); + LogDebug("SiPixelRawToDigi") + << " (Words/Digis) this ev: " << formatter.nWords() << "/" + << formatter.nDigis() << "--- all :" << nwords << "/" << ndigis; + hCPU->Fill(theTimer->realTime()); hDigi->Fill(formatter.nDigis()); } - + ev.put(std::move(collection)); - if(includeErrors){ + if (includeErrors) { ev.put(std::move(errorcollection)); ev.put(std::move(tkerror_detidcollection)); - ev.put(std::move(usererror_detidcollection), "UserErrorModules"); + ev.put(std::move(usererror_detidcollection), "UserErrorModules"); ev.put(std::move(disabled_channelcollection)); } } diff --git a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.h b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.h index bbd9bb1a13757..df381d9794c55 100644 --- a/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.h +++ b/EventFilter/SiPixelRawToDigi/plugins/SiPixelRawToDigi.h @@ -2,19 +2,19 @@ #define SiPixelRawToDigi_H /** \class SiPixelRawToDigi_H - * Plug-in module that performs Raw data to digi conversion + * Plug-in module that performs Raw data to digi conversion * for pixel subdetector */ -#include "FWCore/Framework/interface/ESWatcher.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h" #include "CondFormats/DataRecord/interface/SiPixelQualityRcd.h" #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" #include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Framework/interface/ESWatcher.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/CPUTimer.h" class SiPixelFedCablingTree; @@ -25,25 +25,23 @@ class PixelUnpackingRegions; class SiPixelRawToDigi : public edm::stream::EDProducer<> { public: - /// ctor - explicit SiPixelRawToDigi( const edm::ParameterSet& ); + explicit SiPixelRawToDigi(const edm::ParameterSet &); /// dtor ~SiPixelRawToDigi() override; - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); /// get data, convert to digis attach againe to Event - void produce( edm::Event&, const edm::EventSetup& ) override; + void produce(edm::Event &, const edm::EventSetup &) override; private: - edm::ParameterSet config_; std::unique_ptr cabling_; - const SiPixelQuality* badPixelInfo_; - PixelUnpackingRegions* regions_; - edm::EDGetTokenT tFEDRawDataCollection; + const SiPixelQuality *badPixelInfo_; + PixelUnpackingRegions *regions_; + edm::EDGetTokenT tFEDRawDataCollection; TH1D *hCPU, *hDigi; std::unique_ptr theTimer; bool includeErrors; @@ -55,7 +53,7 @@ class SiPixelRawToDigi : public edm::stream::EDProducer<> { edm::ESWatcher recordWatcher; edm::ESWatcher qualityWatcher; edm::InputTag label; - + int ndigis; int nwords; bool usePilotBlade; diff --git a/EventFilter/SiPixelRawToDigi/src/ErrorChecker.cc b/EventFilter/SiPixelRawToDigi/src/ErrorChecker.cc index 7eccc79719a40..bb5a3b791a11b 100644 --- a/EventFilter/SiPixelRawToDigi/src/ErrorChecker.cc +++ b/EventFilter/SiPixelRawToDigi/src/ErrorChecker.cc @@ -3,60 +3,62 @@ #include "CondFormats/SiPixelObjects/interface/SiPixelFrameConverter.h" #include "DataFormats/DetId/interface/DetId.h" -#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" #include "DataFormats/FEDRawData/interface/FEDHeader.h" #include "DataFormats/FEDRawData/interface/FEDTrailer.h" +#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include -#include #include +#include using namespace std; using namespace edm; using namespace sipixelobjects; namespace { - constexpr int CRC_bits = 1; - constexpr int LINK_bits = 6; - constexpr int ROC_bits = 5; - constexpr int DCOL_bits = 5; - constexpr int PXID_bits = 8; - constexpr int ADC_bits = 8; - constexpr int OMIT_ERR_bits = 1; - - constexpr int CRC_shift = 2; - constexpr int ADC_shift = 0; - constexpr int PXID_shift = ADC_shift + ADC_bits; - constexpr int DCOL_shift = PXID_shift + PXID_bits; - constexpr int ROC_shift = DCOL_shift + DCOL_bits; - constexpr int LINK_shift = ROC_shift + ROC_bits; - constexpr int OMIT_ERR_shift = 20; - - constexpr cms_uint32_t dummyDetId = 0xffffffff; - - constexpr ErrorChecker::Word64 CRC_mask = ~(~ErrorChecker::Word64(0) << CRC_bits); - constexpr ErrorChecker::Word32 ERROR_mask = ~(~ErrorChecker::Word32(0) << ROC_bits); - constexpr ErrorChecker::Word32 LINK_mask = ~(~ErrorChecker::Word32(0) << LINK_bits); - constexpr ErrorChecker::Word32 ROC_mask = ~(~ErrorChecker::Word32(0) << ROC_bits); - constexpr ErrorChecker::Word32 OMIT_ERR_mask = ~(~ErrorChecker::Word32(0) << OMIT_ERR_bits); -} +constexpr int CRC_bits = 1; +constexpr int LINK_bits = 6; +constexpr int ROC_bits = 5; +constexpr int DCOL_bits = 5; +constexpr int PXID_bits = 8; +constexpr int ADC_bits = 8; +constexpr int OMIT_ERR_bits = 1; -ErrorChecker::ErrorChecker() { +constexpr int CRC_shift = 2; +constexpr int ADC_shift = 0; +constexpr int PXID_shift = ADC_shift + ADC_bits; +constexpr int DCOL_shift = PXID_shift + PXID_bits; +constexpr int ROC_shift = DCOL_shift + DCOL_bits; +constexpr int LINK_shift = ROC_shift + ROC_bits; +constexpr int OMIT_ERR_shift = 20; - includeErrors = false; -} +constexpr cms_uint32_t dummyDetId = 0xffffffff; + +constexpr ErrorChecker::Word64 CRC_mask = + ~(~ErrorChecker::Word64(0) << CRC_bits); +constexpr ErrorChecker::Word32 ERROR_mask = + ~(~ErrorChecker::Word32(0) << ROC_bits); +constexpr ErrorChecker::Word32 LINK_mask = + ~(~ErrorChecker::Word32(0) << LINK_bits); +constexpr ErrorChecker::Word32 ROC_mask = + ~(~ErrorChecker::Word32(0) << ROC_bits); +constexpr ErrorChecker::Word32 OMIT_ERR_mask = + ~(~ErrorChecker::Word32(0) << OMIT_ERR_bits); +} // namespace + +ErrorChecker::ErrorChecker() { includeErrors = false; } -void ErrorChecker::setErrorStatus(bool ErrorStatus) -{ +void ErrorChecker::setErrorStatus(bool ErrorStatus) { includeErrors = ErrorStatus; } -bool ErrorChecker::checkCRC(bool& errorsInEvent, int fedId, const Word64* trailer, Errors& errors) -{ +bool ErrorChecker::checkCRC(bool &errorsInEvent, int fedId, + const Word64 *trailer, Errors &errors) { int CRC_BIT = (*trailer >> CRC_shift) & CRC_mask; - if (CRC_BIT == 0) return true; + if (CRC_BIT == 0) + return true; errorsInEvent = true; if (includeErrors) { int errorType = 39; @@ -66,14 +68,16 @@ bool ErrorChecker::checkCRC(bool& errorsInEvent, int fedId, const Word64* traile return false; } -bool ErrorChecker::checkHeader(bool& errorsInEvent, int fedId, const Word64* header, Errors& errors) -{ - FEDHeader fedHeader( reinterpret_cast(header)); - if ( !fedHeader.check() ) return false; // throw exception? - if ( fedHeader.sourceID() != fedId) { - LogDebug("PixelDataFormatter::interpretRawData, fedHeader.sourceID() != fedId") - <<", sourceID = " <(header)); + if (!fedHeader.check()) + return false; // throw exception? + if (fedHeader.sourceID() != fedId) { + LogDebug( + "PixelDataFormatter::interpretRawData, fedHeader.sourceID() != fedId") + << ", sourceID = " << fedHeader.sourceID() << ", fedId = " << fedId + << ", errorType = 32"; errorsInEvent = true; if (includeErrors) { int errorType = 32; @@ -84,24 +88,27 @@ bool ErrorChecker::checkHeader(bool& errorsInEvent, int fedId, const Word64* hea return fedHeader.moreHeaders(); } -bool ErrorChecker::checkTrailer(bool& errorsInEvent, int fedId, unsigned int nWords, const Word64* trailer, Errors& errors) -{ - FEDTrailer fedTrailer(reinterpret_cast(trailer)); - if ( !fedTrailer.check()) { - if(includeErrors) { +bool ErrorChecker::checkTrailer(bool &errorsInEvent, int fedId, + unsigned int nWords, const Word64 *trailer, + Errors &errors) { + FEDTrailer fedTrailer(reinterpret_cast(trailer)); + if (!fedTrailer.check()) { + if (includeErrors) { int errorType = 33; SiPixelRawDataError error(*trailer, errorType, fedId); errors[dummyDetId].push_back(error); } errorsInEvent = true; LogError("FedTrailerCheck") - <<"fedTrailer.check failed, Fed: " << fedId << ", errorType = 33"; - return false; - } - if ( fedTrailer.fragmentLength()!= nWords) { - LogError("FedTrailerLenght")<< "fedTrailer.fragmentLength()!= nWords !! Fed: " << fedId << ", errorType = 34"; + << "fedTrailer.check failed, Fed: " << fedId << ", errorType = 33"; + return false; + } + if (fedTrailer.fragmentLength() != nWords) { + LogError("FedTrailerLenght") + << "fedTrailer.fragmentLength()!= nWords !! Fed: " << fedId + << ", errorType = 34"; errorsInEvent = true; - if(includeErrors) { + if (includeErrors) { int errorType = 34; SiPixelRawDataError error(*trailer, errorType, fedId); errors[dummyDetId].push_back(error); @@ -110,80 +117,89 @@ bool ErrorChecker::checkTrailer(bool& errorsInEvent, int fedId, unsigned int nWo return fedTrailer.moreTrailers(); } -bool ErrorChecker::checkROC(bool& errorsInEvent, int fedId, const SiPixelFrameConverter* converter, - const SiPixelFedCabling* theCablingTree, Word32& errorWord, Errors& errors) -{ +bool ErrorChecker::checkROC(bool &errorsInEvent, int fedId, + const SiPixelFrameConverter *converter, + const SiPixelFedCabling *theCablingTree, + Word32 &errorWord, Errors &errors) { int errorType = (errorWord >> ROC_shift) & ERROR_mask; - if LIKELY(errorType<25) return true; + if + LIKELY(errorType < 25) return true; - switch (errorType) { - case(25) : { - CablingPathToDetUnit cablingPath = { unsigned(fedId), (errorWord >> LINK_shift) & LINK_mask, 1 }; - if (!theCablingTree->findItem(cablingPath)) return false; - LogDebug("")<<" invalid ROC=25 found (errorType=25)"; - errorsInEvent = true; - break; - } - case(26) : { - //LogDebug("")<<" gap word found (errorType=26)"; - return false; - } - case(27) : { - //LogDebug("")<<" dummy word found (errorType=27)"; - return false; - } - case(28) : { - LogDebug("")<<" error fifo nearly full (errorType=28)"; - errorsInEvent = true; - break; - } - case(29) : { - LogDebug("")<<" timeout on a channel (errorType=29)"; - errorsInEvent = true; - if ((errorWord >> OMIT_ERR_shift) & OMIT_ERR_mask) { - LogDebug("")<<" ...first errorType=29 error, this gets masked out"; - return false; - } - break; - } - case(30) : { - LogDebug("")<<" TBM error trailer (errorType=30)"; - int StateMatch_bits = 4; - int StateMatch_shift = 8; - uint32_t StateMatch_mask = ~(~uint32_t(0) << StateMatch_bits); - int StateMatch = (errorWord >> StateMatch_shift) & StateMatch_mask; - if( StateMatch!=1 && StateMatch!=8 ) { - LogDebug("")<<" FED error 30 with unexpected State Bits (errorType=30)"; - return false; - } - if( StateMatch==1 ) errorType = 40; // 1=Overflow -> 40, 8=number of ROCs -> 30 - errorsInEvent = true; - break; - } - case(31) : { - LogDebug("")<<" event number error (errorType=31)"; - errorsInEvent = true; - break; - } - default: return true; - }; + switch (errorType) { + case (25): { + CablingPathToDetUnit cablingPath = { + unsigned(fedId), (errorWord >> LINK_shift) & LINK_mask, 1}; + if (!theCablingTree->findItem(cablingPath)) + return false; + LogDebug("") << " invalid ROC=25 found (errorType=25)"; + errorsInEvent = true; + break; + } + case (26): { + // LogDebug("")<<" gap word found (errorType=26)"; + return false; + } + case (27): { + // LogDebug("")<<" dummy word found (errorType=27)"; + return false; + } + case (28): { + LogDebug("") << " error fifo nearly full (errorType=28)"; + errorsInEvent = true; + break; + } + case (29): { + LogDebug("") << " timeout on a channel (errorType=29)"; + errorsInEvent = true; + if ((errorWord >> OMIT_ERR_shift) & OMIT_ERR_mask) { + LogDebug("") << " ...first errorType=29 error, this gets masked out"; + return false; + } + break; + } + case (30): { + LogDebug("") << " TBM error trailer (errorType=30)"; + int StateMatch_bits = 4; + int StateMatch_shift = 8; + uint32_t StateMatch_mask = ~(~uint32_t(0) << StateMatch_bits); + int StateMatch = (errorWord >> StateMatch_shift) & StateMatch_mask; + if (StateMatch != 1 && StateMatch != 8) { + LogDebug("") << " FED error 30 with unexpected State Bits (errorType=30)"; + return false; + } + if (StateMatch == 1) + errorType = 40; // 1=Overflow -> 40, 8=number of ROCs -> 30 + errorsInEvent = true; + break; + } + case (31): { + LogDebug("") << " event number error (errorType=31)"; + errorsInEvent = true; + break; + } + default: + return true; + }; - if(includeErrors) { - // store error - SiPixelRawDataError error(errorWord, errorType, fedId); - cms_uint32_t detId; - detId = errorDetId(converter, errorType, errorWord); - errors[detId].push_back(error); - } - return false; + if (includeErrors) { + // store error + SiPixelRawDataError error(errorWord, errorType, fedId); + cms_uint32_t detId; + detId = errorDetId(converter, errorType, errorWord); + errors[detId].push_back(error); + } + return false; } -void ErrorChecker::conversionError(int fedId, const SiPixelFrameConverter* converter, int status, Word32& errorWord, Errors& errors) -{ +void ErrorChecker::conversionError(int fedId, + const SiPixelFrameConverter *converter, + int status, Word32 &errorWord, + Errors &errors) { switch (status) { - case(1) : { - LogDebug("ErrorChecker::conversionError") << " Fed: " << fedId << " invalid channel Id (errorType=35)"; - if(includeErrors) { + case (1): { + LogDebug("ErrorChecker::conversionError") + << " Fed: " << fedId << " invalid channel Id (errorType=35)"; + if (includeErrors) { int errorType = 35; SiPixelRawDataError error(errorWord, errorType, fedId); cms_uint32_t detId = errorDetId(converter, errorType, errorWord); @@ -191,9 +207,10 @@ void ErrorChecker::conversionError(int fedId, const SiPixelFrameConverter* conve } break; } - case(2) : { - LogDebug("ErrorChecker::conversionError")<< " Fed: " << fedId << " invalid ROC Id (errorType=36)"; - if(includeErrors) { + case (2): { + LogDebug("ErrorChecker::conversionError") + << " Fed: " << fedId << " invalid ROC Id (errorType=36)"; + if (includeErrors) { int errorType = 36; SiPixelRawDataError error(errorWord, errorType, fedId); cms_uint32_t detId = errorDetId(converter, errorType, errorWord); @@ -201,9 +218,10 @@ void ErrorChecker::conversionError(int fedId, const SiPixelFrameConverter* conve } break; } - case(3) : { - LogDebug("ErrorChecker::conversionError")<< " Fed: " << fedId << " invalid dcol/pixel value (errorType=37)"; - if(includeErrors) { + case (3): { + LogDebug("ErrorChecker::conversionError") + << " Fed: " << fedId << " invalid dcol/pixel value (errorType=37)"; + if (includeErrors) { int errorType = 37; SiPixelRawDataError error(errorWord, errorType, fedId); cms_uint32_t detId = errorDetId(converter, errorType, errorWord); @@ -211,9 +229,10 @@ void ErrorChecker::conversionError(int fedId, const SiPixelFrameConverter* conve } break; } - case(4) : { - LogDebug("ErrorChecker::conversionError")<< " Fed: " << fedId << " dcol/pixel read out of order (errorType=38)"; - if(includeErrors) { + case (4): { + LogDebug("ErrorChecker::conversionError") + << " Fed: " << fedId << " dcol/pixel read out of order (errorType=38)"; + if (includeErrors) { int errorType = 38; SiPixelRawDataError error(errorWord, errorType, fedId); cms_uint32_t detId = errorDetId(converter, errorType, errorWord); @@ -221,78 +240,93 @@ void ErrorChecker::conversionError(int fedId, const SiPixelFrameConverter* conve } break; } - default: LogDebug("ErrorChecker::conversionError")<<" cabling check returned unexpected result, status = "<< status; + default: + LogDebug("ErrorChecker::conversionError") + << " cabling check returned unexpected result, status = " << status; }; } -// this function finds the detId for an error word that cannot be processed in word2digi -cms_uint32_t ErrorChecker::errorDetId(const SiPixelFrameConverter* converter, - int errorType, const Word32 & word) const -{ - if (!converter) return dummyDetId; +// this function finds the detId for an error word that cannot be processed in +// word2digi +cms_uint32_t ErrorChecker::errorDetId(const SiPixelFrameConverter *converter, + int errorType, const Word32 &word) const { + if (!converter) + return dummyDetId; ElectronicIndex cabling; switch (errorType) { - case 25 : case 30 : case 31 : case 36 : case 40 : { - // set dummy values for cabling just to get detId from link - cabling.dcol = 0; - cabling.pxid = 2; - cabling.roc = 1; - cabling.link = (word >> LINK_shift) & LINK_mask; - - DetectorIndex detIdx; - int status = converter->toDetector(cabling, detIdx); - if (!status) return detIdx.rawId; - break; - } - case 29 : { - int chanNmbr = 0; - const int DB0_shift = 0; - const int DB1_shift = DB0_shift + 1; - const int DB2_shift = DB1_shift + 1; - const int DB3_shift = DB2_shift + 1; - const int DB4_shift = DB3_shift + 1; - const cms_uint32_t DataBit_mask = ~(~cms_uint32_t(0) << 1); + case 25: + case 30: + case 31: + case 36: + case 40: { + // set dummy values for cabling just to get detId from link + cabling.dcol = 0; + cabling.pxid = 2; + cabling.roc = 1; + cabling.link = (word >> LINK_shift) & LINK_mask; - int CH1 = (word >> DB0_shift) & DataBit_mask; - int CH2 = (word >> DB1_shift) & DataBit_mask; - int CH3 = (word >> DB2_shift) & DataBit_mask; - int CH4 = (word >> DB3_shift) & DataBit_mask; - int CH5 = (word >> DB4_shift) & DataBit_mask; - int BLOCK_bits = 3; - int BLOCK_shift = 8; - cms_uint32_t BLOCK_mask = ~(~cms_uint32_t(0) << BLOCK_bits); - int BLOCK = (word >> BLOCK_shift) & BLOCK_mask; - int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5; - if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH; - else chanNmbr = ((BLOCK-1)/2)*9+4+localCH; - if ((chanNmbr<1)||(chanNmbr>36)) break; // signifies unexpected result - - // set dummy values for cabling just to get detId from link if in Barrel - cabling.dcol = 0; - cabling.pxid = 2; - cabling.roc = 1; - cabling.link = chanNmbr; - DetectorIndex detIdx; - int status = converter->toDetector(cabling, detIdx); - if (!status) return detIdx.rawId; - break; - } - case 37 : case 38: { - cabling.dcol = 0; - cabling.pxid = 2; - cabling.roc = (word >> ROC_shift) & ROC_mask; - cabling.link = (word >> LINK_shift) & LINK_mask; + DetectorIndex detIdx; + int status = converter->toDetector(cabling, detIdx); + if (!status) + return detIdx.rawId; + break; + } + case 29: { + int chanNmbr = 0; + const int DB0_shift = 0; + const int DB1_shift = DB0_shift + 1; + const int DB2_shift = DB1_shift + 1; + const int DB3_shift = DB2_shift + 1; + const int DB4_shift = DB3_shift + 1; + const cms_uint32_t DataBit_mask = ~(~cms_uint32_t(0) << 1); - DetectorIndex detIdx; - int status = converter->toDetector(cabling, detIdx); - if (status) break; + int CH1 = (word >> DB0_shift) & DataBit_mask; + int CH2 = (word >> DB1_shift) & DataBit_mask; + int CH3 = (word >> DB2_shift) & DataBit_mask; + int CH4 = (word >> DB3_shift) & DataBit_mask; + int CH5 = (word >> DB4_shift) & DataBit_mask; + int BLOCK_bits = 3; + int BLOCK_shift = 8; + cms_uint32_t BLOCK_mask = ~(~cms_uint32_t(0) << BLOCK_bits); + int BLOCK = (word >> BLOCK_shift) & BLOCK_mask; + int localCH = 1 * CH1 + 2 * CH2 + 3 * CH3 + 4 * CH4 + 5 * CH5; + if (BLOCK % 2 == 0) + chanNmbr = (BLOCK / 2) * 9 + localCH; + else + chanNmbr = ((BLOCK - 1) / 2) * 9 + 4 + localCH; + if ((chanNmbr < 1) || (chanNmbr > 36)) + break; // signifies unexpected result + // set dummy values for cabling just to get detId from link if in Barrel + cabling.dcol = 0; + cabling.pxid = 2; + cabling.roc = 1; + cabling.link = chanNmbr; + DetectorIndex detIdx; + int status = converter->toDetector(cabling, detIdx); + if (!status) return detIdx.rawId; + break; + } + case 37: + case 38: { + cabling.dcol = 0; + cabling.pxid = 2; + cabling.roc = (word >> ROC_shift) & ROC_mask; + cabling.link = (word >> LINK_shift) & LINK_mask; + + DetectorIndex detIdx; + int status = converter->toDetector(cabling, detIdx); + if (status) break; - } - default : break; + + return detIdx.rawId; + break; + } + default: + break; }; return dummyDetId; } diff --git a/EventFilter/SiPixelRawToDigi/src/ErrorCheckerPhase0.cc b/EventFilter/SiPixelRawToDigi/src/ErrorCheckerPhase0.cc new file mode 100644 index 0000000000000..d4dfa0149f4e2 --- /dev/null +++ b/EventFilter/SiPixelRawToDigi/src/ErrorCheckerPhase0.cc @@ -0,0 +1,335 @@ +#include "EventFilter/SiPixelRawToDigi/interface/ErrorCheckerPhase0.h" + +#include "CondFormats/SiPixelObjects/interface/SiPixelFrameConverter.h" + +#include "DataFormats/DetId/interface/DetId.h" +#include "DataFormats/FEDRawData/interface/FEDHeader.h" +#include "DataFormats/FEDRawData/interface/FEDTrailer.h" +#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include +#include +#include + +using namespace std; +using namespace edm; +using namespace sipixelobjects; + +namespace { +constexpr int CRC_bits = 1; +constexpr int LINK_bits = 6; +constexpr int ROC_bits = 5; +constexpr int DCOL_bits = 5; +constexpr int PXID_bits = 8; +constexpr int ADC_bits = 8; +constexpr int OMIT_ERR_bits = 1; + +constexpr int CRC_shift = 2; +constexpr int ADC_shift = 0; +constexpr int PXID_shift = ADC_shift + ADC_bits; +constexpr int DCOL_shift = PXID_shift + PXID_bits; +constexpr int ROC_shift = DCOL_shift + DCOL_bits; +constexpr int LINK_shift = ROC_shift + ROC_bits; +constexpr int OMIT_ERR_shift = 20; + +constexpr cms_uint32_t dummyDetId = 0xffffffff; + +constexpr ErrorCheckerPhase0::Word64 CRC_mask = + ~(~ErrorCheckerPhase0::Word64(0) << CRC_bits); +constexpr ErrorCheckerPhase0::Word32 ERROR_mask = + ~(~ErrorCheckerPhase0::Word32(0) << ROC_bits); +constexpr ErrorCheckerPhase0::Word32 LINK_mask = + ~(~ErrorCheckerPhase0::Word32(0) << LINK_bits); +constexpr ErrorCheckerPhase0::Word32 ROC_mask = + ~(~ErrorCheckerPhase0::Word32(0) << ROC_bits); +constexpr ErrorCheckerPhase0::Word32 OMIT_ERR_mask = + ~(~ErrorCheckerPhase0::Word32(0) << OMIT_ERR_bits); +} // namespace + +ErrorCheckerPhase0::ErrorCheckerPhase0() { includeErrors = false; } + +void ErrorCheckerPhase0::setErrorStatus(bool ErrorStatus) { + includeErrors = ErrorStatus; +} + +bool ErrorCheckerPhase0::checkCRC(bool &errorsInEvent, int fedId, + const Word64 *trailer, Errors &errors) { + int CRC_BIT = (*trailer >> CRC_shift) & CRC_mask; + if (CRC_BIT == 0) + return true; + errorsInEvent = true; + if (includeErrors) { + int errorType = 39; + SiPixelRawDataError error(*trailer, errorType, fedId); + errors[dummyDetId].push_back(error); + } + return false; +} + +bool ErrorCheckerPhase0::checkHeader(bool &errorsInEvent, int fedId, + const Word64 *header, Errors &errors) { + FEDHeader fedHeader(reinterpret_cast(header)); + if (!fedHeader.check()) + return false; // throw exception? + if (fedHeader.sourceID() != fedId) { + LogDebug( + "PixelDataFormatter::interpretRawData, fedHeader.sourceID() != fedId") + << ", sourceID = " << fedHeader.sourceID() << ", fedId = " << fedId + << ", errorType = 32"; + errorsInEvent = true; + if (includeErrors) { + int errorType = 32; + SiPixelRawDataError error(*header, errorType, fedId); + errors[dummyDetId].push_back(error); + } + } + return fedHeader.moreHeaders(); +} + +bool ErrorCheckerPhase0::checkTrailer(bool &errorsInEvent, int fedId, + unsigned int nWords, + const Word64 *trailer, Errors &errors) { + FEDTrailer fedTrailer(reinterpret_cast(trailer)); + if (!fedTrailer.check()) { + if (includeErrors) { + int errorType = 33; + SiPixelRawDataError error(*trailer, errorType, fedId); + errors[dummyDetId].push_back(error); + } + errorsInEvent = true; + LogError("FedTrailerCheck") + << "fedTrailer.check failed, Fed: " << fedId << ", errorType = 33"; + return false; + } + if (fedTrailer.fragmentLength() != nWords) { + LogError("FedTrailerLenght") + << "fedTrailer.fragmentLength()!= nWords !! Fed: " << fedId + << ", errorType = 34"; + errorsInEvent = true; + if (includeErrors) { + int errorType = 34; + SiPixelRawDataError error(*trailer, errorType, fedId); + errors[dummyDetId].push_back(error); + } + } + return fedTrailer.moreTrailers(); +} + +bool ErrorCheckerPhase0::checkROC(bool &errorsInEvent, int fedId, + const SiPixelFrameConverter *converter, + const SiPixelFedCabling *theCablingTree, + Word32 &errorWord, Errors &errors) { + int errorType = (errorWord >> ROC_shift) & ERROR_mask; + if + LIKELY(errorType < 25) return true; + + switch (errorType) { + case (25): { + LogDebug("") << " invalid ROC=25 found (errorType=25)"; + errorsInEvent = true; + break; + } + case (26): { + // LogDebug("")<<" gap word found (errorType=26)"; + return false; + } + case (27): { + // LogDebug("")<<" dummy word found (errorType=27)"; + return false; + } + case (28): { + LogDebug("") << " error fifo nearly full (errorType=28)"; + errorsInEvent = true; + break; + } + case (29): { + LogDebug("") << " timeout on a channel (errorType=29)"; + errorsInEvent = true; + if ((errorWord >> OMIT_ERR_shift) & OMIT_ERR_mask) { + LogDebug("") << " ...first errorType=29 error, this gets masked out"; + return false; + } + break; + } + case (30): { + LogDebug("") << " TBM error trailer (errorType=30)"; + errorsInEvent = true; + break; + } + case (31): { + LogDebug("") << " event number error (errorType=31)"; + errorsInEvent = true; + break; + } + default: + return true; + }; + + if (includeErrors) { + // check to see if overflow error for type 30, change type to 40 if so + if (errorType == 30) { + int StateMach_bits = 4; + int StateMach_shift = 8; + uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits); + int StateMach = (errorWord >> StateMach_shift) & StateMach_mask; + if (StateMach == 4 || StateMach == 9) + errorType = 40; + } + + // store error + SiPixelRawDataError error(errorWord, errorType, fedId); + cms_uint32_t detId; + detId = errorDetId(converter, errorType, errorWord); + errors[detId].push_back(error); + } + return false; +} + +void ErrorCheckerPhase0::conversionError(int fedId, + const SiPixelFrameConverter *converter, + int status, Word32 &errorWord, + Errors &errors) { + switch (status) { + case (1): { + LogDebug("ErrorCheckerPhase0::conversionError") + << " Fed: " << fedId << " invalid channel Id (errorType=35)"; + if (includeErrors) { + int errorType = 35; + SiPixelRawDataError error(errorWord, errorType, fedId); + cms_uint32_t detId = errorDetId(converter, errorType, errorWord); + errors[detId].push_back(error); + } + break; + } + case (2): { + LogDebug("ErrorCheckerPhase0::conversionError") + << " Fed: " << fedId << " invalid ROC Id (errorType=36)"; + if (includeErrors) { + int errorType = 36; + SiPixelRawDataError error(errorWord, errorType, fedId); + cms_uint32_t detId = errorDetId(converter, errorType, errorWord); + errors[detId].push_back(error); + } + break; + } + case (3): { + LogDebug("ErrorCheckerPhase0::conversionError") + << " Fed: " << fedId << " invalid dcol/pixel value (errorType=37)"; + if (includeErrors) { + int errorType = 37; + SiPixelRawDataError error(errorWord, errorType, fedId); + cms_uint32_t detId = errorDetId(converter, errorType, errorWord); + errors[detId].push_back(error); + } + break; + } + case (4): { + LogDebug("ErrorCheckerPhase0::conversionError") + << " Fed: " << fedId << " dcol/pixel read out of order (errorType=38)"; + if (includeErrors) { + int errorType = 38; + SiPixelRawDataError error(errorWord, errorType, fedId); + cms_uint32_t detId = errorDetId(converter, errorType, errorWord); + errors[detId].push_back(error); + } + break; + } + default: + LogDebug("ErrorCheckerPhase0::conversionError") + << " cabling check returned unexpected result, status = " << status; + }; +} + +// this function finds the detId for an error word that cannot be processed in +// word2digi +cms_uint32_t +ErrorCheckerPhase0::errorDetId(const SiPixelFrameConverter *converter, + int errorType, const Word32 &word) const { + if (!converter) + return dummyDetId; + + ElectronicIndex cabling; + + switch (errorType) { + case 25: + case 30: + case 31: + case 36: + case 40: { + // set dummy values for cabling just to get detId from link if in Barrel + cabling.dcol = 0; + cabling.pxid = 2; + cabling.roc = 1; + cabling.link = (word >> LINK_shift) & LINK_mask; + + DetectorIndex detIdx; + int status = converter->toDetector(cabling, detIdx); + if (status) + break; + if (DetId(detIdx.rawId).subdetId() == + static_cast(PixelSubdetector::PixelBarrel)) + return detIdx.rawId; + break; + } + case 29: { + int chanNmbr = 0; + const int DB0_shift = 0; + const int DB1_shift = DB0_shift + 1; + const int DB2_shift = DB1_shift + 1; + const int DB3_shift = DB2_shift + 1; + const int DB4_shift = DB3_shift + 1; + const cms_uint32_t DataBit_mask = ~(~cms_uint32_t(0) << 1); + + int CH1 = (word >> DB0_shift) & DataBit_mask; + int CH2 = (word >> DB1_shift) & DataBit_mask; + int CH3 = (word >> DB2_shift) & DataBit_mask; + int CH4 = (word >> DB3_shift) & DataBit_mask; + int CH5 = (word >> DB4_shift) & DataBit_mask; + int BLOCK_bits = 3; + int BLOCK_shift = 8; + cms_uint32_t BLOCK_mask = ~(~cms_uint32_t(0) << BLOCK_bits); + int BLOCK = (word >> BLOCK_shift) & BLOCK_mask; + int localCH = 1 * CH1 + 2 * CH2 + 3 * CH3 + 4 * CH4 + 5 * CH5; + if (BLOCK % 2 == 0) + chanNmbr = (BLOCK / 2) * 9 + localCH; + else + chanNmbr = ((BLOCK - 1) / 2) * 9 + 4 + localCH; + if ((chanNmbr < 1) || (chanNmbr > 36)) + break; // signifies unexpected result + + // set dummy values for cabling just to get detId from link if in Barrel + cabling.dcol = 0; + cabling.pxid = 2; + cabling.roc = 1; + cabling.link = chanNmbr; + DetectorIndex detIdx; + int status = converter->toDetector(cabling, detIdx); + if (status) + break; + if (DetId(detIdx.rawId).subdetId() == + static_cast(PixelSubdetector::PixelBarrel)) + return detIdx.rawId; + break; + } + case 37: + case 38: { + cabling.dcol = 0; + cabling.pxid = 2; + cabling.roc = (word >> ROC_shift) & ROC_mask; + cabling.link = (word >> LINK_shift) & LINK_mask; + + DetectorIndex detIdx; + int status = converter->toDetector(cabling, detIdx); + if (status) + break; + + return detIdx.rawId; + break; + } + default: + break; + }; + return dummyDetId; +} diff --git a/EventFilter/SiPixelRawToDigi/src/PixelDataFormatter.cc b/EventFilter/SiPixelRawToDigi/src/PixelDataFormatter.cc index 84ce0a7d9396c..950c290490679 100644 --- a/EventFilter/SiPixelRawToDigi/src/PixelDataFormatter.cc +++ b/EventFilter/SiPixelRawToDigi/src/PixelDataFormatter.cc @@ -1,149 +1,160 @@ #include "EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h" -#include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingTree.h" #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h" +#include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingTree.h" #include "CondFormats/SiPixelObjects/interface/SiPixelFrameConverter.h" #include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h" -#include "DataFormats/FEDRawData/interface/FEDRawData.h" #include "DataFormats/FEDRawData/interface/FEDHeader.h" +#include "DataFormats/FEDRawData/interface/FEDRawData.h" #include "DataFormats/FEDRawData/interface/FEDTrailer.h" #include "CondFormats/SiPixelObjects/interface/PixelROC.h" #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h" -#include "FWCore/Utilities/interface/Exception.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Utilities/interface/Exception.h" #include -#include #include +#include using namespace std; using namespace edm; using namespace sipixelobjects; namespace { - constexpr int LINK_bits = 6; - constexpr int ROC_bits = 5; - constexpr int DCOL_bits = 5; - constexpr int PXID_bits = 8; - constexpr int ADC_bits = 8; - - // Add phase1 constants - // For phase1 - //GO BACK TO OLD VALUES. THE 48-CHAN FED DOES NOT NEED A NEW FORMAT - // 28/9/16 d.k. - constexpr int LINK_bits1 = 6; // 7; - constexpr int ROC_bits1 = 5; // 4; - // Special for layer 1 bpix rocs 6/9/16 d.k. THIS STAYS. - constexpr int COL_bits1_l1 = 6; - constexpr int ROW_bits1_l1 = 7; - - // Moved to the header file, keep commented out unti the final version is done/ - // constexpr int ADC_shift = 0; - // constexpr int PXID_shift = ADC_shift + ADC_bits; - // constexpr int DCOL_shift = PXID_shift + PXID_bits; - // constexpr int ROC_shift = DCOL_shift + DCOL_bits; - // constexpr int LINK_shift = ROC_shift + ROC_bits; - // constexpr PixelDataFormatter::Word32 LINK_mask = ~(~PixelDataFormatter::Word32(0) << LINK_bits); - // constexpr PixelDataFormatter::Word32 ROC_mask = ~(~PixelDataFormatter::Word32(0) << ROC_bits); - // constexpr PixelDataFormatter::Word32 DCOL_mask = ~(~PixelDataFormatter::Word32(0) << DCOL_bits); - // constexpr PixelDataFormatter::Word32 PXID_mask = ~(~PixelDataFormatter::Word32(0) << PXID_bits); - // constexpr PixelDataFormatter::Word32 ADC_mask = ~(~PixelDataFormatter::Word32(0) << ADC_bits); - //const bool DANEK = false; -} - -PixelDataFormatter::PixelDataFormatter( const SiPixelFedCabling* map, bool phase) - : theDigiCounter(0), theWordCounter(0), theCablingTree(map), badPixelInfo(nullptr), modulesToUnpack(nullptr), phase1(phase) -{ +constexpr int LINK_bits = 6; +constexpr int ROC_bits = 5; +constexpr int DCOL_bits = 5; +constexpr int PXID_bits = 8; +constexpr int ADC_bits = 8; + +// Add phase1 constants +// For phase1 +// GO BACK TO OLD VALUES. THE 48-CHAN FED DOES NOT NEED A NEW FORMAT +// 28/9/16 d.k. +constexpr int LINK_bits1 = 6; // 7; +constexpr int ROC_bits1 = 5; // 4; +// Special for layer 1 bpix rocs 6/9/16 d.k. THIS STAYS. +constexpr int COL_bits1_l1 = 6; +constexpr int ROW_bits1_l1 = 7; + +// Moved to the header file, keep commented out unti the final version is done/ +// constexpr int ADC_shift = 0; +// constexpr int PXID_shift = ADC_shift + ADC_bits; +// constexpr int DCOL_shift = PXID_shift + PXID_bits; +// constexpr int ROC_shift = DCOL_shift + DCOL_bits; +// constexpr int LINK_shift = ROC_shift + ROC_bits; +// constexpr PixelDataFormatter::Word32 LINK_mask = +// ~(~PixelDataFormatter::Word32(0) << LINK_bits); constexpr +// PixelDataFormatter::Word32 ROC_mask = ~(~PixelDataFormatter::Word32(0) << +// ROC_bits); constexpr PixelDataFormatter::Word32 DCOL_mask = +// ~(~PixelDataFormatter::Word32(0) << DCOL_bits); constexpr +// PixelDataFormatter::Word32 PXID_mask = ~(~PixelDataFormatter::Word32(0) << +// PXID_bits); constexpr PixelDataFormatter::Word32 ADC_mask = +// ~(~PixelDataFormatter::Word32(0) << ADC_bits); +// const bool DANEK = false; +} // namespace + +PixelDataFormatter::PixelDataFormatter(const SiPixelFedCabling *map, bool phase) + : theDigiCounter(0), theWordCounter(0), theCablingTree(map), + badPixelInfo(nullptr), modulesToUnpack(nullptr), phase1(phase) { int s32 = sizeof(Word32); int s64 = sizeof(Word64); - int s8 = sizeof(char); - if ( s8 != 1 || s32 != 4*s8 || s64 != 2*s32) { - LogError("UnexpectedSizes") - <<" unexpected sizes: " - <<" size of char is: " << s8 - <<", size of Word32 is: " << s32 - <<", size of Word64 is: " << s64 - <<", send exception" ; + int s8 = sizeof(char); + if (s8 != 1 || s32 != 4 * s8 || s64 != 2 * s32) { + LogError("UnexpectedSizes") + << " unexpected sizes: " + << " size of char is: " << s8 << ", size of Word32 is: " << s32 + << ", size of Word64 is: " << s64 << ", send exception"; } includeErrors = false; useQualityInfo = false; allDetDigis = 0; hasDetDigis = 0; - ADC_shift = 0; + ADC_shift = 0; PXID_shift = ADC_shift + ADC_bits; DCOL_shift = PXID_shift + PXID_bits; - ROC_shift = DCOL_shift + DCOL_bits; + ROC_shift = DCOL_shift + DCOL_bits; - if(phase1) { // for phase 1 + if (phase1) { // for phase 1 LINK_shift = ROC_shift + ROC_bits1; LINK_mask = ~(~PixelDataFormatter::Word32(0) << LINK_bits1); - ROC_mask = ~(~PixelDataFormatter::Word32(0) << ROC_bits1); + ROC_mask = ~(~PixelDataFormatter::Word32(0) << ROC_bits1); // special for layer 1 ROC ROW_shift = ADC_shift + ADC_bits; COL_shift = ROW_shift + ROW_bits1_l1; COL_mask = ~(~PixelDataFormatter::Word32(0) << COL_bits1_l1); ROW_mask = ~(~PixelDataFormatter::Word32(0) << ROW_bits1_l1); - maxROCIndex=8; + maxROCIndex = 8; - } else { // for phase 0 + } else { // for phase 0 LINK_shift = ROC_shift + ROC_bits; LINK_mask = ~(~PixelDataFormatter::Word32(0) << LINK_bits); - ROC_mask = ~(~PixelDataFormatter::Word32(0) << ROC_bits); - maxROCIndex=25; + ROC_mask = ~(~PixelDataFormatter::Word32(0) << ROC_bits); + maxROCIndex = 25; } DCOL_mask = ~(~PixelDataFormatter::Word32(0) << DCOL_bits); PXID_mask = ~(~PixelDataFormatter::Word32(0) << PXID_bits); - ADC_mask = ~(~PixelDataFormatter::Word32(0) << ADC_bits); + ADC_mask = ~(~PixelDataFormatter::Word32(0) << ADC_bits); + if (phase1 == true) { + errorcheck = std::unique_ptr(new ErrorChecker()); + } else { + errorcheck = std::unique_ptr(new ErrorCheckerPhase0()); + } } -void PixelDataFormatter::setErrorStatus(bool ErrorStatus) -{ +void PixelDataFormatter::setErrorStatus(bool ErrorStatus) { includeErrors = ErrorStatus; - errorcheck.setErrorStatus(includeErrors); + errorcheck->setErrorStatus(includeErrors); } -void PixelDataFormatter::setQualityStatus(bool QualityStatus, const SiPixelQuality* QualityInfo) -{ +void PixelDataFormatter::setQualityStatus(bool QualityStatus, + const SiPixelQuality *QualityInfo) { useQualityInfo = QualityStatus; badPixelInfo = QualityInfo; } -void PixelDataFormatter::setModulesToUnpack(const std::set * moduleIds) -{ +void PixelDataFormatter::setModulesToUnpack( + const std::set *moduleIds) { modulesToUnpack = moduleIds; } -void PixelDataFormatter::passFrameReverter(const SiPixelFrameReverter* reverter) -{ +void PixelDataFormatter::passFrameReverter( + const SiPixelFrameReverter *reverter) { theFrameReverter = reverter; } -void PixelDataFormatter::interpretRawData(bool& errorsInEvent, int fedId, const FEDRawData& rawData, Collection & digis, Errors& errors) -{ +void PixelDataFormatter::interpretRawData(bool &errorsInEvent, int fedId, + const FEDRawData &rawData, + Collection &digis, Errors &errors) { using namespace sipixelobjects; - int nWords = rawData.size()/sizeof(Word64); - if (nWords==0) return; + int nWords = rawData.size() / sizeof(Word64); + if (nWords == 0) + return; SiPixelFrameConverter converter(theCablingTree, fedId); // check CRC bit - const Word64* trailer = reinterpret_cast(rawData.data())+(nWords-1); - if(!errorcheck.checkCRC(errorsInEvent, fedId, trailer, errors)) return; + const Word64 *trailer = + reinterpret_cast(rawData.data()) + (nWords - 1); + if (!errorcheck->checkCRC(errorsInEvent, fedId, trailer, errors)) + return; // check headers - const Word64* header = reinterpret_cast(rawData.data()); header--; + const Word64 *header = reinterpret_cast(rawData.data()); + header--; bool moreHeaders = true; while (moreHeaders) { header++; - LogTrace("")<<"HEADER: " << print(*header); - bool headerStatus = errorcheck.checkHeader(errorsInEvent, fedId, header, errors); + LogTrace("") << "HEADER: " << print(*header); + bool headerStatus = + errorcheck->checkHeader(errorsInEvent, fedId, header, errors); moreHeaders = headerStatus; } @@ -152,122 +163,148 @@ void PixelDataFormatter::interpretRawData(bool& errorsInEvent, int fedId, const trailer++; while (moreTrailers) { trailer--; - LogTrace("")<<"TRAILER: " << print(*trailer); - bool trailerStatus = errorcheck.checkTrailer(errorsInEvent, fedId, nWords, trailer, errors); + LogTrace("") << "TRAILER: " << print(*trailer); + bool trailerStatus = + errorcheck->checkTrailer(errorsInEvent, fedId, nWords, trailer, errors); moreTrailers = trailerStatus; } // data words - theWordCounter += 2*(nWords-2); - LogTrace("")<<"data words: "<< (trailer-header-1); + theWordCounter += 2 * (nWords - 2); + LogTrace("") << "data words: " << (trailer - header - 1); int link = -1; - int roc = -1; + int roc = -1; int layer = 0; - PixelROC const * rocp=nullptr; - bool skipROC=false; - edm::DetSet * detDigis=nullptr; - - const Word32 * bw =(const Word32 *)(header+1); - const Word32 * ew =(const Word32 *)(trailer); - if ( *(ew-1) == 0 ) { ew--; theWordCounter--;} + PixelROC const *rocp = nullptr; + bool skipROC = false; + edm::DetSet *detDigis = nullptr; + + const Word32 *bw = (const Word32 *)(header + 1); + const Word32 *ew = (const Word32 *)(trailer); + if (*(ew - 1) == 0) { + ew--; + theWordCounter--; + } for (auto word = bw; word < ew; ++word) { - LogTrace("")<<"DATA: " << print(*word); + LogTrace("") << "DATA: " << print(*word); auto ww = *word; - if UNLIKELY(ww==0) { theWordCounter--; continue;} - int nlink = (ww >> LINK_shift) & LINK_mask; - int nroc = (ww >> ROC_shift) & ROC_mask; - - //if(DANEK) cout<<" fed, link, roc "<> LINK_shift) & LINK_mask; + int nroc = (ww >> ROC_shift) & ROC_mask; + + // if(DANEK) cout<<" fed, link, roc "<checkROC(errorsInEvent, fedId, &converter, + theCablingTree, ww, errors); + if (skipROC) + continue; + rocp = converter.toRoc(link, roc); + if + UNLIKELY(!rocp) { + errorsInEvent = true; + errorcheck->conversionError(fedId, &converter, 2, ww, errors); + skipROC = true; + continue; + } auto rawId = rocp->rawId(); bool barrel = PixelModuleName::isBarrel(rawId); - if(barrel) layer = PixelROC::bpixLayerPhase1(rawId); - else layer=0; + if (barrel) + layer = PixelROC::bpixLayerPhase1(rawId); + else + layer = 0; - //if(DANEK) cout<<" rocp "<print()<<" layer "<bpixLayerPhase1(rawId)<<" " + // if(DANEK) cout<<" rocp "<print()<<" layer + // "<bpixLayerPhase1(rawId)<<" " // <idInDetUnit(); - skipROC = badPixelInfo->IsRocBad(rawId, rocInDet); - if (skipROC) continue; + if (useQualityInfo & (nullptr != badPixelInfo)) { + short rocInDet = (short)rocp->idInDetUnit(); + skipROC = badPixelInfo->IsRocBad(rawId, rocInDet); + if (skipROC) + continue; } - skipROC= modulesToUnpack && ( modulesToUnpack->find(rawId) == modulesToUnpack->end()); - if (skipROC) continue; - + skipROC = modulesToUnpack && + (modulesToUnpack->find(rawId) == modulesToUnpack->end()); + if (skipROC) + continue; + detDigis = &digis.find_or_insert(rawId); - if ( (*detDigis).empty() ) (*detDigis).data.reserve(32); // avoid the first relocations + if ((*detDigis).empty()) + (*detDigis).data.reserve(32); // avoid the first relocations } // skip is roc to be skipped ot invalid - if UNLIKELY(skipROC || !rocp) continue; - - int adc = (ww >> ADC_shift) & ADC_mask; + if + UNLIKELY(skipROC || !rocp) continue; + + int adc = (ww >> ADC_shift) & ADC_mask; std::unique_ptr local; - if(phase1 && layer==1) { // special case for layer 1ROC - // for l1 roc use the roc column and row index instead of dcol and pixel index. + if (phase1 && layer == 1) { // special case for layer 1ROC + // for l1 roc use the roc column and row index instead of dcol and pixel + // index. int col = (ww >> COL_shift) & COL_mask; int row = (ww >> ROW_shift) & ROW_mask; - //if(DANEK) cout<<" layer 1: raw2digi "<(localCR); // local pixel coordinate - //if(DANEK) cout<dcol()<<" "<pxid()<<" "<rocCol()<<" "<rocRow()<conversionError(fedId, &converter, 3, ww, errors); + continue; + } + local = std::make_unique(localCR); // local pixel coordinate + // if(DANEK) cout<dcol()<<" "<pxid()<<" + // "<rocCol()<<" "<rocRow()<> DCOL_shift) & DCOL_mask; int pxid = (ww >> PXID_shift) & PXID_mask; - //if(DANEK) cout<<" raw2digi "<(localDP); // local pixel coordinate - //if(DANEK) cout<dcol()<<" "<pxid()<<" "<rocCol()<<" "<rocRow()<toGlobal( *local ); // global pixel coordinate (in module) + + LocalPixel::DcolPxid localDP = {dcol, pxid}; + // if(DANEK) cout<conversionError(fedId, &converter, 3, ww, errors); + continue; + } + local = std::make_unique(localDP); // local pixel coordinate + // if(DANEK) cout<dcol()<<" "<pxid()<<" + // "<rocCol()<<" "<rocRow()<toGlobal(*local); // global pixel coordinate (in module) (*detDigis).data.emplace_back(global.row, global.col, adc); - //if(DANEK) cout<> DCOL_shift) & DCOL_mask; @@ -280,228 +317,242 @@ void PixelDataFormatter::interpretRawData(bool& errorsInEvent, int fedId, const // } // } - -void PixelDataFormatter::formatRawData(unsigned int lvl1_ID, RawData & fedRawData, const Digis & digis, const BadChannels & badChannels) -{ - std::map > words; +void PixelDataFormatter::formatRawData(unsigned int lvl1_ID, + RawData &fedRawData, const Digis &digis, + const BadChannels &badChannels) { + std::map> words; // translate digis into 32-bit raw words and store in map indexed by Fed for (Digis::const_iterator im = digis.begin(); im != digis.end(); im++) { allDetDigis++; cms_uint32_t rawId = im->first; - int layer=0; + int layer = 0; bool barrel = PixelModuleName::isBarrel(rawId); - if(barrel) layer = PixelROC::bpixLayerPhase1(rawId); - //if(DANEK) cout<<" layer "<second; - for (DetDigis::const_iterator it = detDigis.begin(); it != detDigis.end(); it++) { + const DetDigis &detDigis = im->second; + for (DetDigis::const_iterator it = detDigis.begin(); it != detDigis.end(); + it++) { theDigiCounter++; - const PixelDigi & digi = (*it); - int fedId=0; - - if(layer==1 && phase1) fedId = digi2wordPhase1Layer1( rawId, digi, words); - else fedId = digi2word( rawId, digi, words); - - if (fedId<0) { - LogError("FormatDataException") - <<" digi2word returns error #"<second.begin(), - detBadChannels->second.end(), - [&] (const PixelFEDChannel& ch) { - return (int(ch.fed)==fedId && ch.link==linkId(words[fedId].back())); - }); - if (badChannel!=detBadChannels->second.end()) { - LogError("FormatDataException") - <<" while marked bad, found digi for FED "<second.begin(), detBadChannels->second.end(), + [&](const PixelFEDChannel &ch) { + return (int(ch.fed) == fedId && + ch.link == linkId(words[fedId].back())); + }); + if (badChannel != detBadChannels->second.end()) { + LogError("FormatDataException") + << " while marked bad, found digi for FED " << fedId << " Link " + << linkId(words[fedId].back()) << " on module " << rawId << endl + << print(digi) << endl; + } } // if (fedId) - } // for (DetDigis - } // for (Digis - LogTrace(" allDetDigis/hasDetDigis : ") << allDetDigis<<"/"< >::const_iterator RI; + typedef std::map>::const_iterator RI; for (RI feddata = words.begin(); feddata != words.end(); feddata++) { int fedId = feddata->first; // since raw words are written in the form of 64-bit packets // add extra 32-bit word to make number of words even if necessary - if (words.find(fedId)->second.size() %2 != 0) words[fedId].push_back( Word32(0) ); + if (words.find(fedId)->second.size() % 2 != 0) + words[fedId].push_back(Word32(0)); // size in Bytes; create output structure int dataSize = words.find(fedId)->second.size() * sizeof(Word32); int nHeaders = 1; int nTrailers = 1; - dataSize += (nHeaders+nTrailers)*sizeof(Word64); - FEDRawData * rawData = new FEDRawData(dataSize); + dataSize += (nHeaders + nTrailers) * sizeof(Word64); + FEDRawData *rawData = new FEDRawData(dataSize); // get begining of data; - Word64 * word = reinterpret_cast(rawData->data()); + Word64 *word = reinterpret_cast(rawData->data()); // write one header - FEDHeader::set( reinterpret_cast(word), 0, lvl1_ID, 0, fedId); + FEDHeader::set(reinterpret_cast(word), 0, lvl1_ID, 0, + fedId); word++; // write data unsigned int nWord32InFed = words.find(fedId)->second.size(); - for (unsigned int i=0; i < nWord32InFed; i+=2) { - *word = (Word64(words.find(fedId)->second[i+1]) << 32 ) | words.find(fedId)->second[i]; - LogDebug("PixelDataFormatter") << print(*word); + for (unsigned int i = 0; i < nWord32InFed; i += 2) { + *word = (Word64(words.find(fedId)->second[i + 1]) << 32) | + words.find(fedId)->second[i]; + LogDebug("PixelDataFormatter") << print(*word); word++; } // write one trailer - FEDTrailer::set( reinterpret_cast(word), dataSize/sizeof(Word64), 0,0,0); + FEDTrailer::set(reinterpret_cast(word), + dataSize / sizeof(Word64), 0, 0, 0); word++; // check memory - if (word != reinterpret_cast(rawData->data()+dataSize)) { + if (word != reinterpret_cast(rawData->data() + dataSize)) { string s = "** PROBLEM in PixelDataFormatter !!!"; throw cms::Exception(s); } // if (word != fedRawData[fedId] = *rawData; delete rawData; - } // for (RI feddata + } // for (RI feddata } -int PixelDataFormatter::digi2word( cms_uint32_t detId, const PixelDigi& digi, - std::map > & words) const -{ +int PixelDataFormatter::digi2word(cms_uint32_t detId, const PixelDigi &digi, + std::map> &words) const { LogDebug("PixelDataFormatter") -// <<" detId: " << detId - <toCabling(cabling, detector); - if (fedId<0) return fedId; - - //if(DANEK) cout<<" digi2raw "<toCabling(cabling, detector); + if (fedId < 0) + return fedId; + + // if(DANEK) cout<<" digi2raw "< > & words) const -{ +int PixelDataFormatter::digi2wordPhase1Layer1( + cms_uint32_t detId, const PixelDigi &digi, + std::map> &words) const { LogDebug("PixelDataFormatter") -// <<" detId: " << detId - <toCabling(cabling, detector); - if (fedId<0) return fedId; + int fedId = theFrameReverter->toCabling(cabling, detector); + if (fedId < 0) + return fedId; - int col = ((cabling.dcol)*2) + ((cabling.pxid)%2); - int row = LocalPixel::numRowsInRoc - ((cabling.pxid)/2); + int col = ((cabling.dcol) * 2) + ((cabling.pxid) % 2); + int row = LocalPixel::numRowsInRoc - ((cabling.pxid) / 2); - //if(DANEK) cout<<" layer 1: digi2raw "<> DCOL_shift) & DCOL_mask; cabling.pxid = (word >> PXID_shift) & PXID_mask; cabling.link = (word >> LINK_shift) & LINK_mask; - cabling.roc = (word >> ROC_shift) & ROC_mask; - int adc = (word >> ADC_shift) & ADC_mask; + cabling.roc = (word >> ROC_shift) & ROC_mask; + int adc = (word >> ADC_shift) & ADC_mask; if (debug) { - LocalPixel::DcolPxid pixel = {cabling.dcol,cabling.pxid}; + LocalPixel::DcolPxid pixel = {cabling.dcol, cabling.pxid}; LocalPixel local(pixel); - LogTrace("")<<" link: "<toDetector(cabling, detIdx); - if (status) return status; + if (status) + return status; // exclude ROC(raw) based on bad ROC list bad in SiPixelQuality // enable: process.siPixelDigis.UseQualityInfo = True // 20-10-2010 A.Y. - if (useQuality&&badPixelInfo) { + if (useQuality && badPixelInfo) { CablingPathToDetUnit path = {static_cast(fedId), static_cast(cabling.link), static_cast(cabling.roc)}; - const PixelROC * roc = theCablingTree->findItem(path); - short rocInDet = (short) roc->idInDetUnit(); + const PixelROC *roc = theCablingTree->findItem(path); + short rocInDet = (short)roc->idInDetUnit(); bool badROC = badPixelInfo->IsRocBad(detIdx.rawId, rocInDet); - if (badROC) return 0; + if (badROC) + return 0; } - if (modulesToUnpack && modulesToUnpack->find(detIdx.rawId) == modulesToUnpack->end()) return 0; + if (modulesToUnpack && + modulesToUnpack->find(detIdx.rawId) == modulesToUnpack->end()) + return 0; digis[detIdx.rawId].emplace_back(detIdx.row, detIdx.col, adc); theDigiCounter++; - if (debug) LogTrace("") << digis[detIdx.rawId].back(); + if (debug) + LogTrace("") << digis[detIdx.rawId].back(); return 0; } -std::string PixelDataFormatter::print(const PixelDigi & digi) const -{ +std::string PixelDataFormatter::print(const PixelDigi &digi) const { ostringstream str; - str << " DIGI: row: " << digi.row() <<", col: " << digi.column() <<", adc: " << digi.adc(); + str << " DIGI: row: " << digi.row() << ", col: " << digi.column() + << ", adc: " << digi.adc(); return str.str(); } -std::string PixelDataFormatter::print(const Word64 & word) const -{ +std::string PixelDataFormatter::print(const Word64 &word) const { ostringstream str; - str <<"word64: " << reinterpret_cast&> (word); + str << "word64: " << reinterpret_cast &>(word); return str.str(); } - diff --git a/EventFilter/SiPixelRawToDigi/src/PixelUnpackingRegions.cc b/EventFilter/SiPixelRawToDigi/src/PixelUnpackingRegions.cc index a75b066fd5631..af6ac8e3fbdf1 100644 --- a/EventFilter/SiPixelRawToDigi/src/PixelUnpackingRegions.cc +++ b/EventFilter/SiPixelRawToDigi/src/PixelUnpackingRegions.cc @@ -4,51 +4,54 @@ #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/ESTransientHandle.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" -#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" #include "DataFormats/BeamSpot/interface/BeamSpot.h" -#include "DataFormats/FEDRawData/interface/FEDNumbering.h" #include "DataFormats/Candidate/interface/LeafCandidate.h" -#include "FWCore/Framework/interface/ConsumesCollector.h" #include "DataFormats/FEDRawData/interface/FEDNumbering.h" +#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" #include #include // local convenience functions namespace { - bool isBPIXModule(unsigned int id) {return DetId(id).subdetId() == PixelSubdetector::PixelBarrel;} - bool isFPIXModule(unsigned int id) {return DetId(id).subdetId() == PixelSubdetector::PixelEndcap;} +bool isBPIXModule(unsigned int id) { + return DetId(id).subdetId() == PixelSubdetector::PixelBarrel; } +bool isFPIXModule(unsigned int id) { + return DetId(id).subdetId() == PixelSubdetector::PixelEndcap; +} +} // namespace -PixelUnpackingRegions::PixelUnpackingRegions(const edm::ParameterSet& conf, edm::ConsumesCollector &&iC) -{ +PixelUnpackingRegions::PixelUnpackingRegions(const edm::ParameterSet &conf, + edm::ConsumesCollector &&iC) { edm::ParameterSet regPSet = conf.getParameter("Regions"); beamSpotTag_ = regPSet.getParameter("beamSpot"); - inputs_ = regPSet.getParameter >("inputs"); - dPhi_ = regPSet.getParameter >("deltaPhi"); - maxZ_ = regPSet.getParameter >("maxZ"); + inputs_ = regPSet.getParameter>("inputs"); + dPhi_ = regPSet.getParameter>("deltaPhi"); + maxZ_ = regPSet.getParameter>("maxZ"); tBeamSpot = iC.consumes(beamSpotTag_); - for (unsigned int t=0; t(inputs_[t])); - - if (inputs_.size() != dPhi_.size() || dPhi_.size() != maxZ_.size() ) - { - edm::LogError("PixelUnpackingRegions")<<"Not the same size of config parameters vectors!\n" - <<" inputs "<(inputs_[t])); + + if (inputs_.size() != dPhi_.size() || dPhi_.size() != maxZ_.size()) { + edm::LogError("PixelUnpackingRegions") + << "Not the same size of config parameters vectors!\n" + << " inputs " << inputs_.size() << " deltaPhi " << dPhi_.size() + << " maxZ " << maxZ_.size(); } - } - -void PixelUnpackingRegions::run(const edm::Event& e, const edm::EventSetup& es) -{ +void PixelUnpackingRegions::run(const edm::Event &e, + const edm::EventSetup &es) { feds_.clear(); modules_.clear(); nreg_ = 0; @@ -58,18 +61,16 @@ void PixelUnpackingRegions::run(const edm::Event& e, const edm::EventSetup& es) edm::Handle beamSpot; e.getByToken(tBeamSpot, beamSpot); beamSpot_ = beamSpot->position(); - //beamSpot_ = math::XYZPoint(0.,0.,0.); + // beamSpot_ = math::XYZPoint(0.,0.,0.); size_t ninputs = inputs_.size(); - for(size_t input = 0; input < ninputs; ++input) - { - edm::Handle< reco::CandidateView > h; + for (size_t input = 0; input < ninputs; ++input) { + edm::Handle h; e.getByToken(tCandidateView[input], h); size_t n = h->size(); - for(size_t i = 0; i < n; ++i ) - { - const reco::Candidate & c = (*h)[i]; + for (size_t i = 0; i < n; ++i) { + const reco::Candidate &c = (*h)[i]; // different input collections can have different dPhi and maxZ Region r(c.momentum(), dPhi_[input], maxZ_[input]); @@ -78,31 +79,27 @@ void PixelUnpackingRegions::run(const edm::Event& e, const edm::EventSetup& es) } } - -void PixelUnpackingRegions::initialize(const edm::EventSetup& es) -{ +void PixelUnpackingRegions::initialize(const edm::EventSetup &es) { // initialize cabling map or update it if necessary // and re-cache modules information - if (watcherSiPixelFedCablingMap_.check( es )) - { + if (watcherSiPixelFedCablingMap_.check(es)) { edm::ESTransientHandle cablingMap; - es.get().get( cablingMap ); + es.get().get(cablingMap); cabling_ = cablingMap->cablingTree(); edm::ESHandle geom; // get the TrackerGeom - es.get().get( geom ); + es.get().get(geom); - // switch on the phase1 + // switch on the phase1 unsigned int fedMin = FEDNumbering::MINSiPixelFEDID; // phase0 unsigned int fedMax = FEDNumbering::MAXSiPixelFEDID; - if( (geom->isThere(GeomDetEnumerators::P1PXB)) && - (geom->isThere(GeomDetEnumerators::P1PXEC)) ) { + if ((geom->isThere(GeomDetEnumerators::P1PXB)) && + (geom->isThere(GeomDetEnumerators::P1PXEC))) { fedMin = FEDNumbering::MINSiPixeluTCAFEDID; // phase1 fedMax = FEDNumbering::MAXSiPixeluTCAFEDID; } - phiBPIX_.clear(); phiFPIXp_.clear(); phiFPIXm_.clear(); @@ -112,11 +109,11 @@ void PixelUnpackingRegions::initialize(const edm::EventSetup& es) phiFPIXm_.reserve(512); auto it = geom->dets().begin(); - for ( ; it != geom->dets().end(); ++it) - { + for (; it != geom->dets().end(); ++it) { int subdet = (*it)->geographicalId().subdetId(); - if (! (subdet == PixelSubdetector::PixelBarrel || - subdet == PixelSubdetector::PixelEndcap) ) continue; + if (!(subdet == PixelSubdetector::PixelBarrel || + subdet == PixelSubdetector::PixelEndcap)) + continue; Module m; @@ -127,32 +124,30 @@ void PixelUnpackingRegions::initialize(const edm::EventSetup& es) m.phi = (*it)->position().phi(); m.id = (*it)->geographicalId().rawId(); - const std::vector path2det = cabling_->pathToDetUnit(m.id); + const std::vector path2det = + cabling_->pathToDetUnit(m.id); m.fed = path2det[0].fed; - assert( (m.fed<=fedMax) && (m.fed>=fedMin) ); + assert((m.fed <= fedMax) && (m.fed >= fedMin)); - if (subdet == PixelSubdetector::PixelBarrel) - { + if (subdet == PixelSubdetector::PixelBarrel) { phiBPIX_.push_back(m); - } - else if (subdet == PixelSubdetector::PixelEndcap) - { - if (m.z > 0.) phiFPIXp_.push_back(m); - else phiFPIXm_.push_back(m); + } else if (subdet == PixelSubdetector::PixelEndcap) { + if (m.z > 0.) + phiFPIXp_.push_back(m); + else + phiFPIXm_.push_back(m); } } // pre-sort by phi - std::sort(phiBPIX_.begin(), phiBPIX_.end()); + std::sort(phiBPIX_.begin(), phiBPIX_.end()); std::sort(phiFPIXp_.begin(), phiFPIXp_.end()); std::sort(phiFPIXm_.begin(), phiFPIXm_.end()); } } - -void PixelUnpackingRegions::addRegion(Region &r) -{ +void PixelUnpackingRegions::addRegion(Region &r) { ++nreg_; float phi = r.v.phi(); @@ -161,82 +156,81 @@ void PixelUnpackingRegions::addRegion(Region &r) Module hi(phi + r.dPhi); addRegionLocal(r, phiBPIX_, lo, hi); - if (r.v.eta() > 1.) - { + if (r.v.eta() > 1.) { addRegionLocal(r, phiFPIXp_, lo, hi); } - if (r.v.eta() < -1.) - { + if (r.v.eta() < -1.) { addRegionLocal(r, phiFPIXm_, lo, hi); } } - -void PixelUnpackingRegions::addRegionLocal(Region &r, std::vector &container,const Module& _lo,const Module& _hi) -{ +void PixelUnpackingRegions::addRegionLocal(Region &r, + std::vector &container, + const Module &_lo, + const Module &_hi) { Module lo = _lo; Module hi = _hi; Module pi_m(-M_PI); - Module pi_p( M_PI); + Module pi_p(M_PI); std::vector::const_iterator a, b; - if (lo.phi >= -M_PI && hi.phi <= M_PI) // interval doesn't cross the +-pi overlap + if (lo.phi >= -M_PI && + hi.phi <= M_PI) // interval doesn't cross the +-pi overlap { a = lower_bound(container.begin(), container.end(), lo); b = upper_bound(container.begin(), container.end(), hi); gatherFromRange(r, a, b); - } - else // interval is torn by the +-pi overlap + } else // interval is torn by the +-pi overlap { - if (hi.phi > M_PI) hi.phi -= 2.*M_PI; + if (hi.phi > M_PI) + hi.phi -= 2. * M_PI; a = lower_bound(container.begin(), container.end(), pi_m); b = upper_bound(container.begin(), container.end(), hi); gatherFromRange(r, a, b); - if (lo.phi < -M_PI) lo.phi += 2.*M_PI; + if (lo.phi < -M_PI) + lo.phi += 2. * M_PI; a = lower_bound(container.begin(), container.end(), lo); b = upper_bound(container.begin(), container.end(), pi_p); gatherFromRange(r, a, b); } } - -void PixelUnpackingRegions::gatherFromRange(Region &r, std::vector::const_iterator a, std::vector::const_iterator b) -{ - for(; a != b; ++a) - { +void PixelUnpackingRegions::gatherFromRange( + Region &r, std::vector::const_iterator a, + std::vector::const_iterator b) { + for (; a != b; ++a) { // projection in r's direction onto beam's z - float zmodule = a->z - ( (a->x - beamSpot_.x())*r.cosphi + (a->y - beamSpot_.y())*r.sinphi ) * r.atantheta; + float zmodule = a->z - ((a->x - beamSpot_.x()) * r.cosphi + + (a->y - beamSpot_.y()) * r.sinphi) * + r.atantheta; // do not include modules that project too far in z - if ( std::abs(zmodule) > r.maxZ ) continue; + if (std::abs(zmodule) > r.maxZ) + continue; feds_.insert(a->fed); modules_.insert(a->id); } } - -bool PixelUnpackingRegions::mayUnpackFED(unsigned int fed_n) const -{ - if (feds_.count(fed_n)) return true; +bool PixelUnpackingRegions::mayUnpackFED(unsigned int fed_n) const { + if (feds_.count(fed_n)) + return true; return false; } - -bool PixelUnpackingRegions::mayUnpackModule(unsigned int id) const -{ - if (modules_.count(id)) return true; +bool PixelUnpackingRegions::mayUnpackModule(unsigned int id) const { + if (modules_.count(id)) + return true; return false; } -unsigned int PixelUnpackingRegions::nBarrelModules() const -{ - return std::count_if(modules_.begin(), modules_.end(), isBPIXModule ); +unsigned int PixelUnpackingRegions::nBarrelModules() const { + return std::count_if(modules_.begin(), modules_.end(), isBPIXModule); } -unsigned int PixelUnpackingRegions::nForwardModules() const -{ - return std::count_if(modules_.begin(), modules_.end(), isFPIXModule ); +unsigned int PixelUnpackingRegions::nForwardModules() const { + return std::count_if(modules_.begin(), modules_.end(), isFPIXModule); } diff --git a/EventFilter/SiPixelRawToDigi/test/FedErrorDumper.cc b/EventFilter/SiPixelRawToDigi/test/FedErrorDumper.cc index e68dee2981459..4ab28ea3a5b8b 100644 --- a/EventFilter/SiPixelRawToDigi/test/FedErrorDumper.cc +++ b/EventFilter/SiPixelRawToDigi/test/FedErrorDumper.cc @@ -1,5 +1,5 @@ /** \class SiPixelRawDumper_H - * Plug-in module that dump raw data file + * Plug-in module that dump raw data file * for pixel subdetector * Added class to interpret the data d.k. 30/10/08 * Add histograms. Add pix 0 detection. @@ -11,207 +11,225 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" - #include "DataFormats/Common/interface/Handle.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" #include "DataFormats/FEDRawData/interface/FEDRawData.h" +#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/FEDRawData/interface/FEDNumbering.h" #include "EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h" -// for detids -#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" +// for detids +#include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/SiPixelDetId/interface/PXBDetId.h" #include "DataFormats/SiPixelDetId/interface/PXFDetId.h" #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h" -#include "DataFormats/DetId/interface/DetId.h" - +#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h" // For L1 NOT IN RAW //#include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtUtils.h" -//#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h" +//#include +//"DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h" //#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h" -//#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h" -//#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMapRecord.h" - +//#include +//"DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h" +//#include +//"DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMapRecord.h" // To use root histos -#include "FWCore/ServiceRegistry/interface/Service.h" #include "CommonTools/UtilAlgos/interface/TFileService.h" +#include "FWCore/ServiceRegistry/interface/Service.h" // For ROOT #include //#include -#include #include -#include +#include #include - +#include #include using namespace std; - // Include the helper decoding class ///////////////////////////////////////////////////////////////////////////// class MyDecode { public: MyDecode() {} ~MyDecode() {} - static int error(int error, int & fedChannel, int fed, bool print=false); - static int data(int error, int & fedChannel, int fed, bool print=false); + static int error(int error, int &fedChannel, int fed, bool print = false); + static int data(int error, int &fedChannel, int fed, bool print = false); static int header(unsigned long long word64, int fed, bool print); static int trailer(unsigned long long word64, int fed, bool print); + private: }; ///////////////////////////////////////////////////////////////////////////// int MyDecode::header(unsigned long long word64, int fed, bool print) { - int fed_id=(word64>>8)&0xfff; - int event_id=(word64>>32)&0xffffff; - unsigned int bx_id=(word64>>20)&0xfff; -// if(bx_id!=101) { -// cout<<" Header "<<" for FED " -// <>dummy; -// } - if(print) cout<<" Header "<<" for FED " - <> 8) & 0xfff; + int event_id = (word64 >> 32) & 0xffffff; + unsigned int bx_id = (word64 >> 20) & 0xfff; + // if(bx_id!=101) { + // cout<<" Header "<<" for FED " + // <>dummy; + // } + if (print) + cout << " Header " + << " for FED " << fed_id << " event " << event_id << " bx " << bx_id + << endl; return event_id; } // int MyDecode::trailer(unsigned long long word64, int fed, bool print) { - int slinkLength = int( (word64>>32) & 0xffffff ); - int crc = int( (word64&0xffff0000)>>16 ); - int tts = int( (word64&0xf0)>>4); - int slinkError = int( (word64&0xf00)>>8); - if(print) cout<<" Trailer "<<" len "<> 32) & 0xffffff); + int crc = int((word64 & 0xffff0000) >> 16); + int tts = int((word64 & 0xf0) >> 4); + int slinkError = int((word64 & 0xf00) >> 8); + if (print) + cout << " Trailer " + << " len " << slinkLength << " tts " << tts << " error " << slinkError + << " crc " << hex << crc << dec << endl; return slinkLength; } // // Decode error FIFO // Works for both, the error FIFO and the SLink error words. d.k. 25/04/07 -int MyDecode::error(int word, int & fedChannel, int fed, bool print) { +int MyDecode::error(int word, int &fedChannel, int fed, bool print) { int status = -1; - const unsigned int errorMask = 0x3e00000; - const unsigned int dummyMask = 0x03600000; - const unsigned int gapMask = 0x03400000; - const unsigned int timeOut = 0x3a00000; - const unsigned int eventNumError = 0x3e00000; - const unsigned int trailError = 0x3c00000; - const unsigned int fifoError = 0x3800000; - -// const unsigned int timeOutChannelMask = 0x1f; // channel mask for timeouts - //const unsigned int eventNumMask = 0x1fe000; // event number mask - const unsigned int channelMask = 0xfc000000; // channel num mask - const unsigned int tbmEventMask = 0xff; // tbm event num mask - const unsigned int overflowMask = 0x100; // data overflow - const unsigned int tbmStatusMask = 0xff; //TBM trailer info - const unsigned int BlkNumMask = 0x700; //pointer to error fifo # - const unsigned int FsmErrMask = 0x600; //pointer to FSM errors - const unsigned int RocErrMask = 0x800; //pointer to #Roc errors - const unsigned int ChnFifMask = 0x1f; //channel mask for fifo error - const unsigned int Fif2NFMask = 0x40; //mask for fifo2 NF - const unsigned int TrigNFMask = 0x80; //mask for trigger fifo NF - - const int offsets[8] = {0,4,9,13,18,22,27,31}; + const unsigned int errorMask = 0x3e00000; + const unsigned int dummyMask = 0x03600000; + const unsigned int gapMask = 0x03400000; + const unsigned int timeOut = 0x3a00000; + const unsigned int eventNumError = 0x3e00000; + const unsigned int trailError = 0x3c00000; + const unsigned int fifoError = 0x3800000; + + // const unsigned int timeOutChannelMask = 0x1f; // channel mask for + // timeouts + // const unsigned int eventNumMask = 0x1fe000; // event number mask + const unsigned int channelMask = 0xfc000000; // channel num mask + const unsigned int tbmEventMask = 0xff; // tbm event num mask + const unsigned int overflowMask = 0x100; // data overflow + const unsigned int tbmStatusMask = 0xff; // TBM trailer info + const unsigned int BlkNumMask = 0x700; // pointer to error fifo # + const unsigned int FsmErrMask = 0x600; // pointer to FSM errors + const unsigned int RocErrMask = 0x800; // pointer to #Roc errors + const unsigned int ChnFifMask = 0x1f; // channel mask for fifo error + const unsigned int Fif2NFMask = 0x40; // mask for fifo2 NF + const unsigned int TrigNFMask = 0x80; // mask for trigger fifo NF + + const int offsets[8] = {0, 4, 9, 13, 18, 22, 27, 31}; unsigned int channel = 0; - //cout<<"error word "<>8; - int offset = offsets[chip]; - if(print) cout<<"Timeout Error- channel: "; - for(int i=0;i<5;i++) { - if( (index & 0x1) != 0) { - channel = offset + i + 1; - if(print) cout<> 1; - } - //if(print) cout<<" for Fed "<>26; - unsigned int tbm_event = (word & tbmEventMask); - - if(print) cout<<"Event Number Error- channel: "<>26; - unsigned int tbm_status = (word & tbmStatusMask); - - - if(tbm_status!=0) { - if(print) cout<<"Trailer Error- "<<"channel: "<> 8; + int offset = offsets[chip]; + if (print) + cout << "Timeout Error- channel: "; + for (int i = 0; i < 5; i++) { + if ((index & 0x1) != 0) { + channel = offset + i + 1; + if (print) + cout << channel << " "; + } + index = index >> 1; } + // if(print) cout<<" for Fed "<> 26; + unsigned int tbm_event = (word & tbmEventMask); - if(word & RocErrMask) { - if(print) cout<<"Number of Rocs Error- "<<"channel: "<> 26; + unsigned int tbm_status = (word & tbmStatusMask); + + if (tbm_status != 0) { + if (print) + cout << "Trailer Error- " + << "channel: " << channel << " TBM status:0x" << hex << tbm_status + << dec << " "; // <>9)<> 9) << dec << " "; // <>21); + int roc = ((word & rocmsk) >> 21); // Check for embeded special words - if(roc>0 && roc<25) { // valid ROCs go from 1-24 - //if(print) cout<<"data "<>26); - if(channel>0 && channel<37) { // valid channels 1-36 - //cout<>16; - int pix=(word&pxlmsk)>>8; - int adc=(word&plsmsk); + if (roc > 0 && roc < 25) { // valid ROCs go from 1-24 + // if(print) cout<<"data "<> 26); + if (channel > 0 && channel < 37) { // valid channels 1-36 + // cout<> 16; + int pix = (word & pxlmsk) >> 8; + int adc = (word & plsmsk); fedChannel = channel; // print the roc number according to the online 0-15 scheme - if(print) { - int dcol1 = dcol/6; - int dcol2 = dcol%6; - int pix1 = pix/36; - int pix2 = (pix%36)/6; - int pix3 = pix%6; - cout<<" Fed "<25) { - if(print) cout<<" Fed "<181) { - if(print) cout<<" Fed "<31 && roc>24) || (fed<=31 && roc>16) ) { - if(print) cout<<" Fed "<8 ) { - // ptorotect for rerouted signals - if( !( (fed==13 && channel==17) ||(fed==15 && channel==5) ||(fed==31 && channel==10) - ||(fed==27 && channel==15) ) ) { - if(print) cout<<" Fed "< 25) { + if (print) + cout << " Fed " << fed + << " wrong dcol number chan/roc/dcol/pix/adc = " << channel + << "/" << roc << "/" << dcol << "/" << pix << "/" << adc + << endl; + status = -3; + } + + if (pix < 2 || pix > 181) { + if (print) + cout << " Fed " << fed + << " wrong pix number chan/roc/dcol/pix/adc = " << channel + << "/" << roc << "/" << dcol << "/" << pix << "/" << adc + << endl; + status = -3; + } + + if ((fed > 31 && roc > 24) || (fed <= 31 && roc > 16)) { + if (print) + cout << " Fed " << fed + << " wrong roc number chan/roc/dcol/pix/adc = " << channel + << "/" << roc << "/" << dcol << "/" << pix << "/" << adc + << endl; + status = -4; + } else if (fed <= 31 && channel <= 24 && roc > 8) { + // ptorotect for rerouted signals + if (!((fed == 13 && channel == 17) || (fed == 15 && channel == 5) || + (fed == 31 && channel == 10) || (fed == 27 && channel == 15))) { + if (print) + cout << " Fed " << fed + << " wrong roc number, chan/roc/dcol/pix/adc = " << channel + << "/" << roc << "/" << dcol << "/" << pix << "/" << adc + << endl; + status = -4; + } + } + + if (pix == 0) { + if (print) + cout << " Fed " << fed + << " pix=0 chan/roc/dcol/pix/adc = " << channel << "/" << roc + << "/" << dcol << "/" << pix << "/" << adc << endl; + status = -5; + } } } else { - cout<<"Wrong channel "<>26); - cout<<"Wrong roc 25-"<> 26); + cout << "Wrong roc 25-" << roc << " in fed/chan " << fed << "/" << channel + << endl; + status = -4; - } else { // error word + } else { // error word - //cout<<"error word "< > fedErrorContainer; + edm::EDGetTokenT> fedErrorContainer; bool PRINT; - //int countEvents, countAllEvents; + // int countEvents, countAllEvents; int fedErrors, moduleErrors, spareCounts; - //float sumPixels, sumFedSize, sumFedPixels[40]; - //int fedErrors[40][36]; - //int decodeErrors[40][36]; - //int decodeErrors000[40][36]; // pix 0 problem + // float sumPixels, sumFedSize, sumFedPixels[40]; + // int fedErrors[40][36]; + // int decodeErrors[40][36]; + // int decodeErrors000[40][36]; // pix 0 problem int countErrors[40], countErrors2[40]; TH1F *hfeds, *hfedsF, *hfedsSlink, *hfedsCRC, *hfedsUnknown; TH1F *herrors, *herrorsF, *htype; TH1F *hmode, *hmodeF; TH1F *htbm, *htbmF; - TH2F *hfedErrors0,*hfedErrors1,*hfedErrors2,*hfedErrors3,*hfedErrors4,*hfedErrors5, - *hfedErrors6,*hfedErrors7,*hfedErrors8,*hfedErrors9; - TH2F *hfedErrors0F, *hfed2d,*hfed2d0; + TH2F *hfedErrors0, *hfedErrors1, *hfedErrors2, *hfedErrors3, *hfedErrors4, + *hfedErrors5, *hfedErrors6, *hfedErrors7, *hfedErrors8, *hfedErrors9; + TH2F *hfedErrors0F, *hfed2d, *hfed2d0; TH1F *hlumi, *hbx; - }; //---------------------------------- -FedErrorDumper::FedErrorDumper( const edm::ParameterSet& cfg) : theConfig(cfg) { - - //std::string src_ = theConfig.getUntrackedParameter("InputLabel","source"); - std::string src = theConfig.getUntrackedParameter("InputLabel","siPixelDigis"); +FedErrorDumper::FedErrorDumper(const edm::ParameterSet &cfg) : theConfig(cfg) { + // std::string src_ = + // theConfig.getUntrackedParameter("InputLabel","source"); + std::string src = theConfig.getUntrackedParameter( + "InputLabel", "siPixelDigis"); // For the ByToken method - fedErrorContainer = consumes >(src); -} + fedErrorContainer = consumes>(src); +} //--------------------------------- void FedErrorDumper::endJob() { - cout<<" fed-errors "<0 || countErrors2[i]>0 ) cout< 0 || countErrors2[i] > 0) + cout << i << " " << countErrors[i] << " " << countErrors2[i] << endl; } - //sumFedPixels[i] /= float(countEvents); -// hpixels4->Fill(float(i),sumFedPixels[i]); //pixels only -// } -// } - -// if(countEvents>0) { -// sumPixels /= float(countEvents); -// sumFedSize /= float(countAllEvents); - -// cout<<" Total/non-empty events " <0) { -// cout<0) { -// cout<0 ) cout<<" "<Fill(float(i),sumFedPixels[i]); //pixels only + // } + // } + + // if(countEvents>0) { + // sumPixels /= float(countEvents); + // sumFedSize /= float(countAllEvents); + + // cout<<" Total/non-empty events " <0) { + // cout<0) { + // cout<0 ) cout<<" "<("Verbosity",false); - for(int i=0;i<40;++i) { - countErrors[i]=0; - countErrors2[i]=0; + // countEvents=0; + // countAllEvents=0; + // countErrors=0; + fedErrors = 0; + moduleErrors = 0; + spareCounts = 0.; + // sumFedSize=0; + + PRINT = theConfig.getUntrackedParameter("Verbosity", false); + for (int i = 0; i < 40; ++i) { + countErrors[i] = 0; + countErrors2[i] = 0; } -// for(int i=0;i<40;++i) { -// sumFedPixels[i]=0; -// for(int j=0;j<36;++j) fedErrors[i][j]=0; -// for(int j=0;j<36;++j) decodeErrors[i][j]=0; -// for(int j=0;j<36;++j) decodeErrors000[i][j]=0; -// } -// for(int i=0;i<20;++i) errorType[i]=0; + // for(int i=0;i<40;++i) { + // sumFedPixels[i]=0; + // for(int j=0;j<36;++j) fedErrors[i][j]=0; + // for(int j=0;j<36;++j) decodeErrors[i][j]=0; + // for(int j=0;j<36;++j) decodeErrors000[i][j]=0; + // } + // for(int i=0;i<20;++i) errorType[i]=0; edm::Service fs; - htbm = fs->make("htbm", "tbm errors ",256, -0.5, 255.5); - htbmF = fs->make("htbmF","tbm errors ",256, -0.5, 255.5); - - hmode = fs->make( "hmode", "mode",16, -0.5, 15.5); - hmodeF = fs->make("hmodeF","mode",16, -0.5, 15.5); - - hfeds = fs->make( "hfeds", "errors per FED",40, -0.5, 39.5); - hfedsF = fs->make( "hfedsF", "errors per FED",40, -0.5, 39.5); - hfedsSlink = fs->make( "hfedsSlink", "errors per FED",40, -0.5, 39.5); - hfedsCRC = fs->make( "hfedsCRC", "errors per FED",40, -0.5, 39.5); - hfedsUnknown = fs->make( "hfedsUnknown", "errors per FED",40, -0.5, 39.5); - - htype = fs->make( "htype", "error type ",50, -0.5, 49.5); - herrors = fs->make( "herrors", "error type ",50, -0.5, 49.5); - herrorsF = fs->make( "herrorsF", "error type",50, -0.5, 49.5); - - hfedErrors0 = fs->make( "hfedErrors0", "errors", 40,-0.5,39.5,37, -0.5, 36.5); // ALL - hfedErrors0F = fs->make( "hfedErrors0F","errors",40,-0.5,39.5,37, -0.5, 36.5); // ALL - hfedErrors1 = fs->make( "hfedErrors1", "errors", 40,-0.5,39.5,37, -0.5, 36.5); // Timeout - hfedErrors2 = fs->make( "hfedErrors2", "errors", 40,-0.5,39.5,37, -0.5, 36.5); // Overflow - hfedErrors3 = fs->make( "hfedErrors3", "errors", 40,-0.5,39.5,37, -0.5, 36.5); // ENE - hfedErrors4 = fs->make( "hfedErrors4", "errors", 40,-0.5,39.5,37, -0.5, 36.5); // FIFO - hfedErrors5 = fs->make( "hfedErrors5", "errors", 40,-0.5,39.5,37, -0.5, 36.5); // NOR - hfedErrors6 = fs->make( "hfedErrors6", "errors", 40,-0.5,39.5,37, -0.5, 36.5); // TRAILER - hfedErrors7 = fs->make( "hfedErrors7", "errors", 40,-0.5,39.5,37, -0.5, 36.5); // FSM - hfedErrors8 = fs->make( "hfedErrors8", "errors", 40,-0.5,39.5,37, -0.5, 36.5); // Invalid ROC - hfedErrors9 = fs->make( "hfedErrors9", "errors", 40,-0.5,39.5,37, -0.5, 36.5); // Invalid DCOL-PIX - - hfed2d = fs->make( "hfed2d", "errors", 40,-0.5,39.5,20, 19.5, 39.5); // ALL - hfed2d0 = fs->make("hfed2d0","errors", 40,-0.5,39.5,20, 19.5, 39.5); // ALL - - hlumi = fs->make("hlumi", "lumi", 4000,0,4000.); - hbx = fs->make("hbx", "bx", 4000,0,4000.); - + htbm = fs->make("htbm", "tbm errors ", 256, -0.5, 255.5); + htbmF = fs->make("htbmF", "tbm errors ", 256, -0.5, 255.5); + + hmode = fs->make("hmode", "mode", 16, -0.5, 15.5); + hmodeF = fs->make("hmodeF", "mode", 16, -0.5, 15.5); + + hfeds = fs->make("hfeds", "errors per FED", 40, -0.5, 39.5); + hfedsF = fs->make("hfedsF", "errors per FED", 40, -0.5, 39.5); + hfedsSlink = fs->make("hfedsSlink", "errors per FED", 40, -0.5, 39.5); + hfedsCRC = fs->make("hfedsCRC", "errors per FED", 40, -0.5, 39.5); + hfedsUnknown = + fs->make("hfedsUnknown", "errors per FED", 40, -0.5, 39.5); + + htype = fs->make("htype", "error type ", 50, -0.5, 49.5); + herrors = fs->make("herrors", "error type ", 50, -0.5, 49.5); + herrorsF = fs->make("herrorsF", "error type", 50, -0.5, 49.5); + + hfedErrors0 = fs->make("hfedErrors0", "errors", 40, -0.5, 39.5, 37, + -0.5, 36.5); // ALL + hfedErrors0F = fs->make("hfedErrors0F", "errors", 40, -0.5, 39.5, 37, + -0.5, 36.5); // ALL + hfedErrors1 = fs->make("hfedErrors1", "errors", 40, -0.5, 39.5, 37, + -0.5, 36.5); // Timeout + hfedErrors2 = fs->make("hfedErrors2", "errors", 40, -0.5, 39.5, 37, + -0.5, 36.5); // Overflow + hfedErrors3 = fs->make("hfedErrors3", "errors", 40, -0.5, 39.5, 37, + -0.5, 36.5); // ENE + hfedErrors4 = fs->make("hfedErrors4", "errors", 40, -0.5, 39.5, 37, + -0.5, 36.5); // FIFO + hfedErrors5 = fs->make("hfedErrors5", "errors", 40, -0.5, 39.5, 37, + -0.5, 36.5); // NOR + hfedErrors6 = fs->make("hfedErrors6", "errors", 40, -0.5, 39.5, 37, + -0.5, 36.5); // TRAILER + hfedErrors7 = fs->make("hfedErrors7", "errors", 40, -0.5, 39.5, 37, + -0.5, 36.5); // FSM + hfedErrors8 = fs->make("hfedErrors8", "errors", 40, -0.5, 39.5, 37, + -0.5, 36.5); // Invalid ROC + hfedErrors9 = fs->make("hfedErrors9", "errors", 40, -0.5, 39.5, 37, + -0.5, 36.5); // Invalid DCOL-PIX + + hfed2d = + fs->make("hfed2d", "errors", 40, -0.5, 39.5, 20, 19.5, 39.5); // ALL + hfed2d0 = fs->make("hfed2d0", "errors", 40, -0.5, 39.5, 20, 19.5, + 39.5); // ALL + + hlumi = fs->make("hlumi", "lumi", 4000, 0, 4000.); + hbx = fs->make("hbx", "bx", 4000, 0, 4000.); } //-------------------------------------------------------------------------------- -void FedErrorDumper::analyze(const edm::Event& ev, const edm::EventSetup& es) { - //const bool PRINT = false; +void FedErrorDumper::analyze(const edm::Event &ev, const edm::EventSetup &es) { + // const bool PRINT = false; // Access event information - int run = ev.id().run(); - int event = ev.id().event(); + int run = ev.id().run(); + int event = ev.id().event(); int lumiBlock = ev.luminosityBlock(); - int bx = ev.bunchCrossing(); - //int orbit = ev.orbitNumber(); // unused + int bx = ev.bunchCrossing(); + // int orbit = ev.orbitNumber(); // unused hlumi->Fill(float(lumiBlock)); hbx->Fill(float(bx)); -// edm::Handle buffers; -// static std::string label = theConfig.getUntrackedParameter("InputLabel","source"); -// static std::string instance = theConfig.getUntrackedParameter("InputInstance",""); -// ev.getByLabel( label, instance, buffers); - - edm::Handle< edm::DetSetVector > input; - //static std::string src_ = theConfig.getUntrackedParameter("InputLabel","source"); - //static std::string src_ = theConfig.getUntrackedParameter("InputLabel","siPixelDigis"); - //static std::string instance = theConfig.getUntrackedParameter("InputInstance",""); - //ev.getByLabel( src_, instance, input ); - ev.getByToken(fedErrorContainer , input); // the new bytoken - - if (!input.isValid()) {cout<<" Container not found "< buffers; + // static std::string label = + // theConfig.getUntrackedParameter("InputLabel","source"); + // static std::string instance = + // theConfig.getUntrackedParameter("InputInstance",""); + // ev.getByLabel( label, instance, buffers); + + edm::Handle> input; + // static std::string src_ = + // theConfig.getUntrackedParameter("InputLabel","source"); static + // std::string src_ = + // theConfig.getUntrackedParameter("InputLabel","siPixelDigis"); + // static std::string instance = + // theConfig.getUntrackedParameter("InputInstance",""); + // ev.getByLabel( src_, instance, input ); + ev.getByToken(fedErrorContainer, input); // the new bytoken + + if (!input.isValid()) { + cout << " Container not found " << endl; + return; + } - if(PRINT) cout<<" Container found "<::const_iterator DSViter; - for(DSViter = input->begin(); DSViter != input->end(); DSViter++) { - //bool valid = false; + for (DSViter = input->begin(); DSViter != input->end(); DSViter++) { + // bool valid = false; unsigned int detid = DSViter->id; // = rawid - //cout<data.size()<::const_iterator di; - - for(di = DSViter->data.begin(); di != DSViter->data.end(); di++) { - int FedId = di->getFedId(); // FED the error came from - int errorType = di->getType(); // type of error - uint32_t word32 = di->getWord32(); - uint64_t word64 = di->getWord64(); - - fedErrors++; - - herrors->Fill(float(errorType)); - herrorsF->Fill(float(errorType)); - hfedsF->Fill(float(FedId)); - hfeds->Fill(float(FedId)); - int errorTypeMod = errorType; - - if(PRINT) cout<<" fed " <getMessage()<=26 && errorType<=31) { // fed error - status = MyDecode::error(word32, fedChannel, FedId, PRINT); - if(PRINT) cout<<" status "<36) { - cout<<" Cannot get a valid fed channel number of a -fed- error "<Fill(float(FedId),float(fedChannel)); - hfedErrors0F->Fill(float(FedId),float(fedChannel)); - - switch(errorType) { - - case(28) : { // FIFO - hfedErrors4->Fill(float(FedId),float(fedChannel)); - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - break;} - - case(29) : { // TIMEOUT - hfedErrors1->Fill(float(FedId),float(fedChannel)); - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - break;} - - case(30) : { // TRAILER - - int tbm = (word32& 0xff); - int mode = (word32>>8) & 0xf; - hmodeF->Fill(float(mode)); - hmode->Fill(float(mode)); - //cout<<" error 30 "<Fill(float(FedId),float(fedChannel)); - htbmF->Fill(float(tbm)); - errorTypeMod=20; - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - } - - if( (mode&0x8) != 0) { // nor - //cout<<" NOR "<Fill(float(FedId),float(fedChannel)); - errorTypeMod=21; - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - } - - - if( (mode&0x1) != 0) { // overflow - hfedErrors2->Fill(float(FedId),float(fedChannel)); - errorTypeMod=22; - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - } - - if( (mode&0x6) != 0) { // fsm - hfedErrors7->Fill(float(FedId),float(fedChannel)); - errorTypeMod=23; - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - } - - break;} - - case(31) : { // EVE - hfedErrors3->Fill(float(FedId),float(fedChannel)); - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - break;} - } // end switch - - } else if (errorType>=32 &&errorType<=34) { - cout<<" Slink error "<Fill(float(FedId)); - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - - } else if (errorType==25 || (errorType>=35 && errorType<=38) ) { // conversion error - cout<<" Should never happen, a -fed- conversion error? "<Fill(float(FedId),float(fedChannel)); - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - - switch(errorType) { - case(25) : { // inv ROC - hfedErrors8->Fill(float(FedId),float(fedChannel)); - break;} - case(36) : { // inv ROC - hfedErrors8->Fill(float(FedId),float(fedChannel)); - break;} - case(37) : { // inv DCOL&PIX - hfedErrors9->Fill(float(FedId),float(fedChannel)); - //spareCounts++; - cout<<" does it ever happen "<Fill(float(FedId)); - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - - } else { - cout<<" unknown error "<Fill(float(FedId)); - errorTypeMod=24; - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - } - - hfed2d->Fill(float(FedId),float(errorTypeMod)); - - if(errorTypeMod>=0 && errorTypeMod<40) countErrors[errorTypeMod]++; + // cout<data.size() << endl; + // Look at FED errors now + edm::DetSet::const_iterator di; + + for (di = DSViter->data.begin(); di != DSViter->data.end(); di++) { + int FedId = di->getFedId(); // FED the error came from + int errorType = di->getType(); // type of error + uint32_t word32 = di->getWord32(); + uint64_t word64 = di->getWord64(); + + fedErrors++; + + herrors->Fill(float(errorType)); + herrorsF->Fill(float(errorType)); + hfedsF->Fill(float(FedId)); + hfeds->Fill(float(FedId)); + int errorTypeMod = errorType; + + if (PRINT) + cout << " fed " << FedId << " type " << errorType << " " << hex + << word32 << " " << word64 << dec << " " << di->getMessage() + << endl; + + int status = 0; + int fedChannel = -1; + // const bool printData = true; + if (errorType >= 26 && errorType <= 31) { // fed error + status = MyDecode::error(word32, fedChannel, FedId, PRINT); + if (PRINT) + cout << " status " << status << endl; + + if (fedChannel < 1 || fedChannel > 36) { + cout << " Cannot get a valid fed channel number of a -fed- error " + << fedChannel << endl; + continue; // skip this error + } + + hfedErrors0->Fill(float(FedId), float(fedChannel)); + hfedErrors0F->Fill(float(FedId), float(fedChannel)); + + switch (errorType) { + case (28): { // FIFO + hfedErrors4->Fill(float(FedId), float(fedChannel)); + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + break; + } + + case (29): { // TIMEOUT + hfedErrors1->Fill(float(FedId), float(fedChannel)); + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + break; + } + + case (30): { // TRAILER + + int tbm = (word32 & 0xff); + int mode = (word32 >> 8) & 0xf; + hmodeF->Fill(float(mode)); + hmode->Fill(float(mode)); + // cout<<" error 30 "<Fill(float(FedId), float(fedChannel)); + htbmF->Fill(float(tbm)); + errorTypeMod = 20; + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + } + + if ((mode & 0x8) != 0) { // nor + // cout<<" NOR "<Fill(float(FedId), float(fedChannel)); + errorTypeMod = 21; + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + } + + if ((mode & 0x1) != 0) { // overflow + hfedErrors2->Fill(float(FedId), float(fedChannel)); + errorTypeMod = 22; + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + } + + if ((mode & 0x6) != 0) { // fsm + hfedErrors7->Fill(float(FedId), float(fedChannel)); + errorTypeMod = 23; + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + } + + break; + } + + case (31): { // EVE + hfedErrors3->Fill(float(FedId), float(fedChannel)); + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + break; + } + } // end switch + + } else if (errorType >= 32 && errorType <= 34) { + cout << " Slink error " << endl; + + hfedsSlink->Fill(float(FedId)); + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + + } else if (errorType == 25 || + (errorType >= 35 && errorType <= 38)) { // conversion error + cout << " Should never happen, a -fed- conversion error? " << endl; + status = MyDecode::data(word32, fedChannel, FedId, PRINT); + if (PRINT) + cout << " status " << status << endl; + + hfedErrors0->Fill(float(FedId), float(fedChannel)); + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + + switch (errorType) { + case (25): { // inv ROC + hfedErrors8->Fill(float(FedId), float(fedChannel)); + break; + } + case (36): { // inv ROC + hfedErrors8->Fill(float(FedId), float(fedChannel)); + break; + } + case (37): { // inv DCOL&PIX + hfedErrors9->Fill(float(FedId), float(fedChannel)); + // spareCounts++; + cout << " does it ever happen " << endl; + break; + } + } + + } else if (errorType == 39) { // CRC + cout << " CRC error " << endl; + hfedsCRC->Fill(float(FedId)); + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + + } else { + cout << " unknown error " << errorType << endl; + hfedsUnknown->Fill(float(FedId)); + errorTypeMod = 24; + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + } + + hfed2d->Fill(float(FedId), float(errorTypeMod)); + + if (errorTypeMod >= 0 && errorTypeMod < 40) + countErrors[errorTypeMod]++; } // for errors - } else { // module errors + } else { // module errors DetId detId(detid); - //const GeomDetUnit * geoUnit = geom->idToDetUnit( detId ); - //const PixelGeomDetUnit * pixDet = dynamic_cast(geoUnit); - unsigned int detType=detId.det(); // det type, tracker=1 - unsigned int subid=detId.subdetId(); //subdetector type, barrel=1 - - - if(PRINT) { - cout<<" Module errors "<data.size()<idToDetUnit( detId ); + // const PixelGeomDetUnit * pixDet = dynamic_cast(geoUnit); + unsigned int detType = detId.det(); // det type, tracker=1 + unsigned int subid = detId.subdetId(); // subdetector type, barrel=1 + + if (PRINT) { + cout << " Module errors " << DSViter->data.size() << endl; + cout << "Det: " << detId.rawId() << ":"; + // cout<<"Det: "<::const_iterator di; - for(di = DSViter->data.begin(); di != DSViter->data.end(); di++) { - int FedId = di->getFedId(); // FED the error came from - int errorType = di->getType(); // type of error - uint32_t word32 = di->getWord32(); - //uint64_t word64 = di->getWord64(); // unused - - herrors->Fill(float(errorType)); - moduleErrors++; - int errorTypeMod = errorType; - - //cout<<" fed " <getMessage()<=26 && errorType<=31) { // fed error - status = MyDecode::error(word32, fedChannel, FedId, PRINT); - if(PRINT) cout<<" fed "<Fill(float(FedId),float(fedChannel)); - - switch(errorType) { - - case(28) : { // FIFO - hfedErrors4->Fill(float(FedId),float(fedChannel)); - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - break;} - - case(29) : { // TIMEOUT - hfedErrors1->Fill(float(FedId),float(fedChannel)); - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - break;} - - case(30) : { // TRAILER - - int tbm = (word32& 0xff); - int mode = (word32>>8) & 0xf; - hmode->Fill(float(mode)); - //cout<<" error 30 "<Fill(float(tbm)); - hfedErrors6->Fill(float(FedId),float(fedChannel)); - errorTypeMod=20; - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - } - - if( (mode&0x8) != 0) { // nor - //cout<<" NOR "<Fill(float(FedId),float(fedChannel)); - errorTypeMod=21; - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - } - - if( (mode&0x1) != 0) { // overflow - hfedErrors2->Fill(float(FedId),float(fedChannel)); - errorTypeMod=22; - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - } - - if( (mode&0x6) != 0) { // fsm - hfedErrors7->Fill(float(FedId),float(fedChannel)); - errorTypeMod=23; - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - } - - break;} - - case(31) : { // EVE - hfedErrors3->Fill(float(FedId),float(fedChannel)); - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - break;} - } // end switch - - } else if (errorType>=32 && errorType<=34) { - cout<<" Slink error "<Fill(float(FedId)); - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - - } else if (errorType==25 || (errorType>=35 &&errorType<=38) ) { // conversion error - - status = MyDecode::data(word32, fedChannel, FedId, PRINT); - if(PRINT) cout<<" fed "<Fill(float(FedId),float(fedChannel)); - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - - switch(errorType) { - case(25) : { // inv ROC - hfedErrors8->Fill(float(FedId),float(fedChannel)); - break;} - case(36) : { // inv ROC - hfedErrors8->Fill(float(FedId),float(fedChannel)); - break;} - case(37) : { // inv DCOL&PIX - hfedErrors9->Fill(float(FedId),float(fedChannel)); - if(FedId==6 && fedChannel==35) { - spareCounts++; - cout<Fill(float(FedId)); - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - - } else { - cout<<" unknown error "<Fill(float(FedId)); - errorTypeMod=24; - hfed2d0->Fill(float(FedId),float(errorTypeMod)); - htype->Fill(float(errorTypeMod)); - } - - hfed2d->Fill(float(FedId),float(errorTypeMod)); - - if(errorTypeMod>=0 && errorTypeMod<40) countErrors2[errorTypeMod]++; + // Look at FED errors now + edm::DetSet::const_iterator di; + for (di = DSViter->data.begin(); di != DSViter->data.end(); di++) { + int FedId = di->getFedId(); // FED the error came from + int errorType = di->getType(); // type of error + uint32_t word32 = di->getWord32(); + // uint64_t word64 = di->getWord64(); // unused + + herrors->Fill(float(errorType)); + moduleErrors++; + int errorTypeMod = errorType; + + // cout<<" fed " <getMessage()<= 26 && errorType <= 31) { // fed error + status = MyDecode::error(word32, fedChannel, FedId, PRINT); + if (PRINT) + cout << " fed " << FedId << " " + << "Channel " << fedChannel << " " << status << endl; + + hfedErrors0->Fill(float(FedId), float(fedChannel)); + + switch (errorType) { + case (28): { // FIFO + hfedErrors4->Fill(float(FedId), float(fedChannel)); + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + break; + } + + case (29): { // TIMEOUT + hfedErrors1->Fill(float(FedId), float(fedChannel)); + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + break; + } + + case (30): { // TRAILER + + int tbm = (word32 & 0xff); + int mode = (word32 >> 8) & 0xf; + hmode->Fill(float(mode)); + // cout<<" error 30 "<Fill(float(tbm)); + hfedErrors6->Fill(float(FedId), float(fedChannel)); + errorTypeMod = 20; + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + } + + if ((mode & 0x8) != 0) { // nor + // cout<<" NOR "<Fill(float(FedId), float(fedChannel)); + errorTypeMod = 21; + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + } + + if ((mode & 0x1) != 0) { // overflow + hfedErrors2->Fill(float(FedId), float(fedChannel)); + errorTypeMod = 22; + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + } + + if ((mode & 0x6) != 0) { // fsm + hfedErrors7->Fill(float(FedId), float(fedChannel)); + errorTypeMod = 23; + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + } + + break; + } + + case (31): { // EVE + hfedErrors3->Fill(float(FedId), float(fedChannel)); + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + break; + } + } // end switch + + } else if (errorType >= 32 && errorType <= 34) { + cout << " Slink error " << endl; + hfedsSlink->Fill(float(FedId)); + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + + } else if (errorType == 25 || + (errorType >= 35 && errorType <= 38)) { // conversion error + + status = MyDecode::data(word32, fedChannel, FedId, PRINT); + if (PRINT) + cout << " fed " << FedId << " " + << "Channel " << fedChannel << " " << status << endl; + + hfedErrors0->Fill(float(FedId), float(fedChannel)); + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + + switch (errorType) { + case (25): { // inv ROC + hfedErrors8->Fill(float(FedId), float(fedChannel)); + break; + } + case (36): { // inv ROC + hfedErrors8->Fill(float(FedId), float(fedChannel)); + break; + } + case (37): { // inv DCOL&PIX + hfedErrors9->Fill(float(FedId), float(fedChannel)); + if (FedId == 6 && fedChannel == 35) { + spareCounts++; + cout << errorType << " " << FedId << " " << fedChannel; + if (subid == 1) + cout << " BPix: layer " << layer << " ladder " << ladder + << " module " << module << endl; + else + cout << " FPix: disk " << disk << " " << blade << " " << zindex + << endl; + } + break; + } + } + + } else if (errorType == 39) { // CRC + cout << " CRC error " << endl; + hfedsCRC->Fill(float(FedId)); + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + + } else { + cout << " unknown error " << errorType << endl; + hfedsUnknown->Fill(float(FedId)); + errorTypeMod = 24; + hfed2d0->Fill(float(FedId), float(errorTypeMod)); + htype->Fill(float(errorTypeMod)); + } + + hfed2d->Fill(float(FedId), float(errorTypeMod)); + + if (errorTypeMod >= 0 && errorTypeMod < 40) + countErrors2[errorTypeMod]++; } // for - } // if fed/module - - } // end det loop + } // if fed/module + } // end det loop } #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/EventFilter/SiPixelRawToDigi/test/SiPixelRawDumper.cc b/EventFilter/SiPixelRawToDigi/test/SiPixelRawDumper.cc index 79362e2ed599b..dc55b64b877cb 100644 --- a/EventFilter/SiPixelRawToDigi/test/SiPixelRawDumper.cc +++ b/EventFilter/SiPixelRawToDigi/test/SiPixelRawDumper.cc @@ -1,5 +1,5 @@ /** \class SiPixelRawDumper_H - * Plug-in module that dump raw data file + * Plug-in module that dump raw data file * for pixel subdetector * Added class to interpret the data d.k. 30/10/08 * Add histograms. Add pix 0 detection. @@ -10,24 +10,25 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" - #include "DataFormats/Common/interface/Handle.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" #include "DataFormats/FEDRawData/interface/FEDRawData.h" +#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/FEDRawData/interface/FEDNumbering.h" #include "EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h" - // For L1 NOT IN RAW //#include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtUtils.h" -//#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h" +//#include +//"DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h" //#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h" -//#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h" -//#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMapRecord.h" +//#include +//"DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h" +//#include +//"DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMapRecord.h" // For luminisoty NOT IN RAW //#include "FWCore/Framework/interface/LuminosityBlock.h" @@ -35,38 +36,37 @@ //#include "DataFormats/Common/interface/ConditionsInEdm.h" // To use root histos -#include "FWCore/ServiceRegistry/interface/Service.h" #include "CommonTools/UtilAlgos/interface/TFileService.h" +#include "FWCore/ServiceRegistry/interface/Service.h" // For ROOT #include //#include -#include #include -#include +#include #include +#include #include #include - -#include #include +#include using namespace std; // #define L1 // L1 information not in RAW -//#define OUTFILE +//#define OUTFILE namespace { - bool printErrors = true; - bool printData = false; - bool printHeaders = false; - const bool CHECK_PIXELS = true; - const bool PRINT_BASELINE = false; - // to store the previous pixel - int fed0 = -1, chan0 = -1, roc0 = -1, dcol0 = -1, pix0 =-1, count0=-1; - int countDecodeErrors1=0, countDecodeErrors2=0; -} +bool printErrors = true; +bool printData = false; +bool printHeaders = false; +const bool CHECK_PIXELS = true; +const bool PRINT_BASELINE = false; +// to store the previous pixel +int fed0 = -1, chan0 = -1, roc0 = -1, dcol0 = -1, pix0 = -1, count0 = -1; +int countDecodeErrors1 = 0, countDecodeErrors2 = 0; +} // namespace // Include the helper decoding class ///////////////////////////////////////////////////////////////////////////// @@ -74,276 +74,318 @@ class MyDecode { public: MyDecode() {} ~MyDecode() {} - static int error(int error,int & fedChannel, int fed, int & stat1, int & stat2, bool print=false); - static int data(int error, int & fedChannel, int fed, int & stat1, int & stat2, bool print=false); - static int header(unsigned long long word64, int fed, bool print, unsigned int & bx); + static int error(int error, int &fedChannel, int fed, int &stat1, int &stat2, + bool print = false); + static int data(int error, int &fedChannel, int fed, int &stat1, int &stat2, + bool print = false); + static int header(unsigned long long word64, int fed, bool print, + unsigned int &bx); static int trailer(unsigned long long word64, int fed, bool print); - static int convertToCol(int dcol,int pix); + static int convertToCol(int dcol, int pix); static int convertToRow(int pix); static int checkLayerLink(int fed, int chan); + private: }; ///////////////////////////////////////////////////////////////////////////// -//Returns 1,2,3 for layer 1,2,3 full modules, 11,12,13 for 1/2 modules +// Returns 1,2,3 for layer 1,2,3 full modules, 11,12,13 for 1/2 modules // 0 for fpix // needs fedid 0-31, and channel 1-36. int MyDecode::checkLayerLink(int fed, int chan) { int layer = 0; - if(fed<0 || fed>31) return layer; // return 0 for invalid of fpix + if (fed < 0 || fed > 31) + return layer; // return 0 for invalid of fpix - if( chan>24) { // layer 3 + if (chan > 24) { // layer 3 - if(fed==0 || fed==8 ) { // Type A + if (fed == 0 || fed == 8) { // Type A - if(chan==28 ||chan==34 ||chan==35 ||chan==36 ) layer=13; // 1/2 module - else layer = 3; + if (chan == 28 || chan == 34 || chan == 35 || chan == 36) + layer = 13; // 1/2 module + else + layer = 3; - } else if(fed==23 || fed==31 ) { // Type A + } else if (fed == 23 || fed == 31) { // Type A - if(chan==27 ||chan==31 ||chan==32 ||chan==33 ) layer=13; // 1/2 module - else layer = 3; - - } else if(fed==7 || fed==15 || fed==16 || fed==24 ) { // Type D + if (chan == 27 || chan == 31 || chan == 32 || chan == 33) + layer = 13; // 1/2 module + else + layer = 3; - if(chan==25 ||chan==26 ||chan==29 ||chan==30 ) layer=13; - else layer = 3; + } else if (fed == 7 || fed == 15 || fed == 16 || fed == 24) { // Type D - } else { layer = 3;} + if (chan == 25 || chan == 26 || chan == 29 || chan == 30) + layer = 13; + else + layer = 3; - return layer; // layer 3 + } else { + layer = 3; + } - } else if( (chan>=13 && chan<=19) || chan==24 ) { + return layer; // layer 3 - return 2; //layer 2 + } else if ((chan >= 13 && chan <= 19) || chan == 24) { + return 2; // layer 2 } else { - - if(fed==0 || fed==8 || fed==16 || fed==24 ) { // Type A WRONG AFTER FIBER SWAP - - if(chan==5 ||chan==6 ||chan==22 ||chan==23 ) layer=12; // 1/2 module - else if(chan==4 ||chan==10 ||chan==11 ||chan==12 ) layer=11; // 1/2 module - else layer = 1; - - } else if(fed==7 || fed==15 || fed==23 || fed==31 ) { // Type D - - if(chan==1 ||chan==2 ||chan==20 ||chan==21 ) layer=12; // 1/2 - else if(chan==3 ||chan==7 ||chan==8 ||chan==9 ) layer=11; // 1/2 - else layer = 1; - - } else if( - fed==1 || fed==2 || fed==3 || - fed==9 || fed==10 || fed==11 || - fed==17 || fed==18 || fed==19 || - fed==25 || fed==26 || fed==27 ) { // Type B - - if( (chan>=4 && chan<=6) || (chan>=10 && chan<=12) || (chan>=22 && chan<=23) ) layer=2; - else layer = 1; - - } else if( - fed==4 || fed==5 || fed==6 || - fed==12 || fed==13 || fed==14 || - fed==20 || fed==21 || fed==22 || - fed==28 || fed==29 || fed==30 ) { // Type C - - if( (chan>=1 && chan<=3) || (chan>=7 && chan<=9) || (chan>=20 && chan<=21) ) layer=2; - else layer = 1; + if (fed == 0 || fed == 8 || fed == 16 || + fed == 24) { // Type A WRONG AFTER FIBER SWAP + + if (chan == 5 || chan == 6 || chan == 22 || chan == 23) + layer = 12; // 1/2 module + else if (chan == 4 || chan == 10 || chan == 11 || chan == 12) + layer = 11; // 1/2 module + else + layer = 1; + + } else if (fed == 7 || fed == 15 || fed == 23 || fed == 31) { // Type D + + if (chan == 1 || chan == 2 || chan == 20 || chan == 21) + layer = 12; // 1/2 + else if (chan == 3 || chan == 7 || chan == 8 || chan == 9) + layer = 11; // 1/2 + else + layer = 1; + + } else if (fed == 1 || fed == 2 || fed == 3 || fed == 9 || fed == 10 || + fed == 11 || fed == 17 || fed == 18 || fed == 19 || fed == 25 || + fed == 26 || fed == 27) { // Type B + + if ((chan >= 4 && chan <= 6) || (chan >= 10 && chan <= 12) || + (chan >= 22 && chan <= 23)) + layer = 2; + else + layer = 1; + + } else if (fed == 4 || fed == 5 || fed == 6 || fed == 12 || fed == 13 || + fed == 14 || fed == 20 || fed == 21 || fed == 22 || fed == 28 || + fed == 29 || fed == 30) { // Type C + + if ((chan >= 1 && chan <= 3) || (chan >= 7 && chan <= 9) || + (chan >= 20 && chan <= 21)) + layer = 2; + else + layer = 1; } else { - cout<<"unknown fed "<>8)&0xfff; - int event_id=(word64>>32)&0xffffff; - bx =(word64>>20)&0xfff; -// if(bx!=101) { -// cout<<" Header "<<" for FED " -// <>dummy; -// } - if(print) cout<<"Header "<<" for FED " - <> 8) & 0xfff; + int event_id = (word64 >> 32) & 0xffffff; + bx = (word64 >> 20) & 0xfff; + // if(bx!=101) { + // cout<<" Header "<<" for FED " + // <>dummy; + // } + if (print) + cout << "Header " + << " for FED " << fed_id << " event " << event_id << " bx " << bx + << endl; + fed0 = -1; // reset the previous hit fed id return event_id; } // int MyDecode::trailer(unsigned long long word64, int fed, bool print) { - int slinkLength = int( (word64>>32) & 0xffffff ); - int crc = int( (word64&0xffff0000)>>16 ); - int tts = int( (word64&0xf0)>>4); - int slinkError = int( (word64&0xf00)>>8); - if(print) cout<<"Trailer "<<" len "<> 32) & 0xffffff); + int crc = int((word64 & 0xffff0000) >> 16); + int tts = int((word64 & 0xf0) >> 4); + int slinkError = int((word64 & 0xf00) >> 8); + if (print) + cout << "Trailer " + << " len " << slinkLength << " tts " << tts << " error " << slinkError + << " crc " << hex << crc << dec << endl; return slinkLength; } // // Decode error FIFO // Works for both, the error FIFO and the SLink error words. d.k. 25/04/07 -int MyDecode::error(int word, int & fedChannel, int fed, int & stat1, int & stat2, bool print) { +int MyDecode::error(int word, int &fedChannel, int fed, int &stat1, int &stat2, + bool print) { int status = -1; print = print || printErrors; - const unsigned int errorMask = 0x3e00000; - const unsigned int dummyMask = 0x03600000; - const unsigned int gapMask = 0x03400000; - const unsigned int timeOut = 0x3a00000; - const unsigned int eventNumError = 0x3e00000; - const unsigned int trailError = 0x3c00000; - const unsigned int fifoError = 0x3800000; - -// const unsigned int timeOutChannelMask = 0x1f; // channel mask for timeouts - //const unsigned int eventNumMask = 0x1fe000; // event number mask - const unsigned int channelMask = 0xfc000000; // channel num mask - const unsigned int tbmEventMask = 0xff; // tbm event num mask - const unsigned int overflowMask = 0x100; // data overflow - const unsigned int tbmStatusMask = 0xff; //TBM trailer info - const unsigned int BlkNumMask = 0x700; //pointer to error fifo # - const unsigned int FsmErrMask = 0x600; //pointer to FSM errors - const unsigned int RocErrMask = 0x800; //pointer to #Roc errors - const unsigned int ChnFifMask = 0x1f; //channel mask for fifo error - const unsigned int Fif2NFMask = 0x40; //mask for fifo2 NF - const unsigned int TrigNFMask = 0x80; //mask for trigger fifo NF - - const int offsets[8] = {0,4,9,13,18,22,27,31}; + const unsigned int errorMask = 0x3e00000; + const unsigned int dummyMask = 0x03600000; + const unsigned int gapMask = 0x03400000; + const unsigned int timeOut = 0x3a00000; + const unsigned int eventNumError = 0x3e00000; + const unsigned int trailError = 0x3c00000; + const unsigned int fifoError = 0x3800000; + + // const unsigned int timeOutChannelMask = 0x1f; // channel mask for + // timeouts + // const unsigned int eventNumMask = 0x1fe000; // event number mask + const unsigned int channelMask = 0xfc000000; // channel num mask + const unsigned int tbmEventMask = 0xff; // tbm event num mask + const unsigned int overflowMask = 0x100; // data overflow + const unsigned int tbmStatusMask = 0xff; // TBM trailer info + const unsigned int BlkNumMask = 0x700; // pointer to error fifo # + const unsigned int FsmErrMask = 0x600; // pointer to FSM errors + const unsigned int RocErrMask = 0x800; // pointer to #Roc errors + const unsigned int ChnFifMask = 0x1f; // channel mask for fifo error + const unsigned int Fif2NFMask = 0x40; // mask for fifo2 NF + const unsigned int TrigNFMask = 0x80; // mask for trigger fifo NF + + const int offsets[8] = {0, 4, 9, 13, 18, 22, 27, 31}; unsigned int channel = 0; - //cout<<"error word "<>20; // works only for slink format + } else if ((word & errorMask) == timeOut) { // TIMEOUT + + unsigned int bit20 = (word & 0x100000) >> 20; // works only for slink format - if(bit20 == 0) { // 2nd word + if (bit20 == 0) { // 2nd word - unsigned int timeoutCnt = (word & 0x7f800)>>11; // only for slink - // unsigned int timeoutCnt = ((word&0xfc000000)>>24) + ((word&0x1800)>>11); // only for fifo - // More than 1 channel within a group can have a timeout error - // More than 1 channel within a group can have a timeout error + unsigned int timeoutCnt = (word & 0x7f800) >> 11; // only for slink + // unsigned int timeoutCnt = ((word&0xfc000000)>>24) + + // ((word&0x1800)>>11); // only for fifo More than 1 channel within a + // group can have a timeout error More than 1 channel within a group can + // have a timeout error - unsigned int index = (word & 0x1F); // index within a group of 4/5 - unsigned int chip = (word& BlkNumMask)>>8; + unsigned int index = (word & 0x1F); // index within a group of 4/5 + unsigned int chip = (word & BlkNumMask) >> 8; int offset = offsets[chip]; - if(print) cout<<"Timeout Error- channel: "; - //cout<<"Timeout Error- channel: "; - for(int i=0;i<5;i++) { - if( (index & 0x1) != 0) { - channel = offset + i + 1; - if(print) cout<> 1; + if (print) + cout << "Timeout Error- channel: "; + // cout<<"Timeout Error- channel: "; + for (int i = 0; i < 5; i++) { + if ((index & 0x1) != 0) { + channel = offset + i + 1; + if (print) + cout << channel << " "; + // cout<> 1; } - if(print) cout << " TimeoutCount: " << timeoutCnt; - //cout << " TimeoutCount: " << timeoutCnt<> 26; + unsigned int tbm_event = (word & tbmEventMask); - } else if( (word&errorMask) == eventNumError ) { // EVENT NUMBER ERROR - channel = (word & channelMask) >>26; - unsigned int tbm_event = (word & tbmEventMask); - - if(print) cout<<" Event Number Error- channel: "<>26; - unsigned int tbm_status = (word & tbmStatusMask); - - - if(tbm_status!=0) { - if(print) cout<<" Trailer Error- "<<"channel: "<> 26; + unsigned int tbm_status = (word & tbmStatusMask); + + if (tbm_status != 0) { + if (print) + cout << " Trailer Error- " + << "channel: " << channel << " TBM status:0x" << hex << tbm_status + << dec << " "; // <>9)<> 9) << dec << " "; // <>21); // rocs start from 1 + int roc = ((word & rocmsk) >> 21); // rocs start from 1 // Check for embeded special words - if(roc>0 && roc<25) { // valid ROCs go from 1-24 - //if(print) cout<<"data "<>26); - - if(channel>0 && channel<37) { // valid channels 1-36 - //cout<>16; - int pix=(word&pxlmsk)>>8; - int adc=(word&plsmsk); + if (roc > 0 && roc < 25) { // valid ROCs go from 1-24 + // if(print) cout<<"data "<> 26); + + if (channel > 0 && channel < 37) { // valid channels 1-36 + // cout<> 16; + int pix = (word & pxlmsk) >> 8; + int adc = (word & plsmsk); fedChannel = channel; - int col = convertToCol(dcol,pix); + int col = convertToCol(dcol, pix); int row = convertToRow(pix); // print the roc number according to the online 0-15 scheme - if(print) cout<<" Fed "<31 && roc>24) || (fed<=31 && roc>16) ) { //inv ROC - //if(printErrors) - cout<<" Fed "<8 ) { - // Check invalid ROC numbers - - // protect for rerouted signals - if( !( (fed==13 && channel==17) ||(fed==15 && channel==5) ||(fed==31 && channel==10) - ||(fed==27 && channel==15) ) ) { - //if(printErrors) - cout<<" Fed "<161) { // inv PIX - if(printErrors)cout<<" Fed "<25) { // inv DCOL - if(printErrors) cout<<" Fed "<161 || dcol<0 || dcol>25) { - countDecodeErrors2++; // count pixels with errors - if(pix<2 || pix>161) countDecodeErrors1++; // count errors - if(dcol<0 || dcol>25) countDecodeErrors1++; // count errors - //if(fed==6 && channel==35 ) cout<<" Fed "< 31 && roc > 24) || + (fed <= 31 && roc > 16)) { // inv ROC + // if(printErrors) + cout << " Fed " << fed + << " wrong roc number chan/roc/dcol/pix/adc = " << channel << "/" + << roc - 1 << "/" << dcol << "/" << pix << "/" << adc << endl; + status = -4; + + } else if (fed <= 31 && channel <= 24 && roc > 8) { + // Check invalid ROC numbers + + // protect for rerouted signals + if (!((fed == 13 && channel == 17) || (fed == 15 && channel == 5) || + (fed == 31 && channel == 10) || (fed == 27 && channel == 15))) { + // if(printErrors) + cout << " Fed " << fed + << " wrong roc number, chan/roc/dcol/pix/adc = " << channel + << "/" << roc - 1 << "/" << dcol << "/" << pix << "/" << adc + << endl; + status = -4; + } + } + + // Check pixels + if (pix == 0) { // PIX=0 + // Detect pixel 0 events + if (printErrors) + cout << " Fed " << fed + << " pix=0 chan/roc/dcol/pix/adc = " << channel << "/" + << roc - 1 << "/" << dcol << "/" << pix << "/" << adc << " (" + << col << "," << row << ")" << endl; + count0++; + stat1 = roc - 1; + stat2 = count0; + status = -5; + + } else if (fed == fed0 && channel == chan0 && roc == roc0 && + dcol == dcol0 && pix == pix0) { + // detect multiple pixels + + count0++; + if (printErrors) + cout << " Fed " + << fed + // cout<<" Fed "< 161) { // inv PIX + if (printErrors) + cout << " Fed " << fed + << " wrong pix number chan/roc/dcol/pix/adc = " << channel + << "/" << roc - 1 << "/" << dcol << "/" << pix << "/" << adc + << " (" << col << "," << row << ")" << endl; + status = -3; + } + + if (dcol < 0 || dcol > 25) { // inv DCOL + if (printErrors) + cout << " Fed " << fed + << " wrong dcol number chan/roc/dcol/pix/adc = " << channel + << "/" << roc - 1 << "/" << dcol << "/" << pix << "/" << adc + << " (" << col << "," << row << ")" << endl; + status = -3; + } + + } // check pixels + + // Summary error count (for testing only) + if (pix < 2 || pix > 161 || dcol < 0 || dcol > 25) { + countDecodeErrors2++; // count pixels with errors + if (pix < 2 || pix > 161) + countDecodeErrors1++; // count errors + if (dcol < 0 || dcol > 25) + countDecodeErrors1++; // count errors + // if(fed==6 && channel==35 ) cout<<" Fed "<>26); - cout<<"Wrong roc 25 "<<" in fed/chan "<> 26); + cout << "Wrong roc 25 " + << " in fed/chan " << fed << "/" << channel << endl; + status = -4; - //cout<<"error word "<(theConfig.getUntrackedParameter("InputLabel","source"));} + // explicit SiPixelRawDumper( const edm::ParameterSet& cfg) : theConfig(cfg) { + // consumes(theConfig.getUntrackedParameter("InputLabel","source"));} /// dtor virtual ~SiPixelRawDumper() {} void beginJob(); - //void beginRun( const edm::EventSetup& ) {} + // void beginRun( const edm::EventSetup& ) {} - // end of job + // end of job void endJob(); /// get data, convert to digis attach againe to Event - virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void analyze(const edm::Event &, const edm::EventSetup &); private: edm::ParameterSet theConfig; @@ -514,63 +574,75 @@ class SiPixelRawDumper : public edm::EDAnalyzer { int fedErrorsTime[40][36]; int fedErrorsOver[40][36]; int decodeErrors[40][36]; - int decodeErrors000[40][36]; // pix 0 problem - int decodeErrorsDouble[40][36]; // double pix problem + int decodeErrors000[40][36]; // pix 0 problem + int decodeErrorsDouble[40][36]; // double pix problem int errorType[20]; #ifdef OUTFILE ofstream outfile; #endif - TH1D *hsize,*hsize0, *hsize1, *hsize2, *hsize3; + TH1D *hsize, *hsize0, *hsize1, *hsize2, *hsize3; #ifdef IND_FEDS TH1D *hsizeFeds[40]; #endif TH1D *hpixels, *hpixels0, *hpixels1, *hpixels2, *hpixels3, *hpixels4; - TH1D *htotPixels,*htotPixels0, *htotPixels1; + TH1D *htotPixels, *htotPixels0, *htotPixels1; TH1D *herrors, *htotErrors; - TH1D *herrorType1, *herrorType1Fed, *herrorType1Chan,*herrorType2, *herrorType2Fed, *herrorType2Chan; + TH1D *herrorType1, *herrorType1Fed, *herrorType1Chan, *herrorType2, + *herrorType2Fed, *herrorType2Chan; TH1D *hcountDouble, *hcount000, *hrocDouble, *hroc000; - TH2F *hfed2DErrorsType1,*hfed2DErrorsType2; - TH2F *hfed2DErrors1,*hfed2DErrors2,*hfed2DErrors3,*hfed2DErrors4,*hfed2DErrors5, - *hfed2DErrors6,*hfed2DErrors7,*hfed2DErrors8,*hfed2DErrors9,*hfed2DErrors10,*hfed2DErrors11,*hfed2DErrors12, - *hfed2DErrors13,*hfed2DErrors14,*hfed2DErrors15,*hfed2DErrors16; - TH2F *hfed2d, *hsize2d,*hfedErrorType1ls,*hfedErrorType2ls, *hcountDouble2, *hcount0002; - TH2F *hfed2DErrors1ls,*hfed2DErrors2ls,*hfed2DErrors3ls,*hfed2DErrors4ls,*hfed2DErrors5ls, - *hfed2DErrors6ls,*hfed2DErrors7ls,*hfed2DErrors8ls,*hfed2DErrors9ls,*hfed2DErrors10ls,*hfed2DErrors11ls,*hfed2DErrors12ls, - *hfed2DErrors13ls,*hfed2DErrors14ls,*hfed2DErrors15ls,*hfed2DErrors16ls; + TH2F *hfed2DErrorsType1, *hfed2DErrorsType2; + TH2F *hfed2DErrors1, *hfed2DErrors2, *hfed2DErrors3, *hfed2DErrors4, + *hfed2DErrors5, *hfed2DErrors6, *hfed2DErrors7, *hfed2DErrors8, + *hfed2DErrors9, *hfed2DErrors10, *hfed2DErrors11, *hfed2DErrors12, + *hfed2DErrors13, *hfed2DErrors14, *hfed2DErrors15, *hfed2DErrors16; + TH2F *hfed2d, *hsize2d, *hfedErrorType1ls, *hfedErrorType2ls, *hcountDouble2, + *hcount0002; + TH2F *hfed2DErrors1ls, *hfed2DErrors2ls, *hfed2DErrors3ls, *hfed2DErrors4ls, + *hfed2DErrors5ls, *hfed2DErrors6ls, *hfed2DErrors7ls, *hfed2DErrors8ls, + *hfed2DErrors9ls, *hfed2DErrors10ls, *hfed2DErrors11ls, *hfed2DErrors12ls, + *hfed2DErrors13ls, *hfed2DErrors14ls, *hfed2DErrors15ls, + *hfed2DErrors16ls; TH1D *hevent, *hlumi, *horbit, *hbx, *hlumi0, *hbx0; - //TH1D *hbx1,*hbx2,*hbx3,*hbx4,*hbx5,*hbx6,*hbx7,*hbx8,*hbx9,*hbx10,*hbx11,*hbx12; - TProfile *htotPixelsls, *hsizels, *herrorType1ls, *herrorType2ls, *havsizels, *htotPixelsbx, - *herrorType1bx,*herrorType2bx,*havsizebx,*hsizep; - TProfile *herror1ls,*herror2ls,*herror3ls,*herror4ls,*herror5ls,*herror6ls,*herror7ls,*herror8ls, - *herror9ls,*herror10ls,*herror11ls,*herror12ls,*herror13ls,*herror14ls,*herror15ls,*herror16ls; + // TH1D + // *hbx1,*hbx2,*hbx3,*hbx4,*hbx5,*hbx6,*hbx7,*hbx8,*hbx9,*hbx10,*hbx11,*hbx12; + TProfile *htotPixelsls, *hsizels, *herrorType1ls, *herrorType2ls, *havsizels, + *htotPixelsbx, *herrorType1bx, *herrorType2bx, *havsizebx, *hsizep; + TProfile *herror1ls, *herror2ls, *herror3ls, *herror4ls, *herror5ls, + *herror6ls, *herror7ls, *herror8ls, *herror9ls, *herror10ls, *herror11ls, + *herror12ls, *herror13ls, *herror14ls, *herror15ls, *herror16ls; TProfile2D *hfedchannelsize; - TH1D *herrorTimels, *herrorOverls, *herrorTimels1, *herrorOverls1, *herrorTimels2, *herrorOverls2, - *herrorTimels3, *herrorOverls3, *herrorTimels0, *herrorOverls0; - TH1D *hfedchannelsizeb,*hfedchannelsizeb1,*hfedchannelsizeb2,*hfedchannelsizeb3, - *hfedchannelsizef; - + TH1D *herrorTimels, *herrorOverls, *herrorTimels1, *herrorOverls1, + *herrorTimels2, *herrorOverls2, *herrorTimels3, *herrorOverls3, + *herrorTimels0, *herrorOverls0; + TH1D *hfedchannelsizeb, *hfedchannelsizeb1, *hfedchannelsizeb2, + *hfedchannelsizeb3, *hfedchannelsizef; }; //---------------------------------------------------------------------------------- -SiPixelRawDumper::SiPixelRawDumper( const edm::ParameterSet& cfg) : theConfig(cfg) { - string label = theConfig.getUntrackedParameter("InputLabel","source"); +SiPixelRawDumper::SiPixelRawDumper(const edm::ParameterSet &cfg) + : theConfig(cfg) { + string label = + theConfig.getUntrackedParameter("InputLabel", "source"); // For the ByToken method rawData = consumes(label); -} +} //---------------------------------------------------------------------------------------- void SiPixelRawDumper::endJob() { - string errorName[18] = {" "," ","wrong channel","wrong pix or dcol","wrong roc","pix=0", - " double-pix"," "," "," ","timeout","ENE","NOR","FSM","overflow", - "trailer","fifo","reset/resync"}; - -// 2 - wrong channel -// 3 - wrong pix or dcol -// 4 - wrong roc -// 5 - pix=0 -// 6 - double pixel + string errorName[18] = { + " ", " ", "wrong channel", "wrong pix or dcol", + "wrong roc", "pix=0", " double-pix", " ", + " ", " ", "timeout", "ENE", + "NOR", "FSM", "overflow", "trailer", + "fifo", "reset/resync"}; + + // 2 - wrong channel + // 3 - wrong pix or dcol + // 4 - wrong roc + // 5 - pix=0 + // 6 - double pixel // 10 - timeout () // 11 - ene () // 12 - mum pf rocs error () @@ -580,690 +652,952 @@ void SiPixelRawDumper::endJob() { // 16 - fifo (30) // 17 - reset/resync NOT INCLUDED YET - if(countEvents>0) { + if (countEvents > 0) { sumPixels /= float(countEvents); sumFedSize /= float(countAllEvents); - for(int i=0;i<40;++i) { + for (int i = 0; i < 40; ++i) { sumFedPixels[i] /= float(countEvents); - hpixels4->Fill(float(i),sumFedPixels[i]); //pixels only + hpixels4->Fill(float(i), sumFedPixels[i]); // pixels only } } - - cout<<" Total/non-empty events " < int(countEvents*printThreshold) || (fedErrorsENE[i][j] > 0) ) { - cout<<" "< int(countEvents * printThreshold) || + (fedErrorsENE[i][j] > 0)) { + cout << " " << i << " - " << (j + 1) << " - " << fedErrors[i][j] + << " - " << fedErrorsENE[i][j] << " - " << fedErrorsTime[i][j] + << " - " << fedErrorsOver[i][j] << endl; + } } - cout<<" Decode errors "<10) - cout<<" "< 10) + cout << " " << i << " - " << (j + 1) << " - " << decodeErrors[i][j] + << " - " << decodeErrors000[i][j] << " - " + << decodeErrorsDouble[i][j] << endl; } } - cout<<" Total errors for all feds "<0 ) cout<<" "< 0) + cout << " " << i << " - " << errorName[i] << " - " << errorType[i] + << endl; } - cout<<" Test decode errors "<("Verbosity",1); - printThreshold = theConfig.getUntrackedParameter("PrintThreshold",0.001); // threshold per event for printing errors - cout<<" beginjob "<0) printErrors = true; - else printErrors = false; - if(printLocal>1) printData = true; - else printData = false; - if(printLocal>2) printHeaders = true; - else printHeaders = false; - - countEvents=0; - countAllEvents=0; - countTotErrors=0; - sumPixels=0.; - sumFedSize=0; - for(int i=0;i<40;++i) { - sumFedPixels[i]=0; - for(int j=0;j<36;++j) {fedErrors[i][j]=0; fedErrorsENE[i][j]=0; fedErrorsTime[i][j]=0; fedErrorsOver[i][j]=0;} - for(int j=0;j<36;++j) {decodeErrors[i][j]=0; decodeErrors000[i][j]=0; decodeErrorsDouble[i][j]=0;} + printLocal = theConfig.getUntrackedParameter("Verbosity", 1); + printThreshold = theConfig.getUntrackedParameter( + "PrintThreshold", 0.001); // threshold per event for printing errors + cout << " beginjob " << printLocal << " " << printThreshold << endl; + + if (printLocal > 0) + printErrors = true; + else + printErrors = false; + if (printLocal > 1) + printData = true; + else + printData = false; + if (printLocal > 2) + printHeaders = true; + else + printHeaders = false; + + countEvents = 0; + countAllEvents = 0; + countTotErrors = 0; + sumPixels = 0.; + sumFedSize = 0; + for (int i = 0; i < 40; ++i) { + sumFedPixels[i] = 0; + for (int j = 0; j < 36; ++j) { + fedErrors[i][j] = 0; + fedErrorsENE[i][j] = 0; + fedErrorsTime[i][j] = 0; + fedErrorsOver[i][j] = 0; + } + for (int j = 0; j < 36; ++j) { + decodeErrors[i][j] = 0; + decodeErrors000[i][j] = 0; + decodeErrorsDouble[i][j] = 0; + } } - for(int i=0;i<20;++i) errorType[i]=0; + for (int i = 0; i < 20; ++i) + errorType[i] = 0; edm::Service fs; - //const float pixMax = 5999.5; // pp value - //const float totMax = 99999.5; // pp value - //const float maxLink = 200.; // pp value + // const float pixMax = 5999.5; // pp value + // const float totMax = 99999.5; // pp value + // const float maxLink = 200.; // pp value - const float pixMax = 19999.5; // hi value - const float totMax = 399999.5; // hi value + const float pixMax = 19999.5; // hi value + const float totMax = 399999.5; // hi value const float maxLink = 1000.; // hi value - - hsize = fs->make( "hsize", "FED event size in words-4", 6000, -0.5, pixMax); - hsize0 = fs->make( "hsize0", "FED event size in words-4", 2000, -0.5, 19999.5); - hsize1 = fs->make( "hsize1", "bpix FED event size in words-4", 6000, -0.5, pixMax); - hsize2 = fs->make( "hsize2", "fpix FED event size in words-4", 6000, -0.5, pixMax); - hsize3 = fs->make( "hsize3", "ave bpix FED event size in words-4", 6000, -0.5, pixMax); - - hpixels = fs->make( "hpixels", "pixels per FED", 2000, -0.5, 19999.5); - hpixels0 = fs->make( "hpixels0", "pixels per FED", 6000, -0.5, pixMax); - hpixels1 = fs->make( "hpixels1", "pixels >0 per FED", 6000, -0.5, pixMax); - hpixels2 = fs->make( "hpixels2", "pixels >0 per BPix FED", 6000, -0.5, pixMax); - hpixels3 = fs->make( "hpixels3", "pixels >0 per Fpix FED", 6000, -0.5, pixMax); - hpixels4 = fs->make( "hpixels4", "pixels per each FED", 40, -0.5, 39.5); - - htotPixels = fs->make( "htotPixels", "pixels per event", 10000, -0.5, totMax); - htotPixels0 = fs->make( "htotPixels0", "pixels per event, zoom low region", 20000, -0.5, 19999.5); - htotPixels1 = fs->make( "htotPixels1", "pixels >0 per event", 10000, -0.5, totMax); - - herrors = fs->make( "herrors", "errors per FED", 100, -0.5, 99.5); - htotErrors = fs->make( "htotErrors", "errors per event", 1000, -0.5, 999.5); - - herrorType1 = fs->make( "herrorType1", "errors 1 per type", 20, -0.5, 19.5); - herrorType1Fed = fs->make( "herrorType1Fed", "errors 1 per FED", 40, -0.5, 39.5); - herrorType1Chan = fs->make( "herrorType1Chan", "errors 1 per chan", 37, -0.5, 36.5); - herrorType2 = fs->make( "herrorType2", "readout errors 2 per type", 20, -0.5, 19.5); - herrorType2Fed = fs->make( "herrorType2Fed", "readout errors 2 per FED", 40, -0.5, 39.5); - herrorType2Chan = fs->make( "herrorType2Chan", "readout errors 2 per chan", 37, -0.5, 36.5); - - hcountDouble = fs->make( "hcountDouble", "count double pixels", 100, -0.5, 99.5); - hcountDouble2 = fs->make("hcountDouble2","count double pixels",40,-0.5,39.5, 10,0.,10.); - hcount000 = fs->make( "hcount000", "count 000 pixels", 100, -0.5, 99.5); - hcount0002 = fs->make("hcount0002","count 000 pixels",40,-0.5,39.5, 10,0.,10.); - hrocDouble = fs->make( "hrocDouble", "double pixels rocs", 25,-0.5, 24.5); - hroc000 = fs->make( "hroc000", "000 pixels rocs", 25,-0.5, 24.5); - - hfed2d = fs->make( "hfed2d", "errors", 40,-0.5,39.5,21, -0.5, 20.5); // ALL - - hsize2d = fs->make( "hsize2d", "size vs fed",40,-0.5,39.5, 50,0,500); // ALL - hsizep = fs->make( "hsizep", "size vs fed",40,-0.5,39.5,0,100000); // ALL - //hsize2dls = fs->make( "hsize2dls", "size vs lumi",100,0,1000, 50,0.,500.); // ALL + hsize = + fs->make("hsize", "FED event size in words-4", 6000, -0.5, pixMax); + hsize0 = fs->make("hsize0", "FED event size in words-4", 2000, -0.5, + 19999.5); + hsize1 = fs->make("hsize1", "bpix FED event size in words-4", 6000, + -0.5, pixMax); + hsize2 = fs->make("hsize2", "fpix FED event size in words-4", 6000, + -0.5, pixMax); + hsize3 = fs->make("hsize3", "ave bpix FED event size in words-4", 6000, + -0.5, pixMax); + + hpixels = fs->make("hpixels", "pixels per FED", 2000, -0.5, 19999.5); + hpixels0 = fs->make("hpixels0", "pixels per FED", 6000, -0.5, pixMax); + hpixels1 = + fs->make("hpixels1", "pixels >0 per FED", 6000, -0.5, pixMax); + hpixels2 = + fs->make("hpixels2", "pixels >0 per BPix FED", 6000, -0.5, pixMax); + hpixels3 = + fs->make("hpixels3", "pixels >0 per Fpix FED", 6000, -0.5, pixMax); + hpixels4 = fs->make("hpixels4", "pixels per each FED", 40, -0.5, 39.5); + + htotPixels = + fs->make("htotPixels", "pixels per event", 10000, -0.5, totMax); + htotPixels0 = fs->make( + "htotPixels0", "pixels per event, zoom low region", 20000, -0.5, 19999.5); + htotPixels1 = + fs->make("htotPixels1", "pixels >0 per event", 10000, -0.5, totMax); + + herrors = fs->make("herrors", "errors per FED", 100, -0.5, 99.5); + htotErrors = + fs->make("htotErrors", "errors per event", 1000, -0.5, 999.5); + + herrorType1 = + fs->make("herrorType1", "errors 1 per type", 20, -0.5, 19.5); + herrorType1Fed = + fs->make("herrorType1Fed", "errors 1 per FED", 40, -0.5, 39.5); + herrorType1Chan = + fs->make("herrorType1Chan", "errors 1 per chan", 37, -0.5, 36.5); + herrorType2 = fs->make("herrorType2", "readout errors 2 per type", 20, + -0.5, 19.5); + herrorType2Fed = fs->make("herrorType2Fed", "readout errors 2 per FED", + 40, -0.5, 39.5); + herrorType2Chan = fs->make("herrorType2Chan", + "readout errors 2 per chan", 37, -0.5, 36.5); + + hcountDouble = + fs->make("hcountDouble", "count double pixels", 100, -0.5, 99.5); + hcountDouble2 = fs->make("hcountDouble2", "count double pixels", 40, + -0.5, 39.5, 10, 0., 10.); + hcount000 = fs->make("hcount000", "count 000 pixels", 100, -0.5, 99.5); + hcount0002 = fs->make("hcount0002", "count 000 pixels", 40, -0.5, 39.5, + 10, 0., 10.); + hrocDouble = + fs->make("hrocDouble", "double pixels rocs", 25, -0.5, 24.5); + hroc000 = fs->make("hroc000", "000 pixels rocs", 25, -0.5, 24.5); + + hfed2d = + fs->make("hfed2d", "errors", 40, -0.5, 39.5, 21, -0.5, 20.5); // ALL + + hsize2d = fs->make("hsize2d", "size vs fed", 40, -0.5, 39.5, 50, 0, + 500); // ALL + hsizep = fs->make("hsizep", "size vs fed", 40, -0.5, 39.5, 0, + 100000); // ALL + // hsize2dls = fs->make( "hsize2dls", "size vs lumi",100,0,1000, + // 50,0.,500.); // ALL #ifdef IND_FEDS - hsizeFeds[0] = fs->make( "hsizeFed0", "FED 0 event size ", 1000, -0.5, pixMax); - hsizeFeds[1] = fs->make( "hsizeFed1", "FED 1 event size ", 1000, -0.5, pixMax); - hsizeFeds[2] = fs->make( "hsizeFed2", "FED 2 event size ", 1000, -0.5, pixMax); - hsizeFeds[3] = fs->make( "hsizeFed3", "FED 3 event size ", 1000, -0.5, pixMax); - hsizeFeds[4] = fs->make( "hsizeFed4", "FED 4 event size ", 1000, -0.5, pixMax); - hsizeFeds[5] = fs->make( "hsizeFed5", "FED 5 event size ", 1000, -0.5, pixMax); - hsizeFeds[6] = fs->make( "hsizeFed6", "FED 6 event size ", 1000, -0.5, pixMax); - hsizeFeds[7] = fs->make( "hsizeFed7", "FED 7 event size ", 1000, -0.5, pixMax); - hsizeFeds[8] = fs->make( "hsizeFed8", "FED 8 event size ", 1000, -0.5, pixMax); - hsizeFeds[9] = fs->make( "hsizeFed9", "FED 9 event size ", 1000, -0.5, pixMax); - hsizeFeds[10] = fs->make( "hsizeFed10", "FED 10 event size ", 1000, -0.5, pixMax); - hsizeFeds[11] = fs->make( "hsizeFed11", "FED 11 event size ", 1000, -0.5, pixMax); - hsizeFeds[12] = fs->make( "hsizeFed12", "FED 12 event size ", 1000, -0.5, pixMax); - hsizeFeds[13] = fs->make( "hsizeFed13", "FED 13 event size ", 1000, -0.5, pixMax); - hsizeFeds[14] = fs->make( "hsizeFed14", "FED 14 event size ", 1000, -0.5, pixMax); - hsizeFeds[15] = fs->make( "hsizeFed15", "FED 15 event size ", 1000, -0.5, pixMax); - hsizeFeds[16] = fs->make( "hsizeFed16", "FED 16 event size ", 1000, -0.5, pixMax); - hsizeFeds[17] = fs->make( "hsizeFed17", "FED 17 event size ", 1000, -0.5, pixMax); - hsizeFeds[18] = fs->make( "hsizeFed18", "FED 18 event size ", 1000, -0.5, pixMax); - hsizeFeds[19] = fs->make( "hsizeFed19", "FED 19 event size ", 1000, -0.5, pixMax); - hsizeFeds[20] = fs->make( "hsizeFed20", "FED 20 event size ", 1000, -0.5, pixMax); - hsizeFeds[21] = fs->make( "hsizeFed21", "FED 21 event size ", 1000, -0.5, pixMax); - hsizeFeds[22] = fs->make( "hsizeFed22", "FED 22 event size ", 1000, -0.5, pixMax); - hsizeFeds[23] = fs->make( "hsizeFed23", "FED 23 event size ", 1000, -0.5, pixMax); - hsizeFeds[24] = fs->make( "hsizeFed24", "FED 24 event size ", 1000, -0.5, pixMax); - hsizeFeds[25] = fs->make( "hsizeFed25", "FED 25 event size ", 1000, -0.5, pixMax); - hsizeFeds[26] = fs->make( "hsizeFed26", "FED 26 event size ", 1000, -0.5, pixMax); - hsizeFeds[27] = fs->make( "hsizeFed27", "FED 27 event size ", 1000, -0.5, pixMax); - hsizeFeds[28] = fs->make( "hsizeFed28", "FED 28 event size ", 1000, -0.5, pixMax); - hsizeFeds[29] = fs->make( "hsizeFed29", "FED 29 event size ", 1000, -0.5, pixMax); - hsizeFeds[30] = fs->make( "hsizeFed30", "FED 30 event size ", 1000, -0.5, pixMax); - hsizeFeds[31] = fs->make( "hsizeFed31", "FED 31 event size ", 1000, -0.5, pixMax); - hsizeFeds[32] = fs->make( "hsizeFed32", "FED 32 event size ", 1000, -0.5, pixMax); - hsizeFeds[33] = fs->make( "hsizeFed33", "FED 33 event size ", 1000, -0.5, pixMax); - hsizeFeds[34] = fs->make( "hsizeFed34", "FED 34 event size ", 1000, -0.5, pixMax); - hsizeFeds[35] = fs->make( "hsizeFed35", "FED 35 event size ", 1000, -0.5, pixMax); - hsizeFeds[36] = fs->make( "hsizeFed36", "FED 36 event size ", 1000, -0.5, pixMax); - hsizeFeds[37] = fs->make( "hsizeFed37", "FED 37 event size ", 1000, -0.5, pixMax); - hsizeFeds[38] = fs->make( "hsizeFed38", "FED 38 event size ", 1000, -0.5, pixMax); - hsizeFeds[39] = fs->make( "hsizeFed39", "FED 39 event size ", 1000, -0.5, pixMax); + hsizeFeds[0] = + fs->make("hsizeFed0", "FED 0 event size ", 1000, -0.5, pixMax); + hsizeFeds[1] = + fs->make("hsizeFed1", "FED 1 event size ", 1000, -0.5, pixMax); + hsizeFeds[2] = + fs->make("hsizeFed2", "FED 2 event size ", 1000, -0.5, pixMax); + hsizeFeds[3] = + fs->make("hsizeFed3", "FED 3 event size ", 1000, -0.5, pixMax); + hsizeFeds[4] = + fs->make("hsizeFed4", "FED 4 event size ", 1000, -0.5, pixMax); + hsizeFeds[5] = + fs->make("hsizeFed5", "FED 5 event size ", 1000, -0.5, pixMax); + hsizeFeds[6] = + fs->make("hsizeFed6", "FED 6 event size ", 1000, -0.5, pixMax); + hsizeFeds[7] = + fs->make("hsizeFed7", "FED 7 event size ", 1000, -0.5, pixMax); + hsizeFeds[8] = + fs->make("hsizeFed8", "FED 8 event size ", 1000, -0.5, pixMax); + hsizeFeds[9] = + fs->make("hsizeFed9", "FED 9 event size ", 1000, -0.5, pixMax); + hsizeFeds[10] = + fs->make("hsizeFed10", "FED 10 event size ", 1000, -0.5, pixMax); + hsizeFeds[11] = + fs->make("hsizeFed11", "FED 11 event size ", 1000, -0.5, pixMax); + hsizeFeds[12] = + fs->make("hsizeFed12", "FED 12 event size ", 1000, -0.5, pixMax); + hsizeFeds[13] = + fs->make("hsizeFed13", "FED 13 event size ", 1000, -0.5, pixMax); + hsizeFeds[14] = + fs->make("hsizeFed14", "FED 14 event size ", 1000, -0.5, pixMax); + hsizeFeds[15] = + fs->make("hsizeFed15", "FED 15 event size ", 1000, -0.5, pixMax); + hsizeFeds[16] = + fs->make("hsizeFed16", "FED 16 event size ", 1000, -0.5, pixMax); + hsizeFeds[17] = + fs->make("hsizeFed17", "FED 17 event size ", 1000, -0.5, pixMax); + hsizeFeds[18] = + fs->make("hsizeFed18", "FED 18 event size ", 1000, -0.5, pixMax); + hsizeFeds[19] = + fs->make("hsizeFed19", "FED 19 event size ", 1000, -0.5, pixMax); + hsizeFeds[20] = + fs->make("hsizeFed20", "FED 20 event size ", 1000, -0.5, pixMax); + hsizeFeds[21] = + fs->make("hsizeFed21", "FED 21 event size ", 1000, -0.5, pixMax); + hsizeFeds[22] = + fs->make("hsizeFed22", "FED 22 event size ", 1000, -0.5, pixMax); + hsizeFeds[23] = + fs->make("hsizeFed23", "FED 23 event size ", 1000, -0.5, pixMax); + hsizeFeds[24] = + fs->make("hsizeFed24", "FED 24 event size ", 1000, -0.5, pixMax); + hsizeFeds[25] = + fs->make("hsizeFed25", "FED 25 event size ", 1000, -0.5, pixMax); + hsizeFeds[26] = + fs->make("hsizeFed26", "FED 26 event size ", 1000, -0.5, pixMax); + hsizeFeds[27] = + fs->make("hsizeFed27", "FED 27 event size ", 1000, -0.5, pixMax); + hsizeFeds[28] = + fs->make("hsizeFed28", "FED 28 event size ", 1000, -0.5, pixMax); + hsizeFeds[29] = + fs->make("hsizeFed29", "FED 29 event size ", 1000, -0.5, pixMax); + hsizeFeds[30] = + fs->make("hsizeFed30", "FED 30 event size ", 1000, -0.5, pixMax); + hsizeFeds[31] = + fs->make("hsizeFed31", "FED 31 event size ", 1000, -0.5, pixMax); + hsizeFeds[32] = + fs->make("hsizeFed32", "FED 32 event size ", 1000, -0.5, pixMax); + hsizeFeds[33] = + fs->make("hsizeFed33", "FED 33 event size ", 1000, -0.5, pixMax); + hsizeFeds[34] = + fs->make("hsizeFed34", "FED 34 event size ", 1000, -0.5, pixMax); + hsizeFeds[35] = + fs->make("hsizeFed35", "FED 35 event size ", 1000, -0.5, pixMax); + hsizeFeds[36] = + fs->make("hsizeFed36", "FED 36 event size ", 1000, -0.5, pixMax); + hsizeFeds[37] = + fs->make("hsizeFed37", "FED 37 event size ", 1000, -0.5, pixMax); + hsizeFeds[38] = + fs->make("hsizeFed38", "FED 38 event size ", 1000, -0.5, pixMax); + hsizeFeds[39] = + fs->make("hsizeFed39", "FED 39 event size ", 1000, -0.5, pixMax); #endif - hevent = fs->make("hevent","event",1000,0,10000000.); - //horbit = fs->make("horbit","orbit",100, 0,100000000.); - hlumi = fs->make("hlumi", "lumi", 3000,0,3000.); - hlumi0 = fs->make("hlumi0", "lumi", 3000,0,3000.); - - hbx = fs->make("hbx", "bx", 4000,0,4000.); - hbx0 = fs->make("hbx0", "bx", 4000,0,4000.); - -// hbx1 = fs->make("hbx1", "bx", 4000,0,4000.); -// hbx2 = fs->make("hbx2", "bx", 4000,0,4000.); -// hbx3 = fs->make("hbx3", "bx", 4000,0,4000.); -// hbx4 = fs->make("hbx4", "bx", 4000,0,4000.); -// hbx5 = fs->make("hbx5", "bx", 4000,0,4000.); -// hbx6 = fs->make("hbx6", "bx", 4000,0,4000.); -// hbx7 = fs->make("hbx7", "bx", 4000,0,4000.); -// hbx8 = fs->make("hbx8", "bx", 4000,0,4000.); -// hbx9 = fs->make("hbx9", "bx", 4000,0,4000.); -// hbx10 = fs->make("hbx10", "bx", 4000,0,4000.); -// hbx11 = fs->make("hbx11", "bx", 4000,0,4000.); -// hbx12 = fs->make("hbx12", "bx", 4000,0,4000.); - - herrorTimels = fs->make( "herrorTimels", "timeouts vs ls", 1000,0,3000); - herrorOverls = fs->make( "herrorOverls", "overflows vs ls",1000,0,3000); - herrorTimels1 = fs->make("herrorTimels1","timeouts vs ls", 1000,0,3000); - herrorOverls1 = fs->make("herrorOverls1","overflows vs ls",1000,0,3000); - herrorTimels2 = fs->make("herrorTimels2","timeouts vs ls", 1000,0,3000); - herrorOverls2 = fs->make("herrorOverls2","overflows vs ls",1000,0,3000); - herrorTimels3 = fs->make("herrorTimels3","timeouts vs ls", 1000,0,3000); - herrorOverls3 = fs->make("herrorOverls3","overflows vs ls",1000,0,3000); - herrorTimels0 = fs->make("herrorTimels0","timeouts vs ls", 1000,0,3000); - herrorOverls0 = fs->make("herrorOverls0","overflows vs ls",1000,0,3000); - - hfed2DErrorsType1 = fs->make("hfed2DErrorsType1", "errors type 1 per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrorsType2 = fs->make("hfed2DErrorsType2", "errors type 2 per FED", 40,-0.5,39.5,37, -0.5, 36.5); - - hfed2DErrors1 = fs->make("hfed2DErrors1", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - //hfed2DErrors2 = fs->make("hfed2DErrors2", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors3 = fs->make("hfed2DErrors3", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors4 = fs->make("hfed2DErrors4", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors5 = fs->make("hfed2DErrors5", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors6 = fs->make("hfed2DErrors6", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - //hfed2DErrors7 = fs->make("hfed2DErrors7", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - //hfed2DErrors8 = fs->make("hfed2DErrors8", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - //hfed2DErrors9 = fs->make("hfed2DErrors9", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors10 = fs->make("hfed2DErrors10", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors11 = fs->make("hfed2DErrors11", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors12 = fs->make("hfed2DErrors12", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors13 = fs->make("hfed2DErrors13", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors14 = fs->make("hfed2DErrors14", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors15 = fs->make("hfed2DErrors15", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors16 = fs->make("hfed2DErrors16", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - - - hfedErrorType1ls = fs->make( "hfedErrorType1ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfedErrorType2ls = fs->make( "hfedErrorType2ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - - hfed2DErrors1ls = fs->make("hfed2DErrors1ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - //hfed2DErrors2ls = fs->make("hfed2DErrors2ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors3ls = fs->make("hfed2DErrors3ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors4ls = fs->make("hfed2DErrors4ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors5ls = fs->make("hfed2DErrors5ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors6ls = fs->make("hfed2DErrors6ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - //hfed2DErrors7ls = fs->make("hfed2DErrors7ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - //hfed2DErrors8ls = fs->make("hfed2DErrors8ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - //hfed2DErrors9ls = fs->make("hfed2DErrors9ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors10ls = fs->make("hfed2DErrors10ls","errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors11ls = fs->make("hfed2DErrors11ls","errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors12ls = fs->make("hfed2DErrors12ls","errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors13ls = fs->make("hfed2DErrors13ls","errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors14ls = fs->make("hfed2DErrors14ls","errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors15ls = fs->make("hfed2DErrors15ls","errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors16ls = fs->make("hfed2DErrors16ls","errors vs lumi",300,0,3000, 40,-0.5,39.5); // - - herrorTimels = fs->make( "herrorTimels", "timeouts vs ls", 1000,0,3000); - herrorOverls = fs->make( "herrorOverls", "overflows vs ls",1000,0,3000); - herrorTimels1 = fs->make("herrorTimels1","timeouts vs ls", 1000,0,3000); - herrorOverls1 = fs->make("herrorOverls1","overflows vs ls",1000,0,3000); - herrorTimels2 = fs->make("herrorTimels2","timeouts vs ls", 1000,0,3000); - herrorOverls2 = fs->make("herrorOverls2","overflows vs ls",1000,0,3000); - herrorTimels3 = fs->make("herrorTimels3","timeouts vs ls", 1000,0,3000); - herrorOverls3 = fs->make("herrorOverls3","overflows vs ls",1000,0,3000); - herrorTimels0 = fs->make("herrorTimels0","timeouts vs ls", 1000,0,3000); - herrorOverls0 = fs->make("herrorOverls0","overflows vs ls",1000,0,3000); - - hfed2DErrorsType1 = fs->make("hfed2DErrorsType1", "errors type 1 per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrorsType2 = fs->make("hfed2DErrorsType2", "errors type 2 per FED", 40,-0.5,39.5,37, -0.5, 36.5); - - hfed2DErrors1 = fs->make("hfed2DErrors1", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - //hfed2DErrors2 = fs->make("hfed2DErrors2", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors3 = fs->make("hfed2DErrors3", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors4 = fs->make("hfed2DErrors4", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors5 = fs->make("hfed2DErrors5", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors6 = fs->make("hfed2DErrors6", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - //hfed2DErrors7 = fs->make("hfed2DErrors7", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - //hfed2DErrors8 = fs->make("hfed2DErrors8", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - //hfed2DErrors9 = fs->make("hfed2DErrors9", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors10 = fs->make("hfed2DErrors10", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors11 = fs->make("hfed2DErrors11", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors12 = fs->make("hfed2DErrors12", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors13 = fs->make("hfed2DErrors13", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors14 = fs->make("hfed2DErrors14", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors15 = fs->make("hfed2DErrors15", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - hfed2DErrors16 = fs->make("hfed2DErrors16", "errors per FED", 40,-0.5,39.5,37, -0.5, 36.5); - - - hfedErrorType1ls = fs->make( "hfedErrorType1ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfedErrorType2ls = fs->make( "hfedErrorType2ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - - hfed2DErrors1ls = fs->make("hfed2DErrors1ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - //hfed2DErrors2ls = fs->make("hfed2DErrors2ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors3ls = fs->make("hfed2DErrors3ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors4ls = fs->make("hfed2DErrors4ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors5ls = fs->make("hfed2DErrors5ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors6ls = fs->make("hfed2DErrors6ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - //hfed2DErrors7ls = fs->make("hfed2DErrors7ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - //hfed2DErrors8ls = fs->make("hfed2DErrors8ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - //hfed2DErrors9ls = fs->make("hfed2DErrors9ls", "errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors10ls = fs->make("hfed2DErrors10ls","errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors11ls = fs->make("hfed2DErrors11ls","errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors12ls = fs->make("hfed2DErrors12ls","errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors13ls = fs->make("hfed2DErrors13ls","errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors14ls = fs->make("hfed2DErrors14ls","errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors15ls = fs->make("hfed2DErrors15ls","errors vs lumi",300,0,3000, 40,-0.5,39.5); // - hfed2DErrors16ls = fs->make("hfed2DErrors16ls","errors vs lumi",300,0,3000, 40,-0.5,39.5); // - - - hsizels = fs->make("hsizels"," bpix fed size vs ls",300,0,3000,0,200000.); - htotPixelsls = fs->make("htotPixelsls"," tot pixels vs ls",300,0,3000,0,300000.); - havsizels = fs->make("havsizels","av. bpix fed size vs ls",300,0,3000,0,300000.); - - herrorType1ls = fs->make("herrorType1ls","error type 1 vs ls",300,0,3000,0,1000.); - herrorType2ls = fs->make("herrorType2ls","error type 2 vs ls",300,0,3000,0,1000.); - - herror1ls = fs->make("herror1ls","error 1 vs ls",300,0,3000,0,1000.); - //herror2ls = fs->make("herror2ls","error 2 vs ls",300,0,3000,0,1000.); - herror3ls = fs->make("herror3ls","error 3 vs ls",300,0,3000,0,1000.); - herror4ls = fs->make("herror4ls","error 4 vs ls",300,0,3000,0,1000.); - herror5ls = fs->make("herror5ls","error 5 vs ls",300,0,3000,0,1000.); - herror6ls = fs->make("herror6ls","error 6 vs ls",300,0,3000,0,1000.); - //herror7ls = fs->make("herror7ls","error 7 vs ls",300,0,3000,0,1000.); - //herror8ls = fs->make("herror8ls","error 8 vs ls",300,0,3000,0,1000.); - //herror9ls = fs->make("herror9ls","error 9 vs ls",300,0,3000,0,1000.); - herror10ls = fs->make("herror10ls","error 10 vs ls",300,0,3000,0,1000.); - herror11ls = fs->make("herror11ls","error 11 vs ls",300,0,3000,0,1000.); - herror12ls = fs->make("herror12ls","error 12 vs ls",300,0,3000,0,1000.); - herror13ls = fs->make("herror13ls","error 13 vs ls",300,0,3000,0,1000.); - herror14ls = fs->make("herror14ls","error 14 vs ls",300,0,3000,0,1000.); - herror15ls = fs->make("herror15ls","error 15 vs ls",300,0,3000,0,1000.); - herror16ls = fs->make("herror16ls","error 16 vs ls",300,0,3000,0,1000.); - - htotPixelsbx = fs->make("htotPixelsbx"," tot pixels vs bx",4000,-0.5,3999.5,0,300000.); - havsizebx = fs->make("havsizebx"," ave bpix fed size vs bx",4000,-0.5,3999.5,0,300000.); - herrorType1bx = fs->make("herrorType1bx"," error type 1 vs bx",4000,-0.5,3999.5,0,300000.); - herrorType2bx = fs->make("herrorType2bx"," error type 2 vs bx",4000,-0.5,3999.5,0,300000.); - - //hintgl = fs->make("hintgl", "inst lumi vs ls ",1000,0.,3000.,0.0,1000.); - //hinstl = fs->make("hinstl", "intg lumi vs ls ",1000,0.,3000.,0.0,10.); - - hfedchannelsize = fs->make("hfedchannelsize", "pixels per fed/channel",40,-0.5,39.5,37,-0.5,36.5, 0.0,10000.); - - hfedchannelsizeb = fs->make("hfedchannelsizeb", "pixels per bpix channel",200,0.0,maxLink); - hfedchannelsizeb1 = fs->make("hfedchannelsizeb1", "pixels per bpix1 channel",200,0.0,maxLink); - hfedchannelsizeb2 = fs->make("hfedchannelsizeb2", "pixels per bpix2 channel",200,0.0,maxLink); - hfedchannelsizeb3 = fs->make("hfedchannelsizeb3", "pixels per bpix3 channel",200,0.0,maxLink); - hfedchannelsizef = fs->make("hfedchannelsizef", "pixels per fpix channel",200,0.0,maxLink); - + hevent = fs->make("hevent", "event", 1000, 0, 10000000.); + // horbit = fs->make("horbit","orbit",100, 0,100000000.); + hlumi = fs->make("hlumi", "lumi", 3000, 0, 3000.); + hlumi0 = fs->make("hlumi0", "lumi", 3000, 0, 3000.); + + hbx = fs->make("hbx", "bx", 4000, 0, 4000.); + hbx0 = fs->make("hbx0", "bx", 4000, 0, 4000.); + + // hbx1 = fs->make("hbx1", "bx", 4000,0,4000.); + // hbx2 = fs->make("hbx2", "bx", 4000,0,4000.); + // hbx3 = fs->make("hbx3", "bx", 4000,0,4000.); + // hbx4 = fs->make("hbx4", "bx", 4000,0,4000.); + // hbx5 = fs->make("hbx5", "bx", 4000,0,4000.); + // hbx6 = fs->make("hbx6", "bx", 4000,0,4000.); + // hbx7 = fs->make("hbx7", "bx", 4000,0,4000.); + // hbx8 = fs->make("hbx8", "bx", 4000,0,4000.); + // hbx9 = fs->make("hbx9", "bx", 4000,0,4000.); + // hbx10 = fs->make("hbx10", "bx", 4000,0,4000.); + // hbx11 = fs->make("hbx11", "bx", 4000,0,4000.); + // hbx12 = fs->make("hbx12", "bx", 4000,0,4000.); + + herrorTimels = + fs->make("herrorTimels", "timeouts vs ls", 1000, 0, 3000); + herrorOverls = + fs->make("herrorOverls", "overflows vs ls", 1000, 0, 3000); + herrorTimels1 = + fs->make("herrorTimels1", "timeouts vs ls", 1000, 0, 3000); + herrorOverls1 = + fs->make("herrorOverls1", "overflows vs ls", 1000, 0, 3000); + herrorTimels2 = + fs->make("herrorTimels2", "timeouts vs ls", 1000, 0, 3000); + herrorOverls2 = + fs->make("herrorOverls2", "overflows vs ls", 1000, 0, 3000); + herrorTimels3 = + fs->make("herrorTimels3", "timeouts vs ls", 1000, 0, 3000); + herrorOverls3 = + fs->make("herrorOverls3", "overflows vs ls", 1000, 0, 3000); + herrorTimels0 = + fs->make("herrorTimels0", "timeouts vs ls", 1000, 0, 3000); + herrorOverls0 = + fs->make("herrorOverls0", "overflows vs ls", 1000, 0, 3000); + + hfed2DErrorsType1 = + fs->make("hfed2DErrorsType1", "errors type 1 per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrorsType2 = + fs->make("hfed2DErrorsType2", "errors type 2 per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + + hfed2DErrors1 = fs->make("hfed2DErrors1", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + // hfed2DErrors2 = fs->make("hfed2DErrors2", "errors per FED", + // 40,-0.5,39.5,37, -0.5, 36.5); + hfed2DErrors3 = fs->make("hfed2DErrors3", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors4 = fs->make("hfed2DErrors4", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors5 = fs->make("hfed2DErrors5", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors6 = fs->make("hfed2DErrors6", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + // hfed2DErrors7 = fs->make("hfed2DErrors7", "errors per FED", + // 40,-0.5,39.5,37, -0.5, 36.5); hfed2DErrors8 = + // fs->make("hfed2DErrors8", "errors per FED", 40,-0.5,39.5,37, + // -0.5, 36.5); hfed2DErrors9 = fs->make("hfed2DErrors9", "errors per + // FED", 40,-0.5,39.5,37, -0.5, 36.5); + hfed2DErrors10 = fs->make("hfed2DErrors10", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors11 = fs->make("hfed2DErrors11", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors12 = fs->make("hfed2DErrors12", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors13 = fs->make("hfed2DErrors13", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors14 = fs->make("hfed2DErrors14", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors15 = fs->make("hfed2DErrors15", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors16 = fs->make("hfed2DErrors16", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + + hfedErrorType1ls = fs->make("hfedErrorType1ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + hfedErrorType2ls = fs->make("hfedErrorType2ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + + hfed2DErrors1ls = fs->make("hfed2DErrors1ls", "errors vs lumi", 300, 0, + 3000, 40, -0.5, 39.5); // + // hfed2DErrors2ls = fs->make("hfed2DErrors2ls", "errors vs + // lumi",300,0,3000, 40,-0.5,39.5); // + hfed2DErrors3ls = fs->make("hfed2DErrors3ls", "errors vs lumi", 300, 0, + 3000, 40, -0.5, 39.5); // + hfed2DErrors4ls = fs->make("hfed2DErrors4ls", "errors vs lumi", 300, 0, + 3000, 40, -0.5, 39.5); // + hfed2DErrors5ls = fs->make("hfed2DErrors5ls", "errors vs lumi", 300, 0, + 3000, 40, -0.5, 39.5); // + hfed2DErrors6ls = fs->make("hfed2DErrors6ls", "errors vs lumi", 300, 0, + 3000, 40, -0.5, 39.5); // + // hfed2DErrors7ls = fs->make("hfed2DErrors7ls", "errors vs + // lumi",300,0,3000, 40,-0.5,39.5); // hfed2DErrors8ls = + // fs->make("hfed2DErrors8ls", "errors vs lumi",300,0,3000, + // 40,-0.5,39.5); // hfed2DErrors9ls = fs->make("hfed2DErrors9ls", + // "errors vs lumi",300,0,3000, 40,-0.5,39.5); // + hfed2DErrors10ls = fs->make("hfed2DErrors10ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + hfed2DErrors11ls = fs->make("hfed2DErrors11ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + hfed2DErrors12ls = fs->make("hfed2DErrors12ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + hfed2DErrors13ls = fs->make("hfed2DErrors13ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + hfed2DErrors14ls = fs->make("hfed2DErrors14ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + hfed2DErrors15ls = fs->make("hfed2DErrors15ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + hfed2DErrors16ls = fs->make("hfed2DErrors16ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + + herrorTimels = + fs->make("herrorTimels", "timeouts vs ls", 1000, 0, 3000); + herrorOverls = + fs->make("herrorOverls", "overflows vs ls", 1000, 0, 3000); + herrorTimels1 = + fs->make("herrorTimels1", "timeouts vs ls", 1000, 0, 3000); + herrorOverls1 = + fs->make("herrorOverls1", "overflows vs ls", 1000, 0, 3000); + herrorTimels2 = + fs->make("herrorTimels2", "timeouts vs ls", 1000, 0, 3000); + herrorOverls2 = + fs->make("herrorOverls2", "overflows vs ls", 1000, 0, 3000); + herrorTimels3 = + fs->make("herrorTimels3", "timeouts vs ls", 1000, 0, 3000); + herrorOverls3 = + fs->make("herrorOverls3", "overflows vs ls", 1000, 0, 3000); + herrorTimels0 = + fs->make("herrorTimels0", "timeouts vs ls", 1000, 0, 3000); + herrorOverls0 = + fs->make("herrorOverls0", "overflows vs ls", 1000, 0, 3000); + + hfed2DErrorsType1 = + fs->make("hfed2DErrorsType1", "errors type 1 per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrorsType2 = + fs->make("hfed2DErrorsType2", "errors type 2 per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + + hfed2DErrors1 = fs->make("hfed2DErrors1", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + // hfed2DErrors2 = fs->make("hfed2DErrors2", "errors per FED", + // 40,-0.5,39.5,37, -0.5, 36.5); + hfed2DErrors3 = fs->make("hfed2DErrors3", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors4 = fs->make("hfed2DErrors4", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors5 = fs->make("hfed2DErrors5", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors6 = fs->make("hfed2DErrors6", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + // hfed2DErrors7 = fs->make("hfed2DErrors7", "errors per FED", + // 40,-0.5,39.5,37, -0.5, 36.5); hfed2DErrors8 = + // fs->make("hfed2DErrors8", "errors per FED", 40,-0.5,39.5,37, + // -0.5, 36.5); hfed2DErrors9 = fs->make("hfed2DErrors9", "errors per + // FED", 40,-0.5,39.5,37, -0.5, 36.5); + hfed2DErrors10 = fs->make("hfed2DErrors10", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors11 = fs->make("hfed2DErrors11", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors12 = fs->make("hfed2DErrors12", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors13 = fs->make("hfed2DErrors13", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors14 = fs->make("hfed2DErrors14", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors15 = fs->make("hfed2DErrors15", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + hfed2DErrors16 = fs->make("hfed2DErrors16", "errors per FED", 40, -0.5, + 39.5, 37, -0.5, 36.5); + + hfedErrorType1ls = fs->make("hfedErrorType1ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + hfedErrorType2ls = fs->make("hfedErrorType2ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + + hfed2DErrors1ls = fs->make("hfed2DErrors1ls", "errors vs lumi", 300, 0, + 3000, 40, -0.5, 39.5); // + // hfed2DErrors2ls = fs->make("hfed2DErrors2ls", "errors vs + // lumi",300,0,3000, 40,-0.5,39.5); // + hfed2DErrors3ls = fs->make("hfed2DErrors3ls", "errors vs lumi", 300, 0, + 3000, 40, -0.5, 39.5); // + hfed2DErrors4ls = fs->make("hfed2DErrors4ls", "errors vs lumi", 300, 0, + 3000, 40, -0.5, 39.5); // + hfed2DErrors5ls = fs->make("hfed2DErrors5ls", "errors vs lumi", 300, 0, + 3000, 40, -0.5, 39.5); // + hfed2DErrors6ls = fs->make("hfed2DErrors6ls", "errors vs lumi", 300, 0, + 3000, 40, -0.5, 39.5); // + // hfed2DErrors7ls = fs->make("hfed2DErrors7ls", "errors vs + // lumi",300,0,3000, 40,-0.5,39.5); // hfed2DErrors8ls = + // fs->make("hfed2DErrors8ls", "errors vs lumi",300,0,3000, + // 40,-0.5,39.5); // hfed2DErrors9ls = fs->make("hfed2DErrors9ls", + // "errors vs lumi",300,0,3000, 40,-0.5,39.5); // + hfed2DErrors10ls = fs->make("hfed2DErrors10ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + hfed2DErrors11ls = fs->make("hfed2DErrors11ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + hfed2DErrors12ls = fs->make("hfed2DErrors12ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + hfed2DErrors13ls = fs->make("hfed2DErrors13ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + hfed2DErrors14ls = fs->make("hfed2DErrors14ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + hfed2DErrors15ls = fs->make("hfed2DErrors15ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + hfed2DErrors16ls = fs->make("hfed2DErrors16ls", "errors vs lumi", 300, + 0, 3000, 40, -0.5, 39.5); // + + hsizels = fs->make("hsizels", " bpix fed size vs ls", 300, 0, 3000, + 0, 200000.); + htotPixelsls = fs->make("htotPixelsls", " tot pixels vs ls", 300, 0, + 3000, 0, 300000.); + havsizels = fs->make("havsizels", "av. bpix fed size vs ls", 300, 0, + 3000, 0, 300000.); + + herrorType1ls = fs->make("herrorType1ls", "error type 1 vs ls", 300, + 0, 3000, 0, 1000.); + herrorType2ls = fs->make("herrorType2ls", "error type 2 vs ls", 300, + 0, 3000, 0, 1000.); + + herror1ls = + fs->make("herror1ls", "error 1 vs ls", 300, 0, 3000, 0, 1000.); + // herror2ls = fs->make("herror2ls","error 2 vs + // ls",300,0,3000,0,1000.); + herror3ls = + fs->make("herror3ls", "error 3 vs ls", 300, 0, 3000, 0, 1000.); + herror4ls = + fs->make("herror4ls", "error 4 vs ls", 300, 0, 3000, 0, 1000.); + herror5ls = + fs->make("herror5ls", "error 5 vs ls", 300, 0, 3000, 0, 1000.); + herror6ls = + fs->make("herror6ls", "error 6 vs ls", 300, 0, 3000, 0, 1000.); + // herror7ls = fs->make("herror7ls","error 7 vs + // ls",300,0,3000,0,1000.); herror8ls = fs->make("herror8ls","error + // 8 vs ls",300,0,3000,0,1000.); herror9ls = + // fs->make("herror9ls","error 9 vs ls",300,0,3000,0,1000.); + herror10ls = fs->make("herror10ls", "error 10 vs ls", 300, 0, 3000, + 0, 1000.); + herror11ls = fs->make("herror11ls", "error 11 vs ls", 300, 0, 3000, + 0, 1000.); + herror12ls = fs->make("herror12ls", "error 12 vs ls", 300, 0, 3000, + 0, 1000.); + herror13ls = fs->make("herror13ls", "error 13 vs ls", 300, 0, 3000, + 0, 1000.); + herror14ls = fs->make("herror14ls", "error 14 vs ls", 300, 0, 3000, + 0, 1000.); + herror15ls = fs->make("herror15ls", "error 15 vs ls", 300, 0, 3000, + 0, 1000.); + herror16ls = fs->make("herror16ls", "error 16 vs ls", 300, 0, 3000, + 0, 1000.); + + htotPixelsbx = fs->make("htotPixelsbx", " tot pixels vs bx", 4000, + -0.5, 3999.5, 0, 300000.); + havsizebx = fs->make("havsizebx", " ave bpix fed size vs bx", 4000, + -0.5, 3999.5, 0, 300000.); + herrorType1bx = fs->make("herrorType1bx", " error type 1 vs bx", + 4000, -0.5, 3999.5, 0, 300000.); + herrorType2bx = fs->make("herrorType2bx", " error type 2 vs bx", + 4000, -0.5, 3999.5, 0, 300000.); + + // hintgl = fs->make("hintgl", "inst lumi vs ls + // ",1000,0.,3000.,0.0,1000.); hinstl = fs->make("hinstl", "intg + // lumi vs ls ",1000,0.,3000.,0.0,10.); + + hfedchannelsize = + fs->make("hfedchannelsize", "pixels per fed/channel", 40, + -0.5, 39.5, 37, -0.5, 36.5, 0.0, 10000.); + + hfedchannelsizeb = fs->make( + "hfedchannelsizeb", "pixels per bpix channel", 200, 0.0, maxLink); + hfedchannelsizeb1 = fs->make( + "hfedchannelsizeb1", "pixels per bpix1 channel", 200, 0.0, maxLink); + hfedchannelsizeb2 = fs->make( + "hfedchannelsizeb2", "pixels per bpix2 channel", 200, 0.0, maxLink); + hfedchannelsizeb3 = fs->make( + "hfedchannelsizeb3", "pixels per bpix3 channel", 200, 0.0, maxLink); + hfedchannelsizef = fs->make( + "hfedchannelsizef", "pixels per fpix channel", 200, 0.0, maxLink); #ifdef OUTFILE outfile.open("pixfed.csv"); - for(int i=0;i<40;++i) {if(i<39) outfile<Fill(float(event)); hlumi0->Fill(float(lumiBlock)); hbx0->Fill(float(bx)); - //horbit->Fill(float(orbit)); + // horbit->Fill(float(orbit)); #ifdef L1 // Get L1 edm::Handle L1GTRR; - ev.getByLabel("gtDigis",L1GTRR); + ev.getByLabel("gtDigis", L1GTRR); if (L1GTRR.isValid()) { bool l1a = L1GTRR->decision(); - cout<<" L1 status :"< lumi; -// iLumi.getByLabel("lumiProducer", lumi); -// edm::Handle cond; -// float intlumi = 0, instlumi=0; -// int beamint1=0, beamint2=0; -// iLumi.getByLabel("conditionsInEdm", cond); -// // This will only work when running on RECO until (if) they fix it in the FW -// // When running on RAW and reconstructing, the LumiSummary will not appear -// // in the event before reaching endLuminosityBlock(). Therefore, it is not -// // possible to get this info in the event -// if (lumi.isValid()) { -// intlumi =(lumi->intgRecLumi())/1000.; // integrated lumi per LS in -pb -// instlumi=(lumi->avgInsDelLumi())/1000.; //ave. inst lumi per LS in -pb -// beamint1=(cond->totalIntensityBeam1)/1000; -// beamint2=(cond->totalIntensityBeam2)/1000; -// } else { -// std::cout << "** ERROR: Event does not get lumi info\n"; -// } -// cout<Fill(float(lumiBlock),float(instlumi)); -// hintgl->Fill(float(lumiBlock),float(intlumi)); - + // edm::LuminosityBlock const& iLumi = ev.getLuminosityBlock(); + // edm::Handle lumi; + // iLumi.getByLabel("lumiProducer", lumi); + // edm::Handle cond; + // float intlumi = 0, instlumi=0; + // int beamint1=0, beamint2=0; + // iLumi.getByLabel("conditionsInEdm", cond); + // // This will only work when running on RECO until (if) they fix it in the + // FW + // // When running on RAW and reconstructing, the LumiSummary will not + // appear + // // in the event before reaching endLuminosityBlock(). Therefore, it is + // not + // // possible to get this info in the event + // if (lumi.isValid()) { + // intlumi =(lumi->intgRecLumi())/1000.; // integrated lumi per LS in -pb + // instlumi=(lumi->avgInsDelLumi())/1000.; //ave. inst lumi per LS in -pb + // beamint1=(cond->totalIntensityBeam1)/1000; + // beamint2=(cond->totalIntensityBeam2)/1000; + // } else { + // std::cout << "** ERROR: Event does not get lumi info\n"; + // } + // cout<Fill(float(lumiBlock),float(instlumi)); + // hintgl->Fill(float(lumiBlock),float(intlumi)); edm::Handle buffers; - //static std::string label = theConfig.getUntrackedParameter("InputLabel","source"); - //static std::string instance = theConfig.getUntrackedParameter("InputInstance",""); - //ev.getByLabel( label, instance, buffers); - ev.getByToken(rawData , buffers); // the new bytoken + // static std::string label = + // theConfig.getUntrackedParameter("InputLabel","source"); static + // std::string instance = + // theConfig.getUntrackedParameter("InputInstance",""); + // ev.getByLabel( label, instance, buffers); + ev.getByToken(rawData, buffers); // the new bytoken - std::pair fedIds(FEDNumbering::MINSiPixelFEDID, FEDNumbering::MAXSiPixelFEDID); + std::pair fedIds(FEDNumbering::MINSiPixelFEDID, + FEDNumbering::MAXSiPixelFEDID); - //PixelDataFormatter formatter(0); // only for digis - //bool dummyErrorBool; + // PixelDataFormatter formatter(0); // only for digis + // bool dummyErrorBool; - //typedef unsigned int Word32; - //typedef long long Word64; + // typedef unsigned int Word32; + // typedef long long Word64; typedef uint32_t Word32; typedef uint64_t Word64; - int status=0; - int countPixels=0; + int status = 0; + int countPixels = 0; int eventId = -1; - int countErrorsPerEvent=0; - int countErrorsPerEvent1=0; - int countErrorsPerEvent2=0; + int countErrorsPerEvent = 0; + int countErrorsPerEvent1 = 0; + int countErrorsPerEvent2 = 0; double aveFedSize = 0.; - int stat1=-1, stat2=-1; + int stat1 = -1, stat2 = -1; int fedchannelsize[36]; - int countErrors[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + int countErrors[20] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; countAllEvents++; - if(printHeaders || printLocal>0) cout<<"Event = "< 0) + cout << "Event = " << countEvents << " Event number " << event << " Run " + << run << " LS " << lumiBlock << endl; // Loop over FEDs for (int fedId = fedIds.first; fedId <= fedIds.second; fedId++) { - - //edm::DetSetVector collection; + // edm::DetSetVector collection; PixelDataFormatter::Errors errors; - //get event data for this fed - const FEDRawData& rawData = buffers->FEDData( fedId ); + // get event data for this fed + const FEDRawData &rawData = buffers->FEDData(fedId); - if(printHeaders) cout<<"Get data For FED = "<Fill(float(2*nWords)); // fed buffer size in words (32bit) - hsize0->Fill(float(2*nWords)); // fed buffer size in words (32bit) - if(fedId<32) hsize1->Fill(float(2*nWords)); // bpix fed buffer size in words (32bit) - else hsize2->Fill(float(2*nWords)); // fpix fed buffer size in words (32bit) + hsize->Fill(float(2 * nWords)); // fed buffer size in words (32bit) + hsize0->Fill(float(2 * nWords)); // fed buffer size in words (32bit) + if (fedId < 32) + hsize1->Fill(float(2 * nWords)); // bpix fed buffer size in words (32bit) + else + hsize2->Fill(float(2 * nWords)); // fpix fed buffer size in words (32bit) #ifdef IND_FEDS - hsizeFeds[fedId]->Fill(float(2*nWords)); // size, includes errors and dummy words + hsizeFeds[fedId]->Fill( + float(2 * nWords)); // size, includes errors and dummy words #endif - hsize2d->Fill(float(fedId),float(2*nWords)); // 2d - hsizep->Fill(float(fedId),float(2*nWords)); // profile - if(fedId<32) hsizels->Fill(float(lumiBlock),float(2*nWords)); // bpix versu sls + hsize2d->Fill(float(fedId), float(2 * nWords)); // 2d + hsizep->Fill(float(fedId), float(2 * nWords)); // profile + if (fedId < 32) + hsizels->Fill(float(lumiBlock), float(2 * nWords)); // bpix versu sls // check headers - const Word64* header = reinterpret_cast(rawData.data()); - //cout<(rawData.data()); + // cout<(rawData.data())+(nWords-1); - //cout<(rawData.data()) + (nWords - 1); + // cout<> 32 & WORD32_mask; // 2nd word - } - - num++; - if(printLocal>3) cout<<" "<10) layer = layer-10; // ignore 1/2 modules - if(status>0) { // data - countPixels++; - countPixelsInFed++; - fedchannelsize[fedChannel-1]++; - - } else if(status<0) { // error word - countErrorsInFed++; - //if( status == -6 || status == -5) - if(printErrors) cout<<" Bad stats for FED "<Fill(float(fedId),float(fedChannel)); - hfed2DErrors10ls->Fill(float(lumiBlock),float(fedId)); //errors - - herrorTimels->Fill(float(lumiBlock)); - if(layer==1) herrorTimels1->Fill(float(lumiBlock)); - else if(layer==2) herrorTimels2->Fill(float(lumiBlock)); - else if(layer==3) herrorTimels3->Fill(float(lumiBlock)); - else if(layer==0) herrorTimels0->Fill(float(lumiBlock)); - - //hbx1->Fill(float(bx)); - break; } - - case(14) : { // OVER - - countErrors[14]++; - fedErrorsOver[fedId][(fedChannel-1)]++; - hfed2DErrors14->Fill(float(fedId),float(fedChannel)); - hfed2DErrors14ls->Fill(float(lumiBlock),float(fedId)); //errors - - herrorOverls->Fill(float(lumiBlock)); - if(layer==1) herrorOverls1->Fill(float(lumiBlock)); - else if(layer==2) herrorOverls2->Fill(float(lumiBlock)); - else if(layer==3) herrorOverls3->Fill(float(lumiBlock)); - else if(layer==0) herrorOverls0->Fill(float(lumiBlock)); - //hbx2->Fill(float(bx)); - break; } - - case(11) : { // ENE - - countErrors[11]++; - hfed2DErrors11->Fill(float(fedId),float(fedChannel)); - hfed2DErrors11ls->Fill(float(lumiBlock),float(fedId)); //errors - //hbx3->Fill(float(bx)); - fedErrorsENE[fedId][(fedChannel-1)]++; - break; } - - case(16) : { //FIFO - - countErrors[16]++; - hfed2DErrors16->Fill(float(fedId),float(fedChannel)); - hfed2DErrors16ls->Fill(float(lumiBlock),float(fedId)); //errors - break; } - - case(12) : { // NOR - - countErrors[12]++; - hfed2DErrors12->Fill(float(fedId),float(fedChannel)); - hfed2DErrors12ls->Fill(float(lumiBlock),float(fedId)); //errors - //hbx5->Fill(float(bx)); - break; } - - case(15) : { // TBM Trailer - - countErrors[15]++; - hfed2DErrors15->Fill(float(fedId),float(fedChannel)); - hfed2DErrors15ls->Fill(float(lumiBlock),float(fedId)); //errors - break; } - - case(13) : { // FSM - - countErrors[13]++; - hfed2DErrors13->Fill(float(fedId),float(fedChannel)); - hfed2DErrors13ls->Fill(float(lumiBlock),float(fedId)); //errors - break; } - - case(3) : { // inv. pix-dcol - - countErrors[3]++; - hfed2DErrors3->Fill(float(fedId),float(fedChannel)); - hfed2DErrors3ls->Fill(float(lumiBlock),float(fedId)); //errors - //hbx8->Fill(float(bx)); - break; } - - case(4) : { // inv roc - countErrors[4]++; - hfed2DErrors4->Fill(float(fedId),float(fedChannel)); - hfed2DErrors4ls->Fill(float(lumiBlock),float(fedId)); //errors - //hbx9->Fill(float(bx)); - break; } - - case(5) : { // pix=0 - countErrors[5]++; - hfed2DErrors5->Fill(float(fedId),float(fedChannel)); - hfed2DErrors5ls->Fill(float(lumiBlock),float(fedId)); //errors - //hbx10->Fill(float(bx)); - - hroc000->Fill(float(stat1)); // count rocs - hcount000->Fill(float(stat2)); - hcount0002->Fill(float(fedId),float(stat2)); - break; } - - case(6) : { // double pix - - countErrors[6]++; - hfed2DErrors6->Fill(float(fedId),float(fedChannel)); - hfed2DErrors6ls->Fill(float(lumiBlock),float(fedId)); //errors - //hbx12->Fill(float(bx)); - - hrocDouble->Fill(float(stat1)); // count rocs - hcountDouble->Fill(float(stat2)); - hcountDouble2->Fill(float(fedId),float(stat2)); - break; } - - case(1) : { // unknown - countErrors[1]++; - hfed2DErrors1->Fill(float(fedId),float(fedChannel)); - hfed2DErrors1ls->Fill(float(lumiBlock),float(fedId)); //errors - break; } - - } // end switch - - if(status<20) errorType[status]++; - - //herrorType0->Fill(float(status)); - //herrorFed0->Fill(float(fedId)); - //herrorChan0->Fill(float(fedChannel)); - - hfed2d->Fill(float(fedId),float(status)); - - if(status>=10) { // hard errors - // Type - 1 Errors - - countErrorsInFed1++; - hfedErrorType1ls->Fill(float(lumiBlock),float(fedId)); // hard errors - hfed2DErrorsType1->Fill(float(fedId),float(fedChannel)); - - herrorType1->Fill(float(status)); - herrorType1Fed->Fill(float(fedId)); - herrorType1Chan->Fill(float(fedChannel)); - - fedErrors[fedId][(fedChannel-1)]++; - - } else if(status>0) { // decode errors - // Type 2 errprs - - countErrorsInFed2++; - hfedErrorType2ls->Fill(float(lumiBlock),float(fedId)); // decode errors - hfed2DErrorsType2->Fill(float(fedId),float(fedChannel)); - - herrorType2->Fill(float(status)); - herrorType2Fed->Fill(float(fedId)); - herrorType2Chan->Fill(float(fedChannel)); - - if(status==5) decodeErrors000[fedId][(fedChannel-1)]++; - else if(status==6) decodeErrorsDouble[fedId][(fedChannel-1)]++; - else decodeErrors[fedId][(fedChannel-1)]++; - } - - } + for (const Word64 *word = header + 1; word != trailer; word++) { + static const Word64 WORD32_mask = 0xffffffff; + + for (int ipart = 0; ipart < 2; ++ipart) { + Word32 w = 0; + if (ipart == 0) { + w = *word & WORD32_mask; // 1st word + // w1=w; + } else if (ipart == 1) { + w = *word >> 32 & WORD32_mask; // 2nd word + } + + num++; + if (printLocal > 3) + cout << " " << num << " " << hex << w << dec << endl; + + status = MyDecode::data(w, fedChannel, fedId, stat1, stat2, printData); + int layer = + MyDecode::checkLayerLink(fedId, fedChannel); // get bpix layer + if (layer > 10) + layer = layer - 10; // ignore 1/2 modules + if (status > 0) { // data + countPixels++; + countPixelsInFed++; + fedchannelsize[fedChannel - 1]++; + + } else if (status < 0) { // error word + countErrorsInFed++; + // if( status == -6 || status == -5) + if (printErrors) + cout << " Bad stats for FED " << fedId << " Event " << eventId + << "/" << countAllEvents << " chan " << fedChannel + << " status " << status << endl; + status = abs(status); + // 2 - wrong channel + // 3 - wrong pix or dcol + // 4 - wrong roc + // 5 - pix=0 + // 6 - double pixel + // 10 - timeout () + // 11 - ene () + // 12 - mum pf rocs error () + // 13 - fsm () + // 14 - overflow () + // 15 - trailer () + // 16 - fifo (30) + // 17 - reset/resync NOT INCLUDED YET + + switch (status) { + case (10): { // Timeout + + countErrors[10]++; + fedErrorsTime[fedId][(fedChannel - 1)]++; + hfed2DErrors10->Fill(float(fedId), float(fedChannel)); + hfed2DErrors10ls->Fill(float(lumiBlock), float(fedId)); // errors + + herrorTimels->Fill(float(lumiBlock)); + if (layer == 1) + herrorTimels1->Fill(float(lumiBlock)); + else if (layer == 2) + herrorTimels2->Fill(float(lumiBlock)); + else if (layer == 3) + herrorTimels3->Fill(float(lumiBlock)); + else if (layer == 0) + herrorTimels0->Fill(float(lumiBlock)); + + // hbx1->Fill(float(bx)); + break; + } + + case (14): { // OVER + + countErrors[14]++; + fedErrorsOver[fedId][(fedChannel - 1)]++; + hfed2DErrors14->Fill(float(fedId), float(fedChannel)); + hfed2DErrors14ls->Fill(float(lumiBlock), float(fedId)); // errors + + herrorOverls->Fill(float(lumiBlock)); + if (layer == 1) + herrorOverls1->Fill(float(lumiBlock)); + else if (layer == 2) + herrorOverls2->Fill(float(lumiBlock)); + else if (layer == 3) + herrorOverls3->Fill(float(lumiBlock)); + else if (layer == 0) + herrorOverls0->Fill(float(lumiBlock)); + // hbx2->Fill(float(bx)); + break; + } + + case (11): { // ENE + + countErrors[11]++; + hfed2DErrors11->Fill(float(fedId), float(fedChannel)); + hfed2DErrors11ls->Fill(float(lumiBlock), float(fedId)); // errors + // hbx3->Fill(float(bx)); + fedErrorsENE[fedId][(fedChannel - 1)]++; + break; + } + + case (16): { // FIFO + + countErrors[16]++; + hfed2DErrors16->Fill(float(fedId), float(fedChannel)); + hfed2DErrors16ls->Fill(float(lumiBlock), float(fedId)); // errors + break; + } + + case (12): { // NOR + + countErrors[12]++; + hfed2DErrors12->Fill(float(fedId), float(fedChannel)); + hfed2DErrors12ls->Fill(float(lumiBlock), float(fedId)); // errors + // hbx5->Fill(float(bx)); + break; + } + + case (15): { // TBM Trailer + + countErrors[15]++; + hfed2DErrors15->Fill(float(fedId), float(fedChannel)); + hfed2DErrors15ls->Fill(float(lumiBlock), float(fedId)); // errors + break; + } + + case (13): { // FSM + + countErrors[13]++; + hfed2DErrors13->Fill(float(fedId), float(fedChannel)); + hfed2DErrors13ls->Fill(float(lumiBlock), float(fedId)); // errors + break; + } + + case (3): { // inv. pix-dcol + + countErrors[3]++; + hfed2DErrors3->Fill(float(fedId), float(fedChannel)); + hfed2DErrors3ls->Fill(float(lumiBlock), float(fedId)); // errors + // hbx8->Fill(float(bx)); + break; + } + + case (4): { // inv roc + countErrors[4]++; + hfed2DErrors4->Fill(float(fedId), float(fedChannel)); + hfed2DErrors4ls->Fill(float(lumiBlock), float(fedId)); // errors + // hbx9->Fill(float(bx)); + break; + } + + case (5): { // pix=0 + countErrors[5]++; + hfed2DErrors5->Fill(float(fedId), float(fedChannel)); + hfed2DErrors5ls->Fill(float(lumiBlock), float(fedId)); // errors + // hbx10->Fill(float(bx)); + + hroc000->Fill(float(stat1)); // count rocs + hcount000->Fill(float(stat2)); + hcount0002->Fill(float(fedId), float(stat2)); + break; + } + + case (6): { // double pix + + countErrors[6]++; + hfed2DErrors6->Fill(float(fedId), float(fedChannel)); + hfed2DErrors6ls->Fill(float(lumiBlock), float(fedId)); // errors + // hbx12->Fill(float(bx)); + + hrocDouble->Fill(float(stat1)); // count rocs + hcountDouble->Fill(float(stat2)); + hcountDouble2->Fill(float(fedId), float(stat2)); + break; + } + + case (1): { // unknown + countErrors[1]++; + hfed2DErrors1->Fill(float(fedId), float(fedChannel)); + hfed2DErrors1ls->Fill(float(lumiBlock), float(fedId)); // errors + break; + } + + } // end switch + + if (status < 20) + errorType[status]++; + + // herrorType0->Fill(float(status)); + // herrorFed0->Fill(float(fedId)); + // herrorChan0->Fill(float(fedChannel)); + + hfed2d->Fill(float(fedId), float(status)); + + if (status >= 10) { // hard errors + // Type - 1 Errors + + countErrorsInFed1++; + hfedErrorType1ls->Fill(float(lumiBlock), + float(fedId)); // hard errors + hfed2DErrorsType1->Fill(float(fedId), float(fedChannel)); + + herrorType1->Fill(float(status)); + herrorType1Fed->Fill(float(fedId)); + herrorType1Chan->Fill(float(fedChannel)); + + fedErrors[fedId][(fedChannel - 1)]++; + + } else if (status > 0) { // decode errors + // Type 2 errprs + + countErrorsInFed2++; + hfedErrorType2ls->Fill(float(lumiBlock), + float(fedId)); // decode errors + hfed2DErrorsType2->Fill(float(fedId), float(fedChannel)); + + herrorType2->Fill(float(status)); + herrorType2Fed->Fill(float(fedId)); + herrorType2Chan->Fill(float(fedChannel)); + + if (status == 5) + decodeErrors000[fedId][(fedChannel - 1)]++; + else if (status == 6) + decodeErrorsDouble[fedId][(fedChannel - 1)]++; + else + decodeErrors[fedId][(fedChannel - 1)]++; + } + } } // for 1/2 word } // loop over longlong words @@ -1273,44 +1607,59 @@ void SiPixelRawDumper::analyze(const edm::Event& ev, const edm::EventSetup& es) countErrorsPerEvent1 += countErrorsInFed1; countErrorsPerEvent2 += countErrorsInFed2; - //convert data to digi (dummy for the moment) - //formatter.interpretRawData( dummyErrorBool, fedId, rawData, collection, errors); - //cout<0) { + if (countPixelsInFed > 0) { sumFedPixels[fedId] += countPixelsInFed; } hpixels->Fill(float(countPixelsInFed)); hpixels0->Fill(float(countPixelsInFed)); - if(countPixelsInFed>0) hpixels1->Fill(float(countPixelsInFed)); - if(countPixelsInFed>0 && fedId<32) hpixels2->Fill(float(countPixelsInFed)); - if(countPixelsInFed>0 && fedId>=32) hpixels3->Fill(float(countPixelsInFed)); + if (countPixelsInFed > 0) + hpixels1->Fill(float(countPixelsInFed)); + if (countPixelsInFed > 0 && fedId < 32) + hpixels2->Fill(float(countPixelsInFed)); + if (countPixelsInFed > 0 && fedId >= 32) + hpixels3->Fill(float(countPixelsInFed)); herrors->Fill(float(countErrorsInFed)); - for(int i=0;i<36;++i) { - hfedchannelsize->Fill( float(fedId), float(i+1), float(fedchannelsize[i]) ); - if(fedId<32) { - hfedchannelsizeb->Fill( float(fedchannelsize[i]) ); - int layer = MyDecode::checkLayerLink(fedId, i); // get bpix layer - if(layer>10) layer = layer-10; // ignore 1/2 modules - if(layer==3) hfedchannelsizeb3->Fill( float(fedchannelsize[i]) ); // layer 3 - else if(layer==2) hfedchannelsizeb2->Fill( float(fedchannelsize[i]) ); // layer 2 - else if(layer==1) hfedchannelsizeb1->Fill( float(fedchannelsize[i]) ); // layer 1 - else cout<<" Cannot be "<Fill( float(fedchannelsize[i]) ); // fpix + for (int i = 0; i < 36; ++i) { + hfedchannelsize->Fill(float(fedId), float(i + 1), + float(fedchannelsize[i])); + if (fedId < 32) { + hfedchannelsizeb->Fill(float(fedchannelsize[i])); + int layer = MyDecode::checkLayerLink(fedId, i); // get bpix layer + if (layer > 10) + layer = layer - 10; // ignore 1/2 modules + if (layer == 3) + hfedchannelsizeb3->Fill(float(fedchannelsize[i])); // layer 3 + else if (layer == 2) + hfedchannelsizeb2->Fill(float(fedchannelsize[i])); // layer 2 + else if (layer == 1) + hfedchannelsizeb1->Fill(float(fedchannelsize[i])); // layer 1 + else + cout << " Cannot be " << layer << " " << fedId << " " << i << endl; + } else + hfedchannelsizef->Fill(float(fedchannelsize[i])); // fpix } - // if(fedId == fedIds.first || countPixelsInFed>0 || countErrorsInFed>0 ) { + // if(fedId == fedIds.first || countPixelsInFed>0 || countErrorsInFed>0 ) + // { // eventId = MyDecode::header(*header, true); - // if(countPixelsInFed>0 || countErrorsInFed>0 ) cout<<"fed "<0 || countErrorsInFed>0 ) cout<<"fed + // "<Fill(float(countPixels)); htotErrors->Fill(float(countErrorsPerEvent)); - htotPixelsls->Fill(float(lumiBlock),float(countPixels)); - htotPixelsbx->Fill(float(bx),float(countPixels)); - - herrorType1ls->Fill(float(lumiBlock),float(countErrorsPerEvent1)); - herrorType2ls->Fill(float(lumiBlock),float(countErrorsPerEvent2)); + htotPixelsls->Fill(float(lumiBlock), float(countPixels)); + htotPixelsbx->Fill(float(bx), float(countPixels)); - herror1ls->Fill(float(lumiBlock),float(countErrors[1])); - herror3ls->Fill(float(lumiBlock),float(countErrors[3])); - herror4ls->Fill(float(lumiBlock),float(countErrors[4])); - herror5ls->Fill(float(lumiBlock),float(countErrors[5])); - herror6ls->Fill(float(lumiBlock),float(countErrors[6])); - herror10ls->Fill(float(lumiBlock),float(countErrors[10])); - herror11ls->Fill(float(lumiBlock),float(countErrors[11])); - herror12ls->Fill(float(lumiBlock),float(countErrors[12])); - herror13ls->Fill(float(lumiBlock),float(countErrors[13])); - herror14ls->Fill(float(lumiBlock),float(countErrors[14])); - herror15ls->Fill(float(lumiBlock),float(countErrors[15])); - herror16ls->Fill(float(lumiBlock),float(countErrors[16])); + herrorType1ls->Fill(float(lumiBlock), float(countErrorsPerEvent1)); + herrorType2ls->Fill(float(lumiBlock), float(countErrorsPerEvent2)); + herror1ls->Fill(float(lumiBlock), float(countErrors[1])); + herror3ls->Fill(float(lumiBlock), float(countErrors[3])); + herror4ls->Fill(float(lumiBlock), float(countErrors[4])); + herror5ls->Fill(float(lumiBlock), float(countErrors[5])); + herror6ls->Fill(float(lumiBlock), float(countErrors[6])); + herror10ls->Fill(float(lumiBlock), float(countErrors[10])); + herror11ls->Fill(float(lumiBlock), float(countErrors[11])); + herror12ls->Fill(float(lumiBlock), float(countErrors[12])); + herror13ls->Fill(float(lumiBlock), float(countErrors[13])); + herror14ls->Fill(float(lumiBlock), float(countErrors[14])); + herror15ls->Fill(float(lumiBlock), float(countErrors[15])); + herror16ls->Fill(float(lumiBlock), float(countErrors[16])); - herrorType1bx->Fill(float(bx),float(countErrorsPerEvent1)); - herrorType2bx->Fill(float(bx),float(countErrorsPerEvent2)); + herrorType1bx->Fill(float(bx), float(countErrorsPerEvent1)); + herrorType2bx->Fill(float(bx), float(countErrorsPerEvent2)); aveFedSize /= 32.; hsize3->Fill(aveFedSize); - //hsize2dls->Fill(float(lumiBlock),aveFedSize); + // hsize2dls->Fill(float(lumiBlock),aveFedSize); - havsizels->Fill(float(lumiBlock),aveFedSize); - havsizebx->Fill(float(bx),aveFedSize); + havsizels->Fill(float(lumiBlock), aveFedSize); + havsizebx->Fill(float(bx), aveFedSize); - if(countPixels>0) { + if (countPixels > 0) { hlumi->Fill(float(lumiBlock)); hbx->Fill(float(bx)); htotPixels1->Fill(float(countPixels)); - //cout<<"EVENT: "<>dummy; - } // end if + // int dummy=0; + // cout<<" : "; + // cin>>dummy; + } // end if - } // end analyze // 2 - wrong channel // 4 - wrong roc -// 3 - wrong pix or dcol +// 3 - wrong pix or dcol // 5 - pix=0 // 6 - double pix - // 10 - timeout () - // 11 - ene () - // 12 - mum pf rocs error () - // 13 - fsm () - // 14 - overflow () - // 15 - trailer () - // 16 - fifo (30) - // 17 - reset/resync NOT INCLUDED YET +// 10 - timeout () +// 11 - ene () +// 12 - mum pf rocs error () +// 13 - fsm () +// 14 - overflow () +// 15 - trailer () +// 16 - fifo (30) +// 17 - reset/resync NOT INCLUDED YET #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(SiPixelRawDumper); diff --git a/EventFilter/SiPixelRawToDigi/test/findHotPixels.cc b/EventFilter/SiPixelRawToDigi/test/findHotPixels.cc index d94315e523161..141c2ade2f6b5 100644 --- a/EventFilter/SiPixelRawToDigi/test/findHotPixels.cc +++ b/EventFilter/SiPixelRawToDigi/test/findHotPixels.cc @@ -7,29 +7,28 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" - #include "DataFormats/Common/interface/Handle.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" #include "DataFormats/FEDRawData/interface/FEDRawData.h" +#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/FEDRawData/interface/FEDNumbering.h" #include "EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h" -#include #include +#include +#include #include #include -#include namespace { - const bool printErrors = true; - const bool printData = false; - const bool printHeaders = false; - int count1=0, count2=0, count3=0; -} +const bool printErrors = true; +const bool printData = false; +const bool printHeaders = false; +int count1 = 0, count2 = 0, count3 = 0; +} // namespace using namespace std; @@ -39,37 +38,43 @@ class MyDecode { public: MyDecode() {} ~MyDecode() {} - static int error(int error, bool print=false); - static int data(int error, int &channel, int &roc, int &dcol, int &pix, bool print=false); + static int error(int error, bool print = false); + static int data(int error, int &channel, int &roc, int &dcol, int &pix, + bool print = false); static int header(unsigned long long word64, bool print); static int trailer(unsigned long long word64, bool print); + private: }; ///////////////////////////////////////////////////////////////////////////// int MyDecode::header(unsigned long long word64, bool printFlag) { - int fed_id=(word64>>8)&0xfff; - int event_id=(word64>>32)&0xffffff; - unsigned int bx_id=(word64>>20)&0xfff; -// if(bx_id!=101) { -// cout<<" Header "<<" for FED " -// <>dummy; -// } - if(printFlag) cout<<" Header "<<" for FED " - <> 8) & 0xfff; + int event_id = (word64 >> 32) & 0xffffff; + unsigned int bx_id = (word64 >> 20) & 0xfff; + // if(bx_id!=101) { + // cout<<" Header "<<" for FED " + // <>dummy; + // } + if (printFlag) + cout << " Header " + << " for FED " << fed_id << " event " << event_id << " bx " << bx_id + << endl; + return event_id; } // int MyDecode::trailer(unsigned long long word64, bool printFlag) { - int slinkLength = int( (word64>>32) & 0xffffff ); - int crc = int( (word64&0xffff0000)>>16 ); - int tts = int( (word64&0xf0)>>4); - int slinkError = int( (word64&0xf00)>>8); - if(printFlag) cout<<" Trailer "<<" len "<> 32) & 0xffffff); + int crc = int((word64 & 0xffff0000) >> 16); + int tts = int((word64 & 0xf0) >> 4); + int slinkError = int((word64 & 0xf00) >> 8); + if (printFlag) + cout << " Trailer " + << " len " << slinkLength << " tts " << tts << " error " << slinkError + << " crc " << hex << crc << dec << endl; return slinkLength; } // @@ -77,102 +82,114 @@ int MyDecode::trailer(unsigned long long word64, bool printFlag) { // Works for both, the error FIFO and the SLink error words. d.k. 25/04/07 int MyDecode::error(int word, bool printFlag) { int status = -1; - const unsigned int errorMask = 0x3e00000; - const unsigned int dummyMask = 0x03600000; - const unsigned int gapMask = 0x03400000; - const unsigned int timeOut = 0x3a00000; - const unsigned int eventNumError = 0x3e00000; - const unsigned int trailError = 0x3c00000; - const unsigned int fifoError = 0x3800000; - -// const unsigned int timeOutChannelMask = 0x1f; // channel mask for timeouts - //const unsigned int eventNumMask = 0x1fe000; // event number mask - const unsigned int channelMask = 0xfc000000; // channel num mask - const unsigned int tbmEventMask = 0xff; // tbm event num mask - const unsigned int overflowMask = 0x100; // data overflow - const unsigned int tbmStatusMask = 0xff; //TBM trailer info - const unsigned int BlkNumMask = 0x700; //pointer to error fifo # - const unsigned int FsmErrMask = 0x600; //pointer to FSM errors - const unsigned int RocErrMask = 0x800; //pointer to #Roc errors - const unsigned int ChnFifMask = 0x1f; //channel mask for fifo error - const unsigned int Fif2NFMask = 0x40; //mask for fifo2 NF - const unsigned int TrigNFMask = 0x80; //mask for trigger fifo NF - - const int offsets[8] = {0,4,9,13,18,22,27,31}; - - //cout<<"error word "<>8; - int offset = offsets[chip]; - if(printErrors) { - cout<<"Timeout Error- channels: "; - for(int i=0;i<5;i++) { - if( (index & 0x1) != 0) { - int chan = offset + i + 1; - cout<> 8; + int offset = offsets[chip]; + if (printErrors) { + cout << "Timeout Error- channels: "; + for (int i = 0; i < 5; i++) { + if ((index & 0x1) != 0) { + int chan = offset + i + 1; + cout << chan << " "; + } + index = index >> 1; } - index = index >> 1; - } - cout<>26; - unsigned int tbm_event = (word & tbmEventMask); - - if(printErrors) cout<<"Event Number Error- channel: "<>26; - unsigned int tbm_status = (word & tbmStatusMask); - if(word & RocErrMask) - if(printErrors) cout<<"Number of Rocs Error- "<<"channel: "<>9)<> 26; + unsigned int tbm_event = (word & tbmEventMask); + + if (printErrors) + cout << "Event Number Error- channel: " << channel << " tbm event nr. " + << tbm_event << endl; + + } else if (((word & errorMask) == trailError)) { + unsigned int channel = (word & channelMask) >> 26; + unsigned int tbm_status = (word & tbmStatusMask); + if (word & RocErrMask) + if (printErrors) + cout << "Number of Rocs Error- " + << "channel: " << channel << " " << endl; + if (word & FsmErrMask) + if (printErrors) + cout << "Finite State Machine Error- " + << "channel: " << channel << " Error status:0x" << hex + << ((word & FsmErrMask) >> 9) << dec << " " << endl; + if (word & overflowMask) + if (printErrors) + cout << "Overflow Error- " + << "channel: " << channel << " " << endl; + // if(!((word & RocErrMask)|(word & FsmErrMask)|(word & overflowMask))) + if (tbm_status != 0) + if (printErrors) + cout << "Trailer Error- " + << "channel: " << channel << " TBM status:0x" << hex << tbm_status + << dec << " " << endl; + + } else if ((word & errorMask) == fifoError) { + if (printErrors) { + if (word & Fif2NFMask) + cout << "A fifo 2 is Nearly full- "; + if (word & TrigNFMask) + cout << "The trigger fifo is nearly Full - "; + if (word & ChnFifMask) + cout << "fifo-1 is nearly full for channel" << (word & ChnFifMask); + cout << endl; } } else { - cout<<" Unknown error?"; + cout << " Unknown error?"; } - //unsigned int event = (word & eventNumMask) >>13; - //unsigned int tbm_status = (word & tbmStatusMask); - //if(event>0) cout<<":event: "<>13; + // unsigned int tbm_status = (word & tbmStatusMask); + // if(event>0) cout<<":event: "<>21); + int roc = ((word & rocmsk) >> 21); // Check for embeded special words - if(roc>0 && roc<25) { // valid ROCs go from 1-24 - //if(PRINT_PIXELS) cout<<"data "<>26); - if(channel>0 && channel<37) { // valid channels 1-36 - //cout<>16; - int pix=(word&pxlmsk)>>8; - int adc=(word&plsmsk); + if (roc > 0 && roc < 25) { // valid ROCs go from 1-24 + // if(PRINT_PIXELS) cout<<"data "<> 26); + if (channel > 0 && channel < 37) { // valid channels 1-36 + // cout<> 16; + int pix = (word & pxlmsk) >> 8; + int adc = (word & plsmsk); // print the roc number according to the online 0-15 scheme - if(PRINT_PIXELS) cout<<" Channel- "<ROCMAX) - cout<<" wrong roc number "<25) - cout<<" wrong dcol number "<181) - cout<<" wrong pix number chan/roc/dcol/pix/adc = "< ROCMAX) + cout << " wrong roc number " << channel << "/" << roc << "/" << dcol + << "/" << pix << "/" << adc << endl; + if (dcol < 0 || dcol > 25) + cout << " wrong dcol number " << channel << "/" << roc << "/" << dcol + << "/" << pix << "/" << adc << endl; + if (pix < 2 || pix > 181) + cout << " wrong pix number chan/roc/dcol/pix/adc = " << channel << "/" + << roc << "/" << dcol << "/" << pix << "/" << adc << endl; } c = channel; - r = roc-1; // start roc counting from 0 + r = roc - 1; // start roc counting from 0 d = dcol; p = pix; status++; } else { - cout<<"Wrong channel "<31) return " "; - if(fedChan0<1 || fedChan0>36) return " "; +string MyConvert::moduleNameFromFedChan(int fed0, int fedChan0, string &tbm0) { + if (fed0 < 0 || fed0 > 31) + return " "; + if (fedChan0 < 1 || fedChan0 > 36) + return " "; - ifstream infile; //input file, name data_file uniqe - infile.open("translation_bpix.dat",ios::in); // open data file + ifstream infile; // input file, name data_file uniqe + infile.open("translation_bpix.dat", ios::in); // open data file - //cout << infile.eof() << " " << infile.bad() << " " + // cout << infile.eof() << " " << infile.bad() << " " // << infile.fail() << " " << infile.good()<>name>>tbm>>fec>>mfec>>mfecChan>>hub>>port>>rocId>>fed>>fedChan>>rocOrder; - - if(name==" ")continue; - - if ( infile.eof() != 0 ) { - cout<< " end of file " << endl; - break;; + for (int i = 0; i < 100000; ++i) { + // bool print = false; + + infile >> name >> tbm >> fec >> mfec >> mfecChan >> hub >> port >> rocId >> + fed >> fedChan >> rocOrder; + + if (name == " ") + continue; + + if (infile.eof() != 0) { + cout << " end of file " << endl; + break; + ; } else if (infile.fail()) { // check for errors cout << "Cannot read data file" << endl; - return(" "); + return (" "); } - - if(fed==fedOld && fedChanOld==fedChan) continue; + + if (fed == fedOld && fedChanOld == fedChan) + continue; fedOld = fed; fedChanOld = fedChan; - - if(fed==fed0 && fedChan==fedChan0) { // found + if (fed == fed0 && fedChan == fedChan0) { // found found = true; - tbm0=tbm; + tbm0 = tbm; string::size_type idx; idx = name.find("_ROC"); - if(idx != string::npos) { + if (idx != string::npos) { // cout<<" ROC0 "<=NumPixels) { - cout<<" array too small "<= NumPixels) { + cout << " array too small " << count << " " << endl; } else { - data[count] =1; - array[count]=index; + data[count] = 1; + array[count] = index; count++; } } - } void HotPixels::print(int events, int fed_id) { - int channel=0, roc=0, dcol=0, pix=0; - int num =0; - int cut1 = events/100; - int cut2 = events/1000; - int cut3 = events/10000; - - int cut = events/1000; - //int cut = 2; - if(cut<2) cut=10; - - - - if(fed_id==0) { - cout<<" Threshold of "<cut1) count1++; - if(data[i]>cut2) count2++; - if(data[i]>cut3) count3++; - - if(data[i]>cut) { + for (int i = 0; i < count; ++i) { + if (data[i] > cut1) + count1++; + if (data[i] > cut2) + count2++; + if (data[i] > cut3) + count3++; + + if (data[i] > cut) { num++; int index = array[i]; decode(index, channel, roc, dcol, pix); - // First find if we are in the first or 2nd col of a dcol. - int colEvenOdd = pix%2; // module(2), 0-1st sol, 1-2nd col. + int colEvenOdd = pix % 2; // module(2), 0-1st sol, 1-2nd col. // Transform - int colROC = dcol * 2 + colEvenOdd; // col address, starts from 0 - int rowROC = abs( int(pix/2) - 80); // row addres, starts from 0 - //cout<( + theConfig.getUntrackedParameter("InputLabel", "source")); + } -} - /// dtor virtual ~findHotPixels() {} void beginJob(); - //void beginRun( const edm::EventSetup& ) {} + // void beginRun( const edm::EventSetup& ) {} - // end of job + // end of job void endJob(); /// get data, convert to digis attach againe to Event - virtual void analyze(const edm::Event&, const edm::EventSetup&); - + virtual void analyze(const edm::Event &, const edm::EventSetup &); + private: edm::ParameterSet theConfig; int countEvents, countAllEvents; @@ -435,126 +466,134 @@ class findHotPixels : public edm::EDAnalyzer { }; void findHotPixels::endJob() { - if(countEvents>0) { + if (countEvents > 0) { sumPixels /= float(countEvents); - for(int i=0;i<40;++i) sumFedPixels[i] /= float(countEvents); + for (int i = 0; i < 40; ++i) + sumFedPixels[i] /= float(countEvents); } - - cout<<" Total/non-empty events " < buffers; - static std::string label = theConfig.getUntrackedParameter("InputLabel","source"); - static std::string instance = theConfig.getUntrackedParameter("InputInstance",""); - - ev.getByLabel( label, instance, buffers); - - std::pair fedIds(FEDNumbering::MINSiPixelFEDID, FEDNumbering::MAXSiPixelFEDID); - - //PixelDataFormatter formatter(0); // to get digis - //bool dummyErrorBool; - + static std::string label = + theConfig.getUntrackedParameter("InputLabel", "source"); + static std::string instance = + theConfig.getUntrackedParameter("InputInstance", ""); + + ev.getByLabel(label, instance, buffers); + + std::pair fedIds(FEDNumbering::MINSiPixelFEDID, + FEDNumbering::MAXSiPixelFEDID); + + // PixelDataFormatter formatter(0); // to get digis + // bool dummyErrorBool; + typedef uint32_t Word32; typedef uint64_t Word64; - int status=0; - int countPixels=0; - int countErrors=0; + int status = 0; + int countPixels = 0; + int countErrors = 0; int eventId = -1; - int channel=-1, roc=-1, dcol=-1, pix=-1; - + int channel = -1, roc = -1, dcol = -1, pix = -1; + countAllEvents++; - if(printHeaders) cout<<" Event = "< collection; // for digis only + if (printHeaders) + cout << " Event = " << countEvents << endl; + // edm::DetSetVector collection; // for digis only // Loop over FEDs for (int fedId = fedIds.first; fedId <= fedIds.second; fedId++) { - LogDebug("findHotPixels")<< " GET DATA FOR FED: " << fedId ; - if(printHeaders) cout<<" For FED = "<FEDData( fedId ); - - int nWords = rawData.size()/sizeof(Word64); - //cout<<" size "<(rawData.data()); - //cout<(rawData.data()); + // cout<(rawData.data())+(nWords-1); - //cout<(rawData.data()) + (nWords - 1); + // cout<0) { - countPixels++; - countPixelsInFed++; - hotPixels[fedId].update(channel,roc,dcol,pix); - } else if(status<0) countErrorsInFed++; - Word32 w2 = *word >> 32 & WORD32_mask; + if (status > 0) { + countPixels++; + countPixelsInFed++; + hotPixels[fedId].update(channel, roc, dcol, pix); + } else if (status < 0) + countErrorsInFed++; + Word32 w2 = *word >> 32 & WORD32_mask; status = MyDecode::data(w2, channel, roc, dcol, pix, printData); - if(status>0) { - countPixels++; - countPixelsInFed++; - hotPixels[fedId].update(channel,roc,dcol,pix); - } else if(status<0) countErrorsInFed++; - //cout< 0) { + countPixels++; + countPixelsInFed++; + hotPixels[fedId].update(channel, roc, dcol, pix); + } else if (status < 0) + countErrorsInFed++; + // cout<0) { + + // convert data to digi (dummy for the moment) + // formatter.interpretRawData( dummyErrorBool, fedId, rawData, collection, + // errors); cout< 0) { sumFedPixels[fedId] += countPixelsInFed; } } // loop over feds - if(countPixels>0) { - cout<<"EVENT: "< 0) { + cout << "EVENT: " << countEvents << " " << eventId << " pixels " + << countPixels << " errors " << countErrors << endl; sumPixels += countPixels; countEvents++; - //int dummy=0; - //cout<<" : "; - //cin>>dummy; + // int dummy=0; + // cout<<" : "; + // cin>>dummy; } - } - #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(findHotPixels);