-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpc_randomizedY.C
158 lines (130 loc) · 4.54 KB
/
rpc_randomizedY.C
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
using namespace std;
struct crystal_info {
Int_t fCrystalId;
Float_t fTheta;
Float_t fPhi;
};
int nbin = 1500;
int minData =0;
int maxData = 1500;
int minHist = 0;
int maxHist = 1500;
int offset[41];
void offset_from_file()
{
ifstream myfile;
myfile.open("offset_back.txt", ios::in|ios::out);
for(int i=0; i<41; i++)
{
int tmp;
myfile>>tmp;
offset[i]=tmp-50;
cout<<offset[i]<<endl;;
}
myfile.close();
}
void rpc_randomizedY()
{
srand(time(NULL));
TStopwatch timer;
timer.Start();
///////////////////////////////////////////////////////////
offset_from_file();
TH2F *Pos_histo = new TH2F("Position","Position",nbin,minData,maxData,1230,0,1230);
/////////////////////////////////////////////////////////////////////
std::vector<TString> fileList;
//backgroound
//fileList.push_back("/u/land/mxarepe/unpkd_data/GSI_intern/root_files/r3b_st22045050208.root");
// fileList.push_back("/u/land/mxarepe/unpkd_data/GSI_intern/root_files/r3b_st22046083458.root");
//little
//fileList.push_back("/u/land/mxarepe/unpkd_data/GSI_intern/root_files/r3b_st22046050208.root");
//
//fallen onece
//fileList.push_back("/u/land/mxarepe/unpkd_data/GSI_intern/root_files/r3b_st22046060515.root");
//fileList.push_back("/u/land/mxarepe/unpkd_data/GSI_intern/root_files/r3b_st22046064454.root");
//down
fileList.push_back("/u/land/mxarepe/unpkd_data/GSI_intern/root_files/r3b_st22046082416.root");
// fileList.push_back("/u/land/mxarepe/unpkd_data/GSI_intern/root_files/r3b_st22046060952.root");
// fileList.push_back("/u/land/mxarepe/unpkd_data/GSI_intern/root_files/r3b_st22046065513.root");
//fileList.push_back("/u/land/mxarepe/unpkd_data/GSI_intern/root_files/r3b_st22046070926.root");
//fileList.push_back("/u/land/mxarepe/unpkd_data/GSI_intern/root_files/r3b_st22046071959.root");
//fileList.push_back("/u/land/mxarepe/unpkd_data/GSI_intern/root_files/r3b_st22046080126.root");
//fileList.push_back("/u/land/mxarepe/unpkd_data/GSI_intern/root_files/r3b_st22046081301.root");
//fileList.push_back("/u/land/mxarepe/unpkd_data/GSI_intern/root_files/r3b_st22046075139.root");
//fileList.push_back("/u/land/mxarepe/unpkd_data/GSI_intern/root_files/r3b_st22046074125.root");
//fileList.push_back("/u/land/mxarepe/unpkd_data/GSI_intern/root_files/r3b_st22046073033.root");
for(int s = 0 ; s < fileList.size() ; s++){
TFile *eventFile;
TTree *eventTree;
cout<<"Reading File : "<<fileList.at(s)<<endl;
cout<<endl;
eventFile = TFile::Open(fileList.at(s));
eventTree = (TTree*)eventFile->Get("evt");
eventTree->SetBranchStatus("*",0);
eventTree->SetBranchStatus("R3BRpcHitData.*",1);
eventTree->SetBranchStatus("EventHeader.*",1);
TClonesArray *hitCA = new TClonesArray("R3BRpcHitData");
TBranch *hitBranch = eventTree->GetBranch("R3BRpcHitData");
hitBranch->SetAddress(&hitCA);
R3BEventHeader *fEventHeader = new R3BEventHeader;
eventTree->SetBranchAddress("EventHeader.",&fEventHeader);
Int_t nEvents = eventTree->GetEntries();
Int_t nHits, ntofdHits, nCalifaHits, nCalifaCalHits;
Int_t c = 2048*5;
Int_t tpatbin=0;
double time_Strip=0;
double pos_Strip;
double time_diff;
double pos_scint;
double charge;
double energy_los;
double tofd_Q=0;
double tofd_tof=0;
double rpc_tof=0;
Int_t fTPat=0;
Int_t rpc_strip=0;
Int_t goodEvent,goodCrystalHit;
Int_t goodP2P = 0;
Float_t fEnergy,fTheta2,fTheta1,fPhi1,fPhi2,fEnergy1,fEnergy2,openingAngle;
for(Int_t t = 0; t< nEvents; t++){
hitCA->Clear();
if(t%100000==0)
cout<<t<<endl;
eventTree->GetEvent(t);
nHits = hitCA->GetEntries();
fEnergy=0.0;
goodEvent=0;
goodCrystalHit=0;
if(nHits == 0){continue;}
for(Int_t i = 0; i< nHits; i++){
auto map1 = (R3BRpcHitData*)(hitCA->At(i));
if(map1->GetDetId()==0){
int randtmp = rand()%40;
int strip = map1->GetChannelId();
Pos_histo->Fill(offset[strip-1]+map1->GetPos(),strip*30+(randtmp));
}
}
}
}
TCanvas *C1 = new TCanvas("C1","C1",800,800);
gStyle->SetOptStat(0);
C1->cd();
Pos_histo->SetTitle("RPC detections");
Pos_histo->GetXaxis()->SetTitle("X position");
Pos_histo->GetYaxis()->SetTitle("Strip number");
Pos_histo->Draw("colz");
timer.Stop();
Double_t rtime = timer.RealTime();
Double_t ctime = timer.CpuTime();
std::cout << std::endl << std::endl;
std::cout << "Macro finished succesfully." << std::endl;
std::cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << std::endl << std::endl;
}
# ifndef __CINT__
int main(int argc, char **argv){
TApplication app("app",&argc,argv);
rpc_randomizedY();
app.Run();
return 0 ;
}
#endif