44 if (argc < 4 || argc > 6)
46 std::cout <<
"USAGE: " <<
argv[0] <<
" <JetCollection> <ConfigFile> <OutputFile> (dev mode switch) (JES_vs_E switch)" << std::endl;
51 const TString jetAlgo =
argv[1];
54 const bool isDevMode =
argc > 4 && (TString(
argv[4]) ==
"true" || TString(
argv[4]) ==
"dev");
55 const bool vsE =
argc > 5 && (TString(
argv[5]) ==
"true");
58 const bool outFileIsExtensible =
outFile.EndsWith(
".pdf") ||
outFile.EndsWith(
".ps") ||
outFile.EndsWith(
".root");
61 const TString calibSeq =
"EtaJES";
62 const bool isData =
false;
63 float massForScan = 80.385e3;
64 if ( !jetAlgo.Contains(
"AntiKt10") ) massForScan = 0;
67 TString startingScaleString =
"JetConstitScaleMomentum";
68 if ( !jetAlgo.Contains(
"AntiKt10") ) startingScaleString =
"JetPileupScaleMomentum";
69 const TString endingScaleString =
"JetEtaJESScaleMomentum";
70 const TString detectorEtaString =
"DetectorEta";
84 std::cout <<
"Failed to make ana tool" << std::endl;
87 if (calibTool.
setProperty(
"JetCollection",jetAlgo.Data()).isFailure())
89 std::cout <<
"Failed to set JetCollection: " << jetAlgo.Data() << std::endl;
94 std::cout <<
"Failed to set ConfigFile: " <<
config.Data() << std::endl;
97 if (calibTool.
setProperty(
"CalibSequence",calibSeq.Data()).isFailure())
99 std::cout <<
"Failed to set CalibSequence: " << calibSeq.Data() << std::endl;
102 if (calibTool.
setProperty(
"IsData",isData).isFailure())
104 std::cout <<
"Failed to set IsData: " << (isData ? std::string(
"true") : std::string(
"false")) << std::endl;
107 if (isDevMode && calibTool.
setProperty(
"DEVmode",isDevMode).isFailure())
109 std::cout <<
"Failed to set DEVmode" << std::endl;
112 if (calibTool.
retrieve().isFailure())
114 std::cout <<
"Failed to initialize the JetCalibTool" << std::endl;
131 if ( jetAlgo.Contains(
"AntiKt10") ) hist_pt_eta =
new TH2D(
"JES_pt_eta",Form(
"JES for jets with mass=%.1f GeV",massForScan/1.
e3),1200,100,2500,60,-3,3);
132 else { hist_pt_eta =
new TH2D(
"JES_pt_eta",Form(
"JES for jets with mass=%.1f GeV",massForScan/1.
e3),2500,20,5000,90,-4.5,4.5); }
135 for (
int xBin = 1; xBin <= hist_pt_eta->GetNbinsX(); ++xBin)
137 const double pt = hist_pt_eta->GetXaxis()->GetBinCenter(xBin)*1.e3;
138 for (
int yBin = 1; yBin <= hist_pt_eta->GetNbinsY(); ++yBin)
140 const double eta = hist_pt_eta->GetYaxis()->GetBinCenter(yBin);
149 const double pT = sqrt((
E*
E)-(massForScan*massForScan))/cosh(
eta);
154 const double startingE = startingScale(*jet).e();
157 if(calibTool->
modify(*jets).isFailure()){
158 std::cout <<
"Failed to apply jet calibration" << std::endl;
162 const double JES =
jet->e()/startingE;
165 hist_pt_eta->SetBinContent(xBin,yBin,JES);
174 TCanvas*
canvas =
new TCanvas(
"canvas");
175 canvas->SetMargin(0.07,0.13,0.1,0.10);
176 canvas->SetFillStyle(4000);
178 canvas->SetFrameBorderMode(0);
183 hist_pt_eta->SetStats(
false);
184 if ( !vsE ) hist_pt_eta->GetXaxis()->SetTitle(
"Jet #it{p}_{T} [GeV]");
185 else { hist_pt_eta->GetXaxis()->SetTitle(
"Jet E [GeV]"); }
186 hist_pt_eta->GetXaxis()->SetTitleOffset(1.35);
187 hist_pt_eta->GetXaxis()->SetMoreLogLabels();
188 hist_pt_eta->GetYaxis()->SetTitle(
"#eta");
189 hist_pt_eta->GetYaxis()->SetTitleOffset(0.9);
190 hist_pt_eta->GetZaxis()->SetTitle(
"JES_{Factor}");
193 if (outFileIsExtensible)
198 hist_pt_eta->Draw(
"colz");
201 }
else if (
outFile.EndsWith(
".root") ){
202 TFile *
fout =
new TFile(
outFile.Data(),
"RECREATE");
203 hist_pt_eta->Write();
212 hist_pt_eta->Draw(
"colz");