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;
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");
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);
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.;
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";
105 std::cout <<
"Failed to make ana tool" << std::endl;
108 if (calibTool.
setProperty(
"JetCollection",jetAlgo.Data()).isFailure())
110 std::cout <<
"Failed to set JetCollection: " << jetAlgo.Data() << std::endl;
115 std::cout <<
"Failed to set ConfigFile: " <<
config.Data() << std::endl;
118 if (calibTool.
setProperty(
"CalibSequence",calibSeq.Data()).isFailure())
120 std::cout <<
"Failed to set CalibSequence: " << calibSeq.Data() << std::endl;
123 if (calibTool.
setProperty(
"IsData",isData).isFailure())
125 std::cout <<
"Failed to set IsData: " << (isData ? std::string(
"true") : std::string(
"false")) << std::endl;
128 if (isDevMode && calibTool.
setProperty(
"DEVmode",isDevMode).isFailure())
130 std::cout <<
"Failed to set DEVmode" << std::endl;
133 if (calibTool.
retrieve().isFailure())
135 std::cout <<
"Failed to initialize the JetCalibTool" << std::endl;
155 std::vector<TH2D*> hists_pt_eta;
156 std::vector<TH2D*> hists_pt_mpt;
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));
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));
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));
174 for (
int xBin = 1; xBin <= hists_pt_eta.at(0)->GetNbinsX(); ++xBin)
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)
179 const double eta = hists_pt_eta.at(0)->GetYaxis()->GetBinCenter(yBin);
184 trackMass(*
jet) = trackMassFactor*massForScan;
189 detectorEta(*calibJet) =
eta;
190 trackMass(*calibJet) = trackMassFactor*massForScan;
195 if (calibTool->
modify(*calibJets).isFailure()) {
196 std::cout <<
"Failed to apply jet calibration" << std::endl;
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());
206 size_t plotIndex = 0;
208 hists_pt_eta.at(plotIndex++)->SetBinContent(xBin,yBin,JMScalo);
210 hists_pt_eta.at(plotIndex++)->SetBinContent(xBin,yBin,JMSTA);
212 hists_pt_eta.at(plotIndex++)->SetBinContent(xBin,yBin,JMS);
217 for (
int xBin = 1; xBin <= hists_pt_mpt.at(0)->GetNbinsX(); ++xBin)
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)
222 const double mpt = hists_pt_mpt.at(0)->GetYaxis()->GetBinCenter(yBin);
223 const double mass =
pt*mpt;
227 detectorEta(*
jet) = etaForScan;
228 trackMass(*
jet) = trackMassFactor*
mass;
233 detectorEta(*calibJet) = etaForScan;
234 trackMass(*calibJet) = trackMassFactor*
mass;
239 if(calibTool->
modify(*calibJets).isFailure()){
240 std::cout <<
"Failed to apply jet calibration" << std::endl;
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());
250 size_t plotIndex = 0;
252 hists_pt_mpt.at(plotIndex++)->SetBinContent(xBin,yBin,JMScalo);
254 hists_pt_mpt.at(plotIndex++)->SetBinContent(xBin,yBin,JMSTA);
256 hists_pt_mpt.at(plotIndex++)->SetBinContent(xBin,yBin,JMS);
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);
273 for (TH2*
hist : hists_pt_eta)
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}");
284 for (TH2*
hist : hists_pt_mpt)
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}");
297 if (outFileIsExtensible)
300 for (
size_t iHist = 0; iHist < hists_pt_eta.size(); ++iHist)
302 hists_pt_eta.at(iHist)->Draw(
"colz");
304 hists_pt_mpt.at(iHist)->Draw(
"colz");
309 else if (outFileIsRoot)
312 std::cout <<
"Writing to output ROOT file: " <<
outFile << std::endl;
314 for (
size_t iHist = 0; iHist < hists_pt_eta.size(); ++iHist)
316 hists_pt_eta.at(iHist)->Write();
317 hists_pt_mpt.at(iHist)->Write();
324 for (
size_t iHist = 0; iHist < hists_pt_eta.size(); ++iHist)
326 hists_pt_eta.at(iHist)->Draw(
"colz");
328 hists_pt_mpt.at(iHist)->Draw(
"colz");
334 for (TH2D*
hist : hists_pt_eta)
336 hists_pt_eta.clear();
338 for (TH2D*
hist : hists_pt_mpt)
340 hists_pt_mpt.clear();