4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/StatusCode.h"
6#include "EventModel/EventHeader.h"
8#include "MdcAlignAlg/MdcAlignAlg.h"
9#include "MdcAlignAlg/ResiAlign.h"
10#include "MdcAlignAlg/MilleAlign.h"
22 Algorithm(name, pSvcLocator), m_alignMeth(0), m_flgKalFit(0){
25 m_configFile =
"MdcCalibConfig.txt";
26 m_fixMomLab =
"fixMom_lab.txt";
31 declareProperty(
"DistAlign", m_distAlign);
32 declareProperty(
"MdcAlignMeth", m_alignMeth);
33 declareProperty(
"UseKalFit", m_flgKalFit);
34 declareProperty(
"MagneticField", m_mag);
35 declareProperty(
"AlignFile", m_alignFile);
36 declareProperty(
"HistFile", m_histname);
37 declareProperty(
"ConfigFile", m_configFile);
38 declareProperty(
"FixMomLab", m_fixMomLab);
39 declareProperty(
"NumEvtDisplay", m_nEvtDisp);
45 MsgStream log(
msgSvc(), name() );
46 log << MSG::INFO <<
"MdcAlignAlg initialze() ..." << endreq;
47 log << MSG::INFO <<
"MdcAlignFlg = " << m_alignMeth << endreq;
49 StatusCode sc = service(
"MdcGeomSvc", m_mdcGeomSvc);
50 if(sc != StatusCode::SUCCESS){
51 log << MSG::ERROR <<
"can not use MdcGeomSvc" << endreq;
54 sc = service(
"MdcCalibFunSvc", m_mdcFunSvc);
55 if( sc != StatusCode::SUCCESS ){
56 log << MSG::FATAL <<
"can not use MdcCalibFunSvc" << endreq;
64 std::string strconfig;
65 std::string strcomment;
68 for(i=0; i<50; i++) fgTes[i] = -999;
69 ifstream fconfig( m_configFile.c_str() );
70 if( ! fconfig.is_open() ){
71 log << MSG::WARNING <<
"can not open config file " << m_configFile
72 <<
". Use defalt config parameters" << endreq;
74 log << MSG::INFO <<
"Open config file " << m_configFile << endreq;
75 while( fconfig >> strconfig ){
76 if(
'#' == strconfig[0]){
77 getline(fconfig, strcomment);
78 }
else if(
"EsTimeFlag" == strconfig){
79 getline(fconfig, strTes);
80 int n = sscanf(strTes.c_str(),
"%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d",
81 fgTes+0, fgTes+1, fgTes+2, fgTes+3, fgTes+4,
82 fgTes+5, fgTes+6, fgTes+7, fgTes+8, fgTes+9,
83 fgTes+10, fgTes+11, fgTes+12, fgTes+13, fgTes+14,
84 fgTes+15, fgTes+16, fgTes+17, fgTes+18, fgTes+19);
85 for(i=0; i<
n; i++) m_param.
esFlag[i] = fgTes[i];
87 }
else if(
"TesMin" == strconfig){
89 }
else if(
"TesMax" == strconfig){
91 }
else if(
"ResidualType" == strconfig){
93 }
else if(
"FlagAdjacLayerCut" == strconfig){
95 }
else if(
"FlagBoundLayerCut" == strconfig){
97 }
else if(
"hitStatCut" == strconfig){
99 }
else if(
"nTrkCut" == strconfig){
101 }
else if(
"nHitLayCut" == strconfig){
103 }
else if(
"nHitCut" == strconfig){
105 }
else if(
"ptCut" == strconfig){
106 fconfig >> m_param.
ptCut[0] >> m_param.
ptCut[1];
107 }
else if(
"cosThetaCut" == strconfig){
109 }
else if(
"DrCut" == strconfig){
110 fconfig >> m_param.
drCut;
111 }
else if(
"DzCut" == strconfig){
112 fconfig >> m_param.
dzCut;
113 }
else if(
"MaximalDocaInner" == strconfig){
115 }
else if(
"MaximalDocaOuter" == strconfig){
117 }
else if(
"MaximalResidual" == strconfig){
127 cout <<
"EsFlag for Mdc Alignment: ";
128 for(
int iEs=0; iEs<m_param.
nEsFlag; iEs++) cout << setw(6) << m_param.
esFlag[iEs];
135 m_alignPar -> rdAlignPar(m_alignFile);
138 m_mdcevt -> setParam(m_param);
140 m_hlist =
new TObjArray();
142 if( 0 == m_alignMeth ){
144 }
else if( 1 == m_alignMeth ){
149 m_pAlign ->
initialize(m_hlist, m_mdcGeomSvc, m_mdcFunSvc);
151 return StatusCode::SUCCESS;
156 MsgStream log(
msgSvc(), name());
157 log << MSG::DEBUG <<
"MdcAlignAlg execute()" << endreq;
160 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
162 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
163 return( StatusCode::FAILURE);
165 int iEvt = eventHeader->eventNumber();
166 if(0 == (m_nEvt % m_nEvtDisp)) std::cout <<
"Event " << m_nEvt <<
", Event number online " << iEvt << endl;
170 if(m_flgKalFit) m_mdcevt -> setKalEvent();
171 else m_mdcevt -> setRecEvent();
173 if (!(m_pAlign->
fillHist(m_mdcevt))) {
175 return(StatusCode::SUCCESS);
179 return StatusCode::SUCCESS;
184 MsgStream log(
msgSvc(), name());
185 log << MSG::INFO <<
"MdcAlignAlg finalize()" << endreq;
189 m_pAlign -> updateConst(m_alignPar);
190 m_alignPar -> wrtAlignPar();
193 TFile* fhist =
new TFile(m_histname.c_str(),
"recreate");
198 std::cout <<
"m_pAlign deleted" << std::endl;
201 std::cout <<
"m_alignPar deleted" << std::endl;
204 std::cout <<
"m_mdcevt deleted" << std::endl;
207 std::cout <<
"m_hlist deleted" << std::endl;
211 cout << m_histname <<
" was written" << endl;
214 std::ofstream fend(
"endalign.out");
215 fend <<
"MdcAlign end." << std::endl;
219 std::cout <<
"MdcAlignAlg End." << std::endl;
221 return StatusCode::SUCCESS;
224void MdcAlignAlg::initParam(){
227 for(
int i=0; i<50; i++) m_param.
esFlag[i] = -999;
238 m_param.
ptCut[0] = 0.0;
239 m_param.
ptCut[1] = 100.0;
242 m_param.
drCut = 50.0;
243 m_param.
dzCut = 300.0;
MdcAlignAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual void setParam(MdcAliParams ¶m)=0
virtual bool fillHist(MdcAliEvent *event)=0