00001 #include "GaudiKernel/MsgStream.h"
00002 #include "GaudiKernel/AlgFactory.h"
00003 #include "GaudiKernel/SmartDataPtr.h"
00004 #include "GaudiKernel/IDataProviderSvc.h"
00005 #include "GaudiKernel/PropertyMgr.h"
00006
00007 #include "EventModel/EventModel.h"
00008 #include "EventModel/Event.h"
00009 #include "EventModel/EventHeader.h"
00010 #include "EvtRecEvent/EvtRecEvent.h"
00011 #include "EvtRecEvent/EvtRecTrack.h"
00012
00013 #include "TMath.h"
00014 #include "GaudiKernel/INTupleSvc.h"
00015 #include "GaudiKernel/NTuple.h"
00016 #include "GaudiKernel/Bootstrap.h"
00017 #include "GaudiKernel/IHistogramSvc.h"
00018 #include "CLHEP/Vector/ThreeVector.h"
00019 #include "CLHEP/Vector/LorentzVector.h"
00020 #include "CLHEP/Vector/TwoVector.h"
00021 #include "EmcRawEvent/EmcDigi.h"
00022 #include "RawEvent/RawDataUtil.h"
00023 #include "MdcRawEvent/MdcDigi.h"
00024
00025 #include "GaudiKernel/Bootstrap.h"
00026 #include "GaudiKernel/ISvcLocator.h"
00027 using CLHEP::Hep3Vector;
00028 using CLHEP::Hep2Vector;
00029 using CLHEP::HepLorentzVector;
00030 #include "CLHEP/Geometry/Point3D.h"
00031 #ifndef ENABLE_BACKWARDS_COMPATIBILITY
00032 typedef HepGeom::Point3D<double> HepPoint3D;
00033 #endif
00034
00035 #include "DTagSkim/DTagSkim.h"
00036
00037 #include <vector>
00038 #include "mysql.h"
00039
00040
00042
00043 DTagSkim::DTagSkim(const std::string& name, ISvcLocator* pSvcLocator) :
00044 Algorithm(name, pSvcLocator) {
00045
00046 declareProperty("WriteDst", m_ifwritedst=true);
00047 declareProperty("WriteRec", m_ifwriterec=false);
00048 }
00049
00050
00051 StatusCode DTagSkim::initialize() {
00052 MsgStream log(msgSvc(), name());
00053
00054 log << MSG::INFO << "in initialize()" << endmsg;
00055 StatusCode sc;
00056
00057 log << MSG::INFO << "creating sub-algorithms...." << endreq;
00058
00059
00060 sc = createSubAlgorithm( "EventWriter", "WriteDst", m_subalg1);
00061 if( sc.isFailure() ) {
00062 log << MSG::ERROR << "Error creating Sub-Algorithm WriteDst" <<endreq;
00063 return sc;
00064 } else {
00065 log << MSG::INFO << "Success creating Sub-Algorithm WriteDst" <<endreq;
00066 }
00067
00068
00069
00070 sc = createSubAlgorithm( "EventWriter", "WriteRec", m_subalg2);
00071 if( sc.isFailure() ) {
00072 log << MSG::ERROR << "Error creating Sub-Algorithm WriteRec" <<endreq;
00073 return sc;
00074 } else {
00075 log << MSG::INFO << "Success creating Sub-Algorithm WriteRec" <<endreq;
00076 }
00077
00078
00079
00080 log << MSG::INFO << "successfully return from initialize()" <<endmsg;
00081 return StatusCode::SUCCESS;
00082
00083 }
00084
00085
00086 StatusCode DTagSkim::execute() {
00087 MsgStream log(msgSvc(), name());
00088 log << MSG::INFO << "in execute()" << endreq;
00089
00090
00091 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
00092 if(!eventHeader)
00093 {
00094 cout<<" eventHeader "<<endl;
00095 return StatusCode::FAILURE;
00096 }
00097
00098 int run=eventHeader->runNumber();
00099 int event=eventHeader->eventNumber();
00100
00101
00102 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc(), EventModel::EvtRec::EvtRecEvent);
00103 if(!evtRecEvent ) {
00104 cout<<" evtRecEvent "<<endl;
00105 return StatusCode::FAILURE;
00106 }
00107
00108
00109 log << MSG::DEBUG <<"ncharg, nneu, tottks = "
00110 << evtRecEvent->totalCharged() << " , "
00111 << evtRecEvent->totalNeutral() << " , "
00112 << evtRecEvent->totalTracks() <<endreq;
00113 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol(eventSvc(), EventModel::EvtRec::EvtRecTrackCol);
00114 if(!evtRecTrkCol){
00115 cout<<" evtRecTrkCol "<<endl;
00116 return StatusCode::FAILURE;
00117 }
00118
00119 if(evtRecEvent->totalTracks()!=evtRecTrkCol->size()) return StatusCode::SUCCESS;
00120
00121
00122 SmartDataPtr<EvtRecDTagCol> evtRecDTagCol(eventSvc(), EventModel::EvtRec::EvtRecDTagCol);
00123 if ( ! evtRecDTagCol ) {
00124 log << MSG::FATAL << "Could not find EvtRecDTagCol" << endreq;
00125 return StatusCode::FAILURE;
00126 }
00127
00128
00129 if(evtRecDTagCol->size()==0){
00130
00131 return StatusCode::SUCCESS;
00132 }
00133
00134
00135
00136
00137
00138 if(m_ifwritedst) m_subalg1->execute();
00139 if(m_ifwriterec) m_subalg2->execute();
00140
00141
00142 return StatusCode::SUCCESS;
00143
00144 }
00145
00146
00147 StatusCode DTagSkim::finalize() {
00148
00149 MsgStream log(msgSvc(), name());
00150 log << MSG::INFO << "in finalize()" << endmsg;
00151
00152
00153 return StatusCode::SUCCESS;
00154 }
00155