48{
49
50 if (argc != 5 && argc != 6)
51 {
52 std::cout <<
"USAGE: " <<
argv[0] <<
" <JetCollection> <ConfigFile> <OutputFile> <mass type> (dev mode switch)" << std::endl;
53 std::cout << "\tMass types: \"calo\", \"TA\", \"comb\" (capitalization is ignored)" << std::endl;
54 return 1;
55 }
56
57
58 const TString jetAlgo =
argv[1];
61 const TString massType =
argv[4];
62 const bool isDevMode =
argc > 5 && (TString(argv[5]) ==
"true" || TString(argv[5]) ==
"dev");
63
64
65 const bool outFileIsExtensible =
outFile.EndsWith(
".pdf") ||
outFile.EndsWith(
".ps");
66 const bool outFileIsRoot =
outFile.EndsWith(
".root");
67 const bool doCombMass = !massType.CompareTo("comb",TString::kIgnoreCase);
68 const bool doCaloMass = doCombMass || !massType.CompareTo("calo",TString::kIgnoreCase);
69 const bool doTAMass = doCombMass || !massType.CompareTo("ta",TString::kIgnoreCase);
70
71
72 const TString calibSeq = "JMS";
73 const bool isData = false;
74 const float massForScan = 80.385e3;
75 const float etaForScan = 0;
76 const float etaRange = (doCombMass || doTAMass) ? 2 : 3;
77 const float trackMassFactor = 2./3.;
78 const float trackPtFactor = 2./3.;
79
80
81 const TString startingScaleString = "JetEtaJESScaleMomentum";
82 const TString caloMassScaleString = "JetJMSScaleMomentumCalo";
83 const TString taMassScaleString = "JetJMSScaleMomentumTA";
84 const TString taMassFloatString = "JetTrackAssistedMassCalibrated";
85 const TString detectorEtaString = "DetectorEta";
86 const TString trackMassString = "TrackSumMass";
87 const TString trackPtString = "TrackSumPt";
88
89
97
98
99
102 {
104 {
105 std::cout << "Failed to make ana tool" << std::endl;
106 return 2;
107 }
108 if (calibTool.
setProperty(
"JetCollection",jetAlgo.Data()).isFailure())
109 {
110 std::cout << "Failed to set JetCollection: " << jetAlgo.Data() << std::endl;
111 return 3;
112 }
114 {
115 std::cout <<
"Failed to set ConfigFile: " <<
config.Data() << std::endl;
116 return 3;
117 }
118 if (calibTool.
setProperty(
"CalibSequence",calibSeq.Data()).isFailure())
119 {
120 std::cout << "Failed to set CalibSequence: " << calibSeq.Data() << std::endl;
121 return 3;
122 }
123 if (calibTool.
setProperty(
"IsData",isData).isFailure())
124 {
125 std::cout <<
"Failed to set IsData: " << (isData ? std::string(
"true") :
std::
string(
"false")) <<
std::endl;
126 return 3;
127 }
128 if (isDevMode && calibTool.
setProperty(
"DEVmode",isDevMode).isFailure())
129 {
130 std::cout << "Failed to set DEVmode" << std::endl;
131 return 4;
132 }
133 if (calibTool.
retrieve().isFailure())
134 {
135 std::cout << "Failed to initialize the JetCalibTool" << std::endl;
136 return 5;
137 }
138 }
139
140
141
148
153
154
155 std::vector<TH2D*> hists_pt_eta;
156 std::vector<TH2D*> hists_pt_mpt;
157 if (doCaloMass)
158 {
159 hists_pt_eta.push_back(new TH2D("JMS_calo_pt_eta",Form("JMS (calo) for jets with mass=%.1f GeV",massForScan/1.e3),1150,200,2500,20*etaRange,-etaRange,etaRange));
160 hists_pt_mpt.push_back(new TH2D("JMS_calo_pt_mpt",Form("JMS (calo): for jets with #eta=%.1f",etaForScan),1150,200,2500,100,0,1));
161 }
162 if (doTAMass)
163 {
164 hists_pt_eta.push_back(new TH2D("JMS_TA_pt_eta",Form("JMS (TA) for jets with mass=%.1f GeV (TA factor = %.1f)",massForScan/1.e3,trackMassFactor/trackPtFactor),1150,200,2500,20*etaRange,-etaRange,etaRange));
165 hists_pt_mpt.push_back(new TH2D("JMS_TA_pt_mpt",Form("JMS (TA) for jets with #eta=%.1f",etaForScan),1150,200,2500,100,0,1));
166 }
167 if (doCombMass)
168 {
169 hists_pt_eta.push_back(new TH2D("JMS_comb_pt_eta",Form("JMS (comb) for jets with mass=%.1f GeV",massForScan/1.e3),1150,200,2500,20*etaRange,-etaRange,etaRange));
170 hists_pt_mpt.push_back(new TH2D("JMS_comb_pt_mpt",Form("JMS (comb) for jets with eta=%.1f",etaForScan),1150,200,2500,100,0,1));
171 }
172
173
174 for (int xBin = 1; xBin <= hists_pt_eta.at(0)->GetNbinsX(); ++xBin)
175 {
176 const double pt = hists_pt_eta.at(0)->GetXaxis()->GetBinCenter(xBin)*1.e3;
177 for (int yBin = 1; yBin <= hists_pt_eta.at(0)->GetNbinsY(); ++yBin)
178 {
179 const double eta = hists_pt_eta.at(0)->GetYaxis()->GetBinCenter(yBin);
180
181
184 trackMass(*
jet) = trackMassFactor*massForScan;
187
189 detectorEta(*calibJet) =
eta;
190 trackMass(*calibJet) = trackMassFactor*massForScan;
193
194
195 if (calibTool->modify(*calibJets).isFailure()) {
196 std::cout << "Failed to apply jet calibration" << std::endl;
197 return 6;
198 }
199
200
201 const double JMS = calibJet->
m()/startingScale(*jet).mass();
202 const double JMScalo = doCombMass ? caloMassScale(*calibJet).mass()/startingScale(*jet).mass() : JMS;
203 const double JMSTA = (doCombMass ? taMassScale(*calibJet).mass() : mTAfloat(*calibJet))/
mTA(trackMass(*
jet),
trackPt(*
jet),startingScale(*jet).pt());
204
205
206 size_t plotIndex = 0;
207 if (doCaloMass)
208 hists_pt_eta.at(plotIndex++)->SetBinContent(xBin,yBin,JMScalo);
209 if (doTAMass)
210 hists_pt_eta.at(plotIndex++)->SetBinContent(xBin,yBin,JMSTA);
211 if (doCombMass)
212 hists_pt_eta.at(plotIndex++)->SetBinContent(xBin,yBin,JMS);
213 }
214 }
215
216
217 for (int xBin = 1; xBin <= hists_pt_mpt.at(0)->GetNbinsX(); ++xBin)
218 {
219 const double pt = hists_pt_mpt.at(0)->GetXaxis()->GetBinCenter(xBin)*1.e3;
220 for (int yBin = 1; yBin <= hists_pt_mpt.at(0)->GetNbinsY(); ++yBin)
221 {
222 const double mpt = hists_pt_mpt.at(0)->GetYaxis()->GetBinCenter(yBin);
223 const double mass =
pt*mpt;
224
225
227 detectorEta(*
jet) = etaForScan;
228 trackMass(*
jet) = trackMassFactor*
mass;
231
233 detectorEta(*calibJet) = etaForScan;
234 trackMass(*calibJet) = trackMassFactor*
mass;
237
238
239 if(calibTool->modify(*calibJets).isFailure()){
240 std::cout << "Failed to apply jet calibration" << std::endl;
241 return 6;
242 }
243
244
245 const double JMS = calibJet->
m()/startingScale(*jet).mass();
246 const double JMScalo = doCombMass ? caloMassScale(*calibJet).mass()/startingScale(*jet).mass() : JMS;
247 const double JMSTA = (doCombMass ? taMassScale(*calibJet).mass() : mTAfloat(*calibJet))/
mTA(trackMass(*
jet),
trackPt(*
jet),startingScale(*jet).pt());
248
249
250 size_t plotIndex = 0;
251 if (doCaloMass)
252 hists_pt_mpt.at(plotIndex++)->SetBinContent(xBin,yBin,JMScalo);
253 if (doTAMass)
254 hists_pt_mpt.at(plotIndex++)->SetBinContent(xBin,yBin,JMSTA);
255 if (doCombMass)
256 hists_pt_mpt.at(plotIndex++)->SetBinContent(xBin,yBin,JMS);
257 }
258 }
259
260
261
262
263
264 TCanvas*
canvas =
new TCanvas(
"canvas");
265 canvas->SetMargin(0.07,0.13,0.1,0.10);
266 canvas->SetFillStyle(4000);
268 canvas->SetFrameBorderMode(0);
271
272
273 for (TH2* hist : hists_pt_eta)
274 {
275 hist->SetStats(
false);
276 hist->GetXaxis()->SetTitle(
"Jet #it{p}_{T} [GeV]");
277 hist->GetXaxis()->SetTitleOffset(1.35);
278 hist->GetXaxis()->SetMoreLogLabels();
279 hist->GetYaxis()->SetTitle(
"#eta");
280 hist->GetYaxis()->SetTitleOffset(0.9);
281 hist->GetZaxis()->SetTitle(
"m_{JES+JMS} / m_{JES}");
282
283 }
284 for (TH2* hist : hists_pt_mpt)
285 {
286 hist->SetStats(
false);
287 hist->GetXaxis()->SetTitle(
"Jet #it{p}_{T} [GeV]");
288 hist->GetXaxis()->SetTitleOffset(1.35);
289 hist->GetXaxis()->SetMoreLogLabels();
290 hist->GetYaxis()->SetTitle(
"m / #it{p}_{T}");
291 hist->GetYaxis()->SetTitleOffset(0.9);
292 hist->GetZaxis()->SetTitle(
"m_{JES+JMS} / m_{JES}");
293
294 }
295
296
297 if (outFileIsExtensible)
298 {
299 canvas->Print(outFile+
"[");
300 for (size_t iHist = 0; iHist < hists_pt_eta.size(); ++iHist)
301 {
302 hists_pt_eta.at(iHist)->Draw("colz");
304 hists_pt_mpt.at(iHist)->Draw("colz");
306 }
307 canvas->Print(outFile+
"]");
308 }
309 else if (outFileIsRoot)
310 {
311 TFile*
outRootFile =
new TFile(outFile,
"RECREATE");
312 std::cout <<
"Writing to output ROOT file: " <<
outFile << std::endl;
314 for (size_t iHist = 0; iHist < hists_pt_eta.size(); ++iHist)
315 {
316 hists_pt_eta.at(iHist)->Write();
317 hists_pt_mpt.at(iHist)->Write();
318 }
320 }
321 else
322 {
324 for (size_t iHist = 0; iHist < hists_pt_eta.size(); ++iHist)
325 {
326 hists_pt_eta.at(iHist)->Draw("colz");
328 hists_pt_mpt.at(iHist)->Draw("colz");
329 canvas->Print(Form(
"%u-fixMass-%s",counter++,
outFile.Data()));
330 }
331 }
332
333
334 for (TH2D* hist : hists_pt_eta)
336 hists_pt_eta.clear();
337
338 for (TH2D* hist : hists_pt_mpt)
340 hists_pt_mpt.clear();
341
342 return 0;
343}
Scalar eta() const
pseudorapidity method
const T * at(size_type n) const
Access an element, as an rvalue.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::Accessor< T, ALLOC > Accessor
JetFourMomAccessor is an extension of JetAttributeAccessor::AccessorWrapper<xAOD::JetFourMom_t> Acces...
void setJetP4(const JetFourMom_t &p4)
virtual double m() const
The invariant mass of the particle.
Tool for accessing xAOD files outside of Athena.
A relatively simple transient store for objects created in analysis.
outFile
Comment Out Those You do not wish to run.
etaRange
Filling Eta range.
bool trackPt(const xAOD::TauJet &, const xAOD::TauTrack &track, float &out)
Jet_v1 Jet
Definition of the current "jet version".
JetAuxContainer_v1 JetAuxContainer
Definition of the current jet auxiliary container.
JetContainer_v1 JetContainer
Definition of the current "jet container version".
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.