]> git.uio.no Git - u/mrichter/AliRoot.git/blob - START/AliSTART.cxx
New versions of GDC and CDH raw data headers. Some CDH getters are added
[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, Int_t 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       //   fLoader->TreeD()->Print();
250     } 
251   if (cR && fLoader->TreeR())
252     {
253       if (fRecPoints == 0x0) fRecPoints  = new AliSTARTRecPoint();
254       MakeBranchInTree(fLoader->TreeR(), branchname,
255                        &fRecPoints, 405, 0);
256     } 
257   
258 }    
259
260 //_____________________________________________________________________________
261 void AliSTART::ResetHits()
262 {
263   AliDetector::ResetHits();
264   
265 }
266 //____________________________________________________________________
267 void AliSTART::ResetDigits()
268 {
269   //
270   // Reset number of digits and the digits array for this detector
271   //
272   if (fDigits) fDigits->Clear();
273 }
274
275 //_____________________________________________________________________________
276 void AliSTART::SetTreeAddress()
277 {
278
279   TTree    *treeH;
280   treeH = TreeH();
281   
282   if (treeH)
283     {
284       if (fHits == 0x0) fHits  = new TClonesArray("AliSTARThit",  405);
285     }
286     
287   AliDetector::SetTreeAddress();
288   TTree *treeD = fLoader->TreeD();
289   if (treeD) {
290     if (fDigits == 0x0)  fDigits  = new AliSTARTdigit();
291     TBranch* branch = treeD->GetBranch ("START");
292     if (branch) branch->SetAddress(&fDigits);
293   }
294
295   TTree *treeR = fLoader->TreeR();
296   if (treeR) {
297     if (fRecPoints == 0x0) fRecPoints  = new  AliSTARTRecPoint()  ;
298     TBranch* branch = treeR->GetBranch ("START");
299     if (branch) branch->SetAddress(&fRecPoints);
300   }
301  
302 }
303
304
305 //_____________________________________________________________________________
306 void AliSTART::MakeBranchInTreeD(TTree *treeD, const char *file)
307 {
308     //
309     // Create TreeD branches for the FMD
310     //
311     const Int_t kBufferSize = 4000;
312     char branchname[20];
313     sprintf(branchname,"%s",GetName());
314     if(treeD)
315      {
316        MakeBranchInTree(treeD,  branchname,&fDigits, kBufferSize, file);
317      }
318 }
319
320 //_____________________________________________________________________________
321 AliDigitizer* AliSTART::CreateDigitizer(AliRunDigitizer* manager) const
322 {
323   return new AliSTARTDigitizer(manager);
324 }
325 //____________________________________________________________________________
326 void AliSTART::Digits2Raw()
327 {
328 //
329 // Starting from the START digits, writes the Raw Data objects
330 //
331 //  AliSTARTLoader* pStartLoader = (AliSTARTLoader*)fLoader;
332   fLoader ->LoadDigits("read");
333   TTree* treeD = fLoader->TreeD();
334   if (!treeD) {
335     AliError("no digits tree");
336     return;
337   }
338   if (fDigits == 0x0)  fDigits  = new AliSTARTdigit();
339   
340   TBranch *branch = treeD->GetBranch("START");
341   if (branch) {
342     branch->SetAddress(&fDigits);
343   }else{
344     AliError("Branch START DIGIT not found");
345     exit(111);
346   } 
347   AliSTARTRawData rawWriter;
348   rawWriter.SetVerbose(0);
349   
350   AliDebug(2,Form(" Formatting raw data for START "));
351   branch->GetEntry(0);
352   //  rawWriter.RawDataSTART(treeD->GetBranch("START"));
353   rawWriter.RawDataSTART(fDigits);
354   
355   
356   fLoader->UnloadDigits();
357   
358 }