CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
SD0Tag Class Reference

#include <SD0Tag.h>

+ Inheritance diagram for SD0Tag:

Public Member Functions

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

Detailed Description

Definition at line 13 of file SD0Tag.h.

Constructor & Destructor Documentation

◆ SD0Tag()

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

Definition at line 63 of file SD0Tag.cxx.

63 :
64 Algorithm(name, pSvcLocator) {
65 //Declare the properties
66 declareProperty("PID_FLAG", PID_flag = 1);
67 declareProperty("MC_sample", m_MC_sample = 1);
68
69 declareProperty("m_Seperate_Charge", Seperate_Charge = 1);
70 declareProperty("m_Charge_default", Charge_default = 1);
71
72
73 }

Member Function Documentation

◆ execute()

StatusCode SD0Tag::execute ( )

Definition at line 127 of file SD0Tag.cxx.

127 {
128
129 MsgStream log(msgSvc(), name());
130
131 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
132 int runNo=eventHeader->runNumber();
133 int event=eventHeader->eventNumber();
134
135 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc(), EventModel::EvtRec::EvtRecEvent);
136 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol(eventSvc(), EventModel::EvtRec::EvtRecTrackCol);
137 //cout<<"//////////////////////////////////////"<<endl;
138 nD0++;
139
140 //
141 // The default energy is 3.773 GeV for psi(3770) data.
142 // Alayizer can add calibrated energy here.
143 double Ebeam = 3.773/2.0;
144
145 if(runNo >=11414 && runNo <= 23500) {
146 for(int i = 0; i < 3467; i++) {
147 if(runNo == p_run[i]) {Ebeam = p_Ecm[i]/2.0;}
148 }
149 }
150
151 if(runNo < 0)
152 {
153 int irun = abs(runNo);
154// Ecmset* ECMSET = Ecmset::instance();
155// ECMSET->EcmSet(irun);
156// Ebeam = ECMSET->ECM()/2.0;
157 }
158
159 if(nD0%1000==0) cout<<"SD0TagAlg-13-11-15pp = "<<nD0<<" "<<runNo<<" "<<event<<" "<<Ebeam*2<<endl;
160
161 Hep3Vector xorigin(0,0,0);
162 IVertexDbSvc* vtxsvc;
163 Gaudi::svcLocator()->service("VertexDbSvc", vtxsvc);
164 if(vtxsvc->isVertexValid()){
165 double* dbv = vtxsvc->PrimaryVertex();
166 double* vv = vtxsvc->SigmaPrimaryVertex();
167 xorigin.setX(dbv[0]);
168 xorigin.setY(dbv[1]);
169 xorigin.setZ(dbv[2]);
170 }
171
172 /////////////////////////////////////
173 Vint iCharge_good; iCharge_good.clear();
174 for(int i = 0; i < evtRecEvent->totalCharged(); i++){
175 EvtRecTrackIterator itTrk=evtRecTrkCol->begin() + i;
176 if(!(*itTrk)->isMdcTrackValid()) continue;
177 RecMdcTrack *mdcTrk = (*itTrk)->mdcTrack();
178 //%%%%%%%%%%%%%%%%%%%%%%%%
179 HepVector a = mdcTrk->helix();
180 HepSymMatrix Ea = mdcTrk->err();
181 HepPoint3D point0(0.,0.,0.); // the initial point for MDC recosntruction
182 HepPoint3D IP(xorigin[0],xorigin[1],xorigin[2]);
183 VFHelix helixip(point0,a,Ea);
184 helixip.pivot(IP);
185 HepVector vecipa = helixip.a();
186 double Rvxy0=fabs(vecipa[0]); //the nearest distance to IP in xy plane
187 double Rvz0=vecipa[3]; //the nearest distance to IP in z direction
188 double costheta = cos(mdcTrk->theta());
189 //%%%%%%%%%%%%%%%%%%%%%%%%
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);
194 }
195
196 ///////////////////////////////////////////////////////
197 Vint iGam; iGam.clear();
198 for(int i = evtRecEvent->totalCharged(); i< evtRecEvent->totalTracks(); i++) {
199 EvtRecTrackIterator itTrk=evtRecTrkCol->begin() + i;
200 if(!(*itTrk)->isEmcShowerValid()) continue;
201 RecEmcShower *emcTrk = (*itTrk)->emcShower();
202 //
203 // We here remove the hot channels of EMC
204 //
205 if(abs(runNo)>=11615&&abs(runNo)<=11617&&emcTrk->cellId()==805438481) continue;
206 if(abs(runNo)>=11615&&abs(runNo)<=11655&&emcTrk->cellId()==805376008) continue;
207 if(abs(runNo)>=13629&&abs(runNo)<=13669&&emcTrk->cellId()==805374754) continue;
208 if(abs(runNo)>=21190&&abs(runNo)<=21231&&emcTrk->cellId()==805375262) continue;
209
210 int emctdc = emcTrk->time();
211 if(emctdc>14||emctdc<0) continue;
212
213 double eraw = emcTrk->energy();
214 double theta = emcTrk->theta();
215 int Module = 0;
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());
220 }
221 /////////////////////////////////////////////////////////////////
222 DTagTool trk;
223 bool cosmic_ok = trk.cosmicandleptonVeto();
224 /////////////////////////////////////////////////////////////////
225
226 int ntk;
227 double tagmass,ebeam,tagmode,ksmass,dlte;
228
229 Vint tagtrk; tagtrk.clear();
230 Vint tagGam; tagGam.clear();
231
232 HepLorentzVector tagp;
233
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;
237
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; }
242
243 for(int i = 0; i < 15; i++) {
244 EGam_max_0 = 0;
245 int mdslct=pow(2.,i);
246 Sing sing;
247 sing.Mdset(event,evtRecTrkCol,iCharge_good,iGam,mdslct,Ebeam, PID_flag,Charge_candidate_D);
248 bool oktag=sing.Getoktg();
249 if(oktag) {
250 //
251 // Here analysizer should pick up variables from anti-D0 tags
252 // to do physics analysis
253 //
254 tagtrk=sing.Gettagtrk1();
255 tagmode = sing.Gettagmd();
256 //==========================================================================
257 if((abs(tagmode) == 11 || abs(tagmode) == 15 || abs(tagmode) == 19)) {
258 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
259 for(int i = evtRecEvent->totalCharged(); i < evtRecEvent->totalTracks(); i++) {
260 EvtRecTrackIterator itTrk=evtRecTrkCol->begin() + i;
261 int itrk = (*itTrk)->trackId();
262 if(!(*itTrk)->isEmcShowerValid()) continue;
263 RecEmcShower *emcTrk = (*itTrk)->emcShower();
264
265 int emctdc = emcTrk->time();
266 if(emctdc>14||emctdc<0) continue;
267
268 Hep3Vector emcpos(emcTrk->x(), emcTrk->y(), emcTrk->z());
269 double dang = 200.;
270 for(int j = 0; j < tagtrk.size(); j++) {
271 EvtRecTrackIterator jtTrk = evtRecTrkCol->begin() + tagtrk[j];
272 if(!(*jtTrk)->isExtTrackValid()) continue;
273 RecExtTrack *extTrk = (*jtTrk)->extTrack();
274 if(extTrk->emcVolumeNumber() == -1) continue;
275 Hep3Vector extpos = extTrk->emcPosition();
276 double angd = extpos.angle(emcpos);
277 if(angd < dang) dang = angd;
278 }
279 dang = dang * 180 / (CLHEP::pi);
280 if(fabs(dang)<20.) continue;
281
282 double eraw = emcTrk->energy();
283 if(eraw > EGam_max_0) EGam_max_0 = eraw;
284 }
285 }
286 //==========================================================================
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();
291 m_runNo = runNo;
292 m_event = event;
293
294 m_tagmode = sing.Gettagmd();
295 m_mass_bc = sing.Getmass_bc();
296 m_delE_tag = sing.GetdelE_tag();
297
298 m_tuple1->write();
299
300 // Here one can do double tag analysis based on the variables
301 // from single anti-D0 tag analysis.
302 // To do so, analyzer should make his/her codes
303 //
304 }
305
306 }
307 } // The end of loopping over mdslct
308
309 return StatusCode::SUCCESS;
310
311}
double cos(const BesAngle a)
Definition BesAngle.h:213
int runNo
double abs(const EvtComplex &c)
EvtRecTrackCol::iterator EvtRecTrackIterator
std::vector< int > Vint
Definition Gam4pikp.cxx:52
int nD0
Definition SD0Tag.cxx:53
IMessageSvc * msgSvc()
bool cosmicandleptonVeto(bool emc=true)
int cellId() const
double theta() const
double x() const
double time() const
double z() const
double energy() const
double y() const
const Hep3Vector emcPosition() const
const int emcVolumeNumber() const
const double theta() const
Definition DstMdcTrack.h:59
const HepSymMatrix err() const
const HepVector helix() const
......
virtual bool isVertexValid()=0
virtual double * SigmaPrimaryVertex()=0
virtual double * PrimaryVertex()=0
Definition Sing.h:21
double Gettagmd()
Definition Sing.h:28
double GetdelE_tag()
Definition Sing.h:31
double Getmass_bc()
Definition Sing.h:29
void Mdset(double event, SmartDataPtr< EvtRecTrackCol > evtRecTrkCol, Vint iGood, Vint iGam, int mdset, double Ebeam, int PID_flag, int Charge_candidate_D)
Definition Sing.cxx:51
bool Getoktg()
Definition Sing.h:27
Vint Gettagtrk1()
Definition Sing.h:32
_EXTERN_ std::string EvtRecEvent
Definition EventModel.h:134
_EXTERN_ std::string EvtRecTrackCol
Definition EventModel.h:135

