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 | |
26 | |
27 | // --- ROOT system --- |
28 | #include "TPGON.h" |
29 | #include "TTUBS.h" |
30 | #include "TNode.h" |
31 | #include "TRandom.h" |
32 | #include "TTree.h" |
33 | #include "TGeometry.h" |
34 | |
35 | |
36 | // --- Standard library --- |
37 | |
38 | #include <stdio.h> |
39 | #include <string.h> |
40 | #include <stdlib.h> |
41 | #include <strstream.h> |
42 | #include <iostream.h> |
43 | #include <math.h> |
44 | // --- AliRoot header files --- |
45 | |
46 | #include "AliEMCALv1.h" |
47 | #include "AliEMCALHit.h" |
48 | #include "AliEMCALGeometry.h" |
49 | #include "AliConst.h" |
50 | #include "AliRun.h" |
51 | #include "AliMC.h" |
52 | |
53 | ClassImp(AliEMCALv1) |
54 | |
55 | |
56 | //______________________________________________________________________ |
57 | AliEMCALv1::AliEMCALv1():AliEMCALv0(){ |
58 | // ctor |
59 | } |
60 | //______________________________________________________________________ |
61 | AliEMCALv1::AliEMCALv1(const char *name, const char *title): |
62 | AliEMCALv0(name,title){ |
63 | // Standard Creator. |
64 | |
65 | fHits= new TClonesArray("AliEMCALHit",1000); |
66 | gAlice->AddHitList(fHits); |
67 | |
68 | fNhits = 0; |
69 | |
70 | fIshunt = 1; // All hits are associated with primary particles |
71 | } |
72 | //______________________________________________________________________ |
73 | AliEMCALv1::~AliEMCALv1(){ |
74 | // dtor |
75 | |
76 | if ( fHits) { |
77 | fHits->Delete(); |
78 | delete fHits; |
79 | fHits = 0; |
80 | } |
81 | } |
82 | //______________________________________________________________________ |
61e0abb5 |
83 | void AliEMCALv1::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t iparent, Float_t ienergy, |
84 | Int_t id, Float_t * hits,Float_t * p){ |
b13bbe81 |
85 | // Add a hit to the hit list. |
86 | // A PHOS hit is the sum of all hits in a single crystal |
87 | // or in a single PPSD gas cell |
88 | Int_t hitCounter; |
89 | |
90 | AliEMCALHit *newHit; |
91 | AliEMCALHit *curHit; |
92 | Bool_t deja = kFALSE; |
93 | |
61e0abb5 |
94 | newHit = new AliEMCALHit(shunt, primary, tracknumber, iparent, ienergy, id, hits, p); |
b13bbe81 |
95 | for ( hitCounter = fNhits-1; hitCounter >= 0 && !deja; hitCounter-- ) { |
96 | curHit = (AliEMCALHit*) (*fHits)[hitCounter]; |
61e0abb5 |
97 | // We add hits with the same tracknumber, while GEANT treats |
b13bbe81 |
98 | // primaries succesively |
99 | if(curHit->GetPrimary() != primary) break; |
100 | if( *curHit == *newHit ) { |
101 | *curHit = *curHit + *newHit; |
102 | deja = kTRUE; |
103 | } // end if |
104 | } // end for hitCounter |
105 | |
106 | if ( !deja ) { |
107 | new((*fHits)[fNhits]) AliEMCALHit(*newHit); |
108 | fNhits++; |
109 | } // end if |
110 | |
111 | delete newHit; |
112 | } |
113 | //______________________________________________________________________ |
114 | void AliEMCALv1::StepManager(void){ |
115 | // Accumulates hits as long as the track stays in a single |
116 | // crystal or PPSD gas Cell |
117 | Int_t id[2]; // (layer, phi, Eta) indices |
118 | Int_t absid; |
119 | // position wrt MRS and energy deposited |
120 | Float_t xyze[4]={0.,0.,0.,0.}; |
61e0abb5 |
121 | Float_t pmom[4]={0.,0.,0.,0.}; |
b13bbe81 |
122 | TLorentzVector pos; // Lorentz vector of the track current position. |
123 | TLorentzVector mom; // Lorentz vector of the track current momentum. |
124 | Int_t tracknumber = gAlice->CurrentTrack(); |
61e0abb5 |
125 | Int_t primary; |
126 | static Int_t iparent = 0; |
127 | static Float_t ienergy = 0; |
128 | Int_t copy; |
129 | |
130 | |
131 | if(gMC->IsTrackEntering() && (strcmp(gMC->CurrentVolName(),"XALU") == 0)) |
132 | { |
133 | iparent = tracknumber; |
134 | gMC->TrackMomentum(mom); |
135 | ienergy = mom[3]; |
136 | } |
137 | if(gMC->CurrentVolID(copy) == gMC->VolId("XPHI") ) { // We are inside a PBWO crysta |
b13bbe81 |
138 | |
139 | gMC->CurrentVolOffID(1, id[0]); // get the POLY copy number; |
140 | gMC->CurrentVolID(id[1]); // get the phi number inside the layer |
141 | primary = gAlice->GetPrimary(tracknumber); |
b13bbe81 |
142 | gMC->TrackPosition(pos); |
143 | gMC->TrackMomentum(mom); |
144 | xyze[0] = pos[0]; |
145 | xyze[1] = pos[1]; |
146 | xyze[2] = pos[2]; |
147 | xyze[3] = gMC->Edep(); |
61e0abb5 |
148 | pmom[0] = mom[0]; |
149 | pmom[1] = mom[1]; |
150 | pmom[2] = mom[2]; |
151 | pmom[3] = mom[3]; |
152 | |
b13bbe81 |
153 | if(xyze[3] > 0.){// Track is inside the crystal and deposits some energy |
154 | absid = (id[0]-1)*(fGeom->GetNPhi()) + id[1]; |
61e0abb5 |
155 | AddHit(fIshunt, primary,tracknumber, iparent, ienergy, absid, xyze, pmom); |
b13bbe81 |
156 | } // there is deposited energy |
61e0abb5 |
157 | } |
b13bbe81 |
158 | } |