BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
BFieldCorr.cxx
Go to the documentation of this file.
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/Event.h"
13#include "GaudiKernel/INTupleSvc.h"
14#include "GaudiKernel/NTuple.h"
15#include "GaudiKernel/Bootstrap.h"
16#include "GaudiKernel/IHistogramSvc.h"
17#include "CLHEP/Vector/ThreeVector.h"
18#include "CLHEP/Vector/LorentzVector.h"
19#include "CLHEP/Vector/TwoVector.h"
20#include "CLHEP/Geometry/Point3D.h"
22
24
25#include "CLHEP/Matrix/Vector.h"
26#include "CLHEP/Vector/LorentzVector.h"
27#include "CLHEP/Vector/ThreeVector.h"
28#include "CLHEP/Matrix/SymMatrix.h"
29#include "CLHEP/Matrix/Matrix.h"
30using CLHEP::HepVector;
31using CLHEP::HepLorentzVector;
32using CLHEP::Hep3Vector;
33using CLHEP::HepMatrix;
34using CLHEP::HepSymMatrix;
35
36#include "CLHEP/Geometry/Point3D.h"
37#ifndef ENABLE_BACKWARDS_COMPATIBILITY
39#endif
40
41#include <cmath>
42#include <vector>
43using namespace std;
44
45DECLARE_COMPONENT(BFieldCorr)
46BFieldCorr::BFieldCorr(const std::string& name, ISvcLocator* pSvcLocator):Algorithm(name,pSvcLocator)
47{
48 declareProperty("CorrectionFactor", m_factor = 1.0000);
49}
50
52{
53 m_Ew = HepSymMatrix(5, 0);
54 m_Ew[0][0] = 1.0;
55 m_Ew[1][1] = 1.0;
56 m_Ew[2][2] = fabs(m_factor) < 1e-6 ? 1.0 : 1.0 / m_factor;
57 m_Ew[3][3] = 1.0;
58 m_Ew[4][4] = 1.0;
59 RUN_BEGIN_10 = 11414;
60 RUN_END_10 = 14604;
61 RUN_BEGIN_11 = 20448;
62 RUN_END_11 = 23454;
63
64 MsgStream log(msgSvc(), name());
65 log << MSG::INFO << "in MagCorr::initialize()" <<endmsg;
66 return StatusCode::SUCCESS;
67}
68
70{
71 MsgStream log(msgSvc(), name());
72 log << MSG::INFO << "in BFieldCorr::execute()" << endreq;
73 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
74 int run_no = eventHeader->runNumber();
75 if (run_no < 0) return StatusCode::SUCCESS;
76
77 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc(), EventModel::EvtRec::EvtRecEvent);
78 if (!evtRecEvent)
79 {
80 log << MSG::FATAL << "Could not find EvtRecEvent" << endreq;
81 return StatusCode::SUCCESS;
82 }
83
84 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol(eventSvc(), EventModel::EvtRec::EvtRecTrackCol);
85 if (!evtRecTrkCol)
86 {
87 log << MSG::FATAL << "Could not find EvtRecTrackCol" << endreq;
88 return StatusCode::SUCCESS;
89 }
90
91 if ((unsigned int)evtRecEvent->totalTracks() > evtRecTrkCol->size()) return StatusCode::SUCCESS;
92 //if (evtRecEvent->totalTracks() > 50) return StatusCode::SUCCESS;
93
94 //set Ew if by default
95 double factor;
96 if (fabs(m_factor - 1.000) < 1e-6)
97 {
98 if (run_no >= RUN_BEGIN_10 && run_no <= RUN_END_10)
99 factor = 1.0004;
100 else if (run_no >= RUN_BEGIN_11 && run_no <= RUN_END_11)
101 factor = 1.0002;
102 else
103 factor = 1.0000;
104 }
105 else
106 {
107 factor = m_factor;
108 }
109 m_Ew[2][2] = fabs(factor) < 1e-6 ? 1.0 : 1.0 / factor;
110
111 for (int i = 0; i < evtRecEvent->totalCharged(); i++)
112 {
113 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
114 if (!(*itTrk)->isMdcTrackValid()) continue;
115 if (!(*itTrk)->isMdcKalTrackValid()) continue;
116
117 //RecMdcTrack correction
118 RecMdcTrack *mdc_trk = (*itTrk)->mdcTrack();
119 mdc_trk->setHelix( m_Ew * mdc_trk->helix() );
120 mdc_trk->setError( mdc_trk->err().similarity(m_Ew) );
121 mdc_trk->setP( factor * mdc_trk->p() );
122 mdc_trk->setPxy( factor * mdc_trk->pxy() );
123 mdc_trk->setPx( factor * mdc_trk->px() );
124 mdc_trk->setPy( factor * mdc_trk->py() );
125 mdc_trk->setPz( factor * mdc_trk->pz() );
126
127 //RecMdcKalTrack correction
128 RecMdcKalTrack *kal_trk = (*itTrk)->mdcKalTrack();
129 RecMdcKalTrack::PidType trk_type[] = {
135 };
136
137 for (int j = 0; j < 5; j++)
138 {
139 kal_trk->setPidType( trk_type[j] );
140 kal_trk->setZHelix( m_Ew * kal_trk->helix(), j );
141 kal_trk->setZError( kal_trk->err().similarity(m_Ew), j );
142 kal_trk->setP( factor * kal_trk->p(), j );
143 kal_trk->setPxy( factor * kal_trk->pxy(), j );
144 kal_trk->setPx( factor * kal_trk->px(), j );
145 kal_trk->setPy( factor * kal_trk->py(), j );
146 kal_trk->setPz( factor * kal_trk->pz(), j );
147 }
148 }
149 return StatusCode::SUCCESS;
150}
151
153{
154 MsgStream log(msgSvc(), name());
155 log << MSG::INFO << "in BFieldCorr::finalize()" << endreq;
156 return StatusCode::SUCCESS;
157}
HepGeom::Point3D< double > HepPoint3D
EvtRecTrackCol::iterator EvtRecTrackIterator
IMessageSvc * msgSvc()
StatusCode finalize()
StatusCode initialize()
StatusCode execute()
void setPz(const double pz, const int pid)
const HepVector & helix() const
void setZError(const HepSymMatrix &error, const int pid)
void setP(const double p, const int pid)
void setPx(const double px, const int pid)
const double px() const
void setPxy(const double pxy, const int pid)
void setPy(const double py, const int pid)
static void setPidType(PidType pidType)
const double pz() const
void setZHelix(const HepVector &helix, const int pid)
const double py() const
const double p() const
const HepSymMatrix & err() const
const double pxy() const
void setPxy(const double pxy)
Definition DstMdcTrack.h:84
const double py() const
Definition DstMdcTrack.h:56
void setPy(const double py)
Definition DstMdcTrack.h:86
const HepSymMatrix err() const
void setError(double err[15])
const double px() const
Definition DstMdcTrack.h:55
void setP(const double p)
Definition DstMdcTrack.h:88
void setHelix(double helix[5])
const double pz() const
Definition DstMdcTrack.h:57
const double pxy() const
Definition DstMdcTrack.h:54
const HepVector helix() const
......
void setPz(const double pz)
Definition DstMdcTrack.h:87
const double p() const
Definition DstMdcTrack.h:58
void setPx(const double px)
Definition DstMdcTrack.h:85
_EXTERN_ std::string EvtRecEvent
Definition EventModel.h:116
_EXTERN_ std::string EvtRecTrackCol
Definition EventModel.h:117