64 Algorithm(name, pSvcLocator) {
66 declareProperty(
"PID_FLAG", PID_flag = 1);
67 declareProperty(
"MC_sample", m_MC_sample = 1);
69 declareProperty(
"m_Seperate_Charge", Seperate_Charge = 1);
70 declareProperty(
"m_Charge_default", Charge_default = 1);
80 MsgStream log(
msgSvc(), name());
82 log << MSG::INFO <<
"in initialize()" << endmsg;
89 readrunEcm.open(
"../share/psipp_ecms_calrunbyrun_runno_3648runs.dat");
90 cout<<
"readrunEcm = "<<readrunEcm.is_open()<<endl;
91 for(
int i = 0; i < 3467; i++) {
92 readrunEcm>>p_run[i]; readrunEcm>>p_Ecm[i];
97 if ( nt1 ) m_tuple1 = nt1;
99 m_tuple1 =
ntupleSvc()->book (
"FILE1/tag", CLID_ColumnWiseTuple,
"tag N-Tuple example");
101 status = m_tuple1->addItem (
"tagmode", m_tagmode);
102 status = m_tuple1->addItem (
"mass_bc", m_mass_bc);
103 status = m_tuple1->addItem (
"delE_tag", m_delE_tag);
105 status = m_tuple1->addItem (
"cosmic_ok", m_cosmic_ok);
106 status = m_tuple1->addItem (
"EGam_max_0", m_EGam_max_0);
107 status = m_tuple1->addItem (
"nGood", m_nGood);
108 status = m_tuple1->addItem (
"nGam", m_nGam);
109 status = m_tuple1->addItem (
"runNo", m_runNo);
110 status = m_tuple1->addItem (
"event", m_event);
113 log << MSG::ERROR <<
" Cannot book N-tuple:" << long(m_tuple1) <<endmsg;
114 return StatusCode::FAILURE;
118 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
119 return StatusCode::SUCCESS;
129 MsgStream log(
msgSvc(), name());
131 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
132 int runNo=eventHeader->runNumber();
133 int event=eventHeader->eventNumber();
143 double Ebeam = 3.773/2.0;
146 for(
int i = 0; i < 3467; i++) {
147 if(
runNo == p_run[i]) {Ebeam = p_Ecm[i]/2.0;}
159 if(
nD0%1000==0) cout<<
"SD0TagAlg-13-11-15pp = "<<
nD0<<
" "<<
runNo<<
" "<<
event<<
" "<<Ebeam*2<<endl;
161 Hep3Vector xorigin(0,0,0);
163 Gaudi::svcLocator()->service(
"VertexDbSvc", vtxsvc);
167 xorigin.setX(dbv[0]);
168 xorigin.setY(dbv[1]);
169 xorigin.setZ(dbv[2]);
173 Vint iCharge_good; iCharge_good.clear();
174 for(
int i = 0; i < evtRecEvent->totalCharged(); i++){
176 if(!(*itTrk)->isMdcTrackValid())
continue;
179 HepVector a = mdcTrk->
helix();
180 HepSymMatrix Ea = mdcTrk->
err();
182 HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
185 HepVector vecipa = helixip.
a();
186 double Rvxy0=fabs(vecipa[0]);
187 double Rvz0=vecipa[3];
190 if(fabs(Rvxy0) >= 1.0)
continue;
191 if(fabs(Rvz0) >= 10.0)
continue;
192 if(fabs(
costheta) >= 0.930)
continue;
193 iCharge_good.push_back(i);
197 Vint iGam; iGam.clear();
198 for(
int i = evtRecEvent->totalCharged(); i< evtRecEvent->totalTracks(); i++) {
200 if(!(*itTrk)->isEmcShowerValid())
continue;
210 int emctdc = emcTrk->
time();
211 if(emctdc>14||emctdc<0)
continue;
213 double eraw = emcTrk->
energy();
214 double theta = emcTrk->
theta();
216 if(fabs(
cos(theta)) < 0.80 && eraw > 0.025){ Module = 1; }
217 if(fabs(
cos(theta)) > 0.86 && fabs(
cos(theta)) < 0.92 && eraw > 0.05) { Module = 2; }
218 if(Module == 0)
continue;
219 iGam.push_back((*itTrk)->trackId());
227 double tagmass,
ebeam,tagmode,ksmass,dlte;
229 Vint tagtrk; tagtrk.clear();
230 Vint tagGam; tagGam.clear();
232 HepLorentzVector tagp;
234 double mass_bc_temp, mass_kf_temp, kf_chi2_temp, mks_temp, mpi0_temp, ptag_temp;
235 int Charge_candidate_D = 0;
236 double EGam_max_0 = 0;
238 for(
int i1 = 0; i1 < 2; i1++) {
239 if(Seperate_Charge == 2 ) { Charge_candidate_D = Charge_default; i1 = 2;}
240 if(Seperate_Charge == 1 ) { Charge_candidate_D = pow(-1,i1); }
241 if(Seperate_Charge == 0 ) { Charge_candidate_D = 0; i1 = 2; }
243 for(
int i = 0; i < 15; i++) {
245 int mdslct=pow(2.,i);
247 sing.
Mdset(event,evtRecTrkCol,iCharge_good,iGam,mdslct,Ebeam, PID_flag,Charge_candidate_D);
257 if((
abs(tagmode) == 11 ||
abs(tagmode) == 15 ||
abs(tagmode) == 19)) {
259 for(
int i = evtRecEvent->totalCharged(); i < evtRecEvent->totalTracks(); i++) {
261 int itrk = (*itTrk)->trackId();
262 if(!(*itTrk)->isEmcShowerValid())
continue;
265 int emctdc = emcTrk->
time();
266 if(emctdc>14||emctdc<0)
continue;
268 Hep3Vector emcpos(emcTrk->
x(), emcTrk->
y(), emcTrk->
z());
270 for(
int j = 0; j < tagtrk.size(); j++) {
272 if(!(*jtTrk)->isExtTrackValid())
continue;
276 double angd = extpos.angle(emcpos);
277 if(angd < dang) dang = angd;
279 dang = dang * 180 / (CLHEP::pi);
280 if(fabs(dang)<20.)
continue;
282 double eraw = emcTrk->
energy();
283 if(eraw > EGam_max_0) EGam_max_0 = eraw;
287 m_cosmic_ok = cosmic_ok;
288 m_EGam_max_0 = EGam_max_0;
289 m_nGood = iCharge_good.size();
290 m_nGam = iGam.size();
309 return StatusCode::SUCCESS;
319 MsgStream log(
msgSvc(), name());
320 cout<<
"nD0 = "<<
nD0<<endl;
321 cout<<
"n1 = "<<
n1<<endl;
322 cout<<
"n2 = "<<
n2<<endl;
323 cout<<
"ND0 ==== "<<
ND0<<endl;
324 cout<<
"NDp ==== "<<
NDp<<endl;
325 log << MSG::INFO <<
"in finalize()" << endmsg;
326 return StatusCode::SUCCESS;
double cos(const BesAngle a)
EvtRecTrackCol::iterator EvtRecTrackIterator
const Hep3Vector emcPosition() const
const int emcVolumeNumber() const
const double theta() const
const HepSymMatrix err() const
const HepVector helix() const
......
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0
SD0Tag(const std::string &name, ISvcLocator *pSvcLocator)
void Mdset(double event, SmartDataPtr< EvtRecTrackCol > evtRecTrkCol, Vint iGood, Vint iGam, int mdset, double Ebeam, int PID_flag, int Charge_candidate_D)
const HepPoint3D & pivot(void) const
returns pivot position.
const HepVector & a(void) const
returns helix parameters.
_EXTERN_ std::string EvtRecEvent
_EXTERN_ std::string EvtRecTrackCol