Line data Source code
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 :
66 20 : ClassImp(AliPHOSvImpacts)
67 :
68 : //____________________________________________________________________________
69 0 : AliPHOSvImpacts::AliPHOSvImpacts():
70 0 : fEMCImpacts(new TList),
71 0 : fCPVImpacts(new TList),
72 0 : fPPSDImpacts(new TList),
73 0 : fNEMCImpacts(),
74 0 : fNCPVImpacts(),
75 0 : fNPPSDImpacts()
76 0 : {
77 : // ctor
78 0 : }
79 :
80 : //____________________________________________________________________________
81 : AliPHOSvImpacts::AliPHOSvImpacts(const char *name, const char *title):
82 0 : AliPHOSv1(name,title),
83 0 : fEMCImpacts(new TList),
84 0 : fCPVImpacts(new TList),
85 0 : fPPSDImpacts(0),
86 0 : fNEMCImpacts(),
87 0 : fNCPVImpacts(),
88 0 : fNPPSDImpacts()
89 0 : {
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 0 : Int_t nPHOSModules = GetGeometry()->GetNModules();
104 0 : Int_t nCPVModules = GetGeometry()->GetNModules();
105 :
106 : Int_t iPHOSModule;
107 : TClonesArray * impacts;
108 0 : for (iPHOSModule=0; iPHOSModule<nPHOSModules; iPHOSModule++) {
109 0 : fEMCImpacts->Add(new TClonesArray("AliPHOSImpact",200)) ;
110 0 : fNEMCImpacts[iPHOSModule] = 0;
111 0 : impacts = dynamic_cast<TClonesArray *>(fEMCImpacts->At(iPHOSModule));
112 : }
113 0 : for (iPHOSModule=0; iPHOSModule<nCPVModules; iPHOSModule++) {
114 0 : fCPVImpacts->Add(new TClonesArray("AliPHOSImpact",200)) ;
115 0 : fNCPVImpacts[iPHOSModule] = 0;
116 0 : impacts = dynamic_cast<TClonesArray *>(fCPVImpacts->At(iPHOSModule));
117 : }
118 :
119 0 : }
120 :
121 : //____________________________________________________________________________
122 : AliPHOSvImpacts::~AliPHOSvImpacts()
123 0 : {
124 : // dtor
125 :
126 : // Delete hits
127 0 : if ( fHits ) {
128 0 : fHits->Delete() ;
129 0 : delete fHits ;
130 0 : fHits = 0 ;
131 0 : }
132 :
133 : // Delete impacts in EMC, CPV
134 0 : if ( fEMCImpacts ) {
135 0 : fEMCImpacts->Delete() ;
136 0 : delete fEMCImpacts ;
137 0 : fEMCImpacts = 0 ;
138 0 : }
139 0 : if ( fCPVImpacts ) {
140 0 : fCPVImpacts->Delete() ;
141 0 : delete fCPVImpacts ;
142 0 : fCPVImpacts = 0 ;
143 0 : }
144 0 : }
145 :
146 : //____________________________________________________________________________
147 : void 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 0 : if (strcmp(det,"EMC ")==0) {
156 0 : impacts = dynamic_cast<TClonesArray *>(fEMCImpacts->At(module));
157 0 : nImpacts= fNEMCImpacts[module];
158 0 : fNEMCImpacts[module]++ ;
159 0 : }
160 0 : else if (strcmp(det,"CPV ")==0) {
161 0 : impacts = dynamic_cast<TClonesArray *>(fCPVImpacts->At(module));
162 0 : nImpacts= fNCPVImpacts[module];
163 0 : fNCPVImpacts[module]++ ;
164 0 : }
165 : else
166 0 : AliFatal(Form("Wrong PHOS configuration: det=%s",det));
167 :
168 0 : new((*impacts)[nImpacts]) AliPHOSImpact(shunt,primary,track,pid,p,xyz) ;
169 :
170 0 : AliDebugClass(1,Form("Module %d %s: ",module,det));
171 0 : if (AliLog::GetGlobalDebugLevel()>0)
172 0 : (static_cast<AliPHOSImpact*>((impacts->At(nImpacts))))->Print();
173 0 : }
174 :
175 : //____________________________________________________________________________
176 : void 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 0 : AliDetector::MakeBranch(opt);
182 :
183 : Int_t bufferSize = 32000 ;
184 : Int_t splitlevel = 0 ;
185 0 : fLoader->TreeH()->Branch("PHOSEmcImpacts" , "TList", &fEMCImpacts , bufferSize, splitlevel);
186 0 : fLoader->TreeH()->Branch("PHOSCpvImpacts" , "TList", &fCPVImpacts , bufferSize, splitlevel);
187 :
188 0 : }
189 :
190 : //____________________________________________________________________________
191 : void AliPHOSvImpacts::ResetHits()
192 : {
193 : // Reset impact branches for EMC, CPV and PPSD
194 :
195 0 : AliDetector::ResetHits();
196 :
197 : Int_t i;
198 0 : for (i=0; i<GetGeometry()->GetNModules(); i++) {
199 0 : (static_cast<TClonesArray*>(fEMCImpacts->At(i))) -> Clear();
200 0 : fNEMCImpacts[i] = 0 ;
201 : }
202 :
203 0 : for (i=0; i<GetGeometry()->GetNModules(); i++) {
204 0 : (static_cast<TClonesArray*>(fCPVImpacts->At(i))) -> Clear();
205 0 : fNCPVImpacts[i] = 0 ;
206 : }
207 :
208 0 : }
209 :
210 : //_____________________________________________________________________________
211 : void AliPHOSvImpacts::StepManager(void)
212 : {
213 : // Find impacts (tracks which enter the EMC, CPV)
214 : // and add them to to the impact lists
215 :
216 0 : AliPHOSv1::StepManager();
217 :
218 0 : Float_t xyzm[3], xyzd[3], pm[3], pd[3];
219 0 : TLorentzVector pmom ; // Lorentz momentum of the particle initiated hit
220 0 : TLorentzVector pos ; // Lorentz vector of the track current position
221 0 : Int_t copy ;
222 :
223 0 : Int_t tracknumber = gAlice->GetMCApp()->GetCurrentTrackNumber() ;
224 0 : Int_t primary = gAlice->GetMCApp()->GetPrimary( gAlice->GetMCApp()->GetCurrentTrackNumber() );
225 0 : TString name = GetGeometry()->GetName() ;
226 :
227 : // Add impact to EMC
228 :
229 0 : static Int_t idPXTL = TVirtualMC::GetMC()->VolId("PXTL");
230 0 : if( TVirtualMC::GetMC()->CurrentVolID(copy) == idPXTL &&
231 0 : TVirtualMC::GetMC()->IsTrackEntering() ) {
232 0 : TVirtualMC::GetMC()->TrackMomentum(pmom);
233 0 : TVirtualMC::GetMC()->TrackPosition(pos) ;
234 :
235 : Int_t i;
236 0 : for (i=0; i<3; i++) xyzm[i] = pos[i];
237 :
238 0 : for (i=0; i<3; i++) {
239 0 : xyzm[i] = pos[i] ;
240 0 : pm[i] = pmom[i];
241 : }
242 0 : TVirtualMC::GetMC() -> Gmtod (xyzm, xyzd, 1); // transform coordinate from master to daughter system
243 0 : TVirtualMC::GetMC() -> 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 0 : if ((pd[1]<0 && xyzd[1] > GetGeometry()->GetCrystalSize(1)/2-0.1) ||
247 0 : (pd[1]>0 && xyzd[1] < -GetGeometry()->GetCrystalSize(1)/2+0.1)) {
248 : // Select tracks coming to the crystal from up or down sides
249 0 : Int_t pid = TVirtualMC::GetMC()->TrackPid();
250 0 : Int_t module;
251 0 : TVirtualMC::GetMC()->CurrentVolOffID(10,module);
252 0 : module--;
253 0 : AddImpact("EMC ",fIshunt, primary,tracknumber, module, pid, pmom, xyzm);
254 0 : }
255 0 : }
256 :
257 : // Add impact to CPV
258 :
259 0 : static Int_t idPCPQ = TVirtualMC::GetMC()->VolId("PCPQ");
260 0 : if( TVirtualMC::GetMC()->CurrentVolID(copy) == idPCPQ &&
261 0 : TVirtualMC::GetMC()->IsTrackEntering() ) {
262 0 : TVirtualMC::GetMC()->TrackMomentum(pmom);
263 0 : TVirtualMC::GetMC()->TrackPosition(pos) ;
264 :
265 : Int_t i;
266 0 : for (i=0; i<3; i++) xyzm[i] = pos[i];
267 :
268 0 : for (i=0; i<3; i++) {
269 0 : xyzm[i] = pos[i] ;
270 0 : pm[i] = pmom[i];
271 : }
272 0 : Int_t pid = TVirtualMC::GetMC()->TrackPid();
273 0 : Int_t module;
274 0 : TVirtualMC::GetMC()->CurrentVolOffID(3,module);
275 0 : module--;
276 0 : AddImpact("CPV ",fIshunt, primary,tracknumber, module, pid, pmom, xyzm);
277 0 : }
278 :
279 0 : }
|