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