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