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 ///////////////////////////////////////////////////////////////////////////////
20 // T0 (T-Zero) Detector //
21 // This class contains the base procedures for the T0 //
26 <img src="gif/AliT0Class.gif">
29 <font size=+2 color=red>
30 <p>The responsible person for this module is
31 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
38 ///////////////////////////////////////////////////////////////////////////////
40 #include "TClonesArray.h"
42 #include "AliLoader.h"
48 #include "AliT0Digitizer.h"
49 #include "AliT0RawData.h"
50 #include "AliT0RecPoint.h"
51 #include "AliT0digit.h"
56 //static AliT0digit *digits;
58 //_____________________________________________________________________________
60 : AliDetector(), fIdSens(0), fDigits(NULL), fRecPoints(NULL)
63 // Default constructor for class AliT0
71 //_____________________________________________________________________________
72 AliT0::AliT0(const char *name, const char *title)
73 : AliDetector(name,title), fIdSens(0), fDigits(new AliT0digit()), fRecPoints(new AliT0RecPoint())
76 // Standard constructor for T0 Detector
81 // Initialise Hit array
82 fHits = new TClonesArray("AliT0hit", 405);
83 gAlice->GetMCApp()->AddHitList(fHits);
84 // fDigits = new AliT0digit();
85 // fRecPoints = new AliT0RecPoint();
88 //PH SetMarkerColor(kRed);
91 //_____________________________________________________________________________
103 cout<<" delete fDigits; "<<endl;
106 fRecPoints ->Delete();
108 cout<<" delete fRecPoints; "<<endl;
113 //_____________________________________________________________________________
114 void AliT0::AddHit(Int_t track, Int_t *vol, Float_t *hits)
119 TClonesArray &lhits = *fHits;
120 new(lhits[fNhits++]) AliT0hit(fIshunt,track,vol,hits);
124 //_____________________________________________________________________________
126 void AliT0::AddDigit(Int_t besttimeright, Int_t besttimeleft, Int_t meantime,
127 Int_t timediff, Int_t sumMult, Int_t refpoint,
128 TArrayI *timeCFD, TArrayI *qt0, TArrayI *timeLED, TArrayI *qt1)
131 // Add a T0 digit to the list.
135 fDigits = new AliT0digit();
137 fDigits-> SetTimeBestA(besttimeright);
138 fDigits->SetTimeBestC(besttimeleft);
139 fDigits-> SetMeanTime(meantime);
140 fDigits-> SetDiffTime(timediff);
141 fDigits-> SetSumMult(sumMult);
142 fDigits->SetTimeCFD(*timeCFD);
143 fDigits->SetTimeLED(*timeLED);
144 fDigits->SetQT0(*qt0);
145 fDigits->SetQT1(*qt1);
146 fDigits->SetRefPoint(refpoint);
149 //-------------------------------------------------------------------------
153 // Initialis the T0 after it has been built
156 if(AliLog::GetGlobalDebugLevel()>0) {
157 printf("\n%s: ",ClassName());
158 for(i=0;i<35;i++) printf("*");
160 for(i=0;i<35;i++) printf("*");
161 printf("\n%s: ",ClassName());
163 // Here the T0 initialisation code (if any!)
164 for(i=0;i<80;i++) printf("*");
169 //---------------------------------------------------------------------------
170 void AliT0::MakeBranch(Option_t* option)
173 // Create Tree branches for the T0.
177 // H Make a branch of TClonesArray of AliT0Hit's
178 // D Make a branch of TClonesArray of AliT0Digit's
180 // R Make a branch of AliT0RecPoints
183 sprintf(branchname,"%s",GetName());
185 const char *cH = strstr(option,"H");
186 const char *cD = strstr(option,"D");
187 const char *cR = strstr(option,"R");
188 const char *cS = strstr(option,"S");
190 if (cH && fLoader->TreeH())
192 if (fHits == 0x0) fHits = new TClonesArray("AliT0hit", 405);
193 AliDetector::MakeBranch(option);
197 if (cD && fLoader->TreeD())
199 if (fDigits == 0x0) fDigits = new AliT0digit();
200 // MakeBranchInTree(fLoader->TreeD(), branchname,
201 // &fDigits, 405, 0);
202 fLoader->TreeD()->Branch(branchname,"AliT0digit",&fDigits);
203 // fLoader->TreeD()->Print();
205 if (cR && fLoader->TreeR())
207 if (fRecPoints == 0x0) fRecPoints = new AliT0RecPoint();
208 MakeBranchInTree(fLoader->TreeR(), branchname, &fRecPoints);
210 if (cS && fLoader->TreeS())
212 if (fDigits == 0x0) fDigits = new AliT0digit();
213 // MakeBranchInTree(fLoader->TreeD(), branchname,
214 // &fDigits, 405, 0);
215 fLoader->TreeS()->Branch(branchname,"AliT0digit",&fDigits);
216 // fLoader->TreeD()->Print();
221 //_____________________________________________________________________________
222 void AliT0::ResetHits()
227 AliDetector::ResetHits();
230 //____________________________________________________________________
231 void AliT0::ResetDigits()
234 // Reset number of digits and the digits array for this detector
236 if (fDigits) fDigits->Clear();
239 //_____________________________________________________________________________
240 void AliT0::SetTreeAddress()
243 TTree *treeH = fLoader->TreeH();
247 if (fHits == 0x0) fHits = new TClonesArray("AliT0hit", 405);
250 AliDetector::SetTreeAddress();
251 TTree *treeD = fLoader->TreeD();
253 if (fDigits == 0x0) fDigits = new AliT0digit();
254 TBranch* branch = treeD->GetBranch ("T0");
255 if (branch) branch->SetAddress(&fDigits);
258 TTree *treeR = fLoader->TreeR();
260 if (fRecPoints == 0x0) fRecPoints = new AliT0RecPoint() ;
261 TBranch* branch = treeR->GetBranch ("T0");
262 if (branch) branch->SetAddress(&fRecPoints);
264 // SDigitizer for Federico
265 TTree *treeS = fLoader->TreeS();
267 if (fDigits == 0x0) fDigits = new AliT0digit();
268 TBranch* branch = treeS->GetBranch ("T0");
269 if (branch) branch->SetAddress(&fDigits);
275 //_____________________________________________________________________________
276 void AliT0::MakeBranchInTreeD(TTree *treeD, const char *file)
279 // Create TreeD branches for the FMD
281 const Int_t kBufferSize = 4000;
283 sprintf(branchname,"%s",GetName());
286 MakeBranchInTree(treeD, branchname,&fDigits, kBufferSize, file);
290 //_____________________________________________________________________________
291 AliDigitizer* AliT0::CreateDigitizer(AliRunDigitizer* manager) const
293 return new AliT0Digitizer(manager);
295 //____________________________________________________________________________
296 void AliT0::Digits2Raw()
299 // Starting from the T0 digits, writes the Raw Data objects
301 // AliT0Loader* pStartLoader = (AliT0Loader*)fLoader;
302 fLoader ->LoadDigits("read");
303 TTree* treeD = fLoader->TreeD();
305 AliError("no digits tree");
308 if (fDigits == 0x0) fDigits = new AliT0digit();
310 TBranch *branch = treeD->GetBranch("T0");
312 branch->SetAddress(&fDigits);
314 AliError("Branch T0 DIGIT not found");
317 AliT0RawData rawWriter;
318 rawWriter.SetVerbose(0);
320 AliDebug(2,Form(" Formatting raw data for T0 "));
322 // rawWriter.RawDataT0(treeD->GetBranch("T0"));
323 rawWriter.RawDataT0(fDigits);
326 fLoader->UnloadDigits();
330 //____________________________________________________________________________
331 void AliT0::Raw2Digits(AliRawReader *rawReader,TTree* digitsTree)
334 //T0 raw data-> digits conversion
335 // reconstruct time information from raw data
336 // cout<<" AliT0::Raw2Digits(AliRawReader *rawReader,TTree* digitsTree) "<<
337 // rawReader<<" "<<digitsTree<<endl;
340 // AliT0RawReader myrawreader(rawReader,digitsTree);
341 AliT0RawReader myrawreader(rawReader);
342 if (!myrawreader.Next())
343 AliDebug(1,Form(" no raw data found!! %i", myrawreader.Next()));
344 Int_t allData[110][5];
345 for (Int_t i=0; i<110; i++) {
346 allData[i][0]=myrawreader.GetData(i,0);
350 fDigits = new AliT0digit();
351 digitsTree->Branch("T0","AliT0digit",&fDigits);
354 TArrayI *timeLED = new TArrayI(24);
355 TArrayI * timeCFD = new TArrayI(24);
356 TArrayI *chargeQT0 = new TArrayI(24);
357 TArrayI *chargeQT1 = new TArrayI(24);
359 for (Int_t in=0; in<24; in++)
361 timeLED->AddAt(allData[in+1][0],in);
362 timeCFD->AddAt(allData[in+25][0],in);
363 chargeQT0->AddAt(allData[in+55][0],in);
364 chargeQT1->AddAt(allData[in+79][0],in);
365 AliDebug(2, Form(" readed Raw %i %i %i %i %i", in, timeLED->At(in),timeCFD->At(in),chargeQT0->At(in),chargeQT1->At(in)));
368 fDigits->SetTimeCFD(*timeCFD);
369 fDigits->SetQT0(*chargeQT1);
371 fDigits->SetTimeLED(*timeLED);
372 fDigits->SetQT1(*chargeQT1);
374 fDigits->SetMeanTime(allData[49][0]);
375 fDigits->SetDiffTime(allData[50][0]);
376 fDigits->SetTimeBestA(allData[51][0]);
377 fDigits->SetTimeBestC(allData[52][0]);