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"<<exit;
122 Int_t ntracks = (Int_t) th->GetEntries();
123 if (ntracks<=0) return;
124 // Start loop on tracks in the hits containers
125 for (Int_t track=0; track<ntracks;track++) {
126 brHits->GetEntry(track);
127 nhits = STARThits->GetEntriesFast();
128 for (hit=0;hit<nhits;hit++) {
129 startHit = (AliSTARThit*) STARThits->UncheckedAt(hit);
131 volume = startHit->fVolume;
133 timeright = startHit->fTime;
134 if(timeright<besttimeright) {
135 besttimeright=timeright;
137 }//time for right shoulder
139 timeleft = startHit->fTime;
140 // printf("timeleft %f\n",timeleft);
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 besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
151 timediff=besttimerightGaus-besttimeleftGaus;
152 meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
153 if ( TMath::Abs(timediff)<TMath::Abs(10.) && meanTime<TMath::Abs(7.1))
155 //we assume centre of bunch is 5ns after TTS signal
156 //TOF values are relative of the end of bunch
159 ppBunch=ppBunch-10/2;
160 Float_t t1=1000.*besttimeleftGaus;
161 Float_t t2=1000.*besttimerightGaus;
162 t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
163 t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
167 // Time to TDC signal
168 // 256 channels for timediff, range 1ns
170 timediff=128+1000*timediff/channelWidth; // time in ps
172 timeAv = (Int_t)(timeav); // time (ps) channel numbres
173 timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
174 fdigits->Set(timeAv,timeDiff);
178 {timeAv=999999; timeDiff=99999;}
180 // trick to find out output dir:
181 TTree *outTree = fManager->GetTreeD();
183 cerr<<"something wrong with output...."<<exit;
186 TDirectory *wd = gDirectory;
187 outTree->GetDirectory()->cd();
188 fdigits->Write(nameDigits);