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 **************************************************************************/
16 /*********************************************************************
17 * FIT reconstruction and filling ESD
18 * - reconstruct mean time (interation time)
21 ********************************************************************/
23 #include <AliESDEvent.h>
25 #include "AliFITRecPoint.h"
26 #include "AliFITDigit.h"
27 #include "AliFITReconstructor.h"
28 #include "AliESDFIT.h"
30 #include "AliESDRun.h"
31 #include "AliFITRawReader.h"
36 #include <Riostream.h>
41 ClassImp(AliFITReconstructor)
43 AliFITReconstructor:: AliFITReconstructor(): AliReconstructor(),
53 fESDFIT = new AliESDFIT();
57 //_____________________________________________________________________________
58 void AliFITReconstructor::Init()
62 fESDFIT = new AliESDFIT;
65 //______________________________________________________________________
66 void AliFITReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
68 // converts RAW to digits
69 cout<<" AliFITReconstructor::ConvertDigits "<<rawReader<<" "<<digitsTree<<endl;
71 AliError("No digits tree!");
75 fDigits = new TClonesArray ("AliFITDigit", 100);
76 digitsTree->Branch("FIT", &fDigits);
78 AliFITRawReader myrawreader(rawReader);
79 if (myrawreader.Next())
82 for (Int_t i=0; i<500; i++) allData[i]=0;
83 for (Int_t i=0; i<500; i++)
84 if(myrawreader.GetData(i)>0) {
85 allData[i]=myrawreader.GetData(i);
88 Int_t timeCFD, timeLED, timeQT1, timeQT0;
89 for (Int_t ipmt=0; ipmt<160; ipmt++) {
91 timeCFD = allData[ipmt];
92 timeLED = allData[ipmt];
93 timeQT0= allData[ipmt+160];
94 timeQT1 = allData[ipmt+320];
96 new((*fDigits)[fDigits->GetEntriesFast()] )
97 AliFITDigit( ipmt,timeCFD, timeLED, timeQT0, timeQT1, 0);
109 //____________________________________________________________
110 void AliFITReconstructor::FillESD(TTree *digitsTree, TTree * /*clustersTree*/, AliESDEvent *pESD) const
113 /***************************************************
114 Resonstruct digits to vertex position
115 ****************************************************/
117 AliDebug(1,Form("Start FillESD FIT"));
119 AliError("No ESD Event");
123 Float_t channelWidth = 24.4;
124 Float_t c = 0.0299792458; // cm/ps
125 Float_t currentVertex, shift=0;
127 const AliESDVertex* vertex = pESD->GetPrimaryVertex();
128 if (!vertex) vertex = pESD->GetPrimaryVertexSPD();
129 if (!vertex) vertex = pESD->GetPrimaryVertexTPC();
130 if (!vertex) vertex = pESD->GetVertex();
133 AliDebug(2, Form("Got %s (%s) from ESD: %f",
134 vertex->GetName(), vertex->GetTitle(), vertex->GetZ()));
135 currentVertex = vertex->GetZ();
137 ncont = vertex->GetNContributors();
139 shift = currentVertex/c;
144 // FIT digits reconstruction
147 AliError("No digits tree!");
151 fDigits = new TClonesArray("AliFITDigit", 100);
152 // digitsTree->Print();
153 TBranch *brDigits=digitsTree->GetBranch("FIT");
155 brDigits->SetAddress(&fDigits);
157 AliError("no FIT branch");
160 const Float_t max_time = 1e7;
162 Float_t time[160],amp[160];
163 for(Int_t i=0; i<160; i++) { time[i]=max_time; amp[i]=0;}
165 Int_t nEntries = (Int_t)digitsTree->GetEntries();
166 for (Int_t iev=0; iev<nEntries; iev++) {
167 digitsTree->GetEvent(iev,1);
168 brDigits->GetEvent(iev);
169 Int_t nDigits = fDigits->GetEntriesFast();
170 for (Int_t dig=0; dig<nDigits; dig++) {
171 AliFITDigit* digit = (AliFITDigit*) fDigits->At(dig);
173 time[pmt] = Float_t (digit->TimeCFD() );
174 amp[pmt] = Float_t (digit->TimeQT1() - digit->TimeQT0() );
176 fESDFIT->SetFITtime(time); // best TOF on each PMT
177 fESDFIT->SetFITamplitude(amp); // number of particles(MIPs) on each
179 Float_t firsttime[3] = {max_time,max_time,max_time};
181 Float_t vertexFIT = 9999999;
182 for (Int_t ipmt=0; ipmt<80; ipmt++)//timeC
183 if(time[ipmt]<firsttime[2]) firsttime[2]=time[ipmt];
185 for ( Int_t ipmt=80; ipmt<160; ipmt++)
186 if(time[ipmt]<firsttime[1]) firsttime[1]=time[ipmt];
189 AliDebug(5,Form("1stimeA %f , 1sttimeC %f ",
192 if (firsttime[1]<max_time && firsttime[2]<max_time) {
193 firsttime[0] = channelWidth *(firsttime[1] + firsttime[2])/2;
194 vertexFIT = c*channelWidth*(firsttime[1] - firsttime[2])/2;
196 if (firsttime[1]<max_time)
197 firsttime[1] = firsttime[1] * channelWidth + shift;
199 if (firsttime[2]<max_time)
200 firsttime[2] = firsttime[2] * channelWidth - shift;
204 for(Int_t i=0; i<3; i++) {
205 fESDFIT->SetFITT0(i,firsttime[i]); // interaction time (ns)
207 fESDFIT->SetFITzVertex(vertexFIT); //vertex Z position
210 AliDebug(1,Form("FIT: SPDshift %f Vertex %f FITsignal %f ps FITA %f ps FITC %f ps \n",shift, vertexFIT, firsttime[0], firsttime[1],firsttime[2]));