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>
49 #include <TVirtualMC.h>
54 #include "AliLoader.h"
56 #include "TClonesArray.h"
58 #include "AliT0Loader.h"
59 #include "AliT0digit.h"
61 #include "AliT0Digitizer.h"
62 #include "AliT0RawData.h"
63 #include "AliT0RecPoint.h"
64 #include "AliT0Parameters.h"
69 //static AliT0digit *digits;
71 //_____________________________________________________________________________
73 : AliDetector(), fIdSens(0), fDigits(NULL), fRecPoints(NULL)
76 // Default constructor for class AliT0
84 //_____________________________________________________________________________
85 AliT0::AliT0(const char *name, const char *title)
86 : AliDetector(name,title), fIdSens(0), fDigits(new AliT0digit()), fRecPoints(new AliT0RecPoint())
89 // Standard constructor for T0 Detector
94 // Initialise Hit array
95 fHits = new TClonesArray("AliT0hit", 405);
96 gAlice->GetMCApp()->AddHitList(fHits);
97 // fDigits = new AliT0digit();
98 // fRecPoints = new AliT0RecPoint();
101 //PH SetMarkerColor(kRed);
104 //_____________________________________________________________________________
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,
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);
161 //_____________________________________________________________________________
162 void AliT0::BuildGeometry()
165 // Build simple ROOT TNode geometry for event display
168 const int kColorT0 = 19;
170 top=gAlice->GetGeometry()->GetNode("alice");
172 // T0 define the different volumes
173 new TRotMatrix("rotx999","rot999", 90,0,90,90,180,0);
175 new TTUBE("S_0ST1","T0 volume 1","void",5.,10.7,5.3);
177 node = new TNode("0ST1","0ST01","S_0ST1",0,0,-69.7,"");
178 node->SetLineColor(kColorT0);
181 new TTUBE("S_0ST2","T0 volume 2","void",5.,10.7,5.3);
183 node = new TNode("0ST2","0ST2","S_0ST2",0,0,350,"rotx999");
184 node->SetLineColor(kColorT0);
188 //_____________________________________________________________________________
189 Int_t AliT0::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/)
192 // Calculate the distance from the mouse to the T0 on the screen
198 //-------------------------------------------------------------------------
202 // Initialis the T0 after it has been built
205 if(AliLog::GetGlobalDebugLevel()>0) {
206 printf("\n%s: ",ClassName());
207 for(i=0;i<35;i++) printf("*");
209 for(i=0;i<35;i++) printf("*");
210 printf("\n%s: ",ClassName());
212 // Here the T0 initialisation code (if any!)
213 for(i=0;i<80;i++) printf("*");
218 //---------------------------------------------------------------------------
219 void AliT0::MakeBranch(Option_t* option)
222 // Create Tree branches for the T0.
226 // H Make a branch of TClonesArray of AliT0Hit's
227 // D Make a branch of TClonesArray of AliT0Digit's
229 // R Make a branch of AliT0RecPoints
232 sprintf(branchname,"%s",GetName());
234 const char *cH = strstr(option,"H");
235 const char *cD = strstr(option,"D");
236 const char *cR = strstr(option,"R");
238 if (cH && fLoader->TreeH())
240 if (fHits == 0x0) fHits = new TClonesArray("AliT0hit", 405);
241 AliDetector::MakeBranch(option);
245 if (cD && fLoader->TreeD())
247 if (fDigits == 0x0) fDigits = new AliT0digit();
248 // MakeBranchInTree(fLoader->TreeD(), branchname,
249 // &fDigits, 405, 0);
250 fLoader->TreeD()->Branch(branchname,"AliT0digit",&fDigits,405,1);
251 // fLoader->TreeD()->Print();
253 if (cR && fLoader->TreeR())
255 if (fRecPoints == 0x0) fRecPoints = new AliT0RecPoint();
256 MakeBranchInTree(fLoader->TreeR(), branchname,
257 &fRecPoints, 405, 0);
262 //_____________________________________________________________________________
263 void AliT0::ResetHits()
265 AliDetector::ResetHits();
268 //____________________________________________________________________
269 void AliT0::ResetDigits()
272 // Reset number of digits and the digits array for this detector
274 if (fDigits) fDigits->Clear();
277 //_____________________________________________________________________________
278 void AliT0::SetTreeAddress()
286 if (fHits == 0x0) fHits = new TClonesArray("AliT0hit", 405);
289 AliDetector::SetTreeAddress();
290 TTree *treeD = fLoader->TreeD();
292 if (fDigits == 0x0) fDigits = new AliT0digit();
293 TBranch* branch = treeD->GetBranch ("T0");
294 if (branch) branch->SetAddress(&fDigits);
297 TTree *treeR = fLoader->TreeR();
299 if (fRecPoints == 0x0) fRecPoints = new AliT0RecPoint() ;
300 TBranch* branch = treeR->GetBranch ("T0");
301 if (branch) branch->SetAddress(&fRecPoints);
307 //_____________________________________________________________________________
308 void AliT0::MakeBranchInTreeD(TTree *treeD, const char *file)
311 // Create TreeD branches for the FMD
313 const Int_t kBufferSize = 4000;
315 sprintf(branchname,"%s",GetName());
318 MakeBranchInTree(treeD, branchname,&fDigits, kBufferSize, file);
322 //_____________________________________________________________________________
323 AliDigitizer* AliT0::CreateDigitizer(AliRunDigitizer* manager) const
325 return new AliT0Digitizer(manager);
327 //____________________________________________________________________________
328 void AliT0::Digits2Raw()
331 // Starting from the T0 digits, writes the Raw Data objects
333 // AliT0Loader* pStartLoader = (AliT0Loader*)fLoader;
334 fLoader ->LoadDigits("read");
335 TTree* treeD = fLoader->TreeD();
337 AliError("no digits tree");
340 if (fDigits == 0x0) fDigits = new AliT0digit();
342 TBranch *branch = treeD->GetBranch("T0");
344 branch->SetAddress(&fDigits);
346 AliError("Branch T0 DIGIT not found");
349 AliT0RawData rawWriter;
350 rawWriter.SetVerbose(0);
352 AliDebug(2,Form(" Formatting raw data for T0 "));
354 // rawWriter.RawDataT0(treeD->GetBranch("T0"));
355 rawWriter.RawDataT0(fDigits);
358 fLoader->UnloadDigits();
362 //____________________________________________________________________________
363 void AliT0::Raw2Digits(AliRawReader *rawReader,TTree* digitsTree)
366 //T0 raw data-> digits conversion
367 // reconstruct time information from raw data
368 // cout<<" AliT0::Raw2Digits(AliRawReader *rawReader,TTree* digitsTree) "<<
369 // rawReader<<" "<<digitsTree<<endl;
372 // AliT0RawReader myrawreader(rawReader,digitsTree);
373 AliT0RawReader myrawreader(rawReader);
374 if (!myrawreader.Next())
375 AliDebug(1,Form(" no raw data found!! %i", myrawreader.Next()));
376 Int_t allData[110][5];
377 for (Int_t i=0; i<110; i++) {
378 allData[i][0]=myrawreader.GetData(i,0);
382 AliT0digit* fDigits = new AliT0digit();
383 digitsTree->Branch("T0","AliT0digit",&fDigits,405,1);
386 TArrayI *timeLED = new TArrayI(24);
387 TArrayI * timeCFD = new TArrayI(24);
388 TArrayI *chargeQT0 = new TArrayI(24);
389 TArrayI *chargeQT1 = new TArrayI(24);
391 for (Int_t in=0; in<24; in++)
393 timeLED->AddAt(allData[in+1][0],in);
394 timeCFD->AddAt(allData[in+25][0],in);
395 chargeQT0->AddAt(allData[in+55][0],in);
396 chargeQT1->AddAt(allData[in+79][0],in);
397 AliDebug(2, Form(" readed Raw %i %i %i %i %i", in, timeLED->At(in),timeCFD->At(in),chargeQT0->At(in),chargeQT1->At(in)));
400 fDigits->SetTimeCFD(*timeCFD);
401 fDigits->SetQT0(*chargeQT1);
403 fDigits->SetTimeLED(*timeLED);
404 fDigits->SetQT1(*chargeQT1);
406 fDigits->SetMeanTime(allData[49][0]);
407 fDigits->SetDiffTime(allData[50][0]);
408 fDigits->SetTimeBestA(allData[51][0]);
409 fDigits->SetTimeBestC(allData[52][0]);