3 #include <TObjString.h>
6 #include <TTreeIndex.h>
19 int main(
int argc,
char *argv[])
22 bool IsData = (TString(argv[1]).Atoi() == 1) ?
true :
false;
23 TString EvtVtx_map_filename = TString(argv[2]);
24 TString infilename = TString(argv[3]);
25 TString outfilename = TString(argv[4]);
26 int NevtToRun_ = TString(argv[5]).Atoi();
27 float dRCut = TString(argv[6]).Atof();
31 cout <<
"[Run Info] Event-vertex map file = " << EvtVtx_map_filename << endl
32 <<
" Input file = " << infilename << endl
33 <<
" Output file = " << outfilename << endl
34 <<
" Number of events to run = " << NevtToRun_ << endl
35 <<
" dRCut = " << dRCut << endl
36 <<
"-----------" << endl;
38 cout <<
"[Run Info] NevtToRun: " << NevtToRun_ <<
", dRCut: " << dRCut << endl;
44 TFile *
f =
new TFile(infilename,
"READ");
45 TTree *
t = (TTree *)f->Get(
"EventTree");
46 t->BuildIndex(
"event");
47 TTreeIndex *
index = (TTreeIndex *)t->GetTreeIndex();
49 float TruthPV_trig_x, TruthPV_trig_y, TruthPV_trig_z, centrality_mbd, centrality_mbdquantity;
50 vector<int> *ClusLayer = 0;
51 vector<float> *ClusX = 0, *ClusY = 0, *ClusZ = 0, *ClusPhiSize = 0, *ClusZSize = 0;
52 vector<int> *UniqueAncG4P_PID = 0;
53 vector<float> *UniqueAncG4P_Pt = 0, *UniqueAncG4P_Eta = 0, *UniqueAncG4P_Phi = 0, *UniqueAncG4P_E = 0;
54 t->SetBranchAddress(
"event", &event);
57 t->SetBranchAddress(
"NTruthVtx", &NTruthVtx);
58 t->SetBranchAddress(
"TruthPV_trig_x", &TruthPV_trig_x);
59 t->SetBranchAddress(
"TruthPV_trig_y", &TruthPV_trig_y);
60 t->SetBranchAddress(
"TruthPV_trig_z", &TruthPV_trig_z);
61 t->SetBranchAddress(
"UniqueAncG4P_PID", &UniqueAncG4P_PID);
62 t->SetBranchAddress(
"UniqueAncG4P_Pt", &UniqueAncG4P_Pt);
63 t->SetBranchAddress(
"UniqueAncG4P_Eta", &UniqueAncG4P_Eta);
64 t->SetBranchAddress(
"UniqueAncG4P_Phi", &UniqueAncG4P_Phi);
65 t->SetBranchAddress(
"UniqueAncG4P_E", &UniqueAncG4P_E);
67 t->SetBranchAddress(
"centrality_mbd", ¢rality_mbd);
68 t->SetBranchAddress(
"centrality_mbdquantity", ¢rality_mbdquantity);
69 t->SetBranchAddress(
"ClusLayer", &ClusLayer);
70 t->SetBranchAddress(
"ClusX", &ClusX);
71 t->SetBranchAddress(
"ClusY", &ClusY);
72 t->SetBranchAddress(
"ClusZ", &ClusZ);
73 t->SetBranchAddress(
"ClusPhiSize", &ClusPhiSize);
74 t->SetBranchAddress(
"ClusZSize", &ClusZSize);
76 TFile *
outfile =
new TFile(outfilename,
"RECREATE");
77 TTree *minitree =
new TTree(
"minitree",
"Minitree of Reconstructed Tracklets");
80 for (
int i = 0;
i < NevtToRun_;
i++)
82 Long64_t local = t->LoadTree(index->GetIndex()[
i]);
86 vector<float> PV = EvtVtx_map[
event];
101 cout <<
"[Event info] Event = " <<
event << endl;
104 tkldata.
pu0_sel = (NTruthVtx == 1) ?
true :
false;
111 if (ClusLayer->at(
ihit) < 3 || ClusLayer->at(
ihit) > 6)
113 cout <<
"[WARNING] Unknown layer: " << ClusLayer->at(
ihit) << endl;
117 int layer = (ClusLayer->at(
ihit) == 3 || ClusLayer->at(
ihit) == 4) ? 0 : 1;
118 Hit *hit =
new Hit(ClusX->at(
ihit), ClusY->at(
ihit), ClusZ->at(
ihit), PV[0], PV[1], PV[2], 0);
134 for (
size_t ihad = 0; ihad < UniqueAncG4P_PID->size(); ihad++)
139 GenHadron *genhadron =
new GenHadron(UniqueAncG4P_Pt->at(ihad), UniqueAncG4P_Eta->at(ihad), UniqueAncG4P_Phi->at(ihad), UniqueAncG4P_E->at(ihad));
141 tkldata.
GenHadron_Pt.push_back(UniqueAncG4P_Pt->at(ihad));
144 tkldata.
GenHadron_E.push_back(UniqueAncG4P_E->at(ihad));
154 cout <<
"----------" << endl;
158 minitree->Write(
"", TObject::kOverwrite);