]>
Commit | Line | Data |
---|---|---|
4c039060 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | $Log$ | |
c345bb4f | 18 | Revision 1.6 2000/01/21 15:45:23 fca |
19 | New Version from Alla | |
20 | ||
971579f6 | 21 | Revision 1.5 2000/01/19 17:17:15 fca |
22 | Introducing a list of lists of hits -- more hits allowed for detector now | |
23 | ||
1cedd08a | 24 | Revision 1.4 1999/11/12 15:04:00 fca |
25 | Modifications from A.Maevskaya | |
26 | ||
82fc3fb3 | 27 | Revision 1.3 1999/09/29 09:24:29 fca |
28 | Introduction of the Copyright and cvs Log | |
29 | ||
4c039060 | 30 | */ |
31 | ||
6ca40650 | 32 | /////////////////////////////////////////////////////////////////////////////// |
33 | // // | |
34 | // START (T-Zero) Detector // | |
35 | // This class contains the base procedures for the START // | |
36 | // detector // | |
37 | // // | |
38 | //Begin_Html | |
39 | /* | |
40 | <img src="gif/AliSTARTClass.gif"> | |
41 | </pre> | |
42 | <br clear=left> | |
43 | <font size=+2 color=red> | |
44 | <p>The responsible person for this module is | |
45 | <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>. | |
46 | </font> | |
47 | <pre> | |
48 | */ | |
49 | //End_Html | |
50 | // // | |
51 | // // | |
52 | /////////////////////////////////////////////////////////////////////////////// | |
53 | ||
6ca40650 | 54 | #include <iostream.h> |
55 | #include <fstream.h> | |
971579f6 | 56 | |
57 | #include "TMath.h" | |
58 | #include "TTUBE.h" | |
59 | #include "TNode.h" | |
c345bb4f | 60 | #include "TRandom.h" |
971579f6 | 61 | #include "TGeometry.h" |
62 | #include "AliRun.h" | |
63 | #include "AliSTART.h" | |
64 | #include "AliSTARTdigit.h" | |
6ca40650 | 65 | #include "AliMC.h" |
971579f6 | 66 | #include "AliSTARThit.h" |
c345bb4f | 67 | #include "AliSTARTvertex.h" |
971579f6 | 68 | |
6ca40650 | 69 | ClassImp(AliSTART) |
c345bb4f | 70 | AliSTARTdigit *digits; |
6ca40650 | 71 | //_____________________________________________________________________________ |
99560b47 | 72 | AliSTART::AliSTART() |
6ca40650 | 73 | { |
74 | // | |
75 | // Default constructor for class AliSTART | |
76 | // | |
77 | fIshunt = 0; | |
971579f6 | 78 | fHits = 0; |
79 | fDigits = 0; | |
6ca40650 | 80 | } |
81 | ||
82 | //_____________________________________________________________________________ | |
83 | AliSTART::AliSTART(const char *name, const char *title) | |
84 | : AliDetector(name,title) | |
85 | { | |
86 | // | |
87 | // Standard constructor for START Detector | |
88 | // | |
971579f6 | 89 | |
c345bb4f | 90 | |
6ca40650 | 91 | // |
92 | // Initialise Hit array | |
971579f6 | 93 | fHits = new TClonesArray("AliSTARThit", 405); |
c345bb4f | 94 | // gAlice->AddHitList(fHits); |
95 | // fDigits = new TClonesArray("AliSTARTdigit",500); | |
6ca40650 | 96 | |
97 | fIshunt = 0; | |
c345bb4f | 98 | fIdSens = 0; |
6ca40650 | 99 | SetMarkerColor(kRed); |
100 | } | |
101 | ||
102 | //_____________________________________________________________________________ | |
103 | void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits) | |
104 | { | |
105 | // | |
106 | // Add a START hit | |
107 | // | |
108 | TClonesArray &lhits = *fHits; | |
109 | new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits); | |
110 | } | |
971579f6 | 111 | |
112 | //_____________________________________________________________________________ | |
c345bb4f | 113 | |
971579f6 | 114 | void AliSTART::AddDigit(Int_t *tracks,Int_t *digits) |
115 | { | |
c345bb4f | 116 | |
117 | // Add a START digit to the list | |
118 | ||
119 | // printf (" AddDigit*******"); | |
120 | // TClonesArray &ldigits = *fDigits; | |
121 | // new(ldigits[fNdigits++]) AliSTARTdigit(tracks,digits); | |
971579f6 | 122 | } |
c345bb4f | 123 | |
6ca40650 | 124 | //_____________________________________________________________________________ |
125 | void AliSTART::BuildGeometry() | |
126 | { | |
127 | // | |
128 | // Build simple ROOT TNode geometry for event display | |
129 | // | |
130 | TNode *Node, *Top; | |
131 | const int kColorSTART = 19; | |
132 | // | |
133 | Top=gAlice->GetGeometry()->GetNode("alice"); | |
134 | ||
135 | // START define the different volumes | |
136 | new TRotMatrix("rot999","rot999", 90,0,90,90,180,0); | |
137 | ||
138 | new TTUBE("S_STR1","START volume 1","void",5.,10.7,5.3); | |
139 | Top->cd(); | |
140 | Node = new TNode("STR1","STR1","S_STR1",0,0,75.,""); | |
141 | Node->SetLineColor(kColorSTART); | |
142 | fNodes->Add(Node); | |
143 | ||
144 | new TTUBE("S_STR2","START volume 2","void",5.,10.7,5.3); | |
145 | Top->cd(); | |
146 | Node = new TNode("STR2","STR2","S_STR2",0,0,-75,"rot999"); | |
147 | Node->SetLineColor(kColorSTART); | |
148 | fNodes->Add(Node); | |
149 | } | |
150 | ||
151 | //_____________________________________________________________________________ | |
152 | Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py) | |
153 | { | |
154 | // | |
155 | // Calculate the distance from the mouse to the START on the screen | |
156 | // Dummy routine | |
157 | // | |
158 | return 9999; | |
159 | } | |
160 | ||
6ca40650 | 161 | //------------------------------------------------------------------------- |
162 | void AliSTART::Init() | |
163 | { | |
164 | // | |
165 | // Initialis the START after it has been built | |
166 | Int_t i; | |
6ca40650 | 167 | // |
168 | printf("\n"); | |
169 | for(i=0;i<35;i++) printf("*"); | |
170 | printf(" START_INIT "); | |
171 | for(i=0;i<35;i++) printf("*"); | |
172 | printf("\n"); | |
173 | // | |
174 | // Here the START initialisation code (if any!) | |
175 | for(i=0;i<80;i++) printf("*"); | |
176 | printf("\n"); | |
971579f6 | 177 | // |
178 | // | |
c345bb4f | 179 | // fIdSensRad=gMC->VolId("PTOP"); |
180 | // fIdSensPC =gMC->VolId("T0PC"); | |
6ca40650 | 181 | |
182 | } | |
183 | ||
184 | //--------------------------------------------------------------------------- | |
185 | void AliSTART::MakeBranch(Option_t* option) | |
186 | { | |
187 | ||
c345bb4f | 188 | AliSTARTdigit *digits; |
6ca40650 | 189 | // Create Tree branches for the START. |
c345bb4f | 190 | Int_t buffersize = 400; |
6ca40650 | 191 | char branchname[10]; |
192 | sprintf(branchname,"%s",GetName()); | |
193 | ||
194 | AliDetector::MakeBranch(option); | |
195 | ||
c345bb4f | 196 | TTree *TD = gAlice->TreeD(); |
197 | digits = new AliSTARTdigit(); | |
198 | TD->Branch(branchname,"AliSTARTdigit",&digits, buffersize); | |
199 | printf("Making Branch %s for digits\n",branchname); | |
200 | ||
201 | /* | |
202 | gAlice->TreeR()->Branch(branchname,"Int_t",&fZposit, buffersize); | |
203 | printf("Making Branch %s for vertex position %d\n",branchname); | |
204 | */ | |
6ca40650 | 205 | } |
971579f6 | 206 | |
207 | //_____________________________________________________________________________ | |
c345bb4f | 208 | |
971579f6 | 209 | void AliSTART::Hit2digit(Int_t evnum) |
210 | { | |
211 | ||
c345bb4f | 212 | Float_t x,y,z,e; |
971579f6 | 213 | Int_t nbytes = 0; |
c345bb4f | 214 | Int_t j,hit; |
971579f6 | 215 | Int_t nhits; |
216 | Int_t volume,pmt; | |
c345bb4f | 217 | char nameTH[8],nameTD[8]; |
218 | Float_t timediff,timeright,timeleft,timeav; | |
219 | Float_t besttimeright,besttimeleft,meanTime; | |
971579f6 | 220 | Int_t channel_width=10; |
971579f6 | 221 | |
222 | TParticle *particle; | |
971579f6 | 223 | AliSTARThit *startHit; |
224 | ||
c345bb4f | 225 | Int_t buffersize=256; |
226 | Int_t split=1; | |
227 | ||
228 | digits= new AliSTARTdigit(); | |
229 | TBranch *bDig=0; | |
971579f6 | 230 | |
c345bb4f | 231 | /* |
232 | // Create histograms | |
233 | ||
234 | TH1F *hTimediff = new TH1F("hTimediff","Time different",100,-2,2); | |
235 | TH1F *hMeanTime = new TH1F("hMeanTime","Mean Time",100,2.2,2.8); | |
236 | ||
237 | TH1F *hTime1stright = new TH1F("hTime1stright","Time flight of 1st particle right", 100,1.5,3.2); | |
238 | TH1F *hTime1stleft = new TH1F("hTime1sleft","Time flight of 1st particle left",100,1.5,3.2); | |
239 | ||
240 | */ | |
241 | // AliSTART *START = (AliSTART*) gAlice->GetDetector("START"); | |
242 | ||
243 | // Event ------------------------- LOOP | |
244 | ||
245 | sprintf(nameTD,"TreeD%d",evnum); | |
246 | TTree *TD = new TTree(nameTD,"START"); | |
247 | bDig = TD->Branch("START","AliSTARTdigit",&digits,buffersize,split); | |
971579f6 | 248 | |
249 | besttimeright=9999.; | |
250 | besttimeleft=9999.; | |
c345bb4f | 251 | Int_t Timediff=0; |
252 | Int_t Timeav=0; | |
971579f6 | 253 | |
254 | Int_t nparticles = gAlice->GetEvent(evnum); | |
255 | if (nparticles <= 0) return; | |
256 | printf("\n nparticles %d\n",nparticles); | |
257 | ||
258 | TClonesArray *Particles = gAlice->Particles(); | |
c345bb4f | 259 | |
971579f6 | 260 | sprintf(nameTH,"TreeH%d",evnum); |
261 | printf("%s\n",nameTH); | |
262 | TTree *TH = gAlice->TreeH(); | |
263 | Int_t ntracks = (Int_t) TH->GetEntries(); | |
264 | if (ntracks<=0) return; | |
265 | // Start loop on tracks in the hits containers | |
266 | for (Int_t track=0; track<ntracks;track++) { | |
267 | gAlice->ResetHits(); | |
268 | nbytes += TH->GetEvent(track); | |
269 | particle=(TParticle*)Particles->UncheckedAt(track); | |
c345bb4f | 270 | nhits =fHits->GetEntriesFast(); |
271 | ||
971579f6 | 272 | for (hit=0;hit<nhits;hit++) { |
273 | startHit = (AliSTARThit*)fHits->UncheckedAt(hit); | |
274 | pmt=startHit->fPmt; | |
275 | e=startHit->fEtot; | |
276 | x=startHit->fX; | |
277 | y=startHit->fY; | |
278 | volume = startHit->fVolume; | |
279 | if(volume==1){ | |
280 | timeright = startHit->fTime; | |
281 | if(timeright<besttimeright) { | |
282 | besttimeright=timeright; | |
971579f6 | 283 | } //timeright |
284 | }//time for right shoulder | |
285 | if(volume==2){ | |
286 | timeleft = startHit->fTime; | |
287 | // printf("timeleft %f\n",timeleft); | |
288 | if(timeleft<besttimeleft) { | |
289 | besttimeleft=timeleft; | |
971579f6 | 290 | } //timeleftbest |
291 | }//time for left shoulder | |
292 | } //hit loop | |
293 | } //track loop | |
971579f6 | 294 | |
c345bb4f | 295 | //folding with experimental time distribution |
296 | Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05); | |
297 | Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05); | |
298 | timediff=besttimerightGaus-besttimeleftGaus; | |
299 | meanTime=(besttimerightGaus+besttimeleftGaus)/2.; | |
300 | if ( TMath::Abs(timediff)<2. && meanTime<3.) | |
301 | { | |
302 | //we assume centre of bunch is 5ns after TTS signal | |
303 | //TOF values are relative of the end of bunch | |
304 | // hTimediff->Fill(timediff); | |
305 | //hMeanTime->Fill(meanTime); | |
306 | Float_t pp_bunch=25; | |
971579f6 | 307 | |
c345bb4f | 308 | pp_bunch=pp_bunch-10/2; |
309 | Float_t t1=1000.*besttimeleftGaus; | |
310 | Float_t t2=1000.*besttimerightGaus; | |
311 | t1=t1/channel_width+pp_bunch; //time in ps to channel_width | |
312 | t2=t2/channel_width+pp_bunch; //time in ps to channel_width | |
313 | ||
314 | timeav=(t1+t2)/2.; | |
315 | ||
316 | // Time to TDC signal | |
317 | // 256 channels for timediff, range 1ns | |
318 | ||
319 | timediff=128+1000*timediff/channel_width; // time in ps | |
6ca40650 | 320 | |
c345bb4f | 321 | |
322 | Timeav = (Int_t)(timeav); // time in ps | |
323 | Timediff = (Int_t)(timediff); // time in ps | |
324 | digits->Set(Timeav,Timediff); | |
325 | TD->Fill(); | |
326 | digits->MyDump(); | |
327 | TD->Write(); | |
328 | } //timediff | |
329 | ||
330 | ||
331 | } // end macro | |
332 | ||
333 | ||
334 | ||
335 | ||
336 | ||
337 | ||
338 | ||
339 | ||
340 | ||
6ca40650 | 341 | |
971579f6 | 342 | |
971579f6 | 343 | |
c345bb4f | 344 |