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.21 2005/05/28 14:19:05 schutz
23 * Compilation warnings fixed by T.P.
27 //_________________________________________________________________________
28 // Implementation version vImpacts of PHOS Manager class.
29 // This class inherits from v1 and adds impacts storing.
30 // Impacts stands for exact values of track coming to the detectors
32 // Impacts are written to the same tree as hits are
33 // but in separate branches.
35 //*-- Author: Yuri Kharlov (IHEP, Protvino/SUBATECH, Nantes)
38 // --- ROOT system ---
41 #include <TVirtualMC.h>
43 // --- Standard library ---
45 // --- AliRoot header files ---
47 #include "AliPHOSGeometry.h"
48 #include "AliPHOSImpact.h"
49 #include "AliPHOSvImpacts.h"
54 ClassImp(AliPHOSvImpacts)
56 //____________________________________________________________________________
57 AliPHOSvImpacts::AliPHOSvImpacts():AliPHOSv1()
65 //____________________________________________________________________________
66 AliPHOSvImpacts::AliPHOSvImpacts(const char *name, const char *title):
69 // ctor : title is used to identify the layout
72 // - fHits (the "normal" one), which retains the hits associated with
73 // the current primary particle being tracked
74 // (this array is reset after each primary has been tracked).
75 // This part inherits from AliPHOSv1
78 // - fEMCImpacts, fCPVImpacts which are
79 // TList of EMC and CPV modules respectively, each
80 // modules contains TClonesArray of AliPHOSImpacts
82 fEMCImpacts = new TList();
83 fCPVImpacts = new TList();
85 Int_t nPHOSModules = GetGeometry()->GetNModules();
86 Int_t nCPVModules = GetGeometry()->GetNModules();
89 TClonesArray * impacts;
90 for (iPHOSModule=0; iPHOSModule<nPHOSModules; iPHOSModule++) {
91 fEMCImpacts->Add(new TClonesArray("AliPHOSImpact",200)) ;
92 fNEMCImpacts[iPHOSModule] = 0;
93 impacts = dynamic_cast<TClonesArray *>(fEMCImpacts->At(iPHOSModule));
95 for (iPHOSModule=0; iPHOSModule<nCPVModules; iPHOSModule++) {
96 fCPVImpacts->Add(new TClonesArray("AliPHOSImpact",200)) ;
97 fNCPVImpacts[iPHOSModule] = 0;
98 impacts = dynamic_cast<TClonesArray *>(fCPVImpacts->At(iPHOSModule));
103 //____________________________________________________________________________
104 AliPHOSvImpacts::~AliPHOSvImpacts()
115 // Delete impacts in EMC, CPV
117 fEMCImpacts->Delete() ;
122 fCPVImpacts->Delete() ;
128 //____________________________________________________________________________
129 void AliPHOSvImpacts::Copy(TObject & phos) const
131 TObject::Copy(phos) ;
132 AliPHOS::Copy(phos) ;
136 //____________________________________________________________________________
137 void AliPHOSvImpacts::AddImpact(const char* det, Int_t shunt, Int_t primary, Int_t track, Int_t module,
138 Int_t pid, TLorentzVector p, Float_t *xyz)
140 // Add an impact to the impact list.
142 TClonesArray * impacts = 0;
145 if (strcmp(det,"EMC ")==0) {
146 impacts = dynamic_cast<TClonesArray *>(fEMCImpacts->At(module));
147 nImpacts= fNEMCImpacts[module];
148 fNEMCImpacts[module]++ ;
150 else if (strcmp(det,"CPV ")==0) {
151 impacts = dynamic_cast<TClonesArray *>(fCPVImpacts->At(module));
152 nImpacts= fNCPVImpacts[module];
153 fNCPVImpacts[module]++ ;
156 new((*impacts)[nImpacts]) AliPHOSImpact(shunt,primary,track,pid,p,xyz) ;
158 AliDebugClass(1,Form("Module %d %s: ",module,det));
159 if (AliLog::GetGlobalDebugLevel()>0)
160 (dynamic_cast<AliPHOSImpact*>((impacts->At(nImpacts))))->Print();
163 //____________________________________________________________________________
164 void AliPHOSvImpacts::MakeBranch(Option_t *opt)
166 // Create new branch in the current Hits Root Tree containing
167 // a list of PHOS impacts (exact values of track coming to detector)
169 AliDetector::MakeBranch(opt);
171 Int_t bufferSize = 32000 ;
172 Int_t splitlevel = 0 ;
173 TreeH()->Branch("PHOSEmcImpacts" , "TList", &fEMCImpacts , bufferSize, splitlevel);
174 TreeH()->Branch("PHOSCpvImpacts" , "TList", &fCPVImpacts , bufferSize, splitlevel);
178 //____________________________________________________________________________
179 void AliPHOSvImpacts::ResetHits()
181 // Reset impact branches for EMC, CPV and PPSD
183 AliDetector::ResetHits();
186 for (i=0; i<GetGeometry()->GetNModules(); i++) {
187 (dynamic_cast<TClonesArray*>(fEMCImpacts->At(i))) -> Clear();
188 fNEMCImpacts[i] = 0 ;
191 for (i=0; i<GetGeometry()->GetNModules(); i++) {
192 (dynamic_cast<TClonesArray*>(fCPVImpacts->At(i))) -> Clear();
193 fNCPVImpacts[i] = 0 ;
198 //_____________________________________________________________________________
199 void AliPHOSvImpacts::StepManager(void)
201 // Find impacts (tracks which enter the EMC, CPV)
202 // and add them to to the impact lists
204 AliPHOSv1::StepManager();
206 Float_t xyzm[3], xyzd[3], pm[3], pd[3];
207 TLorentzVector pmom ; // Lorentz momentum of the particle initiated hit
208 TLorentzVector pos ; // Lorentz vector of the track current position
211 Int_t tracknumber = gAlice->GetMCApp()->GetCurrentTrackNumber() ;
212 Int_t primary = gAlice->GetMCApp()->GetPrimary( gAlice->GetMCApp()->GetCurrentTrackNumber() );
213 TString name = GetGeometry()->GetName() ;
217 static Int_t idPXTL = gMC->VolId("PXTL");
218 if( gMC->CurrentVolID(copy) == idPXTL &&
219 gMC->IsTrackEntering() ) {
220 gMC->TrackMomentum(pmom);
221 gMC->TrackPosition(pos) ;
224 for (i=0; i<3; i++) xyzm[i] = pos[i];
226 for (i=0; i<3; i++) {
230 gMC -> Gmtod (xyzm, xyzd, 1); // transform coordinate from master to daughter system
231 gMC -> Gmtod (pm, pd, 2); // transform 3-momentum from master to daughter system
233 // Select tracks coming to the crystal from up or down sides
234 if (pd[1]<0 && xyzd[1] > GetGeometry()->GetCrystalSize(1)/2-0.1 ||
235 pd[1]>0 && xyzd[1] < -GetGeometry()->GetCrystalSize(1)/2+0.1) {
236 // Select tracks coming to the crystal from up or down sides
237 Int_t pid = gMC->TrackPid();
239 gMC->CurrentVolOffID(10,module);
241 AddImpact("EMC ",fIshunt, primary,tracknumber, module, pid, pmom, xyzm);
247 static Int_t idPCPQ = gMC->VolId("PCPQ");
248 if( gMC->CurrentVolID(copy) == idPCPQ &&
249 gMC->IsTrackEntering() ) {
250 gMC->TrackMomentum(pmom);
251 gMC->TrackPosition(pos) ;
254 for (i=0; i<3; i++) xyzm[i] = pos[i];
256 for (i=0; i<3; i++) {
260 Int_t pid = gMC->TrackPid();
262 gMC->CurrentVolOffID(3,module);
264 AddImpact("CPV ",fIshunt, primary,tracknumber, module, pid, pmom, xyzm);