]>
Commit | Line | Data |
---|---|---|
ede9aff7 | 1 | |
2 | /************************************************************************** | |
3 | * Copyright(c) 1998-2000, ALICE Experiment at CERN, All rights reserved. * | |
4 | * * | |
5 | * Author: The ALICE Off-line Project. * | |
6 | * Contributors are mentioned in the code where appropriate. * | |
7 | * * | |
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 | **************************************************************************/ | |
16 | ||
17 | ||
18 | #include <TTree.h> | |
ede9aff7 | 19 | #include <TFile.h> |
20 | #include <TDirectory.h> | |
21 | #include <TRandom.h> | |
e73d68f2 | 22 | #include <TArrayI.h> |
2b4678e2 | 23 | #include <TError.h> |
e4da63c2 | 24 | #include <TH1F.h> |
c848a65b | 25 | #include <TGraph.h> |
ede9aff7 | 26 | |
e4da63c2 | 27 | #include "AliLog.h" |
ede9aff7 | 28 | #include "AliSTARTDigitizer.h" |
29 | #include "AliSTART.h" | |
30 | #include "AliSTARThit.h" | |
31 | #include "AliSTARTdigit.h" | |
32 | #include "AliRunDigitizer.h" | |
affef71b | 33 | #include <AliDetector.h> |
ede9aff7 | 34 | #include "AliRun.h" |
affef71b | 35 | #include <AliLoader.h> |
36 | #include <AliRunLoader.h> | |
ede9aff7 | 37 | #include <stdlib.h> |
ef0750c2 | 38 | #include <Riostream.h> |
39 | #include <Riostream.h> | |
c848a65b | 40 | #include "AliSTARTParameters.h" |
41 | #include "AliCDBLocal.h" | |
42 | #include "AliCDBStorage.h" | |
43 | #include "AliCDBManager.h" | |
44 | #include "AliCDBEntry.h" | |
ede9aff7 | 45 | |
46 | ClassImp(AliSTARTDigitizer) | |
47 | ||
48 | //___________________________________________ | |
49 | AliSTARTDigitizer::AliSTARTDigitizer() :AliDigitizer() | |
50 | { | |
51 | // Default ctor - don't use it | |
52 | ; | |
53 | } | |
54 | ||
55 | //___________________________________________ | |
56 | AliSTARTDigitizer::AliSTARTDigitizer(AliRunDigitizer* manager) | |
7a18b6a5 | 57 | :AliDigitizer(manager), |
58 | fSTART(0), | |
59 | fHits(0), | |
60 | fdigits(0), | |
c848a65b | 61 | ftimeCFD(0), |
62 | ftimeLED(0), | |
7a18b6a5 | 63 | fADC(0), |
c848a65b | 64 | fADC0(0) |
ede9aff7 | 65 | { |
ede9aff7 | 66 | // ctor which should be used |
e4da63c2 | 67 | |
68 | AliDebug(1,"processed"); | |
69 | ||
7a18b6a5 | 70 | fSTART = 0; |
7a18b6a5 | 71 | fHits = 0; |
72 | fdigits = 0; | |
73 | ||
c848a65b | 74 | ftimeCFD = new TArrayI(24); |
db173afc | 75 | fADC = new TArrayI(24); |
c848a65b | 76 | ftimeLED = new TArrayI(24); |
77 | fADC0 = new TArrayI(24); | |
db173afc | 78 | |
174d209f | 79 | |
ede9aff7 | 80 | } |
81 | ||
82 | //------------------------------------------------------------------------ | |
83 | AliSTARTDigitizer::~AliSTARTDigitizer() | |
84 | { | |
85 | // Destructor | |
e4da63c2 | 86 | |
7a18b6a5 | 87 | AliDebug(1,"START"); |
88 | ||
c848a65b | 89 | delete ftimeCFD; |
e4da63c2 | 90 | delete fADC; |
c848a65b | 91 | delete ftimeLED; |
92 | delete fADC0; | |
ede9aff7 | 93 | } |
94 | ||
95 | //------------------------------------------------------------------------ | |
96 | Bool_t AliSTARTDigitizer::Init() | |
97 | { | |
98 | // Initialization | |
e4da63c2 | 99 | AliDebug(1," Init"); |
ede9aff7 | 100 | return kTRUE; |
101 | } | |
102 | ||
103 | ||
104 | //--------------------------------------------------------------------- | |
105 | ||
dc63cec5 | 106 | void AliSTARTDigitizer::Exec(Option_t* /*option*/) |
ede9aff7 | 107 | { |
108 | ||
affef71b | 109 | /* |
110 | Produde digits from hits | |
111 | digits is TObject and includes | |
112 | We are writing array if left & right TDC | |
113 | left & right ADC (will need for slow simulation) | |
114 | TOF first particle left & right | |
115 | mean time and time difference (vertex position) | |
116 | ||
117 | */ | |
88cb7938 | 118 | |
db173afc | 119 | //output loader |
120 | AliRunLoader *outRL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName()); | |
121 | AliLoader * pOutStartLoader = outRL->GetLoader("STARTLoader"); | |
88cb7938 | 122 | |
e4da63c2 | 123 | AliDebug(1,"start..."); |
db173afc | 124 | //input loader |
ede9aff7 | 125 | // |
126 | // From hits to digits | |
127 | // | |
c848a65b | 128 | Int_t hit, nhits; |
129 | Int_t countE[24]; | |
130 | Int_t volume, pmt, trCFD, trLED; | |
131 | Float_t sl, qt; | |
4c7da157 | 132 | Int_t bestRightTDC, bestLeftTDC, qtCh; |
c848a65b | 133 | Float_t time[24], besttime[24], timeGaus[24] ; |
db173afc | 134 | //Q->T-> coefficients !!!! should be asked!!! |
c848a65b | 135 | Float_t gain[24],timeDelayCFD[24], timeDelayLED[24]; |
db173afc | 136 | Int_t threshold =50; //photoelectrons |
c848a65b | 137 | Float_t zdetA, zdetC; |
ad89b610 | 138 | Int_t sumMultCoeff = 25; |
c848a65b | 139 | TObjArray slewingLED; |
7bdc4686 | 140 | TObjArray slewingRec; |
c848a65b | 141 | AliSTARTParameters* param = AliSTARTParameters::Instance(); |
7bdc4686 | 142 | param->Init(); |
143 | ||
c848a65b | 144 | Int_t ph2Mip = param->GetPh2Mip(); |
145 | Int_t channelWidth = param->GetChannelWidth() ; | |
7bdc4686 | 146 | Float_t delayVertex = param->GetTimeDelayTVD(); |
c848a65b | 147 | for (Int_t i=0; i<24; i++){ |
148 | timeDelayCFD[i] = param->GetTimeDelayCFD(i); | |
149 | timeDelayLED[i] = param->GetTimeDelayLED(i); | |
150 | gain[i] = param->GetGain(i); | |
151 | TGraph* gr = param ->GetSlew(i); | |
152 | slewingLED.AddAtAndExpand(gr,i); | |
7bdc4686 | 153 | |
154 | TGraph* gr1 = param ->GetSlewRec(i); | |
155 | slewingRec.AddAtAndExpand(gr1,i); | |
156 | ||
c848a65b | 157 | TGraph* grEff = param ->GetPMTeff(i); |
158 | fEffPMT.AddAtAndExpand(grEff,i); | |
159 | } | |
160 | zdetC = param->GetZposition(0); | |
161 | zdetA = param->GetZposition(1); | |
e73d68f2 | 162 | |
ede9aff7 | 163 | AliSTARThit *startHit; |
164 | TBranch *brHits=0; | |
c848a65b | 165 | |
ede9aff7 | 166 | Int_t nFiles=fManager->GetNinputs(); |
167 | for (Int_t inputFile=0; inputFile<nFiles; inputFile++) { | |
6fc133d2 | 168 | if (inputFile < nFiles-1) { |
c848a65b | 169 | AliWarning(Form("ignoring input stream %d", inputFile)); |
170 | continue; | |
171 | ||
6fc133d2 | 172 | } |
db173afc | 173 | |
174 | Float_t besttimeright=99999.; | |
175 | Float_t besttimeleft=99999.; | |
c848a65b | 176 | Int_t pmtBestRight=9999; |
177 | Int_t pmtBestLeft=9999; | |
7bdc4686 | 178 | Int_t timeDiff=999, meanTime=0; |
51f1bdcf | 179 | Int_t sumMult =0; fSumMult=0; |
ad89b610 | 180 | bestRightTDC = 99999; bestLeftTDC = 99999; |
181 | ||
c848a65b | 182 | ftimeCFD -> Reset(); |
183 | fADC -> Reset(); | |
184 | fADC0 -> Reset(); | |
185 | ftimeLED ->Reset(); | |
db173afc | 186 | for (Int_t i0=0; i0<24; i0++) |
e73d68f2 | 187 | { |
40d2047f | 188 | time[i0]=besttime[i0]=timeGaus[i0]=99999; countE[i0]=0; |
e73d68f2 | 189 | } |
db173afc | 190 | AliRunLoader * inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile)); |
191 | AliLoader * pInStartLoader = inRL->GetLoader("STARTLoader"); | |
6fc133d2 | 192 | if (!inRL->GetAliRun()) inRL->LoadgAlice(); |
985b3149 | 193 | AliSTART *fSTART = (AliSTART*)inRL ->GetAliRun()->GetDetector("START"); |
db173afc | 194 | |
195 | //read Hits | |
affef71b | 196 | pInStartLoader->LoadHits("READ");//probably it is necessary to load them before |
affef71b | 197 | TClonesArray *fHits = fSTART->Hits (); |
affef71b | 198 | TTree *th = pInStartLoader->TreeH(); |
ede9aff7 | 199 | brHits = th->GetBranch("START"); |
200 | if (brHits) { | |
e4da63c2 | 201 | fSTART->SetHitsAddressBranch(brHits); |
ede9aff7 | 202 | }else{ |
db173afc | 203 | AliError("Branch START hit not found"); |
00907af4 | 204 | exit(111); |
ede9aff7 | 205 | } |
206 | Int_t ntracks = (Int_t) th->GetEntries(); | |
db173afc | 207 | |
e4da63c2 | 208 | if (ntracks<=0) return; |
ede9aff7 | 209 | // Start loop on tracks in the hits containers |
210 | for (Int_t track=0; track<ntracks;track++) { | |
211 | brHits->GetEntry(track); | |
7a68e0ef | 212 | nhits = fHits->GetEntriesFast(); |
db173afc | 213 | for (hit=0;hit<nhits;hit++) |
e4da63c2 | 214 | { |
215 | startHit = (AliSTARThit*) fHits->UncheckedAt(hit); | |
216 | if (!startHit) { | |
217 | AliError("The unchecked hit doesn't exist"); | |
218 | break; | |
219 | } | |
220 | pmt=startHit->Pmt(); | |
221 | Int_t numpmt=pmt-1; | |
db173afc | 222 | Double_t e=startHit->Etot(); |
e4da63c2 | 223 | volume = startHit->Volume(); |
e4da63c2 | 224 | |
c848a65b | 225 | if(e>0 && RegisterPhotoE(numpmt,e)) { |
db173afc | 226 | countE[numpmt]++; |
227 | besttime[numpmt] = startHit->Time(); | |
228 | if(besttime[numpmt]<time[numpmt]) | |
229 | { | |
230 | time[numpmt]=besttime[numpmt]; | |
231 | } | |
c848a65b | 232 | } //photoelectron accept |
e4da63c2 | 233 | } //hits loop |
ede9aff7 | 234 | } //track loop |
e4da63c2 | 235 | |
db173afc | 236 | //spread time right&left by 25ps && besttime |
4c7da157 | 237 | Float_t c = 0.0299792; // cm/ps |
238 | ||
239 | Float_t koef=(zdetA-zdetC)/c; //correction position difference by cable | |
db173afc | 240 | for (Int_t ipmt=0; ipmt<12; ipmt++){ |
241 | if(countE[ipmt] > threshold) { | |
c848a65b | 242 | timeGaus[ipmt]=gRandom->Gaus(time[ipmt],25)+koef; |
243 | if(timeGaus[ipmt]<besttimeleft){ | |
244 | besttimeleft=timeGaus[ipmt]; //timeleft | |
245 | pmtBestLeft=ipmt;} | |
ad89b610 | 246 | } |
db173afc | 247 | } |
0c1330a8 | 248 | for ( Int_t ipmt=12; ipmt<24; ipmt++){ |
db173afc | 249 | if(countE[ipmt] > threshold) { |
250 | timeGaus[ipmt]=gRandom->Gaus(time[ipmt],25); | |
c848a65b | 251 | if(timeGaus[ipmt]<besttimeright) { |
252 | besttimeright=timeGaus[ipmt]; //timeright | |
253 | pmtBestRight=ipmt;} | |
db173afc | 254 | } |
255 | } | |
c848a65b | 256 | //folding with alignmentz position distribution |
ad89b610 | 257 | if( besttimeleft > 10000. && besttimeleft <15000) |
258 | bestLeftTDC=Int_t ((besttimeleft+1000*timeDelayCFD[pmtBestLeft]) | |
259 | /channelWidth); | |
4c7da157 | 260 | |
ad89b610 | 261 | if( besttimeright > 10000. && besttimeright <15000) |
262 | bestRightTDC=Int_t ((besttimeright+1000*timeDelayCFD[pmtBestRight]) | |
c848a65b | 263 | /channelWidth); |
ad89b610 | 264 | |
265 | if (bestRightTDC < 99999 && bestLeftTDC < 99999) | |
266 | { | |
267 | timeDiff=Int_t (((besttimeleft-besttimeright)+1000*delayVertex) | |
268 | /channelWidth); | |
269 | meanTime=Int_t (((besttimeright+1000*timeDelayCFD[pmtBestLeft]+ | |
270 | besttimeleft+1000*timeDelayCFD[pmtBestLeft])/2.) | |
271 | /channelWidth); | |
ad89b610 | 272 | } |
6672a3cb | 273 | AliDebug(10,Form(" time right& left %i %i time diff && mean time in channels %i %i",bestRightTDC,bestLeftTDC, timeDiff, meanTime)); |
db173afc | 274 | for (Int_t i=0; i<24; i++) |
e73d68f2 | 275 | { |
c848a65b | 276 | Float_t al = countE[i]; |
277 | if (al>threshold && timeGaus[i]<50000 ) { | |
ad89b610 | 278 | //fill ADC |
279 | // QTC procedure: | |
280 | // phe -> mV 0.3; 1MIP ->500phe -> ln (amp (mV)) = 5; | |
281 | // max 200ns, HIJING mean 50000phe -> 15000mv -> ln = 15 (s zapasom) | |
282 | // channel 25ps | |
c848a65b | 283 | qt= 50.*al*gain[i]/ph2Mip; // 50mv/Mip amp in mV |
ad89b610 | 284 | // fill TDC |
c848a65b | 285 | trCFD = Int_t (timeGaus[i] + 1000.*timeDelayCFD[i])/channelWidth; |
286 | trLED= Int_t (timeGaus[i] + 1000.*timeDelayLED[i]); | |
287 | sl = ((TGraph*)slewingLED.At(i))->Eval(qt); | |
288 | trLED = Int_t(( trLED + 1000*sl )/channelWidth); | |
289 | qtCh=Int_t (1000.*TMath::Log(qt)) / channelWidth; | |
290 | fADC0->AddAt(0,i); | |
291 | fADC->AddAt(qtCh,i); | |
292 | ftimeCFD->AddAt(Int_t (trCFD),i); | |
293 | ftimeLED->AddAt(trLED,i); | |
ad89b610 | 294 | // sumMult += Int_t ((al*gain[i]/ph2Mip)*50) ; |
295 | sumMult += Int_t (qt/sumMultCoeff) ; | |
296 | ||
297 | AliDebug(10,Form(" pmt %i : time in ns %f time in channels %i ", | |
298 | i, timeGaus[i],trCFD )); | |
299 | AliDebug(10,Form(" qt in mV %f qt in ns %f qt in channels %i ",qt, | |
300 | TMath::Log(qt), qtCh)); | |
db173afc | 301 | } |
e4da63c2 | 302 | } //pmt loop |
db173afc | 303 | |
ad89b610 | 304 | if (sumMult > threshold){ |
305 | fSumMult = Int_t (1000.* TMath::Log(Double_t(sumMult) / Double_t(sumMultCoeff)) | |
306 | /channelWidth); | |
0c1330a8 | 307 | AliDebug(10,Form("summult mv %i mult in chammens %i in ps %i ", |
ad89b610 | 308 | sumMult, fSumMult, fSumMult*channelWidth)); |
309 | } | |
6672a3cb | 310 | // if ( besttimeright<99999 || besttimeleft < 99999) { |
311 | ||
ad89b610 | 312 | fSTART->AddDigit(bestRightTDC,bestLeftTDC,meanTime,timeDiff,fSumMult, |
313 | ftimeCFD,fADC,ftimeLED,fADC0); | |
6672a3cb | 314 | // } |
315 | ||
0c1330a8 | 316 | AliDebug(10,Form(" Digits wrote bestRightTDC %i bestLeftTDC %i meanTime %i timeDiff %i fSumMult %i ", bestRightTDC,bestLeftTDC,meanTime,timeDiff,fSumMult )); |
db173afc | 317 | pOutStartLoader->UnloadHits(); |
6fc133d2 | 318 | } //input streams loop |
db173afc | 319 | |
320 | //load digits | |
321 | pOutStartLoader->LoadDigits("UPDATE"); | |
322 | TTree *treeD = pOutStartLoader->TreeD(); | |
323 | if (treeD == 0x0) { | |
324 | pOutStartLoader->MakeTree("D"); | |
325 | treeD = pOutStartLoader->TreeD(); | |
326 | } | |
c848a65b | 327 | treeD->Reset(); |
328 | fSTART = (AliSTART*)outRL ->GetAliRun()->GetDetector("START"); | |
329 | // Make a branch in the tree | |
db173afc | 330 | fSTART->MakeBranch("D"); |
db173afc | 331 | treeD->Fill(); |
332 | ||
c848a65b | 333 | pOutStartLoader->WriteDigits("OVERWRITE"); |
334 | ||
c848a65b | 335 | fSTART->ResetDigits(); |
336 | pOutStartLoader->UnloadDigits(); | |
337 | ||
ede9aff7 | 338 | } |
339 | ||
340 | ||
e73d68f2 | 341 | //------------------------------------------------------------------------ |
c848a65b | 342 | Bool_t AliSTARTDigitizer::RegisterPhotoE(Int_t ipmt,Double_t energy) |
e73d68f2 | 343 | { |
e4da63c2 | 344 | |
345 | ||
346 | // Float_t hc=197.326960*1.e6; //mev*nm | |
2303c85c | 347 | Double_t hc=1.973*1.e-6; //gev*nm |
2303c85c | 348 | Float_t lambda=hc/energy; |
c848a65b | 349 | Float_t eff = ((TGraph*) fEffPMT.At(ipmt))->Eval(lambda); |
e4da63c2 | 350 | Double_t p = gRandom->Rndm(); |
c848a65b | 351 | |
e4da63c2 | 352 | if (p > eff) |
353 | return kFALSE; | |
354 | ||
355 | return kTRUE; | |
e73d68f2 | 356 | } |
c848a65b | 357 | |
7a68e0ef | 358 | //---------------------------------------------------------------------------- |