1+ #include < string>
2+
3+ #include " AnalysisTree/TaskManager.hpp"
4+ #include " AnalysisTree/Variable.hpp"
5+
6+ #include " Task.hpp"
7+ #include " YamlReader.hpp"
8+
9+ using namespace AnalysisTree ;
10+
11+ void example (const std::string& filelist){
12+ auto * man = TaskManager::GetInstance ();
13+
14+ auto * task = new QA::Task;
15+ task->SetOutputFileName (" cbm_qa.root" );
16+
17+ Cuts* pT_cut = new Cuts (" pT_cut" , {RangeCut (" RecTracks.pT" , 1 , 1.5 )});
18+ Variable pxpy (" pxpy" , {{" RecTracks" , " px" }, {" RecTracks" , " py" }}, []( std::vector<double >& var ) { return var.at (0 )*var.at (1 ); });
19+
20+ task->AddCut (pT_cut);
21+ task->AddVariable (pxpy);
22+
23+ QA::YamlReader r (" /Users/viktor/Soft/AnalysisTreeQA/examples/example.yaml" );
24+ r.AddPlotsFromYaml (task);
25+
26+ // // 1D histo
27+ // task->AddH1({"p_{T}, GeV/c", Variable::FromString("VtxTracks.pT"), {100, 0, 3}});
28+ //
29+ // // 1D histo with cut
30+ // Cuts* pT_cut = new Cuts("pT_cut", {RangeCut("VtxTracks.pT", 1, 1.5)});
31+ // task->AddH1({"p_{T}, GeV/c", Variable::FromString("VtxTracks.pT"), {100, 0, 3}}, pT_cut);
32+ //
33+ // // AnalysisTree::Variable in case of more complicated plot
34+ // Variable chi2_over_ndf("#chi^{2}/NDF", {{"VtxTracks", "chi2"}, {"VtxTracks", "ndf"}}, []( std::vector<double>& var ) { return var.at(0)/var.at(1); });
35+ // task->AddH1({"#chi^{2}/NDF", chi2_over_ndf, {100, 0, 10}});
36+ //
37+ // // 2D histo
38+ // task->AddH2({"#eta", Variable::FromString("VtxTracks.eta"), {100, -1, 4}}, {"p_{T}, GeV/c", Variable::FromString("VtxTracks.pT"), {100, 0, 3}});
39+ //
40+ // Variable qp_sts("qp_reco", {{"VtxTracks", "q"}, {"VtxTracks", "p"}}, [](std::vector<double>& qp) { return qp.at(0) * qp.at(1); });
41+ // task->AddH2({"sign(q)*p, GeV/c", qp_sts, {500, -10, 10}},{"m^{2}, GeV^{2}/c^{2}", {"TofHits", "mass2"}, {500, -1, 2}});
42+ //
43+ // // Histo with additional cuts:
44+ // Cuts* mc_protons = new Cuts("McProtons", {EqualsCut("SimParticles.pid", 2212)});
45+ // Cuts* mc_pions = new Cuts("McPions", {EqualsCut("SimParticles.pid", 211)});
46+ // task->AddH1({"MC-protons #chi^{2}/NDF", chi2_over_ndf, {100, 0, 10}}, mc_protons);
47+ // task->AddH1({"MC-pions #chi^{2}/NDF", chi2_over_ndf, {100, 0, 10}}, mc_pions);
48+ //
49+ // // TProfiles
50+ // const Field psi_RP = Field("SimEventHeader", "psi_RP");
51+ // const Field mc_phi = Field("SimParticles", "phi");
52+ // Variable v1("v1", {mc_phi, psi_RP}, [](std::vector<double> phi) { return cos(phi[0] - phi[1]); });
53+ // Variable v2("v2", {mc_phi, psi_RP}, [](std::vector<double> phi) { return cos(2 * (phi[0] - phi[1])); });
54+ // task->AddProfile({"#it{y}", Variable::FromString("SimParticles.rapidity"), {20, 0.5, 2.5}}, {"MC-protons v_{1}", v1, {}}, mc_protons);
55+ // task->AddProfile({"#it{y}", Variable::FromString("SimParticles.rapidity"), {20, 0.5, 2.5}}, {"MC-protons v_{1}", v1, {}}, mc_pions);
56+
57+ man->AddTask (task);
58+
59+ man->Init ({filelist}, {" tTree" });
60+ man->Run (-1 );
61+ man->Finish ();
62+ }
63+
64+ int main (int argc, char * argv[]){
65+ if (argc < 2 ) {
66+ std::cout << " Error! Please use " << std::endl;
67+ std::cout << " ./example filename" << std::endl;
68+ exit (EXIT_FAILURE);
69+ }
70+
71+ const std::string filename = argv[1 ];
72+ example (filename);
73+
74+ return 0 ;
75+ }
0 commit comments