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