Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-05-25 06:38:29

0001 /*
0002  *  See header file for a description of this class.
0003  *
0004  *  \author G. Mila - INFN Torino
0005  */
0006 
0007 #include "DQMOffline/Muon/interface/MuonEnergyDepositAnalyzer.h"
0008 
0009 #include "DataFormats/Common/interface/Handle.h"
0010 
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 
0013 #include "DataFormats/TrackReco/interface/Track.h"
0014 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0015 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
0016 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
0017 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
0018 
0019 #include <cmath>
0020 #include <string>
0021 using namespace std;
0022 using namespace edm;
0023 
0024 MuonEnergyDepositAnalyzer::MuonEnergyDepositAnalyzer(const edm::ParameterSet& pSet)
0025     : trasientTrackToken_(
0026           esConsumes<TransientTrackBuilder, TransientTrackRecord>(edm::ESInputTag("", "TransientTrackBuilder"))) {
0027   parameters = pSet;
0028 
0029   theMuonCollectionLabel_ = consumes<reco::MuonCollection>(parameters.getParameter<InputTag>("MuonCollection"));
0030 
0031   AlgoName = parameters.getParameter<std::string>("AlgoName");
0032   emNoBin = parameters.getParameter<int>("emSizeBin");
0033   emNoMin = parameters.getParameter<double>("emSizeMin");
0034   emNoMax = parameters.getParameter<double>("emSizeMax");
0035 
0036   hadNoBin = parameters.getParameter<int>("hadSizeBin");
0037   hadNoMin = parameters.getParameter<double>("hadSizeMin");
0038   hadNoMax = parameters.getParameter<double>("hadSizeMax");
0039 
0040   emS9NoBin = parameters.getParameter<int>("emS9SizeBin");
0041   emS9NoMin = parameters.getParameter<double>("emS9SizeMin");
0042   emS9NoMax = parameters.getParameter<double>("emS9SizeMax");
0043 
0044   hadS9NoBin = parameters.getParameter<int>("hadS9SizeBin");
0045   hadS9NoMin = parameters.getParameter<double>("hadS9SizeMin");
0046   hadS9NoMax = parameters.getParameter<double>("hadS9SizeMax");
0047 
0048   hoNoBin = parameters.getParameter<int>("hoSizeBin");
0049   hoNoMin = parameters.getParameter<double>("hoSizeMin");
0050   hoNoMax = parameters.getParameter<double>("hoSizeMax");
0051 
0052   hoS9NoBin = parameters.getParameter<int>("hoS9SizeBin");
0053   hoS9NoMin = parameters.getParameter<double>("hoS9SizeMin");
0054   hoS9NoMax = parameters.getParameter<double>("hoS9SizeMax");
0055 }
0056 MuonEnergyDepositAnalyzer::~MuonEnergyDepositAnalyzer() {}
0057 void MuonEnergyDepositAnalyzer::bookHistograms(DQMStore::IBooker& ibooker,
0058                                                edm::Run const& /*iRun*/,
0059                                                edm::EventSetup const& /* iSetup */) {
0060   ibooker.cd();
0061   ibooker.setCurrentFolder("Muons/MuonEnergyDepositAnalyzer");
0062 
0063   std::string histname = "ecalDepositedEnergyBarrel_";
0064   ecalDepEnergyBarrel =
0065       ibooker.book1D(histname + AlgoName, "Energy deposited in the ECAL barrel cells", emNoBin, emNoMin, emNoMax);
0066   ecalDepEnergyBarrel->setAxisTitle("GeV");
0067 
0068   histname = "ecalDepositedEnergyEndcap_";
0069   ecalDepEnergyEndcap =
0070       ibooker.book1D(histname + AlgoName, "Energy deposited in the ECAL endcap cells", emNoBin, emNoMin, emNoMax);
0071   ecalDepEnergyEndcap->setAxisTitle("GeV");
0072 
0073   histname = "ecalS9DepositedEnergyBarrel_";
0074   ecalS9DepEnergyBarrel = ibooker.book1D(
0075       histname + AlgoName, "Energy deposited in the ECAL barrel 3*3 towers", emS9NoBin, emS9NoMin, emS9NoMax);
0076   ecalS9DepEnergyBarrel->setAxisTitle("GeV");
0077   histname = "ecalS9DepositedEnergyEndcap_";
0078   ecalS9DepEnergyEndcap = ibooker.book1D(
0079       histname + AlgoName, "Energy deposited in the ECAL endcap 3*3 towers", emS9NoBin, emS9NoMin, emS9NoMax);
0080   ecalS9DepEnergyEndcap->setAxisTitle("GeV");
0081   histname = "ecalS9PointingMuDepositedEnergy_Glb_";
0082   ecalS9PointingMuDepEnergy_Glb = ibooker.book1D(histname + AlgoName,
0083                                                  "Pointing glb muons energy deposited in the ECAL 3*3 towers",
0084                                                  emS9NoBin,
0085                                                  emS9NoMin,
0086                                                  emS9NoMax);
0087   ecalS9PointingMuDepEnergy_Glb->setAxisTitle("GeV");
0088   histname = "ecalS9PointingMuDepositedEnergy_Tk_";
0089   ecalS9PointingMuDepEnergy_Tk = ibooker.book1D(
0090       histname + AlgoName, "Pointing tk muons energy deposited in the ECAL 3*3 towers", emS9NoBin, emS9NoMin, emS9NoMax);
0091   ecalS9PointingMuDepEnergy_Tk->setAxisTitle("GeV");
0092   histname = "ecalS9PointingMuDepositedEnergy_Sta_";
0093   ecalS9PointingMuDepEnergy_Sta = ibooker.book1D(histname + AlgoName,
0094                                                  "Pointing sta muons energy deposited in the ECAL 3*3 towers",
0095                                                  emS9NoBin,
0096                                                  emS9NoMin,
0097                                                  emS9NoMax);
0098   ecalS9PointingMuDepEnergy_Sta->setAxisTitle("GeV");
0099 
0100   histname = "hadDepositedEnergyBarrel_";
0101   hcalDepEnergyBarrel =
0102       ibooker.book1D(histname + AlgoName, "Energy deposited in the HCAL barrel cells", hadNoBin, hadNoMin, hadNoMax);
0103   hcalDepEnergyBarrel->setAxisTitle("GeV");
0104   histname = "hadDepositedEnergyEndcap_";
0105   hcalDepEnergyEndcap =
0106       ibooker.book1D(histname + AlgoName, "Energy deposited in the HCAL endcap cells", hadNoBin, hadNoMin, hadNoMax);
0107   hcalDepEnergyEndcap->setAxisTitle("GeV");
0108 
0109   histname = "hadS9DepositedEnergyBarrel_";
0110   hcalS9DepEnergyBarrel = ibooker.book1D(
0111       histname + AlgoName, "Energy deposited in the HCAL barrel 3*3 towers", hadS9NoBin, hadS9NoMin, hadS9NoMax);
0112   hcalS9DepEnergyBarrel->setAxisTitle("GeV");
0113   histname = "hadS9DepositedEnergyEndcap_";
0114   hcalS9DepEnergyEndcap = ibooker.book1D(
0115       histname + AlgoName, "Energy deposited in the HCAL endcap 3*3 towers", hadS9NoBin, hadS9NoMin, hadS9NoMax);
0116   hcalS9DepEnergyEndcap->setAxisTitle("GeV");
0117   histname = "hadS9PointingMuDepositedEnergy_Glb_";
0118   hcalS9PointingMuDepEnergy_Glb = ibooker.book1D(histname + AlgoName,
0119                                                  "Pointing glb muons energy deposited in the HCAL endcap 3*3 towers",
0120                                                  hadS9NoBin,
0121                                                  hadS9NoMin,
0122                                                  hadS9NoMax);
0123   hcalS9PointingMuDepEnergy_Glb->setAxisTitle("GeV");
0124   histname = "hadS9PointingMuDepositedEnergy_Tk_";
0125   hcalS9PointingMuDepEnergy_Tk = ibooker.book1D(histname + AlgoName,
0126                                                 "Pointing tk muons energy deposited in the HCAL endcap 3*3 towers",
0127                                                 hadS9NoBin,
0128                                                 hadS9NoMin,
0129                                                 hadS9NoMax);
0130   hcalS9PointingMuDepEnergy_Tk->setAxisTitle("GeV");
0131   histname = "hadS9PointingMuDepositedEnergy_Sta_";
0132   hcalS9PointingMuDepEnergy_Sta = ibooker.book1D(histname + AlgoName,
0133                                                  "Pointing sta muons energy deposited in the HCAL endcap 3*3 towers",
0134                                                  hadS9NoBin,
0135                                                  hadS9NoMin,
0136                                                  hadS9NoMax);
0137   hcalS9PointingMuDepEnergy_Sta->setAxisTitle("GeV");
0138 
0139   histname = "hoDepositedEnergy_";
0140   hoDepEnergy = ibooker.book1D(histname + AlgoName, "Energy deposited in the HO cells", hoNoBin, hoNoMin, hoNoMax);
0141   hoDepEnergy->setAxisTitle("GeV");
0142 
0143   histname = "hoS9DepositedEnergy_";
0144   hoS9DepEnergy =
0145       ibooker.book1D(histname + AlgoName, "Energy deposited in the HO 3*3 towers", hoS9NoBin, hoS9NoMin, hoS9NoMax);
0146   hoS9DepEnergy->setAxisTitle("GeV");
0147   histname = "hoS9PointingMuDepositedEnergy_Glb_";
0148   hoS9PointingMuDepEnergy_Glb = ibooker.book1D(
0149       histname + AlgoName, "Pointing glb muons energy deposited in the HO 3*3 towers", hoS9NoBin, hoS9NoMin, hoS9NoMax);
0150   hoS9PointingMuDepEnergy_Glb->setAxisTitle("GeV");
0151   histname = "hoS9PointingMuDepositedEnergy_Tk_";
0152   hoS9PointingMuDepEnergy_Tk = ibooker.book1D(
0153       histname + AlgoName, "Pointing tk muons energy deposited in the HO 3*3 towers", hoS9NoBin, hoS9NoMin, hoS9NoMax);
0154   hoS9PointingMuDepEnergy_Tk->setAxisTitle("GeV");
0155   histname = "hoS9PointingMuDepositedEnergy_Sta_";
0156   hoS9PointingMuDepEnergy_Sta = ibooker.book1D(
0157       histname + AlgoName, "Pointing sta muons energy deposited in the HO 3*3 towers", hoS9NoBin, hoS9NoMin, hoS9NoMax);
0158   hoS9PointingMuDepEnergy_Sta->setAxisTitle("GeV");
0159 }
0160 void MuonEnergyDepositAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0161   LogTrace(metname) << "[MuonEnergyDepositAnalyzer] Filling the histos";
0162 
0163   // Take the muon container
0164   edm::Handle<reco::MuonCollection> muons;
0165   iEvent.getByToken(theMuonCollectionLabel_, muons);
0166 
0167   if (!muons.isValid())
0168     return;
0169 
0170   for (reco::MuonCollection::const_iterator recoMu = muons->begin(); recoMu != muons->end(); ++recoMu) {
0171     // get all the mu energy deposits
0172     reco::MuonEnergy muEnergy = recoMu->calEnergy();
0173 
0174     // energy deposited in ECAL
0175     LogTrace(metname) << "Energy deposited in ECAL: " << muEnergy.em;
0176     if (fabs(recoMu->eta()) > 1.479)
0177       ecalDepEnergyEndcap->Fill(muEnergy.em);
0178     else
0179       ecalDepEnergyBarrel->Fill(muEnergy.em);
0180 
0181     // energy deposited in HCAL
0182     LogTrace(metname) << "Energy deposited in HCAL: " << muEnergy.had;
0183     if (fabs(recoMu->eta()) > 1.4)
0184       hcalDepEnergyEndcap->Fill(muEnergy.had);
0185     else
0186       hcalDepEnergyBarrel->Fill(muEnergy.had);
0187 
0188     // energy deposited in HO
0189     LogTrace(metname) << "Energy deposited in HO: " << muEnergy.ho;
0190     if (fabs(recoMu->eta()) < 1.26)
0191       hoDepEnergy->Fill(muEnergy.ho);
0192 
0193     // energy deposited in ECAL in 3*3 towers
0194     LogTrace(metname) << "Energy deposited in ECAL: " << muEnergy.emS9;
0195     if (fabs(recoMu->eta()) > 1.479)
0196       ecalS9DepEnergyEndcap->Fill(muEnergy.emS9);
0197     else
0198       ecalS9DepEnergyBarrel->Fill(muEnergy.emS9);
0199 
0200     // energy deposited in HCAL in 3*3 crystals
0201     LogTrace(metname) << "Energy deposited in HCAL: " << muEnergy.hadS9;
0202     if (fabs(recoMu->eta()) > 1.4)
0203       hcalS9DepEnergyEndcap->Fill(muEnergy.hadS9);
0204     else
0205       hcalS9DepEnergyBarrel->Fill(muEnergy.hadS9);
0206 
0207     // energy deposited in HO in 3*3 crystals
0208     LogTrace(metname) << "Energy deposited in HO: " << muEnergy.hoS9;
0209     if (fabs(recoMu->eta()) < 1.26)
0210       hoS9DepEnergy->Fill(muEnergy.hoS9);
0211 
0212     // plot for energy tests
0213 
0214     theB = iSetup.getHandle(trasientTrackToken_);
0215 
0216     reco::TransientTrack TransTrack;
0217 
0218     if (recoMu->isGlobalMuon())
0219       TransTrack = theB->build(recoMu->globalTrack());
0220     else if ((recoMu->isTrackerMuon() || recoMu->isRPCMuon()))
0221       TransTrack = theB->build(recoMu->innerTrack());
0222     else if (recoMu->isStandAloneMuon())
0223       TransTrack = theB->build(recoMu->outerTrack());
0224     else
0225       continue;
0226 
0227     TrajectoryStateOnSurface TSOS;
0228     TSOS = TransTrack.impactPointState();
0229     // section for vertex pointing muon
0230     if ((abs(TSOS.globalPosition().z()) < 30) && (abs(TSOS.globalPosition().perp()) < 20)) {
0231       // GLB muon
0232       if (recoMu->isGlobalMuon()) {
0233         ecalS9PointingMuDepEnergy_Glb->Fill(muEnergy.emS9);
0234         hcalS9PointingMuDepEnergy_Glb->Fill(muEnergy.hadS9);
0235         hoS9PointingMuDepEnergy_Glb->Fill(muEnergy.hoS9);
0236       }
0237       // TK muon
0238       else if (recoMu->isTrackerMuon()) {
0239         ecalS9PointingMuDepEnergy_Tk->Fill(muEnergy.emS9);
0240         hcalS9PointingMuDepEnergy_Tk->Fill(muEnergy.hadS9);
0241         hoS9PointingMuDepEnergy_Tk->Fill(muEnergy.hoS9);
0242       }
0243       // STA muon
0244       else if (recoMu->isStandAloneMuon()) {
0245         ecalS9PointingMuDepEnergy_Sta->Fill(muEnergy.emS9);
0246         hcalS9PointingMuDepEnergy_Sta->Fill(muEnergy.hadS9);
0247         hoS9PointingMuDepEnergy_Sta->Fill(muEnergy.hoS9);
0248       }
0249     }
0250   }
0251 }