#include <MdcAlignAlg.h>
Public Member Functions | |
StatusCode | execute () |
StatusCode | execute () |
StatusCode | finalize () |
StatusCode | finalize () |
StatusCode | initialize () |
StatusCode | initialize () |
MdcAlignAlg (const std::string &name, ISvcLocator *pSvcLocator) | |
MdcAlignAlg (const std::string &name, ISvcLocator *pSvcLocator) | |
Private Member Functions | |
void | initParam () |
void | initParam () |
Private Attributes | |
std::string | m_alignFile |
int | m_alignMeth |
MdcAlignPar * | m_alignPar |
MdcAlignPar * | m_alignPar |
std::string | m_configFile |
bool | m_distAlign |
int | m_evtType |
std::string | m_fixMomLab |
int | m_flgKalFit |
std::string | m_histname |
TObjArray * | m_hlist |
TObjArray * | m_hlist |
double | m_mag |
MdcAliEvent * | m_mdcevt |
MdcAliEvent * | m_mdcevt |
IMdcCalibFunSvc * | m_mdcFunSvc |
IMdcCalibFunSvc * | m_mdcFunSvc |
IMdcGeomSvc * | m_mdcGeomSvc |
IMdcGeomSvc * | m_mdcGeomSvc |
int | m_nEvt |
int | m_nEvtDisp |
MdcAlign * | m_pAlign |
MdcAlign * | m_pAlign |
MdcAliParams | m_param |
|
00021 : 00022 Algorithm(name, pSvcLocator), m_alignMeth(0), m_flgKalFit(0){ 00023 00024 m_distAlign = false; 00025 m_configFile = "MdcCalibConfig.txt"; 00026 m_fixMomLab = "fixMom_lab.txt"; 00027 m_nEvt = 0; 00028 m_mag = 1.0; 00029 00030 //declare properties 00031 declareProperty("DistAlign", m_distAlign); 00032 declareProperty("MdcAlignMeth", m_alignMeth); 00033 declareProperty("UseKalFit", m_flgKalFit); 00034 declareProperty("MagneticField", m_mag); 00035 declareProperty("AlignFile", m_alignFile); 00036 declareProperty("HistFile", m_histname); 00037 declareProperty("ConfigFile", m_configFile); 00038 declareProperty("FixMomLab", m_fixMomLab); 00039 declareProperty("NumEvtDisplay", m_nEvtDisp); 00040 }
|
|
|
|
|
|
00153 { 00154 MsgStream log(msgSvc(), name()); 00155 log << MSG::DEBUG << "MdcAlignAlg execute()" << endreq; 00156 00157 // display event number for debug 00158 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader"); 00159 if (!eventHeader) { 00160 log << MSG::FATAL << "Could not find Event Header" << endreq; 00161 return( StatusCode::FAILURE); 00162 } 00163 int iEvt = eventHeader->eventNumber(); 00164 if(0 == (m_nEvt % m_nEvtDisp)) std::cout << "Event " << m_nEvt << ", Event number online " << iEvt << endl; 00165 m_nEvt++; 00166 00167 // get reconstruction result 00168 if(m_flgKalFit) m_mdcevt -> setKalEvent(); 00169 else m_mdcevt -> setRecEvent(); 00170 00171 if (!(m_pAlign->fillHist(m_mdcevt))) { 00172 m_mdcevt->clear(); 00173 return(StatusCode::SUCCESS); 00174 } 00175 m_mdcevt->clear(); 00176 00177 return StatusCode::SUCCESS; 00178 }
|
|
|
|
00181 { 00182 MsgStream log(msgSvc(), name()); 00183 log << MSG::INFO << "MdcAlignAlg finalize()" << endreq; 00184 00185 if( ! m_distAlign ){ 00186 // execute calibration and write new calibration data file 00187 m_pAlign -> updateConst(m_alignPar); 00188 m_alignPar -> wrtAlignPar(); 00189 } 00190 00191 TFile* fhist = new TFile(m_histname.c_str(), "recreate"); 00192 m_hlist -> Write(); 00193 00194 m_pAlign -> clear(); 00195 delete m_pAlign; 00196 std::cout << "m_pAlign deleted" << std::endl; 00197 00198 delete m_alignPar; 00199 std::cout << "m_alignPar deleted" << std::endl; 00200 00201 delete m_mdcevt; 00202 std::cout << "m_mdcevt deleted" << std::endl; 00203 00204 delete m_hlist; 00205 std::cout << "m_hlist deleted" << std::endl; 00206 00207 fhist->Close(); 00208 delete fhist; 00209 cout << m_histname << " was written" << endl; 00210 00211 if( ! m_distAlign ){ 00212 std::ofstream fend("endalign.out"); 00213 fend << "MdcAlign end." << std::endl; 00214 fend.close(); 00215 } 00216 00217 std::cout << "MdcAlignAlg End." << std::endl; 00218 00219 return StatusCode::SUCCESS; 00220 }
|
|
|
|
00044 { 00045 MsgStream log( msgSvc(), name() ); 00046 log << MSG::INFO << "MdcAlignAlg initialze() ..." << endreq; 00047 log << MSG::INFO << "MdcAlignFlg = " << m_alignMeth << endreq; 00048 00049 StatusCode sc = service("MdcGeomSvc", m_mdcGeomSvc); 00050 if(sc != StatusCode::SUCCESS){ 00051 log << MSG::ERROR << "can not use MdcGeomSvc" << endreq; 00052 } 00053 00054 sc = service("MdcCalibFunSvc", m_mdcFunSvc); 00055 if( sc != StatusCode::SUCCESS ){ 00056 log << MSG::FATAL << "can not use MdcCalibFunSvc" << endreq; 00057 } 00058 00059 // initialize m_param 00060 initParam(); 00061 00062 // read mdc config parameters 00063 int i; 00064 std::string strconfig; 00065 std::string strcomment; 00066 std::string strTes; 00067 int fgTes[50]; 00068 for(i=0; i<50; i++) fgTes[i] = -999; 00069 ifstream fconfig( m_configFile.c_str() ); 00070 if( ! fconfig.is_open() ){ 00071 log << MSG::WARNING << "can not open config file " << m_configFile 00072 << ". Use defalt config parameters" << endreq; 00073 } else { 00074 log << MSG::INFO << "Open config file " << m_configFile << endreq; 00075 while( fconfig >> strconfig ){ 00076 if('#' == strconfig[0]){ 00077 getline(fconfig, strcomment); 00078 } else if("EsTimeFlag" == strconfig){ 00079 getline(fconfig, strTes); 00080 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", 00081 fgTes+0, fgTes+1, fgTes+2, fgTes+3, fgTes+4, 00082 fgTes+5, fgTes+6, fgTes+7, fgTes+8, fgTes+9, 00083 fgTes+10, fgTes+11, fgTes+12, fgTes+13, fgTes+14, 00084 fgTes+15, fgTes+16, fgTes+17, fgTes+18, fgTes+19); 00085 for(i=0; i<n; i++) m_param.esFlag[i] = fgTes[i]; 00086 m_param.nEsFlag = n; 00087 } else if("TesMin" == strconfig){ 00088 fconfig >> m_param.tesMin; 00089 } else if("TesMax" == strconfig){ 00090 fconfig >> m_param.tesMax; 00091 } else if("ResidualType" == strconfig){ 00092 fconfig >> m_param.resiType; 00093 } else if("FlagAdjacLayerCut" == strconfig){ 00094 fconfig >> m_param.fgAdjacLayerCut; 00095 } else if("FlagBoundLayerCut" == strconfig){ 00096 fconfig >> m_param.fgBoundLayerCut; 00097 } else if("hitStatCut" == strconfig){ 00098 fconfig >> m_param.hitStatCut; 00099 } else if("nTrkCut" == strconfig){ 00100 fconfig >> m_param.nTrkCut[0] >> m_param.nTrkCut[1]; 00101 } else if("nHitLayCut" == strconfig){ 00102 fconfig >> m_param.nHitLayCut; 00103 } else if("nHitCut" == strconfig){ 00104 fconfig >> m_param.nHitCut; 00105 } else if("cosThetaCut" == strconfig){ 00106 fconfig >> m_param.costheCut[0] >> m_param.costheCut[1]; 00107 } else if("DrCut" == strconfig){ 00108 fconfig >> m_param.drCut; 00109 } else if("DzCut" == strconfig){ 00110 fconfig >> m_param.dzCut; 00111 } else if("MaximalDocaInner" == strconfig){ 00112 fconfig >> m_param.maxDocaInner; 00113 }else if("MaximalDocaOuter" == strconfig){ 00114 fconfig >> m_param.maxDocaOuter; 00115 }else if("MaximalResidual" == strconfig){ 00116 fconfig >> m_param.maxResi; 00117 } 00118 } 00119 fconfig.close(); 00120 } 00121 00122 // set event type 00123 m_param.particle = m_evtType; 00124 00125 cout << "EsFlag for Mdc Alignment: "; 00126 for(int iEs=0; iEs<m_param.nEsFlag; iEs++) cout << setw(6) << m_param.esFlag[iEs]; 00127 cout << endl; 00128 00129 if(fabs(m_mag) > 0.01) Alignment::gFlagMag = true; 00130 else Alignment::gFlagMag = false; 00131 00132 m_alignPar = new MdcAlignPar(); 00133 m_alignPar -> rdAlignPar(m_alignFile); 00134 00135 m_mdcevt = new MdcAliEvent(); 00136 m_mdcevt -> setParam(m_param); 00137 00138 m_hlist = new TObjArray(); 00139 00140 if( 0 == m_alignMeth ){ 00141 m_pAlign = new ResiAlign(); 00142 } else if( 1 == m_alignMeth ){ 00143 m_pAlign = new MilleAlign(); 00144 m_pAlign->fixMomLab = m_fixMomLab; 00145 } 00146 m_pAlign->setParam(m_param); 00147 m_pAlign -> initialize(m_hlist, m_mdcGeomSvc, m_mdcFunSvc); 00148 00149 return StatusCode::SUCCESS; 00150 }
|
|
|
|
00222 { 00223 m_param.particle = 0; 00224 m_param.nEsFlag = 0; 00225 for(int i=0; i<50; i++) m_param.esFlag[i] = -999; 00226 m_param.tesMin = 0.0; 00227 m_param.tesMax = 9999.0; 00228 m_param.resiType = 0; 00229 m_param.fgAdjacLayerCut = 0; 00230 m_param.fgBoundLayerCut = 0; 00231 m_param.hitStatCut = 0; 00232 m_param.nTrkCut[0] = 2; 00233 m_param.nTrkCut[1] = 2; 00234 m_param.nHitLayCut = 35; 00235 m_param.nHitCut = 70; 00236 m_param.costheCut[0] = -1.0; 00237 m_param.costheCut[1] = 1.0; 00238 m_param.drCut = 50.0; // mm 00239 m_param.dzCut = 300.0; // mm 00240 m_param.maxDocaInner = 8.0; // mm 00241 m_param.maxDocaOuter = 12.0; // mm 00242 m_param.maxResi = 1.0; // mm 00243 00244 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|