]> git.uio.no Git - u/mrichter/AliRoot.git/blame - START/AliSTARTReconstructor.cxx
fixed bug in AliSTARTTrigger
[u/mrichter/AliRoot.git] / START / AliSTARTReconstructor.cxx
CommitLineData
6740ab97 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
4c475d27 15
88cb7938 16/* $Id$ */
ef0750c2 17
88cb7938 18#include <Riostream.h>
94de3818 19
88cb7938 20#include <TDirectory.h>
ef51244a 21
a8859328 22#include "AliRunLoader.h"
23#include "AliRun.h"
affef71b 24#include <AliESD.h>
460b4363 25#include "AliLog.h"
db173afc 26#include <TClonesArray.h>
27#include "AliSTARTRecPoint.h"
28#include "AliRawReader.h"
29#include "AliSTARTRawReader.h"
460b4363 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"
40
41#include <TArrayI.h>
42
121a60bd 43ClassImp(AliSTARTReconstructor)
460b4363 44AliSTARTAlignData* AliSTARTReconstructor::fgAlignData = 0;
45AliSTARTCalibData* AliSTARTReconstructor::fgCalibData = 0;
6740ab97 46
db173afc 47 void AliSTARTReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
121a60bd 48{
db173afc 49 //START raw data-> digits conversion
50 // reconstruct time information from raw data
51 AliSTARTRawReader myrawreader(rawReader,digitsTree);
52 myrawreader.NextThing();
121a60bd 53}
db173afc 54 void AliSTARTReconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
55{
56// START digits reconstruction
57// STARTRecPoint writing
58
460b4363 59 //Q->T-> coefficients !!!! should be asked!!!
60 // Float_t ph2MIP=500;
61 Float_t gain[24], timeDelayCFD[24], timeDelayLED[24];
460b4363 62 Float_t zdetA,zdetC;
63 TObjArray slewingLED;
64
65 TArrayI * fADC = new TArrayI(24);
66 TArrayI * fTimeCFD = new TArrayI(24);
67 TArrayI * fADCLED = new TArrayI(24);
68 TArrayI * fTimeLED = new TArrayI(24);
b2214376 69 cout<<" fTimeCFD "<<fTimeCFD<<endl;
460b4363 70
71 AliSTARTParameters* param = AliSTARTParameters::Instance();
b2214376 72 param->Init();
460b4363 73 Int_t ph2MIP = param->GetPh2Mip();
74 Int_t channelWidth = param->GetChannelWidth() ;
75
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);
b2214376 81 }
460b4363 82 zdetC = param->GetZposition(0);
83 zdetA = param->GetZposition(1);
84
db173afc 85 AliDebug(1,Form("Start DIGITS reconstruction "));
b2214376 86
db173afc 87 TBranch *brDigits=digitsTree->GetBranch("START");
88 AliSTARTdigit *fDigits = new AliSTARTdigit();
89 if (brDigits) {
90 brDigits->SetAddress(&fDigits);
91 }else{
92 cerr<<"EXEC Branch START digits not found"<<endl;
93 return;
94 }
95 brDigits->GetEntry(0);
460b4363 96 fDigits->GetTime(*fTimeCFD);
460b4363 97 fDigits->GetADC(*fADC);
98 fDigits->GetTimeAmp(*fTimeLED);
99 fDigits->GetADCAmp(*fADCLED);
100
101 Float_t time[24], adc[24];
102 for (Int_t ipmt=0; ipmt<24; ipmt++)
103 {
104
b2214376 105 if(fTimeCFD->At(ipmt)>0 ){
106 time[ipmt] = channelWidth *( fTimeCFD->At(ipmt)) - 1000*timeDelayCFD[ipmt];
460b4363 107 cout<<ipmt<<" "<<time[ipmt];
b2214376 108 Float_t adc_digPs = channelWidth * Float_t (fADC->At(ipmt)) ;
109 // cout<<" adc_digmV "<< adc_digPs<<endl;
110 adc[ipmt] = TMath::Exp(adc_digPs/1000) /gain[ipmt];
111 // cout<<" adc"<<adc[ipmt]<<" inMIP "<<adc[ipmt]/50<< endl;
112 }
460b4363 113 }
114
b2214376 115 Int_t besttimeright=channelWidth * (fDigits->BestTimeRight());
116 Int_t besttimeleft=channelWidth * (fDigits->BestTimeLeft());
db173afc 117 //folding with experimental time distribution
118 // Float_t c = 29.9792; // cm/ns
119 Float_t c = 0.0299792; // cm/ps
460b4363 120 Float_t lenr=TMath::Sqrt(zdetA*zdetA + 6.5*6.5);
121 Float_t lenl=TMath::Sqrt(zdetC*zdetC + 6.5*6.5);
b2214376 122 Float_t timeDiff=channelWidth * (fDigits->TimeDiff());
123 Int_t meanTime=channelWidth * (fDigits->MeanTime());
db173afc 124 Float_t ds=(c*(timeDiff)-(lenr-lenl))/2;
125 AliDebug(2,Form(" timediff in ns %f real point%f",timeDiff,ds));
126
460b4363 127 /*
db173afc 128 fDigits->GetSumMult(*fSumMult);
460b4363 129 Int_t multipl[4];
130
131 for (Int_t i=0; i<4; i++)
db173afc 132 {
133 Float_t mult=Float_t (fSumMult->At(i));
134 Float_t realMultmV=TMath::Exp(mult/mV2channel);
135 multipl[i]=Int_t ((realMultmV/ph2mV)/500+0.5);
136 }
460b4363 137 */
138
139 // AliDebug(2,Form(" multiplicity Abs side %i multiplicity non-Abs side %i",multipl[1],multipl[2]));
db173afc 140
141 AliSTARTRecPoint* frecpoints= new AliSTARTRecPoint ();
142 clustersTree->Branch( "START", "AliSTARTRecPoint" ,&frecpoints, 405,1);
143 frecpoints->SetTimeBestRight(besttimeright);
144 frecpoints->SetTimeBestLeft(besttimeleft);
145 frecpoints->SetVertex(ds);
146 frecpoints->SetMeanTime(meanTime);
460b4363 147 /*
db173afc 148 frecpoints->SetMult(multipl[0]);
149 frecpoints->SetMultA(multipl[2]);
150 frecpoints->SetMultC(multipl[1]);
460b4363 151 */
db173afc 152 clustersTree->Fill();
153}
154
155
156void AliSTARTReconstructor::FillESD(AliRunLoader* runLoader, AliESD *pESD) const
6740ab97 157{
db173afc 158
f3ed336b 159 /***************************************************
160 Resonstruct digits to vertex position
161 ****************************************************/
db173afc 162
163 // Float_t c = 0.3; //speed of light mm/ps
164 // Float_t Zposition=0;
165
166 if (!runLoader) {
167 AliError("Reconstruct >> No run loader");
6fc133d2 168 return;
169 }
db173afc 170
171 AliDebug(1,Form("Start FillESD START"));
affef71b 172
db173afc 173 AliSTARTLoader* pStartLoader = (AliSTARTLoader*) runLoader->GetLoader("STARTLoader");
6fc133d2 174
db173afc 175 pStartLoader->LoadRecPoints("READ");
176
177 TTree *treeR = pStartLoader->TreeR();
178
179 AliSTARTRecPoint* frecpoints= new AliSTARTRecPoint ();
180 if (!frecpoints) {
181 AliError("Reconstruct Fill ESD >> no recpoints found");
6fc133d2 182 return;
183 }
a8859328 184
db173afc 185 AliDebug(1,Form("Start FillESD START"));
186 TBranch *brRec = treeR->GetBranch("START");
187 if (brRec) {
188 brRec->SetAddress(&frecpoints);
189 }else{
190 cerr<<"EXEC Branch START rec not found"<<endl;
191 exit(111);
192 }
193
194 brRec->GetEntry(0);
195 Float_t Zposition=frecpoints->GetVertex();
6fc133d2 196
db173afc 197 pESD->SetT0zVertex(Zposition);
198 pStartLoader->UnloadRecPoints();
6fc133d2 199
db173afc 200} // vertex in 3 sigma
6740ab97 201
202
203
204
7115262b 205
206