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.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
25 * Revision 1.23 2006/09/13 07:31:01 kharlov
26 * Effective C++ corrections (T.Pocheptsov)
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
31 * Revision 1.21 2005/05/28 14:19:05 schutz
32 * Compilation warnings fixed by T.P.
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
41 // Impacts are written to the same tree as hits are
42 // but in separate branches.
44 //*-- Author: Yuri Kharlov (IHEP, Protvino/SUBATECH, Nantes)
47 // --- ROOT system ---
50 #include <TClonesArray.h>
51 #include <TVirtualMC.h>
54 // --- Standard library ---
56 // --- AliRoot header files ---
58 #include "AliPHOSGeometry.h"
59 #include "AliPHOSImpact.h"
60 #include "AliPHOSvImpacts.h"
62 #include "AliLoader.h"
66 ClassImp(AliPHOSvImpacts)
68 //____________________________________________________________________________
69 AliPHOSvImpacts::AliPHOSvImpacts():
70 fEMCImpacts(new TList),
71 fCPVImpacts(new TList),
72 fPPSDImpacts(new TList),
80 //____________________________________________________________________________
81 AliPHOSvImpacts::AliPHOSvImpacts(const char *name, const char *title):
82 AliPHOSv1(name,title),
83 fEMCImpacts(new TList),
84 fCPVImpacts(new TList),
90 // ctor : title is used to identify the layout
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
99 // - fEMCImpacts, fCPVImpacts which are
100 // TList of EMC and CPV modules respectively, each
101 // modules contains TClonesArray of AliPHOSImpacts
103 Int_t nPHOSModules = GetGeometry()->GetNModules();
104 Int_t nCPVModules = GetGeometry()->GetNModules();
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));
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));
121 //____________________________________________________________________________
122 AliPHOSvImpacts::~AliPHOSvImpacts()
133 // Delete impacts in EMC, CPV
135 fEMCImpacts->Delete() ;
140 fCPVImpacts->Delete() ;
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)
150 // Add an impact to the impact list.
152 TClonesArray * impacts = 0;
155 if (strcmp(det,"EMC ")==0) {
156 impacts = dynamic_cast<TClonesArray *>(fEMCImpacts->At(module));
157 nImpacts= fNEMCImpacts[module];
158 fNEMCImpacts[module]++ ;
160 else if (strcmp(det,"CPV ")==0) {
161 impacts = dynamic_cast<TClonesArray *>(fCPVImpacts->At(module));
162 nImpacts= fNCPVImpacts[module];
163 fNCPVImpacts[module]++ ;
166 AliFatal(Form("Wrong PHOS configuration: det=%s",det));
168 new((*impacts)[nImpacts]) AliPHOSImpact(shunt,primary,track,pid,p,xyz) ;
170 AliDebugClass(1,Form("Module %d %s: ",module,det));
171 if (AliLog::GetGlobalDebugLevel()>0)
172 (static_cast<AliPHOSImpact*>((impacts->At(nImpacts))))->Print();
175 //____________________________________________________________________________
176 void AliPHOSvImpacts::MakeBranch(Option_t *opt)
178 // Create new branch in the current Hits Root Tree containing
179 // a list of PHOS impacts (exact values of track coming to detector)
181 AliDetector::MakeBranch(opt);
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);
190 //____________________________________________________________________________
191 void AliPHOSvImpacts::ResetHits()
193 // Reset impact branches for EMC, CPV and PPSD
195 AliDetector::ResetHits();
198 for (i=0; i<GetGeometry()->GetNModules(); i++) {
199 (static_cast<TClonesArray*>(fEMCImpacts->At(i))) -> Clear();
200 fNEMCImpacts[i] = 0 ;
203 for (i=0; i<GetGeometry()->GetNModules(); i++) {
204 (static_cast<TClonesArray*>(fCPVImpacts->At(i))) -> Clear();
205 fNCPVImpacts[i] = 0 ;
210 //_____________________________________________________________________________
211 void AliPHOSvImpacts::StepManager(void)
213 // Find impacts (tracks which enter the EMC, CPV)
214 // and add them to to the impact lists
216 AliPHOSv1::StepManager();
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
223 Int_t tracknumber = gAlice->GetMCApp()->GetCurrentTrackNumber() ;
224 Int_t primary = gAlice->GetMCApp()->GetPrimary( gAlice->GetMCApp()->GetCurrentTrackNumber() );
225 TString name = GetGeometry()->GetName() ;
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) ;
236 for (i=0; i<3; i++) xyzm[i] = pos[i];
238 for (i=0; i<3; i++) {
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
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();
251 gMC->CurrentVolOffID(10,module);
253 AddImpact("EMC ",fIshunt, primary,tracknumber, module, pid, pmom, xyzm);
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) ;
266 for (i=0; i<3; i++) xyzm[i] = pos[i];
268 for (i=0; i<3; i++) {
272 Int_t pid = gMC->TrackPid();
274 gMC->CurrentVolOffID(3,module);
276 AddImpact("CPV ",fIshunt, primary,tracknumber, module, pid, pmom, xyzm);