Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:45:51

0001 #ifndef Alignment_OfflineValidation_MuonAlignmentAnalyzer_H
0002 #define Alignment_OfflineValidation_MuonAlignmentAnalyzer_H
0003 
0004 /** \class MuonAlignmentANalyzer
0005  *  MuonAlignment offline Monitor Analyzer 
0006  *  Makes histograms of high level Muon objects/quantities
0007  *  and residuals (base EDAnalyzer for Muon Alignment Offline DQM)
0008  *  for Alignment Scenarios/DB comparison
0009  *
0010  *  $Date: 2010/03/29 13:18:44 $
0011  *  $Revision: 1.8 $
0012  *  \author J. Fernandez - Univ. Oviedo <Javier.Fernandez@cern.ch>
0013  */
0014 
0015 // Base Class Headers
0016 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0017 #include "DataFormats/CSCRecHit/interface/CSCSegmentCollection.h"
0018 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
0019 #include "DataFormats/TrackReco/interface/Track.h"
0020 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0021 #include "FWCore/ServiceRegistry/interface/Service.h"
0022 #include "FWCore/Utilities/interface/InputTag.h"
0023 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
0024 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
0025 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
0026 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
0027 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0028 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
0029 #include <vector>
0030 
0031 namespace edm {
0032   class ParameterSet;
0033   class EventSetup;
0034 }  // namespace edm
0035 
0036 class TH1F;
0037 class TH2F;
0038 
0039 typedef std::vector<std::vector<int> > intDVector;
0040 typedef std::vector<TrackingRecHit *> RecHitVector;
0041 
0042 class MuonAlignmentAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0043 public:
0044   /// Constructor
0045   MuonAlignmentAnalyzer(const edm::ParameterSet &pset);
0046 
0047   /// Destructor
0048   ~MuonAlignmentAnalyzer() override;
0049 
0050   // Operations
0051 
0052   void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override;
0053 
0054   void beginJob() override;
0055   void endJob() override;
0056 
0057 protected:
0058 private:
0059   const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken_;
0060   const edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> trackingGeometryToken_;
0061   RecHitVector doMatching(const reco::Track &,
0062                           edm::Handle<DTRecSegment4DCollection> &,
0063                           edm::Handle<CSCSegmentCollection> &,
0064                           intDVector *,
0065                           intDVector *,
0066                           edm::ESHandle<GlobalTrackingGeometry> &);
0067 
0068   edm::Service<TFileService> fs;
0069 
0070   // InputTags
0071   edm::InputTag theGLBMuonTag;
0072   edm::InputTag theSTAMuonTag;
0073 
0074   // Collections needed
0075   edm::InputTag theRecHits4DTagDT;
0076   edm::InputTag theRecHits4DTagCSC;
0077 
0078   // To switch between real data and MC
0079   std::string theDataType;
0080 
0081   bool doSAplots, doGBplots, doResplots;
0082 
0083   // Histograms
0084 
0085   //# muons per event
0086   TH1F *hGBNmuons;
0087   TH1F *hSANmuons;
0088   TH1F *hSimNmuons;
0089   TH1F *hGBNmuons_Barrel;
0090   TH1F *hSANmuons_Barrel;
0091   TH1F *hSimNmuons_Barrel;
0092   TH1F *hGBNmuons_Endcap;
0093   TH1F *hSANmuons_Endcap;
0094   TH1F *hSimNmuons_Endcap;
0095 
0096   // # hits per track
0097   TH1F *hGBNhits;
0098   TH1F *hGBNhits_Barrel;
0099   TH1F *hGBNhits_Endcap;
0100   TH1F *hSANhits;
0101   TH1F *hSANhits_Barrel;
0102   TH1F *hSANhits_Endcap;
0103 
0104   // Chi2 of Track
0105   TH1F *hGBChi2;
0106   TH1F *hSAChi2;
0107   TH1F *hGBChi2_Barrel;
0108   TH1F *hSAChi2_Barrel;
0109   TH1F *hGBChi2_Endcap;
0110   TH1F *hSAChi2_Endcap;
0111 
0112   // Invariant mass for dimuons
0113   TH1F *hGBInvM;
0114   TH1F *hSAInvM;
0115   TH1F *hSimInvM;
0116   // Invariant Mass distributions in Barrel (eta<1.04) region
0117   TH1F *hGBInvM_Barrel;
0118   TH1F *hSAInvM_Barrel;
0119   TH1F *hSimInvM_Barrel;
0120   // Invariant Mass distributions in Endcap (eta>=1.04) region
0121   TH1F *hGBInvM_Endcap;
0122   TH1F *hSAInvM_Endcap;
0123   TH1F *hSimInvM_Endcap;
0124   // Invariant Mass distributions in Barrel-Endcap overlap region
0125   // 1 muon barrel & 1 muon endcap
0126   TH1F *hGBInvM_Overlap;
0127   TH1F *hSAInvM_Overlap;
0128   TH1F *hSimInvM_Overlap;
0129 
0130   // pT
0131   TH1F *hSAPTRec;
0132   TH1F *hGBPTRec;
0133   TH1F *hSimPT;
0134   TH1F *hSAPTRec_Barrel;
0135   TH1F *hGBPTRec_Barrel;
0136   TH1F *hSimPT_Barrel;
0137   TH1F *hSAPTRec_Endcap;
0138   TH1F *hGBPTRec_Endcap;
0139   TH1F *hSimPT_Endcap;
0140   TH2F *hGBPTvsEta;
0141   TH2F *hGBPTvsPhi;
0142   TH2F *hSAPTvsEta;
0143   TH2F *hSAPTvsPhi;
0144   TH2F *hSimPTvsEta;
0145   TH2F *hSimPTvsPhi;
0146 
0147   // For reco efficiency calculations
0148   TH2F *hSimPhivsEta;
0149   TH2F *hSAPhivsEta;
0150   TH2F *hGBPhivsEta;
0151 
0152   // pT resolution
0153   TH1F *hSAPTres;
0154   TH1F *hSAinvPTres;
0155   TH1F *hGBPTres;
0156   TH1F *hGBinvPTres;
0157   TH1F *hSAPTres_Barrel;
0158   TH1F *hSAPTres_Endcap;
0159   TH1F *hGBPTres_Barrel;
0160   TH1F *hGBPTres_Endcap;
0161   //pT rec - pT gen
0162   TH1F *hSAPTDiff;
0163   TH1F *hGBPTDiff;
0164   TH2F *hSAPTDiffvsEta;
0165   TH2F *hSAPTDiffvsPhi;
0166   TH2F *hGBPTDiffvsEta;
0167   TH2F *hGBPTDiffvsPhi;
0168   TH2F *hGBinvPTvsEta;
0169   TH2F *hGBinvPTvsPhi;
0170   TH2F *hSAinvPTvsEta;
0171   TH2F *hSAinvPTvsPhi;
0172   TH2F *hSAinvPTvsNhits;
0173   TH2F *hGBinvPTvsNhits;
0174 
0175   // Vector of chambers Residuals
0176   std::vector<TH1F *> unitsLocalX;
0177   std::vector<TH1F *> unitsLocalPhi;
0178   std::vector<TH1F *> unitsLocalTheta;
0179   std::vector<TH1F *> unitsLocalY;
0180   std::vector<TH1F *> unitsGlobalRPhi;
0181   std::vector<TH1F *> unitsGlobalPhi;
0182   std::vector<TH1F *> unitsGlobalTheta;
0183   std::vector<TH1F *> unitsGlobalRZ;
0184 
0185   // DT & CSC Residuals
0186   TH1F *hResidualLocalXDT;
0187   TH1F *hResidualLocalPhiDT;
0188   TH1F *hResidualLocalThetaDT;
0189   TH1F *hResidualLocalYDT;
0190   TH1F *hResidualLocalXCSC;
0191   TH1F *hResidualLocalPhiCSC;
0192   TH1F *hResidualLocalThetaCSC;
0193   TH1F *hResidualLocalYCSC;
0194   std::vector<TH1F *> hResidualLocalXDT_W;
0195   std::vector<TH1F *> hResidualLocalPhiDT_W;
0196   std::vector<TH1F *> hResidualLocalThetaDT_W;
0197   std::vector<TH1F *> hResidualLocalYDT_W;
0198   std::vector<TH1F *> hResidualLocalXCSC_ME;
0199   std::vector<TH1F *> hResidualLocalPhiCSC_ME;
0200   std::vector<TH1F *> hResidualLocalThetaCSC_ME;
0201   std::vector<TH1F *> hResidualLocalYCSC_ME;
0202   std::vector<TH1F *> hResidualLocalXDT_MB;
0203   std::vector<TH1F *> hResidualLocalPhiDT_MB;
0204   std::vector<TH1F *> hResidualLocalThetaDT_MB;
0205   std::vector<TH1F *> hResidualLocalYDT_MB;
0206   TH1F *hResidualGlobalRPhiDT;
0207   TH1F *hResidualGlobalPhiDT;
0208   TH1F *hResidualGlobalThetaDT;
0209   TH1F *hResidualGlobalZDT;
0210   TH1F *hResidualGlobalRPhiCSC;
0211   TH1F *hResidualGlobalPhiCSC;
0212   TH1F *hResidualGlobalThetaCSC;
0213   TH1F *hResidualGlobalRCSC;
0214   std::vector<TH1F *> hResidualGlobalRPhiDT_W;
0215   std::vector<TH1F *> hResidualGlobalPhiDT_W;
0216   std::vector<TH1F *> hResidualGlobalThetaDT_W;
0217   std::vector<TH1F *> hResidualGlobalZDT_W;
0218   std::vector<TH1F *> hResidualGlobalRPhiCSC_ME;
0219   std::vector<TH1F *> hResidualGlobalPhiCSC_ME;
0220   std::vector<TH1F *> hResidualGlobalThetaCSC_ME;
0221   std::vector<TH1F *> hResidualGlobalRCSC_ME;
0222   std::vector<TH1F *> hResidualGlobalRPhiDT_MB;
0223   std::vector<TH1F *> hResidualGlobalPhiDT_MB;
0224   std::vector<TH1F *> hResidualGlobalThetaDT_MB;
0225   std::vector<TH1F *> hResidualGlobalZDT_MB;
0226 
0227   // Mean and RMS of residuals for DQM
0228   TH2F *hprofLocalPositionCSC;
0229   TH2F *hprofLocalAngleCSC;
0230   TH2F *hprofLocalPositionRmsCSC;
0231   TH2F *hprofLocalAngleRmsCSC;
0232   TH2F *hprofGlobalPositionCSC;
0233   TH2F *hprofGlobalAngleCSC;
0234   TH2F *hprofGlobalPositionRmsCSC;
0235   TH2F *hprofGlobalAngleRmsCSC;
0236   TH2F *hprofLocalPositionDT;
0237   TH2F *hprofLocalAngleDT;
0238   TH2F *hprofLocalPositionRmsDT;
0239   TH2F *hprofLocalAngleRmsDT;
0240   TH2F *hprofGlobalPositionDT;
0241   TH2F *hprofGlobalAngleDT;
0242   TH2F *hprofGlobalPositionRmsDT;
0243   TH2F *hprofGlobalAngleRmsDT;
0244 
0245   TH1F *hprofLocalXDT;
0246   TH1F *hprofLocalPhiDT;
0247   TH1F *hprofLocalThetaDT;
0248   TH1F *hprofLocalYDT;
0249   TH1F *hprofLocalXCSC;
0250   TH1F *hprofLocalPhiCSC;
0251   TH1F *hprofLocalThetaCSC;
0252   TH1F *hprofLocalYCSC;
0253   TH1F *hprofGlobalRPhiDT;
0254   TH1F *hprofGlobalPhiDT;
0255   TH1F *hprofGlobalThetaDT;
0256   TH1F *hprofGlobalZDT;
0257   TH1F *hprofGlobalRPhiCSC;
0258   TH1F *hprofGlobalPhiCSC;
0259   TH1F *hprofGlobalThetaCSC;
0260   TH1F *hprofGlobalRCSC;
0261 
0262   std::vector<long> detectorCollection;
0263 
0264   //  ESHandle<MagneticField> theMGField;
0265 
0266   Propagator *thePropagator;
0267 
0268   // Counters
0269   int numberOfSimTracks;
0270   int numberOfGBRecTracks;
0271   int numberOfSARecTracks;
0272   int numberOfHits;
0273 
0274   // hist kinematic range
0275   double ptRangeMin, ptRangeMax, invMassRangeMin, invMassRangeMax;
0276   // hist residual range
0277   double resLocalXRangeStation1, resLocalXRangeStation2, resLocalXRangeStation3, resLocalXRangeStation4;
0278   double resLocalYRangeStation1, resLocalYRangeStation2, resLocalYRangeStation3, resLocalYRangeStation4;
0279   double resPhiRange, resThetaRange;
0280   unsigned int nbins, min1DTrackRecHitSize, min4DTrackSegmentSize;
0281 };
0282 #endif