Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:05

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