BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
DQAFillEx.cxx
Go to the documentation of this file.
1#include <vector>
2
3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/SmartDataPtr.h"
5#include "GaudiKernel/PropertyMgr.h"
6#include "GaudiKernel/Bootstrap.h"
7
8#include "GaudiKernel/INTupleSvc.h"
9#include "GaudiKernel/NTuple.h"
10#include "GaudiKernel/ITHistSvc.h"
11
12#include "CLHEP/Vector/ThreeVector.h"
13#include "CLHEP/Vector/LorentzVector.h"
14
15#include "TH1F.h"
16
17#include "EventModel/EventModel.h"
18#include "EventModel/Event.h"
19
20#include "EvtRecEvent/EvtRecEvent.h"
21#include "EvtRecEvent/EvtRecTrack.h"
22#include "DstEvent/TofHitStatus.h"
23#include "EventModel/EventHeader.h"
24
25//#include "VertexFit/VertexDbSvc.h"
26#include "ParticleID/ParticleID.h"
27//
28#include "DQAEvent/DQAEvent.h"
29#include "DQAFillEx/DQAFillEx.h"
30
31#ifndef ENABLE_BACKWARDS_COMPATIBILITY
33#endif
34using CLHEP::HepLorentzVector;
35
36
37/////////////////////////////////////////////////////////////////////////////
38
39DQAFillEx::DQAFillEx(const std::string& name, ISvcLocator* pSvcLocator) :
40 Algorithm(name, pSvcLocator) {
41
42 //Declare the properties
43}
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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}
89
90// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
91StatusCode DQAFillEx::execute() {
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}
168
169// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
171
172 MsgStream log(msgSvc(), name());
173 log << MSG::INFO << "in finalize()" << endmsg;
174 return StatusCode::SUCCESS;
175}
176
177
HepGeom::Point3D< double > HepPoint3D
Definition: DQAFillEx.cxx:32
StatusCode finalize()
Definition: DQAFillEx.cxx:170
StatusCode execute()
Definition: DQAFillEx.cxx:91
DQAFillEx(const std::string &name, ISvcLocator *pSvcLocator)
Definition: DQAFillEx.cxx:39
StatusCode initialize()
Definition: DQAFillEx.cxx:46