|
1 | | -#include "T0Simulation/Detector.h" |
| 1 | +#if !defined(__CLING__) || defined(__ROOTCLING__) |
2 | 2 | #include "FITBase/Digit.h" |
| 3 | +#include "FITSimulation/HitType.h" |
3 | 4 | #include <TH2F.h> |
4 | | -void readHitsDigits() |
| 5 | +#include <TTree.h> |
| 6 | +#include <TFile.h> |
| 7 | +void readHitsDigits() |
5 | 8 | { |
6 | 9 | using namespace o2::fit; |
7 | 10 | // using namespace o2::fit::Digit; |
8 | | - |
| 11 | + |
9 | 12 | // Create histograms |
10 | 13 | TDirectory* cwd = gDirectory; |
11 | 14 | gDirectory = 0x0; |
12 | | - |
13 | | - TH2F *hMultHit = new TH2F("hMultHits","photons Hits ",210, 0, 210, 500, 0, 5000); |
14 | | - TH2F *hTimeHitA = new TH2F("hTimeAhit", "Time Hits", 210, 0, 210, 1000, 11, 12); |
15 | | - TH2F *hTimeHitC = new TH2F("hTimeChit", "Time Hits", 210, 0, 210, 1000, 2.8, 3.8); |
16 | | - TH2F *hMultDig = new TH2F("hMultDig","photons Digits ",210, 0, 210, 500, 0, 20); |
17 | | - TH2F *hTimeDig = new TH2F("hTimeDig", "Time Digits", 210, 0, 210, 100, -1, 1); |
18 | 15 |
|
19 | | - gDirectory = cwd; |
20 | | - |
21 | | - TFile *fhit = new TFile("o2sim.root"); |
22 | | - TTree *hitTree = (TTree*)fhit->Get("o2sim"); |
| 16 | + TH2F* hMultHit = new TH2F("hMultHits", "photons Hits ", 210, 0, 210, 500, 0, 5000); |
| 17 | + TH2F* hTimeHitA = new TH2F("hTimeAhit", "Time Hits", 210, 0, 210, 1000, 11, 12); |
| 18 | + TH2F* hTimeHitC = new TH2F("hTimeChit", "Time Hits", 210, 0, 210, 1000, 2.8, 3.8); |
| 19 | + TH2F* hMultDig = new TH2F("hMultDig", "photons Digits ", 210, 0, 210, 500, 0, 20); |
| 20 | + TH2F* hTimeDig = new TH2F("hTimeDig", "Time Digits", 210, 0, 210, 100, -1, 1); |
| 21 | + |
| 22 | + gDirectory = cwd; |
| 23 | + |
| 24 | + TFile* fhit = new TFile("o2sim.root"); |
| 25 | + TTree* hitTree = (TTree*)fhit->Get("o2sim"); |
23 | 26 | std::vector<o2::fit::HitType>* hitArray = nullptr; |
24 | 27 | hitTree->SetBranchAddress("T0Hit", &hitArray); |
25 | 28 | Int_t nevH = hitTree->GetEntries(); // hits are stored as one event per entry |
26 | 29 | // std::cout << "Found " << nevH << " events with hits " << std::endl; |
27 | | - |
| 30 | + |
28 | 31 | Double_t hit_time[240]; |
29 | 32 | Int_t countE[240]; |
30 | | - // Event ------------------------- LOOP |
31 | | - for (Int_t ievent=0; ievent<nevH; ievent++){ |
| 33 | + // Event ------------------------- LOOP |
| 34 | + for (Int_t ievent = 0; ievent < nevH; ievent++) { |
32 | 35 | hitTree->GetEntry(ievent); |
33 | | - for (int ii=0; ii<240; ii++) { countE[ii]=0;hit_time[ii]=0; } |
| 36 | + for (int ii = 0; ii < 240; ii++) { |
| 37 | + countE[ii] = 0; |
| 38 | + hit_time[ii] = 0; |
| 39 | + } |
34 | 40 | for (auto& hit : *hitArray) { |
35 | 41 | Int_t detID = hit.GetDetectorID(); |
36 | 42 | hit_time[detID] = hit.GetTime(); |
37 | | - hTimeHitA -> Fill(detID, hit_time[detID]); |
38 | | - hTimeHitC -> Fill(detID, hit_time[detID]); |
39 | | - countE[detID]++; |
| 43 | + hTimeHitA->Fill(detID, hit_time[detID]); |
| 44 | + hTimeHitC->Fill(detID, hit_time[detID]); |
| 45 | + countE[detID]++; |
40 | 46 | } |
41 | | - for (int ii=0; ii<208; ii++) { |
42 | | - if (countE[ii]>100) { |
43 | | - hMultHit -> Fill(ii, countE[ii]); |
44 | | - // std::cout<<ii<<" "<<countE[ii]<<endl; |
| 47 | + for (int ii = 0; ii < 208; ii++) { |
| 48 | + if (countE[ii] > 100) { |
| 49 | + hMultHit->Fill(ii, countE[ii]); |
| 50 | + // std::cout<<ii<<" "<<countE[ii]<<endl; |
45 | 51 | } |
46 | 52 | } |
47 | 53 | } |
48 | | - |
| 54 | + |
49 | 55 | TFile* fdig = TFile::Open("t0digits.root"); |
50 | 56 | std::cout << " Open digits file " << std::endl; |
51 | 57 | TTree* digTree = (TTree*)fdig->Get("o2sim"); |
52 | | - std::vector<o2::fit::Digit> * digArr = new std::vector<Digit>; |
| 58 | + std::vector<o2::fit::Digit>* digArr = new std::vector<Digit>; |
53 | 59 | digTree->SetBranchAddress("T0Digit", &digArr); |
54 | 60 | Int_t nevD = digTree->GetEntries(); // digits in cont. readout may be grouped as few events per entry |
55 | | - std::cout << "Found " << nevD << " events with digits " << std::endl; |
| 61 | + // std::cout << "Found " << nevD << " events with digits " << std::endl; |
56 | 62 | Float_t cfd[208], amp[208], part[208]; |
57 | 63 | for (Int_t iev = 0; iev < nevD; iev++) { |
58 | 64 | digTree->GetEvent(iev); |
59 | 65 | for (const auto& digit : *digArr) { |
60 | | - for (int ii=0; ii<208; ii++) { cfd[ii]=amp[ii]=0; } |
| 66 | + for (int ii = 0; ii < 208; ii++) { |
| 67 | + cfd[ii] = amp[ii] = 0; |
| 68 | + } |
61 | 69 | Double_t evtime = digit.getTime(); |
62 | 70 | for (const auto& d : digit.getChDgData()) { |
63 | | - Int_t mcp = d.ChId; |
64 | | - cfd[mcp] = d.CFDTime - evtime - 12.5; |
65 | | - amp[mcp] = d.QTCAmpl; |
66 | | - part[mcp] = d.numberOfParticles; |
67 | | - cout<<iev<<" "<<mcp<<" "<< cfd[mcp]<<" "<< amp[mcp]<<" "<<part[mcp]<<endl; |
68 | | - hMultDig ->Fill(Float_t (mcp),amp[mcp]); |
69 | | - hTimeDig ->Fill(Float_t (mcp),cfd[mcp]); |
| 71 | + Int_t mcp = d.ChId; |
| 72 | + cfd[mcp] = d.CFDTime - evtime - 12.5; |
| 73 | + amp[mcp] = d.QTCAmpl; |
| 74 | + part[mcp] = d.numberOfParticles; |
| 75 | + // cout << iev << " " << mcp << " " << cfd[mcp] << " " << amp[mcp] << " " << part[mcp] << endl; |
| 76 | + hMultDig->Fill(Float_t(mcp), amp[mcp]); |
| 77 | + hTimeDig->Fill(Float_t(mcp), cfd[mcp]); |
70 | 78 | } |
71 | 79 | } |
72 | | - } |
73 | | - TFile *Hfile = new TFile("FigFit_hits_pp.root","RECREATE"); |
| 80 | + } |
| 81 | + TFile* Hfile = new TFile("FigFit_hits_pp.root", "RECREATE"); |
74 | 82 | printf("Writting histograms to root file \n"); |
75 | | - Hfile->cd(); |
| 83 | + Hfile->cd(); |
76 | 84 | //Create a canvas, set the view range, show histograms |
77 | 85 | // TCanvas *c1 = new TCanvas("c1","Alice T0 Time ",400,10,600,600); |
78 | 86 | hTimeHitA->Write(); |
79 | 87 | hTimeHitC->Write(); |
80 | 88 | hMultHit->Write(); |
81 | 89 | hTimeDig->Write(); |
82 | 90 | hMultDig->Write(); |
83 | | - |
84 | 91 |
|
85 | 92 | } // end of macro |
86 | | - |
87 | | - |
88 | | - |
89 | | - |
90 | | - |
| 93 | +#endif |
0 commit comments