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 }
59  edm::Run const& /*iRun*/,
60  edm::EventSetup const& /* iSetup */) {
61  ibooker.cd();
62  ibooker.setCurrentFolder("Muons/MuonEnergyDepositAnalyzer");
63 
64  std::string histname = "ecalDepositedEnergyBarrel_";
65  ecalDepEnergyBarrel =
66  ibooker.book1D(histname + AlgoName, "Energy deposited in the ECAL barrel cells", emNoBin, emNoMin, emNoMax);
67  ecalDepEnergyBarrel->setAxisTitle("GeV");
68 
69  histname = "ecalDepositedEnergyEndcap_";
70  ecalDepEnergyEndcap =
71  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(
76  histname + AlgoName, "Energy deposited in the ECAL barrel 3*3 towers", emS9NoBin, emS9NoMin, emS9NoMax);
77  ecalS9DepEnergyBarrel->setAxisTitle("GeV");
78  histname = "ecalS9DepositedEnergyEndcap_";
79  ecalS9DepEnergyEndcap = ibooker.book1D(
80  histname + AlgoName, "Energy deposited in the ECAL endcap 3*3 towers", emS9NoBin, emS9NoMin, emS9NoMax);
81  ecalS9DepEnergyEndcap->setAxisTitle("GeV");
82  histname = "ecalS9PointingMuDepositedEnergy_Glb_";
83  ecalS9PointingMuDepEnergy_Glb = ibooker.book1D(histname + AlgoName,
84  "Pointing glb muons energy deposited in the ECAL 3*3 towers",
85  emS9NoBin,
86  emS9NoMin,
87  emS9NoMax);
88  ecalS9PointingMuDepEnergy_Glb->setAxisTitle("GeV");
89  histname = "ecalS9PointingMuDepositedEnergy_Tk_";
90  ecalS9PointingMuDepEnergy_Tk = ibooker.book1D(
91  histname + AlgoName, "Pointing tk muons energy deposited in the ECAL 3*3 towers", emS9NoBin, emS9NoMin, emS9NoMax);
92  ecalS9PointingMuDepEnergy_Tk->setAxisTitle("GeV");
93  histname = "ecalS9PointingMuDepositedEnergy_Sta_";
94  ecalS9PointingMuDepEnergy_Sta = ibooker.book1D(histname + AlgoName,
95  "Pointing sta muons energy deposited in the ECAL 3*3 towers",
96  emS9NoBin,
97  emS9NoMin,
98  emS9NoMax);
99  ecalS9PointingMuDepEnergy_Sta->setAxisTitle("GeV");
100 
101  histname = "hadDepositedEnergyBarrel_";
102  hcalDepEnergyBarrel =
103  ibooker.book1D(histname + AlgoName, "Energy deposited in the HCAL barrel cells", hadNoBin, hadNoMin, hadNoMax);
104  hcalDepEnergyBarrel->setAxisTitle("GeV");
105  histname = "hadDepositedEnergyEndcap_";
106  hcalDepEnergyEndcap =
107  ibooker.book1D(histname + AlgoName, "Energy deposited in the HCAL endcap cells", hadNoBin, hadNoMin, hadNoMax);
108  hcalDepEnergyEndcap->setAxisTitle("GeV");
109 
110  histname = "hadS9DepositedEnergyBarrel_";
111  hcalS9DepEnergyBarrel = ibooker.book1D(
112  histname + AlgoName, "Energy deposited in the HCAL barrel 3*3 towers", hadS9NoBin, hadS9NoMin, hadS9NoMax);
113  hcalS9DepEnergyBarrel->setAxisTitle("GeV");
114  histname = "hadS9DepositedEnergyEndcap_";
115  hcalS9DepEnergyEndcap = ibooker.book1D(
116  histname + AlgoName, "Energy deposited in the HCAL endcap 3*3 towers", hadS9NoBin, hadS9NoMin, hadS9NoMax);
117  hcalS9DepEnergyEndcap->setAxisTitle("GeV");
118  histname = "hadS9PointingMuDepositedEnergy_Glb_";
119  hcalS9PointingMuDepEnergy_Glb = ibooker.book1D(histname + AlgoName,
120  "Pointing glb muons energy deposited in the HCAL endcap 3*3 towers",
121  hadS9NoBin,
122  hadS9NoMin,
123  hadS9NoMax);
124  hcalS9PointingMuDepEnergy_Glb->setAxisTitle("GeV");
125  histname = "hadS9PointingMuDepositedEnergy_Tk_";
126  hcalS9PointingMuDepEnergy_Tk = ibooker.book1D(histname + AlgoName,
127  "Pointing tk muons energy deposited in the HCAL endcap 3*3 towers",
128  hadS9NoBin,
129  hadS9NoMin,
130  hadS9NoMax);
131  hcalS9PointingMuDepEnergy_Tk->setAxisTitle("GeV");
132  histname = "hadS9PointingMuDepositedEnergy_Sta_";
133  hcalS9PointingMuDepEnergy_Sta = ibooker.book1D(histname + AlgoName,
134  "Pointing sta muons energy deposited in the HCAL endcap 3*3 towers",
135  hadS9NoBin,
136  hadS9NoMin,
137  hadS9NoMax);
138  hcalS9PointingMuDepEnergy_Sta->setAxisTitle("GeV");
139 
140  histname = "hoDepositedEnergy_";
141  hoDepEnergy = ibooker.book1D(histname + AlgoName, "Energy deposited in the HO cells", hoNoBin, hoNoMin, hoNoMax);
142  hoDepEnergy->setAxisTitle("GeV");
143 
144  histname = "hoS9DepositedEnergy_";
145  hoS9DepEnergy =
146  ibooker.book1D(histname + AlgoName, "Energy deposited in the HO 3*3 towers", hoS9NoBin, hoS9NoMin, hoS9NoMax);
147  hoS9DepEnergy->setAxisTitle("GeV");
148  histname = "hoS9PointingMuDepositedEnergy_Glb_";
149  hoS9PointingMuDepEnergy_Glb = ibooker.book1D(
150  histname + AlgoName, "Pointing glb muons energy deposited in the HO 3*3 towers", hoS9NoBin, hoS9NoMin, hoS9NoMax);
151  hoS9PointingMuDepEnergy_Glb->setAxisTitle("GeV");
152  histname = "hoS9PointingMuDepositedEnergy_Tk_";
153  hoS9PointingMuDepEnergy_Tk = ibooker.book1D(
154  histname + AlgoName, "Pointing tk muons energy deposited in the HO 3*3 towers", hoS9NoBin, hoS9NoMin, hoS9NoMax);
155  hoS9PointingMuDepEnergy_Tk->setAxisTitle("GeV");
156  histname = "hoS9PointingMuDepositedEnergy_Sta_";
157  hoS9PointingMuDepEnergy_Sta = ibooker.book1D(
158  histname + AlgoName, "Pointing sta muons energy deposited in the HO 3*3 towers", hoS9NoBin, hoS9NoMin, hoS9NoMax);
159  hoS9PointingMuDepEnergy_Sta->setAxisTitle("GeV");
160 }
162  LogTrace(metname) << "[MuonEnergyDepositAnalyzer] Filling the histos";
163  theService->update(iSetup);
164 
165  // Take the muon container
167  iEvent.getByToken(theMuonCollectionLabel_, muons);
168 
169  if (!muons.isValid())
170  return;
171 
172  for (reco::MuonCollection::const_iterator recoMu = muons->begin(); recoMu != muons->end(); ++recoMu) {
173  // get all the mu energy deposits
174  reco::MuonEnergy muEnergy = recoMu->calEnergy();
175 
176  // energy deposited in ECAL
177  LogTrace(metname) << "Energy deposited in ECAL: " << muEnergy.em;
178  if (fabs(recoMu->eta()) > 1.479)
179  ecalDepEnergyEndcap->Fill(muEnergy.em);
180  else
181  ecalDepEnergyBarrel->Fill(muEnergy.em);
182 
183  // energy deposited in HCAL
184  LogTrace(metname) << "Energy deposited in HCAL: " << muEnergy.had;
185  if (fabs(recoMu->eta()) > 1.4)
186  hcalDepEnergyEndcap->Fill(muEnergy.had);
187  else
188  hcalDepEnergyBarrel->Fill(muEnergy.had);
189 
190  // energy deposited in HO
191  LogTrace(metname) << "Energy deposited in HO: " << muEnergy.ho;
192  if (fabs(recoMu->eta()) < 1.26)
193  hoDepEnergy->Fill(muEnergy.ho);
194 
195  // energy deposited in ECAL in 3*3 towers
196  LogTrace(metname) << "Energy deposited in ECAL: " << muEnergy.emS9;
197  if (fabs(recoMu->eta()) > 1.479)
198  ecalS9DepEnergyEndcap->Fill(muEnergy.emS9);
199  else
200  ecalS9DepEnergyBarrel->Fill(muEnergy.emS9);
201 
202  // energy deposited in HCAL in 3*3 crystals
203  LogTrace(metname) << "Energy deposited in HCAL: " << muEnergy.hadS9;
204  if (fabs(recoMu->eta()) > 1.4)
205  hcalS9DepEnergyEndcap->Fill(muEnergy.hadS9);
206  else
207  hcalS9DepEnergyBarrel->Fill(muEnergy.hadS9);
208 
209  // energy deposited in HO in 3*3 crystals
210  LogTrace(metname) << "Energy deposited in HO: " << muEnergy.hoS9;
211  if (fabs(recoMu->eta()) < 1.26)
212  hoS9DepEnergy->Fill(muEnergy.hoS9);
213 
214  // plot for energy tests
216  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", theB);
217  reco::TransientTrack TransTrack;
218 
219  if (recoMu->isGlobalMuon())
220  TransTrack = theB->build(recoMu->globalTrack());
221  else if ((recoMu->isTrackerMuon() || recoMu->isRPCMuon()))
222  TransTrack = theB->build(recoMu->innerTrack());
223  else if (recoMu->isStandAloneMuon())
224  TransTrack = theB->build(recoMu->outerTrack());
225  else
226  continue;
227 
229  TSOS = TransTrack.impactPointState();
230  // section for vertex pointing muon
231  if ((abs(TSOS.globalPosition().z()) < 30) && (abs(TSOS.globalPosition().perp()) < 20)) {
232  // GLB muon
233  if (recoMu->isGlobalMuon()) {
234  ecalS9PointingMuDepEnergy_Glb->Fill(muEnergy.emS9);
235  hcalS9PointingMuDepEnergy_Glb->Fill(muEnergy.hadS9);
236  hoS9PointingMuDepEnergy_Glb->Fill(muEnergy.hoS9);
237  }
238  // TK muon
239  else if (recoMu->isTrackerMuon()) {
240  ecalS9PointingMuDepEnergy_Tk->Fill(muEnergy.emS9);
241  hcalS9PointingMuDepEnergy_Tk->Fill(muEnergy.hadS9);
242  hoS9PointingMuDepEnergy_Tk->Fill(muEnergy.hoS9);
243  }
244  // STA muon
245  else if (recoMu->isStandAloneMuon()) {
246  ecalS9PointingMuDepEnergy_Sta->Fill(muEnergy.emS9);
247  hcalS9PointingMuDepEnergy_Sta->Fill(muEnergy.hadS9);
248  hoS9PointingMuDepEnergy_Sta->Fill(muEnergy.hoS9);
249  }
250  }
251  }
252 }
MuonEnergyDepositAnalyzer(const edm::ParameterSet &)
Constructor.
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
Definition: DQMStore.cc:239
T perp() const
Definition: PV3DBase.h:69
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
const std::string metname
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:418
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:28
GlobalPoint globalPosition() const
float ho
energy deposited in crossed HO towers
Definition: MuonEnergy.h:42
int iEvent
Definition: GenABIO.cc:224
T z() const
Definition: PV3DBase.h:61
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:44
bool isValid() const
Definition: HandleBase.h:70
#define LogTrace(id)
TrajectoryStateOnSurface TSOS
Definition: TestHits.cc:19
HLT enums.
T get() const
Definition: EventSetup.h:73
TrajectoryStateOnSurface impactPointState() const
void analyze(const edm::Event &, const edm::EventSetup &) override
float hadS9
energy deposited in 3x3 HCAL tower shape around central tower
Definition: MuonEnergy.h:38
Definition: Run.h:45
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)