CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  theDbe = edm::Service<DQMStore>().operator->();
28 
29  // the services
30  theService = new MuonServiceProxy(parameters.getParameter<ParameterSet>("ServiceParameters"));
31 
32  theMuonCollectionLabel_ = consumes<reco::MuonCollection>(parameters.getParameter<InputTag>("MuonCollection"));
33 }
34 
35 
37  delete theService;
38 }
39 
40 
42  metname = "muEnergyDepositAnalyzer";
43 }
44 
46  std::string AlgoName = parameters.getParameter<std::string>("AlgoName");
47 
48  theDbe->cd();
49  theDbe->setCurrentFolder("Muons/MuonEnergyDepositAnalyzer");
50 
51  LogTrace(metname)<<"[MuonEnergyDepositAnalyzer] Parameters initialization";
52  LogTrace(metname)<<"[MuonEnergyDepositAnalyzer] Run, Event" << iRun << " , "<< iSetup;
53 
54  emNoBin = parameters.getParameter<int>("emSizeBin");
55  emNoMin = parameters.getParameter<double>("emSizeMin");
56  emNoMax = parameters.getParameter<double>("emSizeMax");
57 
58  hadNoBin = parameters.getParameter<int>("hadSizeBin");
59  hadNoMin = parameters.getParameter<double>("hadSizeMin");
60  hadNoMax = parameters.getParameter<double>("hadSizeMax");
61 
62  emS9NoBin = parameters.getParameter<int>("emS9SizeBin");
63  emS9NoMin = parameters.getParameter<double>("emS9SizeMin");
64  emS9NoMax = parameters.getParameter<double>("emS9SizeMax");
65 
66  hadS9NoBin = parameters.getParameter<int>("hadS9SizeBin");
67  hadS9NoMin = parameters.getParameter<double>("hadS9SizeMin");
68  hadS9NoMax = parameters.getParameter<double>("hadS9SizeMax");
69 
70  hoNoBin = parameters.getParameter<int>("hoSizeBin");
71  hoNoMin = parameters.getParameter<double>("hoSizeMin");
72  hoNoMax = parameters.getParameter<double>("hoSizeMax");
73 
74  hoS9NoBin = parameters.getParameter<int>("hoS9SizeBin");
75  hoS9NoMin = parameters.getParameter<double>("hoS9SizeMin");
76  hoS9NoMax = parameters.getParameter<double>("hoS9SizeMax");
77 
78  std::string histname = "ecalDepositedEnergyBarrel_";
79  ecalDepEnergyBarrel = theDbe->book1D(histname+AlgoName, "Energy deposited in the ECAL barrel cells", emNoBin, emNoMin, emNoMax);
80  ecalDepEnergyBarrel->setAxisTitle("GeV");
81 
82  histname = "ecalDepositedEnergyEndcap_";
83  ecalDepEnergyEndcap = theDbe->book1D(histname+AlgoName, "Energy deposited in the ECAL endcap cells", emNoBin, emNoMin, emNoMax);
84  ecalDepEnergyEndcap->setAxisTitle("GeV");
85 
86  histname = "ecalS9DepositedEnergyBarrel_";
87  ecalS9DepEnergyBarrel = theDbe->book1D(histname+AlgoName, "Energy deposited in the ECAL barrel 3*3 towers", emS9NoBin, emS9NoMin, emS9NoMax);
88  ecalS9DepEnergyBarrel->setAxisTitle("GeV");
89  histname = "ecalS9DepositedEnergyEndcap_";
90  ecalS9DepEnergyEndcap = theDbe->book1D(histname+AlgoName, "Energy deposited in the ECAL endcap 3*3 towers", emS9NoBin, emS9NoMin, emS9NoMax);
91  ecalS9DepEnergyEndcap->setAxisTitle("GeV");
92  histname = "ecalS9PointingMuDepositedEnergy_Glb_";
93  ecalS9PointingMuDepEnergy_Glb = theDbe->book1D(histname+AlgoName, "Pointing glb muons energy deposited in the ECAL 3*3 towers", emS9NoBin, emS9NoMin, emS9NoMax);
94  ecalS9PointingMuDepEnergy_Glb->setAxisTitle("GeV");
95  histname = "ecalS9PointingMuDepositedEnergy_Tk_";
96  ecalS9PointingMuDepEnergy_Tk = theDbe->book1D(histname+AlgoName, "Pointing tk muons energy deposited in the ECAL 3*3 towers", emS9NoBin, emS9NoMin, emS9NoMax);
97  ecalS9PointingMuDepEnergy_Tk->setAxisTitle("GeV");
98  histname = "ecalS9PointingMuDepositedEnergy_Sta_";
99  ecalS9PointingMuDepEnergy_Sta = theDbe->book1D(histname+AlgoName, "Pointing sta muons energy deposited in the ECAL 3*3 towers", emS9NoBin, emS9NoMin, emS9NoMax);
100  ecalS9PointingMuDepEnergy_Sta->setAxisTitle("GeV");
101 
102  histname = "hadDepositedEnergyBarrel_";
103  hcalDepEnergyBarrel = theDbe->book1D(histname+AlgoName, "Energy deposited in the HCAL barrel cells", hadNoBin, hadNoMin, hadNoMax);
104  hcalDepEnergyBarrel->setAxisTitle("GeV");
105  histname = "hadDepositedEnergyEndcap_";
106  hcalDepEnergyEndcap = theDbe->book1D(histname+AlgoName, "Energy deposited in the HCAL endcap cells", hadNoBin, hadNoMin, hadNoMax);
107  hcalDepEnergyEndcap->setAxisTitle("GeV");
108 
109  histname = "hadS9DepositedEnergyBarrel_";
110  hcalS9DepEnergyBarrel = theDbe->book1D(histname+AlgoName, "Energy deposited in the HCAL barrel 3*3 towers", hadS9NoBin, hadS9NoMin, hadS9NoMax);
111  hcalS9DepEnergyBarrel->setAxisTitle("GeV");
112  histname = "hadS9DepositedEnergyEndcap_";
113  hcalS9DepEnergyEndcap = theDbe->book1D(histname+AlgoName, "Energy deposited in the HCAL endcap 3*3 towers", hadS9NoBin, hadS9NoMin, hadS9NoMax);
114  hcalS9DepEnergyEndcap->setAxisTitle("GeV");
115  histname = "hadS9PointingMuDepositedEnergy_Glb_";
116  hcalS9PointingMuDepEnergy_Glb = theDbe->book1D(histname+AlgoName, "Pointing glb muons energy deposited in the HCAL endcap 3*3 towers", hadS9NoBin, hadS9NoMin, hadS9NoMax);
117  hcalS9PointingMuDepEnergy_Glb->setAxisTitle("GeV");
118  histname = "hadS9PointingMuDepositedEnergy_Tk_";
119  hcalS9PointingMuDepEnergy_Tk = theDbe->book1D(histname+AlgoName, "Pointing tk muons energy deposited in the HCAL endcap 3*3 towers", hadS9NoBin, hadS9NoMin, hadS9NoMax);
120  hcalS9PointingMuDepEnergy_Tk->setAxisTitle("GeV");
121  histname = "hadS9PointingMuDepositedEnergy_Sta_";
122  hcalS9PointingMuDepEnergy_Sta = theDbe->book1D(histname+AlgoName, "Pointing sta muons energy deposited in the HCAL endcap 3*3 towers", hadS9NoBin, hadS9NoMin, hadS9NoMax);
123  hcalS9PointingMuDepEnergy_Sta->setAxisTitle("GeV");
124 
125  histname = "hoDepositedEnergy_";
126  hoDepEnergy = theDbe->book1D(histname+AlgoName, "Energy deposited in the HO cells", hoNoBin, hoNoMin, hoNoMax);
127  hoDepEnergy->setAxisTitle("GeV");
128 
129  histname = "hoS9DepositedEnergy_";
130  hoS9DepEnergy = theDbe->book1D(histname+AlgoName, "Energy deposited in the HO 3*3 towers", hoS9NoBin, hoS9NoMin, hoS9NoMax);
131  hoS9DepEnergy->setAxisTitle("GeV");
132  histname = "hoS9PointingMuDepositedEnergy_Glb_";
133  hoS9PointingMuDepEnergy_Glb = theDbe->book1D(histname+AlgoName, "Pointing glb muons energy deposited in the HO 3*3 towers", hoS9NoBin, hoS9NoMin, hoS9NoMax);
134  hoS9PointingMuDepEnergy_Glb->setAxisTitle("GeV");
135  histname = "hoS9PointingMuDepositedEnergy_Tk_";
136  hoS9PointingMuDepEnergy_Tk = theDbe->book1D(histname+AlgoName, "Pointing tk muons energy deposited in the HO 3*3 towers", hoS9NoBin, hoS9NoMin, hoS9NoMax);
137  hoS9PointingMuDepEnergy_Tk->setAxisTitle("GeV");
138  histname = "hoS9PointingMuDepositedEnergy_Sta_";
139  hoS9PointingMuDepEnergy_Sta = theDbe->book1D(histname+AlgoName, "Pointing sta muons energy deposited in the HO 3*3 towers", hoS9NoBin, hoS9NoMin, hoS9NoMax);
140  hoS9PointingMuDepEnergy_Sta->setAxisTitle("GeV");
141 
142 }
144  LogTrace(metname)<<"[MuonEnergyDepositAnalyzer] Filling the histos";
145  theService->update(iSetup);
146 
147  // Take the muon container
149  iEvent.getByToken(theMuonCollectionLabel_,muons);
150 
151  if (!muons.isValid()) return;
152 
153  for (reco::MuonCollection::const_iterator recoMu = muons->begin(); recoMu!=muons->end(); ++recoMu){
154  // get all the mu energy deposits
155  reco::MuonEnergy muEnergy = recoMu->calEnergy();
156 
157  // energy deposited in ECAL
158  LogTrace(metname) << "Energy deposited in ECAL: "<<muEnergy.em;
159  if (fabs(recoMu->eta()) > 1.479)
160  ecalDepEnergyEndcap->Fill(muEnergy.em);
161  else
162  ecalDepEnergyBarrel->Fill(muEnergy.em);
163 
164  // energy deposited in HCAL
165  LogTrace(metname) << "Energy deposited in HCAL: "<<muEnergy.had;
166  if (fabs(recoMu->eta()) > 1.4)
167  hcalDepEnergyEndcap->Fill(muEnergy.had);
168  else
169  hcalDepEnergyBarrel->Fill(muEnergy.had);
170 
171  // energy deposited in HO
172  LogTrace(metname) << "Energy deposited in HO: "<<muEnergy.ho;
173  if (fabs(recoMu->eta()) < 1.26)
174  hoDepEnergy->Fill(muEnergy.ho);
175 
176  // energy deposited in ECAL in 3*3 towers
177  LogTrace(metname) << "Energy deposited in ECAL: "<<muEnergy.emS9;
178  if (fabs(recoMu->eta()) > 1.479)
179  ecalS9DepEnergyEndcap->Fill(muEnergy.emS9);
180  else
181  ecalS9DepEnergyBarrel->Fill(muEnergy.emS9);
182 
183  // energy deposited in HCAL in 3*3 crystals
184  LogTrace(metname) << "Energy deposited in HCAL: "<<muEnergy.hadS9;
185  if (fabs(recoMu->eta()) > 1.4)
186  hcalS9DepEnergyEndcap->Fill(muEnergy.hadS9);
187  else
188  hcalS9DepEnergyBarrel->Fill(muEnergy.hadS9);
189 
190  // energy deposited in HO in 3*3 crystals
191  LogTrace(metname) << "Energy deposited in HO: "<<muEnergy.hoS9;
192  if (fabs(recoMu->eta()) < 1.26)
193  hoS9DepEnergy->Fill(muEnergy.hoS9);
194 
195  // plot for energy tests
197  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theB);
198  reco::TransientTrack TransTrack;
199 
200  if(recoMu->isGlobalMuon())
201  TransTrack = theB->build(recoMu->globalTrack());
202  if(recoMu->isTrackerMuon() && !(recoMu->isGlobalMuon()))
203  TransTrack = theB->build(recoMu->innerTrack());
204  if(recoMu->isStandAloneMuon() && !(recoMu->isGlobalMuon()))
205  TransTrack = theB->build(recoMu->outerTrack());
206 
208  TSOS = TransTrack.impactPointState();
209  // section for vertex pointing muon
210  if((abs(TSOS.globalPosition().z())<30) && (abs(TSOS.globalPosition().perp())<20)){
211  // GLB muon
212  if(recoMu->isGlobalMuon()){
213  ecalS9PointingMuDepEnergy_Glb->Fill(muEnergy.emS9);
214  hcalS9PointingMuDepEnergy_Glb->Fill(muEnergy.hadS9);
215  hoS9PointingMuDepEnergy_Glb->Fill(muEnergy.hoS9);
216  }
217  // TK muon
218  if(recoMu->isTrackerMuon() && !(recoMu->isGlobalMuon())){
219  ecalS9PointingMuDepEnergy_Tk->Fill(muEnergy.emS9);
220  hcalS9PointingMuDepEnergy_Tk->Fill(muEnergy.hadS9);
221  hoS9PointingMuDepEnergy_Tk->Fill(muEnergy.hoS9);
222  }
223  // STA muon
224  if(recoMu->isStandAloneMuon() && !(recoMu->isGlobalMuon())){
225  ecalS9PointingMuDepEnergy_Sta->Fill(muEnergy.emS9);
226  hcalS9PointingMuDepEnergy_Sta->Fill(muEnergy.hadS9);
227  hoS9PointingMuDepEnergy_Sta->Fill(muEnergy.hoS9);
228  }
229  }
230  }
231 
232 }
233 
234 
MuonEnergyDepositAnalyzer(const edm::ParameterSet &)
Constructor.
dictionary parameters
Definition: Parameters.py:2
T perp() const
Definition: PV3DBase.h:72
void analyze(const edm::Event &, const edm::EventSetup &)
Get the analysis.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
const std::string metname
float emS9
energy deposited in 3x3 ECAL crystal shape around central crystal
Definition: MuonEnergy.h:18
GlobalPoint globalPosition() const
void beginJob()
Inizialize parameters for histo binning.
void beginRun(const edm::Run &run, const edm::EventSetup &iSetup)
float ho
energy deposited in crossed HO towers
Definition: MuonEnergy.h:32
virtual ~MuonEnergyDepositAnalyzer()
Destructor.
int iEvent
Definition: GenABIO.cc:243
T z() const
Definition: PV3DBase.h:64
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:76
#define LogTrace(id)
TrajectoryStateOnSurface TSOS
Definition: TestHits.cc:19
const T & get() const
Definition: EventSetup.h:55
tuple muons
Definition: patZpeak.py:38
TrajectoryStateOnSurface impactPointState() const
float hadS9
energy deposited in 3x3 HCAL tower shape around central tower
Definition: MuonEnergy.h:28
Definition: Run.h:41