]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSCPVModule.cxx
Major upgrade of AliRoot code
[u/mrichter/AliRoot.git] / PHOS / AliPHOSCPVModule.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 /*
17   $Log$
18   Revision 1.5  2000/11/30 11:58:21  schutz
19   make it compile with Federico  modifications
20
21   Revision 1.4  2000/11/20 09:50:03  schutz
22   AliPHOSCPVHit inherits from AliHit
23
24   Revision 1.3  2000/11/13 11:45:36  schutz
25   DEC and HP compilers sufisfied
26
27   Revision 1.2  2000/11/13 09:34:11  martinez
28   Copy constructor and operator = changed
29
30   Revision 1.1  2000/11/03 16:49:35  schutz
31   New class AliPHOSCPVModule
32
33 */
34
35 ////////////////////////////////////////////////
36 //  Manager class for one CPV module          //
37 //                                            //
38 //  Author: Yuri Kharlov, IHEP, Protvino      //
39 //  e-mail: Yuri.Kharlov@cern.ch              //
40 //  Last modified: 2 November 2000            //
41 ////////////////////////////////////////////////
42  
43 // --- ROOT system ---
44 #include <TTree.h>
45 #include <TFile.h>
46
47 // --- Standard library ---
48 #include <stdio.h>
49 #include <string.h>
50 #include <stdlib.h>
51 #include <iostream.h>
52
53 // --- galice header files ---
54 #include "AliRun.h"
55 #include "AliPHOSCPVModule.h"
56 #include "AliPHOSCPVHit.h"
57
58 //==============================================================================
59 //                              AliPHOSCPVModule
60 //==============================================================================
61
62 ClassImp(AliPHOSCPVModule)
63
64 //______________________________________________________________________________
65
66 AliPHOSCPVModule::AliPHOSCPVModule(void)
67 {
68   //
69   // Allocate an array of hits
70   //
71
72   if ( NULL==(fHits         =new TClonesArray("AliPHOSCPVHit",100)) ) {
73     Error("CPV","Can not create array of hits per track");
74     exit(1);
75   }
76 }
77
78 //______________________________________________________________________________
79 AliPHOSCPVModule::AliPHOSCPVModule(const AliPHOSCPVModule & module)
80 {
81   // Copy constructor
82   module.Copy(*this);
83 }
84
85 //____________________________________________________________________________
86 AliPHOSCPVModule & AliPHOSCPVModule::operator= (const AliPHOSCPVModule &module)
87 {
88   module.Copy(*this);
89   return (*this);
90 }
91
92 //______________________________________________________________________________
93 void AliPHOSCPVModule::Copy(AliPHOSCPVModule & module) const
94 {
95   // Copy *this onto module
96   // It takes care about copying array of hits fHits
97
98   // Copy all first
99   if(this != &module) {
100     ((TObject*) this)->Copy((TObject&)module);
101     module.fHits          = fHits;
102   }
103 }
104
105 //______________________________________________________________________________
106
107 AliPHOSCPVModule::~AliPHOSCPVModule(void)
108 {
109   Clear();
110 }
111
112 //______________________________________________________________________________
113
114 void AliPHOSCPVModule::Clear(Option_t *opt)
115 {
116 // Clear hit information
117
118   fHits          -> Clear(opt);
119 }
120
121 //______________________________________________________________________________
122
123 void AliPHOSCPVModule::AddHit(Int_t shunt, Int_t track, TLorentzVector p, Float_t *xy, Int_t ipart)
124 {
125   //
126   // Add this hit to the hit list in CPV detector.
127   //
128
129   TClonesArray &lhits = *(TClonesArray *)fHits;
130   new(lhits[fHits->GetEntriesFast()]) AliPHOSCPVHit(shunt,track,p,xy,ipart);
131 }
132
133 //______________________________________________________________________________
134
135 void AliPHOSCPVModule::Print(Option_t *opt)
136 {
137   //
138   // Print AliPHOSCPVModule information.
139   // options:  'p' - print hits in the module
140   //
141
142   Int_t nhits,hit;
143   if (strcmp(opt,"p")==0) {
144     printf ("CPV module has %d hits\n",nhits=fHits->GetEntriesFast());
145     for (hit=0;hit<nhits;hit++) {
146       AliPHOSCPVHit *cpvHit = (AliPHOSCPVHit*)fHits->UncheckedAt(hit);
147       cpvHit->Print();
148     }
149   }
150 }
151
152 //______________________________________________________________________________
153
154 void AliPHOSCPVModule::MakeBranch(char *title,Int_t i,char *file)
155 {
156   //
157   // Create a new branch for a EMC or CPV module #i in the current Root Tree
158   //
159
160   char branchname[10];
161   sprintf(branchname,"%s%d",title,i);
162   gAlice->MakeBranchInTree(gAlice->TreeH(), 
163                            branchname, &fHits, 1000, file) ;  
164 }
165
166 //_____________________________________________________________________________
167 void AliPHOSCPVModule::SetTreeAddress(char *title, Int_t i)
168 {
169   //
170   // Set branch address for the Hits Tree for a CPV or EMC module #i
171   //
172
173   TBranch *branch;
174   char branchname[20];
175   TTree *treeH = gAlice->TreeH();
176   if (treeH){
177     sprintf(branchname,"%s%d",title,i);
178     branch = treeH->GetBranch(branchname);
179     if (branch) branch->SetAddress(&fHits);
180   }
181 }