◆ finalize()

StatusCode SD0Tag::finalize ( )

Definition at line 318 of file SD0Tag.cxx.

318 {
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;
327}
int NDp
Definition SD0Tag.cxx:57
int ND0
Definition SD0Tag.cxx:56
int n2
Definition SD0Tag.cxx:55
int n1
Definition SD0Tag.cxx:54

◆ initialize()

StatusCode SD0Tag::initialize ( )

Definition at line 77 of file SD0Tag.cxx.

77 {
78
79
80 MsgStream log(msgSvc(), name());
81
82 log << MSG::INFO << "in initialize()" << endmsg;
83
84 StatusCode status;
85
86 ifstream readrunEcm;
87//
88// Read in the energy calibration constant for run-by-run data
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];
93 }
94
95
96 NTuplePtr nt1(ntupleSvc(), "FILE1/tag");
97 if ( nt1 ) m_tuple1 = nt1;
98 else {
99 m_tuple1 = ntupleSvc()->book ("FILE1/tag", CLID_ColumnWiseTuple, "tag N-Tuple example");
100 if ( m_tuple1 ) {
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);
104
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);
111 }
112 else {
113 log << MSG::ERROR << " Cannot book N-tuple:" << long(m_tuple1) <<endmsg;
114 return StatusCode::FAILURE;
115 }
116 }
117
118 log << MSG::INFO << "successfully return from initialize()" <<endmsg;
119 return StatusCode::SUCCESS;
120}
INTupleSvc * ntupleSvc()

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