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 //_____________________________________________________________________________
72 : AliDetector(), fIdSens(0), fDigits(NULL), fRecPoints(NULL)
75 // Default constructor for class AliSTART
83 //_____________________________________________________________________________
84 AliSTART::AliSTART(const char *name, const char *title)
85 : AliDetector(name,title), fIdSens(0), fDigits(new AliSTARTdigit()), fRecPoints(new AliSTARTRecPoint())
88 // Standard constructor for START Detector
93 // Initialise Hit array
94 fHits = new TClonesArray("AliSTARThit", 405);
95 gAlice->GetMCApp()->AddHitList(fHits);
96 // fDigits = new AliSTARTdigit();
97 // fRecPoints = new AliSTARTRecPoint();
100 SetMarkerColor(kRed);
103 //_____________________________________________________________________________
104 AliSTART::~AliSTART() {
114 cout<<" delete fDigits; "<<endl;
117 fRecPoints ->Delete();
119 cout<<" delete fRecPoints; "<<endl;
124 //______________________________________________________________________________
125 AliSTART::AliSTART(const AliSTART &source):
130 AliWarning("Copy constructor not implemented!");
133 //______________________________________________________________________________
134 AliSTART& AliSTART::operator= (const AliSTART& source)
136 // Asignment operator
138 if(this==&source) return *this;
140 AliWarning("Asignment operator not implemented!");
142 ((TObject *)this)->operator=(source);
147 //_____________________________________________________________________________
148 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
153 TClonesArray &lhits = *fHits;
154 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
158 //_____________________________________________________________________________
160 void AliSTART::AddDigit(Int_t besttimeright, Int_t besttimeleft, Int_t meantime,
161 Int_t timediff, Int_t sumMult,
162 TArrayI *time, TArrayI *adc, TArrayI *timeAmp, TArrayI *adcAmp)
165 // Add a START digit to the list.
169 fDigits = new AliSTARTdigit();
171 fDigits-> SetTimeBestRight(besttimeright);
172 fDigits->SetTimeBestLeft(besttimeleft);
173 fDigits-> SetMeanTime(meantime);
174 fDigits-> SetDiffTime(timediff);
175 fDigits-> SetSumMult(sumMult);
176 fDigits->SetTime(*time);
177 fDigits->SetTimeAmp(*timeAmp);
178 fDigits->SetADC(*adc);
179 fDigits->SetADCAmp(*adcAmp);
183 //_____________________________________________________________________________
184 void AliSTART::BuildGeometry()
187 // Build simple ROOT TNode geometry for event display
190 const int kColorSTART = 19;
192 top=gAlice->GetGeometry()->GetNode("alice");
194 // START define the different volumes
195 new TRotMatrix("rotx999","rot999", 90,0,90,90,180,0);
197 new TTUBE("S_0ST1","START volume 1","void",5.,10.7,5.3);
199 node = new TNode("0ST1","0ST01","S_0ST1",0,0,-69.7,"");
200 node->SetLineColor(kColorSTART);
203 new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3);
205 node = new TNode("0ST2","0ST2","S_0ST2",0,0,350,"rotx999");
206 node->SetLineColor(kColorSTART);
210 //_____________________________________________________________________________
211 Int_t AliSTART::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/)
214 // Calculate the distance from the mouse to the START on the screen
220 //-------------------------------------------------------------------------
221 void AliSTART::Init()
224 // Initialis the START after it has been built
227 if(AliLog::GetGlobalDebugLevel()>0) {
228 printf("\n%s: ",ClassName());
229 for(i=0;i<35;i++) printf("*");
230 printf(" START_INIT ");
231 for(i=0;i<35;i++) printf("*");
232 printf("\n%s: ",ClassName());
234 // Here the START initialisation code (if any!)
235 for(i=0;i<80;i++) printf("*");
240 //---------------------------------------------------------------------------
241 void AliSTART::MakeBranch(Option_t* option)
244 // Create Tree branches for the START.
248 // H Make a branch of TClonesArray of AliSTARTHit's
249 // D Make a branch of TClonesArray of AliSTARTDigit's
251 // R Make a branch of AliSTARTRecPoints
254 sprintf(branchname,"%s",GetName());
256 const char *cH = strstr(option,"H");
257 const char *cD = strstr(option,"D");
258 const char *cR = strstr(option,"R");
260 if (cH && fLoader->TreeH())
262 if (fHits == 0x0) fHits = new TClonesArray("AliSTARThit", 405);
263 AliDetector::MakeBranch(option);
267 if (cD && fLoader->TreeD())
269 if (fDigits == 0x0) fDigits = new AliSTARTdigit();
270 // MakeBranchInTree(fLoader->TreeD(), branchname,
271 // &fDigits, 405, 0);
272 fLoader->TreeD()->Branch(branchname,"AliSTARTdigit",&fDigits,405,1);
273 // fLoader->TreeD()->Print();
275 if (cR && fLoader->TreeR())
277 if (fRecPoints == 0x0) fRecPoints = new AliSTARTRecPoint();
278 MakeBranchInTree(fLoader->TreeR(), branchname,
279 &fRecPoints, 405, 0);
284 //_____________________________________________________________________________
285 void AliSTART::ResetHits()
287 AliDetector::ResetHits();
290 //____________________________________________________________________
291 void AliSTART::ResetDigits()
294 // Reset number of digits and the digits array for this detector
296 if (fDigits) fDigits->Clear();
299 //_____________________________________________________________________________
300 void AliSTART::SetTreeAddress()
308 if (fHits == 0x0) fHits = new TClonesArray("AliSTARThit", 405);
311 AliDetector::SetTreeAddress();
312 TTree *treeD = fLoader->TreeD();
314 if (fDigits == 0x0) fDigits = new AliSTARTdigit();
315 TBranch* branch = treeD->GetBranch ("START");
316 if (branch) branch->SetAddress(&fDigits);
319 TTree *treeR = fLoader->TreeR();
321 if (fRecPoints == 0x0) fRecPoints = new AliSTARTRecPoint() ;
322 TBranch* branch = treeR->GetBranch ("START");
323 if (branch) branch->SetAddress(&fRecPoints);
329 //_____________________________________________________________________________
330 void AliSTART::MakeBranchInTreeD(TTree *treeD, const char *file)
333 // Create TreeD branches for the FMD
335 const Int_t kBufferSize = 4000;
337 sprintf(branchname,"%s",GetName());
340 MakeBranchInTree(treeD, branchname,&fDigits, kBufferSize, file);
344 //_____________________________________________________________________________
345 AliDigitizer* AliSTART::CreateDigitizer(AliRunDigitizer* manager) const
347 return new AliSTARTDigitizer(manager);
349 //____________________________________________________________________________
350 void AliSTART::Digits2Raw()
353 // Starting from the START digits, writes the Raw Data objects
355 // AliSTARTLoader* pStartLoader = (AliSTARTLoader*)fLoader;
356 fLoader ->LoadDigits("read");
357 TTree* treeD = fLoader->TreeD();
359 AliError("no digits tree");
362 if (fDigits == 0x0) fDigits = new AliSTARTdigit();
364 TBranch *branch = treeD->GetBranch("START");
366 branch->SetAddress(&fDigits);
368 AliError("Branch START DIGIT not found");
371 AliSTARTRawData rawWriter;
372 rawWriter.SetVerbose(0);
374 AliDebug(2,Form(" Formatting raw data for START "));
376 // rawWriter.RawDataSTART(treeD->GetBranch("START"));
377 rawWriter.RawDataSTART(fDigits);
380 fLoader->UnloadDigits();