]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCD.cxx
Added the entry for the IRST code checking utility
[u/mrichter/AliRoot.git] / TPC / AliTPCD.cxx
1 //-----------------------------------------------------------------------------
2 // 
3 //  Origin: Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk
4 //
5 //  Implementation of class AliTPCD
6 //
7 //-----------------------------------------------------------------------------
8
9 #include <TMath.h>
10 #include "AliTPCParam.h"
11 #include "AliTPCRF1D.h"
12 #include "AliTPCPRF2D.h"
13 #include "AliTPCD.h"
14 #include "TClonesArray.h"
15 #include "TClass.h"
16 #include "TBranchClones.h"
17 #include "TTree.h"   
18 #include "TDirectory.h"
19
20
21
22 // other include files follow here
23
24
25 ClassImp(AliTPCD)
26   //_____________________________________________________________ 
27 AliTPCD::AliTPCD(Text_t *  name,
28                  AliTPCParam * param, AliTPCPRF2D* prf, AliTPCRF1D* prfz) 
29 {
30   //construct new object's or accept objects sent to constructor
31   //AliTPCD handle sent object and is repsonsible for
32   //deleting it
33
34 //Begin_Html
35 /*
36 <img src="picts/alitpcd.gif">
37 */
38 //End_Html
39   SetName(name);
40   if ((param!=0) && 
41       ( (param->IsA()->InheritsFrom("AliTPCParam")==kTRUE ) ))
42     fParam=param; 
43   else
44     fParam= new AliTPCParam;
45   if ( (prf!=0) && (prf->IsA()->InheritsFrom("AliTPCPRF2D")==kTRUE) )
46     fPRF=prf;
47   else
48     fPRF =  new AliTPCPRF2D;
49   if ( (prfz!=0) && (prfz->IsA()->InheritsFrom("AliTPCRF1D")==kTRUE) )
50     fRF=prfz;
51   else
52     fRF =  new AliTPCRF1D(kTRUE);  
53   fDigits = new TClonesArray("AliTPCdigit",5000);
54   fpthis=this;
55 }
56
57 AliTPCD::~AliTPCD() 
58 {
59   if (fParam!=0) fParam->Delete();
60   if (fPRF!=0) fPRF->Delete();
61   if (fRF!=0) fRF->Delete();
62   if (fDigits!=0) fDigits->Delete();
63 }
64
65
66 Bool_t  AliTPCD::SetTree(Int_t nevent, TDirectory *dir )
67 {
68   char treeName[100];
69   // Get Hits Tree header from file
70   sprintf(treeName,"TreeD%d_%s",nevent,GetName());
71   fTreeD = (TTree*)dir->Get(treeName);
72   if (fTreeD == 0) return kFALSE;
73   //set Digit branch 
74   TBranch *b = fTreeD->GetBranch("Digits");
75   if (b==0) return kFALSE;
76   b->SetAddress(&fDigits);
77   return kTRUE;
78 }
79
80
81 Bool_t  AliTPCD::MakeTree(Int_t nevent)
82 {
83   char treeName[100];
84   // Get Hits Tree header from file
85   sprintf(treeName,"TreeD%d_%s",nevent,GetName());
86   fTreeD =  new TTree(treeName,treeName);
87   if (fTreeD == 0) return kFALSE;
88   //set Digit branch 
89   TBranch *b = fTreeD->Branch("Digits",&fDigits,40000);
90   if (b==0) return kFALSE;
91   b->SetAddress(&fDigits);
92  
93   return kTRUE;
94 }
95   
96 void AliTPCD::Fill()
97
98   if (fTreeD!=0) fTreeD->Fill();    
99 }
100
101
102
103
104
105 void AliTPCD::Streamer(TBuffer &R__b)
106 {
107  // Stream an object of class AliTPCD. 
108   if (R__b.IsReading()) {    
109     Version_t R__v = R__b.ReadVersion(); if (R__v) { }
110     TNamed::Streamer(R__b);  
111     if (fParam!=0) {
112       fParam->Delete();
113       fParam = new AliTPCParam;
114     }
115     if (fPRF!=0) {
116       fPRF->Delete();
117       fPRF = new AliTPCPRF2D;
118     }
119     if (fRF!=0) {
120       fRF->Delete();
121       fRF = new AliTPCRF1D;
122     }
123     if (fTreeD!=0) {
124       fRF->Delete();
125       fRF = new AliTPCRF1D;
126     }
127     R__b >>fParam;
128     R__b >>fPRF;
129     R__b >>fRF;    
130     SetTree();        
131   } else {
132     R__b.WriteVersion(AliTPCD::IsA());
133     TNamed::Streamer(R__b);     
134     R__b <<fParam;
135     R__b <<fPRF;
136     R__b <<fRF;     
137     if (fTreeD!=0) fTreeD->Write();         
138   } 
139 }