CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
EFSectorHits.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2//#include "GaudiKernel/AlgFactory.h"
3#include "GaudiKernel/SmartDataPtr.h"
4//#include "GaudiKernel/PropertyMgr.h"
5#include "EventModel/Event.h"
9#include "Identifier/MdcID.h"
12
13using namespace Event;
14
15int EFSectorHits::idmax[43]={40,44,48,56,64,72,80,80,76,76,
16 88,88,100,100,112,112,128,128,140,140,
17 160,160,160,160,176,176,176,176,208,208,
18 208,208,240,240,240,240,256,256,256,256,
19 288,288,288};
20
21EFSectorHits::EFSectorHits(const std::string& name, ISvcLocator* pSvcLocator) :
22 IEFAlgorithm(name, pSvcLocator) {
23 int output= (m_output%1000)/100;
24 //declareProperty("OutputLevel",m_output = MSG::NIL);
25 MsgStream log(msgSvc(), name);
26 msgSvc()->setOutputLevel(name,output);
27 m_nsec = new CriteriaItemValue;
28}
29
31 delete m_nsec;
32}
33
35
36 MsgStream log(msgSvc(), name());
37 log << MSG::INFO << "in initialize()" << endreq;
38
40
41 StatusCode sc;
42 sc = m_HltStoreSvc->put("nsec", m_nsec);
43 if ( sc.isFailure() ) {
44 log << MSG::ERROR << "m_HltStoreSvc->put(nsec) wrong" << endreq;
45 return sc;
46 }
47
48 return StatusCode::SUCCESS;
49}
50
52
53 //reset();
54 MsgStream log(msgSvc(), name());
55 int32_t nshower=m_ef->getEFVec(38);
56 if(nshower<2) return StatusCode::SUCCESS;
57
58 //DataObject* pObject;
59
60 // Part 1: Get the event header, print out event and run number
61 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
62 if (!eventHeader) {
63 log << MSG::FATAL << "Could not find Event Header" << endreq;
64 return( StatusCode::FAILURE);
65 }
66 //Part 2: Retrieve Hits Collection
67 SmartDataPtr<MdcDigiCol> mdcDigiCol(eventSvc(),"/Event/Digi/MdcDigiCol");
68 if (!mdcDigiCol) {
69 log << MSG::FATAL << "EmcRec could not find Mdc digi!!" << endreq;
70 return( StatusCode::FAILURE);
71 }
72 //Part 3: Get information of hits
73 unsigned int nsec=0;
74 Identifier id;
75 MdcDigiCol::iterator iter=mdcDigiCol->begin();
76
79 float phi1,phi2;
80 if((!m_HltStoreSvc->get("phi1", p1))||(!m_HltStoreSvc->get("phi2", p2)))return false;
81 if((!(p1->getValue(phi1)))||(!(p2->getValue(phi2)))) return false;
82 //phi(-pi,pi)==>(0,2pi)
83 if(phi1<0) phi1+=6.2831852;
84 if(phi2<0) phi2+=6.2831852;
85 //Decide sector (phi11,phi12) and (phi21,phi22)
86 float phi11=min(phi1,phi2);
87 float phi22=max(phi1,phi2);
88 float phi12=(phi11+phi22-3.1415926)*0.5;
89 float phi21=(phi11+phi22+3.1415926)*0.5;
90 if(phi12<0.) phi12 += 6.2831852;
91 if(phi21>6.2831852) phi21 -= 6.2831852;
92 for(;iter!= mdcDigiCol->end();iter++) {
93 id=(*iter)->identify();
94 unsigned int iphi=MdcID::wire(id);
95 unsigned int ilayer=MdcID::layer(id);
96 if(ilayer>=43)
97 log << MSG::ERROR << "MDC(" << ilayer <<","<<iphi <<endreq;
98 float phi=6.2831853*iphi/idmax[ilayer];
99 if(WhetherSector(phi,phi11,phi12)||WhetherSector(phi,phi21,phi22)) nsec++;
100 }
101 log << MSG::INFO << " Number of hits in sector of MDC is " << nsec <<endreq;
102
103 //Part 4: Put the criteria item(s) to HltStoreSvc here
104 m_nsec->setValue(nsec);
105 m_ef->setVecBit(true, 0, 3);
106 m_ef->addToEFVec(9,37);
107 if(m_ef->getEFVec(37)!=0) log << MSG::WARNING << "nsec(0) !=0"<< endreq;
108 m_ef->addToEFVec(nsec,37);
109
110 m_run=1;
111
112 return StatusCode::SUCCESS;
113}
114
116 MsgStream log(msgSvc(), name());
117 log << MSG::INFO << "in finalize()" << endmsg;
118 return StatusCode::SUCCESS;
119}
120
122
123 if(m_run){
124 m_nsec->reset();
125 m_run=0;
126 }
127 return;
128}
129
130bool EFSectorHits::WhetherSector(float ph,float ph1,float ph2){
131 float phi1=min(ph1,ph2);
132 float phi2=max(ph1,ph2);
133 float delta=0.0610865; //3.5*3.1415926/180.
134 if((phi2-phi1)<3.1415926){
135 phi1 -=delta;
136 phi2 +=delta;
137 if(phi1<0.) phi1 += 6.2831852;
138 if(phi2>6.2831852) phi2 -= 6.2831852;
139 float tmp1=min(phi1,phi2);
140 float tmp2=max(phi1,phi2);
141 phi1=tmp1;
142 phi2=tmp2;
143 }
144 else{
145 phi1 +=delta;
146 phi2 -=delta;
147 }
148 if((phi2-phi1)<3.1415926){
149 if(ph<=phi2&&ph>=phi1) return true;
150 else return false;
151 }
152 else{
153 if(ph>=phi2||ph<=phi1) return true;
154 else return false;
155 }
156}
Double_t phi2
Double_t phi1
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per saves r n generator level $ !Flag for chat level in output
Definition: FoamA.h:89
IMessageSvc * msgSvc()
void setValue(float value)
bool getValue(float &value) const
bool addToEFVec(uint32_t val, uint32_t pos)
Definition: EFResult.cxx:81
bool setVecBit(uint32_t val, uint32_t vecpos, uint32_t bbegin, uint32_t bend)
Definition: EFResult.cxx:94
const std::vector< uint32_t > getEFVec() const
Definition: EFResult.cxx:51
StatusCode execute()
EFSectorHits(const std::string &name, ISvcLocator *pSvcLocator)
virtual ~EFSectorHits()
virtual StatusCode initialize()
StatusCode finalize()
bool put(const std::string &name, const T &value)
Definition: HltStoreSvc.h:60
bool get(const std::string &name, T &value)
Definition: HltStoreSvc.h:76
EFResult * m_ef
Definition: IEFAlgorithm.h:22
virtual StatusCode initialize()
HltStoreSvc * m_HltStoreSvc
Definition: IEFAlgorithm.h:20
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
Definition: MdcID.cxx:49
static int wire(const Identifier &id)
Definition: MdcID.cxx:54
Definition: Event.h:21