Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:26

0001 #ifndef CalibMuon_DTT0CalibrationRMS_H
0002 #define CalibMuon_DTT0CalibrationRMS_H
0003 
0004 /** \class DTT0CalibrationRMS
0005  *  Analyzer class computes the mean and RMS of t0 from pulses.
0006  *  Those values are written in the DB with cell granularity. The
0007  *  mean value for each channel is normalized to a reference time common to all the sector.
0008  *  The t0 of wires in odd layers are corrected for the relative difference between
0009  *  odd and even layers
0010  */
0011 
0012 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0013 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0014 #include "DataFormats/MuonDetId/interface/DTWireId.h"
0015 #include "DataFormats/DTDigi/interface/DTDigiCollection.h"
0016 #include "FWCore/Framework/interface/ESHandle.h"
0017 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0018 
0019 #include <string>
0020 #include <vector>
0021 #include <map>
0022 
0023 class TFile;
0024 class TH1I;
0025 class TH1D;
0026 class DTT0;
0027 
0028 class DTT0CalibrationRMS : public edm::one::EDAnalyzer<> {
0029 public:
0030   /// Constructor
0031   DTT0CalibrationRMS(const edm::ParameterSet& pset);
0032 
0033   /// Destructor
0034   ~DTT0CalibrationRMS() override;
0035 
0036   // Operations
0037 
0038   /// Fill the maps with t0 (by channel)
0039   void analyze(const edm::Event& event, const edm::EventSetup& eventSetup) override;
0040 
0041   /// Compute the mean and the RMS of the t0 from the maps and write them to the DB with channel granularity
0042   void endJob() override;
0043 
0044 protected:
0045 private:
0046   // Generate the histo name
0047   std::string getHistoName(const DTWireId& wId) const;
0048   std::string getHistoName(const DTLayerId& lId) const;
0049 
0050   // Debug flag
0051   bool debug;
0052 
0053   // The token used to retrieve digis from the event
0054   edm::EDGetTokenT<DTDigiCollection> digiToken;
0055 
0056   // The root file which contain the histos per layer
0057   TFile* theFile;
0058   // The root file which will contain the histos per wire (for the given layer)
0059   TFile* theOutputFile;
0060 
0061   //The event counter
0062   unsigned int nevents;
0063   //Number of events to be used for the t0 per layer histos
0064   unsigned int eventsForLayerT0;
0065   //Number of events to be used for the t0 reference per wire
0066   unsigned int eventsForWireT0;
0067 
0068   //Reject digis if far from TP peak
0069   unsigned int rejectDigiFromPeak;
0070 
0071   //Acceptance of t0 w.r.t. reference peak
0072   double tpPeakWidth;
0073 
0074   // Write relative t0's with respect to mean t0's in chamber
0075   bool correctByChamberMean_;
0076 
0077   //The wheels,sector to be calibrated (default All)
0078   std::string theCalibWheel;
0079   int selWheel;
0080   std::string theCalibSector;
0081   int selSector;
0082 
0083   // Map of the histos and graph by layer
0084   std::map<DTLayerId, TH1I*> theHistoLayerMap;
0085   //Histo with t0 mean per layer for all the sector
0086   TH1D* hT0SectorHisto;
0087 
0088   //Layer with histos for each wire
0089   std::vector<DTWireId> wireIdWithHistos;
0090   std::vector<std::string> cellsWithHistos;
0091 
0092   //Maps with t0, sigma, number of digi per wire
0093   std::map<DTWireId, double> theAbsoluteT0PerWire;
0094   std::map<DTWireId, double> theRelativeT0PerWire;
0095   std::map<DTWireId, double> theSigmaT0PerWire;
0096   std::map<DTWireId, int> nDigiPerWire;
0097   std::map<DTWireId, int> nDigiPerWire_ref;
0098   std::map<DTWireId, double> mK;
0099   std::map<DTWireId, double> mK_ref;
0100   std::map<DTWireId, double> qK;
0101   //Map with histo per wire for the chosen layer
0102   std::map<DTWireId, TH1I*> theHistoWireMap;
0103   std::map<DTWireId, TH1I*> theHistoWireMap_ref;
0104   //Map with mean and RMS of t0 per layer
0105   std::map<std::string, double> theT0LayerMap;
0106   std::map<std::string, double> theSigmaT0LayerMap;
0107 
0108   //DTGeometry used to loop on the SL in the endJob
0109   edm::ESHandle<DTGeometry> dtGeom;
0110   const edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeomToken_;
0111 };
0112 #endif