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