BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcRecSplitWeighted Class Reference

#include <EmcRecSplitWeighted.h>

Inheritance diagram for EmcRecSplitWeighted:

Public Member Functions

 EmcRecSplitWeighted ()
 ~EmcRecSplitWeighted ()
virtual void Split (RecEmcCluster &aCluster, const RecEmcIDVector &aMaxVec, RecEmcShowerMap &aShowerMap)
 EmcRecSplitWeighted ()
 ~EmcRecSplitWeighted ()
virtual void Split (RecEmcCluster &aCluster, const RecEmcIDVector &aMaxVec, RecEmcShowerMap &aShowerMap)
 EmcRecSplitWeighted ()
 ~EmcRecSplitWeighted ()
virtual void Split (RecEmcCluster &aCluster, const RecEmcIDVector &aMaxVec, RecEmcShowerMap &aShowerMap)
Public Member Functions inherited from EmcRecSplitAbs
 EmcRecSplitAbs ()
virtual ~EmcRecSplitAbs ()
virtual void Split (RecEmcCluster &aCluster, const RecEmcIDVector &aMaxVec, RecEmcShowerMap &aShowerMap)=0
 EmcRecSplitAbs ()
virtual ~EmcRecSplitAbs ()
virtual void Split (RecEmcCluster &aCluster, const RecEmcIDVector &aMaxVec, RecEmcShowerMap &aShowerMap)=0
 EmcRecSplitAbs ()
virtual ~EmcRecSplitAbs ()
virtual void Split (RecEmcCluster &aCluster, const RecEmcIDVector &aMaxVec, RecEmcShowerMap &aShowerMap)=0

Public Attributes

EmcRecShowerEnergyfShowerE
EmcRecShowerPosAbsfShowerPos
EmcRecShowerShapefShowerShape

Detailed Description

Constructor & Destructor Documentation

◆ EmcRecSplitWeighted() [1/3]

EmcRecSplitWeighted::EmcRecSplitWeighted ( )

Definition at line 23 of file EmcRecSplitWeighted.cxx.

23 {
24 fShowerE = new EmcRecShowerEnergy;
25 fShowerShape = new EmcRecShowerShape;
26
27 EmcRecParameter& Para = EmcRecParameter::GetInstance();
28 // if(Para.PositionMode1()=="lin") {
29 // fShowerPos=new EmcRecShowerPosLin;
30 // } else {
31 // fShowerPos=new EmcRecShowerPosLog;
32 // }
33
34 if ( Para.PositionMode1() == "lin" ) { fShowerPos = new EmcRecShowerPosLin; }
35 else if ( Para.PositionMode1() == "log" ) { fShowerPos = new EmcRecShowerPosLog; }
36 else if ( Para.PositionMode1() == "loglin" ) { fShowerPos = new EmcRecShowerPosLoglin; }
37 else if ( Para.PositionMode1() == "linsh" ) { fShowerPos = new EmcRecShowerPosLinShMax; }
38 else if ( Para.PositionMode1() == "logsh" ) { fShowerPos = new EmcRecShowerPosLogShMax; }
39}
static EmcRecParameter & GetInstance()

◆ ~EmcRecSplitWeighted() [1/3]

EmcRecSplitWeighted::~EmcRecSplitWeighted ( )

Definition at line 41 of file EmcRecSplitWeighted.cxx.

41 {
42 delete fShowerE;
43 delete fShowerPos;
44 delete fShowerShape;
45}

◆ EmcRecSplitWeighted() [2/3]

EmcRecSplitWeighted::EmcRecSplitWeighted ( )

◆ ~EmcRecSplitWeighted() [2/3]

EmcRecSplitWeighted::~EmcRecSplitWeighted ( )

◆ EmcRecSplitWeighted() [3/3]

EmcRecSplitWeighted::EmcRecSplitWeighted ( )

◆ ~EmcRecSplitWeighted() [3/3]

EmcRecSplitWeighted::~EmcRecSplitWeighted ( )

Member Function Documentation

◆ Split() [1/3]

void EmcRecSplitWeighted::Split ( RecEmcCluster & aCluster,
const RecEmcIDVector & aMaxVec,
RecEmcShowerMap & aShowerMap )
virtual

Definition at line 47 of file EmcRecSplitWeighted.cxx.

