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 **************************************************************************/
17 //_________________________________________________________________________
18 // Version of AliPHOSv1 which keeps all hits in TreeH
19 // AddHit, StepManager,and FinishEvent are redefined
21 //*-- Author: Gines MARTINEZ (SUBATECH)
24 // --- ROOT system ---
30 // --- Standard library ---
35 #include <strstream.h>
37 // --- AliRoot header files ---
39 #include "AliPHOSv2.h"
40 #include "AliPHOSHit.h"
41 #include "AliPHOSDigit.h"
42 #include "AliPHOSReconstructioner.h"
48 //____________________________________________________________________________
49 AliPHOSv2::AliPHOSv2()
56 //____________________________________________________________________________
57 AliPHOSv2::AliPHOSv2(const char *name, const char *title):
61 fHits= new TClonesArray("AliPHOSHit",1000) ;
64 //____________________________________________________________________________
65 AliPHOSv2::~AliPHOSv2()
74 if ( fEmcRecPoints ) {
75 fEmcRecPoints->Delete() ;
76 delete fEmcRecPoints ;
80 if ( fPpsdRecPoints ) {
81 fPpsdRecPoints->Delete() ;
82 delete fPpsdRecPoints ;
86 if ( fTrackSegments ) {
87 fTrackSegments->Delete() ;
88 delete fTrackSegments ;
93 //____________________________________________________________________________
94 void AliPHOSv2::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t Id, Float_t * hits)
96 // Add a hit to the hit list.
97 // In this version of AliPHOSv1, a PHOS hit is real geant
98 // hits in a single crystal or in a single PPSD gas cell
100 TClonesArray <mphits = *fHits ;
105 newHit = new AliPHOSHit(shunt, primary, tracknumber, Id, hits) ;
107 // We DO want to save in TreeH the raw hits
108 new(ltmphits[fNhits]) AliPHOSHit(*newHit) ;
111 // Please note that the fTmpHits array must survive up to the
112 // end of the events, so it does not appear e.g. in ResetHits() (
113 // which is called at the end of each primary).
122 //___________________________________________________________________________
123 void AliPHOSv2::FinishEvent()
125 // Makes the digits from the sum of summed hit in a single crystal or PPSD gas cell
126 // Adds to the energy the electronic noise
127 // Keeps digits with energy above fDigitThreshold
129 // Save the cumulated hits instead of raw hits (need to create the branch myself)
130 // It is put in the Digit Tree because the TreeH is filled after each primary
131 // and the TreeD at the end of the event.
136 TClonesArray &lDigits = *fDigits ;
138 AliPHOSDigit * newdigit ;
139 AliPHOSDigit * curdigit ;
140 Bool_t deja = kFALSE ;
142 for ( i = 0 ; i < fNhits ; i++ ) {
143 hit = (AliPHOSHit*)fHits->At(i) ;
144 newdigit = new AliPHOSDigit( hit->GetPrimary(), hit->GetId(), Digitize( hit->GetEnergy() ) ) ;
146 for ( j = 0 ; j < fNdigits ; j++) {
147 curdigit = (AliPHOSDigit*) lDigits[j] ;
148 if ( *curdigit == *newdigit) {
149 *curdigit = *curdigit + *newdigit ;
154 new(lDigits[fNdigits]) AliPHOSDigit(* newdigit) ;
161 // Noise induced by the PIN diode of the PbWO crystals
163 Float_t energyandnoise ;
164 for ( i = 0 ; i < fNdigits ; i++ ) {
165 newdigit = (AliPHOSDigit * ) fDigits->At(i) ;
166 fGeom->AbsToRelNumbering(newdigit->GetId(), relid) ;
168 if (relid[1]==0){ // Digits belong to EMC (PbW0_4 crystals)
169 energyandnoise = newdigit->GetAmp() + Digitize(gRandom->Gaus(0., fPinElectronicNoise)) ;
171 if (energyandnoise < 0 )
174 if ( newdigit->GetAmp() < fDigitThreshold ) // if threshold not surpassed, remove digit from list
175 fDigits->RemoveAt(i) ;
179 fDigits->Compress() ;
181 fNdigits = fDigits->GetEntries() ;
182 for (i = 0 ; i < fNdigits ; i++) {
183 newdigit = (AliPHOSDigit *) fDigits->At(i) ;
184 newdigit->SetIndexInList(i) ;
189 void AliPHOSv2::StepManager(void)
191 // Accumulates hits as long as the track stays in a single crystal or PPSD gas Cell
193 Int_t relid[4] ; // (box, layer, row, column) indices
194 Float_t xyze[4] ; // position wrt MRS and energy deposited
198 Int_t tracknumber = gAlice->CurrentTrack() ;
199 Int_t primary = gAlice->GetPrimary( gAlice->CurrentTrack() );
201 TString name = fGeom->GetName() ;
202 if ( name == "GPS2" ) { // the CPV is a PPSD
203 if( gMC->CurrentVolID(copy) == gMC->VolId("GCEL") ) // We are inside a gas cell
205 gMC->TrackPosition(pos) ;
209 xyze[3] = gMC->Edep() ;
211 if ( xyze[3] != 0 ) { // there is deposited energy
212 gMC->CurrentVolOffID(5, relid[0]) ; // get the PHOS Module number
213 gMC->CurrentVolOffID(3, relid[1]) ; // get the Micromegas Module number
214 // 1-> Geom->GetNumberOfModulesPhi() * fGeom->GetNumberOfModulesZ() upper
215 // > fGeom->GetNumberOfModulesPhi() * fGeom->GetNumberOfModulesZ() lower
216 gMC->CurrentVolOffID(1, relid[2]) ; // get the row number of the cell
217 gMC->CurrentVolID(relid[3]) ; // get the column number
219 // get the absolute Id number
222 fGeom->RelToAbsNumbering(relid, absid) ;
224 // add current hit to the hit list
225 AddHit(fIshunt, primary, tracknumber, absid, xyze);
227 } // there is deposited energy
228 } // We are inside the gas of the CPV
229 } // GPS2 configuration
231 if(gMC->CurrentVolID(copy) == gMC->VolId("PXTL") ) // We are inside a PBWO crystal
233 gMC->TrackPosition(pos) ;
237 xyze[3] = gMC->Edep() ;
239 if ( xyze[3] != 0 ) {
240 gMC->CurrentVolOffID(10, relid[0]) ; // get the PHOS module number ;
241 relid[1] = 0 ; // means PBW04
242 gMC->CurrentVolOffID(4, relid[2]) ; // get the row number inside the module
243 gMC->CurrentVolOffID(3, relid[3]) ; // get the cell number inside the module
245 // get the absolute Id number
248 fGeom->RelToAbsNumbering(relid, absid) ;
250 // add current hit to the hit list
252 AddHit(fIshunt, primary,tracknumber, absid, xyze);
254 } // there is deposited energy
255 } // we are inside a PHOS Xtal