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>
38 ClassImp(AliFITReconstructor)
40 AliFITReconstructor:: AliFITReconstructor(): AliReconstructor(),
50 fESDFIT = new AliESDFIT();
54 //_____________________________________________________________________________
55 void AliFITReconstructor::Init()
59 fESDFIT = new AliESDFIT;
62 //______________________________________________________________________
63 void AliFITReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
65 // converts RAW to digits
66 cout<<" AliFITReconstructor::ConvertDigits "<<rawReader<<" "<<digitsTree<<endl;
68 AliError("No digits tree!");
72 fDigits = new TClonesArray ("AliFITDigit", 100);
73 digitsTree->Branch("FIT", &fDigits);
75 AliFITRawReader myrawreader(rawReader);
76 if (myrawreader.Next())
79 for (Int_t i=0; i<500; i++) allData[i]=0;
80 for (Int_t i=0; i<500; i++)
81 if(myrawreader.GetData(i)>0) {
82 allData[i]=myrawreader.GetData(i);
85 Int_t timeCFD, timeLED, timeQT1, timeQT0;
86 for (Int_t ipmt=0; ipmt<160; ipmt++) {
88 timeCFD = allData[ipmt];
89 timeLED = allData[ipmt];
90 timeQT0= allData[ipmt+160];
91 timeQT1 = allData[ipmt+320];
93 new((*fDigits)[fDigits->GetEntriesFast()] )
94 AliFITDigit( ipmt,timeCFD, timeLED, timeQT0, timeQT1, 0);
106 //____________________________________________________________
107 void AliFITReconstructor::FillESD(TTree *digitsTree, TTree * /*clustersTree*/, AliESDEvent *pESD) const
110 /***************************************************
111 Resonstruct digits to vertex position
112 ****************************************************/
114 AliDebug(1,Form("Start FillESD FIT"));
116 AliError("No ESD Event");
120 Float_t channelWidth = 24.4;
121 Float_t c = 0.0299792458; // cm/ps
122 Float_t currentVertex, shift=0;
124 const AliESDVertex* vertex = pESD->GetPrimaryVertex();
125 if (!vertex) vertex = pESD->GetPrimaryVertexSPD();
126 if (!vertex) vertex = pESD->GetPrimaryVertexTPC();
127 if (!vertex) vertex = pESD->GetVertex();
130 AliDebug(2, Form("Got %s (%s) from ESD: %f",
131 vertex->GetName(), vertex->GetTitle(), vertex->GetZ()));
132 currentVertex = vertex->GetZ();
134 ncont = vertex->GetNContributors();
136 shift = currentVertex/c;
141 // FIT digits reconstruction
144 AliError("No digits tree!");
148 fDigits = new TClonesArray("AliFITDigit", 100);
149 // digitsTree->Print();
150 TBranch *brDigits=digitsTree->GetBranch("FIT");
152 brDigits->SetAddress(&fDigits);
154 AliError("no FIT branch");
157 const Float_t max_time = 1e7;
159 Float_t time[160],amp[160];
160 for(Int_t i=0; i<160; i++) { time[i]=max_time; amp[i]=0;}
162 Int_t nEntries = (Int_t)digitsTree->GetEntries();
163 for (Int_t iev=0; iev<nEntries; iev++) {
164 digitsTree->GetEvent(iev,1);
165 brDigits->GetEvent(iev);
166 Int_t nDigits = fDigits->GetEntriesFast();
167 for (Int_t dig=0; dig<nDigits; dig++) {
168 AliFITDigit* digit = (AliFITDigit*) fDigits->At(dig);
170 time[pmt] = Float_t (digit->TimeCFD() );
171 amp[pmt] = Float_t (digit->TimeQT1() - digit->TimeQT0() );
173 fESDFIT->SetFITtime(time); // best TOF on each PMT
174 fESDFIT->SetFITamplitude(amp); // number of particles(MIPs) on each
176 Float_t firsttime[3] = {max_time,max_time,max_time};
178 Float_t vertexFIT = 9999999;
179 for (Int_t ipmt=0; ipmt<80; ipmt++)//timeC
180 if(time[ipmt]<firsttime[2]) firsttime[2]=time[ipmt];
182 for ( Int_t ipmt=80; ipmt<160; ipmt++)
183 if(time[ipmt]<firsttime[1]) firsttime[1]=time[ipmt];
186 AliDebug(5,Form("1stimeA %f , 1sttimeC %f ",
189 if (firsttime[1]<max_time && firsttime[2]<max_time) {
190 firsttime[0] = channelWidth *(firsttime[1] + firsttime[2])/2;
191 vertexFIT = c*channelWidth*(firsttime[1] - firsttime[2])/2;
193 if (firsttime[1]<max_time)
194 firsttime[1] = firsttime[1] * channelWidth + shift;
196 if (firsttime[2]<max_time)
197 firsttime[2] = firsttime[2] * channelWidth - shift;
201 for(Int_t i=0; i<3; i++) {
202 fESDFIT->SetFITT0(i,firsttime[i]); // interaction time (ns)
204 fESDFIT->SetFITzVertex(vertexFIT); //vertex Z position
207 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]));