]> git.uio.no Git - u/mrichter/AliRoot.git/blob - T0/AliT0.cxx
Use RGTopFrame::RedrawDisabler in GotoEvent(Int_t).
[u/mrichter/AliRoot.git] / T0 / AliT0.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 //  T0 (T-Zero) Detector                                            //
21 //  This class contains the base procedures for the T0     //
22 //  detector                                                                 //
23 //                                                                           //
24 //Begin_Html
25 /*
26 <img src="gif/AliT0Class.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 "AliT0.h"
58 #include "AliT0Loader.h"
59 #include "AliT0digit.h"
60 #include "AliT0hit.h"
61 #include "AliT0Digitizer.h"
62 #include "AliT0RawData.h"
63 #include "AliT0RecPoint.h"
64 #include "AliLog.h"
65
66 ClassImp(AliT0)
67
68   //static  AliT0digit *digits; 
69
70 //_____________________________________________________________________________
71 AliT0::AliT0()
72   : AliDetector(), fIdSens(0), fDigits(NULL), fRecPoints(NULL)
73 {
74   //
75   // Default constructor for class AliT0
76   //
77   fIshunt   = 1;
78   fHits     = 0;
79   fDigits   = 0;
80   fRecPoints = 0;
81 }
82  
83 //_____________________________________________________________________________
84 AliT0::AliT0(const char *name, const char *title)
85   : AliDetector(name,title), fIdSens(0), fDigits(new AliT0digit()), fRecPoints(new AliT0RecPoint())
86 {
87   //
88   // Standard constructor for T0 Detector
89   //
90
91   
92   //
93   // Initialise Hit array
94   fHits       = new TClonesArray("AliT0hit",  405);
95   gAlice->GetMCApp()->AddHitList(fHits);
96   //  fDigits    = new AliT0digit();
97   //  fRecPoints = new AliT0RecPoint();
98   fIshunt     =  1;
99   //  fIdSens   =  0;
100   //PH  SetMarkerColor(kRed);
101 }
102
103 //_____________________________________________________________________________
104 AliT0::~AliT0() {
105   
106   if (fHits) {
107     fHits->Delete();
108     delete fHits;
109   }
110   /*
111   if (fDigits) {
112     fDigits->Delete();
113     delete fDigits;
114     cout<<" delete fDigits; "<<endl;
115   }
116   if (fRecPoints) {
117    fRecPoints ->Delete();
118     delete fRecPoints;
119     cout<<" delete fRecPoints; "<<endl;
120   }
121   */ 
122 }
123
124 //_____________________________________________________________________________
125 void AliT0::AddHit(Int_t track, Int_t *vol, Float_t *hits)
126 {
127   //
128   // Add a T0 hit
129   //
130   TClonesArray &lhits = *fHits;
131   new(lhits[fNhits++]) AliT0hit(fIshunt,track,vol,hits);
132 }
133
134
135 //_____________________________________________________________________________
136
137 void AliT0::AddDigit(Int_t besttimeright, Int_t besttimeleft, Int_t meantime, 
138                         Int_t timediff, Int_t sumMult,
139                         TArrayI *time, TArrayI *adc, TArrayI *timeAmp, TArrayI *adcAmp)
140 {
141   
142   //  Add a T0 digit to the list.
143  //
144   
145   if (!fDigits) {
146     fDigits = new AliT0digit();
147   }
148   fDigits-> SetTimeBestRight(besttimeright);
149   fDigits->SetTimeBestLeft(besttimeleft);
150   fDigits-> SetMeanTime(meantime);
151   fDigits-> SetDiffTime(timediff);
152   fDigits-> SetSumMult(sumMult);
153   fDigits->SetTime(*time);
154   fDigits->SetTimeAmp(*timeAmp);
155   fDigits->SetADC(*adc);
156   fDigits->SetADCAmp(*adcAmp);
157 }
158
159
160 //_____________________________________________________________________________
161 void AliT0::BuildGeometry()
162 {
163   //
164   // Build simple ROOT TNode geometry for event display
165   //
166   TNode *node, *top;
167   const int kColorT0  = 19;
168
169   top=gAlice->GetGeometry()->GetNode("alice");
170
171   // T0 define the different volumes
172   new TRotMatrix("rotx999","rot999",  90,0,90,90,180,0);
173
174   new TTUBE("S_0ST1","T0  volume 1","void",5.,10.7,5.3);
175   top->cd();
176   node = new TNode("0ST1","0ST01","S_0ST1",0,0,-69.7,"");
177   node->SetLineColor(kColorT0);
178   fNodes->Add(node);
179
180   new TTUBE("S_0ST2","T0 volume 2","void",5.,10.7,5.3);
181   top->cd();
182   node = new TNode("0ST2","0ST2","S_0ST2",0,0,350,"rotx999");
183   node->SetLineColor(kColorT0);
184   fNodes->Add(node);
185 }
186  
187 //_____________________________________________________________________________
188 Int_t AliT0::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/)
189 {
190   //
191   // Calculate the distance from the mouse to the T0 on the screen
192   // Dummy routine
193   //
194   return 9999;
195 }
196  
197 //-------------------------------------------------------------------------
198 void AliT0::Init()
199 {
200   //
201   // Initialis the T0 after it has been built
202   Int_t i;
203   //
204   if(AliLog::GetGlobalDebugLevel()>0) {
205     printf("\n%s: ",ClassName());
206     for(i=0;i<35;i++) printf("*");
207     printf(" T0_INIT ");
208     for(i=0;i<35;i++) printf("*");
209     printf("\n%s: ",ClassName());
210     //
211     // Here the T0 initialisation code (if any!)
212     for(i=0;i<80;i++) printf("*");
213     printf("\n");
214   }
215 }
216
217 //---------------------------------------------------------------------------
218 void AliT0::MakeBranch(Option_t* option)
219 {
220   //
221 // Create Tree branches for the T0.
222
223  // Options:
224   //
225   //    H          Make a branch of TClonesArray of AliT0Hit's
226   //    D          Make a branch of TClonesArray of AliT0Digit's
227   //
228   //    R         Make a branch of  AliT0RecPoints
229   //
230   char branchname[20];
231   sprintf(branchname,"%s",GetName());
232
233   const char *cH = strstr(option,"H");
234   const char *cD = strstr(option,"D");
235   const char *cR = strstr(option,"R");
236
237     if (cH && fLoader->TreeH())
238   {
239      if (fHits == 0x0) fHits  = new TClonesArray("AliT0hit",  405);
240      AliDetector::MakeBranch(option);
241   } 
242     
243     
244   if (cD && fLoader->TreeD())
245     {
246       if (fDigits == 0x0) fDigits  = new AliT0digit();
247       //     MakeBranchInTree(fLoader->TreeD(), branchname,
248       //                       &fDigits, 405, 0);
249       fLoader->TreeD()->Branch(branchname,"AliT0digit",&fDigits,405,1);
250       //   fLoader->TreeD()->Print();
251     } 
252   if (cR && fLoader->TreeR())
253     {
254       if (fRecPoints == 0x0) fRecPoints  = new AliT0RecPoint();
255       MakeBranchInTree(fLoader->TreeR(), branchname,
256                        &fRecPoints, 405, 0);
257     } 
258   
259 }    
260
261 //_____________________________________________________________________________
262 void AliT0::ResetHits()
263 {
264   AliDetector::ResetHits();
265   
266 }
267 //____________________________________________________________________
268 void AliT0::ResetDigits()
269 {
270   //
271   // Reset number of digits and the digits array for this detector
272   //
273   if (fDigits) fDigits->Clear();
274 }
275
276 //_____________________________________________________________________________
277 void AliT0::SetTreeAddress()
278 {
279
280   TTree    *treeH;
281   treeH = TreeH();
282   
283   if (treeH)
284     {
285       if (fHits == 0x0) fHits  = new TClonesArray("AliT0hit",  405);
286     }
287     
288   AliDetector::SetTreeAddress();
289   TTree *treeD = fLoader->TreeD();
290   if (treeD) {
291     if (fDigits == 0x0)  fDigits  = new AliT0digit();
292     TBranch* branch = treeD->GetBranch ("T0");
293     if (branch) branch->SetAddress(&fDigits);
294   }
295
296   TTree *treeR = fLoader->TreeR();
297   if (treeR) {
298     if (fRecPoints == 0x0) fRecPoints  = new  AliT0RecPoint()  ;
299     TBranch* branch = treeR->GetBranch ("T0");
300     if (branch) branch->SetAddress(&fRecPoints);
301   }
302  
303 }
304
305
306 //_____________________________________________________________________________
307 void AliT0::MakeBranchInTreeD(TTree *treeD, const char *file)
308 {
309     //
310     // Create TreeD branches for the FMD
311     //
312     const Int_t kBufferSize = 4000;
313     char branchname[20];
314     sprintf(branchname,"%s",GetName());
315     if(treeD)
316      {
317        MakeBranchInTree(treeD,  branchname,&fDigits, kBufferSize, file);
318      }
319 }
320
321 //_____________________________________________________________________________
322 AliDigitizer* AliT0::CreateDigitizer(AliRunDigitizer* manager) const
323 {
324   return new AliT0Digitizer(manager);
325 }
326 //____________________________________________________________________________
327 void AliT0::Digits2Raw()
328 {
329 //
330 // Starting from the T0 digits, writes the Raw Data objects
331 //
332 //  AliT0Loader* pStartLoader = (AliT0Loader*)fLoader;
333   fLoader ->LoadDigits("read");
334   TTree* treeD = fLoader->TreeD();
335   if (!treeD) {
336     AliError("no digits tree");
337     return;
338   }
339   if (fDigits == 0x0)  fDigits  = new AliT0digit();
340   
341   TBranch *branch = treeD->GetBranch("T0");
342   if (branch) {
343     branch->SetAddress(&fDigits);
344   }else{
345     AliError("Branch T0 DIGIT not found");
346     exit(111);
347   } 
348   AliT0RawData rawWriter;
349   rawWriter.SetVerbose(0);
350   
351   AliDebug(2,Form(" Formatting raw data for T0 "));
352   branch->GetEntry(0);
353   //  rawWriter.RawDataT0(treeD->GetBranch("T0"));
354   rawWriter.RawDataT0(fDigits);
355   
356   
357   fLoader->UnloadDigits();
358   
359 }