1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 /* History of cvs commits:
22 * Revision 1.22 2005/06/17 07:39:07 hristov
23 * Removing GetDebug and SetDebug from AliRun and AliModule. Using AliLog for the messages
25 * Revision 1.21 2005/05/28 14:19:05 schutz
26 * Compilation warnings fixed by T.P.
30 //_________________________________________________________________________
31 // Implementation version vImpacts of PHOS Manager class.
32 // This class inherits from v1 and adds impacts storing.
33 // Impacts stands for exact values of track coming to the detectors
35 // Impacts are written to the same tree as hits are
36 // but in separate branches.
38 //*-- Author: Yuri Kharlov (IHEP, Protvino/SUBATECH, Nantes)
41 // --- ROOT system ---
44 #include <TVirtualMC.h>
46 // --- Standard library ---
48 // --- AliRoot header files ---
50 #include "AliPHOSGeometry.h"
51 #include "AliPHOSImpact.h"
52 #include "AliPHOSvImpacts.h"
57 ClassImp(AliPHOSvImpacts)
59 //____________________________________________________________________________
60 AliPHOSvImpacts::AliPHOSvImpacts():
68 //____________________________________________________________________________
69 AliPHOSvImpacts::AliPHOSvImpacts(const char *name, const char *title):
70 AliPHOSv1(name,title),
71 fEMCImpacts(new TList),
72 fCPVImpacts(new TList),
75 // ctor : title is used to identify the layout
78 // - fHits (the "normal" one), which retains the hits associated with
79 // the current primary particle being tracked
80 // (this array is reset after each primary has been tracked).
81 // This part inherits from AliPHOSv1
84 // - fEMCImpacts, fCPVImpacts which are
85 // TList of EMC and CPV modules respectively, each
86 // modules contains TClonesArray of AliPHOSImpacts
88 Int_t nPHOSModules = GetGeometry()->GetNModules();
89 Int_t nCPVModules = GetGeometry()->GetNModules();
92 TClonesArray * impacts;
93 for (iPHOSModule=0; iPHOSModule<nPHOSModules; iPHOSModule++) {
94 fEMCImpacts->Add(new TClonesArray("AliPHOSImpact",200)) ;
95 fNEMCImpacts[iPHOSModule] = 0;
96 impacts = dynamic_cast<TClonesArray *>(fEMCImpacts->At(iPHOSModule));
98 for (iPHOSModule=0; iPHOSModule<nCPVModules; iPHOSModule++) {
99 fCPVImpacts->Add(new TClonesArray("AliPHOSImpact",200)) ;
100 fNCPVImpacts[iPHOSModule] = 0;
101 impacts = dynamic_cast<TClonesArray *>(fCPVImpacts->At(iPHOSModule));
106 //____________________________________________________________________________
107 AliPHOSvImpacts::AliPHOSvImpacts(AliPHOSvImpacts & phos):
116 //____________________________________________________________________________
117 AliPHOSvImpacts::~AliPHOSvImpacts()
128 // Delete impacts in EMC, CPV
130 fEMCImpacts->Delete() ;
135 fCPVImpacts->Delete() ;
141 //____________________________________________________________________________
142 void AliPHOSvImpacts::Copy(TObject & phos) const
144 TObject::Copy(phos) ;
145 AliPHOS::Copy(phos) ;
149 //____________________________________________________________________________
150 void AliPHOSvImpacts::AddImpact(const char* det, Int_t shunt, Int_t primary, Int_t track, Int_t module,
151 Int_t pid, TLorentzVector p, Float_t *xyz)
153 // Add an impact to the impact list.
155 TClonesArray * impacts = 0;
158 if (strcmp(det,"EMC ")==0) {
159 impacts = dynamic_cast<TClonesArray *>(fEMCImpacts->At(module));
160 nImpacts= fNEMCImpacts[module];
161 fNEMCImpacts[module]++ ;
163 else if (strcmp(det,"CPV ")==0) {
164 impacts = dynamic_cast<TClonesArray *>(fCPVImpacts->At(module));
165 nImpacts= fNCPVImpacts[module];
166 fNCPVImpacts[module]++ ;
169 new((*impacts)[nImpacts]) AliPHOSImpact(shunt,primary,track,pid,p,xyz) ;
171 AliDebugClass(1,Form("Module %d %s: ",module,det));
172 if (AliLog::GetGlobalDebugLevel()>0)
173 (dynamic_cast<AliPHOSImpact*>((impacts->At(nImpacts))))->Print();
176 //____________________________________________________________________________
177 void AliPHOSvImpacts::MakeBranch(Option_t *opt)
179 // Create new branch in the current Hits Root Tree containing
180 // a list of PHOS impacts (exact values of track coming to detector)
182 AliDetector::MakeBranch(opt);
184 Int_t bufferSize = 32000 ;
185 Int_t splitlevel = 0 ;
186 TreeH()->Branch("PHOSEmcImpacts" , "TList", &fEMCImpacts , bufferSize, splitlevel);
187 TreeH()->Branch("PHOSCpvImpacts" , "TList", &fCPVImpacts , bufferSize, splitlevel);
191 //____________________________________________________________________________
192 void AliPHOSvImpacts::ResetHits()
194 // Reset impact branches for EMC, CPV and PPSD
196 AliDetector::ResetHits();
199 for (i=0; i<GetGeometry()->GetNModules(); i++) {
200 (dynamic_cast<TClonesArray*>(fEMCImpacts->At(i))) -> Clear();
201 fNEMCImpacts[i] = 0 ;
204 for (i=0; i<GetGeometry()->GetNModules(); i++) {
205 (dynamic_cast<TClonesArray*>(fCPVImpacts->At(i))) -> Clear();
206 fNCPVImpacts[i] = 0 ;
211 //_____________________________________________________________________________
212 void AliPHOSvImpacts::StepManager(void)
214 // Find impacts (tracks which enter the EMC, CPV)
215 // and add them to to the impact lists
217 AliPHOSv1::StepManager();
219 Float_t xyzm[3], xyzd[3], pm[3], pd[3];
220 TLorentzVector pmom ; // Lorentz momentum of the particle initiated hit
221 TLorentzVector pos ; // Lorentz vector of the track current position
224 Int_t tracknumber = gAlice->GetMCApp()->GetCurrentTrackNumber() ;
225 Int_t primary = gAlice->GetMCApp()->GetPrimary( gAlice->GetMCApp()->GetCurrentTrackNumber() );
226 TString name = GetGeometry()->GetName() ;
230 static Int_t idPXTL = gMC->VolId("PXTL");
231 if( gMC->CurrentVolID(copy) == idPXTL &&
232 gMC->IsTrackEntering() ) {
233 gMC->TrackMomentum(pmom);
234 gMC->TrackPosition(pos) ;
237 for (i=0; i<3; i++) xyzm[i] = pos[i];
239 for (i=0; i<3; i++) {
243 gMC -> Gmtod (xyzm, xyzd, 1); // transform coordinate from master to daughter system
244 gMC -> Gmtod (pm, pd, 2); // transform 3-momentum from master to daughter system
246 // Select tracks coming to the crystal from up or down sides
247 if (pd[1]<0 && xyzd[1] > GetGeometry()->GetCrystalSize(1)/2-0.1 ||
248 pd[1]>0 && xyzd[1] < -GetGeometry()->GetCrystalSize(1)/2+0.1) {
249 // Select tracks coming to the crystal from up or down sides
250 Int_t pid = gMC->TrackPid();
252 gMC->CurrentVolOffID(10,module);
254 AddImpact("EMC ",fIshunt, primary,tracknumber, module, pid, pmom, xyzm);
260 static Int_t idPCPQ = gMC->VolId("PCPQ");
261 if( gMC->CurrentVolID(copy) == idPCPQ &&
262 gMC->IsTrackEntering() ) {
263 gMC->TrackMomentum(pmom);
264 gMC->TrackPosition(pos) ;
267 for (i=0; i<3; i++) xyzm[i] = pos[i];
269 for (i=0; i<3; i++) {
273 Int_t pid = gMC->TrackPid();
275 gMC->CurrentVolOffID(3,module);
277 AddImpact("CPV ",fIshunt, primary,tracknumber, module, pid, pmom, xyzm);