forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadFT0hits.C
More file actions
108 lines (97 loc) · 3.73 KB
/
readFT0hits.C
File metadata and controls
108 lines (97 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright 2019-2025 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#if !defined(__CLING__) || defined(__ROOTCLING__)
#include "DataFormatsFIT/Triggers.h"
#include "DataFormatsFT0/Digit.h"
#include "DataFormatsFT0/HitType.h"
#include "SimulationDataFormat/MCEventHeader.h"
#include <TFile.h>
#include <TH1F.h>
#include <TH2F.h>
#include <TTree.h>
#include "DetectorsCommonDataFormats/DetID.h"
#include "DetectorsCommonDataFormats/DetectorNameConf.h"
#endif
void readFT0hits()
{
// Create histograms
TDirectory* cwd = gDirectory;
gDirectory = 0x0;
TH2F* hMultHit =
new TH2F("hMultHits", "photons Hits ", 220, 0, 220, 500, 0, 5000);
TH2F* hTimeHitA = new TH2F("hTimeAhit", "Time Hits", 220, 0, 220, 500, -1, 1);
TH2F* hTimeHitC = new TH2F("hTimeChit", "Time Hits", 220, 0, 220, 200, -1, 1);
TH2F* hMultDig =
new TH2F("hMultDig", "amplitude ", 220, 0, 220, 500, 0, 1000);
TH2F* hPel = new TH2F("hPelDig", "N p.e. ", 220, 0, 220, 500, 0, 10000);
TH2F* hXYA = new TH2F("hXYA", "X vs Y A side", 400, -20, 20, 400, -20, 20);
TH2F* hXYC = new TH2F("hXYC", "X vs Y C side", 400, -20, 20, 400, -20, 20);
TH1F* hZA = new TH1F("hZA", "Z A side", 200, 330, 340);
TH1F* hZC = new TH1F("hZC", "Z C side", 200, -90, -80);
gDirectory = cwd;
using namespace o2::detectors;
TFile* fhit = new TFile(o2::base::DetectorNameConf::getHitsFileName(DetID::FT0, "o2sim").c_str());
TTree* hitTree = (TTree*)fhit->Get("o2sim");
o2::dataformats::MCEventHeader* mcHeader = nullptr;
/* if (!hitTree->GetBranch("MCEventHeader.")) {
LOG(fatal) << "Did not find MC event header in the input header file." <<
FairLogger::endl;
}*/
hitTree->SetBranchAddress("MCEventHeader.", &mcHeader);
std::vector<o2::ft0::HitType>* hitArray = nullptr;
hitTree->SetBranchAddress("FT0Hit", &hitArray);
Int_t nevH = hitTree->GetEntries(); // hits are stored as one event per entry
// std::cout << "Found " << nevH << " events with hits " << std::endl;
Double_t hit_time[240];
Int_t countE[240];
// Event ------------------------- LOOP
for (Int_t ievent = 0; ievent < nevH; ievent++) {
hitTree->GetEntry(ievent);
///* std::cout<<ievent<<" b"<<mcHeader->GetB()<<std::endl;
for (int ii = 0; ii < 240; ii++) {
countE[ii] = 0;
hit_time[ii] = 0;
}
for (auto& hit : *hitArray) {
Int_t detID = hit.GetDetectorID();
hit_time[detID] = hit.GetTime();
hTimeHitA->Fill(detID, hit_time[detID] - 11.04);
hTimeHitC->Fill(detID, hit_time[detID] - 2.91);
countE[detID]++;
if (detID < 96) {
hXYA->Fill(hit.GetX(), hit.GetY());
hZA->Fill(hit.GetZ());
} else {
hXYC->Fill(hit.GetX(), hit.GetY());
hZC->Fill(hit.GetZ());
}
}
for (int ii = 0; ii < 220; ii++) {
if (countE[ii] > 100) {
hMultHit->Fill(ii, countE[ii]);
}
}
}
TFile* Hfile = new TFile("ft0_hits_pp.root", "RECREATE");
printf("Writting histograms to root file \n");
Hfile->cd();
// Create a canvas, set the view range, show histograms
// TCanvas *c1 = new TCanvas("c1","Alice T0 Time ",400,10,600,600);
hTimeHitA->Scale(1. / 250.);
hTimeHitC->Scale(1. / 250.);
hTimeHitA->Write();
hTimeHitC->Write();
hMultHit->Write();
hXYA->Write();
hXYC->Write();
hZA->Write();
hZC->Write();
} // end of macro