2 /**************************************************************************
3 * Copyright(c) 1998-2000, ALICE Experiment at CERN, All rights reserved. *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
20 #include <TObjArray.h>
22 #include <TDirectory.h>
26 #include "AliSTARTDigitizer.h"
28 #include "AliSTARThit.h"
29 #include "AliSTARTdigit.h"
30 #include "AliRunDigitizer.h"
39 ClassImp(AliSTARTDigitizer)
41 //___________________________________________
42 AliSTARTDigitizer::AliSTARTDigitizer() :AliDigitizer()
44 // Default ctor - don't use it
48 //___________________________________________
49 AliSTARTDigitizer::AliSTARTDigitizer(AliRunDigitizer* manager)
50 :AliDigitizer(manager)
52 cout<<"AliSTARTDigitizer::AliSTARTDigitizer"<<endl;
53 // ctor which should be used
56 // cerr<<"AliSTARTDigitizer::AliSTARTDigitizer"
57 // <<"(AliRunDigitizer* manager) was processed"<<endl;
61 //------------------------------------------------------------------------
62 AliSTARTDigitizer::~AliSTARTDigitizer()
69 //------------------------------------------------------------------------
70 Bool_t AliSTARTDigitizer::Init()
73 cout<<"AliSTARTDigitizer::Init"<<endl;
78 //---------------------------------------------------------------------
80 void AliSTARTDigitizer::Exec(Option_t* option)
86 cout<<"AliSTARTDigitizer::>SDigits2Digits start...\n";
89 // From hits to digits
95 Float_t timediff,timeright,timeleft,timeav;
96 Float_t besttimeright,besttimeleft,meanTime;
97 Int_t channelWidth=10;
98 fHits = new TClonesArray ("AliSTARThit", 1000);
99 AliSTART *START = (AliSTART*) gAlice->GetDetector("START");
101 AliSTARThit *startHit;
103 fdigits= new AliSTARTdigit();
105 Int_t nFiles=fManager->GetNinputs();
106 for (Int_t inputFile=0; inputFile<nFiles; inputFile++) {
107 sprintf(nameDigits,"START_D_%d",fManager->GetOutputEventNr());
113 TClonesArray *STARThits = START->Hits ();
115 TTree *th = fManager->GetInputTreeH(inputFile);
116 brHits = th->GetBranch("START");
118 START->SetHitsAddressBranch(brHits);
120 cerr<<"EXEC Branch START hit not found"<<endl;
123 Int_t ntracks = (Int_t) th->GetEntries();
124 if (ntracks<=0) return;
125 // Start loop on tracks in the hits containers
126 for (Int_t track=0; track<ntracks;track++) {
127 brHits->GetEntry(track);
128 nhits = STARThits->GetEntriesFast();
129 for (hit=0;hit<nhits;hit++) {
130 startHit = (AliSTARThit*) STARThits->UncheckedAt(hit);
132 volume = startHit->fVolume;
134 timeright = startHit->fTime;
135 if(timeright<besttimeright) {
136 besttimeright=timeright;
138 }//time for right shoulder
140 timeleft = startHit->fTime;
141 if(timeleft<besttimeleft) {
142 besttimeleft=timeleft;
144 }//time for left shoulder
148 //folding with experimental time distribution
149 Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
150 Float_t koef=69.7/350.;
151 besttimeleft=koef*besttimeleft;
152 Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
153 timediff=besttimerightGaus-besttimeleftGaus;
154 meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
155 if ( TMath::Abs(timediff)<TMath::Abs(3.) && meanTime<TMath::Abs(5.))
157 //we assume centre of bunch is 5ns after TTS signal
158 //TOF values are relative of the end of bunch
161 ppBunch=ppBunch-10/2;
162 Float_t t1=1000.*besttimeleftGaus;
163 Float_t t2=1000.*besttimerightGaus;
164 t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
165 t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
168 // Time to TDC signal
169 // 256 channels for timediff, range 1ns
171 timediff=128+1000*timediff/channelWidth; // time in ps
173 timeAv = (Int_t)(timeav); // time (ps) channel numbres
174 timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
175 fdigits->Set(timeAv,timeDiff);
179 {timeAv=999999; timeDiff=99999;}
181 // trick to find out output dir:
182 TTree *outTree = fManager->GetTreeD();
184 cerr<<"something wrong with output...."<<endl;
187 TDirectory *wd = gDirectory;
188 outTree->GetDirectory()->cd();
189 fdigits->Write(nameDigits);