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 **************************************************************************/
18 //_________________________________________________________________________
19 // Implementation version vImpacts of PHOS Manager class.
20 // This class inherits from v1 and adds impacts storing.
21 // Impacts stands for exact values of track coming to the detectors
23 // Impacts are written to the same tree as hits are
24 // but in separate branches.
26 //*-- Author: Yuri Kharlov (IHEP, Protvino/SUBATECH, Nantes)
29 // --- ROOT system ---
33 // --- Standard library ---
35 // --- AliRoot header files ---
39 #include "AliPHOSvImpacts.h"
40 #include "AliPHOSGeometry.h"
41 #include "AliPHOSImpact.h"
43 ClassImp(AliPHOSvImpacts)
45 //____________________________________________________________________________
46 AliPHOSvImpacts::AliPHOSvImpacts():AliPHOSv1()
54 //____________________________________________________________________________
55 AliPHOSvImpacts::AliPHOSvImpacts(const char *name, const char *title):
58 // ctor : title is used to identify the layout
61 // - fHits (the "normal" one), which retains the hits associated with
62 // the current primary particle being tracked
63 // (this array is reset after each primary has been tracked).
64 // This part inherits from AliPHOSv1
67 // - fEMCImpacts, fCPVImpacts which are
68 // TList of EMC and CPV modules respectively, each
69 // modules contains TClonesArray of AliPHOSImpacts
71 fEMCImpacts = new TList();
72 fCPVImpacts = new TList();
74 Int_t nPHOSModules = GetGeometry()->GetNModules();
75 Int_t nCPVModules = GetGeometry()->GetNModules();
78 TClonesArray * impacts;
79 for (iPHOSModule=0; iPHOSModule<nPHOSModules; iPHOSModule++) {
80 fEMCImpacts->Add(new TClonesArray("AliPHOSImpact",200)) ;
81 fNEMCImpacts[iPHOSModule] = 0;
82 impacts = dynamic_cast<TClonesArray *>(fEMCImpacts->At(iPHOSModule));
84 for (iPHOSModule=0; iPHOSModule<nCPVModules; iPHOSModule++) {
85 fCPVImpacts->Add(new TClonesArray("AliPHOSImpact",200)) ;
86 fNCPVImpacts[iPHOSModule] = 0;
87 impacts = dynamic_cast<TClonesArray *>(fCPVImpacts->At(iPHOSModule));
92 //____________________________________________________________________________
93 AliPHOSvImpacts::~AliPHOSvImpacts()
104 // Delete impacts in EMC, CPV
106 fEMCImpacts->Delete() ;
111 fCPVImpacts->Delete() ;
117 //____________________________________________________________________________
118 void AliPHOSvImpacts::AddImpact( char* det, Int_t shunt, Int_t primary, Int_t track, Int_t module,
119 Int_t pid, TLorentzVector p, Float_t *xyz)
121 // Add an impact to the impact list.
123 TClonesArray * impacts = 0;
126 if (strcmp(det,"EMC ")==0) {
127 impacts = dynamic_cast<TClonesArray *>(fEMCImpacts->At(module));
128 nImpacts= fNEMCImpacts[module];
129 fNEMCImpacts[module]++ ;
131 else if (strcmp(det,"CPV ")==0) {
132 impacts = dynamic_cast<TClonesArray *>(fCPVImpacts->At(module));
133 nImpacts= fNCPVImpacts[module];
134 fNCPVImpacts[module]++ ;
137 new((*impacts)[nImpacts]) AliPHOSImpact(shunt,primary,track,pid,p,xyz) ;
140 printf("Module %d %s: ",module,det);
141 (dynamic_cast<AliPHOSImpact*>((impacts->At(nImpacts))))->Print();
145 //____________________________________________________________________________
146 void AliPHOSvImpacts::MakeBranch(Option_t *opt, const char *file)
148 // Create new branch in the current Hits Root Tree containing
149 // a list of PHOS impacts (exact values of track coming to detector)
151 AliDetector::MakeBranch(opt,file);
153 Int_t bufferSize = 32000 ;
154 Int_t splitlevel = 0 ;
155 gAlice->TreeH()->Branch("PHOSEmcImpacts" , "TList", &fEMCImpacts , bufferSize, splitlevel);
156 gAlice->TreeH()->Branch("PHOSCpvImpacts" , "TList", &fCPVImpacts , bufferSize, splitlevel);
160 //____________________________________________________________________________
161 void AliPHOSvImpacts::ResetHits()
163 // Reset impact branches for EMC, CPV and PPSD
165 AliDetector::ResetHits();
168 for (i=0; i<GetGeometry()->GetNModules(); i++) {
169 (dynamic_cast<TClonesArray*>(fEMCImpacts->At(i))) -> Clear();
170 fNEMCImpacts[i] = 0 ;
173 for (i=0; i<GetGeometry()->GetNModules(); i++) {
174 (dynamic_cast<TClonesArray*>(fCPVImpacts->At(i))) -> Clear();
175 fNCPVImpacts[i] = 0 ;
180 //_____________________________________________________________________________
181 void AliPHOSvImpacts::StepManager(void)
183 // Find impacts (tracks which enter the EMC, CPV)
184 // and add them to to the impact lists
186 AliPHOSv1::StepManager();
188 Float_t xyzm[3], xyzd[3], pm[3], pd[3];
189 TLorentzVector pmom ; // Lorentz momentum of the particle initiated hit
190 TLorentzVector pos ; // Lorentz vector of the track current position
193 Int_t tracknumber = gAlice->CurrentTrack() ;
194 Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() );
195 TString name = GetGeometry()->GetName() ;
199 if( gMC->CurrentVolID(copy) == gMC->VolId("PXTL") &&
200 gMC->IsTrackEntering() ) {
201 gMC->TrackMomentum(pmom);
202 gMC->TrackPosition(pos) ;
205 for (i=0; i<3; i++) xyzm[i] = pos[i];
207 for (i=0; i<3; i++) {
211 gMC -> Gmtod (xyzm, xyzd, 1); // transform coordinate from master to daughter system
212 gMC -> Gmtod (pm, pd, 2); // transform 3-momentum from master to daughter system
214 // Select tracks coming to the crystal from up or down sides
215 if (pd[1]<0 && xyzd[1] > GetGeometry()->GetCrystalSize(1)/2-0.1 ||
216 pd[1]>0 && xyzd[1] < -GetGeometry()->GetCrystalSize(1)/2+0.1) {
217 // Select tracks coming to the crystal from up or down sides
218 Int_t pid = gMC->TrackPid();
220 gMC->CurrentVolOffID(10,module);
222 AddImpact("EMC ",fIshunt, primary,tracknumber, module, pid, pmom, xyzm);
228 if( gMC->CurrentVolID(copy) == gMC->VolId("PCPQ") &&
229 gMC->IsTrackEntering() ) {
230 gMC->TrackMomentum(pmom);
231 gMC->TrackPosition(pos) ;
234 for (i=0; i<3; i++) xyzm[i] = pos[i];
236 for (i=0; i<3; i++) {
240 Int_t pid = gMC->TrackPid();
242 gMC->CurrentVolOffID(3,module);
244 AddImpact("CPV ",fIshunt, primary,tracknumber, module, pid, pmom, xyzm);