CMS 3D CMS Logo

MuonEnergyDepositAnalyzer.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author G. Mila - INFN Torino
5  */
6 
8 
10 
12 
18 
19 #include <cmath>
20 #include <string>
21 using namespace std;
22 using namespace edm;
23 
25  parameters = pSet;
26 
27  // the services
28  theService = new MuonServiceProxy(parameters.getParameter<ParameterSet>("ServiceParameters"));
29 
30  theMuonCollectionLabel_ = consumes<reco::MuonCollection>(parameters.getParameter<InputTag>("MuonCollection"));
31 
32  AlgoName = parameters.getParameter<std::string>("AlgoName");
33  emNoBin = parameters.getParameter<int>("emSizeBin");
34  emNoMin = parameters.getParameter<double>("emSizeMin");
35  emNoMax = parameters.getParameter<double>("emSizeMax");
36 
37  hadNoBin = parameters.getParameter<int>("hadSizeBin");
38  hadNoMin = parameters.getParameter<double>("hadSizeMin");
39  hadNoMax = parameters.getParameter<double>("hadSizeMax");
40 
41  emS9NoBin = parameters.getParameter<int>("emS9SizeBin");
42  emS9NoMin = parameters.getParameter<double>("emS9SizeMin");
43  emS9NoMax = parameters.getParameter<double>("emS9SizeMax");
44 
45  hadS9NoBin = parameters.getParameter<int>("hadS9SizeBin");
46  hadS9NoMin = parameters.getParameter<double>("hadS9SizeMin");
47  hadS9NoMax = parameters.getParameter<double>("hadS9SizeMax");
48 
49  hoNoBin = parameters.getParameter<int>("hoSizeBin");
50  hoNoMin = parameters.getParameter<double>("hoSizeMin");
51  hoNoMax = parameters.getParameter<double>("hoSizeMax");
52 
53  hoS9NoBin = parameters.getParameter<int>("hoS9SizeBin");
54  hoS9NoMin = parameters.getParameter<double>("hoS9SizeMin");
55  hoS9NoMax = parameters.getParameter<double>("hoS9SizeMax");
56 }
58  delete theService;
59 }
61  edm::Run const & /*iRun*/,
62  edm::EventSetup const & /* iSetup */){
63  ibooker.cd();
64  ibooker.setCurrentFolder("Muons/MuonEnergyDepositAnalyzer");
65 
66  std::string histname = "ecalDepositedEnergyBarrel_";
67  ecalDepEnergyBarrel = ibooker.book1D(histname+AlgoName, "Energy deposited in the ECAL barrel cells", emNoBin, emNoMin, emNoMax);
68  ecalDepEnergyBarrel->setAxisTitle("GeV");
69 
70  histname = "ecalDepositedEnergyEndcap_";
71  ecalDepEnergyEndcap = ibooker.book1D(histname+AlgoName, "Energy deposited in the ECAL endcap cells", emNoBin, emNoMin, emNoMax);
72  ecalDepEnergyEndcap->setAxisTitle("GeV");
73 
74  histname = "ecalS9DepositedEnergyBarrel_";
75  ecalS9DepEnergyBarrel = ibooker.book1D(histname+AlgoName, "Energy deposited in the ECAL barrel 3*3 towers", emS9NoBin, emS9NoMin, emS9NoMax);
76  ecalS9DepEnergyBarrel->setAxisTitle("GeV");
77  histname = "ecalS9DepositedEnergyEndcap_";
78  ecalS9DepEnergyEndcap = ibooker.book1D(histname+AlgoName, "Energy deposited in the ECAL endcap 3*3 towers", emS9NoBin, emS9NoMin, emS9NoMax);
79  ecalS9DepEnergyEndcap->setAxisTitle("GeV");
80  histname = "ecalS9PointingMuDepositedEnergy_Glb_";
81  ecalS9PointingMuDepEnergy_Glb = ibooker.book1D(histname+AlgoName, "Pointing glb muons energy deposited in the ECAL 3*3 towers", emS9NoBin, emS9NoMin, emS9NoMax);
82  ecalS9PointingMuDepEnergy_Glb->setAxisTitle("GeV");
83  histname = "ecalS9PointingMuDepositedEnergy_Tk_";
84  ecalS9PointingMuDepEnergy_Tk = ibooker.book1D(histname+AlgoName, "Pointing tk muons energy deposited in the ECAL 3*3 towers", emS9NoBin, emS9NoMin, emS9NoMax);
85  ecalS9PointingMuDepEnergy_Tk->setAxisTitle("GeV");
86  histname = "ecalS9PointingMuDepositedEnergy_Sta_";
87  ecalS9PointingMuDepEnergy_Sta = ibooker.book1D(histname+AlgoName, "Pointing sta muons energy deposited in the ECAL 3*3 towers", emS9NoBin, emS9NoMin, emS9NoMax);
88  ecalS9PointingMuDepEnergy_Sta->setAxisTitle("GeV");
89 
90  histname = "hadDepositedEnergyBarrel_";
91  hcalDepEnergyBarrel = ibooker.book1D(histname+AlgoName, "Energy deposited in the HCAL barrel cells", hadNoBin, hadNoMin, hadNoMax);
92  hcalDepEnergyBarrel->setAxisTitle("GeV");
93  histname = "hadDepositedEnergyEndcap_";
94  hcalDepEnergyEndcap = ibooker.book1D(histname+AlgoName, "Energy deposited in the HCAL endcap cells", hadNoBin, hadNoMin, hadNoMax);
95  hcalDepEnergyEndcap->setAxisTitle("GeV");
96 
97  histname = "hadS9DepositedEnergyBarrel_";
98  hcalS9DepEnergyBarrel = ibooker.book1D(histname+AlgoName, "Energy deposited in the HCAL barrel 3*3 towers", hadS9NoBin, hadS9NoMin, hadS9NoMax);
99  hcalS9DepEnergyBarrel->setAxisTitle("GeV");
100  histname = "hadS9DepositedEnergyEndcap_";
101  hcalS9DepEnergyEndcap = ibooker.book1D(histname+AlgoName, "Energy deposited in the HCAL endcap 3*3 towers", hadS9NoBin, hadS9NoMin, hadS9NoMax);
102  hcalS9DepEnergyEndcap->setAxisTitle("GeV");
103  histname = "hadS9PointingMuDepositedEnergy_Glb_";
104  hcalS9PointingMuDepEnergy_Glb = ibooker.book1D(histname+AlgoName, "Pointing glb muons energy deposited in the HCAL endcap 3*3 towers", hadS9NoBin, hadS9NoMin, hadS9NoMax);
105  hcalS9PointingMuDepEnergy_Glb->setAxisTitle("GeV");
106  histname = "hadS9PointingMuDepositedEnergy_Tk_";
107  hcalS9PointingMuDepEnergy_Tk = ibooker.book1D(histname+AlgoName, "Pointing tk muons energy deposited in the HCAL endcap 3*3 towers", hadS9NoBin, hadS9NoMin, hadS9NoMax);
108  hcalS9PointingMuDepEnergy_Tk->setAxisTitle("GeV");
109  histname = "hadS9PointingMuDepositedEnergy_Sta_";
110  hcalS9PointingMuDepEnergy_Sta = ibooker.book1D(histname+AlgoName, "Pointing sta muons energy deposited in the HCAL endcap 3*3 towers", hadS9NoBin, hadS9NoMin, hadS9NoMax);
111  hcalS9PointingMuDepEnergy_Sta->setAxisTitle("GeV");
112 
113  histname = "hoDepositedEnergy_";
114  hoDepEnergy = ibooker.book1D(histname+AlgoName, "Energy deposited in the HO cells", hoNoBin, hoNoMin, hoNoMax);
115  hoDepEnergy->setAxisTitle("GeV");
116 
117  histname = "hoS9DepositedEnergy_";
118  hoS9DepEnergy = ibooker.book1D(histname+AlgoName, "Energy deposited in the HO 3*3 towers", hoS9NoBin, hoS9NoMin, hoS9NoMax);
119  hoS9DepEnergy->setAxisTitle("GeV");
120  histname = "hoS9PointingMuDepositedEnergy_Glb_";
121  hoS9PointingMuDepEnergy_Glb = ibooker.book1D(histname+AlgoName, "Pointing glb muons energy deposited in the HO 3*3 towers", hoS9NoBin, hoS9NoMin, hoS9NoMax);
122  hoS9PointingMuDepEnergy_Glb->setAxisTitle("GeV");
123  histname = "hoS9PointingMuDepositedEnergy_Tk_";
124  hoS9PointingMuDepEnergy_Tk = ibooker.book1D(histname+AlgoName, "Pointing tk muons energy deposited in the HO 3*3 towers", hoS9NoBin, hoS9NoMin, hoS9NoMax);
125  hoS9PointingMuDepEnergy_Tk->setAxisTitle("GeV");
126  histname = "hoS9PointingMuDepositedEnergy_Sta_";
127  hoS9PointingMuDepEnergy_Sta = ibooker.book1D(histname+AlgoName, "Pointing sta muons energy deposited in the HO 3*3 towers", hoS9NoBin, hoS9NoMin, hoS9NoMax);
128  hoS9PointingMuDepEnergy_Sta->setAxisTitle("GeV");
129 }
131  LogTrace(metname)<<"[MuonEnergyDepositAnalyzer] Filling the histos";
132  theService->update(iSetup);
133 
134  // Take the muon container
136  iEvent.getByToken(theMuonCollectionLabel_,muons);
137 
138  if (!muons.isValid()) return;
139 
140  for (reco::MuonCollection::const_iterator recoMu = muons->begin(); recoMu!=muons->end(); ++recoMu){
141  // get all the mu energy deposits
142  reco::MuonEnergy muEnergy = recoMu->calEnergy();
143 
144  // energy deposited in ECAL
145  LogTrace(metname) << "Energy deposited in ECAL: "<<muEnergy.em;
146  if (fabs(recoMu->eta()) > 1.479)
147  ecalDepEnergyEndcap->Fill(muEnergy.em);
148  else
149  ecalDepEnergyBarrel->Fill(muEnergy.em);
150 
151  // energy deposited in HCAL
152  LogTrace(metname) << "Energy deposited in HCAL: "<<muEnergy.had;
153  if (fabs(recoMu->eta()) > 1.4)
154  hcalDepEnergyEndcap->Fill(muEnergy.had);
155  else
156  hcalDepEnergyBarrel->Fill(muEnergy.had);
157 
158  // energy deposited in HO
159  LogTrace(metname) << "Energy deposited in HO: "<<muEnergy.ho;
160  if (fabs(recoMu->eta()) < 1.26)
161  hoDepEnergy->Fill(muEnergy.ho);
162 
163  // energy deposited in ECAL in 3*3 towers
164  LogTrace(metname) << "Energy deposited in ECAL: "<<muEnergy.emS9;
165  if (fabs(recoMu->eta()) > 1.479)
166  ecalS9DepEnergyEndcap->Fill(muEnergy.emS9);
167  else
168  ecalS9DepEnergyBarrel->Fill(muEnergy.emS9);
169 
170  // energy deposited in HCAL in 3*3 crystals
171  LogTrace(metname) << "Energy deposited in HCAL: "<<muEnergy.hadS9;
172  if (fabs(recoMu->eta()) > 1.4)
173  hcalS9DepEnergyEndcap->Fill(muEnergy.hadS9);
174  else
175  hcalS9DepEnergyBarrel->Fill(muEnergy.hadS9);
176 
177  // energy deposited in HO in 3*3 crystals
178  LogTrace(metname) << "Energy deposited in HO: "<<muEnergy.hoS9;
179  if (fabs(recoMu->eta()) < 1.26)
180  hoS9DepEnergy->Fill(muEnergy.hoS9);
181 
182  // plot for energy tests
184  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theB);
185  reco::TransientTrack TransTrack;
186 
187  if(recoMu->isGlobalMuon())
188  TransTrack = theB->build(recoMu->globalTrack());
189  else if((recoMu->isTrackerMuon() || recoMu->isRPCMuon()))
190  TransTrack = theB->build(recoMu->innerTrack());
191  else if(recoMu->isStandAloneMuon())
192  TransTrack = theB->build(recoMu->outerTrack());
193  else
194  continue;
195 
197  TSOS = TransTrack.impactPointState();
198  // section for vertex pointing muon
199  if((abs(TSOS.globalPosition().z())<30) && (abs(TSOS.globalPosition().perp())<20)){
200  // GLB muon
201  if(recoMu->isGlobalMuon()){
202  ecalS9PointingMuDepEnergy_Glb->Fill(muEnergy.emS9);
203  hcalS9PointingMuDepEnergy_Glb->Fill(muEnergy.hadS9);
204  hoS9PointingMuDepEnergy_Glb->Fill(muEnergy.hoS9);
205  }
206  // TK muon
207  else if(recoMu->isTrackerMuon()){
208  ecalS9PointingMuDepEnergy_Tk->Fill(muEnergy.emS9);
209  hcalS9PointingMuDepEnergy_Tk->Fill(muEnergy.hadS9);
210  hoS9PointingMuDepEnergy_Tk->Fill(muEnergy.hoS9);
211  }
212  // STA muon
213  else if(recoMu->isStandAloneMuon()){
214  ecalS9PointingMuDepEnergy_Sta->Fill(muEnergy.emS9);
215  hcalS9PointingMuDepEnergy_Sta->Fill(muEnergy.hadS9);
216  hoS9PointingMuDepEnergy_Sta->Fill(muEnergy.hoS9);
217  }
218  }
219  }
220 
221 }
222 
223 
MuonEnergyDepositAnalyzer(const edm::ParameterSet &)
Constructor.
T perp() const
Definition: PV3DBase.h:72
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
const std::string metname
void cd(void)
Definition: DQMStore.cc:269
reco::TransientTrack build(const reco::Track *p) const
~MuonEnergyDepositAnalyzer() override
Destructor.
float emS9
energy deposited in 3x3 ECAL crystal shape around central crystal
Definition: MuonEnergy.h:18
GlobalPoint globalPosition() const
float ho
energy deposited in crossed HO towers
Definition: MuonEnergy.h:32
int iEvent
Definition: GenABIO.cc:230
T z() const
Definition: PV3DBase.h:64
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float hoS9
energy deposited in 3x3 HO tower shape around central tower
Definition: MuonEnergy.h:34
bool isValid() const
Definition: HandleBase.h:74
#define LogTrace(id)
TrajectoryStateOnSurface TSOS
Definition: TestHits.cc:19
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
const T & get() const
Definition: EventSetup.h:55
HLT enums.
TrajectoryStateOnSurface impactPointState() const
void analyze(const edm::Event &, const edm::EventSetup &) override
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
float hadS9
energy deposited in 3x3 HCAL tower shape around central tower
Definition: MuonEnergy.h:28
Definition: Run.h:43
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override