1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include <Riostream.h>
20 #include <TDirectory.h>
22 #include "AliRunLoader.h"
26 #include <TClonesArray.h>
27 #include "AliT0RecPoint.h"
29 #include "AliRawReader.h"
30 #include "AliT0RawReader.h"
31 #include "AliT0Loader.h"
32 #include "AliT0digit.h"
33 #include "AliT0Reconstructor.h"
34 #include "AliT0Parameters.h"
35 #include "AliCDBLocal.h"
36 #include "AliCDBStorage.h"
37 #include "AliCDBManager.h"
38 #include "AliCDBEntry.h"
43 ClassImp(AliT0Reconstructor)
45 //____________________________________________________________________
47 AliT0Reconstructor::Init(AliRunLoader* runLoader,TTree* digitsTree ) const
50 // Initialize the reconstructor
51 AliDebug(2, Form("Init called with runloader 0x%x", runLoader));
53 // Initialize the parameters
54 AliT0Loader* pStartLoader = (AliT0Loader*) runLoader->GetLoader("T0Loader");
56 pStartLoader->LoadDigits("READ");
58 digitsTree = pStartLoader->TreeD();
62 //____________________________________________________________________
63 void AliT0Reconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
65 //T0 raw data-> digits conversion
66 // reconstruct time information from raw data
68 baseT0->Raw2Digits(rawReader, digitsTree);
72 void AliT0Reconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
73 //void AliT0Reconstructor::Reconstruct(AliRunLoader *runLoader) const
75 // T0 digits reconstruction
78 //Q->T-> coefficients !!!! should be asked!!!
79 // Float_t ph2MIP=500;
80 Float_t gain[24], timeDelayCFD[24], timeDelayLED[24];
84 TArrayI * fADC = new TArrayI(24);
85 TArrayI * fTimeCFD = new TArrayI(24);
86 TArrayI * fADCLED = new TArrayI(24);
87 TArrayI * fTimeLED = new TArrayI(24);
89 AliT0Parameters* param = AliT0Parameters::Instance();
92 Int_t mV2Mip = param->GetmV2Mip();
93 //mV2Mip = param->GetmV2Mip();
94 Int_t channelWidth = param->GetChannelWidth() ;
96 for (Int_t i=0; i<24; i++){
97 timeDelayCFD[i] = param->GetTimeDelayCFD(i);
98 timeDelayLED[i] = param->GetTimeDelayLED(i);
99 gain[i] = param->GetGain(i);
101 slewingLED.AddAtAndExpand(param->GetSlew(i),i);
103 zdetC = param->GetZposition(0);
104 zdetA = param->GetZposition(1);
106 AliDebug(1,Form("Start DIGITS reconstruction "));
108 TBranch *brDigits=digitsTree->GetBranch("T0");
109 AliT0digit *fDigits = new AliT0digit() ;
111 brDigits->SetAddress(&fDigits);
113 cerr<<"EXEC Branch T0 digits not found"<<endl;
117 digitsTree->GetEvent(0);
118 digitsTree->GetEntry(0);
119 brDigits->GetEntry(0);
120 fDigits->GetTime(*fTimeCFD);
121 fDigits->GetADC(*fADC);
122 fDigits->GetTimeAmp(*fTimeLED);
123 fDigits->GetADCAmp(*fADCLED);
126 Float_t besttimeright=999999;
127 Float_t besttimeleft=999999;
128 Int_t pmtBestRight=99999;
129 Int_t pmtBestLeft=99999;
130 Float_t timeDiff=999999, meanTime=0;
134 AliT0RecPoint* frecpoints= new AliT0RecPoint ();
135 clustersTree->Branch( "T0", "AliT0RecPoint" ,&frecpoints, 405,1);
137 Float_t time[24], adc[24];
138 for (Int_t ipmt=0; ipmt<24; ipmt++) {
139 if(fTimeCFD->At(ipmt)>0 ){
140 time[ipmt] = channelWidth *( fTimeCFD->At(ipmt)) - 1000*timeDelayCFD[ipmt];
141 // Float_t adc_digPs = channelWidth * Float_t (fADCLED->At(ipmt)) ;
142 // adc[ipmt] = TMath::Exp(adc_digPs/1000) /gain[ipmt];
144 AliDebug(1,Form(" time %f ps, adc %f mv in MIP %i\n ",
145 time[ipmt], adc[ipmt], Int_t (adc[ipmt]/mV2Mip +0.5)));
146 frecpoints->SetTime(ipmt,time[ipmt]);
147 frecpoints->SetAmp(ipmt,adc[ipmt]);
155 for (Int_t ipmt=0; ipmt<12; ipmt++){
156 if(time[ipmt] > 1 ) {
157 if(time[ipmt]<besttimeleft){
158 besttimeleft=time[ipmt]; //timeleft
163 for ( Int_t ipmt=12; ipmt<24; ipmt++){
165 if(time[ipmt]<besttimeright) {
166 besttimeright=time[ipmt]; //timeright
170 if(besttimeright !=999999) frecpoints->SetTimeBestRight(Int_t(besttimeright));
171 if( besttimeleft != 999999 ) frecpoints->SetTimeBestLeft(Int_t(besttimeleft));
172 AliDebug(1,Form(" besttimeA %f ps, besttimeC %f ps",besttimeright, besttimeleft));
173 Float_t c = 0.0299792; // cm/ps
175 if(besttimeright !=999999 && besttimeleft != 999999 ){
176 timeDiff = besttimeleft - besttimeright;
177 meanTime = (besttimeright + besttimeleft)/2.;
178 vertex = c*(timeDiff)/2.; //-(lenr-lenl))/2;
179 AliDebug(1,Form(" timeDiff %f ps, meanTime %f ps, vertex %f cm",timeDiff, meanTime,vertex ));
180 frecpoints->SetVertex(vertex);
181 frecpoints->SetMeanTime(Int_t(meanTime));
184 clustersTree->Fill();
188 void AliT0Reconstructor::FillESD(AliRunLoader* runLoader, AliESD *pESD) const
191 /***************************************************
192 Resonstruct digits to vertex position
193 ****************************************************/
197 AliError("Reconstruct >> No run loader");
201 AliDebug(1,Form("Start FillESD T0"));
203 AliT0Loader* pStartLoader = (AliT0Loader*) runLoader->GetLoader("T0Loader");
205 pStartLoader->LoadRecPoints("READ");
207 TTree *treeR = pStartLoader->TreeR();
209 AliT0RecPoint* frecpoints= new AliT0RecPoint ();
211 AliError("Reconstruct Fill ESD >> no recpoints found");
215 AliDebug(1,Form("Start FillESD T0"));
216 TBranch *brRec = treeR->GetBranch("T0");
218 brRec->SetAddress(&frecpoints);
220 cerr<<"EXEC Branch T0 rec not found"<<endl;
226 Float_t timeStart, Zposition, amp[24], time[24];
228 Zposition = frecpoints -> GetVertex();
229 timeStart = frecpoints -> GetMeanTime();
230 for ( i=0; i<24; i++) {
231 time[i] = Float_t (frecpoints -> GetTime(i)) / 1000.; // ps to ns
232 amp[i] = frecpoints -> GetAmp(i);
234 pESD->SetT0zVertex(Zposition); //vertex Z position
235 pESD->SetT0(timeStart); // interaction time
236 pESD->SetT0time(time); // best TOF on each PMT
237 pESD->SetT0amplitude(amp); // number of particles(MIPs) on each PMT
238 cout<<" ESD >> "<<Zposition<<" "<<timeStart<<endl;
240 pStartLoader->UnloadRecPoints();
242 } // vertex in 3 sigma