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 <Riostream.h>
43 #include <TGeometry.h>
46 //#include <TParticle.h>
47 //#include <TRandom.h>
49 //#include <TVirtualMC.h>
53 #include "AliLoader.h"
55 #include "TClonesArray.h"
57 //#include "AliT0Loader.h"
58 #include "AliT0digit.h"
60 #include "AliT0Digitizer.h"
61 #include "AliT0RawData.h"
62 #include "AliT0RecPoint.h"
63 //#include "AliT0Parameters.h"
68 //static AliT0digit *digits;
70 //_____________________________________________________________________________
72 : AliDetector(), fIdSens(0), fDigits(NULL), fRecPoints(NULL)
75 // Default constructor for class AliT0
83 //_____________________________________________________________________________
84 AliT0::AliT0(const char *name, const char *title)
85 : AliDetector(name,title), fIdSens(0), fDigits(new AliT0digit()), fRecPoints(new AliT0RecPoint())
88 // Standard constructor for T0 Detector
93 // Initialise Hit array
94 fHits = new TClonesArray("AliT0hit", 405);
95 gAlice->GetMCApp()->AddHitList(fHits);
96 // fDigits = new AliT0digit();
97 // fRecPoints = new AliT0RecPoint();
100 //PH SetMarkerColor(kRed);
103 //_____________________________________________________________________________
115 cout<<" delete fDigits; "<<endl;
118 fRecPoints ->Delete();
120 cout<<" delete fRecPoints; "<<endl;
125 //_____________________________________________________________________________
126 void AliT0::AddHit(Int_t track, Int_t *vol, Float_t *hits)
131 TClonesArray &lhits = *fHits;
132 new(lhits[fNhits++]) AliT0hit(fIshunt,track,vol,hits);
136 //_____________________________________________________________________________
138 void AliT0::AddDigit(Int_t besttimeright, Int_t besttimeleft, Int_t meantime,
139 Int_t timediff, Int_t sumMult, Int_t refpoint,
140 TArrayI *timeCFD, TArrayI *qt0, TArrayI *timeLED, TArrayI *qt1)
143 // Add a T0 digit to the list.
147 fDigits = new AliT0digit();
149 fDigits-> SetTimeBestA(besttimeright);
150 fDigits->SetTimeBestC(besttimeleft);
151 fDigits-> SetMeanTime(meantime);
152 fDigits-> SetDiffTime(timediff);
153 fDigits-> SetSumMult(sumMult);
154 fDigits->SetTimeCFD(*timeCFD);
155 fDigits->SetTimeLED(*timeLED);
156 fDigits->SetQT0(*qt0);
157 fDigits->SetQT1(*qt1);
158 fDigits->SetRefPoint(refpoint);
161 //-------------------------------------------------------------------------
165 // Initialis the T0 after it has been built
168 if(AliLog::GetGlobalDebugLevel()>0) {
169 printf("\n%s: ",ClassName());
170 for(i=0;i<35;i++) printf("*");
172 for(i=0;i<35;i++) printf("*");
173 printf("\n%s: ",ClassName());
175 // Here the T0 initialisation code (if any!)
176 for(i=0;i<80;i++) printf("*");
181 //---------------------------------------------------------------------------
182 void AliT0::MakeBranch(Option_t* option)
185 // Create Tree branches for the T0.
189 // H Make a branch of TClonesArray of AliT0Hit's
190 // D Make a branch of TClonesArray of AliT0Digit's
192 // R Make a branch of AliT0RecPoints
195 sprintf(branchname,"%s",GetName());
197 const char *cH = strstr(option,"H");
198 const char *cD = strstr(option,"D");
199 const char *cR = strstr(option,"R");
201 if (cH && fLoader->TreeH())
203 if (fHits == 0x0) fHits = new TClonesArray("AliT0hit", 405);
204 AliDetector::MakeBranch(option);
208 if (cD && fLoader->TreeD())
210 if (fDigits == 0x0) fDigits = new AliT0digit();
211 // MakeBranchInTree(fLoader->TreeD(), branchname,
212 // &fDigits, 405, 0);
213 fLoader->TreeD()->Branch(branchname,"AliT0digit",&fDigits,405,1);
214 // fLoader->TreeD()->Print();
216 if (cR && fLoader->TreeR())
218 if (fRecPoints == 0x0) fRecPoints = new AliT0RecPoint();
219 MakeBranchInTree(fLoader->TreeR(), branchname,
220 &fRecPoints, 405, 0);
225 //_____________________________________________________________________________
226 void AliT0::ResetHits()
231 AliDetector::ResetHits();
234 //____________________________________________________________________
235 void AliT0::ResetDigits()
238 // Reset number of digits and the digits array for this detector
240 if (fDigits) fDigits->Clear();
243 //_____________________________________________________________________________
244 void AliT0::SetTreeAddress()
252 if (fHits == 0x0) fHits = new TClonesArray("AliT0hit", 405);
255 AliDetector::SetTreeAddress();
256 TTree *treeD = fLoader->TreeD();
258 if (fDigits == 0x0) fDigits = new AliT0digit();
259 TBranch* branch = treeD->GetBranch ("T0");
260 if (branch) branch->SetAddress(&fDigits);
263 TTree *treeR = fLoader->TreeR();
265 if (fRecPoints == 0x0) fRecPoints = new AliT0RecPoint() ;
266 TBranch* branch = treeR->GetBranch ("T0");
267 if (branch) branch->SetAddress(&fRecPoints);
273 //_____________________________________________________________________________
274 void AliT0::MakeBranchInTreeD(TTree *treeD, const char *file)
277 // Create TreeD branches for the FMD
279 const Int_t kBufferSize = 4000;
281 sprintf(branchname,"%s",GetName());
284 MakeBranchInTree(treeD, branchname,&fDigits, kBufferSize, file);
288 //_____________________________________________________________________________
289 AliDigitizer* AliT0::CreateDigitizer(AliRunDigitizer* manager) const
291 return new AliT0Digitizer(manager);
293 //____________________________________________________________________________
294 void AliT0::Digits2Raw()
297 // Starting from the T0 digits, writes the Raw Data objects
299 // AliT0Loader* pStartLoader = (AliT0Loader*)fLoader;
300 fLoader ->LoadDigits("read");
301 TTree* treeD = fLoader->TreeD();
303 AliError("no digits tree");
306 if (fDigits == 0x0) fDigits = new AliT0digit();
308 TBranch *branch = treeD->GetBranch("T0");
310 branch->SetAddress(&fDigits);
312 AliError("Branch T0 DIGIT not found");
315 AliT0RawData rawWriter;
316 rawWriter.SetVerbose(0);
318 AliDebug(2,Form(" Formatting raw data for T0 "));
320 // rawWriter.RawDataT0(treeD->GetBranch("T0"));
321 rawWriter.RawDataT0(fDigits);
324 fLoader->UnloadDigits();
328 //____________________________________________________________________________
329 void AliT0::Raw2Digits(AliRawReader *rawReader,TTree* digitsTree)
332 //T0 raw data-> digits conversion
333 // reconstruct time information from raw data
334 // cout<<" AliT0::Raw2Digits(AliRawReader *rawReader,TTree* digitsTree) "<<
335 // rawReader<<" "<<digitsTree<<endl;
338 // AliT0RawReader myrawreader(rawReader,digitsTree);
339 AliT0RawReader myrawreader(rawReader);
340 if (!myrawreader.Next())
341 AliDebug(1,Form(" no raw data found!! %i", myrawreader.Next()));
342 Int_t allData[110][5];
343 for (Int_t i=0; i<110; i++) {
344 allData[i][0]=myrawreader.GetData(i,0);
348 fDigits = new AliT0digit();
349 digitsTree->Branch("T0","AliT0digit",&fDigits,405,1);
352 TArrayI *timeLED = new TArrayI(24);
353 TArrayI * timeCFD = new TArrayI(24);
354 TArrayI *chargeQT0 = new TArrayI(24);
355 TArrayI *chargeQT1 = new TArrayI(24);
357 for (Int_t in=0; in<24; in++)
359 timeLED->AddAt(allData[in+1][0],in);
360 timeCFD->AddAt(allData[in+25][0],in);
361 chargeQT0->AddAt(allData[in+55][0],in);
362 chargeQT1->AddAt(allData[in+79][0],in);
363 AliDebug(2, Form(" readed Raw %i %i %i %i %i", in, timeLED->At(in),timeCFD->At(in),chargeQT0->At(in),chargeQT1->At(in)));
366 fDigits->SetTimeCFD(*timeCFD);
367 fDigits->SetQT0(*chargeQT1);
369 fDigits->SetTimeLED(*timeLED);
370 fDigits->SetQT1(*chargeQT1);
372 fDigits->SetMeanTime(allData[49][0]);
373 fDigits->SetDiffTime(allData[50][0]);
374 fDigits->SetTimeBestA(allData[51][0]);
375 fDigits->SetTimeBestC(allData[52][0]);