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