]>
Commit | Line | Data |
---|---|---|
49a7aa5d | 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 | */ | |
19 | ||
20 | //////////////////////////////////////////////// | |
21 | // Manager and hits classes for set // | |
22 | // Charged Particle Veto (CPV) // | |
23 | // // | |
24 | // Author: Yuri Kharlov, IHEP, Protvino // | |
25 | // e-mail: Yuri.Kharlov@cern.ch // | |
26 | // Last modified: 28 September 2000 // | |
27 | //////////////////////////////////////////////// | |
28 | ||
29 | // --- ROOT system --- | |
30 | #include <TTree.h> | |
31 | ||
32 | // --- Standard library --- | |
33 | #include <stdio.h> | |
34 | #include <string.h> | |
35 | #include <stdlib.h> | |
36 | #include <iostream.h> | |
37 | ||
38 | // --- galice header files --- | |
39 | #include "AliPHOSCPV.h" | |
40 | #include "AliRun.h" | |
41 | ||
42 | //============================================================================== | |
43 | // CPVModule | |
44 | //============================================================================== | |
45 | ||
46 | ClassImp(CPVModule) | |
47 | ||
48 | //______________________________________________________________________________ | |
49 | ||
50 | CPVModule::CPVModule(void) { | |
51 | // | |
52 | // Allocate an array of hits | |
53 | // | |
54 | ||
55 | if ( NULL==(fHits=new TClonesArray("CPVHit",100)) ) { | |
56 | Error("CPV","Can not create array of hits"); | |
57 | exit(1); | |
58 | } | |
59 | } | |
60 | ||
61 | //______________________________________________________________________________ | |
62 | ||
63 | CPVModule::~CPVModule(void) | |
64 | { | |
65 | Clear(); | |
66 | } | |
67 | ||
68 | //______________________________________________________________________________ | |
69 | ||
70 | void CPVModule::Clear(Option_t *opt="") | |
71 | { | |
72 | // Clear hit information | |
73 | ||
74 | fHits -> Clear(opt); | |
75 | } | |
76 | ||
77 | //______________________________________________________________________________ | |
78 | ||
79 | void CPVModule::AddHit(TLorentzVector p, Float_t *xy, Int_t ipart) | |
80 | { | |
81 | // | |
82 | // Add this hit to the hit list in CPV detector. | |
83 | // | |
84 | ||
85 | TClonesArray &lhits = *(TClonesArray *)fHits; | |
86 | new(lhits[fHits->GetEntriesFast()]) CPVHit(p,xy,ipart); | |
87 | } | |
88 | ||
89 | //______________________________________________________________________________ | |
90 | ||
91 | void CPVModule::Print(Option_t *opt) | |
92 | { | |
93 | // | |
94 | // Print CPVModule information. | |
95 | // options: 'p' - print hits in the module | |
96 | // | |
97 | ||
98 | Int_t nhits,hit; | |
99 | if (strcmp(opt,"p")==0) { | |
100 | printf ("CPV module has %d hits\n",nhits=fHits->GetEntriesFast()); | |
101 | for (hit=0;hit<nhits;hit++) { | |
102 | CPVHit *cpvHit = (CPVHit*)fHits->UncheckedAt(hit); | |
103 | cpvHit->Print(); | |
104 | } | |
105 | } | |
106 | } | |
107 | ||
108 | //______________________________________________________________________________ | |
109 | ||
110 | void CPVModule::MakeBranch(Int_t i) | |
111 | { | |
112 | // | |
113 | // Create a new branch for a CPV module #i in the current Root Tree | |
114 | // | |
115 | ||
116 | char branchname[10]; | |
117 | sprintf(branchname,"CPV%d",i); | |
118 | gAlice->TreeH()->Branch(branchname,&fHits, 1000); | |
119 | } | |
120 | ||
121 | //_____________________________________________________________________________ | |
122 | void CPVModule::SetTreeAddress(Int_t i) | |
123 | { | |
124 | // | |
125 | // Set branch address for the Hits Tree for a CPV module #i | |
126 | // | |
127 | ||
128 | TBranch *branch; | |
129 | char branchname[20]; | |
130 | TTree *treeH = gAlice->TreeH(); | |
131 | if (treeH){ | |
132 | sprintf(branchname,"CPV%d",i); | |
133 | branch = treeH->GetBranch(branchname); | |
134 | if (branch) branch->SetAddress(&fHits); | |
135 | } | |
136 | } | |
137 | ||
138 | //============================================================================== | |
139 | // CPVHit | |
140 | //============================================================================== | |
141 | ||
142 | ClassImp(CPVHit) | |
143 | ||
144 | //______________________________________________________________________________ | |
145 | ||
146 | CPVHit::CPVHit(TLorentzVector p, Float_t *xy, Int_t ipart) | |
147 | { | |
148 | // | |
149 | // Create a CPV hit object | |
150 | // | |
151 | ||
152 | fMomentum = p; | |
153 | fXhit = xy[0]; | |
154 | fYhit = xy[1]; | |
155 | fIpart = ipart; | |
156 | } | |
157 | ||
158 | //______________________________________________________________________________ | |
159 | void CPVHit::Print() | |
160 | { | |
161 | // | |
162 | // Print CPV hit | |
163 | // | |
164 | ||
165 | printf("CPV hit: p = (% .4f, % .4f, % .4f, % .4f) GeV,\n", | |
166 | GetMomentum().Px(),GetMomentum().Py(),GetMomentum().Pz(),GetMomentum().E()); | |
167 | printf(" xy = (%8.4f, %8.4f) cm, ipart = %d\n", | |
168 | fXhit,fYhit,fIpart); | |
169 | } | |
170 | ||
171 | //============================================================================== | |
172 | // CPVDigit | |
173 | //============================================================================== | |
174 | ||
175 | ClassImp(CPVDigit) | |
176 | ||
177 | //______________________________________________________________________________ | |
178 | ||
179 | CPVDigit::CPVDigit(Int_t x, Int_t y, Float_t q) | |
180 | { | |
181 | // | |
182 | // Create a CPV digit object | |
183 | // | |
184 | ||
185 | fXpad = x; | |
186 | fYpad = y; | |
187 | fQpad = q; | |
188 | } | |
189 | ||
190 | //______________________________________________________________________________ |