Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-28 07:38:10

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 
0022 void b0_tracker_hits(const char* fname = "./sim_output/sim_forward_protons.edm4hep.root"){
0023 
0024   ROOT::EnableImplicitMT(); // Tell ROOT you want to go parallel
0025   double degree = TMath::Pi()/180.0;
0026 
0027   TChain* t = new TChain("events");
0028   t->Add(fname);
0029 
0030   ROOT::RDataFrame d0(*t);
0031 
0032   auto hits_eta = [&](const std::vector<edm4hep::SimTrackerHitData>& hits) {
0033     std::vector<double> result;
0034     for (const auto& h : hits) {
0035       ROOT::Math::XYZVector vec(h.position.x,h.position.y,h.position.z);
0036       result.push_back(vec.eta());
0037       std::cout << vec.eta() << "\n";
0038     }
0039     return result;
0040   };
0041 
0042   auto d1 = d0.Define("hits_eta", hits_eta, {"B0TrackerHits"});
0043 
0044   auto h1 = d1.Histo1D({"h1", "hits_eta", 100, 0,20}, "hits_eta");
0045   TCanvas* c = new TCanvas();
0046   h1->DrawCopy();
0047   c->SaveAs("results/far_forward/b0/hits_eta.png");
0048   c->SaveAs("results/far_forward/b0/hits_eta.pdf");
0049   auto n1 = h1->GetMean();
0050   std::cout << "Pseudorapidity of hits: " << n1 << std::endl;
0051 
0052   //if (n1 < 5) {
0053   //        std::quick_exit(1);
0054   //}
0055 
0056 }