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