Adapted to PHOS classes using the Getter
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALv1.cxx
CommitLineData
b13bbe81 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$ */
17
18//_________________________________________________________________________
19// Implementation version v1 of EMCAL Manager class
20// An object of this class does not produce digits
21// It is the one to use if you do want to produce outputs in TREEH
22//
23//*-- Author: Sahal Yacoob (LBL /UCT)
24//*-- : Jennifer Klay (LBL)
25
fceb09ed 26// This Class not stores information on all particles prior to EMCAL entry - in order to facilitate analysis.
27// This is done by setting fIShunt =2, and flagging all parents of particles entering the EMCAL.
28
b13bbe81 29
30// --- ROOT system ---
31#include "TPGON.h"
32#include "TTUBS.h"
33#include "TNode.h"
34#include "TRandom.h"
35#include "TTree.h"
36#include "TGeometry.h"
fceb09ed 37#include "TParticle.h"
b13bbe81 38
39// --- Standard library ---
40
41#include <stdio.h>
42#include <string.h>
43#include <stdlib.h>
44#include <strstream.h>
45#include <iostream.h>
46#include <math.h>
47// --- AliRoot header files ---
48
49#include "AliEMCALv1.h"
50#include "AliEMCALHit.h"
51#include "AliEMCALGeometry.h"
52#include "AliConst.h"
53#include "AliRun.h"
54#include "AliMC.h"
55
56ClassImp(AliEMCALv1)
57
58
59//______________________________________________________________________
60AliEMCALv1::AliEMCALv1():AliEMCALv0(){
61 // ctor
62}
63//______________________________________________________________________
64AliEMCALv1::AliEMCALv1(const char *name, const char *title):
65 AliEMCALv0(name,title){
66 // Standard Creator.
67
68 fHits= new TClonesArray("AliEMCALHit",1000);
69 gAlice->AddHitList(fHits);
70
71 fNhits = 0;
ffa6d63b 72 fSamplingFraction = 12.9 ;
d75bea67 73 fLayerToPreshowerRatio = 5.0/6.0;
fceb09ed 74 fIshunt = 2; // All hits are associated with particles entering the calorimeter
b13bbe81 75}
76//______________________________________________________________________
77AliEMCALv1::~AliEMCALv1(){
78 // dtor
79
80 if ( fHits) {
81 fHits->Delete();
82 delete fHits;
83 fHits = 0;
84 }
85}
86//______________________________________________________________________
61e0abb5 87void AliEMCALv1::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t iparent, Float_t ienergy,
88 Int_t id, Float_t * hits,Float_t * p){
b13bbe81 89 // Add a hit to the hit list.
ffa6d63b 90 // An EMCAL hit is the sum of all hits in a single segment
91 // originating from the same enterring particle
b13bbe81 92 Int_t hitCounter;
93
94 AliEMCALHit *newHit;
95 AliEMCALHit *curHit;
96 Bool_t deja = kFALSE;
97
61e0abb5 98 newHit = new AliEMCALHit(shunt, primary, tracknumber, iparent, ienergy, id, hits, p);
b13bbe81 99 for ( hitCounter = fNhits-1; hitCounter >= 0 && !deja; hitCounter-- ) {
100 curHit = (AliEMCALHit*) (*fHits)[hitCounter];
61e0abb5 101 // We add hits with the same tracknumber, while GEANT treats
b13bbe81 102 // primaries succesively
103 if(curHit->GetPrimary() != primary) break;
104 if( *curHit == *newHit ) {
105 *curHit = *curHit + *newHit;
106 deja = kTRUE;
107 } // end if
108 } // end for hitCounter
109
110 if ( !deja ) {
111 new((*fHits)[fNhits]) AliEMCALHit(*newHit);
112 fNhits++;
113 } // end if
114
115 delete newHit;
116}
117//______________________________________________________________________
118void AliEMCALv1::StepManager(void){
119 // Accumulates hits as long as the track stays in a single
120 // crystal or PPSD gas Cell
121 Int_t id[2]; // (layer, phi, Eta) indices
122 Int_t absid;
123 // position wrt MRS and energy deposited
124 Float_t xyze[4]={0.,0.,0.,0.};
61e0abb5 125 Float_t pmom[4]={0.,0.,0.,0.};
b13bbe81 126 TLorentzVector pos; // Lorentz vector of the track current position.
127 TLorentzVector mom; // Lorentz vector of the track current momentum.
128 Int_t tracknumber = gAlice->CurrentTrack();
ffa6d63b 129 Int_t primary = 0;
61e0abb5 130 static Int_t iparent = 0;
131 static Float_t ienergy = 0;
ffa6d63b 132 Int_t copy = 0;
61e0abb5 133
134
ffa6d63b 135 if(gMC->IsTrackEntering() && (strcmp(gMC->CurrentVolName(),"XALU") == 0)) // This Particle in enterring the Calorimeter
61e0abb5 136 {
fceb09ed 137
138gMC->TrackPosition(pos) ;
139 xyze[0] = pos[0] ;
140 xyze[1] = pos[1] ;
141 xyze[2] = pos[2] ;
142
143 if ( (xyze[1]*xyze[1] + xyze[2]*xyze[2] + xyze[3]*xyze[3]) < (fGeom->GetEnvelop(0)+fGeom->GetGap2Active()+1.5 )*(fGeom->GetEnvelop(0)+fGeom->GetGap2Active()+1.5 ) )
144 {
61e0abb5 145 iparent = tracknumber;
146 gMC->TrackMomentum(mom);
147 ienergy = mom[3];
fceb09ed 148 TParticle * part = 0 ;
149 Int_t parent = iparent ;
150 while ( parent != -1 ) { // <------------- flags this particle to be kept and
151//all the ancestors of this particle
152 part = gAlice->Particle(parent) ;
153 part->SetBit(kKeepBit);
154 parent = part->GetFirstMother() ;
155 }
156 }
157
158
159
61e0abb5 160}
ffa6d63b 161 if(gMC->CurrentVolID(copy) == gMC->VolId("XPHI") ) { // We are in a Scintillator Layer
b13bbe81 162
163 gMC->CurrentVolOffID(1, id[0]); // get the POLY copy number;
164 gMC->CurrentVolID(id[1]); // get the phi number inside the layer
165 primary = gAlice->GetPrimary(tracknumber);
b13bbe81 166 gMC->TrackPosition(pos);
167 gMC->TrackMomentum(mom);
168 xyze[0] = pos[0];
169 xyze[1] = pos[1];
170 xyze[2] = pos[2];
ffa6d63b 171 xyze[3] = fSamplingFraction*(gMC->Edep()); // Correct for sampling calorimeter
61e0abb5 172 pmom[0] = mom[0];
173 pmom[1] = mom[1];
174 pmom[2] = mom[2];
175 pmom[3] = mom[3];
176
b13bbe81 177 if(xyze[3] > 0.){// Track is inside the crystal and deposits some energy
178 absid = (id[0]-1)*(fGeom->GetNPhi()) + id[1];
ffa6d63b 179 if((absid/fGeom->GetNPhi()) < (2*fGeom->GetNZ()))
d75bea67 180 {xyze[3] = fLayerToPreshowerRatio*xyze[3] ;} // Preshower readout must be scaled
ffa6d63b 181 AddHit(fIshunt, primary,tracknumber, iparent, ienergy, absid, xyze, pmom);
b13bbe81 182 } // there is deposited energy
61e0abb5 183}
b13bbe81 184}