BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcRecShowerEnergy.cxx
Go to the documentation of this file.
1
2#include "EmcRec/EmcRecShowerEnergy.h"
3#include "EmcRec/EmcRecNeighbor.h"
4#include "EmcRec/EmcRecParameter.h"
5
7 RecEmcFractionMap::const_iterator cit;
9 RecEmcEnergy e9 = 0;
10 RecEmcEnergy e25 = 0;
11 RecEmcEnergy elepton = 0;
12 RecEmcEnergy eall = 0;
13
15
16 RecEmcID CellId = aShower.getShowerId();
17 int module = EmcID::barrel_ec( CellId );
18 RecEmcIDVector NearCell = nhb.GetNeighbors( CellId );
19 RecEmcIDVector NextNearCell = nhb.GetNextNeighbors( CellId );
20 RecEmcIDVector tmpNearCell;
21 RecEmcIDVector tmpNextNearCell;
22 i_RecEmcIDVector pNearCell;
23 i_RecEmcIDVector pNextNearCell;
24 vector<RecEmcEnergy> eVec;
25 vector<RecEmcEnergy>::const_iterator ciVec;
26
27 tmpNearCell.push_back( CellId );
28 tmpNextNearCell.push_back( CellId );
29
30 cit = aShower.Find( CellId );
31 // int time_seed = cit->second.getTime();
32 e1 = ( cit->second.getEnergy() ) * ( cit->second.getFraction() );
33 e9 += ( cit->second.getEnergy() ) * ( cit->second.getFraction() );
34 e25 += ( cit->second.getEnergy() ) * ( cit->second.getFraction() );
35
36 // e3x3
37 for ( pNearCell = NearCell.begin(); pNearCell != NearCell.end(); pNearCell++ )
38 {
39 cit = aShower.Find( *pNearCell );
40 if ( cit != aShower.End() )
41 {
42 tmpNearCell.push_back( *pNearCell );
43 tmpNextNearCell.push_back( *pNearCell );
44 e9 += cit->second.getEnergy() * cit->second.getFraction();
45 e25 += cit->second.getEnergy() * cit->second.getFraction();
46 }
47 }
48
49 // e5x5
50 for ( pNextNearCell = NextNearCell.begin(); pNextNearCell != NextNearCell.end();
51 pNextNearCell++ )
52 {
53 cit = aShower.Find( *pNextNearCell );
54 if ( cit != aShower.End() )
55 {
56 tmpNextNearCell.push_back( *pNextNearCell );
57 e25 += cit->second.getEnergy() * cit->second.getFraction();
58 }
59 }
60
61 // eall
62 for ( cit = aShower.Begin(); cit != aShower.End(); ++cit )
63 {
64 eall += ( cit->second.getEnergy() ) * ( cit->second.getFraction() );
65 eVec.push_back( cit->second.getEnergy() * cit->second.getFraction() );
66 }
67
68 // calculate number of hits from MC
69 int nHit, n;
71 nHit = (int)( Para.HitNb( 0 ) * log( Para.HitNb( 1 ) * e9 + Para.HitNb( 2 ) ) );
72 n = 0;
73
74 // sort by energy
75 sort( eVec.begin(), eVec.end(), greater<RecEmcEnergy>() );
76
77 for ( ciVec = eVec.begin(); ciVec != eVec.end(); ciVec++ )
78 {
79 if ( n < nHit )
80 {
81 elepton += *ciVec;
82 n++;
83 }
84 }
85
86 // energy correction
87 // RecEmcEnergy eCorr=ECorrTheta(e25,CellId);
88 // RecEmcEnergy eCorr=ECorrection(e25);
89 int getthetaid = EmcID::theta_module( CellId );
90 int getmodule = EmcID::barrel_ec( CellId );
91 if ( getthetaid > 21 ) getthetaid = 43 - getthetaid;
92 if ( getmodule == 1 ) getthetaid = getthetaid + 6;
93 double dthetaid = double( getthetaid );
94 double eCorr = Para.ECorrMC( e25, dthetaid );
95
96 // energy error
97 RecEmcEnergy de, de1, de2, de3;
98 de1 = Para.SigE( 0 ) / eCorr;
99 de2 = Para.SigE( 1 ) / pow( eCorr, 0.25 );
100 de3 = Para.SigE( 2 );
101 de = sqrt( de1 * de1 + de2 * de2 + de3 * de3 ) * perCent * eCorr;
102
103 double err = Para.ErrMC( e25, dthetaid );
104 if ( err > 0 ) de = err * e25;
105
106 aShower.setTrackId( -1 );
107 aShower.setCellId( CellId );
108 aShower.setModule( module );
109 aShower.setNumHits( aShower.getSize() );
110 aShower.setDE( de );
111 aShower.CellId3x3( tmpNearCell );
112 aShower.CellId5x5( tmpNextNearCell );
113 aShower.setESeed( e1 );
114 aShower.setE3x3( e9 );
115 aShower.setE5x5( e25 );
116 aShower.ELepton( elepton );
117 aShower.EAll( eall );
118 aShower.setEnergy( eCorr );
119
120 // cout<<"e1="<<aShower.eSeed()
121 // <<"\te9="<<aShower.e3x3()
122 // <<"\te25="<<aShower.e5x5()
123 // <<"\telepton="<<aShower.getELepton()
124 // <<"\teall="<<aShower.getEAll()
125 // <<"\tenergy="<<aShower.energy()<<endl;
126}
127
129 if ( eIn > 3. ) return eIn;
130
132
133 RecEmcEnergy eOut = 0;
134 double par[4];
135 for ( int i = 0; i < 4; i++ ) { par[i] = Para.ECorr( i ); }
136
137 eOut = eIn / ( par[0] + par[1] * eIn + par[2] * eIn * eIn + par[3] * eIn * eIn * eIn );
138 return eOut;
139}
140
143 RecEmcEnergy eOut = eIn;
144
145 unsigned int npart = EmcID::barrel_ec( id );
146 unsigned int ntheta = EmcID::theta_module( id );
147
148 if ( npart == 1 ) { eOut *= 1.843 / Para.Peak( ntheta ); }
149 else if ( npart == 0 ) { eOut *= 1.843 / Para.Peak( ntheta + 44 ); }
150 else if ( npart == 2 ) { eOut *= 1.843 / Para.Peak( ntheta + 50 ); }
151
152 return eOut;
153}
const Int_t n
Double_t e1
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0).
Definition EmcID.cxx:36
static unsigned int theta_module(const Identifier &id)
Definition EmcID.cxx:41
RecEmcIDVector GetNeighbors(const Identifier &id)
RecEmcIDVector GetNextNeighbors(const Identifier &id)
double ECorr(int n) const
double SigE(int n) const
double ECorrMC(double eg, double theid) const
static EmcRecParameter & GetInstance()
double HitNb(int n) const
double Peak(int n) const
double ErrMC(double eg, double theid) const
RecEmcEnergy ECorrection(const RecEmcEnergy eIn)
RecEmcEnergy ECorrTheta(const RecEmcEnergy eIn, const RecEmcID &id)
void Energy(RecEmcShower &aShower)
RecEmcFractionMap::const_iterator End() const
void CellId3x3(RecEmcIDVector &id3x3)
RecEmcEnergy EAll(RecEmcEnergy e)
RecEmcEnergy ELepton(RecEmcEnergy e)
RecEmcFractionMap::const_iterator Begin() const
RecEmcFractionMap::const_iterator Find(const RecEmcID &CellId) const
unsigned int getSize() const
void CellId5x5(RecEmcIDVector &id5x5)