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