Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef CalibMuon_DTT0Calibration_H
0002 #define CalibMuon_DTT0Calibration_H
0003 
0004 /** \class DTT0Calibration
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  *  \author S. Bolognesi - INFN Torino
0012  */
0013 
0014 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0015 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0016 #include "DataFormats/MuonDetId/interface/DTWireId.h"
0017 #include "DataFormats/DTDigi/interface/DTDigiCollection.h"
0018 #include "FWCore/Framework/interface/ESHandle.h"
0019 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0020 
0021 #include <string>
0022 #include <vector>
0023 #include <map>
0024 
0025 #include "TFile.h"
0026 #include "TH1I.h"
0027 #include "TH1D.h"
0028 #include "TSpectrum.h"
0029 
0030 //class TFile;
0031 //class TH1I;
0032 //class TH1D;
0033 //class TSpectrum;
0034 class DTT0;
0035 
0036 class DTT0Calibration : public edm::one::EDAnalyzer<> {
0037 public:
0038   /// Constructor
0039   DTT0Calibration(const edm::ParameterSet& pset);
0040 
0041   /// Destructor
0042   ~DTT0Calibration() override;
0043 
0044   // Operations
0045 
0046   /// Fill the maps with t0 (by channel)
0047   void analyze(const edm::Event& event, const edm::EventSetup& eventSetup) override;
0048 
0049   /// Compute the mean and the RMS of the t0 from the maps and write them to the DB with channel granularity
0050   void endJob() override;
0051 
0052 protected:
0053 private:
0054   // Generate the histo name
0055   std::string getHistoName(const DTWireId& wId) const;
0056   std::string getHistoName(const DTLayerId& lId) const;
0057 
0058   // Debug flag
0059   bool debug;
0060 
0061   // The label used to retrieve digis from the event
0062   edm::EDGetTokenT<DTDigiCollection> digiToken;
0063 
0064   // The root file which contain the histos per layer
0065   TFile theFile;
0066 
0067   //The event counter
0068   unsigned int nevents;
0069   //Number of events to be used for the t0 per layer histos
0070   unsigned int eventsForLayerT0;
0071   //Number of events to be used for the t0 reference per wire
0072   unsigned int eventsForWireT0;
0073 
0074   //Acceptance of t0 w.r.t. reference peak
0075   double tpPeakWidth;
0076 
0077   //Acceptance of t0 w.r.t. reference peak
0078   double tpPeakWidthPerLayer;
0079 
0080   //Digi's will be rejected if too far from TP peak
0081   unsigned int rejectDigiFromPeak;
0082 
0083   //The wheels,sector to be calibrated (default All)
0084   std::string theCalibWheel;
0085   int selWheel;
0086   std::string theCalibSector;
0087   int selSector;
0088 
0089   // Map of the histos and graph by layer
0090   std::map<DTLayerId, TH1I> theHistoLayerMap;
0091 
0092   // Histogram containing position of all peaks
0093   TH1D hLayerPeaks;
0094 
0095   TSpectrum spectrum;
0096 
0097   //Layer with histos for each wire
0098   std::vector<DTWireId> wireIdWithHistos;
0099   std::vector<DTLayerId> layerIdWithWireHistos;
0100 
0101   //Maps with t0, sigma, number of digi per wire
0102   std::map<DTWireId, double> theAbsoluteT0PerWire;
0103   std::map<DTWireId, double> theRelativeT0PerWire;
0104   std::map<DTWireId, double> theSigmaT0PerWire;
0105   std::map<DTWireId, int> nDigiPerWire;
0106   std::map<DTWireId, int> nDigiPerWire_ref;
0107   std::map<DTWireId, double> mK;
0108   std::map<DTWireId, double> mK_ref;
0109   std::map<DTWireId, double> qK;
0110   //Map with histo per wire for the chosen layer
0111   std::map<DTWireId, TH1I> theHistoWireMap;
0112   //Map with mean and RMS of t0 per layer
0113   std::map<std::string, double> theT0LayerMap;
0114   std::map<std::string, double> theSigmaT0LayerMap;
0115   std::map<DTLayerId, double> theTPPeakMap;
0116   //Ref. t0 per chamber
0117   std::map<DTChamberId, double> theSumT0ByChamber;
0118   std::map<DTChamberId, int> theCountT0ByChamber;
0119   std::map<DTChamberId, double> theSigmaT0ByChamber;
0120   std::map<DTChamberId, double> theMeanT0ByChamber;
0121   std::map<DTChamberId, double> theRefT0ByChamber;
0122 
0123   //DTGeometry used to loop on the SL in the endJob
0124   edm::ESHandle<DTGeometry> dtGeom;
0125   const edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeomToken_;
0126 };
0127 #endif