]>
Commit | Line | Data |
---|---|---|
85da5382 | 1 | #ifndef __CINT__ |
2 | #include "alles.h" | |
3 | #include "GetGoodParticles.h" | |
4 | #include "AliL3Transform.h" | |
5 | #endif | |
6 | ||
7 | ||
b1886074 | 8 | void GetGoodParticles(Int_t minslice,Int_t maxslice,char *eventfile,char *digitfile,Int_t event) |
85da5382 | 9 | { |
10 | ||
4ab9f8f0 | 11 | Int_t good_number = 70; //Minimum number of points on a good track |
85da5382 | 12 | |
13 | struct GoodTrack goodtracks[15000]; | |
14 | Int_t nt=0; | |
15 | char *fname = "good_tracks"; | |
16 | ||
17 | ifstream in(fname); | |
18 | if(in) | |
19 | { | |
20 | printf("Delete you old good_tracks file\n"); | |
21 | return; | |
22 | } | |
23 | ||
24 | TFile *evfile = TFile::Open(eventfile); | |
25 | if(!evfile) | |
26 | { | |
27 | printf("No eventfile\n"); | |
28 | return; | |
29 | } | |
30 | gAlice = (AliRun*)evfile->Get("gAlice"); | |
b1886074 | 31 | gAlice->GetEvent(event); |
85da5382 | 32 | |
33 | AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC"); | |
34 | AliTPCParam *param = (AliTPCParam*)evfile->Get("75x40_100x60"); | |
35 | ||
36 | TPC->SetParam(param); | |
37 | ||
38 | Int_t ver = TPC->IsVersion(); | |
39 | if(ver!=2) | |
40 | { | |
41 | printf("Wrong TPC version\n"); | |
42 | return; | |
43 | } | |
44 | ||
45 | Int_t zero=TPC->GetParam()->GetZeroSup(); | |
46 | ||
47 | Int_t np = gAlice->GetNtrack(); | |
48 | Int_t *good = new Int_t[np]; | |
49 | for(Int_t ii=0; ii<np; ii++) | |
50 | good[ii] = 0; | |
51 | ||
4ab9f8f0 | 52 | |
85da5382 | 53 | |
54 | TFile *digfile = TFile::Open(digitfile); | |
b1886074 | 55 | Char_t dname[100]; |
56 | sprintf(dname,"TreeD_75x40_100x60_%d",event); | |
57 | TTree *tree=(TTree*)digfile->Get(dname); | |
85da5382 | 58 | AliSimDigits da, *digits=&da; |
59 | tree->GetBranch("Segment")->SetAddress(&digits); | |
60 | ||
61 | Int_t *count = new Int_t[np]; //np number of particles. | |
62 | Int_t i; | |
63 | for (i=0; i<np; i++) count[i]=0; | |
64 | for(i=0; i<tree->GetEntries(); i++) | |
65 | { | |
66 | if (!tree->GetEvent(i)) continue; | |
67 | Int_t sec,row; | |
68 | param->AdjustSectorRow(digits->GetID(),sec,row); | |
69 | Int_t sl,padrow; | |
4ab9f8f0 | 70 | AliL3Transform::Sector2Slice(sl,padrow,sec,row); |
722130ee | 71 | if(sl < minslice) continue; |
72 | if(sl > maxslice) break; | |
85da5382 | 73 | digits->First(); |
74 | do { | |
75 | Int_t it=digits->CurrentRow(), ip=digits->CurrentColumn(); | |
76 | Short_t dig = digits->GetDigit(it,ip); | |
77 | Int_t idx0=digits->GetTrackID(it,ip,0); | |
78 | Int_t idx1=digits->GetTrackID(it,ip,1); | |
79 | Int_t idx2=digits->GetTrackID(it,ip,2); | |
80 | ||
81 | if (idx0>=0 && dig>=zero) count[idx0]+=1; | |
82 | if (idx1>=0 && dig>=zero) count[idx1]+=1; | |
83 | if (idx2>=0 && dig>=zero) count[idx2]+=1; | |
b1886074 | 84 | } while (digits->Next()); |
85da5382 | 85 | |
86 | for (Int_t j=0; j<np; j++) | |
87 | { | |
88 | if (count[j]>1) //at least two digits at this padrow | |
89 | good[j]++; | |
90 | ||
91 | count[j]=0; | |
92 | } | |
93 | } | |
94 | ||
95 | delete[] count; | |
96 | ||
97 | ||
98 | //The following code has been taken from offlinemacro->AliTPCComparison.C | |
99 | ||
100 | TTree *TH=gAlice->TreeH(); | |
101 | Int_t npart=(Int_t)TH->GetEntries(); | |
b1886074 | 102 | cout<<"Found "<<npart<<" particles in this event"<<endl; |
85da5382 | 103 | |
104 | ||
105 | while (npart--) { | |
106 | AliTPChit *hit0=0; | |
107 | ||
108 | TPC->ResetHits(); | |
109 | TH->GetEvent(npart); | |
110 | AliTPChit * hit = (AliTPChit*) TPC->FirstHit(-1); | |
111 | while (hit){ | |
112 | if (hit->fQ==0.) break; | |
113 | hit = (AliTPChit*) TPC->NextHit(); | |
114 | } | |
115 | if (hit) { | |
116 | hit0 = new AliTPChit(*hit); //Make copy of hit | |
117 | hit = hit0; | |
118 | } | |
119 | else continue; | |
120 | AliTPChit *hit1=(AliTPChit*)TPC->NextHit(); | |
121 | if (hit1==0) continue; | |
122 | if (hit1->fQ != 0.) continue; | |
123 | Int_t i=hit->Track(); | |
124 | TParticle *p = (TParticle*)gAlice->Particle(i); | |
b1886074 | 125 | |
85da5382 | 126 | if (p->GetFirstMother()>=0) continue; //secondary particle |
127 | if (good[i] < good_number) continue; | |
128 | if (p->Pt() < 0.1) continue; | |
129 | if (TMath::Abs(p->Pz()/p->Pt())>0.999) continue; | |
b1886074 | 130 | cout<<"Checking particle with "<<good[i]<<" hits, and pt: "<<p->Pt()<<endl; |
85da5382 | 131 | goodtracks[nt].eta = p->Eta(); |
132 | goodtracks[nt].label=i; | |
133 | goodtracks[nt].code=p->GetPdgCode(); | |
134 | goodtracks[nt].px=hit->X(); goodtracks[nt].py=hit->Y(); goodtracks[nt].pz=hit->Z(); | |
135 | goodtracks[nt].pt = p->Pt(); | |
136 | goodtracks[nt].nhits = good[i]; | |
137 | nt++; | |
138 | ||
139 | if (hit0) delete hit0; | |
140 | } | |
b1886074 | 141 | cout<<"Found "<<nt<<" good tracks in this event"<<endl; |
85da5382 | 142 | ofstream out(fname); |
143 | if(out) | |
144 | { | |
145 | for (Int_t ngd=0; ngd<nt; ngd++) | |
146 | out<<goodtracks[ngd].label<<' '<<goodtracks[ngd].code<<' '<< | |
147 | goodtracks[ngd].px<<' '<<goodtracks[ngd].py<<' '<<goodtracks[ngd].pz<<' '<< | |
148 | goodtracks[ngd].pt<<' '<<goodtracks[ngd].eta<<' '<<goodtracks[ngd].nhits<<endl; | |
149 | ||
150 | } | |
151 | else | |
152 | printf("cannot open file\n"); | |
153 | ||
154 | out.close(); | |
155 | ||
156 | delete [] good; | |
157 | ||
158 | evfile->Close(); | |
159 | digfile->Close(); | |
160 | ||
85da5382 | 161 | |
162 | } |