From 30db029affacae93178fe1507045f09ef9f403b3 Mon Sep 17 00:00:00 2001 From: Cms Build Date: Fri, 7 Feb 2020 15:09:50 +0100 Subject: [PATCH] Clang-Format --- .../interface/EcalEBTrigPrimTestAlgo.h | 240 ++++++------ .../src/EcalEBTrigPrimTestAlgo.cc | 341 +++++++++--------- .../src/EcalFenixLinearizer.cc | 183 +++++----- .../src/EcalFenixTcpFormat.cc | 201 +++++------ .../plugins/EcalEBTrigPrimAnalyzer.cc | 304 ++++++++-------- .../plugins/EcalEBTrigPrimAnalyzer.h | 28 +- .../plugins/EcalEBTrigPrimProducer.cc | 160 ++++---- .../plugins/EcalEBTrigPrimProducer.h | 35 +- .../plugins/SealModules.cc | 2 - 9 files changed, 704 insertions(+), 790 deletions(-) diff --git a/SimCalorimetry/EcalEBTrigPrimAlgos/interface/EcalEBTrigPrimTestAlgo.h b/SimCalorimetry/EcalEBTrigPrimAlgos/interface/EcalEBTrigPrimTestAlgo.h index 4e352ddc6d725..590ec84824998 100644 --- a/SimCalorimetry/EcalEBTrigPrimAlgos/interface/EcalEBTrigPrimTestAlgo.h +++ b/SimCalorimetry/EcalEBTrigPrimAlgos/interface/EcalEBTrigPrimTestAlgo.h @@ -17,7 +17,6 @@ //#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" - #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -26,79 +25,75 @@ #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h" - #include #include #include -#include +#include #include #include #include - class EcalTrigTowerDetId; class ETPCoherenceTest; class EcalEBTriggerPrimitiveSample; class CaloSubdetectorGeometry; class EBDataFrame; - - -class EcalEBTrigPrimTestAlgo -{ - public: - - explicit EcalEBTrigPrimTestAlgo(const edm::EventSetup & setup, int nSamples, int binofmax, bool tcpFormat, bool barrelOnly, bool debug, bool famos); +class EcalEBTrigPrimTestAlgo { +public: + explicit EcalEBTrigPrimTestAlgo( + const edm::EventSetup &setup, int nSamples, int binofmax, bool tcpFormat, bool barrelOnly, bool debug, bool famos); virtual ~EcalEBTrigPrimTestAlgo(); - // void run(const edm::EventSetup &, const EcalRecHitCollection *col, EcalEBTrigPrimDigiCollection & result, EcalEBTrigPrimDigiCollection & resultTcp); - void run(const edm::EventSetup &, const EBDigiCollection *col, EcalEBTrigPrimDigiCollection & result, EcalEBTrigPrimDigiCollection & resultTcp); - + void run(const edm::EventSetup &, + const EBDigiCollection *col, + EcalEBTrigPrimDigiCollection &result, + EcalEBTrigPrimDigiCollection &resultTcp); + void setPointers(const EcalTPGLinearizationConst *ecaltpLin, - const EcalTPGPedestals *ecaltpPed, - const EcalTPGCrystalStatus * ecaltpgBadX, - const EcalTPGWeightIdMap *ecaltpgWeightMap, - const EcalTPGWeightGroup *ecaltpgWeightGroup, - const EcalTPGSlidingWindow* ecaltpgSlidW, - const EcalTPGLutGroup *ecaltpgLutGroup, - const EcalTPGLutIdMap *ecaltpgLut, - const EcalTPGTowerStatus *ecaltpgBadTT, - const EcalTPGSpike * ecaltpgSpike ) -{ - ecaltpPed_=ecaltpPed; - ecaltpLin_=ecaltpLin; - ecaltpgBadX_=ecaltpgBadX; - ecaltpgWeightMap_=ecaltpgWeightMap; - ecaltpgWeightGroup_=ecaltpgWeightGroup; - ecaltpgSlidW_=ecaltpgSlidW; - ecaltpgLutGroup_=ecaltpgLutGroup; - ecaltpgLut_=ecaltpgLut; - ecaltpgBadTT_=ecaltpgBadTT; - ecaltpgSpike_= ecaltpgSpike; + const EcalTPGPedestals *ecaltpPed, + const EcalTPGCrystalStatus *ecaltpgBadX, + const EcalTPGWeightIdMap *ecaltpgWeightMap, + const EcalTPGWeightGroup *ecaltpgWeightGroup, + const EcalTPGSlidingWindow *ecaltpgSlidW, + const EcalTPGLutGroup *ecaltpgLutGroup, + const EcalTPGLutIdMap *ecaltpgLut, + const EcalTPGTowerStatus *ecaltpgBadTT, + const EcalTPGSpike *ecaltpgSpike) { + ecaltpPed_ = ecaltpPed; + ecaltpLin_ = ecaltpLin; + ecaltpgBadX_ = ecaltpgBadX; + ecaltpgWeightMap_ = ecaltpgWeightMap; + ecaltpgWeightGroup_ = ecaltpgWeightGroup; + ecaltpgSlidW_ = ecaltpgSlidW; + ecaltpgLutGroup_ = ecaltpgLutGroup; + ecaltpgLut_ = ecaltpgLut; + ecaltpgBadTT_ = ecaltpgBadTT; + ecaltpgSpike_ = ecaltpgSpike; } - - private: - - void init(const edm::EventSetup&); - template - void initStructures(std::vector > > > & towMap); - template - void clean(std::vector > > > &towerMap); - template - void fillMap(Coll const * col, std::vector > > > &towerMap); +private: + void init(const edm::EventSetup &); + template + void initStructures(std::vector > > > &towMap); + template + void clean(std::vector > > > &towerMap); + template + void fillMap(Coll const *col, + std::vector > > > &towerMap); int findStripNr(const EBDetId &id); int findStripNr(const EEDetId &id); // FIXME: temporary until hashedIndex works alsom for endcap - int getIndex(const EBDigiCollection *, EcalTrigTowerDetId& id) {return id.hashedIndex();} + int getIndex(const EBDigiCollection *, EcalTrigTowerDetId &id) { return id.hashedIndex(); } // mind that eta is continuous between barrel+endcap - int getIndex(const EEDigiCollection *, EcalTrigTowerDetId& id) { - int ind=(id.ietaAbs()-18)*72 + id.iphi(); - if (id.zside()<0) ind+=792; + int getIndex(const EEDigiCollection *, EcalTrigTowerDetId &id) { + int ind = (id.ietaAbs() - 18) * 72 + id.iphi(); + if (id.zside() < 0) + ind += 792; return ind; } @@ -106,46 +101,42 @@ class EcalEBTrigPrimTestAlgo // const CaloSubdetectorGeometry *theEndcapGeometry; edm::ESHandle theGeometry; - float threshold; int nSamples_; int binOfMaximum_; int maxNrSamples_; - bool tcpFormat_; bool barrelOnly_; - bool debug_; - bool famos_; + bool debug_; + bool famos_; - - int nrTowers_; // nr of towers found by fillmap method + int nrTowers_; // nr of towers found by fillmap method static const unsigned int maxNrTowers_; - static const unsigned int maxNrSamplesOut_; - static const unsigned int nrSamples_; + static const unsigned int maxNrSamplesOut_; + static const unsigned int nrSamples_; // data structures kept during the whole run std::vector > striptp_; - std::vector > > > towerMapEB_; - std::vector > > > towerMapEE_; - std::vector > hitTowers_; + std::vector > > > towerMapEB_; + std::vector > > > towerMapEE_; + std::vector > hitTowers_; std::vector towtp_; std::vector towtp2_; - enum {nbMaxStrips_=5}; - enum {nbMaxXtals_=5}; - - const EcalElectronicsMapping* theMapping_; + enum { nbMaxStrips_ = 5 }; + enum { nbMaxXtals_ = 5 }; + const EcalElectronicsMapping *theMapping_; - std::vector linearizer_; - EcalFenixAmplitudeFilter *amplitude_filter_; - EcalFenixPeakFinder *peak_finder_; + std::vector linearizer_; + EcalFenixAmplitudeFilter *amplitude_filter_; + EcalFenixPeakFinder *peak_finder_; EcalFenixStripFormatEB *fenixFormatterEB_; EcalFenixTcpFormat *fenixTcpFormat_; - + // - const EcalTPGPedestals * ecaltpPed_; + const EcalTPGPedestals *ecaltpPed_; const EcalTPGLinearizationConst *ecaltpLin_; const EcalTPGCrystalStatus *ecaltpgBadX_; const EcalTPGWeightIdMap *ecaltpgWeightMap_; @@ -154,13 +145,12 @@ class EcalEBTrigPrimTestAlgo const EcalTPGLutGroup *ecaltpgLutGroup_; const EcalTPGLutIdMap *ecaltpgLut_; const EcalTPGTowerStatus *ecaltpgBadTT_; - const EcalTPGSpike * ecaltpgSpike_; - + const EcalTPGSpike *ecaltpgSpike_; - EcalFenixLinearizer *getLinearizer (int i) const { return linearizer_[i];} + EcalFenixLinearizer *getLinearizer(int i) const { return linearizer_[i]; } std::vector > lin_out_; // - EcalFenixAmplitudeFilter *getFilter() const { return amplitude_filter_;} + EcalFenixAmplitudeFilter *getFilter() const { return amplitude_filter_; } std::vector filt_out_; std::vector peak_out_; std::vector format_out_; @@ -169,82 +159,84 @@ class EcalEBTrigPrimTestAlgo std::vector fgvb_out_temp_; // - EcalFenixPeakFinder *getPeakFinder() const { return peak_finder_;} - EcalFenixStripFormatEB *getFormatterEB() const { return fenixFormatterEB_;} + EcalFenixPeakFinder *getPeakFinder() const { return peak_finder_; } + EcalFenixStripFormatEB *getFormatterEB() const { return fenixFormatterEB_; } // - EcalFenixTcpFormat *getFormatter() const {return fenixTcpFormat_;} + EcalFenixTcpFormat *getFormatter() const { return fenixTcpFormat_; } std::vector tcpformat_out_; - - - }; - -template -void EcalEBTrigPrimTestAlgo::clean( std::vector > > > & towMap) { +template +void EcalEBTrigPrimTestAlgo::clean(std::vector > > > &towMap) { // clean internal data structures - for (unsigned int i=0;i -void EcalEBTrigPrimTestAlgo::fillMap(Coll const * col, - std::vector > > > &towerMap) -{ +template +void EcalEBTrigPrimTestAlgo::fillMap( + Coll const *col, std::vector > > > &towerMap) { typedef typename Coll::Digi Digi; - // implementation for Barrel + // implementation for Barrel if (col) { - nrTowers_=0; - if ( debug_) std::cout <<"Fill mapping, Collection size = "<< col->size() << std::endl;; - for(unsigned int i = 0; i < col->size() ; ++i) { - Digi samples((*col)[i]); - EcalTrigTowerDetId coarser=(*eTTmap_).towerOf(samples.id()); - int index=getIndex(col,coarser); - int stripnr=findStripNr(samples.id()); - - int filled=0; - for (unsigned int ij=0;ij= nbMaxXtals_) { + edm::LogError("EcalTrigPrimFunctionAlgo") + << "! Too many xtals for TT " << coarser << " stripnr " << stripnr << " xtalid " << samples.id(); + continue; } - ((towerMap[index])[stripnr-1].second)[ncryst]=samples; - (towerMap[index])[stripnr-1].first++; + ((towerMap[index])[stripnr - 1].second)[ncryst] = samples; + (towerMap[index])[stripnr - 1].first++; } - - if (debug_) std::cout << "fillMap"<<"[EcalTrigPrimFunctionalAlgo] (found " - << col->size() << " frames in "<< towerMap.size() << " towers) " << std::endl; - } - else { - if (debug_) std::cout <<"FillMap - FillMap Collection size=0 !!!!" << std::endl;; + + if (debug_) + std::cout << "fillMap" + << "[EcalTrigPrimFunctionalAlgo] (found " << col->size() << " frames in " << towerMap.size() + << " towers) " << std::endl; + } else { + if (debug_) + std::cout << "FillMap - FillMap Collection size=0 !!!!" << std::endl; + ; } } -template -void EcalEBTrigPrimTestAlgo::initStructures( std::vector > > > & towMap) { +template +void EcalEBTrigPrimTestAlgo::initStructures(std::vector > > > &towMap) { //initialise internal data structures - std::vector vec0(nbMaxXtals_ ); - std::vector > > vec1(nbMaxStrips_); - for (int i=0;i >(0,vec0); - towMap.resize(maxNrTowers_); - for (unsigned int i=0;i vec0(nbMaxXtals_); + std::vector > > vec1(nbMaxStrips_); + for (int i = 0; i < nbMaxStrips_; ++i) + vec1[i] = std::pair >(0, vec0); + towMap.resize(maxNrTowers_); + for (unsigned int i = 0; i < maxNrTowers_; ++i) + towMap[i] = vec1; + std::vector vecint(maxNrSamples_); striptp_.resize(nbMaxStrips_); - for (int i=0;i #include - //---------------------------------------------------------------------- -const unsigned int EcalEBTrigPrimTestAlgo::nrSamples_=5; -const unsigned int EcalEBTrigPrimTestAlgo::maxNrTowers_=2448; -const unsigned int EcalEBTrigPrimTestAlgo::maxNrSamplesOut_=10; +const unsigned int EcalEBTrigPrimTestAlgo::nrSamples_ = 5; +const unsigned int EcalEBTrigPrimTestAlgo::maxNrTowers_ = 2448; +const unsigned int EcalEBTrigPrimTestAlgo::maxNrSamplesOut_ = 10; - -EcalEBTrigPrimTestAlgo::EcalEBTrigPrimTestAlgo(const edm::EventSetup & setup,int nSam, int binofmax,bool tcpFormat, bool barrelOnly,bool debug, bool famos): - nSamples_(nSam),binOfMaximum_(binofmax), tcpFormat_(tcpFormat), barrelOnly_(barrelOnly), debug_(debug), famos_(famos) +EcalEBTrigPrimTestAlgo::EcalEBTrigPrimTestAlgo( + const edm::EventSetup &setup, int nSam, int binofmax, bool tcpFormat, bool barrelOnly, bool debug, bool famos) + : nSamples_(nSam), + binOfMaximum_(binofmax), + tcpFormat_(tcpFormat), + barrelOnly_(barrelOnly), + debug_(debug), + famos_(famos) { - - maxNrSamples_=10; - this->init(setup); + maxNrSamples_ = 10; + this->init(setup); } //---------------------------------------------------------------------- -void EcalEBTrigPrimTestAlgo::init(const edm::EventSetup & setup) { +void EcalEBTrigPrimTestAlgo::init(const edm::EventSetup &setup) { if (!barrelOnly_) { //edm::ESHandle theGeometry; // edm::ESHandle theEndcapGeometry_handle; - setup.get().get( theGeometry ); + setup.get().get(theGeometry); setup.get().get(eTTmap_); } @@ -65,49 +66,46 @@ void EcalEBTrigPrimTestAlgo::init(const edm::EventSetup & setup) { initStructures(towerMapEB_); hitTowers_.resize(maxNrTowers_); - linearizer_.resize(nbMaxXtals_); - for (int i=0;i v; + std::vector v; v.resize(maxNrSamples_); - lin_out_.resize(nbMaxXtals_); - for (int i=0;i<5;i++) lin_out_[i]=v; + lin_out_.resize(nbMaxXtals_); + for (int i = 0; i < 5; i++) + lin_out_[i] = v; // amplitude_filter_ = new EcalFenixAmplitudeFilter(); filt_out_.resize(maxNrSamples_); peak_out_.resize(maxNrSamples_); // these two are dummy fgvb_out_.resize(maxNrSamples_); - fgvb_out_temp_.resize(maxNrSamples_); + fgvb_out_temp_.resize(maxNrSamples_); // - peak_finder_ = new EcalFenixPeakFinder(); + peak_finder_ = new EcalFenixPeakFinder(); fenixFormatterEB_ = new EcalFenixStripFormatEB(); format_out_.resize(maxNrSamples_); // fenixTcpFormat_ = new EcalFenixTcpFormat(tcpFormat_, debug_, famos_, binOfMaximum_); - tcpformat_out_.resize(maxNrSamples_); - + tcpformat_out_.resize(maxNrSamples_); } //---------------------------------------------------------------------- -EcalEBTrigPrimTestAlgo::~EcalEBTrigPrimTestAlgo() -{ - for (int i=0;i &dataFrames = (towerMapEB_[index])[iStrip].second;//vector of dataframes for this strip, size; nr of crystals/strip - - nxstals = (towerMapEB_[index])[iStrip].first; - if (nxstals <= 0) continue; - if (debug_) std::cout << " Number of xTals " << nxstals << std::endl; - - const EcalTriggerElectronicsId elId = theMapping_->getTriggerElectronicsId(dataFrames[0].id()); - uint32_t stripid=elId.rawId() & 0xfffffff8; - - - // loop over the xstals in a strip - for (int iXstal=0;iXstalgetLinearizer(iXstal)->setParameters( dataFrames[iXstal].id().rawId(),ecaltpPed_,ecaltpLin_,ecaltpgBadX_) ; - this->getLinearizer(iXstal)->process( dataFrames[iXstal],lin_out_[iXstal]); - - for (unsigned int i =0; i0X3FFFF) (lin_out_[iXstal])[i]=0X3FFFF; - } - - - if ( debug_ ) { - std::cout<< "output of linearizer for channel " << iXstal << std::endl; - std::cout<<" lin_out[iXstal].size()= "<getFilter()->setParameters(stripid,ecaltpgWeightMap_,ecaltpgWeightGroup_); - this->getFilter()->process(lin_out_[iXstal],filt_out_,fgvb_out_temp_,fgvb_out_); - - if(debug_){ - std::cout<< "output of filter is a vector of size: "<getPeakFinder()->process(filt_out_,peak_out_); - - if(debug_){ - std::cout<< "output of peakfinder is a vector of size: "<getFormatterEB()->setParameters(stripid,ecaltpgSlidW_) ; - this->getFormatterEB()->process(fgvb_out_,peak_out_,filt_out_,format_out_); - - if (debug_) { - std::cout<< "output of formatter is a vector of size: "<getFormatter()->setParameters( thisTower.rawId(),ecaltpgLutGroup_,ecaltpgLut_,ecaltpgBadTT_,ecaltpgSpike_); - this->getFormatter()->process(format_out_,tcpformat_out_); - // loop over the time samples and fill the TP - int nSam=0; - for (int iSample=firstSample;iSample<=lastSample;++iSample) { - etInADC= tcpformat_out_[iSample]; - if (debug_) std::cout << " format_out " << tcpformat_out_[iSample] << " etInADC " << etInADC << std::endl; - - bool isASpike=false; // no spikes for now - int timing=0; // set to 0 value for now - tp.setSample(nSam, EcalEBTriggerPrimitiveSample(etInADC,isASpike,timing) ); - - nSam++; - if (debug_) std::cout << "in TestAlgo" <<" tp size "< &dataFrames = + (towerMapEB_[index])[iStrip].second; //vector of dataframes for this strip, size; nr of crystals/strip + + nxstals = (towerMapEB_[index])[iStrip].first; + if (nxstals <= 0) + continue; + if (debug_) + std::cout << " Number of xTals " << nxstals << std::endl; + + const EcalTriggerElectronicsId elId = theMapping_->getTriggerElectronicsId(dataFrames[0].id()); + uint32_t stripid = elId.rawId() & 0xfffffff8; + + // loop over the xstals in a strip + for (int iXstal = 0; iXstal < nxstals; iXstal++) { + const EBDetId &myid = dataFrames[iXstal].id(); + tp = EcalEBTriggerPrimitiveDigi(myid); + tp.setSize(nrSamples_); + + if (debug_) { + std::cout << std::endl; + std::cout << "iXstal= " << iXstal << " id " << dataFrames[iXstal].id() << " EBDataFrame is: " << std::endl; + for (int i = 0; i < dataFrames[iXstal].size(); i++) { + std::cout << " " << std::dec << dataFrames[iXstal][i].adc(); + } + std::cout << std::endl; + } + // Call the linearizer + this->getLinearizer(iXstal)->setParameters( + dataFrames[iXstal].id().rawId(), ecaltpPed_, ecaltpLin_, ecaltpgBadX_); + this->getLinearizer(iXstal)->process(dataFrames[iXstal], lin_out_[iXstal]); + + for (unsigned int i = 0; i < lin_out_[iXstal].size(); i++) { + if ((lin_out_[iXstal])[i] > 0X3FFFF) + (lin_out_[iXstal])[i] = 0X3FFFF; + } + + if (debug_) { + std::cout << "output of linearizer for channel " << iXstal << std::endl; + std::cout << " lin_out[iXstal].size()= " << std::dec << lin_out_[iXstal].size() << std::endl; + for (unsigned int i = 0; i < lin_out_[iXstal].size(); i++) { + std::cout << " " << std::dec << (lin_out_[iXstal])[i]; + } + std::cout << std::endl; + } + + // Call the amplitude filter + this->getFilter()->setParameters(stripid, ecaltpgWeightMap_, ecaltpgWeightGroup_); + this->getFilter()->process(lin_out_[iXstal], filt_out_, fgvb_out_temp_, fgvb_out_); + + if (debug_) { + std::cout << "output of filter is a vector of size: " << std::dec << filt_out_.size() << std::endl; + for (unsigned int ix = 0; ix < filt_out_.size(); ix++) { + std::cout << std::dec << filt_out_[ix] << " "; + } + std::cout << std::endl; + } + + // call peakfinder + this->getPeakFinder()->process(filt_out_, peak_out_); + + if (debug_) { + std::cout << "output of peakfinder is a vector of size: " << std::dec << peak_out_.size() << std::endl; + for (unsigned int ix = 0; ix < peak_out_.size(); ix++) { + std::cout << std::dec << peak_out_[ix] << " "; + } + std::cout << std::endl; + } + + // call formatter + this->getFormatterEB()->setParameters(stripid, ecaltpgSlidW_); + this->getFormatterEB()->process(fgvb_out_, peak_out_, filt_out_, format_out_); + + if (debug_) { + std::cout << "output of formatter is a vector of size: " << format_out_.size() << std::endl; + for (unsigned int i = 0; i < format_out_.size(); i++) { + std::cout << " " << std::dec << format_out_[i] << " "; + } + std::cout << std::endl; + } + + // call final tcp formatter + this->getFormatter()->setParameters( + thisTower.rawId(), ecaltpgLutGroup_, ecaltpgLut_, ecaltpgBadTT_, ecaltpgSpike_); + this->getFormatter()->process(format_out_, tcpformat_out_); + // loop over the time samples and fill the TP + int nSam = 0; + for (int iSample = firstSample; iSample <= lastSample; ++iSample) { + etInADC = tcpformat_out_[iSample]; + if (debug_) + std::cout << " format_out " << tcpformat_out_[iSample] << " etInADC " << etInADC << std::endl; + + bool isASpike = false; // no spikes for now + int timing = 0; // set to 0 value for now + tp.setSample(nSam, EcalEBTriggerPrimitiveSample(etInADC, isASpike, timing)); + + nSam++; + if (debug_) + std::cout << "in TestAlgo" + << " tp size " << tp.size() << std::endl; + } + + if (!tcpFormat_) + result.push_back(tp); + else + resultTcp.push_back(tp); + + } // Loop over the xStals + + } //loop over strips in one tower } - - - /* for (unsigned int i=0;isize();i++) { EBDataFrame myFrame((*digi)[i]); @@ -310,21 +298,16 @@ void EcalEBTrigPrimTestAlgo::run(const edm::EventSetup & setup, } */ - } - - - - - //---------------------------------------------------------------------- -int EcalEBTrigPrimTestAlgo::findStripNr(const EBDetId &id){ +int EcalEBTrigPrimTestAlgo::findStripNr(const EBDetId &id) { int stripnr; - int n=((id.ic()-1)%100)/20; //20 corresponds to 4 * ecal_barrel_crystals_per_strip FIXME!! - if (id.ieta()<0) stripnr = n+1; - else stripnr =nbMaxStrips_ - n; + int n = ((id.ic() - 1) % 100) / 20; //20 corresponds to 4 * ecal_barrel_crystals_per_strip FIXME!! + if (id.ieta() < 0) + stripnr = n + 1; + else + stripnr = nbMaxStrips_ - n; return stripnr; } - diff --git a/SimCalorimetry/EcalEBTrigPrimAlgos/src/EcalFenixLinearizer.cc b/SimCalorimetry/EcalEBTrigPrimAlgos/src/EcalFenixLinearizer.cc index 9448658d5bea6..2f232249fa773 100644 --- a/SimCalorimetry/EcalEBTrigPrimAlgos/src/EcalFenixLinearizer.cc +++ b/SimCalorimetry/EcalEBTrigPrimAlgos/src/EcalFenixLinearizer.cc @@ -7,142 +7,121 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" EcalFenixLinearizer::EcalFenixLinearizer(bool famos) - : famos_(famos), init_(false), - linConsts_(nullptr), - peds_(nullptr), - badXStatus_(nullptr) -{ -} + : famos_(famos), init_(false), linConsts_(nullptr), peds_(nullptr), badXStatus_(nullptr) {} -EcalFenixLinearizer::~EcalFenixLinearizer(){ +EcalFenixLinearizer::~EcalFenixLinearizer() { if (init_) { - for (int i=0;i<(int)vectorbadXStatus_.size();i++){ + for (int i = 0; i < (int)vectorbadXStatus_.size(); i++) { delete vectorbadXStatus_[i]; } - } + } } -void EcalFenixLinearizer::setParameters(uint32_t raw, const EcalTPGPedestals * ecaltpPed, const EcalTPGLinearizationConst * ecaltpLin, const EcalTPGCrystalStatus * ecaltpBadX) -{ - - - const EcalTPGLinearizationConstMap & linMap = ecaltpLin->getMap() ; - EcalTPGLinearizationConstMapIterator it=linMap.find(raw); - - if (it!=linMap.end()) { - linConsts_=&(*it); - } - else std::cout <<" could not find EcalTPGLinearizationConstMap entry for "<find(raw); - if (itped!=ecaltpPed->end()) peds_=&(*itped); - else std::cout <<" could not find EcalTPGPedestalsMap entry for "<getMap(); - EcalTPGCrystalStatusMapIterator itbadX=badXMap.find(raw); - - if (itbadX!=badXMap.end()) { - badXStatus_=&(*itbadX); - } - else - { - edm::LogWarning("EcalTPG")<<" could not find EcalTPGCrystalStatusMap entry for "<getMap(); + EcalTPGLinearizationConstMapIterator it = linMap.find(raw); + + if (it != linMap.end()) { + linConsts_ = &(*it); + } else + std::cout << " could not find EcalTPGLinearizationConstMap entry for " << raw << std::endl; + + EcalTPGPedestalsMapIterator itped = ecaltpPed->find(raw); + if (itped != ecaltpPed->end()) + peds_ = &(*itped); + else + std::cout << " could not find EcalTPGPedestalsMap entry for " << raw << std::endl; + + const EcalTPGCrystalStatusMap &badXMap = ecaltpBadX->getMap(); + EcalTPGCrystalStatusMapIterator itbadX = badXMap.find(raw); + + if (itbadX != badXMap.end()) { + badXStatus_ = &(*itbadX); + } else { + edm::LogWarning("EcalTPG") << " could not find EcalTPGCrystalStatusMap entry for " << raw; badXStatus_ = new EcalTPGCrystalStatusCode(); vectorbadXStatus_.push_back(&(*badXStatus_)); - init_ = true; + init_ = true; } - - - } -int EcalFenixLinearizer::process() -{ - - - int output=(uncorrectedSample_-base_); //Substract base - //std::cout << " EcalFenixLinearizer::process() output non bit shifted " << output << std::endl; - if(famos_ || output<0) return 0; - - if(output<0) return shift_ << 12; // FENIX bug(!) - output=(output*mult_)>>(shift_+2); //Apply multiplicative factor - //std::cout << " EcalFenixLinearizer::process() output 2nd step " << output << std::endl; - if(output>0X3FFFF)output=0X3FFFF; //Saturation if too high - //std::cout << " EcalFenixLinearizer::process() output 3rd step " << output << std::endl; +int EcalFenixLinearizer::process() { + int output = (uncorrectedSample_ - base_); //Substract base + //std::cout << " EcalFenixLinearizer::process() output non bit shifted " << output << std::endl; + if (famos_ || output < 0) + return 0; + + if (output < 0) + return shift_ << 12; // FENIX bug(!) + output = (output * mult_) >> (shift_ + 2); //Apply multiplicative factor + //std::cout << " EcalFenixLinearizer::process() output 2nd step " << output << std::endl; + if (output > 0X3FFFF) + output = 0X3FFFF; //Saturation if too high + //std::cout << " EcalFenixLinearizer::process() output 3rd step " << output << std::endl; return output; } - -int EcalFenixLinearizer::setInput(const EcalMGPASample &RawSam) -{ +int EcalFenixLinearizer::setInput(const EcalMGPASample &RawSam) { //std::cout << " EcalFenixLinearizer::setInput RawSam.raw() " << RawSam.raw() << std::endl; - if(RawSam.raw()>0X3FFF) - { - LogDebug("EcalTPG")<<"ERROR IN INPUT SAMPLE OF FENIX LINEARIZER"; - return -1; - } - - uncorrectedSample_=RawSam.adc(); //uncorrectedSample_ is coded in the 12 LSB - gainID_=RawSam.gainId(); //uncorrectedSample_ is coded in the 2 next bits! + if (RawSam.raw() > 0X3FFF) { + LogDebug("EcalTPG") << "ERROR IN INPUT SAMPLE OF FENIX LINEARIZER"; + return -1; + } + uncorrectedSample_ = RawSam.adc(); //uncorrectedSample_ is coded in the 12 LSB + gainID_ = RawSam.gainId(); //uncorrectedSample_ is coded in the 2 next bits! - if(gainID_ == 0) - { + if (gainID_ == 0) { base_ = 0; shift_ = 0; mult_ = 0xFF; - if((linConsts_->mult_x12 == 0) && (linConsts_->mult_x6 == 0) && (linConsts_->mult_x1 == 0)) - { - - mult_ = 0; // Implemented in CCSSupervisor to - // reject overflow cases in rejected channels + if ((linConsts_->mult_x12 == 0) && (linConsts_->mult_x6 == 0) && (linConsts_->mult_x1 == 0)) { + mult_ = 0; // Implemented in CCSSupervisor to + // reject overflow cases in rejected channels } - } - else if (gainID_==1) { - base_ = peds_ -> mean_x12; - shift_ = linConsts_ -> shift_x12; - + } else if (gainID_ == 1) { + base_ = peds_->mean_x12; + shift_ = linConsts_->shift_x12; + // take into account the badX // badXStatus_ == 0 if the crystal works // badXStatus_ !=0 some problem with the crystal - if (badXStatus_->getStatusCode()!=0){ + if (badXStatus_->getStatusCode() != 0) { mult_ = 0; + } else { + mult_ = linConsts_->mult_x12; } - else{ - mult_ = linConsts_ -> mult_x12; - } - } - else if (gainID_==2) { - base_ = peds_ -> mean_x6; - shift_ = linConsts_ -> shift_x6; - + } else if (gainID_ == 2) { + base_ = peds_->mean_x6; + shift_ = linConsts_->shift_x6; + // take into account the badX - // check if the badX has a status code=0 or 1 - if (badXStatus_->getStatusCode()!=0){ + // check if the badX has a status code=0 or 1 + if (badXStatus_->getStatusCode() != 0) { mult_ = 0; + } else { + mult_ = linConsts_->mult_x6; } - else{ - mult_ = linConsts_ -> mult_x6; - } - } - else if (gainID_==3){ - base_ = peds_-> mean_x1; - shift_ = linConsts_ -> shift_x1; - - // take into account the badX + } else if (gainID_ == 3) { + base_ = peds_->mean_x1; + shift_ = linConsts_->shift_x1; + + // take into account the badX // check if the badX has a status code=0 or 1 - if (badXStatus_->getStatusCode()!=0){ + if (badXStatus_->getStatusCode() != 0) { mult_ = 0; + } else { + mult_ = linConsts_->mult_x1; } - else{ - mult_ = linConsts_ -> mult_x1; - } } - + //std::cout << " EcalFenixLinearizer::setInput uncorrectedSample_ " << RawSam.adc() << " gainID " << gainID_ << " baseline " << base_ << std::endl; - - if (famos_) base_=200; //FIXME by preparing a correct TPG.txt for Famos + + if (famos_) + base_ = 200; //FIXME by preparing a correct TPG.txt for Famos return 1; } - diff --git a/SimCalorimetry/EcalEBTrigPrimAlgos/src/EcalFenixTcpFormat.cc b/SimCalorimetry/EcalEBTrigPrimAlgos/src/EcalFenixTcpFormat.cc index e8b5063156d26..f5fd039bd365d 100644 --- a/SimCalorimetry/EcalEBTrigPrimAlgos/src/EcalFenixTcpFormat.cc +++ b/SimCalorimetry/EcalEBTrigPrimAlgos/src/EcalFenixTcpFormat.cc @@ -6,166 +6,161 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include -using namespace std; +using namespace std; -EcalFenixTcpFormat::EcalFenixTcpFormat(bool tcpFormat, bool debug, bool famos,int binOfMax) - : tcpFormat_(tcpFormat),debug_(debug),famos_(famos),binOfMax_(binOfMax) -{ - status_=0; - badTTStatus_=&status_; +EcalFenixTcpFormat::EcalFenixTcpFormat(bool tcpFormat, bool debug, bool famos, int binOfMax) + : tcpFormat_(tcpFormat), debug_(debug), famos_(famos), binOfMax_(binOfMax) { + status_ = 0; + badTTStatus_ = &status_; } - -EcalFenixTcpFormat::~EcalFenixTcpFormat() { -} - +EcalFenixTcpFormat::~EcalFenixTcpFormat() {} -void EcalFenixTcpFormat::process(std::vector &Etin, std::vector &Etout){ +void EcalFenixTcpFormat::process(std::vector &Etin, std::vector &Etout) { // put TP-s in the output - // on request also in TcpFormat + // on request also in TcpFormat // for famos version we have to write dummies except for the middle // std::cout << " EcalFenixTcpFormat::process(... Etout size " << Etout.size() << " Et size " << Etin.size() << std::endl; int myEt; - int eTTotShift=2; + int eTTotShift = 2; // std::cout << " FenixTcpFormatter Etin size() " << Etin.size() << std::endl; - for (unsigned int i=0; i0xfff) - myEt=0xfff ; + if (myEt > 0xfff) + myEt = 0xfff; - myEt >>= eTTotShift ; - //std::cout << " after myEt>>= eTTotShift " << myEt << std::endl; - if (myEt>0x3ff) myEt=0x3ff ; - + myEt >>= eTTotShift; + //std::cout << " after myEt>>= eTTotShift " << myEt << std::endl; + if (myEt > 0x3ff) + myEt = 0x3ff; - //myEt = lut_out & 0xff ; + //myEt = lut_out & 0xff ; // the lut is foreseen for 8 bits. Useless to use it here // stay with 10 bits - Etout[i]=myEt; + Etout[i] = myEt; } - } - - - -void EcalFenixTcpFormat::process(std::vector &Et, std::vector &fgvb, - std::vector &sfgvb,int eTTotShift, - std::vector & out, - std::vector & out2, bool isInInnerRings){ +void EcalFenixTcpFormat::process(std::vector &Et, + std::vector &fgvb, + std::vector &sfgvb, + int eTTotShift, + std::vector &out, + std::vector &out2, + bool isInInnerRings) { // put TP-s in the output - // on request also in TcpFormat + // on request also in TcpFormat // for famos version we have to write dummies except for the middle - //std::cout << " EcalFenixTcpFormat::process(... out size " << out.size() << " Et size " << Et.size() << " Et[0] " << Et[0] << std::endl; + //std::cout << " EcalFenixTcpFormat::process(... out size " << out.size() << " Et size " << Et.size() << " Et[0] " << Et[0] << std::endl; int myEt; if (famos_) { - for (unsigned int i=0; i>eTTotShift; - if (myEt>0x3ff) myEt=0x3ff ; - if (isInInnerRings) myEt = myEt /2 ; - - // badTTStatus_ ==0 if the TT works - // badTTStatus_ !=0 if there are some problems - int lut_out; - if (*badTTStatus_!=0){ - lut_out = 0; - } - else - lut_out = (lut_)[myEt] ; - - // int ttFlag = (lut_out & 0x700) >> 8 ; - myEt = lut_out & 0xff ; - // out[i]=EcalEBTriggerPrimitiveSample( myEt,fgvb[0],sfgvb[0],ttFlag); - out[i]=EcalEBTriggerPrimitiveSample( myEt ); - } - else out[i]=EcalEBTriggerPrimitiveSample( ); + for (unsigned int i = 0; i < out.size(); ++i) { + if (i == binOfMax_ - 1) { + myEt = Et[0] >> eTTotShift; + if (myEt > 0x3ff) + myEt = 0x3ff; + if (isInInnerRings) + myEt = myEt / 2; + + // badTTStatus_ ==0 if the TT works + // badTTStatus_ !=0 if there are some problems + int lut_out; + if (*badTTStatus_ != 0) { + lut_out = 0; + } else + lut_out = (lut_)[myEt]; + + // int ttFlag = (lut_out & 0x700) >> 8 ; + myEt = lut_out & 0xff; + // out[i]=EcalEBTriggerPrimitiveSample( myEt,fgvb[0],sfgvb[0],ttFlag); + out[i] = EcalEBTriggerPrimitiveSample(myEt); + } else + out[i] = EcalEBTriggerPrimitiveSample(); } - } - else { + } else { //std::cout << " FenixTcpFormatter et.size() " << Et.size() << std::endl; - for (unsigned int i=0; i>eTTotShift; //if (myEt>0x3ff) myEt=0x3ff ; - //if (isInInnerRings) myEt = myEt /2 ; + //if (isInInnerRings) myEt = myEt /2 ; // bug fix 091009: - myEt=Et[i]; + myEt = Et[i]; //std::cout << " Et " << myEt << std::endl; - if (myEt>0xfff) - myEt=0xfff ; - if (isInInnerRings) - myEt = myEt /2 ; - myEt >>= eTTotShift ; - //std::cout << " after myEt>>= eTTotShift " << myEt << std::endl; - if (myEt>0x3ff) myEt=0x3ff ; + if (myEt > 0xfff) + myEt = 0xfff; + if (isInInnerRings) + myEt = myEt / 2; + myEt >>= eTTotShift; + //std::cout << " after myEt>>= eTTotShift " << myEt << std::endl; + if (myEt > 0x3ff) + myEt = 0x3ff; // Spike killing - if((myEt > spikeZeroThresh_) && (mysFgvb == 0)) - { + if ((myEt > spikeZeroThresh_) && (mysFgvb == 0)) { myEt = 0; } int lut_out; - if (*badTTStatus_!=0){ - lut_out = 0; - } - else - lut_out = (lut_)[myEt] ; - + if (*badTTStatus_ != 0) { + lut_out = 0; + } else + lut_out = (lut_)[myEt]; + //int ttFlag = (lut_out & 0x700) >> 8 ; - if (tcpFormat_) { - out2[i]=EcalEBTriggerPrimitiveSample( myEt & 0x3ff); - //std::cout << " FenixTcpFormatter final et " << (myEt & 0x3ff) << std::endl; + if (tcpFormat_) { + out2[i] = EcalEBTriggerPrimitiveSample(myEt & 0x3ff); + //std::cout << " FenixTcpFormatter final et " << (myEt & 0x3ff) << std::endl; } - myEt = lut_out & 0xff ; + myEt = lut_out & 0xff; //std::cout << " FenixTcpFormatter final lut_out " << lut_out << " 0xff " << 0xff << " et " << myEt << std::endl; - out[i]=EcalEBTriggerPrimitiveSample( myEt ); + out[i] = EcalEBTriggerPrimitiveSample(myEt); } } } -void EcalFenixTcpFormat::setParameters(uint32_t towid,const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGTowerStatus *ecaltpgbadTT,const EcalTPGSpike * ecaltpgSpike) -{ +void EcalFenixTcpFormat::setParameters(uint32_t towid, + const EcalTPGLutGroup *ecaltpgLutGroup, + const EcalTPGLutIdMap *ecaltpgLut, + const EcalTPGTowerStatus *ecaltpgbadTT, + const EcalTPGSpike *ecaltpgSpike) { // Get TP zeroing threshold - defaut to 1023 for old data (no record found or EE) spikeZeroThresh_ = 1023; - if(ecaltpgSpike != nullptr) - { + if (ecaltpgSpike != nullptr) { const EcalTPGSpike::EcalTPGSpikeMap &spikeMap = ecaltpgSpike->getMap(); - EcalTPGSpike:: EcalTPGSpikeMapIterator sit = spikeMap.find(towid); - if(sit != spikeMap.end()) - { + EcalTPGSpike::EcalTPGSpikeMapIterator sit = spikeMap.find(towid); + if (sit != spikeMap.end()) { spikeZeroThresh_ = sit->second; } } - const EcalTPGGroups::EcalTPGGroupsMap & groupmap = ecaltpgLutGroup -> getMap(); - EcalTPGGroups::EcalTPGGroupsMapItr it=groupmap.find(towid); - if (it!=groupmap.end()) { - uint32_t lutid=(*it).second; - const EcalTPGLutIdMap::EcalTPGLutMap &lutmap = ecaltpgLut-> getMap(); - EcalTPGLutIdMap::EcalTPGLutMapItr itl=lutmap.find(lutid); - if (itl!=lutmap.end()) { - lut_=(*itl).second.getLut(); + const EcalTPGGroups::EcalTPGGroupsMap &groupmap = ecaltpgLutGroup->getMap(); + EcalTPGGroups::EcalTPGGroupsMapItr it = groupmap.find(towid); + if (it != groupmap.end()) { + uint32_t lutid = (*it).second; + const EcalTPGLutIdMap::EcalTPGLutMap &lutmap = ecaltpgLut->getMap(); + EcalTPGLutIdMap::EcalTPGLutMapItr itl = lutmap.find(lutid); + if (itl != lutmap.end()) { + lut_ = (*itl).second.getLut(); //std::cout << " FenixTcpFormatter lut_ " << std::dec< getMap(); + } else + edm::LogWarning("EcalTPG") << " could not find EcalTPGFineGrainTowerEEMap for " << towid; + + const EcalTPGTowerStatusMap &badTTMap = ecaltpgbadTT->getMap(); EcalTPGTowerStatusMapIterator itbadTT = badTTMap.find(towid); - if (itbadTT!=badTTMap.end()) { - badTTStatus_=&(*itbadTT).second; + if (itbadTT != badTTMap.end()) { + badTTStatus_ = &(*itbadTT).second; } } - diff --git a/SimCalorimetry/EcalEBTrigPrimProducers/plugins/EcalEBTrigPrimAnalyzer.cc b/SimCalorimetry/EcalEBTrigPrimProducers/plugins/EcalEBTrigPrimAnalyzer.cc index db2cbba7ed9a3..f14ce8dbb51b8 100644 --- a/SimCalorimetry/EcalEBTrigPrimProducers/plugins/EcalEBTrigPrimAnalyzer.cc +++ b/SimCalorimetry/EcalEBTrigPrimProducers/plugins/EcalEBTrigPrimAnalyzer.cc @@ -32,96 +32,90 @@ using namespace edm; class CaloSubdetectorGeometry; -EcalEBTrigPrimAnalyzer::EcalEBTrigPrimAnalyzer(const edm::ParameterSet& iConfig) +EcalEBTrigPrimAnalyzer::EcalEBTrigPrimAnalyzer(const edm::ParameterSet& iConfig) { ecal_parts_.push_back("Barrel"); - - histfile_=new TFile("histos.root","RECREATE"); - tree_ = new TTree("TPGtree","TPGtree"); - tree_->Branch("tpIphi",&tpIphi_,"tpIphi/I"); - tree_->Branch("tpIeta",&tpIeta_,"tpIeta/I"); - tree_->Branch("rhIphi",&rhIphi_,"rhIphi/I"); - tree_->Branch("rhIeta",&rhIeta_,"rhIeta/I"); - tree_->Branch("eRec",&eRec_,"eRec/F"); - tree_->Branch("tpgADC",&tpgADC_,"tpgADC/I"); - tree_->Branch("tpgGeV",&tpgGeV_,"tpgGeV/F"); - tree_->Branch("ttf",&ttf_,"ttf/I"); - tree_->Branch("fg",&fg_,"fg/I"); - for (unsigned int i=0;iBranch("tpIphi", &tpIphi_, "tpIphi/I"); + tree_->Branch("tpIeta", &tpIeta_, "tpIeta/I"); + tree_->Branch("rhIphi", &rhIphi_, "rhIphi/I"); + tree_->Branch("rhIeta", &rhIeta_, "rhIeta/I"); + tree_->Branch("eRec", &eRec_, "eRec/F"); + tree_->Branch("tpgADC", &tpgADC_, "tpgADC/I"); + tree_->Branch("tpgGeV", &tpgGeV_, "tpgGeV/F"); + tree_->Branch("ttf", &ttf_, "ttf/I"); + tree_->Branch("fg", &fg_, "fg/I"); + for (unsigned int i = 0; i < ecal_parts_.size(); ++i) { char title[30]; - sprintf(title,"%s_Et",ecal_parts_[i].c_str()); - ecal_et_[i]=new TH1I(title,"Et",255,0,255); - sprintf(title,"%s_ttf",ecal_parts_[i].c_str()); - ecal_tt_[i]=new TH1I(title,"TTF",10,0,10); - sprintf(title,"%s_fgvb",ecal_parts_[i].c_str()); - ecal_fgvb_[i]=new TH1I(title,"FGVB",10,0,10); + sprintf(title, "%s_Et", ecal_parts_[i].c_str()); + ecal_et_[i] = new TH1I(title, "Et", 255, 0, 255); + sprintf(title, "%s_ttf", ecal_parts_[i].c_str()); + ecal_tt_[i] = new TH1I(title, "TTF", 10, 0, 10); + sprintf(title, "%s_fgvb", ecal_parts_[i].c_str()); + ecal_fgvb_[i] = new TH1I(title, "FGVB", 10, 0, 10); } - recHits_= iConfig.getParameter("AnalyzeRecHits"); - debug_= iConfig.getParameter("Debug"); - rechits_labelEB_=consumes(iConfig.getParameter("inputRecHitsEB")); - primToken_=consumes(iConfig.getParameter("inputTP")); - tokenEBdigi_=consumes(iConfig.getParameter("barrelEcalDigis")); - nEvents_=0; + recHits_ = iConfig.getParameter("AnalyzeRecHits"); + debug_ = iConfig.getParameter("Debug"); + rechits_labelEB_ = consumes(iConfig.getParameter("inputRecHitsEB")); + primToken_ = consumes(iConfig.getParameter("inputTP")); + tokenEBdigi_ = consumes(iConfig.getParameter("barrelEcalDigis")); + nEvents_ = 0; - hTPvsTow_eta_= new TH2F("TP_vs_Tow_eta","TP vs Tow eta ; #eta(tow); #eta(tp)",50,-2.5,2.5,50,-2.5,2.5); - hAllTPperEvt_ = new TH1F("AllTPperEvt","TP per Event; N_{TP}; ", 100, 0., 20000.); - hTPperEvt_ = new TH1F("TPperEvt","N_{TP} per Event; N_{TP}; ", 100, 0., 500.); - hTP_iphiVsieta_= new TH2F("TP_iphiVsieta","TP i#phi vs i#eta ; i#eta(tp); i#phi(tp)",10,70,80,10,340,350); - hTP_iphiVsieta_fullrange_= new TH2F("TP_iphiVsieta_fullrange","TP i#phi vs i#eta ; i#eta(tp); i#phi(tp)",200,-100,100,350,0,350); + hTPvsTow_eta_ = new TH2F("TP_vs_Tow_eta", "TP vs Tow eta ; #eta(tow); #eta(tp)", 50, -2.5, 2.5, 50, -2.5, 2.5); + hAllTPperEvt_ = new TH1F("AllTPperEvt", "TP per Event; N_{TP}; ", 100, 0., 20000.); + hTPperEvt_ = new TH1F("TPperEvt", "N_{TP} per Event; N_{TP}; ", 100, 0., 500.); + hTP_iphiVsieta_ = new TH2F("TP_iphiVsieta", "TP i#phi vs i#eta ; i#eta(tp); i#phi(tp)", 10, 70, 80, 10, 340, 350); + hTP_iphiVsieta_fullrange_ = + new TH2F("TP_iphiVsieta_fullrange", "TP i#phi vs i#eta ; i#eta(tp); i#phi(tp)", 200, -100, 100, 350, 0, 350); if (recHits_) { - hTPvsTow_ieta_= new TH2F("TP_vs_Tow_ieta","TP vs Tow ieta ; i#eta(tow); i#eta(tp)",200,-100,100,200,-100,100); - - hTPvsRechit_= new TH2F("TP_vs_RecHit","TP vs rechit Et;E_{T}(rh) (GeV);E_{T}(tp) (GeV)",100,0,50,100,0,50); - hDeltaEt_ = new TH1F("DeltaEt","[Et(rh)-Et(TP)]/Et(rh); [E_{T}(rh)-E_{T}(tp)]/E_{T}(rh); Counts",200,-1,1); - hTPoverRechit_= new TH1F("TP_over_RecHit","Et(TP/rechit); E_{T}(tp)/E_{T}(rh); Counts",200,0,2); - hRechitEt_= new TH1F("RecHitEt","E_{T};E_{T}(rh) (GeV);Counts",100,0,50); - hTPEt_= new TH1F("TPEt","E_{T}{tp);E_{T}(rh) (GeV);Count",100,0,50); - hRatioEt_ = new TH1F("RatioTPoverRH","Et",100,0,50); - hAllRechitEt_= new TH1F("AllRecHit","Et",100,0,50); - - hRH_iphiVsieta_= new TH2F("RH_iphiVsieta","RH i#phi vs i#eta ; i#eta(rh); i#phi(rh)",10,70,80,10,340,350); - hRH_iphiVsieta_fullrange_= new TH2F("RH_iphiVsieta_fullrange","RH i#phi vs i#eta ; i#eta(rh); i#phi(rh)",200,-100,100,350,0,350); - - + hTPvsTow_ieta_ = + new TH2F("TP_vs_Tow_ieta", "TP vs Tow ieta ; i#eta(tow); i#eta(tp)", 200, -100, 100, 200, -100, 100); + + hTPvsRechit_ = new TH2F("TP_vs_RecHit", "TP vs rechit Et;E_{T}(rh) (GeV);E_{T}(tp) (GeV)", 100, 0, 50, 100, 0, 50); + hDeltaEt_ = new TH1F("DeltaEt", "[Et(rh)-Et(TP)]/Et(rh); [E_{T}(rh)-E_{T}(tp)]/E_{T}(rh); Counts", 200, -1, 1); + hTPoverRechit_ = new TH1F("TP_over_RecHit", "Et(TP/rechit); E_{T}(tp)/E_{T}(rh); Counts", 200, 0, 2); + hRechitEt_ = new TH1F("RecHitEt", "E_{T};E_{T}(rh) (GeV);Counts", 100, 0, 50); + hTPEt_ = new TH1F("TPEt", "E_{T}{tp);E_{T}(rh) (GeV);Count", 100, 0, 50); + hRatioEt_ = new TH1F("RatioTPoverRH", "Et", 100, 0, 50); + hAllRechitEt_ = new TH1F("AllRecHit", "Et", 100, 0, 50); + + hRH_iphiVsieta_ = new TH2F("RH_iphiVsieta", "RH i#phi vs i#eta ; i#eta(rh); i#phi(rh)", 10, 70, 80, 10, 340, 350); + hRH_iphiVsieta_fullrange_ = + new TH2F("RH_iphiVsieta_fullrange", "RH i#phi vs i#eta ; i#eta(rh); i#phi(rh)", 200, -100, 100, 350, 0, 350); } } - -EcalEBTrigPrimAnalyzer::~EcalEBTrigPrimAnalyzer() -{ - - // do anything here that needs to be done at desctruction time - // (e.g. close files, deallocate resources etc.) +EcalEBTrigPrimAnalyzer::~EcalEBTrigPrimAnalyzer() { + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) histfile_->Write(); histfile_->Close(); - } -void EcalEBTrigPrimAnalyzer::init(const edm::EventSetup & iSetup) { - iSetup.get().get(eTTmap_); -} +void EcalEBTrigPrimAnalyzer::init(const edm::EventSetup& iSetup) { iSetup.get().get(eTTmap_); } // // member functions // // ------------ method called to analyze the data ------------ -void -EcalEBTrigPrimAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup & iSetup) -{ +void EcalEBTrigPrimAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { using namespace edm; using namespace std; nEvents_++; - if ( nEvents_==1) this->init(iSetup); + if (nEvents_ == 1) + this->init(iSetup); // Get input edm::Handle tp; - iEvent.getByToken(primToken_,tp); + iEvent.getByToken(primToken_, tp); // /* edm::Handle barrelDigiHandle; @@ -130,67 +124,65 @@ EcalEBTrigPrimAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup ebdigi=barrelDigiHandle.product(); */ - - - for (unsigned int i=0;isize();i++) { - EcalEBTriggerPrimitiveDigi d=(*(tp.product()))[i]; - int subdet=0; - if (subdet==0) { + for (unsigned int i = 0; i < tp.product()->size(); i++) { + EcalEBTriggerPrimitiveDigi d = (*(tp.product()))[i]; + int subdet = 0; + if (subdet == 0) { ecal_et_[subdet]->Fill(d.encodedEt()); } } - // if (!recHits_) return; edm::Handle rechit_EB_col; - if ( recHits_ ) { + if (recHits_) { // get the RecHits - iEvent.getByToken(rechits_labelEB_,rechit_EB_col); + iEvent.getByToken(rechits_labelEB_, rechit_EB_col); } edm::ESHandle theBarrelGeometry_handle; - iSetup.get().get("EcalBarrel",theBarrelGeometry_handle); - const CaloSubdetectorGeometry *theBarrelGeometry = theBarrelGeometry_handle.product(); - - if (debug_) { std::cout << " TP analyzer =================> Treating event "<size() << std::endl; - if ( recHits_ ) std::cout << " Number of EB rechits "<< rechit_EB_col.product()->size() << std::endl; + iSetup.get().get("EcalBarrel", theBarrelGeometry_handle); + const CaloSubdetectorGeometry* theBarrelGeometry = theBarrelGeometry_handle.product(); + + if (debug_) { + std::cout << " TP analyzer =================> Treating event " << iEvent.id() << " Number of TPs " + << tp.product()->size() << std::endl; + if (recHits_) + std::cout << " Number of EB rechits " << rechit_EB_col.product()->size() << std::endl; } - hAllTPperEvt_->Fill(float(tp.product()->size())); - + hAllTPperEvt_->Fill(float(tp.product()->size())); + //if ( iEvent.id().event() != 648) return; //EcalEBTPGScale ecalScale ; - EcalTPGScale ecalScale ; - ecalScale.setEventSetup(iSetup) ; - - + EcalTPGScale ecalScale; + ecalScale.setEventSetup(iSetup); + // for(unsigned int iDigi = 0; iDigi < ebdigi->size() ; ++iDigi) { - // EBDataFrame myFrame((*ebdigi)[iDigi]); + // EBDataFrame myFrame((*ebdigi)[iDigi]); // const EBDetId & myId = myFrame.id(); - - int nTP=0; - for (unsigned int i=0;isize();i++) { - EcalEBTriggerPrimitiveDigi d=(*(tp.product()))[i]; - const EBDetId TPid= d.id(); + + int nTP = 0; + for (unsigned int i = 0; i < tp.product()->size(); i++) { + EcalEBTriggerPrimitiveDigi d = (*(tp.product()))[i]; + const EBDetId TPid = d.id(); // if ( myId != TPid ) continue; - - + /* int index=getIndex(ebdigi,coarser); std::cout << " Same xTal " << myId << " " << TPid << " coarser " << coarser << " index " << index << std::endl; double Et = ecalScale.getTPGInGeV(d.encodedEt(), coarser) ; */ //this works if the energy is compressed into 8 bits float Et=d.compressedEt()/2.; // 2ADC counts/GeV - float Et=d.encodedEt()/8.; // 8 ADCcounts/GeV - if ( Et<= 5 ) continue; + float Et = d.encodedEt() / 8.; // 8 ADCcounts/GeV + if (Et <= 5) + continue; //if ( Et<= 0 ) continue; nTP++; std::cout << " TP digi size " << d.size() << std::endl; - for (int iBx=0;iBxgetGeometry(TPid)->getPosition().eta(); // does not work hTPvsTow_eta_->Fill ( etaTow, etaTP ); // hTPvsTow_ieta_->Fill ( coarser.ieta(), TPid.ieta() ); - - - tpIphi_ = TPid.iphi() ; - tpIeta_ = TPid.ieta() ; + + tpIphi_ = TPid.iphi(); + tpIeta_ = TPid.ieta(); tpgADC_ = d.encodedEt(); - tpgGeV_ = Et ; - + tpgGeV_ = Et; + hTP_iphiVsieta_->Fill(TPid.ieta(), TPid.iphi(), Et); hTP_iphiVsieta_fullrange_->Fill(TPid.ieta(), TPid.iphi(), Et); - - - if ( recHits_ ) { - for (unsigned int j=0;jsize();j++) { - const EBDetId & myid1=(*rechit_EB_col.product())[j].id(); - float theta = theBarrelGeometry->getGeometry(myid1)->getPosition().theta(); - float rhEt=((*rechit_EB_col.product())[j].energy())*sin(theta); - if ( myid1 == TPid ) { - if (debug_) std::cout << " Analyzer same cristal " << myid1 << " " << TPid << std::endl; - // if ( rhEt < 1.5 && Et > 10 ) { - // std::cout << " TP analyzer =================> Treating event "<size() << " Number of TPs " << tp.product()->size() << std::endl; - //std::cout << " TP compressed et " << d.encodedEt() << " Et in GeV " << Et << " RH Et " << rhEt << " Et/rhEt " << Et/rhEt << std::endl; - //} - - //std::cout << " TP out " << d << std::endl; - - // for (int isam=0;isam< d.size();++isam) { - // std::cout << " d[isam].raw() " << d[isam].raw() << std::endl; - //} - - rhIphi_ = myid1.iphi() ; - rhIeta_ = myid1.ieta() ; - hRH_iphiVsieta_->Fill(myid1.ieta(), myid1.iphi(), rhEt); - hRH_iphiVsieta_fullrange_->Fill(myid1.ieta(), myid1.iphi(), rhEt); - - hTPvsRechit_->Fill(rhEt,Et); - hTPoverRechit_->Fill(Et/rhEt); - hDeltaEt_ ->Fill ((rhEt-Et)/rhEt); - if (debug_) std::cout << " TP compressed et " << d.encodedEt() << " Et in GeV " << Et << " RH Et " << rhEt << " Et/rhEt " << Et/rhEt << std::endl; - hRechitEt_->Fill(rhEt); - hTPEt_->Fill(Et); - if ( rhEt < 1000000) eRec_ = rhEt; - tree_->Fill() ; - } - + + if (recHits_) { + for (unsigned int j = 0; j < rechit_EB_col.product()->size(); j++) { + const EBDetId& myid1 = (*rechit_EB_col.product())[j].id(); + float theta = theBarrelGeometry->getGeometry(myid1)->getPosition().theta(); + float rhEt = ((*rechit_EB_col.product())[j].energy()) * sin(theta); + if (myid1 == TPid) { + if (debug_) + std::cout << " Analyzer same cristal " << myid1 << " " << TPid << std::endl; + // if ( rhEt < 1.5 && Et > 10 ) { + // std::cout << " TP analyzer =================> Treating event "<size() << " Number of TPs " << tp.product()->size() << std::endl; + //std::cout << " TP compressed et " << d.encodedEt() << " Et in GeV " << Et << " RH Et " << rhEt << " Et/rhEt " << Et/rhEt << std::endl; + //} + + //std::cout << " TP out " << d << std::endl; + + // for (int isam=0;isam< d.size();++isam) { + // std::cout << " d[isam].raw() " << d[isam].raw() << std::endl; + //} + + rhIphi_ = myid1.iphi(); + rhIeta_ = myid1.ieta(); + hRH_iphiVsieta_->Fill(myid1.ieta(), myid1.iphi(), rhEt); + hRH_iphiVsieta_fullrange_->Fill(myid1.ieta(), myid1.iphi(), rhEt); + + hTPvsRechit_->Fill(rhEt, Et); + hTPoverRechit_->Fill(Et / rhEt); + hDeltaEt_->Fill((rhEt - Et) / rhEt); + if (debug_) + std::cout << " TP compressed et " << d.encodedEt() << " Et in GeV " << Et << " RH Et " << rhEt + << " Et/rhEt " << Et / rhEt << std::endl; + hRechitEt_->Fill(rhEt); + hTPEt_->Fill(Et); + if (rhEt < 1000000) + eRec_ = rhEt; + tree_->Fill(); + } + } // end loop of recHits - } // if recHits - - } // end loop over TP collection - + } // if recHits + + } // end loop over TP collection + // } // end loop over digi collection - hTPperEvt_->Fill(float(nTP)); - - if ( recHits_) { - hRatioEt_->Divide( hTPEt_, hRechitEt_); - for (unsigned int j=0;jsize();j++) { - const EBDetId & myid1=(*rechit_EB_col.product())[j].id(); - float theta = theBarrelGeometry->getGeometry(myid1)->getPosition().theta(); - float rhEt=((*rechit_EB_col.product())[j].energy())*sin(theta); - if ( rhEt >0 ) - hAllRechitEt_ ->Fill(rhEt); + hTPperEvt_->Fill(float(nTP)); + + if (recHits_) { + hRatioEt_->Divide(hTPEt_, hRechitEt_); + for (unsigned int j = 0; j < rechit_EB_col.product()->size(); j++) { + const EBDetId& myid1 = (*rechit_EB_col.product())[j].id(); + float theta = theBarrelGeometry->getGeometry(myid1)->getPosition().theta(); + float rhEt = ((*rechit_EB_col.product())[j].energy()) * sin(theta); + if (rhEt > 0) + hAllRechitEt_->Fill(rhEt); } } - - } -void -EcalEBTrigPrimAnalyzer::endJob(){ - for (unsigned int i=0;iWrite(); ecal_tt_[i]->Write(); ecal_fgvb_[i]->Write(); } - hAllTPperEvt_->Write(); hTPperEvt_->Write(); if (recHits_) { hTPvsTow_ieta_->Write(); - hTPvsTow_eta_->Write(); + hTPvsTow_eta_->Write(); hTPvsRechit_->Write(); hTPoverRechit_->Write(); hAllRechitEt_->Write(); hRechitEt_->Write(); - hDeltaEt_ ->Write(); + hDeltaEt_->Write(); hTPEt_->Write(); hRatioEt_->Write(); hTP_iphiVsieta_->Write(); hRH_iphiVsieta_->Write(); hTP_iphiVsieta_fullrange_->Write(); hRH_iphiVsieta_fullrange_->Write(); - } } - diff --git a/SimCalorimetry/EcalEBTrigPrimProducers/plugins/EcalEBTrigPrimAnalyzer.h b/SimCalorimetry/EcalEBTrigPrimProducers/plugins/EcalEBTrigPrimAnalyzer.h index 4fa7184e57bb6..d2b458bb813e6 100644 --- a/SimCalorimetry/EcalEBTrigPrimProducers/plugins/EcalEBTrigPrimAnalyzer.h +++ b/SimCalorimetry/EcalEBTrigPrimProducers/plugins/EcalEBTrigPrimAnalyzer.h @@ -22,24 +22,23 @@ // class EcalEBTrigPrimAnalyzer : public edm::one::EDAnalyzer<> { - public: - explicit EcalEBTrigPrimAnalyzer(const edm::ParameterSet&); +public: + explicit EcalEBTrigPrimAnalyzer(const edm::ParameterSet &); ~EcalEBTrigPrimAnalyzer() override; - - void analyze(const edm::Event&, const edm::EventSetup&) override; + void analyze(const edm::Event &, const edm::EventSetup &) override; void endJob() override; - private: +private: int nEvents_; - void init(const edm::EventSetup&); + void init(const edm::EventSetup &); // for histos of nr of hits std::vector ecal_parts_; - TH1I * ecal_et_[2]; - TH1I * ecal_tt_[2]; - TH1I * ecal_fgvb_[2]; - TH1I *histEndc,*histBar; + TH1I *ecal_et_[2]; + TH1I *ecal_tt_[2]; + TH1I *ecal_fgvb_[2]; + TH1I *histEndc, *histBar; TFile *histfile_; TH1F *hAllTPperEvt_; TH1F *hTPperEvt_; @@ -57,11 +56,11 @@ class EcalEBTrigPrimAnalyzer : public edm::one::EDAnalyzer<> { TH2F *hTP_iphiVsieta_fullrange_; TH2F *hRH_iphiVsieta_fullrange_; - TTree *tree_ ; + TTree *tree_; - int tpIphi_, tpIeta_ , tpgADC_, ttf_, fg_ ; + int tpIphi_, tpIeta_, tpgADC_, ttf_, fg_; int rhIeta_, rhIphi_; - float eRec_, tpgGeV_ ; + float eRec_, tpgGeV_; //edm::InputTag label_; edm::EDGetTokenT primToken_; @@ -71,6 +70,5 @@ class EcalEBTrigPrimAnalyzer : public edm::one::EDAnalyzer<> { bool debug_; edm::ESHandle eTTmap_; - int getIndex(const EBDigiCollection *, EcalTrigTowerDetId& id) {return id.hashedIndex();} - + int getIndex(const EBDigiCollection *, EcalTrigTowerDetId &id) { return id.hashedIndex(); } }; diff --git a/SimCalorimetry/EcalEBTrigPrimProducers/plugins/EcalEBTrigPrimProducer.cc b/SimCalorimetry/EcalEBTrigPrimProducers/plugins/EcalEBTrigPrimProducer.cc index 912671ce2defd..717356b29220c 100644 --- a/SimCalorimetry/EcalEBTrigPrimProducers/plugins/EcalEBTrigPrimProducer.cc +++ b/SimCalorimetry/EcalEBTrigPrimProducers/plugins/EcalEBTrigPrimProducer.cc @@ -39,7 +39,6 @@ #include "CondFormats/DataRecord/interface/EcalTPGSpikeRcd.h" #include "CondFormats/EcalObjects/interface/EcalTPGSpike.h" - /* #include "CondFormats/DataRecord/interface/EcalTPGFineGrainEBGroupRcd.h" #include "CondFormats/DataRecord/interface/EcalTPGFineGrainEBIdMapRcd.h" @@ -60,161 +59,152 @@ #include "EcalEBTrigPrimProducer.h" #include "SimCalorimetry/EcalEBTrigPrimAlgos/interface/EcalEBTrigPrimTestAlgo.h" -EcalEBTrigPrimProducer::EcalEBTrigPrimProducer(const edm::ParameterSet& iConfig): - barrelOnly_(iConfig.getParameter("BarrelOnly")), - tcpFormat_(iConfig.getParameter("TcpOutput")), - debug_(iConfig.getParameter("Debug")), - famos_(iConfig.getParameter("Famos")), - nSamples_(iConfig.getParameter("nOfSamples")), - binOfMaximum_(iConfig.getParameter("binOfMaximum")) -{ - tokenEBdigi_=consumes(iConfig.getParameter("barrelEcalDigis")); +EcalEBTrigPrimProducer::EcalEBTrigPrimProducer(const edm::ParameterSet& iConfig) + : barrelOnly_(iConfig.getParameter("BarrelOnly")), + tcpFormat_(iConfig.getParameter("TcpOutput")), + debug_(iConfig.getParameter("Debug")), + famos_(iConfig.getParameter("Famos")), + nSamples_(iConfig.getParameter("nOfSamples")), + binOfMaximum_(iConfig.getParameter("binOfMaximum")) { + tokenEBdigi_ = consumes(iConfig.getParameter("barrelEcalDigis")); //register your products - produces (); - if (tcpFormat_) produces ("formatTCP"); + produces(); + if (tcpFormat_) + produces("formatTCP"); } - - -void EcalEBTrigPrimProducer::beginRun(edm::Run const & run,edm::EventSetup const& setup) { +void EcalEBTrigPrimProducer::beginRun(edm::Run const& run, edm::EventSetup const& setup) { //ProcessHistory is guaranteed to be constant for an entire Run //binOfMaximum_ = findBinOfMaximum(fillBinOfMaximumFromHistory_,binOfMaximum_,run.processHistory()); - algo_.reset( new EcalEBTrigPrimTestAlgo(setup,nSamples_,binOfMaximum_,tcpFormat_,barrelOnly_,debug_, famos_) ); - // get a first version of the records - cacheID_=this->getRecords(setup); - nEvent_=0; + algo_.reset(new EcalEBTrigPrimTestAlgo(setup, nSamples_, binOfMaximum_, tcpFormat_, barrelOnly_, debug_, famos_)); + // get a first version of the records + cacheID_ = this->getRecords(setup); + nEvent_ = 0; } -unsigned long long EcalEBTrigPrimProducer::getRecords(edm::EventSetup const& setup) { - +unsigned long long EcalEBTrigPrimProducer::getRecords(edm::EventSetup const& setup) { // get parameter records for xtals edm::ESHandle theEcalTPGLinearization_handle; setup.get().get(theEcalTPGLinearization_handle); - const EcalTPGLinearizationConst * ecaltpLin = theEcalTPGLinearization_handle.product(); + const EcalTPGLinearizationConst* ecaltpLin = theEcalTPGLinearization_handle.product(); // edm::ESHandle theEcalTPGPedestals_handle; setup.get().get(theEcalTPGPedestals_handle); - const EcalTPGPedestals * ecaltpPed = theEcalTPGPedestals_handle.product(); + const EcalTPGPedestals* ecaltpPed = theEcalTPGPedestals_handle.product(); // edm::ESHandle theEcalTPGCrystalStatus_handle; setup.get().get(theEcalTPGCrystalStatus_handle); - const EcalTPGCrystalStatus * ecaltpgBadX = theEcalTPGCrystalStatus_handle.product(); + const EcalTPGCrystalStatus* ecaltpgBadX = theEcalTPGCrystalStatus_handle.product(); // //for strips // edm::ESHandle theEcalTPGWEightIdMap_handle; setup.get().get(theEcalTPGWEightIdMap_handle); - const EcalTPGWeightIdMap * ecaltpgWeightMap = theEcalTPGWEightIdMap_handle.product(); + const EcalTPGWeightIdMap* ecaltpgWeightMap = theEcalTPGWEightIdMap_handle.product(); // edm::ESHandle theEcalTPGWEightGroup_handle; setup.get().get(theEcalTPGWEightGroup_handle); - const EcalTPGWeightGroup * ecaltpgWeightGroup = theEcalTPGWEightGroup_handle.product(); - // + const EcalTPGWeightGroup* ecaltpgWeightGroup = theEcalTPGWEightGroup_handle.product(); + // edm::ESHandle theEcalTPGSlidingWindow_handle; setup.get().get(theEcalTPGSlidingWindow_handle); - const EcalTPGSlidingWindow * ecaltpgSlidW = theEcalTPGSlidingWindow_handle.product(); - // TCP + const EcalTPGSlidingWindow* ecaltpgSlidW = theEcalTPGSlidingWindow_handle.product(); + // TCP edm::ESHandle theEcalTPGLutGroup_handle; setup.get().get(theEcalTPGLutGroup_handle); - const EcalTPGLutGroup * ecaltpgLutGroup = theEcalTPGLutGroup_handle.product(); + const EcalTPGLutGroup* ecaltpgLutGroup = theEcalTPGLutGroup_handle.product(); // edm::ESHandle theEcalTPGLutIdMap_handle; setup.get().get(theEcalTPGLutIdMap_handle); - const EcalTPGLutIdMap * ecaltpgLut = theEcalTPGLutIdMap_handle.product(); + const EcalTPGLutIdMap* ecaltpgLut = theEcalTPGLutIdMap_handle.product(); // edm::ESHandle theEcalTPGTowerStatus_handle; setup.get().get(theEcalTPGTowerStatus_handle); - const EcalTPGTowerStatus * ecaltpgBadTT = theEcalTPGTowerStatus_handle.product(); + const EcalTPGTowerStatus* ecaltpgBadTT = theEcalTPGTowerStatus_handle.product(); // edm::ESHandle theEcalTPGSpike_handle; setup.get().get(theEcalTPGSpike_handle); - const EcalTPGSpike * ecaltpgSpike = theEcalTPGSpike_handle.product(); - - + const EcalTPGSpike* ecaltpgSpike = theEcalTPGSpike_handle.product(); //////////////// - algo_->setPointers(ecaltpLin,ecaltpPed,ecaltpgBadX,ecaltpgWeightMap,ecaltpgWeightGroup,ecaltpgSlidW,ecaltpgLutGroup,ecaltpgLut,ecaltpgBadTT, ecaltpgSpike); + algo_->setPointers(ecaltpLin, + ecaltpPed, + ecaltpgBadX, + ecaltpgWeightMap, + ecaltpgWeightGroup, + ecaltpgSlidW, + ecaltpgLutGroup, + ecaltpgLut, + ecaltpgBadTT, + ecaltpgSpike); return setup.get().cacheIdentifier(); - - - - -} - - - -void EcalEBTrigPrimProducer::endRun(edm::Run const& run,edm::EventSetup const& setup) { - algo_.reset(); } +void EcalEBTrigPrimProducer::endRun(edm::Run const& run, edm::EventSetup const& setup) { algo_.reset(); } -EcalEBTrigPrimProducer::~EcalEBTrigPrimProducer() -{} - +EcalEBTrigPrimProducer::~EcalEBTrigPrimProducer() {} // ------------ method called to produce the data ------------ -void -EcalEBTrigPrimProducer::produce(edm::Event& e, const edm::EventSetup& iSetup) -{ - +void EcalEBTrigPrimProducer::produce(edm::Event& e, const edm::EventSetup& iSetup) { nEvent_++; // get input collections edm::Handle barrelDigiHandle; - - if (! e.getByToken(tokenEBdigi_,barrelDigiHandle)) { + if (!e.getByToken(tokenEBdigi_, barrelDigiHandle)) { edm::EDConsumerBase::Labels labels; labelsForToken(tokenEBdigi_, labels); - edm::LogWarning("EcalTPG") <<" Couldnt find Barrel digis "< Treating event "<< nEvent_<<", Number of EB digis "<size() << std::endl; - + if (debug_) + std::cout << "EcalTPG" + << " =================> Treating event " << nEvent_ << ", Number of EB digis " + << barrelDigiHandle.product()->size() << std::endl; auto pOut = std::make_unique(); auto pOutTcp = std::make_unique(); - + // if ( e.id().event() != 648 ) return; //std::cout << " Event number " << e.id().event() << std::endl; - // invoke algorithm + // invoke algorithm - - const EBDigiCollection *ebdigi=nullptr; - ebdigi=barrelDigiHandle.product(); - algo_->run(iSetup,ebdigi,*pOut,*pOutTcp); - + const EBDigiCollection* ebdigi = nullptr; + ebdigi = barrelDigiHandle.product(); + algo_->run(iSetup, ebdigi, *pOut, *pOutTcp); - if (debug_ ) std::cout << "produce" << " For Barrel "<size()<<" TP Digis were produced" << std::endl; + if (debug_) + std::cout << "produce" + << " For Barrel " << pOut->size() << " TP Digis were produced" << std::endl; // debug prints if TP >0 - int nonZeroTP=0; - for (unsigned int i=0;isize();++i) { - - if (debug_ ) { - std::cout << "EcalTPG Printing only non zero TP " <<" For tower "<<(((*pOut)[i])).id()<<", TP is "<<(*pOut)[i]; - for (int isam=0;isam<(*pOut)[i].size();++isam) { - - if ( (*pOut)[i][isam].encodedEt() > 0) { - nonZeroTP++; - std::cout << " (*pOut)[i][isam].raw() " << (*pOut)[i][isam].raw() << " (*pOut)[i][isam].encodedEt() " << (*pOut)[i][isam].encodedEt() << std::endl; - } + int nonZeroTP = 0; + for (unsigned int i = 0; i < pOut->size(); ++i) { + if (debug_) { + std::cout << "EcalTPG Printing only non zero TP " + << " For tower " << (((*pOut)[i])).id() << ", TP is " << (*pOut)[i]; + for (int isam = 0; isam < (*pOut)[i].size(); ++isam) { + if ((*pOut)[i][isam].encodedEt() > 0) { + nonZeroTP++; + std::cout << " (*pOut)[i][isam].raw() " << (*pOut)[i][isam].raw() << " (*pOut)[i][isam].encodedEt() " + << (*pOut)[i][isam].encodedEt() << std::endl; + } } } } - if (debug_ ) std::cout << "EcalTPG" <<"\n =================> For Barrel , "<size()<<" TP Digis were produced (including zero ones)" << " Non zero primitives were " << nonZeroTP << std::endl; - - + if (debug_) + std::cout << "EcalTPG" + << "\n =================> For Barrel , " << pOut->size() + << " TP Digis were produced (including zero ones)" + << " Non zero primitives were " << nonZeroTP << std::endl; // put result into the Event e.put(std::move(pOut)); - if (tcpFormat_) e.put(std::move(pOutTcp),"formatTCP"); + if (tcpFormat_) + e.put(std::move(pOutTcp), "formatTCP"); } diff --git a/SimCalorimetry/EcalEBTrigPrimProducers/plugins/EcalEBTrigPrimProducer.h b/SimCalorimetry/EcalEBTrigPrimProducers/plugins/EcalEBTrigPrimProducer.h index d6e0d2a1f2f61..d1daf9be36db9 100644 --- a/SimCalorimetry/EcalEBTrigPrimProducers/plugins/EcalEBTrigPrimProducer.h +++ b/SimCalorimetry/EcalEBTrigPrimProducers/plugins/EcalEBTrigPrimProducer.h @@ -1,49 +1,44 @@ #ifndef EcalEBTrigPrimProducer_h #define EcalEBTrigPrimProducer_h - + /** \class EcalEBTrigPrimProducer * For Phase II * ************************************************************/ #include - + #include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Utilities/interface/EDGetToken.h" - + #include "DataFormats/Common/interface/Handle.h" - + #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" - -class EcalEBTrigPrimTestAlgo; +class EcalEBTrigPrimTestAlgo; - -class EcalEBTrigPrimProducer : public edm::stream::EDProducer<> -{ - public: - +class EcalEBTrigPrimProducer : public edm::stream::EDProducer<> { +public: explicit EcalEBTrigPrimProducer(const edm::ParameterSet& conf); - + ~EcalEBTrigPrimProducer() override; - void beginRun(const edm::Run& run, const edm::EventSetup& es) override; void endRun(const edm::Run&, const edm::EventSetup&) override; void produce(edm::Event& e, const edm::EventSetup& c) override; - private: +private: std::unique_ptr algo_; bool barrelOnly_; bool tcpFormat_; bool debug_; bool famos_; - int nSamples_; - int nEvent_; - + int nSamples_; + int nEvent_; + edm::EDGetTokenT tokenEBdigi_; int binOfMaximum_; @@ -51,10 +46,6 @@ class EcalEBTrigPrimProducer : public edm::stream::EDProducer<> unsigned long long getRecords(edm::EventSetup const& setup); unsigned long long cacheID_; - }; - -#endif - - +#endif diff --git a/SimCalorimetry/EcalEBTrigPrimProducers/plugins/SealModules.cc b/SimCalorimetry/EcalEBTrigPrimProducers/plugins/SealModules.cc index 48d5f449845b7..5ddb5f51d9755 100644 --- a/SimCalorimetry/EcalEBTrigPrimProducers/plugins/SealModules.cc +++ b/SimCalorimetry/EcalEBTrigPrimProducers/plugins/SealModules.cc @@ -6,7 +6,5 @@ #include "EcalEBTrigPrimProducer.h" #include "EcalEBTrigPrimAnalyzer.h" - DEFINE_FWK_MODULE(EcalEBTrigPrimProducer); DEFINE_FWK_MODULE(EcalEBTrigPrimAnalyzer); -