]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSvImpacts.cxx
New base class AliPIDResponse
[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():
09828f52 68 fEMCImpacts(new TList),
69 fCPVImpacts(new TList),
bec9be73 70 fPPSDImpacts(new TList),
71 fNEMCImpacts(),
72 fNCPVImpacts(),
73 fNPPSDImpacts()
09906775 74{
75 // ctor
76}
77
78//____________________________________________________________________________
79AliPHOSvImpacts::AliPHOSvImpacts(const char *name, const char *title):
43fbaae1 80 AliPHOSv1(name,title),
81 fEMCImpacts(new TList),
82 fCPVImpacts(new TList),
bec9be73 83 fPPSDImpacts(0),
84 fNEMCImpacts(),
85 fNCPVImpacts(),
86 fNPPSDImpacts()
09906775 87{
88 // ctor : title is used to identify the layout
09906775 89 //
90 // We store hits :
91 // - fHits (the "normal" one), which retains the hits associated with
92 // the current primary particle being tracked
93 // (this array is reset after each primary has been tracked).
94 // This part inherits from AliPHOSv1
95 //
96 // We store impacts :
9688c1dd 97 // - fEMCImpacts, fCPVImpacts which are
98 // TList of EMC and CPV modules respectively, each
09906775 99 // modules contains TClonesArray of AliPHOSImpacts
09906775 100
fa7cce36 101 Int_t nPHOSModules = GetGeometry()->GetNModules();
9688c1dd 102 Int_t nCPVModules = GetGeometry()->GetNModules();
09906775 103
104 Int_t iPHOSModule;
105 TClonesArray * impacts;
106 for (iPHOSModule=0; iPHOSModule<nPHOSModules; iPHOSModule++) {
107 fEMCImpacts->Add(new TClonesArray("AliPHOSImpact",200)) ;
108 fNEMCImpacts[iPHOSModule] = 0;
29b077b5 109 impacts = dynamic_cast<TClonesArray *>(fEMCImpacts->At(iPHOSModule));
09906775 110 }
111 for (iPHOSModule=0; iPHOSModule<nCPVModules; iPHOSModule++) {
112 fCPVImpacts->Add(new TClonesArray("AliPHOSImpact",200)) ;
113 fNCPVImpacts[iPHOSModule] = 0;
29b077b5 114 impacts = dynamic_cast<TClonesArray *>(fCPVImpacts->At(iPHOSModule));
09906775 115 }
09906775 116
117}
118
119//____________________________________________________________________________
120AliPHOSvImpacts::~AliPHOSvImpacts()
121{
122 // dtor
123
124 // Delete hits
125 if ( fHits ) {
126 fHits->Delete() ;
127 delete fHits ;
128 fHits = 0 ;
129 }
130
9688c1dd 131 // Delete impacts in EMC, CPV
09906775 132 if ( fEMCImpacts ) {
133 fEMCImpacts->Delete() ;
134 delete fEMCImpacts ;
135 fEMCImpacts = 0 ;
136 }
137 if ( fCPVImpacts ) {
138 fCPVImpacts->Delete() ;
139 delete fCPVImpacts ;
140 fCPVImpacts = 0 ;
141 }
09906775 142}
143
144//____________________________________________________________________________
8e8eae84 145void AliPHOSvImpacts::AddImpact(const char* det, Int_t shunt, Int_t primary, Int_t track, Int_t module,
09906775 146 Int_t pid, TLorentzVector p, Float_t *xyz)
147{
148 // Add an impact to the impact list.
149
150 TClonesArray * impacts = 0;
151 Int_t nImpacts = 0;
152
153 if (strcmp(det,"EMC ")==0) {
29b077b5 154 impacts = dynamic_cast<TClonesArray *>(fEMCImpacts->At(module));
09906775 155 nImpacts= fNEMCImpacts[module];
156 fNEMCImpacts[module]++ ;
157 }
158 else if (strcmp(det,"CPV ")==0) {
29b077b5 159 impacts = dynamic_cast<TClonesArray *>(fCPVImpacts->At(module));
09906775 160 nImpacts= fNCPVImpacts[module];
161 fNCPVImpacts[module]++ ;
162 }
c28bf7f5 163 else
164 AliFatal(Form("Wrong PHOS configuration: det=%s",det));
09906775 165
166 new((*impacts)[nImpacts]) AliPHOSImpact(shunt,primary,track,pid,p,xyz) ;
167
4951e003 168 AliDebugClass(1,Form("Module %d %s: ",module,det));
169 if (AliLog::GetGlobalDebugLevel()>0)
c28bf7f5 170 (static_cast<AliPHOSImpact*>((impacts->At(nImpacts))))->Print();
09906775 171}
172
173//____________________________________________________________________________
88cb7938 174void AliPHOSvImpacts::MakeBranch(Option_t *opt)
09906775 175{
176 // Create new branch in the current Hits Root Tree containing
177 // a list of PHOS impacts (exact values of track coming to detector)
178
88cb7938 179 AliDetector::MakeBranch(opt);
09906775 180
181 Int_t bufferSize = 32000 ;
182 Int_t splitlevel = 0 ;
6b3a4c8e 183 fLoader->TreeH()->Branch("PHOSEmcImpacts" , "TList", &fEMCImpacts , bufferSize, splitlevel);
184 fLoader->TreeH()->Branch("PHOSCpvImpacts" , "TList", &fCPVImpacts , bufferSize, splitlevel);
09906775 185
186}
187
188//____________________________________________________________________________
189void AliPHOSvImpacts::ResetHits()
190{
191 // Reset impact branches for EMC, CPV and PPSD
192
193 AliDetector::ResetHits();
194
195 Int_t i;
fa7cce36 196 for (i=0; i<GetGeometry()->GetNModules(); i++) {
09828f52 197 (static_cast<TClonesArray*>(fEMCImpacts->At(i))) -> Clear();
09906775 198 fNEMCImpacts[i] = 0 ;
199 }
200
9688c1dd 201 for (i=0; i<GetGeometry()->GetNModules(); i++) {
09828f52 202 (static_cast<TClonesArray*>(fCPVImpacts->At(i))) -> Clear();
9688c1dd 203 fNCPVImpacts[i] = 0 ;
09906775 204 }
205
206}
207
208//_____________________________________________________________________________
209void AliPHOSvImpacts::StepManager(void)
210{
9688c1dd 211 // Find impacts (tracks which enter the EMC, CPV)
09906775 212 // and add them to to the impact lists
213
214 AliPHOSv1::StepManager();
215
216 Float_t xyzm[3], xyzd[3], pm[3], pd[3];
217 TLorentzVector pmom ; // Lorentz momentum of the particle initiated hit
218 TLorentzVector pos ; // Lorentz vector of the track current position
219 Int_t copy ;
220
5d12ce38 221 Int_t tracknumber = gAlice->GetMCApp()->GetCurrentTrackNumber() ;
222 Int_t primary = gAlice->GetMCApp()->GetPrimary( gAlice->GetMCApp()->GetCurrentTrackNumber() );
fa7cce36 223 TString name = GetGeometry()->GetName() ;
09906775 224
225 // Add impact to EMC
226
d6fb41ac 227 static Int_t idPXTL = gMC->VolId("PXTL");
228 if( gMC->CurrentVolID(copy) == idPXTL &&
09906775 229 gMC->IsTrackEntering() ) {
230 gMC->TrackMomentum(pmom);
231 gMC->TrackPosition(pos) ;
232
233 Int_t i;
234 for (i=0; i<3; i++) xyzm[i] = pos[i];
235
fdeead01 236 for (i=0; i<3; i++) {
09906775 237 xyzm[i] = pos[i] ;
238 pm[i] = pmom[i];
239 }
240 gMC -> Gmtod (xyzm, xyzd, 1); // transform coordinate from master to daughter system
241 gMC -> Gmtod (pm, pd, 2); // transform 3-momentum from master to daughter system
242
243 // Select tracks coming to the crystal from up or down sides
f12d42ce 244 if ((pd[1]<0 && xyzd[1] > GetGeometry()->GetCrystalSize(1)/2-0.1) ||
245 (pd[1]>0 && xyzd[1] < -GetGeometry()->GetCrystalSize(1)/2+0.1)) {
c3a88feb 246 // Select tracks coming to the crystal from up or down sides
09906775 247 Int_t pid = gMC->TrackPid();
248 Int_t module;
249 gMC->CurrentVolOffID(10,module);
09906775 250 module--;
251 AddImpact("EMC ",fIshunt, primary,tracknumber, module, pid, pmom, xyzm);
252 }
253 }
254
255 // Add impact to CPV
256
d6fb41ac 257 static Int_t idPCPQ = gMC->VolId("PCPQ");
258 if( gMC->CurrentVolID(copy) == idPCPQ &&
09906775 259 gMC->IsTrackEntering() ) {
260 gMC->TrackMomentum(pmom);
261 gMC->TrackPosition(pos) ;
262
263 Int_t i;
264 for (i=0; i<3; i++) xyzm[i] = pos[i];
265
fdeead01 266 for (i=0; i<3; i++) {
09906775 267 xyzm[i] = pos[i] ;
268 pm[i] = pmom[i];
269 }
270 Int_t pid = gMC->TrackPid();
271 Int_t module;
272 gMC->CurrentVolOffID(3,module);
273 module--;
274 AddImpact("CPV ",fIshunt, primary,tracknumber, module, pid, pmom, xyzm);
275 }
9688c1dd 276
09906775 277}