Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-07-10 22:32:49

0001 // -*- C++ -*-
0002 //
0003 // Package:    CalibTracker/SiStripChannelGain
0004 // Class:      SiStripGainsPCLHarvester
0005 //
0006 /**\class SiStripGainsPCLHarvester SiStripGainsPCLHarvester.cc 
0007  Description: Harvests output of SiStripGainsPCLWorker and creates histograms and Gains Payload
0008  
0009 */
0010 //
0011 //  Original Author: L. Quertermont (calibration algorithm)
0012 //  Contributors:    M. Verzetti    (data access)
0013 //                   A. Di Mattia   (PCL multi stream processing and monitoring)
0014 //                   M. Delcourt    (monitoring)
0015 //                   M. Musich      (migration to thread-safe DQMStore access)
0016 //
0017 //  Created:  Wed, 12 Apr 2017 14:46:48 GMT
0018 //
0019 
0020 // CMSSW includes
0021 #include "CondFormats/SiStripObjects/interface/SiStripApvGain.h"
0022 #include "FWCore/Framework/interface/Event.h"
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "FWCore/Framework/interface/MakerMacros.h"
0025 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0026 #include "FWCore/ServiceRegistry/interface/Service.h"
0027 #include "DQMServices/Core/interface/DQMEDHarvester.h"
0028 #include "DQMServices/Core/interface/DQMStore.h"
0029 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0030 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0031 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0032 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0033 #include "CalibFormats/SiStripObjects/interface/SiStripGain.h"
0034 #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
0035 #include "CalibTracker/Records/interface/SiStripGainRcd.h"
0036 #include "CalibTracker/Records/interface/SiStripQualityRcd.h"
0037 
0038 // user includes
0039 #include "CalibTracker/SiStripChannelGain/interface/APVGainStruct.h"
0040 
0041 // ROOT includes
0042 #include "TH1F.h"
0043 #include "TH2S.h"
0044 #include "TProfile.h"
0045 #include "TF1.h"
0046 
0047 // System includes
0048 #include <unordered_map>
0049 
0050 class SiStripGainsPCLHarvester : public DQMEDHarvester {
0051 public:
0052   explicit SiStripGainsPCLHarvester(const edm::ParameterSet& ps);
0053   void beginRun(edm::Run const& run, edm::EventSetup const& isetup) override;
0054   void endRun(edm::Run const& run, edm::EventSetup const& isetup) override;
0055   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0056 
0057 private:
0058   virtual void checkBookAPVColls(const edm::EventSetup& setup);
0059   void dqmEndJob(DQMStore::IBooker& ibooker_, DQMStore::IGetter& igetter_) override;
0060   void gainQualityMonitor(DQMStore::IBooker& ibooker_, const MonitorElement* Charge_Vs_Index) const;
0061   void storeGainsTree(const TAxis* chVsIdxXaxis) const;
0062   int statCollectionFromMode(const char* tag) const;
0063 
0064   void algoComputeMPVandGain(const MonitorElement* Charge_Vs_Index);
0065   void getPeakOfLandau(TH1* InputHisto,
0066                        double* FitResults,
0067                        double LowRange = 50,
0068                        double HighRange = 5400,
0069                        bool gaussianConvolution = false);
0070   bool IsGoodLandauFit(double* FitResults);
0071 
0072   bool produceTagFilter(const MonitorElement* Charge_Vs_Index);
0073   std::unique_ptr<SiStripApvGain> getNewObject(const MonitorElement* Charge_Vs_Index);
0074 
0075   bool doStoreOnDB;
0076   bool doChargeMonitorPerPlane; /*!< Charge monitor per detector plane */
0077   bool storeGainsTree_;
0078   unsigned int GOOD;
0079   unsigned int BAD;
0080   unsigned int MASKED;
0081 
0082   double tagCondition_NClusters;
0083   double tagCondition_GoodFrac;
0084 
0085   int NStripAPVs;
0086   int NPixelDets;
0087   double MinNrEntries;
0088 
0089   std::string m_Record;
0090 
0091   std::string m_DQMdir;                  /*!< DQM folder hosting the charge statistics and the monitor plots */
0092   std::string m_calibrationMode;         /*!< Type of statistics for the calibration */
0093   std::vector<std::string> VChargeHisto; /*!< Charge monitor plots to be output */
0094 
0095   std::vector<std::string> dqm_tag_;
0096 
0097   int CalibrationLevel;
0098 
0099   const TrackerGeometry* bareTkGeomPtr_ = nullptr;  // ugly hack to fill APV colls only once, but checks
0100   std::unique_ptr<TrackerTopology> tTopo_;
0101 
0102   std::vector<std::shared_ptr<stAPVGain> > APVsCollOrdered;
0103   std::unordered_map<unsigned int, std::shared_ptr<stAPVGain> > APVsColl;
0104 
0105   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoTokenBR_, tTopoTokenER_;
0106   edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tkGeomToken_;
0107   edm::ESGetToken<SiStripGain, SiStripGainRcd> gainToken_;
0108   edm::ESGetToken<SiStripQuality, SiStripQualityRcd> qualityToken_;
0109 
0110   // fit options
0111   bool fit_gaussianConvolution_ = false;
0112   bool fit_gaussianConvolutionTOBL56_ = false;
0113   bool fit_dataDrivenRange_ = false;
0114 };