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