1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/AlgFactory.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/SmartDataPtr.h"
5#include "GaudiKernel/IDataProviderSvc.h"
6#include "GaudiKernel/PropertyMgr.h"
8#include "EventModel/EventModel.h"
9#include "EventModel/Event.h"
10#include "EventModel/EventHeader.h"
11#include "EvtRecEvent/EvtRecEvent.h"
12#include "EvtRecEvent/EvtRecTrack.h"
15#include "GaudiKernel/INTupleSvc.h"
16#include "GaudiKernel/NTuple.h"
17#include "GaudiKernel/Bootstrap.h"
18#include "GaudiKernel/IHistogramSvc.h"
19#include "CLHEP/Vector/ThreeVector.h"
20#include "CLHEP/Vector/LorentzVector.h"
21#include "CLHEP/Vector/TwoVector.h"
22#include "MdcRawEvent/MdcDigi.h"
23using CLHEP::Hep3Vector;
24using CLHEP::Hep2Vector;
25using CLHEP::HepLorentzVector;
26#include "CLHEP/Geometry/Point3D.h"
27#ifndef ENABLE_BACKWARDS_COMPATIBILITY
30#include "DigammaPreSelect/DigammaPreSelect.h"
35typedef std::vector<int>
Vint;
36typedef std::vector<HepLorentzVector>
Vp4;
37const double PI = 3.1415927;
42 Algorithm(name, pSvcLocator) {
46 declareProperty (
"Vr0cut", m_vr0cut=1.0);
47 declareProperty (
"Vz0cut", m_vz0cut=5.0);
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);
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);
70 MsgStream log(
msgSvc(), name());
72 log << MSG::INFO <<
"in initialize()" << endmsg;
76 NTuplePtr nt1(
ntupleSvc(),
"FILE1/bhabha");
77 if ( nt1 ) m_tuple1 = nt1;
79 m_tuple1 =
ntupleSvc()->book (
"FILE1/bhabha", CLID_ColumnWiseTuple,
"N-Tuple example");
81 status = m_tuple1->addItem (
"sh1_ene",m_sh1_ene);
82 status = m_tuple1->addItem (
"sh1_theta", m_sh1_theta);
83 status = m_tuple1->addItem (
"sh1_phi", m_sh1_phi);
84 status = m_tuple1->addItem (
"sh2_ene",m_sh2_ene);
85 status = m_tuple1->addItem (
"sh2_theta", m_sh2_theta);
86 status = m_tuple1->addItem (
"sh2_phi", m_sh2_phi);
87 status = m_tuple1->addItem (
"di_phi", m_di_phi);
88 status = m_tuple1->addItem (
"di_the", m_di_the);
89 status = m_tuple1->addItem (
"acolli", m_acolli);
90 status = m_tuple1->addItem (
"mdc_hit", m_mdc_hit);
91 status = m_tuple1->addItem (
"etot", m_etot);
95 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple1) << endmsg;
96 return StatusCode::FAILURE;
101 NTuplePtr nt2(
ntupleSvc(),
"FILE1/bha1");
102 if ( nt2 ) m_tuple2 = nt2;
104 m_tuple2 =
ntupleSvc()->book (
"FILE1/bha1", CLID_ColumnWiseTuple,
"N-Tuple example");
106 status = m_tuple2->addItem (
"sh_ene",m_sh_ene);
107 status = m_tuple2->addItem (
"sh_theta", m_sh_theta);
108 status = m_tuple2->addItem (
"sh_phi", m_sh_phi);
111 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple2) << endmsg;
112 return StatusCode::FAILURE;
124 m_oneProngsSelected=0;
125 m_twoProngsMatchedSelected=0;
126 m_twoProngsOneMatchedSelected=0;
127 m_selectedTrkID1=999;
128 m_selectedTrkID2=999;
130 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
131 return StatusCode::SUCCESS;
138 setFilterPassed(
false);
140 MsgStream log(
msgSvc(), name());
141 log << MSG::INFO <<
"in execute()" << endreq;
145 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
148 cout<<
" eventHeader "<<endl;
149 return StatusCode::FAILURE;
152 int run=eventHeader->runNumber();
153 int event=eventHeader->eventNumber();
154 if(event%1000==0) cout<<
" run,event: "<<run<<
","<<
event<<endl;
158 cout<<
" evtRecEvent "<<endl;
159 return StatusCode::FAILURE;
162 log << MSG::DEBUG <<
"ncharg, nneu, tottks = "
163 << evtRecEvent->totalCharged() <<
" , "
164 << evtRecEvent->totalNeutral() <<
" , "
165 << evtRecEvent->totalTracks() <<endreq;
168 cout<<
" evtRecTrkCol "<<endl;
169 return StatusCode::FAILURE;
175 double ene5x5,theta,phi,eseed;
176 double showerX,showerY,showerZ;
177 long int thetaIndex,phiIndex;
189 vector<RecEmcShower* > GoodShowers;
192 for(
int i = 0; i< evtRecEvent->totalTracks(); i++) {
193 if(i>=evtRecTrkCol->size())
break;
195 if((*itTrk)->isEmcShowerValid()) {
200 ene5x5=theShower->
e5x5();
203 if (ene5x5>0.4&&ene5x5<4&&npart==1&&(m_BarrelOrEndcap==1)){
204 GoodShowers.push_back(theShower);
205 iGood.push_back((*itTrk)->trackId());
207 else if (ene5x5>0.4&&ene5x5<4&&(npart==2||npart==0)&&(m_BarrelOrEndcap==2)){
208 GoodShowers.push_back(theShower);
209 iGood.push_back((*itTrk)->trackId());
211 else if (ene5x5>0.4&&ene5x5<4&&(m_BarrelOrEndcap==0)){
212 GoodShowers.push_back(theShower);
213 iGood.push_back((*itTrk)->trackId());
221 double MaxE(0), MaxPhi, MaxThe;
223 double SecE(0), SecPhi, SecThe;
224 for(
int i=0; i<GoodShowers.size(); i++) {
226 double eraw = theShower->
energy();
230 MaxPhi = theShower->
phi();
231 MaxThe = theShower->
theta();
234 for(
int i=0; i<GoodShowers.size(); i++) {
236 double eraw = theShower->
energy();
237 if(i!=MaxId&&eraw>SecE) {
239 SecPhi = theShower->
phi();
240 SecThe = theShower->
theta();
244 double dphi = (fabs(MaxPhi-SecPhi)-
PI)*180./
PI;
245 double dthe = (fabs(MaxThe+SecThe)-
PI)*180./
PI;
246 if(GoodShowers.size()>=2&&SecE>1.0&&dphi>-4&&dphi<2&&
abs(dthe)<3&&
etot>2.7) {
247 setFilterPassed(
true);
254 m_sh1_theta = MaxThe;
257 m_sh2_theta = SecThe;
264 return StatusCode::SUCCESS;
271 MsgStream log(
msgSvc(), name());
272 log << MSG::INFO <<
"in finalize()" << endmsg;
273 cout<<
"total events: "<<m_events<<endl;
274 cout<<
"selected digamma: "<<
selected<<endl;
276 return StatusCode::SUCCESS;
HepGeom::Point3D< double > HepPoint3D
std::vector< HepLorentzVector > Vp4
EvtRecTrackCol::iterator EvtRecTrackIterator
std::vector< HepLorentzVector > Vp4
DigammaPreSelect(const std::string &name, ISvcLocator *pSvcLocator)
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0)
static unsigned int theta_module(const Identifier &id)
static unsigned int phi_module(const Identifier &id)
void clear()
Reset to invalid state.
RecEmcID getShowerId() const
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol