CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
CgemAlignAlg Class Reference

#include <CgemAlignAlg.h>

+ Inheritance diagram for CgemAlignAlg:

Public Member Functions

 CgemAlignAlg (const std::string &name, ISvcLocator *pSvcLocator)
 
 ~CgemAlignAlg ()
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 

Detailed Description

Definition at line 21 of file CgemAlignAlg.h.

Constructor & Destructor Documentation

◆ CgemAlignAlg()

CgemAlignAlg::CgemAlignAlg ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 24 of file CgemAlignAlg.cxx.

24 :
25 Algorithm(name, pSvcLocator){
26
27 m_histname = "NULL";
28 m_initAlignParFlg = false;
29
30 declareProperty("AlignMethod", m_alignMethod);
31 declareProperty("Event", m_evtType);
32 declareProperty("HistOutput", m_histname);
33 declareProperty("ConfigFile", m_configFile);
34 declareProperty("AlignFile", m_alignFile);
35 declareProperty("NumEvtDisplay", m_nEvtDisp);
36 declareProperty("EventStart", EventStart=0);
37 declareProperty("EventEnd", EventEnd=1E10);
38 // declareProperty("CombineCosmic", m_combCosmic = false);
39 }

◆ ~CgemAlignAlg()

CgemAlignAlg::~CgemAlignAlg ( )

Definition at line 41 of file CgemAlignAlg.cxx.

41 {
42
43 std::ofstream fend("endAlign.out");
44 fend << "CgemAlign end." << std::endl;
45 fend.close();
46
47 std::cout << "CgemAlignAlg End." << std::endl;
48}

Member Function Documentation

◆ execute()

StatusCode CgemAlignAlg::execute ( )

Definition at line 143 of file CgemAlignAlg.cxx.

143 {
144 MsgStream log(msgSvc(), name());
145 log << MSG::INFO << "CgemAlignAlg execute()" << endreq;
146
147 // display event number for debug
148 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
149 if (!eventHeader) {
150 log << MSG::FATAL << "Could not find Event Header" << endreq;
151 return( StatusCode::FAILURE);
152 }
153 int iRun = eventHeader->runNumber();
154 int iEvt = eventHeader->eventNumber();
155 if(0 == (m_nEvt % m_nEvtDisp)){
156 std::cout << "Run " << iRun << ", Event " << iEvt << ", Total Event number " << m_nEvt << endl;
157 }
158
159 if(m_nEvt<EventStart||m_nEvt>EventEnd)
160 {
161 cout<<"Skim the event!!"<<endl;
162 m_nEvt++;
163 return StatusCode::SUCCESS;
164 }
165 else
166 {
167
168 if( ! m_initAlignParFlg ){
169 m_initAlignParFlg = true;
170 }
171
172 m_cgemevt -> setRecEvent();
173
174 if (!(m_align->fillHist(m_cgemevt, m_alignPar))) {
175 m_cgemevt->clear();
176 return(StatusCode::SUCCESS);
177 }
178 m_cgemevt->clear();
179
180 m_nEvt++;
181 return StatusCode::SUCCESS;
182 }
183
184}
IMessageSvc * msgSvc()
virtual bool fillHist(CgemAliEvent *event, CgemAlignPar *alignPar)=0

◆ finalize()

StatusCode CgemAlignAlg::finalize ( )

Definition at line 186 of file CgemAlignAlg.cxx.

186 {
187 MsgStream log(msgSvc(), name());
188 log << MSG::INFO << "CgemAlignAlg finalize()" << endreq;
189
190 m_align->updateAlignPar(m_alignPar);
191 m_alignPar->wrtAlignPar();
192
193 // write histogram file
194 TFile fhist(m_histname.c_str(), "recreate");
195 m_hlist -> Write();
196 fhist.Close();
197 std::cout << m_histname << " was written" << std::endl;
198
199 return StatusCode::SUCCESS;
200}
virtual bool updateAlignPar(CgemAlignPar *alignPar)=0

◆ initialize()

StatusCode CgemAlignAlg::initialize ( )

Definition at line 50 of file CgemAlignAlg.cxx.

50 {
51 MsgStream log( msgSvc(), name() );
52
53 std::cout<<" "<<std::endl;
54 std::cout<<" ██████╗ ███████╗███████╗██╗██╗██╗ ██████╗ ██████╗ ███████╗███╗ ███╗ █████╗ ██╗ ██╗ ██████╗ ███╗ ██╗███╗ ███╗███████╗███╗ ██╗████████╗ "<<std::endl;
55 std::cout<<" ██╔══██╗██╔════╝██╔════╝██║██║██║ ██╔════╝██╔════╝ ██╔════╝████╗ ████║ ██╔══██╗██║ ██║██╔════╝ ████╗ ██║████╗ ████║██╔════╝████╗ ██║╚══██╔══╝ "<<std::endl;
56 std::cout<<" ██████╔╝█████╗ ███████╗██║██║██║ ██║ ██║ ███╗█████╗ ██╔████╔██║ ███████║██║ ██║██║ ███╗██╔██╗ ██║██╔████╔██║█████╗ ██╔██╗ ██║ ██║ "<<std::endl;
57 std::cout<<" ██╔══██╗██╔══╝ ╚════██║██║██║██║ ██║ ██║ ██║██╔══╝ ██║╚██╔╝██║ ██╔══██║██║ ██║██║ ██║██║╚██╗██║██║╚██╔╝██║██╔══╝ ██║╚██╗██║ ██║ "<<std::endl;
58 std::cout<<" ██████╔╝███████╗███████║██║██║██║ ╚██████╗╚██████╔╝███████╗██║ ╚═╝ ██║ ██║ ██║███████╗██║╚██████╔╝██║ ╚████║██║ ╚═╝ ██║███████╗██║ ╚████║ ██║ "<<std::endl;
59 std::cout<<" ╚═════╝ ╚══════╝╚══════╝╚═╝╚═╝╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝ "<<std::endl;
60 std::cout<<" "<<std::endl;
61
62 log << MSG::INFO << "CgemAlignAlg initialze() ..." << endreq;
63
64 if("NULL"==m_histname){
65 log << MSG::ERROR << "not defined histogram file." << endreq;
66 return StatusCode::FAILURE;
67 }
68
69 StatusCode sc = service("CgemGeomSvc", m_cgemGeomSvc);
70 if(sc != StatusCode::SUCCESS){
71 log << MSG::ERROR << "can not use CgemGeomSvc" << endreq;
72 }
73
74 sc = service("CgemCalibFunSvc", m_cgemFunSvc);
75 if( sc != StatusCode::SUCCESS ){
76 log << MSG::FATAL << "can not use CgemCalibFunSvc" << endreq;
77 }
78
79 // initialize m_param
80 initParam();
81
82 // read cgem config parameters
83 int i;
84 std::string strconfig;
85 std::string strcomment;
86 std::string strTes;
87 int fgTes[50];
88 for(i=0; i<50; i++) fgTes[i] = -999;
89 ifstream fconfig( m_configFile.c_str() );
90 if( ! fconfig.is_open() ){
91 log << MSG::WARNING << "can not open config file " << m_configFile
92 << ". Use defalt config parameters" << endreq;
93 } else {
94 log << MSG::INFO << "Open config file " << m_configFile << endreq;
95 while( fconfig >> strconfig ){
96 if('#' == strconfig[0]){
97 getline(fconfig, strcomment);
98 } else if("TesMin" == strconfig){
99 fconfig >> m_param.tesMin;
100 }
101
102 }
103 fconfig.close();
104 }
105
106 // set event type
107 m_param.particle = m_evtType;
108
109 m_alignPar = new CgemAlignPar();
110 m_alignPar -> rdAlignPar(m_alignFile);
111 cout << std::setprecision(4) << std::fixed;
112 cout<<" The parameters are:"<<endl;
113 cout<<" Layer Dx(mm) Dy(mm) Dz(mm) Rx(mrad) Ry(mrad) Rz(mrad) "<<endl;
114 cout<<" =============================================================================================== "<<endl;
115 cout<<" 0 "<<std::setw(15)<<m_alignPar->getDx(0)<<std::setw(15)<<m_alignPar->getDy(0)<<std::setw(15)<<m_alignPar->getDz(0)<<std::setw(15)<<m_alignPar->getRx(0)*1000.<<std::setw(15)<<m_alignPar->getRy(0)*1000.<<std::setw(15)<<m_alignPar->getRz(0)*1000.<<endl;
116 cout<<" 1 "<<std::setw(15)<<m_alignPar->getDx(1)<<std::setw(15)<<m_alignPar->getDy(1)<<std::setw(15)<<m_alignPar->getDz(1)<<std::setw(15)<<m_alignPar->getRx(1)*1000.<<std::setw(15)<<m_alignPar->getRy(1)*1000.<<std::setw(15)<<m_alignPar->getRz(1)*1000.<<endl;
117 cout<<" 2 "<<std::setw(15)<<m_alignPar->getDx(2)<<std::setw(15)<<m_alignPar->getDy(2)<<std::setw(15)<<m_alignPar->getDz(2)<<std::setw(15)<<m_alignPar->getRx(2)*1000.<<std::setw(15)<<m_alignPar->getRy(2)*1000.<<std::setw(15)<<m_alignPar->getRz(2)*1000.<<endl;
118 cout<<" 3 "<<std::setw(15)<<m_alignPar->getDx(3)<<std::setw(15)<<m_alignPar->getDy(3)<<std::setw(15)<<m_alignPar->getDz(3)<<std::setw(15)<<m_alignPar->getRx(3)*1000.<<std::setw(15)<<m_alignPar->getRy(3)*1000.<<std::setw(15)<<m_alignPar->getRz(3)*1000.<<endl;
119 cout<<" 4 "<<std::setw(15)<<m_alignPar->getDx(4)<<std::setw(15)<<m_alignPar->getDy(4)<<std::setw(15)<<m_alignPar->getDz(4)<<std::setw(15)<<m_alignPar->getRx(4)*1000.<<std::setw(15)<<m_alignPar->getRy(4)*1000.<<std::setw(15)<<m_alignPar->getRz(4)*1000.<<endl;
120 cout<<" 5 "<<std::setw(15)<<m_alignPar->getDx(5)<<std::setw(15)<<m_alignPar->getDy(5)<<std::setw(15)<<m_alignPar->getDz(5)<<std::setw(15)<<m_alignPar->getRx(5)*1000.<<std::setw(15)<<m_alignPar->getRy(5)*1000.<<std::setw(15)<<m_alignPar->getRz(5)*1000.<<endl;
121 cout<<" =============================================================================================== "<<endl;
122 cout<<"\n"<<endl;
123
124 m_cgemevt = new CgemAliEvent();
125 m_cgemevt -> setParam(m_param);
126
127 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
128 m_hlist = new TObjArray(0);
129
130 if( 0 == m_alignMethod ){
131 m_align = new CgemMilleAlign();
132 }
133 m_align->setParam(m_param);
134 m_align->initialize(m_hlist, m_cgemGeomSvc, m_cgemFunSvc);
135
136 log << MSG::INFO << "CgemAlignAlg initialze() successfully !!" << endreq;
137
138 m_nEvt = 0;
139
140 return StatusCode::SUCCESS;
141}
virtual void setParam(CgemAliParams &param)=0
virtual void initialize(TObjArray *hlist, ICgemGeomSvc *cgemGeomSvc, ICgemCalibFunSvc *cgemFunSvc)=0
double getDz(int iEP)
double getRy(int iEP)
double getDy(int iEP)
double getDx(int iEP)
double getRz(int iEP)
double getRx(int iEP)

The documentation for this class was generated from the following files: