]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSvImpacts.cxx
Fixed compilation warnings with gcc-4.
[u/mrichter/AliRoot.git] / PHOS / AliPHOSvImpacts.cxx
CommitLineData
09906775 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
88cb7938 16
09906775 17/* $Id$ */
18
702ab87e 19/* History of cvs commits:
20 *
21 * $Log$
4951e003 22 * Revision 1.21 2005/05/28 14:19:05 schutz
23 * Compilation warnings fixed by T.P.
24 *
702ab87e 25 */
26
09906775 27//_________________________________________________________________________
28// Implementation version vImpacts of PHOS Manager class.
29// This class inherits from v1 and adds impacts storing.
30// Impacts stands for exact values of track coming to the detectors
31// EMC, CPV or PPSD.
32// Impacts are written to the same tree as hits are
33// but in separate branches.
34//---
35//*-- Author: Yuri Kharlov (IHEP, Protvino/SUBATECH, Nantes)
36
37
38// --- ROOT system ---
39
e957fea8 40//#include <TTree.h>
88cb7938 41#include <TVirtualMC.h>
09906775 42
43// --- Standard library ---
44
45// --- AliRoot header files ---
46
09906775 47#include "AliPHOSGeometry.h"
48#include "AliPHOSImpact.h"
88cb7938 49#include "AliPHOSvImpacts.h"
50#include "AliRun.h"
5d12ce38 51#include "AliMC.h"
4951e003 52#include "AliLog.h"
09906775 53
54ClassImp(AliPHOSvImpacts)
55
56//____________________________________________________________________________
9688c1dd 57AliPHOSvImpacts::AliPHOSvImpacts():AliPHOSv1()
09906775 58{
59 // ctor
fa0bc588 60 fEMCImpacts = 0 ;
61 fPPSDImpacts = 0 ;
62 fCPVImpacts = 0 ;
09906775 63}
64
65//____________________________________________________________________________
66AliPHOSvImpacts::AliPHOSvImpacts(const char *name, const char *title):
67AliPHOSv1(name,title)
68{
69 // ctor : title is used to identify the layout
09906775 70 //
71 // We store hits :
72 // - fHits (the "normal" one), which retains the hits associated with
73 // the current primary particle being tracked
74 // (this array is reset after each primary has been tracked).
75 // This part inherits from AliPHOSv1
76 //
77 // We store impacts :
9688c1dd 78 // - fEMCImpacts, fCPVImpacts which are
79 // TList of EMC and CPV modules respectively, each
09906775 80 // modules contains TClonesArray of AliPHOSImpacts
81
82 fEMCImpacts = new TList();
83 fCPVImpacts = new TList();
09906775 84
fa7cce36 85 Int_t nPHOSModules = GetGeometry()->GetNModules();
9688c1dd 86 Int_t nCPVModules = GetGeometry()->GetNModules();
09906775 87
88 Int_t iPHOSModule;
89 TClonesArray * impacts;
90 for (iPHOSModule=0; iPHOSModule<nPHOSModules; iPHOSModule++) {
91 fEMCImpacts->Add(new TClonesArray("AliPHOSImpact",200)) ;
92 fNEMCImpacts[iPHOSModule] = 0;
29b077b5 93 impacts = dynamic_cast<TClonesArray *>(fEMCImpacts->At(iPHOSModule));
09906775 94 }
95 for (iPHOSModule=0; iPHOSModule<nCPVModules; iPHOSModule++) {
96 fCPVImpacts->Add(new TClonesArray("AliPHOSImpact",200)) ;
97 fNCPVImpacts[iPHOSModule] = 0;
29b077b5 98 impacts = dynamic_cast<TClonesArray *>(fCPVImpacts->At(iPHOSModule));
09906775 99 }
09906775 100
101}
102
103//____________________________________________________________________________
104AliPHOSvImpacts::~AliPHOSvImpacts()
105{
106 // dtor
107
108 // Delete hits
109 if ( fHits ) {
110 fHits->Delete() ;
111 delete fHits ;
112 fHits = 0 ;
113 }
114
9688c1dd 115 // Delete impacts in EMC, CPV
09906775 116 if ( fEMCImpacts ) {
117 fEMCImpacts->Delete() ;
118 delete fEMCImpacts ;
119 fEMCImpacts = 0 ;
120 }
121 if ( fCPVImpacts ) {
122 fCPVImpacts->Delete() ;
123 delete fCPVImpacts ;
124 fCPVImpacts = 0 ;
125 }
09906775 126}
127
780fda6d 128//____________________________________________________________________________
702ab87e 129void AliPHOSvImpacts::Copy(TObject & phos) const
780fda6d 130{
131 TObject::Copy(phos) ;
132 AliPHOS::Copy(phos) ;
133}
134
135
09906775 136//____________________________________________________________________________
8e8eae84 137void AliPHOSvImpacts::AddImpact(const char* det, Int_t shunt, Int_t primary, Int_t track, Int_t module,
09906775 138 Int_t pid, TLorentzVector p, Float_t *xyz)
139{
140 // Add an impact to the impact list.
141
142 TClonesArray * impacts = 0;
143 Int_t nImpacts = 0;
144
145 if (strcmp(det,"EMC ")==0) {
29b077b5 146 impacts = dynamic_cast<TClonesArray *>(fEMCImpacts->At(module));
09906775 147 nImpacts= fNEMCImpacts[module];
148 fNEMCImpacts[module]++ ;
149 }
150 else if (strcmp(det,"CPV ")==0) {
29b077b5 151 impacts = dynamic_cast<TClonesArray *>(fCPVImpacts->At(module));
09906775 152 nImpacts= fNCPVImpacts[module];
153 fNCPVImpacts[module]++ ;
154 }
09906775 155
156 new((*impacts)[nImpacts]) AliPHOSImpact(shunt,primary,track,pid,p,xyz) ;
157
4951e003 158 AliDebugClass(1,Form("Module %d %s: ",module,det));
159 if (AliLog::GetGlobalDebugLevel()>0)
29b077b5 160 (dynamic_cast<AliPHOSImpact*>((impacts->At(nImpacts))))->Print();
09906775 161}
162
163//____________________________________________________________________________
88cb7938 164void AliPHOSvImpacts::MakeBranch(Option_t *opt)
09906775 165{
166 // Create new branch in the current Hits Root Tree containing
167 // a list of PHOS impacts (exact values of track coming to detector)
168
88cb7938 169 AliDetector::MakeBranch(opt);
09906775 170
171 Int_t bufferSize = 32000 ;
172 Int_t splitlevel = 0 ;
88cb7938 173 TreeH()->Branch("PHOSEmcImpacts" , "TList", &fEMCImpacts , bufferSize, splitlevel);
174 TreeH()->Branch("PHOSCpvImpacts" , "TList", &fCPVImpacts , bufferSize, splitlevel);
09906775 175
176}
177
178//____________________________________________________________________________
179void AliPHOSvImpacts::ResetHits()
180{
181 // Reset impact branches for EMC, CPV and PPSD
182
183 AliDetector::ResetHits();
184
185 Int_t i;
fa7cce36 186 for (i=0; i<GetGeometry()->GetNModules(); i++) {
29b077b5 187 (dynamic_cast<TClonesArray*>(fEMCImpacts->At(i))) -> Clear();
09906775 188 fNEMCImpacts[i] = 0 ;
189 }
190
9688c1dd 191 for (i=0; i<GetGeometry()->GetNModules(); i++) {
29b077b5 192 (dynamic_cast<TClonesArray*>(fCPVImpacts->At(i))) -> Clear();
9688c1dd 193 fNCPVImpacts[i] = 0 ;
09906775 194 }
195
196}
197
198//_____________________________________________________________________________
199void AliPHOSvImpacts::StepManager(void)
200{
9688c1dd 201 // Find impacts (tracks which enter the EMC, CPV)
09906775 202 // and add them to to the impact lists
203
204 AliPHOSv1::StepManager();
205
206 Float_t xyzm[3], xyzd[3], pm[3], pd[3];
207 TLorentzVector pmom ; // Lorentz momentum of the particle initiated hit
208 TLorentzVector pos ; // Lorentz vector of the track current position
209 Int_t copy ;
210
5d12ce38 211 Int_t tracknumber = gAlice->GetMCApp()->GetCurrentTrackNumber() ;
212 Int_t primary = gAlice->GetMCApp()->GetPrimary( gAlice->GetMCApp()->GetCurrentTrackNumber() );
fa7cce36 213 TString name = GetGeometry()->GetName() ;
09906775 214
215 // Add impact to EMC
216
d6fb41ac 217 static Int_t idPXTL = gMC->VolId("PXTL");
218 if( gMC->CurrentVolID(copy) == idPXTL &&
09906775 219 gMC->IsTrackEntering() ) {
220 gMC->TrackMomentum(pmom);
221 gMC->TrackPosition(pos) ;
222
223 Int_t i;
224 for (i=0; i<3; i++) xyzm[i] = pos[i];
225
fdeead01 226 for (i=0; i<3; i++) {
09906775 227 xyzm[i] = pos[i] ;
228 pm[i] = pmom[i];
229 }
230 gMC -> Gmtod (xyzm, xyzd, 1); // transform coordinate from master to daughter system
231 gMC -> Gmtod (pm, pd, 2); // transform 3-momentum from master to daughter system
232
233 // Select tracks coming to the crystal from up or down sides
c3a88feb 234 if (pd[1]<0 && xyzd[1] > GetGeometry()->GetCrystalSize(1)/2-0.1 ||
235 pd[1]>0 && xyzd[1] < -GetGeometry()->GetCrystalSize(1)/2+0.1) {
236 // Select tracks coming to the crystal from up or down sides
09906775 237 Int_t pid = gMC->TrackPid();
238 Int_t module;
239 gMC->CurrentVolOffID(10,module);
09906775 240 module--;
241 AddImpact("EMC ",fIshunt, primary,tracknumber, module, pid, pmom, xyzm);
242 }
243 }
244
245 // Add impact to CPV
246
d6fb41ac 247 static Int_t idPCPQ = gMC->VolId("PCPQ");
248 if( gMC->CurrentVolID(copy) == idPCPQ &&
09906775 249 gMC->IsTrackEntering() ) {
250 gMC->TrackMomentum(pmom);
251 gMC->TrackPosition(pos) ;
252
253 Int_t i;
254 for (i=0; i<3; i++) xyzm[i] = pos[i];
255
fdeead01 256 for (i=0; i<3; i++) {
09906775 257 xyzm[i] = pos[i] ;
258 pm[i] = pmom[i];
259 }
260 Int_t pid = gMC->TrackPid();
261 Int_t module;
262 gMC->CurrentVolOffID(3,module);
263 module--;
264 AddImpact("CPV ",fIshunt, primary,tracknumber, module, pid, pmom, xyzm);
265 }
9688c1dd 266
09906775 267}