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 <TDirectory.h>
27 #include "AliSTARTDigitizer.h"
29 #include "AliSTARThit.h"
30 #include "AliSTARTdigit.h"
31 #include "AliRunDigitizer.h"
32 #include <AliDetector.h>
34 #include <AliLoader.h>
35 #include <AliRunLoader.h>
37 #include <Riostream.h>
38 #include <Riostream.h>
40 ClassImp(AliSTARTDigitizer)
42 //___________________________________________
43 AliSTARTDigitizer::AliSTARTDigitizer() :AliDigitizer()
45 // Default ctor - don't use it
49 //___________________________________________
50 AliSTARTDigitizer::AliSTARTDigitizer(AliRunDigitizer* manager)
51 :AliDigitizer(manager)
53 // cout<<"AliSTARTDigitizer::AliSTARTDigitizer"<<endl;
54 // ctor which should be used
56 AliDebug(1,"processed");
58 ftimeTDC = new TArrayI(24);
59 fADC = new TArrayI(24);
62 //------------------------------------------------------------------------
63 AliSTARTDigitizer::~AliSTARTDigitizer()
72 //------------------------------------------------------------------------
73 Bool_t AliSTARTDigitizer::Init()
81 //---------------------------------------------------------------------
83 void AliSTARTDigitizer::Exec(Option_t* /*option*/)
87 Produde digits from hits
88 digits is TObject and includes
89 We are writing array if left & right TDC
90 left & right ADC (will need for slow simulation)
91 TOF first particle left & right
92 mean time and time difference (vertex position)
96 AliRunLoader *inRL, *outRL;//in and out Run Loaders
97 AliLoader *pInStartLoader, *pOutStartLoader;// in and out STARTLoaders
99 outRL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
100 pOutStartLoader = outRL->GetLoader("STARTLoader");
102 AliDebug(1,"start...");
105 // From hits to digits
110 Int_t volume,pmt,tr,sumRight;
111 Int_t bestRightTDC,bestLeftTDC;
112 Float_t time[24]={24*0};
113 Float_t besttime[24]={24*0};
114 Float_t timeGaus[37]={24*0};
115 Float_t channelWidth=25.; //ps
117 AliSTARThit *startHit;
120 pOutStartLoader->LoadDigits("UPDATE");//probably it is necessary to load them before
121 fdigits= new AliSTARTdigit();
122 pOutStartLoader->GetDigitsDataLoader()->GetBaseLoader(0)->Post(fdigits);
124 Int_t nFiles=fManager->GetNinputs();
125 for (Int_t inputFile=0; inputFile<nFiles; inputFile++) {
126 if (inputFile < nFiles-1) {
127 AliWarning(Form("ignoring input stream %d", inputFile));
132 Float_t besttimeright=9999.;
133 Float_t besttimeleft=9999.;
136 for (Int_t i0=0; i0<24; i0++)
138 time[i0]=9999; besttime[i0]=9999; countE[i0]=0;
141 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
142 if (!inRL->GetAliRun()) inRL->LoadgAlice();
143 AliSTART *fSTART = (AliSTART*) inRL->GetAliRun()->GetDetector("START");
144 pInStartLoader = inRL->GetLoader("STARTLoader");
145 pInStartLoader->LoadHits("READ");//probably it is necessary to load them before
146 TClonesArray *fHits = fSTART->Hits ();
148 TTree *th = pInStartLoader->TreeH();
149 brHits = th->GetBranch("START");
151 fSTART->SetHitsAddressBranch(brHits);
153 AliError("Branch START hit not found");
156 Int_t ntracks = (Int_t) th->GetEntries();
158 if (ntracks<=0) return;
159 // Start loop on tracks in the hits containers
160 for (Int_t track=0; track<ntracks;track++) {
161 brHits->GetEntry(track);
162 nhits = fHits->GetEntriesFast();
163 for (hit=0;hit<nhits;hit++)
165 startHit = (AliSTARThit*) fHits->UncheckedAt(hit);
167 AliError("The unchecked hit doesn't exist");
172 Float_t e=startHit->Etot();
173 volume = startHit->Volume();
174 if(RegisterPhotoE(e)) countE[numpmt]++;
175 besttime[numpmt] = startHit->Time();
176 if(besttime[numpmt]<time[numpmt])
178 time[numpmt]=besttime[numpmt];
184 //best time right&left
185 for (Int_t ipmt=0; ipmt<12; ipmt++)
187 timeGaus[ipmt]=gRandom->Gaus(time[ipmt],0.025);
188 if(timeGaus[ipmt]<besttimeleft) besttimeleft=timeGaus[ipmt]; //timeleft
190 for ( Int_t ipmt=12; ipmt<24; ipmt++)
192 timeGaus[ipmt]=gRandom->Gaus(time[ipmt],0.025);
193 if(timeGaus[ipmt]<besttimeright) besttimeright=timeGaus[ipmt]; //timeright
196 //folding with experimental time distribution
197 Float_t c = 29.9792; // mm/ns
198 Float_t koef=(350.-69.7)/c;
199 Float_t besttimeleftR= besttimeleft;
200 besttimeleft=koef+besttimeleft;
201 bestLeftTDC=Int_t (besttimeleftR*1000/channelWidth);
202 bestRightTDC=Int_t (besttimeright*1000/channelWidth);
203 timeDiff=(c*(besttimeright-besttimeleftR)-(350.-69.7))/(2*c);
204 meanTime=(besttimeright+besttimeleftR)/2.;
205 Float_t ds=(c*(besttimeright-besttimeleftR)-(350.-69.7))/2;
206 AliDebug(2,Form(" timediff in ns %f z= %f real point%f",timeDiff,timeDiff*c,ds));
209 // Time to TDC signal
210 Int_t iTimeAv=Int_t (meanTime*1000/channelWidth);
211 // time channel numbres
213 fdigits->SetTimeBestLeft(bestLeftTDC);
214 fdigits->SetTimeBestRight(bestRightTDC);
215 fdigits->SetMeanTime(iTimeAv);
219 for (Int_t i=0; i<24; i++)
223 tr= Int_t (timeGaus[i]*1000/channelWidth);
224 if(timeGaus[i]>100) tr=0;
225 ftimeTDC->AddAt(tr,i);
228 Int_t al= countE[i]; //1024 - channel width shoul be change
232 fdigits->SetTime(*ftimeTDC);
233 fdigits->SetADC(*fADC);
235 pInStartLoader->UnloadHits();
237 } //input streams loop
239 pOutStartLoader->WriteDigits("OVERWRITE");
240 pOutStartLoader->UnloadDigits();
244 //------------------------------------------------------------------------
245 Bool_t AliSTARTDigitizer::RegisterPhotoE(Float_t e)
249 // Float_t hc=197.326960*1.e6; //mev*nm
250 Float_t hc=1.973*1.e-6; //gev*nm
254 Char_t *dirname=getenv("ALICE_ROOT");
255 sprintf(filename,"%s/START/PMTefficiency.root",dirname);
256 TFile *file= new TFile(filename);
258 hEff = (TH1F*)file->Get("hEff");
259 Int_t bin= hEff->GetXaxis()->FindBin(lambda);
260 Float_t eff=hEff->GetBinContent(bin);
262 Double_t p = gRandom->Rndm();
268 //----------------------------------------------------------------------------