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()
51 //____________________________________________________________________________
52 AliPHOSvImpacts::AliPHOSvImpacts(const char *name, const char *title):
55 // ctor : title is used to identify the layout
58 // - fHits (the "normal" one), which retains the hits associated with
59 // the current primary particle being tracked
60 // (this array is reset after each primary has been tracked).
61 // This part inherits from AliPHOSv1
64 // - fEMCImpacts, fCPVImpacts which are
65 // TList of EMC and CPV modules respectively, each
66 // modules contains TClonesArray of AliPHOSImpacts
68 fEMCImpacts = new TList();
69 fCPVImpacts = new TList();
71 Int_t nPHOSModules = GetGeometry()->GetNModules();
72 Int_t nCPVModules = GetGeometry()->GetNModules();
75 TClonesArray * impacts;
76 for (iPHOSModule=0; iPHOSModule<nPHOSModules; iPHOSModule++) {
77 fEMCImpacts->Add(new TClonesArray("AliPHOSImpact",200)) ;
78 fNEMCImpacts[iPHOSModule] = 0;
79 impacts = (TClonesArray *)fEMCImpacts->At(iPHOSModule);
81 for (iPHOSModule=0; iPHOSModule<nCPVModules; iPHOSModule++) {
82 fCPVImpacts->Add(new TClonesArray("AliPHOSImpact",200)) ;
83 fNCPVImpacts[iPHOSModule] = 0;
84 impacts = (TClonesArray *)fCPVImpacts->At(iPHOSModule);
89 //____________________________________________________________________________
90 AliPHOSvImpacts::~AliPHOSvImpacts()
101 // Delete impacts in EMC, CPV
103 fEMCImpacts->Delete() ;
108 fCPVImpacts->Delete() ;
114 //____________________________________________________________________________
115 void AliPHOSvImpacts::AddImpact( char* det, Int_t shunt, Int_t primary, Int_t track, Int_t module,
116 Int_t pid, TLorentzVector p, Float_t *xyz)
118 // Add an impact to the impact list.
120 TClonesArray * impacts = 0;
123 if (strcmp(det,"EMC ")==0) {
124 impacts = (TClonesArray *)fEMCImpacts->At(module);
125 nImpacts= fNEMCImpacts[module];
126 fNEMCImpacts[module]++ ;
128 else if (strcmp(det,"CPV ")==0) {
129 impacts = (TClonesArray *)fCPVImpacts->At(module);
130 nImpacts= fNCPVImpacts[module];
131 fNCPVImpacts[module]++ ;
134 new((*impacts)[nImpacts]) AliPHOSImpact(shunt,primary,track,pid,p,xyz) ;
137 printf("Module %d %s: ",module,det);
138 ((AliPHOSImpact*)(impacts->At(nImpacts)))->Print();
142 //____________________________________________________________________________
143 void AliPHOSvImpacts::MakeBranch(Option_t *opt, const char *file)
145 // Create new branch in the current Hits Root Tree containing
146 // a list of PHOS impacts (exact values of track coming to detector)
148 AliDetector::MakeBranch(opt,file);
150 Int_t bufferSize = 32000 ;
151 Int_t splitlevel = 0 ;
152 gAlice->TreeH()->Branch("PHOSEmcImpacts" , "TList", &fEMCImpacts , bufferSize, splitlevel);
153 gAlice->TreeH()->Branch("PHOSCpvImpacts" , "TList", &fCPVImpacts , bufferSize, splitlevel);
157 //____________________________________________________________________________
158 void AliPHOSvImpacts::ResetHits()
160 // Reset impact branches for EMC, CPV and PPSD
162 AliDetector::ResetHits();
165 for (i=0; i<GetGeometry()->GetNModules(); i++) {
166 ((TClonesArray*)fEMCImpacts->At(i)) -> Clear();
167 fNEMCImpacts[i] = 0 ;
170 for (i=0; i<GetGeometry()->GetNModules(); i++) {
171 ((TClonesArray*)fCPVImpacts->At(i)) -> Clear();
172 fNCPVImpacts[i] = 0 ;
177 //_____________________________________________________________________________
178 void AliPHOSvImpacts::StepManager(void)
180 // Find impacts (tracks which enter the EMC, CPV)
181 // and add them to to the impact lists
183 AliPHOSv1::StepManager();
185 Float_t xyzm[3], xyzd[3], pm[3], pd[3];
186 TLorentzVector pmom ; // Lorentz momentum of the particle initiated hit
187 TLorentzVector pos ; // Lorentz vector of the track current position
190 Int_t tracknumber = gAlice->CurrentTrack() ;
191 Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() );
192 TString name = GetGeometry()->GetName() ;
196 if( gMC->CurrentVolID(copy) == gMC->VolId("PXTL") &&
197 gMC->IsTrackEntering() ) {
198 gMC->TrackMomentum(pmom);
199 gMC->TrackPosition(pos) ;
202 for (i=0; i<3; i++) xyzm[i] = pos[i];
204 for (i=0; i<3; i++) {
208 gMC -> Gmtod (xyzm, xyzd, 1); // transform coordinate from master to daughter system
209 gMC -> Gmtod (pm, pd, 2); // transform 3-momentum from master to daughter system
211 // Select tracks coming to the crystal from up or down sides
212 if (pd[1]<0 && xyzd[1] > GetGeometry()->GetCrystalSize(1)/2-0.001 ||
213 pd[1]>0 && xyzd[1] < -GetGeometry()->GetCrystalSize(1)/2+0.001) {
214 Int_t pid = gMC->TrackPid();
216 gMC->CurrentVolOffID(10,module);
218 AddImpact("EMC ",fIshunt, primary,tracknumber, module, pid, pmom, xyzm);
224 if( gMC->CurrentVolID(copy) == gMC->VolId("PCPQ") &&
225 gMC->IsTrackEntering() ) {
226 gMC->TrackMomentum(pmom);
227 gMC->TrackPosition(pos) ;
230 for (i=0; i<3; i++) xyzm[i] = pos[i];
232 for (i=0; i<3; i++) {
236 Int_t pid = gMC->TrackPid();
238 gMC->CurrentVolOffID(3,module);
240 AddImpact("CPV ",fIshunt, primary,tracknumber, module, pid, pmom, xyzm);