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 "AliSTARTRecPoint.h"
28 #include "AliRawReader.h"
29 #include "AliSTARTRawReader.h"
30 #include "AliSTARTLoader.h"
31 #include "AliSTARTdigit.h"
32 #include "AliSTARTReconstructor.h"
33 #include "AliSTARTParameters.h"
34 #include "AliSTARTAlignData.h"
35 #include "AliSTARTCalibData.h"
36 #include "AliCDBLocal.h"
37 #include "AliCDBStorage.h"
38 #include "AliCDBManager.h"
39 #include "AliCDBEntry.h"
43 ClassImp(AliSTARTReconstructor)
44 AliSTARTAlignData* AliSTARTReconstructor::fgAlignData = 0;
45 AliSTARTCalibData* AliSTARTReconstructor::fgCalibData = 0;
47 void AliSTARTReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
49 //START raw data-> digits conversion
50 // reconstruct time information from raw data
51 AliSTARTRawReader myrawreader(rawReader,digitsTree);
52 myrawreader.NextThing();
54 void AliSTARTReconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
56 // START digits reconstruction
57 // STARTRecPoint writing
59 //Q->T-> coefficients !!!! should be asked!!!
60 // Float_t ph2MIP=500;
61 Float_t gain[24], timeDelayCFD[24], timeDelayLED[24];
62 Int_t threshold =50; //photoelectrons
63 // Int_t mV2channel=200000/(25*25); //5V -> 200ns
67 TArrayI * fADC = new TArrayI(24);
68 TArrayI * fTimeCFD = new TArrayI(24);
69 TArrayI * fADCLED = new TArrayI(24);
70 TArrayI * fTimeLED = new TArrayI(24);
72 AliSTARTParameters* param = AliSTARTParameters::Instance();
73 Int_t ph2MIP = param->GetPh2Mip();
74 Int_t channelWidth = param->GetChannelWidth() ;
76 for (Int_t i=0; i<24; i++){
77 timeDelayCFD[i] = param->GetTimeDelayCFD(i);
78 timeDelayLED[i] = param->GetTimeDelayLED(i);
79 gain[i] = param->GetGain(i);
80 slewingLED.AddAtAndExpand(param->GetSlew(i),i);
82 zdetC = param->GetZposition(0);
83 zdetA = param->GetZposition(1);
85 AliDebug(1,Form("Start DIGITS reconstruction "));
86 Int_t channelWigth=25; //ps
88 TBranch *brDigits=digitsTree->GetBranch("START");
89 cout<<" TBranch *brDigits "<<brDigits<<endl;
90 AliSTARTdigit *fDigits = new AliSTARTdigit();
92 brDigits->SetAddress(&fDigits);
94 cerr<<"EXEC Branch START digits not found"<<endl;
98 brDigits->GetEntry(0);
99 cout<<" brDigits->GetEntry(0); "<<endl;
101 fDigits->GetTime(*fTimeCFD);
102 cout<<" fDigits->GetTime(*fTimeCFD); "<<endl;
103 fDigits->GetADC(*fADC);
104 fDigits->GetTimeAmp(*fTimeLED);
105 fDigits->GetADCAmp(*fADCLED);
107 Float_t time[24], adc[24];
108 for (Int_t ipmt=0; ipmt<24; ipmt++)
111 if(fTimeCFD->At(ipmt)){
112 time[ipmt] = channelWigth *( fTimeCFD->At(ipmt)) - 1000*timeDelayCFD[ipmt];
113 cout<<ipmt<<" "<<time[ipmt];
114 Float_t adc_digmV = channelWigth * Float_t (fADC->At(ipmt)) ;
115 cout<<" adc_digmV "<< adc_digmV;
116 // adc[ipmt] = ( TMath::Exp (fADC->At(ipmt)) / gain[ipmt] /mV2channel );
117 adc[ipmt] = TMath::Exp(adc_digmV);
118 cout<<" adc"<<adc[ipmt]<<" inMIP "<<adc[ipmt]/50<< endl;
122 Int_t besttimeright=channelWigth * (fDigits->BestTimeRight());
123 Int_t besttimeleft=channelWigth * (fDigits->BestTimeLeft());
125 //folding with experimental time distribution
126 // Float_t c = 29.9792; // cm/ns
127 Float_t c = 0.0299792; // cm/ps
128 Float_t lenr=TMath::Sqrt(zdetA*zdetA + 6.5*6.5);
129 Float_t lenl=TMath::Sqrt(zdetC*zdetC + 6.5*6.5);
130 Float_t timeDiff=channelWigth * (fDigits->TimeDiff());
131 Int_t meanTime=channelWigth * (fDigits->MeanTime());
132 Float_t ds=(c*(timeDiff)-(lenr-lenl))/2;
133 AliDebug(2,Form(" timediff in ns %f real point%f",timeDiff,ds));
136 fDigits->GetSumMult(*fSumMult);
139 for (Int_t i=0; i<4; i++)
141 Float_t mult=Float_t (fSumMult->At(i));
142 Float_t realMultmV=TMath::Exp(mult/mV2channel);
143 multipl[i]=Int_t ((realMultmV/ph2mV)/500+0.5);
147 // AliDebug(2,Form(" multiplicity Abs side %i multiplicity non-Abs side %i",multipl[1],multipl[2]));
149 AliSTARTRecPoint* frecpoints= new AliSTARTRecPoint ();
150 clustersTree->Branch( "START", "AliSTARTRecPoint" ,&frecpoints, 405,1);
151 frecpoints->SetTimeBestRight(besttimeright);
152 frecpoints->SetTimeBestLeft(besttimeleft);
153 frecpoints->SetVertex(ds);
154 frecpoints->SetMeanTime(meanTime);
156 frecpoints->SetMult(multipl[0]);
157 frecpoints->SetMultA(multipl[2]);
158 frecpoints->SetMultC(multipl[1]);
160 clustersTree->Fill();
164 void AliSTARTReconstructor::FillESD(AliRunLoader* runLoader, AliESD *pESD) const
167 /***************************************************
168 Resonstruct digits to vertex position
169 ****************************************************/
171 // Float_t c = 0.3; //speed of light mm/ps
172 // Float_t Zposition=0;
175 AliError("Reconstruct >> No run loader");
179 AliDebug(1,Form("Start FillESD START"));
181 AliSTARTLoader* pStartLoader = (AliSTARTLoader*) runLoader->GetLoader("STARTLoader");
183 pStartLoader->LoadRecPoints("READ");
185 TTree *treeR = pStartLoader->TreeR();
187 AliSTARTRecPoint* frecpoints= new AliSTARTRecPoint ();
189 AliError("Reconstruct Fill ESD >> no recpoints found");
193 AliDebug(1,Form("Start FillESD START"));
194 TBranch *brRec = treeR->GetBranch("START");
196 brRec->SetAddress(&frecpoints);
198 cerr<<"EXEC Branch START rec not found"<<endl;
203 Float_t Zposition=frecpoints->GetVertex();
205 pESD->SetT0zVertex(Zposition);
206 pStartLoader->UnloadRecPoints();
208 } // vertex in 3 sigma