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