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_hits 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 "AliPHOSv0_hits.h"
39 #include "AliPHOSHit.h"
40 #include "AliPHOSDigit.h"
41 #include "AliPHOSReconstructioner.h"
45 ClassImp(AliPHOSv0_hits)
47 //____________________________________________________________________________
48 AliPHOSv0_hits::AliPHOSv0_hits()
55 //____________________________________________________________________________
56 AliPHOSv0_hits::AliPHOSv0_hits(const char *name, const char *title):
59 fHits= new TClonesArray("AliPHOSHit",1000) ;
62 //____________________________________________________________________________
63 AliPHOSv0_hits::~AliPHOSv0_hits()
70 fEmcClusters->Delete() ;
74 fPpsdClusters->Delete() ;
75 delete fPpsdClusters ;
78 fTrackSegments->Delete() ;
79 delete fTrackSegments ;
83 //____________________________________________________________________________
84 void AliPHOSv0_hits::AddHit(Int_t primary, Int_t Id, Float_t * hits)
86 // Add a hit to the hit list.
87 // In this version of AliPHOSv0, a PHOS hit is real geant
88 // hits in a single crystal or in a single PPSD gas cell
90 // cout << "Primary particle is " << primary << endl;
91 //cout << "Vol Id is " << Id << endl;
92 //cout << "hits is " << hits[0] << " " << hits[1] << " " << hits[2] << " " << hits[3] <<endl;
94 cout << " Adding a hit number " << fNhits << endl ;
96 TClonesArray <mphits = *fHits ;
101 newHit = new AliPHOSHit(primary, Id, hits) ;
103 // We DO want to save in TreeH the raw hits
104 // TClonesArray &lhits = *fHits;
105 cout << " Adding a hit to fHits TCloneArray number " << fNhits << endl ;
106 new(ltmphits[fNhits]) AliPHOSHit(*newHit) ;
109 cout << " Added a hit to fHits TCloneArray number " << fNhits << endl ;
110 // We do not want to save in TreeH the raw hits
111 // new(lhits[fNhits]) AliPHOSHit(*newHit) ;
114 // Please note that the fTmpHits array must survive up to the
115 // end of the events, so it does not appear e.g. in ResetHits() (
116 // which is called at the end of each primary).
125 //___________________________________________________________________________
126 void AliPHOSv0_hits::FinishEvent()
128 // Makes the digits from the sum of summed hit in a single crystal or PPSD gas cell
129 // Adds to the energy the electronic noise
130 // Keeps digits with energy above fDigitThreshold
132 // Save the cumulated hits instead of raw hits (need to create the branch myself)
133 // It is put in the Digit Tree because the TreeH is filled after each primary
134 // and the TreeD at the end of the event.
139 TClonesArray &lDigits = *fDigits ;
141 AliPHOSDigit * newdigit ;
142 AliPHOSDigit * curdigit ;
143 Bool_t deja = kFALSE ;
145 for ( i = 0 ; i < fNhits ; i++ ) {
146 hit = (AliPHOSHit*)fHits->At(i) ;
147 newdigit = new AliPHOSDigit( hit->GetPrimary(), hit->GetId(), Digitize( hit->GetEnergy() ) ) ;
149 for ( j = 0 ; j < fNdigits ; j++) {
150 curdigit = (AliPHOSDigit*) lDigits[j] ;
151 if ( *curdigit == *newdigit) {
152 *curdigit = *curdigit + *newdigit ;
157 new(lDigits[fNdigits]) AliPHOSDigit(* newdigit) ;
164 // Noise induced by the PIN diode of the PbWO crystals
166 Float_t energyandnoise ;
167 for ( i = 0 ; i < fNdigits ; i++ ) {
168 newdigit = (AliPHOSDigit * ) fDigits->At(i) ;
169 fGeom->AbsToRelNumbering(newdigit->GetId(), relid) ;
171 if (relid[1]==0){ // Digits belong to EMC (PbW0_4 crystals)
172 energyandnoise = newdigit->GetAmp() + Digitize(gRandom->Gaus(0., fPinElectronicNoise)) ;
174 if (energyandnoise < 0 )
177 if ( newdigit->GetAmp() < fDigitThreshold ) // if threshold not surpassed, remove digit from list
178 fDigits->RemoveAt(i) ;
182 fDigits->Compress() ;
184 fNdigits = fDigits->GetEntries() ;
185 for (i = 0 ; i < fNdigits ; i++) {
186 newdigit = (AliPHOSDigit *) fDigits->At(i) ;
187 newdigit->SetIndexInList(i) ;