Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-09-27 07:02:36

0001 R__LOAD_LIBRARY(libfmt.so)
0002 #include "fmt/core.h"
0003 
0004 #include "ROOT/RDataFrame.hxx"
0005 #include "Math/Vector3D.h"
0006 //#include "Math/Vector4D.h"
0007 //#include "Math/VectorUtil.h"
0008 #include "TCanvas.h"
0009 //#include "TLegend.h"
0010 //#include "TMath.h"
0011 //#include "TRandom3.h"
0012 //#include "TFile.h"
0013 //#include "TH1F.h"
0014 //#include "TH1D.h"
0015 //#include "TTree.h"
0016 #include "TChain.h"
0017 //#include "TF1.h"
0018 
0019 #include "edm4hep/SimTrackerHitCollection.h"
0020 
0021 #include "common_bench/particles.h"
0022 #include "common_bench/benchmark.h"
0023 #include "common_bench/mt.h"
0024 #include "common_bench/util.h"
0025 
0026 void b0_tracker_hits(const char* fname = "./sim_output/sim_forward_protons.edm4hep.root"){
0027 
0028   ROOT::EnableImplicitMT(); // Tell ROOT you want to go parallel
0029   double degree = TMath::Pi()/180.0;
0030 
0031   TChain* t = new TChain("events");
0032   t->Add(fname);
0033 
0034   ROOT::RDataFrame d0(*t);
0035 
0036   auto hits_eta = [&](const std::vector<edm4hep::SimTrackerHitData>& hits) {
0037     std::vector<double> result;
0038     for (const auto& h : hits) {
0039       ROOT::Math::XYZVector vec(h.position.x,h.position.y,h.position.z);
0040       result.push_back(vec.eta());
0041       std::cout << vec.eta() << "\n";
0042     }
0043     return result;
0044   };
0045 
0046   auto d1 = d0.Define("hits_eta", hits_eta, {"B0TrackerHits"});
0047 
0048   auto h1 = d1.Histo1D({"h1", "hits_eta", 100, 0,20}, "hits_eta");
0049   TCanvas* c = new TCanvas();
0050   h1->DrawCopy();
0051   c->SaveAs("results/far_forward/b0/hits_eta.png");
0052   c->SaveAs("results/far_forward/b0/hits_eta.pdf");
0053   auto n1 = h1->GetMean();
0054   std::cout << "Pseudorapidity of hits: " << n1 << std::endl;
0055 
0056   //if (n1 < 5) {
0057   //        std::quick_exit(1);
0058   //}
0059 
0060 }
0061