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 // START (T-Zero) Detector //
21 // This class contains the base procedures for the START //
26 <img src="gif/AliSTARTClass.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 "AliSTARTLoader.h"
59 #include "AliSTARTdigit.h"
60 #include "AliSTARThit.h"
61 #include "AliSTARTDigitizer.h"
62 #include "AliSTARTRawData.h"
63 #include "AliSTARTRecPoint.h"
68 //static AliSTARTdigit *digits;
70 //_____________________________________________________________________________
74 // Default constructor for class AliSTART
82 //_____________________________________________________________________________
83 AliSTART::AliSTART(const char *name, const char *title)
84 : AliDetector(name,title)
87 // Standard constructor for START Detector
92 // Initialise Hit array
93 fHits = new TClonesArray("AliSTARThit", 405);
94 gAlice->GetMCApp()->AddHitList(fHits);
95 fDigits = new AliSTARTdigit();
96 fRecPoints = new AliSTARTRecPoint();
102 //_____________________________________________________________________________
103 AliSTART::~AliSTART() {
113 cout<<" delete fDigits; "<<endl;
116 fRecPoints ->Delete();
118 cout<<" delete fRecPoints; "<<endl;
123 //_____________________________________________________________________________
124 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
129 TClonesArray &lhits = *fHits;
130 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
134 //_____________________________________________________________________________
136 void AliSTART::AddDigit(Int_t besttimeright, Int_t besttimeleft, Int_t meantime,
137 Int_t timediff, Int_t sumMult,
138 TArrayI *time, TArrayI *adc, TArrayI *timeAmp, TArrayI *adcAmp)
141 // Add a START digit to the list.
145 fDigits = new AliSTARTdigit();
147 fDigits-> SetTimeBestRight(besttimeright);
148 fDigits->SetTimeBestLeft(besttimeleft);
149 fDigits-> SetMeanTime(meantime);
150 fDigits-> SetDiffTime(timediff);
151 fDigits-> SetSumMult(sumMult);
152 fDigits->SetTime(*time);
153 fDigits->SetTimeAmp(*timeAmp);
154 fDigits->SetADC(*adc);
155 fDigits->SetADCAmp(*adcAmp);
159 //_____________________________________________________________________________
160 void AliSTART::BuildGeometry()
163 // Build simple ROOT TNode geometry for event display
166 const int kColorSTART = 19;
168 top=gAlice->GetGeometry()->GetNode("alice");
170 // START define the different volumes
171 new TRotMatrix("rotx999","rot999", 90,0,90,90,180,0);
173 new TTUBE("S_0ST1","START volume 1","void",5.,10.7,5.3);
175 node = new TNode("0ST1","0ST01","S_0ST1",0,0,-69.7,"");
176 node->SetLineColor(kColorSTART);
179 new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3);
181 node = new TNode("0ST2","0ST2","S_0ST2",0,0,350,"rotx999");
182 node->SetLineColor(kColorSTART);
186 //_____________________________________________________________________________
187 Int_t AliSTART::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/)
190 // Calculate the distance from the mouse to the START on the screen
196 //-------------------------------------------------------------------------
197 void AliSTART::Init()
200 // Initialis the START after it has been built
203 if(AliLog::GetGlobalDebugLevel()>0) {
204 printf("\n%s: ",ClassName());
205 for(i=0;i<35;i++) printf("*");
206 printf(" START_INIT ");
207 for(i=0;i<35;i++) printf("*");
208 printf("\n%s: ",ClassName());
210 // Here the START initialisation code (if any!)
211 for(i=0;i<80;i++) printf("*");
216 //---------------------------------------------------------------------------
217 void AliSTART::MakeBranch(Option_t* option)
220 // Create Tree branches for the START.
224 // H Make a branch of TClonesArray of AliSTARTHit's
225 // D Make a branch of TClonesArray of AliSTARTDigit's
227 // R Make a branch of AliSTARTRecPoints
230 sprintf(branchname,"%s",GetName());
232 const char *cH = strstr(option,"H");
233 const char *cD = strstr(option,"D");
234 const char *cR = strstr(option,"R");
236 if (cH && fLoader->TreeH())
238 if (fHits == 0x0) fHits = new TClonesArray("AliSTARThit", 405);
239 AliDetector::MakeBranch(option);
243 if (cD && fLoader->TreeD())
245 if (fDigits == 0x0) fDigits = new AliSTARTdigit();
246 // MakeBranchInTree(fLoader->TreeD(), branchname,
247 // &fDigits, 405, 0);
248 fLoader->TreeD()->Branch(branchname,"AliSTARTdigit",&fDigits,405,1);
249 // fLoader->TreeD()->Print();
251 if (cR && fLoader->TreeR())
253 if (fRecPoints == 0x0) fRecPoints = new AliSTARTRecPoint();
254 MakeBranchInTree(fLoader->TreeR(), branchname,
255 &fRecPoints, 405, 0);
260 //_____________________________________________________________________________
261 void AliSTART::ResetHits()
263 AliDetector::ResetHits();
266 //____________________________________________________________________
267 void AliSTART::ResetDigits()
270 // Reset number of digits and the digits array for this detector
272 if (fDigits) fDigits->Clear();
275 //_____________________________________________________________________________
276 void AliSTART::SetTreeAddress()
284 if (fHits == 0x0) fHits = new TClonesArray("AliSTARThit", 405);
287 AliDetector::SetTreeAddress();
288 TTree *treeD = fLoader->TreeD();
290 if (fDigits == 0x0) fDigits = new AliSTARTdigit();
291 TBranch* branch = treeD->GetBranch ("START");
292 if (branch) branch->SetAddress(&fDigits);
295 TTree *treeR = fLoader->TreeR();
297 if (fRecPoints == 0x0) fRecPoints = new AliSTARTRecPoint() ;
298 TBranch* branch = treeR->GetBranch ("START");
299 if (branch) branch->SetAddress(&fRecPoints);
305 //_____________________________________________________________________________
306 void AliSTART::MakeBranchInTreeD(TTree *treeD, const char *file)
309 // Create TreeD branches for the FMD
311 const Int_t kBufferSize = 4000;
313 sprintf(branchname,"%s",GetName());
316 MakeBranchInTree(treeD, branchname,&fDigits, kBufferSize, file);
320 //_____________________________________________________________________________
321 AliDigitizer* AliSTART::CreateDigitizer(AliRunDigitizer* manager) const
323 return new AliSTARTDigitizer(manager);
325 //____________________________________________________________________________
326 void AliSTART::Digits2Raw()
329 // Starting from the START digits, writes the Raw Data objects
331 // AliSTARTLoader* pStartLoader = (AliSTARTLoader*)fLoader;
332 fLoader ->LoadDigits("read");
333 TTree* treeD = fLoader->TreeD();
335 AliError("no digits tree");
338 if (fDigits == 0x0) fDigits = new AliSTARTdigit();
340 TBranch *branch = treeD->GetBranch("START");
342 branch->SetAddress(&fDigits);
344 AliError("Branch START DIGIT not found");
347 AliSTARTRawData rawWriter;
348 rawWriter.SetVerbose(0);
350 AliDebug(2,Form(" Formatting raw data for START "));
352 // rawWriter.RawDataSTART(treeD->GetBranch("START"));
353 rawWriter.RawDataSTART(fDigits);
356 fLoader->UnloadDigits();