Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:10:51

0001 #include "FWCore/PluginManager/interface/ModuleDef.h"
0002 
0003 #include "DataFormats/Common/interface/Handle.h"
0004 #include "DataFormats/MuonReco/interface/Muon.h"
0005 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0006 #include "DataFormats/TrackReco/interface/Track.h"
0007 
0008 #include "FWCore/Utilities/interface/InputTag.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/Framework/interface/MakerMacros.h"
0012 #include "FWCore/ServiceRegistry/interface/Service.h"
0013 
0014 #include "DQMServices/Core/interface/DQMStore.h"
0015 #include "DQMServices/Core/interface/MonitorElement.h"
0016 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0017 
0018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0019 
0020 using namespace std;
0021 using namespace edm;
0022 
0023 class CosmicMuonRecoAnalyzer : public DQMEDAnalyzer {
0024 public:
0025   /// Constructor
0026   CosmicMuonRecoAnalyzer(const edm::ParameterSet&);
0027 
0028   /// Destructor
0029   ~CosmicMuonRecoAnalyzer() override;
0030 
0031   /// Inizialize parameters for histo binning
0032   void analyze(const edm::Event&, const edm::EventSetup&) override;
0033   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0034 
0035 private:
0036   // ----------member data ---------------------------
0037   edm::ParameterSet parameters;
0038 
0039   edm::EDGetTokenT<edm::View<reco::Track> > theMuonCollectionLabel_;
0040 
0041   //histo binning parameters
0042 
0043   int hitsBin;
0044   int hitsMin;
0045   int hitsMax;
0046 
0047   int nTrkBin;
0048   int nTrkMax;
0049   int nTrkMin;
0050 
0051   int etaBin;
0052   double etaMin;
0053   double etaMax;
0054 
0055   int thetaBin;
0056   double thetaMin;
0057   double thetaMax;
0058 
0059   int phiBin;
0060   double phiMin;
0061   double phiMax;
0062 
0063   int chi2Bin;
0064   double chi2Min;
0065   double chi2Max;
0066 
0067   int pBin;
0068   double pMin;
0069   double pMax;
0070 
0071   int ptBin;
0072   double ptMin;
0073   double ptMax;
0074 
0075   int pResBin;
0076   double pResMin;
0077   double pResMax;
0078 
0079   // sta muon
0080   MonitorElement* nTracksSta;
0081 
0082   MonitorElement* etaStaTrack;
0083   MonitorElement* thetaStaTrack;
0084   MonitorElement* phiStaTrack;
0085   MonitorElement* chi2OvDFStaTrack;
0086   MonitorElement* probchi2StaTrack;
0087   MonitorElement* pStaTrack;
0088   MonitorElement* qOverPStaTrack;
0089   MonitorElement* ptStaTrack;
0090   MonitorElement* qStaTrack;
0091   MonitorElement* nValidHitsStaTrack;
0092 
0093   MonitorElement* qOverPStaTrack_p;
0094   MonitorElement* phiVsetaStaTrack;
0095   MonitorElement* nValidHitsStaTrack_eta;
0096   MonitorElement* nValidHitsStaTrack_phi;
0097 
0098   std::string theFolder;
0099 };
0100 
0101 CosmicMuonRecoAnalyzer::CosmicMuonRecoAnalyzer(const edm::ParameterSet& pSet) {
0102   parameters = pSet;
0103 
0104   // the services:
0105   theMuonCollectionLabel_ = consumes<edm::View<reco::Track> >(parameters.getParameter<edm::InputTag>("MuonCollection"));
0106 
0107   nTrkBin = parameters.getParameter<int>("nTrkBin");
0108   nTrkMax = parameters.getParameter<int>("nTrkMax");
0109   nTrkMin = parameters.getParameter<int>("nTrkMin");
0110   ptBin = parameters.getParameter<int>("ptBin");
0111   ptMin = parameters.getParameter<double>("ptMin");
0112   ptMax = parameters.getParameter<double>("ptMax");
0113   pBin = parameters.getParameter<int>("pBin");
0114   pMin = parameters.getParameter<double>("pMin");
0115   pMax = parameters.getParameter<double>("pMax");
0116   chi2Bin = parameters.getParameter<int>("chi2Bin");
0117   chi2Min = parameters.getParameter<double>("chi2Min");
0118   chi2Max = parameters.getParameter<double>("chi2Max");
0119   phiBin = parameters.getParameter<int>("phiBin");
0120   phiMin = parameters.getParameter<double>("phiMin");
0121   phiMax = parameters.getParameter<double>("phiMax");
0122   thetaBin = parameters.getParameter<int>("thetaBin");
0123   thetaMin = parameters.getParameter<double>("thetaMin");
0124   thetaMax = parameters.getParameter<double>("thetaMax");
0125   etaBin = parameters.getParameter<int>("etaBin");
0126   etaMin = parameters.getParameter<double>("etaMin");
0127   etaMax = parameters.getParameter<double>("etaMax");
0128   pResBin = parameters.getParameter<int>("pResBin");
0129   pResMin = parameters.getParameter<double>("pResMin");
0130   pResMax = parameters.getParameter<double>("pResMax");
0131 
0132   hitsBin = parameters.getParameter<int>("hitsBin");
0133   hitsMin = parameters.getParameter<int>("hitsMin");
0134   hitsMax = parameters.getParameter<int>("hitsMax");
0135 
0136   theFolder = parameters.getParameter<string>("folder");
0137 }
0138 
0139 CosmicMuonRecoAnalyzer::~CosmicMuonRecoAnalyzer() {}
0140 
0141 void CosmicMuonRecoAnalyzer::bookHistograms(DQMStore::IBooker& ibooker,
0142                                             edm::Run const& /*iRun*/,
0143                                             edm::EventSetup const& /* iSetup */) {
0144   ibooker.cd();
0145   ibooker.setCurrentFolder(theFolder);
0146 
0147   /////////////////////////////////////////////////////
0148   // monitoring of eta parameter
0149   /////////////////////////////////////////////////////
0150   std::string histname = "cosmicMuon";
0151 
0152   nTracksSta = ibooker.book1D(histname + "_traks", "#tracks", nTrkBin, nTrkMin, nTrkMax);
0153 
0154   etaStaTrack = ibooker.book1D(histname + "_eta", "#eta_{STA}", etaBin, etaMin, etaMax);
0155 
0156   //////////////////////////////////////////////////////
0157   // monitoring of theta parameter
0158   /////////////////////////////////////////////////////
0159 
0160   thetaStaTrack = ibooker.book1D(histname + "_theta", "#theta_{STA}", thetaBin, thetaMin, thetaMax);
0161   thetaStaTrack->setAxisTitle("rad");
0162 
0163   // monitoring of phi paramater
0164 
0165   phiStaTrack = ibooker.book1D(histname + "_phi", "#phi_{STA}", phiBin, phiMin, phiMax);
0166   phiStaTrack->setAxisTitle("rad");
0167 
0168   // monitoring of the chi2 parameter
0169 
0170   chi2OvDFStaTrack = ibooker.book1D(histname + "_chi2OverDf", "#chi_{2}OverDF_{STA}", chi2Bin, chi2Min, chi2Max);
0171 
0172   //--------------------------
0173 
0174   probchi2StaTrack = ibooker.book1D(histname + "_probchi", "Prob #chi_{STA}", 120, chi2Min, 1.20);
0175 
0176   // monitoring of the momentum
0177 
0178   pStaTrack = ibooker.book1D(histname + "_p", "p_{STA}", pBin, pMin, pMax);
0179   pStaTrack->setAxisTitle("GeV");
0180 
0181   qOverPStaTrack = ibooker.book1D(histname + "_qoverp", "qoverp_{STA}", pResBin, pResMin, pResMax);
0182   qOverPStaTrack->setAxisTitle("1/GeV");
0183 
0184   qOverPStaTrack_p =
0185       ibooker.book2D(histname + "_qoverp_p", "qoverp_p_{STA}", pBin, pMin, pMax, pResBin, pResMin, pResMax);
0186 
0187   // monitoring of the transverse momentum
0188 
0189   ptStaTrack = ibooker.book1D(histname + "_pt", "pt_{STA}", ptBin, ptMin, pMax);
0190   ptStaTrack->setAxisTitle("GeV");
0191 
0192   // monitoring of the muon charge
0193 
0194   qStaTrack = ibooker.book1D(histname + "_q", "q_{STA}", 5, -2.5, 2.5);
0195 
0196   //////////////////////////////////////////////////////////////
0197   // monitoring of the phi-eta
0198 
0199   phiVsetaStaTrack = ibooker.book2D(
0200       histname + "_phiVseta", "#phi vs #eta (STA)", etaBin / 2, etaMin, etaMax, phiBin / 2, phiMin, phiMax);
0201   phiVsetaStaTrack->setAxisTitle("eta", 1);
0202   phiVsetaStaTrack->setAxisTitle("phi", 2);
0203 
0204   // monitoring the hits
0205   nValidHitsStaTrack = ibooker.book1D(histname + "_nValidHits", "#valid hits (STA)", hitsBin, hitsMin, hitsMax);
0206 
0207   nValidHitsStaTrack_eta = ibooker.book2D(
0208       histname + "_nValidHits_eta", "#valid hits vs eta (STA)", etaBin, etaMin, etaMax, hitsBin, hitsMin, hitsMax);
0209 
0210   nValidHitsStaTrack_phi = ibooker.book2D(
0211       histname + "_nValidHits_phi", "#valid hits vs phi (STA)", phiBin, phiMin, phiMax, hitsBin, hitsMin, hitsMax);
0212 }
0213 
0214 void CosmicMuonRecoAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0215   LogTrace("CosmicMuon") << "[MuonRecoAnalyzer] Analyze the mu";
0216 
0217   // Take the muon container
0218   edm::Handle<edm::View<reco::Track> > muons;
0219   iEvent.getByToken(theMuonCollectionLabel_, muons);
0220 
0221   int nTracks_ = 0;
0222 
0223   if (!muons.isValid())
0224     return;
0225 
0226   for (edm::View<reco::Track>::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
0227     nTracks_++;
0228 
0229     // get the track using only the mu spectrometer data
0230 
0231     etaStaTrack->Fill(muon->eta());
0232     thetaStaTrack->Fill(muon->theta());
0233     phiStaTrack->Fill(muon->phi());
0234     chi2OvDFStaTrack->Fill(muon->normalizedChi2());
0235     probchi2StaTrack->Fill(TMath::Prob(muon->chi2(), muon->ndof()));
0236     pStaTrack->Fill(muon->p());
0237     ptStaTrack->Fill(muon->pt());
0238     qStaTrack->Fill(muon->charge());
0239     qOverPStaTrack->Fill(muon->qoverp());
0240     qOverPStaTrack_p->Fill(muon->p(), muon->qoverp());
0241     phiVsetaStaTrack->Fill(muon->eta(), muon->phi());
0242 
0243     nValidHitsStaTrack->Fill(muon->numberOfValidHits());
0244     nValidHitsStaTrack_eta->Fill(muon->eta(), muon->numberOfValidHits());
0245     nValidHitsStaTrack_phi->Fill(muon->phi(), muon->numberOfValidHits());
0246   }
0247 
0248   nTracksSta->Fill(nTracks_);
0249 }
0250 
0251 DEFINE_FWK_MODULE(CosmicMuonRecoAnalyzer);