BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
DigammaPreSelect.cxx
Go to the documentation of this file.
1#include "GaudiKernel/AlgFactory.h"
2#include "GaudiKernel/IDataProviderSvc.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/PropertyMgr.h"
6#include "GaudiKernel/SmartDataPtr.h"
7
8#include "EventModel/Event.h"
9#include "EventModel/EventHeader.h"
10#include "EventModel/EventModel.h"
11#include "EvtRecEvent/EvtRecEvent.h"
12#include "EvtRecEvent/EvtRecTrack.h"
13
14#include "CLHEP/Vector/LorentzVector.h"
15#include "CLHEP/Vector/ThreeVector.h"
16#include "CLHEP/Vector/TwoVector.h"
17#include "GaudiKernel/Bootstrap.h"
18#include "GaudiKernel/IHistogramSvc.h"
19#include "GaudiKernel/INTupleSvc.h"
20#include "GaudiKernel/NTuple.h"
21#include "MdcRawEvent/MdcDigi.h"
22#include "TMath.h"
23using CLHEP::Hep2Vector;
24using CLHEP::Hep3Vector;
25using CLHEP::HepLorentzVector;
26#include "CLHEP/Geometry/Point3D.h"
27#ifndef ENABLE_BACKWARDS_COMPATIBILITY
28typedef HepGeom::Point3D<double> HepPoint3D;
29#endif
31int selected = 0;
32
33#include <vector>
34
35typedef std::vector<int> Vint;
36typedef std::vector<HepLorentzVector> Vp4;
37const double PI = 3.1415927;
38const double EBeam = 1.548; // temporary
39/////////////////////////////////////////////////////////////////////////////
41DigammaPreSelect::DigammaPreSelect( const std::string& name, ISvcLocator* pSvcLocator )
42 : Algorithm( name, pSvcLocator ) {
43
44 // Declare the properties
45
46 declareProperty( "Vr0cut", m_vr0cut = 1.0 ); // suggest cut: |z0|<5cm && r0<1cm
47 declareProperty( "Vz0cut", m_vz0cut = 5.0 );
48
49 declareProperty( "lowEnergyShowerCut", m_lowEnergyShowerCut = 0.1 );
50 declareProperty( "highEnergyShowerCut", m_highEnergyShowerCut = 0.5 );
51 declareProperty( "matchThetaCut", m_matchThetaCut = 0.2 );
52 declareProperty( "matchPhiCut", m_matchPhiCut = 0.2 );
53
54 declareProperty( "highMomentumCut", m_highMomentumCut = 0.5 );
55 declareProperty( "EoPMaxCut", m_EoPMaxCut = 1.3 );
56 declareProperty( "EoPMinCut", m_EoPMinCut = 0.6 );
57 declareProperty( "minAngShEnergyCut", m_minAngShEnergyCut = 0.2 );
58 declareProperty( "minAngCut", m_minAngCut = 0.3 );
59 declareProperty( "acolliCut", m_acolliCut = 0.03 );
60 declareProperty( "eNormCut", m_eNormCut = 0.5 );
61 declareProperty( "pNormCut", m_pNormCut = 0.5 );
62 declareProperty( "BarrelOrEndcap", m_BarrelOrEndcap = 1 );
63 declareProperty( "Output", m_output = false );
64 declareProperty( "oneProngMomentumCut", m_oneProngMomentumCut = 1.2 );
65}
66
67// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
69 MsgStream log( msgSvc(), name() );
70
71 log << MSG::INFO << "in initialize()" << endmsg;
72
73 if ( m_output )
74 {
75 StatusCode status;
76 NTuplePtr nt1( ntupleSvc(), "FILE1/bhabha" );
77 if ( nt1 ) m_tuple1 = nt1;
78 else
79 {
80 m_tuple1 = ntupleSvc()->book( "FILE1/bhabha", CLID_ColumnWiseTuple, "N-Tuple example" );
81 if ( m_tuple1 )
82 {
83 status = m_tuple1->addItem( "sh1_ene", m_sh1_ene );
84 status = m_tuple1->addItem( "sh1_theta", m_sh1_theta );
85 status = m_tuple1->addItem( "sh1_phi", m_sh1_phi );
86 status = m_tuple1->addItem( "sh2_ene", m_sh2_ene );
87 status = m_tuple1->addItem( "sh2_theta", m_sh2_theta );
88 status = m_tuple1->addItem( "sh2_phi", m_sh2_phi );
89 status = m_tuple1->addItem( "di_phi", m_di_phi );
90 status = m_tuple1->addItem( "di_the", m_di_the );
91 status = m_tuple1->addItem( "acolli", m_acolli );
92 status = m_tuple1->addItem( "mdc_hit", m_mdc_hit );
93 status = m_tuple1->addItem( "etot", m_etot );
94 }
95 else
96 {
97 log << MSG::ERROR << " Cannot book N-tuple:" << long( m_tuple1 ) << endmsg;
98 return StatusCode::FAILURE;
99 }
100 }
101
102 NTuplePtr nt2( ntupleSvc(), "FILE1/bha1" );
103 if ( nt2 ) m_tuple2 = nt2;
104 else
105 {
106 m_tuple2 = ntupleSvc()->book( "FILE1/bha1", CLID_ColumnWiseTuple, "N-Tuple example" );
107 if ( m_tuple2 )
108 {
109 status = m_tuple2->addItem( "sh_ene", m_sh_ene );
110 status = m_tuple2->addItem( "sh_theta", m_sh_theta );
111 status = m_tuple2->addItem( "sh_phi", m_sh_phi );
112 }
113 else
114 {
115 log << MSG::ERROR << " Cannot book N-tuple:" << long( m_tuple2 ) << endmsg;
116 return StatusCode::FAILURE;
117 }
118 }
119 }
120
121 //
122 //--------end of book--------
123 //
124
125 m_rejected = 0;
126 m_events = 0;
127 m_oneProngsSelected = 0;
128 m_twoProngsMatchedSelected = 0;
129 m_twoProngsOneMatchedSelected = 0;
130 m_selectedTrkID1 = 999;
131 m_selectedTrkID2 = 999;
132
133 log << MSG::INFO << "successfully return from initialize()" << endmsg;
134 return StatusCode::SUCCESS;
135}
136
137// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
139
140 setFilterPassed( false );
141
142 MsgStream log( msgSvc(), name() );
143 log << MSG::INFO << "in execute()" << endmsg;
144
145 m_events++;
146
147 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
148 if ( !eventHeader )
149 {
150 cout << " eventHeader " << endl;
151 return StatusCode::FAILURE;
152 }
153
154 int run = eventHeader->runNumber();
155 int event = eventHeader->eventNumber();
156 if ( event % 1000 == 0 ) cout << " run,event: " << run << "," << event << endl;
157
158 SmartDataPtr<EvtRecEvent> evtRecEvent( eventSvc(), EventModel::EvtRec::EvtRecEvent );
159 if ( !evtRecEvent )
160 {
161 cout << " evtRecEvent " << endl;
162 return StatusCode::FAILURE;
163 }
164
165 log << MSG::DEBUG << "ncharg, nneu, tottks = " << evtRecEvent->totalCharged() << " , "
166 << evtRecEvent->totalNeutral() << " , " << evtRecEvent->totalTracks() << endmsg;
167 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol( eventSvc(), EventModel::EvtRec::EvtRecTrackCol );
168 if ( !evtRecTrkCol )
169 {
170 cout << " evtRecTrkCol " << endl;
171 return StatusCode::FAILURE;
172 }
173
174 Vint iGood;
175 iGood.clear();
176
177 double ene5x5, theta, phi, eseed;
178 double showerX, showerY, showerZ;
179 long int thetaIndex, phiIndex;
180
181 RecEmcID showerId;
182 unsigned int npart;
183
184 Vint ipip, ipim;
185 ipip.clear();
186 ipim.clear();
187 Vp4 ppip, ppim;
188 ppip.clear();
189 ppim.clear();
190
191 vector<RecEmcShower*> GoodShowers;
192 GoodShowers.clear();
193 double etot = 0;
194 for ( int i = 0; i < evtRecEvent->totalTracks(); i++ )
195 {
196 if ( i >= evtRecTrkCol->size() ) break;
197 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
198 if ( ( *itTrk )->isEmcShowerValid() )
199 {
200 RecEmcShower* theShower = ( *itTrk )->emcShower();
201 etot += theShower->e5x5();
202 showerId = theShower->getShowerId();
203 npart = EmcID::barrel_ec( showerId );
204 ene5x5 = theShower->e5x5();
205 thetaIndex = EmcID::theta_module( showerId );
206 phiIndex = EmcID::phi_module( showerId );
207 if ( ene5x5 > 0.4 && ene5x5 < 4 && npart == 1 && ( m_BarrelOrEndcap == 1 ) )
208 {
209 GoodShowers.push_back( theShower );
210 iGood.push_back( ( *itTrk )->trackId() );
211 }
212 else if ( ene5x5 > 0.4 && ene5x5 < 4 && ( npart == 2 || npart == 0 ) &&
213 ( m_BarrelOrEndcap == 2 ) )
214 {
215 GoodShowers.push_back( theShower );
216 iGood.push_back( ( *itTrk )->trackId() );
217 }
218 else if ( ene5x5 > 0.4 && ene5x5 < 4 && ( m_BarrelOrEndcap == 0 ) )
219 {
220 GoodShowers.push_back( theShower );
221 iGood.push_back( ( *itTrk )->trackId() );
222 }
223 }
224 // good photon cut will be set here
225 }
226 // Finish Good Photon Selection
227 //
228
229 double MaxE( 0 ), MaxPhi, MaxThe;
230 int MaxId;
231 double SecE( 0 ), SecPhi, SecThe;
232 for ( int i = 0; i < GoodShowers.size(); i++ )
233 {
234 RecEmcShower* theShower = GoodShowers[i];
235 double eraw = theShower->energy();
236 if ( eraw > MaxE )
237 {
238 MaxId = i;
239 MaxE = eraw;
240 MaxPhi = theShower->phi();
241 MaxThe = theShower->theta();
242 }
243 }
244 for ( int i = 0; i < GoodShowers.size(); i++ )
245 {
246 RecEmcShower* theShower = GoodShowers[i];
247 double eraw = theShower->energy();
248 if ( i != MaxId && eraw > SecE )
249 {
250 SecE = eraw;
251 SecPhi = theShower->phi();
252 SecThe = theShower->theta();
253 }
254 }
255
256 double dphi = ( fabs( MaxPhi - SecPhi ) - PI ) * 180. / PI;
257 double dthe = ( fabs( MaxThe + SecThe ) - PI ) * 180. / PI;
258 if ( GoodShowers.size() >= 2 && SecE > 1.0 && dphi > -4 && dphi < 2 && abs( dthe ) < 3 &&
259 etot > 2.7 )
260 {
261 setFilterPassed( true );
262 selected++;
263 }
264
265 if ( m_output )
266 {
267 m_etot = etot;
268 m_sh1_ene = MaxE;
269 m_sh1_theta = MaxThe;
270 m_sh1_phi = MaxPhi;
271 m_sh2_ene = SecE;
272 m_sh2_theta = SecThe;
273 m_sh2_phi = SecPhi;
274 m_di_phi = dphi;
275 m_di_the = dthe;
276 m_tuple1->write();
277 }
278
279 return StatusCode::SUCCESS;
280}
281
282// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
284
285 MsgStream log( msgSvc(), name() );
286 log << MSG::INFO << "in finalize()" << endmsg;
287 cout << "total events: " << m_events << endl;
288 cout << "selected digamma: " << selected << endl;
289
290 return StatusCode::SUCCESS;
291}
DECLARE_COMPONENT(BesBdkRc)
int selected
const double EBeam
HepGeom::Point3D< double > HepPoint3D
Double_t etot
EvtRecTrackCol::iterator EvtRecTrackIterator
#define PI
std::vector< HepLorentzVector > Vp4
Definition Gam4pikp.cxx:38
std::vector< int > Vint
Definition Gam4pikp.cxx:37
INTupleSvc * ntupleSvc()
IMessageSvc * msgSvc()
DigammaPreSelect(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize()
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
static unsigned int phi_module(const Identifier &id)
Definition EmcID.cxx:46