BOSS 8.0.0
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 21 of file DQAFillEx.h.

Constructor & Destructor Documentation

◆ DQAFillEx()

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

Definition at line 31 of file DQAFillEx.cxx.

32 : Algorithm( name, pSvcLocator ) {
33
34 // Declare the properties
35}

Referenced by DQAFillEx().

Member Function Documentation

◆ execute()

StatusCode DQAFillEx::execute ( )

Definition at line 81 of file DQAFillEx.cxx.

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

◆ finalize()

StatusCode DQAFillEx::finalize ( )

Definition at line 150 of file DQAFillEx.cxx.

150 {
151
152 MsgStream log( msgSvc(), name() );
153 log << MSG::INFO << "in finalize()" << endmsg;
154 return StatusCode::SUCCESS;
155}

◆ initialize()

StatusCode DQAFillEx::initialize ( )

Definition at line 38 of file DQAFillEx.cxx.

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

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