BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
DQAFillEx Class Reference

#include <DQAFillEx.h>

+ Inheritance diagram for DQAFillEx:

Public Member Functions

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

Detailed Description

Definition at line 23 of file DQAFillEx.h.

Constructor & Destructor Documentation

◆ DQAFillEx()

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

Definition at line 39 of file DQAFillEx.cxx.

39 :
40 Algorithm(name, pSvcLocator) {
41
42 //Declare the properties
43}

Member Function Documentation

◆ execute()

StatusCode DQAFillEx::execute ( )

Definition at line 91 of file DQAFillEx.cxx.

91 {
92
93 MsgStream log(msgSvc(), name());
94 log << MSG::INFO << "in execute()" << endreq;
95
96 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
97 m_runNo=eventHeader->runNumber();
98 m_event=eventHeader->eventNumber();
99 log << MSG::DEBUG <<"run, evtnum = "
100 << m_runNo << " , "
101 << m_event <<endreq;
102
103
104 SmartDataPtr<EvtRecEvent> evtRecEvent(eventSvc(), EventModel::EvtRec::EvtRecEvent);
105
106 SmartDataPtr<DQAEvent::DQAEvent> dqaevt(eventSvc(), "/Event/DQATag");
107 if ( dqaevt ) {
108 log << MSG::INFO << "success get DQAEvent" << endreq;
109 } else {
110 log << MSG::ERROR << "Error accessing DQAEvent" << endreq;
111 return StatusCode::FAILURE;
112 }
113
114 log << MSG::DEBUG << "event tag = " << dqaevt->EventTag() << endreq;
115
116 // get the required control sample with DQA tag
117 if ( dqaevt->Bhabha() ) {
118 log << MSG::INFO << "Bhabha event" << endreq;
119 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol(eventSvc(), EventModel::EvtRec::EvtRecTrackCol);
120 for(int i = 0; i < evtRecEvent->totalCharged(); i++){
121 EvtRecTrackIterator itTrk=evtRecTrkCol->begin() + i;
122 log << MSG::DEBUG << i << " " << (*itTrk)->partId() << " "
123 << (*itTrk)->quality() << endreq;
124 // get the required particle through the track's PID
125 // Pid: 1 - electron, 2 - muon, 3 - pion, 4 - kaon, 5 - proton
126 // if ( (*itTrk)->partId() != 1 ) continue; // only e+, e-
127 // PID: isElectron(), isMuon(), isPion(), isKaon(), isProton()
128 if ( !(*itTrk)->isElectron() ) continue; // only e+, e-
129 // if you want to do dE/dx or TOF study, select track with no bias
130 // Quality: defined by whether dE/dx or TOF is used to identify particle
131 // 0 - no dE/dx, no TOF (can be used for dE/dx and TOF calibration)
132 // 1 - only dE/dx (can be used for TOF calibration)
133 // 2 - only TOF (can be used for dE/dx calibration)
134 // 3 - Both dE/dx and TOF
135 int qual = (*itTrk)->quality();
136 if ( qual != 0 && qual != 2) continue; // no dE/dx PID is used in selection
137// if ( qual != 0 && qual != 1) continue; // no TOF PID is used in the selection
138 RecMdcTrack *mdcTrk = (*itTrk)->mdcTrack();
139 if ( mdcTrk->charge() > 0 ) {
140 log << MSG::DEBUG << "is electron" << endreq;
141 } else {
142 log << MSG::DEBUG << "is positron" << endreq;
143 }
144 double x0 =mdcTrk->x();
145 double y0 =mdcTrk->y();
146 double z0 =mdcTrk->z();
147 double Rxy=sqrt(x0*x0+y0*y0);
148 // DQA
149 TH1 *h(0);
150 if (m_thsvc->getHist("/DQAHist/MDC/hrxy", h).isSuccess()) {
151 h->Fill(Rxy);
152 } else {
153 log << MSG::ERROR << "Couldn't retrieve hrxy" << endreq;
154 }
155 if (m_thsvc->getHist("/DQAHist/MDC/hz", h).isSuccess()) {
156 h->Fill(z0);
157 } else {
158 log << MSG::ERROR << "Couldn't retrieve hz" << endreq;
159 }
160 }
161 }
162
163 m_tuple->write();
164
165 return StatusCode::SUCCESS;
166
167}
EvtRecTrackCol::iterator EvtRecTrackIterator
Definition: EvtRecTrack.h:111
IMessageSvc * msgSvc()
const int charge() const
Definition: DstMdcTrack.h:53
const double z() const
Definition: DstMdcTrack.h:63
const double y() const
Definition: DstMdcTrack.h:62
const double x() const
Definition: DstMdcTrack.h:61
_EXTERN_ std::string EvtRecEvent
Definition: EventModel.h:116
_EXTERN_ std::string EvtRecTrackCol
Definition: EventModel.h:117

◆ finalize()

StatusCode DQAFillEx::finalize ( )

Definition at line 170 of file DQAFillEx.cxx.

170 {
171
172 MsgStream log(msgSvc(), name());
173 log << MSG::INFO << "in finalize()" << endmsg;
174 return StatusCode::SUCCESS;
175}

◆ initialize()

StatusCode DQAFillEx::initialize ( )

Definition at line 46 of file DQAFillEx.cxx.

46 {
47 MsgStream log(msgSvc(), name());
48
49 log << MSG::INFO << "in initialize()" << endmsg;
50 StatusCode status;
51
52 // DQA
53 // The first directory specifier must be "DQAFILE"
54 // The second is the sub-system name: MDC, DEDX, TOF, EMC, MUC, TRG
55 // user can define more directory, such as DAQFILE/MDC/Bhabha.
56 NTuplePtr nt(ntupleSvc(), "DQAFILE/MDC");
57 if ( nt ) m_tuple = nt;
58 else {
59 m_tuple = ntupleSvc()->book("DQAFILE/MDC", CLID_ColumnWiseTuple, "MDC ntuple");
60 if( m_tuple ) {
61 status = m_tuple->addItem("runNo", m_runNo);
62 status = m_tuple->addItem("event", m_event);
63 } else {
64 log << MSG::ERROR << "Can not book N-tuple:" << long(m_tuple) << endreq;
65 }
66 }
67
68 if(service("THistSvc", m_thsvc).isFailure()) {
69 log << MSG::ERROR << "Couldn't get THistSvc" << endreq;
70 return StatusCode::FAILURE;
71 }
72
73 // "DQAHist" is fixed
74 // "Rhopi" is the sub-system name, just as ntuple case.
75 TH1F* hrxy = new TH1F("Rxy", "Rxy distribution", 110, -1., 10.);
76 if(m_thsvc->regHist("/DQAHist/MDC/hrxy", hrxy).isFailure()) {
77 log << MSG::ERROR << "Couldn't register Rxy" << endreq;
78 }
79 TH1F* hz = new TH1F("z", "z distribution", 200, -100., 100.);
80 if(m_thsvc->regHist("/DQAHist/MDC/hz", hz).isFailure()) {
81 log << MSG::ERROR << "Couldn't register z" << endreq;
82 }
83
84 log << MSG::INFO << "successfully return from initialize()" <<endmsg;
85 return StatusCode::SUCCESS;
86
87
88}
INTupleSvc * ntupleSvc()

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