pueoAnalysisTools
Loading...
Searching...
No Matches
plot_RFdir_payload.cpp
Go to the documentation of this file.
1
9
10#include <filesystem>
11
12#include "util.h"
13// CERN ROOT
14#include "ROOT/RDataFrame.hxx"
15#include "TH2.h"
16#include "TVector3.h"
17#include "TCanvas.h"
18
19// NiceMC
20#include "Event.h"
21
22int main(int argc, char *argv[]){
23
24 std::unique_ptr<TChain> allTree_chain_ptr;
25 std::unique_ptr<TChain> passTree_chain_ptr;
26 std::filesystem::path PUEO_MC_DATA = argv[1];
27 (void) argc; // suppresses unused variable warning
28
29 Util::prepare_icefinal_chain(PUEO_MC_DATA, passTree_chain_ptr, allTree_chain_ptr);
30
31 TH2D rfdir_hist("weighted passed events",
32 "RF Direction (payload coordinates); #phi; #theta",
33 100, -4, 4, // horizontal bin number and bounds
34 100, 0, M_PI);
35
36 // a lambda expression that fills the above histogram
37 auto fill_histogram = [&rfdir_hist](
38 const double &path_weight, const double &pos_weight, const double &dir_weight,
39 std::vector<nicemc::DetectorEvent> & dE){
40
41 double weight = path_weight / (pos_weight * dir_weight);
42
43 // detectorEvents[0] is for the main instrument
44 TVector3 RFdir_payload = dE[0].RFdir_payload;
45
46 // fill the histogram (weighted)
47 rfdir_hist.Fill(RFdir_payload.Phi(), RFdir_payload.Theta(), weight);
48 };
49
50 // use a dataframe to loop through each entry in the passTree
51 ROOT::RDataFrame df(*passTree_chain_ptr);
52 df.Foreach(
53 fill_histogram,
54 {
55 "neutrino.path.weight", "loop.positionWeight", "loop.directionWeight",
56 "detectorEvents"
57 }
58 );
59
60 TCanvas canvas("", "");
61 rfdir_hist.Draw("colz");
62 rfdir_hist.SetStats(0);
63 canvas.SaveAs("RFdirection_histogram.svg");
64
65
66 return 0;
67}
Contains only one utility function currently.
int prepare_icefinal_chain(std::filesystem::path PUEO_MC_DATA, std::unique_ptr< TChain > &passTree_chain_ptr, std::unique_ptr< TChain > &allTree_chain_ptr)
Prepares two TChains that combine all the IceFinal_*_allTree.root files in the simulation output dire...
Definition util.h:21