]>
Commit | Line | Data |
---|---|---|
7587f5a5 | 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 | ||
b2a60966 | 16 | /* $Id$ */ |
7587f5a5 | 17 | //_________________________________________________________________________ |
bea63bea | 18 | // Version of AliPHOSv0 which allows for keeping all hits in TreeH |
b2a60966 | 19 | // |
bea63bea | 20 | //*-- Author: Gines MARTINEZ (SUBATECH) |
b2a60966 | 21 | |
7587f5a5 | 22 | |
23 | // --- ROOT system --- | |
bea63bea | 24 | |
25 | #include "TBRIK.h" | |
26 | #include "TNode.h" | |
7587f5a5 | 27 | #include "TRandom.h" |
28 | ||
29 | // --- Standard library --- | |
30 | ||
de9ec31b | 31 | #include <stdio.h> |
32 | #include <string.h> | |
33 | #include <stdlib.h> | |
34 | #include <strstream.h> | |
7587f5a5 | 35 | |
36 | // --- AliRoot header files --- | |
37 | ||
38 | #include "AliPHOSv1.h" | |
39 | #include "AliPHOSHit.h" | |
40 | #include "AliPHOSDigit.h" | |
bea63bea | 41 | #include "AliPHOSReconstructioner.h" |
7587f5a5 | 42 | #include "AliRun.h" |
43 | #include "AliConst.h" | |
44 | ||
45 | ClassImp(AliPHOSv1) | |
46 | ||
bea63bea | 47 | //____________________________________________________________________________ |
48 | AliPHOSv1::AliPHOSv1() | |
49 | { | |
50 | // default ctor | |
51 | fNTmpHits = 0 ; | |
52 | fTmpHits = 0 ; | |
53 | } | |
54 | ||
7587f5a5 | 55 | //____________________________________________________________________________ |
56 | AliPHOSv1::AliPHOSv1(const char *name, const char *title): | |
57 | AliPHOSv0(name,title) | |
58 | { | |
bea63bea | 59 | // ctor |
60 | fHits= new TClonesArray("AliPHOSHit",1000) ; | |
7587f5a5 | 61 | } |
b2a60966 | 62 | |
7587f5a5 | 63 | //____________________________________________________________________________ |
bea63bea | 64 | AliPHOSv1::~AliPHOSv1() |
b2a60966 | 65 | { |
bea63bea | 66 | // dtor |
8dfa469d | 67 | if ( fTmpHits) { |
68 | fTmpHits->Delete() ; | |
69 | delete fTmpHits ; | |
70 | fTmpHits = 0 ; | |
71 | } | |
72 | ||
73 | if ( fEmcRecPoints ) { | |
74 | fEmcRecPoints->Delete() ; | |
75 | delete fEmcRecPoints ; | |
76 | fEmcRecPoints = 0 ; | |
77 | } | |
78 | ||
79 | if ( fPpsdRecPoints ) { | |
80 | fPpsdRecPoints->Delete() ; | |
81 | delete fPpsdRecPoints ; | |
82 | fPpsdRecPoints = 0 ; | |
83 | } | |
bea63bea | 84 | |
8dfa469d | 85 | if ( fTrackSegments ) { |
86 | fTrackSegments->Delete() ; | |
87 | delete fTrackSegments ; | |
88 | fTrackSegments = 0 ; | |
89 | } | |
7587f5a5 | 90 | } |
91 | ||
7587f5a5 | 92 | //____________________________________________________________________________ |
bea63bea | 93 | void AliPHOSv1::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t Id, Float_t * hits) |
94 | { | |
95 | // Add a hit to the hit list. | |
96 | // In this version of AliPHOSv0, a PHOS hit is real geant | |
97 | // hits in a single crystal or in a single PPSD gas cell | |
98 | ||
99 | // cout << "Primary is " << primary << endl; | |
100 | //cout << "Tracknumber is " << tracknumber << endl; | |
101 | //cout << "Vol Id is " << Id << endl; | |
102 | //cout << "hits is " << hits[0] << " " << hits[1] << " " << hits[2] << " " << hits[3] <<endl; | |
103 | ||
104 | // cout << " Adding a hit number " << fNhits << endl ; | |
105 | ||
106 | TClonesArray <mphits = *fHits ; | |
107 | AliPHOSHit *newHit ; | |
108 | ||
109 | // fHits->Print(""); | |
110 | ||
111 | newHit = new AliPHOSHit(shunt, primary, tracknumber, Id, hits) ; | |
112 | ||
113 | // We DO want to save in TreeH the raw hits | |
114 | // TClonesArray &lhits = *fHits; | |
115 | // cout << " Adding a hit to fHits TCloneArray number " << fNhits << endl ; | |
116 | new(ltmphits[fNhits]) AliPHOSHit(*newHit) ; | |
117 | fNhits++ ; | |
118 | ||
119 | // cout << " Added a hit to fHits TCloneArray number " << fNhits << endl ; | |
120 | // We do not want to save in TreeH the raw hits | |
121 | // new(lhits[fNhits]) AliPHOSHit(*newHit) ; | |
122 | // fNhits++ ; | |
123 | ||
124 | // Please note that the fTmpHits array must survive up to the | |
125 | // end of the events, so it does not appear e.g. in ResetHits() ( | |
126 | // which is called at the end of each primary). | |
127 | ||
128 | delete newHit; | |
129 | ||
130 | } | |
131 | ||
132 | ||
133 | ||
134 | ||
135 | //___________________________________________________________________________ | |
136 | void AliPHOSv1::FinishEvent() | |
137 | { | |
138 | // Makes the digits from the sum of summed hit in a single crystal or PPSD gas cell | |
139 | // Adds to the energy the electronic noise | |
140 | // Keeps digits with energy above fDigitThreshold | |
141 | ||
142 | // Save the cumulated hits instead of raw hits (need to create the branch myself) | |
143 | // It is put in the Digit Tree because the TreeH is filled after each primary | |
144 | // and the TreeD at the end of the event. | |
145 | ||
146 | Int_t i ; | |
147 | Int_t relid[4]; | |
148 | Int_t j ; | |
149 | TClonesArray &lDigits = *fDigits ; | |
150 | AliPHOSHit * hit ; | |
151 | AliPHOSDigit * newdigit ; | |
152 | AliPHOSDigit * curdigit ; | |
153 | Bool_t deja = kFALSE ; | |
154 | ||
155 | for ( i = 0 ; i < fNhits ; i++ ) { | |
156 | hit = (AliPHOSHit*)fHits->At(i) ; | |
157 | newdigit = new AliPHOSDigit( hit->GetPrimary(), hit->GetId(), Digitize( hit->GetEnergy() ) ) ; | |
158 | deja =kFALSE ; | |
159 | for ( j = 0 ; j < fNdigits ; j++) { | |
160 | curdigit = (AliPHOSDigit*) lDigits[j] ; | |
161 | if ( *curdigit == *newdigit) { | |
162 | *curdigit = *curdigit + *newdigit ; | |
163 | deja = kTRUE ; | |
164 | } | |
165 | } | |
166 | if ( !deja ) { | |
167 | new(lDigits[fNdigits]) AliPHOSDigit(* newdigit) ; | |
168 | fNdigits++ ; | |
169 | } | |
170 | ||
171 | delete newdigit ; | |
172 | } | |
173 | ||
174 | // Noise induced by the PIN diode of the PbWO crystals | |
175 | ||
176 | Float_t energyandnoise ; | |
177 | for ( i = 0 ; i < fNdigits ; i++ ) { | |
178 | newdigit = (AliPHOSDigit * ) fDigits->At(i) ; | |
179 | fGeom->AbsToRelNumbering(newdigit->GetId(), relid) ; | |
180 | ||
181 | if (relid[1]==0){ // Digits belong to EMC (PbW0_4 crystals) | |
182 | energyandnoise = newdigit->GetAmp() + Digitize(gRandom->Gaus(0., fPinElectronicNoise)) ; | |
183 | ||
184 | if (energyandnoise < 0 ) | |
185 | energyandnoise = 0 ; | |
186 | ||
187 | if ( newdigit->GetAmp() < fDigitThreshold ) // if threshold not surpassed, remove digit from list | |
188 | fDigits->RemoveAt(i) ; | |
189 | } | |
190 | } | |
191 | ||
192 | fDigits->Compress() ; | |
193 | ||
194 | fNdigits = fDigits->GetEntries() ; | |
195 | for (i = 0 ; i < fNdigits ; i++) { | |
196 | newdigit = (AliPHOSDigit *) fDigits->At(i) ; | |
197 | newdigit->SetIndexInList(i) ; | |
198 | } | |
199 | ||
200 | } | |
201 | ||
7587f5a5 | 202 | void AliPHOSv1::StepManager(void) |
203 | { | |
b2a60966 | 204 | // Accumulates hits as long as the track stays in a single crystal or PPSD gas Cell |
b2a60966 | 205 | |
7587f5a5 | 206 | Int_t relid[4] ; // (box, layer, row, column) indices |
207 | Float_t xyze[4] ; // position wrt MRS and energy deposited | |
208 | TLorentzVector pos ; | |
bea63bea | 209 | Int_t copy ; |
7587f5a5 | 210 | |
bea63bea | 211 | Int_t tracknumber = gAlice->CurrentTrack() ; |
212 | Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() ); | |
457ebb6e | 213 | |
bea63bea | 214 | TString name = fGeom->GetName() ; |
7587f5a5 | 215 | if ( name == "GPS2" ) { // the CPV is a PPSD |
b2a60966 | 216 | if( gMC->CurrentVolID(copy) == gMC->VolId("GCEL") ) // We are inside a gas cell |
7587f5a5 | 217 | { |
218 | gMC->TrackPosition(pos) ; | |
219 | xyze[0] = pos[0] ; | |
220 | xyze[1] = pos[1] ; | |
221 | xyze[2] = pos[2] ; | |
bea63bea | 222 | xyze[3] = gMC->Edep() ; |
7587f5a5 | 223 | |
224 | if ( xyze[3] != 0 ) { // there is deposited energy | |
225 | gMC->CurrentVolOffID(5, relid[0]) ; // get the PHOS Module number | |
226 | gMC->CurrentVolOffID(3, relid[1]) ; // get the Micromegas Module number | |
227 | // 1-> Geom->GetNumberOfModulesPhi() * fGeom->GetNumberOfModulesZ() upper | |
228 | // > fGeom->GetNumberOfModulesPhi() * fGeom->GetNumberOfModulesZ() lower | |
229 | gMC->CurrentVolOffID(1, relid[2]) ; // get the row number of the cell | |
230 | gMC->CurrentVolID(relid[3]) ; // get the column number | |
231 | ||
232 | // get the absolute Id number | |
233 | ||
234 | Int_t absid ; | |
bea63bea | 235 | fGeom->RelToAbsNumbering(relid, absid) ; |
7587f5a5 | 236 | |
bea63bea | 237 | // add current hit to the hit list |
238 | AddHit(fIshunt, primary, tracknumber, absid, xyze); | |
7587f5a5 | 239 | |
240 | } // there is deposited energy | |
241 | } // We are inside the gas of the CPV | |
242 | } // GPS2 configuration | |
243 | ||
bea63bea | 244 | if(gMC->CurrentVolID(copy) == gMC->VolId("PXTL") ) // We are inside a PBWO crystal |
7587f5a5 | 245 | { |
246 | gMC->TrackPosition(pos) ; | |
247 | xyze[0] = pos[0] ; | |
248 | xyze[1] = pos[1] ; | |
249 | xyze[2] = pos[2] ; | |
a333c916 | 250 | xyze[3] = gMC->Edep() ; |
7587f5a5 | 251 | |
7587f5a5 | 252 | if ( xyze[3] != 0 ) { |
253 | gMC->CurrentVolOffID(10, relid[0]) ; // get the PHOS module number ; | |
bea63bea | 254 | relid[1] = 0 ; // means PBW04 |
7587f5a5 | 255 | gMC->CurrentVolOffID(4, relid[2]) ; // get the row number inside the module |
256 | gMC->CurrentVolOffID(3, relid[3]) ; // get the cell number inside the module | |
257 | ||
258 | // get the absolute Id number | |
259 | ||
260 | Int_t absid ; | |
bea63bea | 261 | fGeom->RelToAbsNumbering(relid, absid) ; |
262 | ||
263 | // add current hit to the hit list | |
264 | ||
265 | AddHit(fIshunt, primary,tracknumber, absid, xyze); | |
7587f5a5 | 266 | |
267 | } // there is deposited energy | |
268 | } // we are inside a PHOS Xtal | |
269 | } | |
270 |