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 AliPHOSv0 which allows for keeping all hits in TreeH
20 //*-- Author: Gines MARTINEZ (SUBATECH)
23 // --- ROOT system ---
29 // --- Standard library ---
34 #include <strstream.h>
36 // --- AliRoot header files ---
38 #include "AliPHOSv0hits.h"
39 #include "AliPHOSHit.h"
40 #include "AliPHOSDigit.h"
41 #include "AliPHOSReconstructioner.h"
45 ClassImp(AliPHOSv0hits)
47 //____________________________________________________________________________
48 AliPHOSv0hits::AliPHOSv0hits()
55 //____________________________________________________________________________
56 AliPHOSv0hits::AliPHOSv0hits(const char *name, const char *title):
59 fHits= new TClonesArray("AliPHOSHit",1000) ;
62 //____________________________________________________________________________
63 AliPHOSv0hits::~AliPHOSv0hits()
70 fEmcRecPoints->Delete() ;
71 delete fEmcRecPoints ;
74 fPpsdRecPoints->Delete() ;
75 delete fPpsdRecPoints ;
78 fTrackSegments->Delete() ;
79 delete fTrackSegments ;
84 //____________________________________________________________________________
85 void AliPHOSv0hits::AddHit(Int_t tracknumber, Int_t Id, Float_t * hits)
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
91 // cout << "Tracknumber is " << tracknumber << endl;
92 //cout << "Vol Id is " << Id << endl;
93 //cout << "hits is " << hits[0] << " " << hits[1] << " " << hits[2] << " " << hits[3] <<endl;
95 // cout << " Adding a hit number " << fNhits << endl ;
97 TClonesArray <mphits = *fHits ;
102 newHit = new AliPHOSHit(tracknumber, Id, hits) ;
104 // We DO want to save in TreeH the raw hits
105 // TClonesArray &lhits = *fHits;
106 // cout << " Adding a hit to fHits TCloneArray number " << fNhits << endl ;
107 new(ltmphits[fNhits]) AliPHOSHit(*newHit) ;
110 // cout << " Added a hit to fHits TCloneArray number " << fNhits << endl ;
111 // We do not want to save in TreeH the raw hits
112 // new(lhits[fNhits]) AliPHOSHit(*newHit) ;
115 // Please note that the fTmpHits array must survive up to the
116 // end of the events, so it does not appear e.g. in ResetHits() (
117 // which is called at the end of each primary).
126 //___________________________________________________________________________
127 void AliPHOSv0hits::FinishEvent()
129 // Makes the digits from the sum of summed hit in a single crystal or PPSD gas cell
130 // Adds to the energy the electronic noise
131 // Keeps digits with energy above fDigitThreshold
133 // Save the cumulated hits instead of raw hits (need to create the branch myself)
134 // It is put in the Digit Tree because the TreeH is filled after each primary
135 // and the TreeD at the end of the event.
140 TClonesArray &lDigits = *fDigits ;
142 AliPHOSDigit * newdigit ;
143 AliPHOSDigit * curdigit ;
144 Bool_t deja = kFALSE ;
146 for ( i = 0 ; i < fNhits ; i++ ) {
147 hit = (AliPHOSHit*)fHits->At(i) ;
148 newdigit = new AliPHOSDigit( hit->GetPrimary(), hit->GetId(), Digitize( hit->GetEnergy() ) ) ;
150 for ( j = 0 ; j < fNdigits ; j++) {
151 curdigit = (AliPHOSDigit*) lDigits[j] ;
152 if ( *curdigit == *newdigit) {
153 *curdigit = *curdigit + *newdigit ;
158 new(lDigits[fNdigits]) AliPHOSDigit(* newdigit) ;
165 // Noise induced by the PIN diode of the PbWO crystals
167 Float_t energyandnoise ;
168 for ( i = 0 ; i < fNdigits ; i++ ) {
169 newdigit = (AliPHOSDigit * ) fDigits->At(i) ;
170 fGeom->AbsToRelNumbering(newdigit->GetId(), relid) ;
172 if (relid[1]==0){ // Digits belong to EMC (PbW0_4 crystals)
173 energyandnoise = newdigit->GetAmp() + Digitize(gRandom->Gaus(0., fPinElectronicNoise)) ;
175 if (energyandnoise < 0 )
178 if ( newdigit->GetAmp() < fDigitThreshold ) // if threshold not surpassed, remove digit from list
179 fDigits->RemoveAt(i) ;
183 fDigits->Compress() ;
185 fNdigits = fDigits->GetEntries() ;
186 for (i = 0 ; i < fNdigits ; i++) {
187 newdigit = (AliPHOSDigit *) fDigits->At(i) ;
188 newdigit->SetIndexInList(i) ;
193 void AliPHOSv0hits::StepManager(void)
195 // Accumulates hits as long as the track stays in a single crystal or PPSD gas Cell
197 Int_t relid[4] ; // (box, layer, row, column) indices
198 Float_t xyze[4] ; // position wrt MRS and energy deposited
202 Int_t tracknumber = gAlice->CurrentTrack() ;
204 TString name = fGeom->GetName() ;
205 if ( name == "GPS2" ) { // the CPV is a PPSD
206 if( gMC->CurrentVolID(copy) == gMC->VolId("GCEL") ) // We are inside a gas cell
208 gMC->TrackPosition(pos) ;
212 xyze[3] = gMC->Edep() ;
214 if ( xyze[3] != 0 ) { // there is deposited energy
215 gMC->CurrentVolOffID(5, relid[0]) ; // get the PHOS Module number
216 gMC->CurrentVolOffID(3, relid[1]) ; // get the Micromegas Module number
217 // 1-> Geom->GetNumberOfModulesPhi() * fGeom->GetNumberOfModulesZ() upper
218 // > fGeom->GetNumberOfModulesPhi() * fGeom->GetNumberOfModulesZ() lower
219 gMC->CurrentVolOffID(1, relid[2]) ; // get the row number of the cell
220 gMC->CurrentVolID(relid[3]) ; // get the column number
222 // get the absolute Id number
225 fGeom->RelToAbsNumbering(relid, absid) ;
227 // add current hit to the hit list
228 AddHit(tracknumber, absid, xyze);
230 } // there is deposited energy
231 } // We are inside the gas of the CPV
232 } // GPS2 configuration
234 if(gMC->CurrentVolID(copy) == gMC->VolId("PXTL") ) // We are inside a PBWO crystal
236 gMC->TrackPosition(pos) ;
240 xyze[3] = gMC->Edep() ;
242 if ( xyze[3] != 0 ) {
243 gMC->CurrentVolOffID(10, relid[0]) ; // get the PHOS module number ;
244 relid[1] = 0 ; // means PBW04
245 gMC->CurrentVolOffID(4, relid[2]) ; // get the row number inside the module
246 gMC->CurrentVolOffID(3, relid[3]) ; // get the cell number inside the module
248 // get the absolute Id number
251 fGeom->RelToAbsNumbering(relid, absid) ;
253 // add current hit to the hit list
255 AddHit(tracknumber, absid, xyze);
257 } // there is deposited energy
258 } // we are inside a PHOS Xtal