13 #include <TDatabasePDG.h>
28 #include "fastjet/ClusterSequence.hh"
29 #include "fastjet/PseudoJet.hh"
32 using namespace fastjet;
35 int main(
int argc,
char* argv[]){
39 TString smearedname =
"truth.smeared.root";
40 TString outfilebase =
"simplejet";
43 vector<string> arguments(argv + 1, argv + argc);
45 for (
auto parg = arguments.begin() ; parg!=arguments.end() ; ++parg){
48 if (++parg == arguments.end() ){ argsokay=
false;
break; }
50 }
else if ( arg ==
"-s" ){
51 if (++parg ==arguments.end() ){ argsokay=
false;
break; }
53 }
else if ( arg ==
"-N" ){
54 if (++parg==arguments.end() ){ argsokay=
false;
break; }
55 nevents=std::stoi(parg->data());
63 cerr <<
"usage: " << argv[0] << endl
64 <<
" [-s smearedname] (root file)" << endl
65 <<
" [-o OutFileBase] (extension will be added)" << endl
66 <<
" [-N Nevents] (<0 for all)" << endl
78 JetDefinition jet_def = JetDefinition(kt_algorithm, R);
81 double ConstEtaMax = 3.5;
82 double ConstEtaMin = -ConstEtaMax;
84 double JetEtaMax = ConstEtaMax -
R;
85 double JetEtaMin = -JetEtaMax;
87 auto select_jet_eta = fastjet::SelectorEtaRange ( JetEtaMin + R, JetEtaMax -R );
88 auto select_jet_pt = SelectorPtRange( jetPtCut, 1000 );
89 auto select_jet = select_jet_eta * select_jet_pt;
99 double Q2max = 1000000;
105 TF1* eff =
new TF1(
"eff",
"(x>[2]) * [0]*TMath::Erf(x-[1])",0, 100);
108 eff->SetParameters (0.99,-0.8, 0.2);
113 TChain* inTreeS =
new TChain(
"Smeared");
114 inTreeS->Add(smearedname);
118 inTreeS->SetBranchAddress(
"eventS",&inEventS);
122 TFile * outfile =
new TFile ( outfilebase +
".root",
"RECREATE");
124 TH1::SetDefaultSumw2(
true);
128 TH1D* smearedpt=
new TH1D(
"smearedpt",
";p_{T}^{smeared} [GeV/c];counts", ptbins, ptmin, ptmax );
139 vector<PseudoJet> SmearedConstituents;
141 for(
long iEvent=0; iEvent<inTreeS->GetEntries(); iEvent++){
144 if(inTreeS->GetEntry(iEvent) <=0)
break;
145 if(iEvent%10000 == 0) cout <<
"Event " << iEvent << endl;
150 bool smearacceptev=
true;
156 if ( xS < xmin || xS > xmax ) smearacceptev =
false;
157 if ( yS < ymin || yS > ymax ) smearacceptev =
false;
158 if ( Q2S < Q2min || Q2S > Q2max ) smearacceptev =
false;
160 if ( !smearacceptev )
continue;
165 SmearedConstituents.clear();
173 if ( !inParticleS )
continue;
176 if ( inParticleS->
GetStatus() != 1 )
continue;
189 double E = inParticleS->
GetE();
190 double px = inParticleS->
GetPx();
191 double py = inParticleS->
GetPy();
192 double pz = inParticleS->
GetPz();
193 double P = inParticleS->
GetP();
195 bool charged=( fabs(P)>
epsilon );
199 auto ran = gRandom->Uniform (0,1);
200 auto pt = std::sqrt ( px*px + py*py );
201 if (
ran > eff->Eval ( pt ) ) {
210 if ( fabs(P) <= epsilon && fabs(E) <=
epsilon ){
217 if ( fabs(P) > epsilon && fabs(E) >
epsilon ){
233 if ( fabs(P) > epsilon && fabs(E) <=
epsilon ){
244 E = std::sqrt(P*P + m*m);
248 if ( fabs(P) <= epsilon && fabs(E) > epsilon ){
264 auto pj = PseudoJet (px, py, pz, E);
272 if ( pj.eta() < ConstEtaMin || pj.eta() > ConstEtaMax)
continue;
278 SmearedConstituents.push_back ( pj );
283 ClusterSequence smearcs(SmearedConstituents, jet_def);
284 vector<PseudoJet> smearjets = sorted_by_pt( select_jet(smearcs.inclusive_jets()) );
289 for (
auto j : smearjets ){
290 smearedpt->Fill ( j.pt() );
298 gPad->SaveAs( outfilebase +
"_pt.png");