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