]> git.uio.no Git - u/mrichter/AliRoot.git/blob - START/AliSTARTReconstructor.cxx
fixed bug in AliSTARTTrigger
[u/mrichter/AliRoot.git] / START / AliSTARTReconstructor.cxx
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  **************************************************************************/
15
16 /* $Id$ */
17
18 #include <Riostream.h>
19
20 #include <TDirectory.h>
21
22 #include "AliRunLoader.h"
23 #include "AliRun.h"
24 #include <AliESD.h>
25 #include "AliLog.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"
40
41 #include <TArrayI.h>
42
43 ClassImp(AliSTARTReconstructor)
44 AliSTARTAlignData* AliSTARTReconstructor::fgAlignData = 0;
45 AliSTARTCalibData* AliSTARTReconstructor::fgCalibData = 0;
46
47   void  AliSTARTReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
48 {
49   //START raw data-> digits conversion
50  // reconstruct time information from raw data
51   AliSTARTRawReader myrawreader(rawReader,digitsTree);
52   myrawreader.NextThing();
53 }
54   void AliSTARTReconstructor::Reconstruct(TTree*digitsTree, TTree*clustersTree) const
55 {
56 // START digits reconstruction
57 // STARTRecPoint writing 
58
59     //Q->T-> coefficients !!!! should be asked!!!
60   //  Float_t ph2MIP=500;
61   Float_t gain[24], timeDelayCFD[24], timeDelayLED[24];
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); 
69   cout<<" fTimeCFD "<<fTimeCFD<<endl;
70
71   AliSTARTParameters* param = AliSTARTParameters::Instance();
72   param->Init();
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);
81      }
82     zdetC = param->GetZposition(0);
83     zdetA  = param->GetZposition(1);
84   
85   AliDebug(1,Form("Start DIGITS reconstruction "));
86  
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);
96   fDigits->GetTime(*fTimeCFD);
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       
105          if(fTimeCFD->At(ipmt)>0 ){
106          time[ipmt] = channelWidth *( fTimeCFD->At(ipmt)) - 1000*timeDelayCFD[ipmt];
107          cout<<ipmt<<" "<<time[ipmt];
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          }
113     }
114
115   Int_t besttimeright=channelWidth * (fDigits->BestTimeRight());
116   Int_t besttimeleft=channelWidth * (fDigits->BestTimeLeft());
117   //folding with experimental time distribution
118   //  Float_t c = 29.9792; // cm/ns
119   Float_t c = 0.0299792; // cm/ps
120   Float_t lenr=TMath::Sqrt(zdetA*zdetA + 6.5*6.5);
121   Float_t lenl=TMath::Sqrt(zdetC*zdetC + 6.5*6.5);
122   Float_t timeDiff=channelWidth * (fDigits->TimeDiff());
123   Int_t meanTime=channelWidth * (fDigits->MeanTime());
124   Float_t ds=(c*(timeDiff)-(lenr-lenl))/2;
125   AliDebug(2,Form(" timediff in ns %f  real point%f",timeDiff,ds));
126   
127   /*
128   fDigits->GetSumMult(*fSumMult);
129   Int_t multipl[4]; 
130  
131  for (Int_t i=0; i<4; i++)
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     }
137   */
138
139   //  AliDebug(2,Form(" multiplicity Abs side %i  multiplicity non-Abs side %i",multipl[1],multipl[2]));
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);
147   /*
148   frecpoints->SetMult(multipl[0]);
149   frecpoints->SetMultA(multipl[2]);
150   frecpoints->SetMultC(multipl[1]);
151   */
152   clustersTree->Fill();
153 }
154
155
156 void AliSTARTReconstructor::FillESD(AliRunLoader* runLoader, AliESD *pESD) const
157 {
158
159   /***************************************************
160   Resonstruct digits to vertex position
161   ****************************************************/
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");
168     return;
169   }
170   
171   AliDebug(1,Form("Start FillESD START"));
172
173   AliSTARTLoader* pStartLoader = (AliSTARTLoader*) runLoader->GetLoader("STARTLoader");
174  
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");
182     return;
183   }
184   
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();
196     
197     pESD->SetT0zVertex(Zposition);
198     pStartLoader->UnloadRecPoints();
199     
200 } // vertex in 3 sigma
201
202
203
204
205
206