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