]> git.uio.no Git - u/mrichter/AliRoot.git/blob - START/AliSTART.cxx
Adding protected copy constructor and assignment operator
[u/mrichter/AliRoot.git] / START / AliSTART.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  START (T-Zero) Detector                                            //
21 //  This class contains the base procedures for the START     //
22 //  detector                                                                 //
23 //                                                                           //
24 //Begin_Html
25 /*
26 <img src="gif/AliSTARTClass.gif">
27 </pre>
28 <br clear=left>
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>.
32 </font>
33 <pre>
34 */
35 //End_Html
36 //                                                                           //
37 //                                                                           //
38 ///////////////////////////////////////////////////////////////////////////////
39
40 #include <Riostream.h>
41
42 #include <TFile.h>
43 #include <TGeometry.h>
44 #include <TMath.h>
45 #include <TNode.h>
46 #include <TParticle.h>
47 #include <TRandom.h>
48 #include <TTUBE.h>
49 #include <TVirtualMC.h>
50 #include <AliESD.h>
51
52 #include "AliLog.h"
53 #include "AliMC.h"
54 #include "AliLoader.h"
55 #include "AliRun.h"
56 #include "TClonesArray.h"
57 #include "AliSTART.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"
64 #include "AliLog.h"
65
66 ClassImp(AliSTART)
67
68   //static  AliSTARTdigit *digits; 
69
70 //_____________________________________________________________________________
71 AliSTART::AliSTART()
72 {
73   //
74   // Default constructor for class AliSTART
75   //
76   fIshunt   = 1;
77   fHits     = 0;
78   fDigits   = 0;
79   fRecPoints = 0;
80 }
81  
82 //_____________________________________________________________________________
83 AliSTART::AliSTART(const char *name, const char *title)
84        : AliDetector(name,title)
85 {
86   //
87   // Standard constructor for START Detector
88   //
89
90   
91   //
92   // Initialise Hit array
93   fHits       = new TClonesArray("AliSTARThit",  405);
94   gAlice->GetMCApp()->AddHitList(fHits);
95   fDigits    = new AliSTARTdigit();
96   fRecPoints = new AliSTARTRecPoint();
97   fIshunt     =  1;
98   fIdSens   =  0;
99   SetMarkerColor(kRed);
100 }
101
102 //_____________________________________________________________________________
103 AliSTART::~AliSTART() {
104   
105   if (fHits) {
106     fHits->Delete();
107     delete fHits;
108   }
109   /*
110   if (fDigits) {
111     fDigits->Delete();
112     delete fDigits;
113     cout<<" delete fDigits; "<<endl;
114   }
115   if (fRecPoints) {
116    fRecPoints ->Delete();
117     delete fRecPoints;
118     cout<<" delete fRecPoints; "<<endl;
119   }
120   */ 
121 }
122  
123 //_____________________________________________________________________________
124 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
125 {
126   //
127   // Add a START hit
128   //
129   TClonesArray &lhits = *fHits;
130   new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
131 }
132
133
134 //_____________________________________________________________________________
135
136 void AliSTART::AddDigit(Int_t besttimeright, Int_t besttimeleft, Int_t meantime, 
137                         Int_t timediff, TArrayI *sumMult,
138                         TArrayI *time, TArrayI *adc, TArrayI *timeAmp, TArrayI *adcAmp)
139 {
140   
141   //  Add a START digit to the list.
142  //
143   
144   if (!fDigits) {
145     fDigits = new AliSTARTdigit();
146   }
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);
156 }
157
158
159 //_____________________________________________________________________________
160 void AliSTART::BuildGeometry()
161 {
162   //
163   // Build simple ROOT TNode geometry for event display
164   //
165   TNode *node, *top;
166   const int kColorSTART  = 19;
167
168   top=gAlice->GetGeometry()->GetNode("alice");
169
170   // START define the different volumes
171   new TRotMatrix("rotx999","rot999",  90,0,90,90,180,0);
172
173   new TTUBE("S_0ST1","START  volume 1","void",5.,10.7,5.3);
174   top->cd();
175   node = new TNode("0ST1","0ST01","S_0ST1",0,0,-69.7,"");
176   node->SetLineColor(kColorSTART);
177   fNodes->Add(node);
178
179   new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3);
180   top->cd();
181   node = new TNode("0ST2","0ST2","S_0ST2",0,0,350,"rotx999");
182   node->SetLineColor(kColorSTART);
183   fNodes->Add(node);
184 }
185  
186 //_____________________________________________________________________________
187 Int_t AliSTART::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/)
188 {
189   //
190   // Calculate the distance from the mouse to the START on the screen
191   // Dummy routine
192   //
193   return 9999;
194 }
195  
196 //-------------------------------------------------------------------------
197 void AliSTART::Init()
198 {
199   //
200   // Initialis the START after it has been built
201   Int_t i;
202   //
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());
209     //
210     // Here the START initialisation code (if any!)
211     for(i=0;i<80;i++) printf("*");
212     printf("\n");
213   }
214 }
215
216 //---------------------------------------------------------------------------
217 void AliSTART::MakeBranch(Option_t* option)
218 {
219   //
220 // Create Tree branches for the START.
221
222  // Options:
223   //
224   //    H          Make a branch of TClonesArray of AliSTARTHit's
225   //    D          Make a branch of TClonesArray of AliSTARTDigit's
226   //
227   //    R         Make a branch of  AliSTARTRecPoints
228   //
229   char branchname[20];
230   sprintf(branchname,"%s",GetName());
231
232   const char *cH = strstr(option,"H");
233   const char *cD = strstr(option,"D");
234   const char *cR = strstr(option,"R");
235
236     if (cH && fLoader->TreeH())
237   {
238      if (fHits == 0x0) fHits  = new TClonesArray("AliSTARThit",  405);
239      AliDetector::MakeBranch(option);
240   } 
241     
242     
243   if (cD && fLoader->TreeD())
244     {
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     } 
250   if (cR && fLoader->TreeR())
251     {
252       if (fRecPoints == 0x0) fRecPoints  = new AliSTARTRecPoint();
253       MakeBranchInTree(fLoader->TreeR(), branchname,
254                        &fRecPoints, 405, 0);
255     } 
256   
257 }    
258
259 //_____________________________________________________________________________
260 void AliSTART::ResetHits()
261 {
262   AliDetector::ResetHits();
263   
264 }
265 //____________________________________________________________________
266 void AliSTART::ResetDigits()
267 {
268   //
269   // Reset number of digits and the digits array for this detector
270   //
271   if (fDigits) fDigits->Clear();
272 }
273
274 //_____________________________________________________________________________
275 void AliSTART::SetTreeAddress()
276 {
277
278   TTree    *treeH;
279   treeH = TreeH();
280   
281   if (treeH)
282     {
283       if (fHits == 0x0) fHits  = new TClonesArray("AliSTARThit",  405);
284     }
285     
286   AliDetector::SetTreeAddress();
287   TTree *treeD = fLoader->TreeD();
288   if (treeD) {
289     if (fDigits == 0x0)  fDigits  = new AliSTARTdigit();
290     TBranch* branch = treeD->GetBranch ("START");
291     if (branch) branch->SetAddress(&fDigits);
292   }
293
294   TTree *treeR = fLoader->TreeR();
295   if (treeR) {
296     if (fRecPoints == 0x0) fRecPoints  = new  AliSTARTRecPoint()  ;
297     TBranch* branch = treeR->GetBranch ("START");
298     if (branch) branch->SetAddress(&fRecPoints);
299   }
300  
301 }
302
303
304 //_____________________________________________________________________________
305 void AliSTART::MakeBranchInTreeD(TTree *treeD, const char *file)
306 {
307     //
308     // Create TreeD branches for the FMD
309     //
310     const Int_t kBufferSize = 4000;
311     char branchname[20];
312     sprintf(branchname,"%s",GetName());
313     if(treeD)
314      {
315        MakeBranchInTree(treeD,  branchname,&fDigits, kBufferSize, file);
316      }
317 }
318
319 //_____________________________________________________________________________
320 AliDigitizer* AliSTART::CreateDigitizer(AliRunDigitizer* manager) const
321 {
322   return new AliSTARTDigitizer(manager);
323 }
324 //____________________________________________________________________________
325 void AliSTART::Digits2Raw()
326 {
327 //
328 // Starting from the START digits, writes the Raw Data objects
329 //
330 //  AliSTARTLoader* pStartLoader = (AliSTARTLoader*)fLoader;
331   fLoader ->LoadDigits("read");
332   TTree* treeD = fLoader->TreeD();
333   if (!treeD) {
334     AliError("no digits tree");
335     return;
336   }
337   if (fDigits == 0x0)  fDigits  = new AliSTARTdigit();
338   
339   TBranch *branch = treeD->GetBranch("START");
340   if (branch) {
341     branch->SetAddress(&fDigits);
342   }else{
343     AliError("Branch START DIGIT not found");
344     exit(111);
345   } 
346   AliSTARTRawData rawWriter;
347   rawWriter.SetVerbose(0);
348   
349   AliDebug(2,Form(" Formatting raw data for START "));
350   branch->GetEntry(0);
351   //  rawWriter.RawDataSTART(treeD->GetBranch("START"));
352   rawWriter.RawDataSTART(fDigits);
353   
354   
355   fLoader->UnloadDigits();
356   
357 }