48 {
49 // A exponential function will be used to describe the shape of a shower.
50 // Energy fall off with distance from centre of shower is exp(-a*dist/r)
51 // dist: distance from center
52 // r: moliere radius
53 // a: a parameter, needed to be optimised
54 EmcRecParameter& Para = EmcRecParameter::GetInstance();
55
56 // Calculate the cut of second moment
57 double eCluster = aCluster.getEnergy();
58 double cut = 0;
59 if ( eCluster > Para.SmCut( 3 ) )
60 { cut = Para.SmCut( 0 ) * exp( -( eCluster ) / Para.SmCut( 1 ) ) + Para.SmCut( 2 ); }
61 else
62 {
63 cut = Para.SmCut( 0 ) * exp( -( Para.SmCut( 3 ) ) / Para.SmCut( 1 ) ) +
64 Para.SmCut( 2 ); // constant
65 }
66 cut /= 10;
67
68 RecEmcShower aShower;
69 RecEmcHit aHit;
70 RecEmcFraction aFraction;
71 RecEmcHitMap::const_iterator ciHitMap;
72 if ( aMaxVec.size() == 0 )
73 {
74 // the cluster is abandoned
75 }
76
77 // only one seed or second moment belows cut
78 else if ( aMaxVec.size() == 1 || aMaxVec.size() > 20 || aCluster.getSecondMoment() < cut )
79 {
80 aShower.Clear();
81 aShower.setStatus( 1 );
82 // ID
83 aShower.ShowerId( aMaxVec[0] );
84 aShower.ClusterId( aCluster.getClusterId() );
85 aCluster.InsertShowerId( aMaxVec[0] );
86 // each fraction
87 double time = aCluster.Find( aMaxVec[0] )->second.getTime();
88 if ( time >= Para.TimeMin() && time <= Para.TimeMax() )
89 {
90 for ( ciHitMap = aCluster.Begin(); ciHitMap != aCluster.End(); ++ciHitMap )
91 {
92 aHit = ciHitMap->second;
93 // if((aHit.time()>=Para.TimeMin()) &&
94 //(aHit.time()<=Para.TimeMax())){
95 aFraction = aHit;
96 aFraction.Fraction( 1 );
97 aShower.Insert( aFraction );
98 //}
99 }
100
101 aShower.setTime( time );
102 fShowerE->Energy( aShower );
103 fShowerPos->Position( aShower );
104 fShowerShape->CalculateMoment( aShower );
105 aShower.ThetaGap( 9 );
106 aShower.PhiGap( 9 );
107 // push it into map
108 aShowerMap[aMaxVec[0]] = aShower;
109 }
110 }
111
112 // two or more seeds and second moment beyonds cut
113 else if ( aMaxVec.size() > 1 && aMaxVec.size() <= 20 && aCluster.getSecondMoment() > cut )
114 {
115 // cout<<"In EmcRecSplitWeighted: ";
116 // cout<<aMaxVec.size();
117 // cout<<" seeds in a cluster"<<endl;
118
119 RecEmcCluster tmpCluster = aCluster;
120 RecEmcHitMap::const_iterator ci_HitMap;
121 ci_RecEmcIDVector ciMax, ciMax1;
122 ;
123 RecEmcShower aShower;
124 RecEmcShowerMap tmpShowerMap;
125 RecEmcShowerMap::iterator i_ShowerMap, i2_ShowerMap;
126
127 RecEmcFraction aFrac;
128 unsigned int iterations = 0; // iteration time
129 double centroidShift; // center shift between 2 iterations
130 map<RecEmcID, HepPoint3D, less<RecEmcID>> showerCentroid; // shower center
131 map<RecEmcID, HepPoint3D, less<RecEmcID>>::const_iterator ci_showerCentroid;
132
133 IEmcRecGeoSvc* iGeoSvc;
134 ISvcLocator* svcLocator = Gaudi::svcLocator();
135 StatusCode sc = svcLocator->service( "EmcRecGeoSvc", iGeoSvc );
136 if ( sc != StatusCode::SUCCESS )
137 {
138 // cout<<"Error: Can't get EmcRecGeoSvc"<<endl;
139 }
140
141 // Preparation
142 for ( ciMax = aMaxVec.begin(); ciMax != aMaxVec.end(); ++ciMax )
143 {
144 // initialize: seed's front center
145 showerCentroid[*ciMax] = iGeoSvc->GetCFrontCenter( *ciMax );
146 }
147 do {
148 centroidShift = 0.;
149 tmpShowerMap.clear();
150 for ( ciMax = aMaxVec.begin(); ciMax != aMaxVec.end(); ++ciMax )
151 {
152 double weightTotal = 0., weight = 0.;
153
154 aShower.Clear();
155 aShower.ShowerId( *ciMax );
156
157 // figure out the weight for each cell for each seed
158 for ( ci_HitMap = tmpCluster.Begin(); ci_HitMap != tmpCluster.End(); ++ci_HitMap )
159 {
160
161 aFrac = ci_HitMap->second;
162 double aDistance = 0;
163 RecEmcEnergy aESeed = 0;
164
165 bool isSeed = false;
166 for ( ciMax1 = aMaxVec.begin(); ciMax1 != aMaxVec.end(); ++ciMax1 )
167 {
168 HepPoint3D seedPoint( showerCentroid[*ciMax1] );
169 HepPoint3D hitPoint( iGeoSvc->GetCFrontCenter( aFrac.getCellId() ) );
170
171 RecEmcEnergy theESeed = tmpCluster.Find( *ciMax1 )->second.getEnergy();
172 double theDistance;
173 if ( *ciMax1 == aFrac.getCellId() )
174 {
175 isSeed = true;
176 theDistance = 0.;
177 }
178 else { theDistance = ( hitPoint - seedPoint ).mag(); }
179
180 if ( *ciMax1 == *ciMax )
181 {
182 aDistance = theDistance;
183 aESeed = theESeed;
184 }
185
186 weightTotal +=
187 theESeed * exp( -Para.LateralProfile() * theDistance / Para.MoliereRadius() );
188 }
189
190 weight = aESeed * exp( -Para.LateralProfile() * aDistance / Para.MoliereRadius() ) /
191 weightTotal;
192 aFrac.Fraction( weight );
193 // if((aFrac.time()>=Para.TimeMin() &&
194 // aFrac.time()<=Para.TimeMax()) ||
195 // isSeed) {
196 if ( aFrac.getEnergy() * aFrac.getFraction() > Para.ElectronicsNoiseLevel() )
197 { aShower.Insert( aFrac ); }
198 //}
199 weightTotal = 0;
200 }
201
202 fShowerE->Energy( aShower );
203 fShowerPos->Position( aShower );
204 HepPoint3D newCentroid( aShower.position() );
205 HepPoint3D oldCentroid( showerCentroid[*ciMax] );
206 centroidShift += ( newCentroid - oldCentroid ).mag();
207 tmpShowerMap[aShower.getShowerId()] = aShower;
208 showerCentroid[*ciMax] = newCentroid;
209 }
210
211 centroidShift /= (double)aMaxVec.size();
212 for ( ci_showerCentroid = showerCentroid.begin();
213 ci_showerCentroid != showerCentroid.end(); ci_showerCentroid++ )
214 {
215 showerCentroid[ci_showerCentroid->first] =
216 tmpShowerMap[ci_showerCentroid->first].position();
217 }
218 iterations++;
219 // cout<<"iterations: "<<iterations<<"\tcentroidShift: "<<centroidShift<<endl;
220 } while ( ( iterations < 8 ) && ( centroidShift > 0.01 ) );
221
222 unsigned int tht, phi;
223 unsigned int tht2, phi2;
224 unsigned int dtht, dphi;
225 unsigned int thetagap = 0, phigap = 0;
226 double distmin, dist;
227 RecEmcID id, id2, nearest;
228 // shower attributes
229 for ( i_ShowerMap = tmpShowerMap.begin(); i_ShowerMap != tmpShowerMap.end();
230 ++i_ShowerMap )
231 {
232 aCluster.InsertShowerId( i_ShowerMap->second.getShowerId() );
233 i_ShowerMap->second.ClusterId( aCluster.getClusterId() );
234 i_ShowerMap->second.setStatus( 2 );
235 fShowerE->Energy( i_ShowerMap->second );
236 fShowerPos->Position( i_ShowerMap->second );
237 fShowerShape->CalculateMoment( i_ShowerMap->second );
238 //
239 // min theta, phi gap
240 id = ( i_ShowerMap->second ).getShowerId();
241 tht = EmcID::theta_module( id );
242 phi = EmcID::phi_module( id );
243 distmin = 999999;
244 for ( i2_ShowerMap = tmpShowerMap.begin(); i2_ShowerMap != tmpShowerMap.end();
245 ++i2_ShowerMap )
246 {
247 id2 = ( i2_ShowerMap->second ).getShowerId();
248 tht2 = EmcID::theta_module( id2 );
249 phi2 = EmcID::phi_module( id2 );
250 if ( id != id2 )
251 {
252 dtht = tht > tht2 ? tht - tht2 : tht2 - tht;
253 dphi = phi > phi2 ? phi - phi2 : phi2 - phi;
254 if ( dphi > ( EmcID::getPHI_BARREL_MAX() + 1 ) / 2 )
255 dphi = EmcID::getPHI_BARREL_MAX() + 1 - dphi;
256 dist = sqrt( double( dtht * dtht + dphi * dphi ) );
257 if ( dist < distmin )
258 {
259 distmin = dist;
260 nearest = id2;
261 if ( dtht > 6 ) dtht = 6;
262 if ( dphi > 6 ) dphi = 6;
263 thetagap = dtht;
264 phigap = dphi;
265 }
266 }
267 }
268 // cout<<"+++++"<<id<<" "<<thetagap<<" "<<phigap<<endl;
269 i_ShowerMap->second.NearestSeed( nearest );
270 i_ShowerMap->second.ThetaGap( thetagap );
271 i_ShowerMap->second.PhiGap( phigap );
272
273 // save it
274 double time =
275 i_ShowerMap->second.Find( i_ShowerMap->second.getShowerId() )->second.getTime();
276 if ( time >= Para.TimeMin() && time <= Para.TimeMax() &&
277 ( i_ShowerMap->second.getEAll() > Para.EThresholdCluster() ) )
278 {
279 i_ShowerMap->second.setTime( time );
280 aShowerMap[i_ShowerMap->first] = i_ShowerMap->second;
281 }
282 }
283 tmpShowerMap.clear();
284 }
285}
HepGeom::Point3D< double > HepPoint3D
Double_t phi2
Double_t time
RecEmcIDVector::const_iterator ci_RecEmcIDVector
map< RecEmcID, RecEmcShower, less< RecEmcID > > RecEmcShowerMap
EvtComplex exp(const EvtComplex &c)
*********Class see also m_nmax DOUBLE PRECISION m_MasPhot DOUBLE PRECISION m_phsu DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_r2 DOUBLE PRECISION m_WtMass INTEGER m_nmax INTEGER m_Nevgen INTEGER m_IsFSR INTEGER m_MarTot *COMMON c_KarFin $ !Output file $ !Event serial number $ !alpha QED at Thomson limit $ !minimum energy at CMS for remooval $ !infrared cut
Definition KarFin.h:27
*********Class see also m_nmax DOUBLE PRECISION m_MasPhot DOUBLE PRECISION m_phsu DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_r2 DOUBLE PRECISION m_WtMass INTEGER m_nmax INTEGER m_Nevgen INTEGER m_IsFSR INTEGER m_MarTot *COMMON c_KarFin $ !Output file $ !Event serial number $ !alpha QED at Thomson limit $ !minimum energy at CMS for remooval $ !infrared dimensionless $ !dummy photon IR regulator $ !crude photon multiplicity enhancement factor *EVENT $ !MC crude volume of PhhSpace *Sfactors $ !YFS formfactor IR part only $ !YFS formfactor non IR finite part $ !mass weight
Definition KarFin.h:34
static unsigned int getPHI_BARREL_MAX()
Definition EmcID.cxx:83
static unsigned int theta_module(const Identifier &id)
Definition EmcID.cxx:41
static unsigned int phi_module(const Identifier &id)
Definition EmcID.cxx:46
double EThresholdCluster() const
double ElectronicsNoiseLevel() const
double LateralProfile() const
double TimeMax() const
double MoliereRadius() const
double TimeMin() const
double SmCut(int n) const
virtual HepPoint3D GetCFrontCenter(const Identifier &id) const =0
RecEmcEnergy getEnergy() const
RecEmcHitMap::const_iterator Find(const RecEmcID &CellId) const
double getSecondMoment() const
RecEmcHitMap::const_iterator Begin() const
RecEmcHitMap::const_iterator End() const
void InsertShowerId(const RecEmcID id)
RecEmcFrac Fraction(const RecEmcFrac &Fraction)
RecEmcFrac getFraction() const
void ClusterId(const RecEmcID id)
RecEmcID ShowerId(RecEmcID id)
int ThetaGap() const
void Insert(const RecEmcFraction &aFraction)
int PhiGap() const

◆ Split() [2/3]

virtual void EmcRecSplitWeighted::Split ( RecEmcCluster & aCluster,
const RecEmcIDVector & aMaxVec,
RecEmcShowerMap & aShowerMap )
virtual

◆ Split() [3/3]

virtual void EmcRecSplitWeighted::Split ( RecEmcCluster & aCluster,
const RecEmcIDVector & aMaxVec,
RecEmcShowerMap & aShowerMap )
virtual

Member Data Documentation

◆ fShowerE

◆ fShowerPos

◆ fShowerShape

EmcRecShowerShape * EmcRecSplitWeighted::fShowerShape

The documentation for this class was generated from the following files: