]> git.uio.no Git - u/mrichter/AliRoot.git/blame - START/AliSTART.cxx
Major upgrade of AliRoot code
[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$
2ab0c725 18Revision 1.16 2001/01/17 10:56:08 hristov
19Corrections to destructors
20
bff160c8 21Revision 1.15 2001/01/01 13:10:42 hristov
22Local definition of digits removed
23
9d0cd3ab 24Revision 1.14 2000/12/22 16:17:15 hristov
25Updated START code from Alla
26
f3ed336b 27Revision 1.13 2000/12/18 11:39:41 alibrary
28Quick fix to avoid crash in display waiting for new version
29
b169435d 30Revision 1.12 2000/12/04 08:48:19 alibrary
31Fixing problems in the HEAD
32
0cc62300 33Revision 1.11 2000/10/13 13:14:08 hristov
34Bug fixes and code cleaning
35
528332ba 36Revision 1.10 2000/10/02 21:28:13 fca
37Removal of useless dependecies via forward declarations
38
94de3818 39Revision 1.9 2000/07/13 16:41:29 fca
40New START corrected for coding conventions
41
ef51244a 42Revision 1.8 2000/03/27 17:24:25 alla
43Modifing geometry
44
c345bb4f 45Revision 1.6 2000/01/21 15:45:23 fca
46New Version from Alla
47
971579f6 48Revision 1.5 2000/01/19 17:17:15 fca
49Introducing a list of lists of hits -- more hits allowed for detector now
50
1cedd08a 51Revision 1.4 1999/11/12 15:04:00 fca
52Modifications from A.Maevskaya
53
82fc3fb3 54Revision 1.3 1999/09/29 09:24:29 fca
55Introduction of the Copyright and cvs Log
56
4c039060 57*/
58
6ca40650 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
6ca40650 81#include <iostream.h>
82#include <fstream.h>
971579f6 83
84#include "TMath.h"
85#include "TTUBE.h"
86#include "TNode.h"
c345bb4f 87#include "TRandom.h"
971579f6 88#include "TGeometry.h"
2ab0c725 89#include "TFile.h"
0cc62300 90#include "TParticle.h"
2ab0c725 91
971579f6 92#include "AliRun.h"
93#include "AliSTART.h"
94#include "AliSTARTdigit.h"
6ca40650 95#include "AliMC.h"
971579f6 96#include "AliSTARThit.h"
c345bb4f 97#include "AliSTARTvertex.h"
971579f6 98
6ca40650 99ClassImp(AliSTART)
ef51244a 100
101static AliSTARTdigit *digits;
102
6ca40650 103//_____________________________________________________________________________
99560b47 104AliSTART::AliSTART()
6ca40650 105{
106 //
107 // Default constructor for class AliSTART
108 //
f3ed336b 109 fIshunt = 1;
971579f6 110 fHits = 0;
111 fDigits = 0;
6ca40650 112}
113
114//_____________________________________________________________________________
115AliSTART::AliSTART(const char *name, const char *title)
116 : AliDetector(name,title)
117{
118 //
119 // Standard constructor for START Detector
120 //
971579f6 121
c345bb4f 122
6ca40650 123 //
124 // Initialise Hit array
971579f6 125 fHits = new TClonesArray("AliSTARThit", 405);
b169435d 126 gAlice->AddHitList(fHits);
6ca40650 127
f3ed336b 128 fIshunt = 1;
c345bb4f 129 fIdSens = 0;
6ca40650 130 SetMarkerColor(kRed);
131}
bff160c8 132
133//_____________________________________________________________________________
134AliSTART::~AliSTART() {
135 if (fHits) {
136 fHits->Delete();
137 delete fHits;
138 }
139}
6ca40650 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}
971579f6 150
151//_____________________________________________________________________________
c345bb4f 152
971579f6 153void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
154{
c345bb4f 155
f3ed336b 156 // Add a START digit to the list. Dummy function.
c345bb4f 157
971579f6 158}
c345bb4f 159
6ca40650 160//_____________________________________________________________________________
161void AliSTART::BuildGeometry()
162{
163 //
164 // Build simple ROOT TNode geometry for event display
165 //
ef51244a 166 TNode *node, *top;
6ca40650 167 const int kColorSTART = 19;
f3ed336b 168
ef51244a 169 top=gAlice->GetGeometry()->GetNode("alice");
6ca40650 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);
ef51244a 175 top->cd();
176 node = new TNode("STR1","STR1","S_STR1",0,0,75.,"");
177 node->SetLineColor(kColorSTART);
178 fNodes->Add(node);
6ca40650 179
180 new TTUBE("S_STR2","START volume 2","void",5.,10.7,5.3);
ef51244a 181 top->cd();
182 node = new TNode("STR2","STR2","S_STR2",0,0,-75,"rot999");
183 node->SetLineColor(kColorSTART);
184 fNodes->Add(node);
6ca40650 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
6ca40650 197//-------------------------------------------------------------------------
198void AliSTART::Init()
199{
200 //
201 // Initialis the START after it has been built
202 Int_t i;
6ca40650 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");
971579f6 213 //
214 //
c345bb4f 215 // fIdSensRad=gMC->VolId("PTOP");
216 // fIdSensPC =gMC->VolId("T0PC");
6ca40650 217
218}
219
220//---------------------------------------------------------------------------
2ab0c725 221void AliSTART::MakeBranch(Option_t* option, char *file)
6ca40650 222{
ef51244a 223 //
224 // Specific START branches
225 //
6ca40650 226 // Create Tree branches for the START.
c345bb4f 227 Int_t buffersize = 400;
6ca40650 228 char branchname[10];
229 sprintf(branchname,"%s",GetName());
230
2ab0c725 231 AliDetector::MakeBranch(option,file);
6ca40650 232
2ab0c725 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 }
c345bb4f 240/*
2ab0c725 241 char *cR = strstr(option,"R");
242
243 if (cR) {
244 gAlice->MakeBranchInTree(gAlice->TreeR(),
245 branchname, "Int_t", &fZposit, buffersize, 1, file) ;
246 }
c345bb4f 247 */
6ca40650 248}
971579f6 249
250//_____________________________________________________________________________
c345bb4f 251
971579f6 252void AliSTART::Hit2digit(Int_t evnum)
253{
ef51244a 254 //
255 // From hits to digits
256 //
257 Float_t x,y,e;
971579f6 258 Int_t nbytes = 0;
ef51244a 259 Int_t hit;
971579f6 260 Int_t nhits;
261 Int_t volume,pmt;
c345bb4f 262 char nameTH[8],nameTD[8];
263 Float_t timediff,timeright,timeleft,timeav;
264 Float_t besttimeright,besttimeleft,meanTime;
ef51244a 265 Int_t channelWidth=10;
971579f6 266
267 TParticle *particle;
971579f6 268 AliSTARThit *startHit;
269
c345bb4f 270 Int_t buffersize=256;
271 Int_t split=1;
272
273 digits= new AliSTARTdigit();
274 TBranch *bDig=0;
971579f6 275
c345bb4f 276
277 // Event ------------------------- LOOP
278
279 sprintf(nameTD,"TreeD%d",evnum);
ef51244a 280 TTree *td = new TTree(nameTD,"START");
281 bDig = td->Branch("START","AliSTARTdigit",&digits,buffersize,split);
971579f6 282
283 besttimeright=9999.;
284 besttimeleft=9999.;
ef51244a 285 Int_t timeDiff=0;
286 Int_t timeAv=0;
971579f6 287
288 Int_t nparticles = gAlice->GetEvent(evnum);
289 if (nparticles <= 0) return;
290 printf("\n nparticles %d\n",nparticles);
291
c345bb4f 292
971579f6 293 sprintf(nameTH,"TreeH%d",evnum);
294 printf("%s\n",nameTH);
ef51244a 295 TTree *th = gAlice->TreeH();
296 Int_t ntracks = (Int_t) th->GetEntries();
971579f6 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();
ef51244a 301 nbytes += th->GetEvent(track);
2ab0c725 302 particle=gAlice->Particle(track);
c345bb4f 303 nhits =fHits->GetEntriesFast();
304
971579f6 305 for (hit=0;hit<nhits;hit++) {
306 startHit = (AliSTARThit*)fHits->UncheckedAt(hit);
307 pmt=startHit->fPmt;
308 e=startHit->fEtot;
94de3818 309 x=startHit->X();
310 y=startHit->Y();
971579f6 311 volume = startHit->fVolume;
312 if(volume==1){
313 timeright = startHit->fTime;
314 if(timeright<besttimeright) {
315 besttimeright=timeright;
971579f6 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;
971579f6 323 } //timeleftbest
324 }//time for left shoulder
325 } //hit loop
326 } //track loop
971579f6 327
c345bb4f 328 //folding with experimental time distribution
ef51244a 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.)
c345bb4f 334 {
ef51244a 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;
971579f6 338
ef51244a 339 ppBunch=ppBunch-10/2;
c345bb4f 340 Float_t t1=1000.*besttimeleftGaus;
341 Float_t t2=1000.*besttimerightGaus;
ef51244a 342 t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
343 t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
c345bb4f 344
345 timeav=(t1+t2)/2.;
346
347 // Time to TDC signal
348 // 256 channels for timediff, range 1ns
349
ef51244a 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 }
f3ed336b 356 else
357 {timeAv=999999; timeDiff=99999;}
358
359 td->Fill();
360 printf("digits-> %d \n",digits->GetTime());
361 td->Write();
c345bb4f 362
f3ed336b 363}
c345bb4f 364
365
366
367
368
369
370
371
372
6ca40650 373
971579f6 374
ef51244a 375
971579f6 376
c345bb4f 377