BOSS 8.0.0
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"
6#include "EventModel/EventHeader.h"
9#include "Identifier/Identifier.h"
10#include "Identifier/MdcID.h"
11#include "MdcRawEvent/MdcDigi.h"
12
13using namespace Event;
14
15int EFSectorHits::idmax[43] = { 40, 44, 48, 56, 64, 72, 80, 80, 76, 76, 88,
16 88, 100, 100, 112, 112, 128, 128, 140, 140, 160, 160,
17 160, 160, 176, 176, 176, 176, 208, 208, 208, 208, 240,
18 240, 240, 240, 256, 256, 256, 256, 288, 288, 288 };
19
20EFSectorHits::EFSectorHits( const std::string& name, ISvcLocator* pSvcLocator )
21 : IEFAlgorithm( name, pSvcLocator ) {
22 int output = ( m_output % 1000 ) / 100;
23 // declareProperty("OutputLevel",m_output = MSG::NIL);
24 MsgStream log( msgSvc(), name );
25 msgSvc()->setOutputLevel( name, output );
26 m_nsec = new CriteriaItemValue;
27}
28
29EFSectorHits::~EFSectorHits() { delete m_nsec; }
30
32
33 MsgStream log( msgSvc(), name() );
34 log << MSG::INFO << "in initialize()" << endmsg;
35
37
38 StatusCode sc;
39 sc = m_HltStoreSvc->put( "nsec", m_nsec );
40 if ( sc.isFailure() )
41 {
42 log << MSG::ERROR << "m_HltStoreSvc->put(nsec) wrong" << endmsg;
43 return sc;
44 }
45
46 return StatusCode::SUCCESS;
47}
48
50
51 // reset();
52 MsgStream log( msgSvc(), name() );
53 int32_t nshower = m_ef->getEFVec( 38 );
54 if ( nshower < 2 ) return StatusCode::SUCCESS;
55
56 // DataObject* pObject;
57
58 // Part 1: Get the event header, print out event and run number
59 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
60 if ( !eventHeader )
61 {
62 log << MSG::FATAL << "Could not find Event Header" << endmsg;
63 return ( StatusCode::FAILURE );
64 }
65 // Part 2: Retrieve Hits Collection
66 SmartDataPtr<MdcDigiCol> mdcDigiCol( eventSvc(), "/Event/Digi/MdcDigiCol" );
67 if ( !mdcDigiCol )
68 {
69 log << MSG::FATAL << "EmcRec could not find Mdc digi!!" << endmsg;
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 ) ) )
81 return false;
82 if ( ( !( p1->getValue( phi1 ) ) ) || ( !( p2->getValue( phi2 ) ) ) ) return false;
83 // phi(-pi,pi)==>(0,2pi)
84 if ( phi1 < 0 ) phi1 += 6.2831852;
85 if ( phi2 < 0 ) phi2 += 6.2831852;
86 // Decide sector (phi11,phi12) and (phi21,phi22)
87 float phi11 = min( phi1, phi2 );
88 float phi22 = max( phi1, phi2 );
89 float phi12 = ( phi11 + phi22 - 3.1415926 ) * 0.5;
90 float phi21 = ( phi11 + phi22 + 3.1415926 ) * 0.5;
91 if ( phi12 < 0. ) phi12 += 6.2831852;
92 if ( phi21 > 6.2831852 ) phi21 -= 6.2831852;
93 for ( ; iter != mdcDigiCol->end(); iter++ )
94 {
95 id = ( *iter )->identify();
96 unsigned int iphi = MdcID::wire( id );
97 unsigned int ilayer = MdcID::layer( id );
98 if ( ilayer >= 43 ) log << MSG::ERROR << "MDC(" << ilayer << "," << iphi << endmsg;
99 float phi = 6.2831853 * iphi / idmax[ilayer];
100 if ( WhetherSector( phi, phi11, phi12 ) || WhetherSector( phi, phi21, phi22 ) ) nsec++;
101 }
102 log << MSG::INFO << " Number of hits in sector of MDC is " << nsec << endmsg;
103
104 // Part 4: Put the criteria item(s) to HltStoreSvc here
105 m_nsec->setValue( nsec );
106 m_ef->setVecBit( true, 0, 3 );
107 m_ef->addToEFVec( 9, 37 );
108 if ( m_ef->getEFVec( 37 ) != 0 ) log << MSG::WARNING << "nsec(0) !=0" << endmsg;
109 m_ef->addToEFVec( nsec, 37 );
110
111 m_run = 1;
112
113 return StatusCode::SUCCESS;
114}
115
117 MsgStream log( msgSvc(), name() );
118 log << MSG::INFO << "in finalize()" << endmsg;
119 return StatusCode::SUCCESS;
120}
121
123
124 if ( m_run )
125 {
126 m_nsec->reset();
127 m_run = 0;
128 }
129 return;
130}
131
132bool EFSectorHits::WhetherSector( float ph, float ph1, float ph2 ) {
133 float phi1 = min( ph1, ph2 );
134 float phi2 = max( ph1, ph2 );
135 float delta = 0.0610865; // 3.5*3.1415926/180.
136 if ( ( phi2 - phi1 ) < 3.1415926 )
137 {
138 phi1 -= delta;
139 phi2 += delta;
140 if ( phi1 < 0. ) phi1 += 6.2831852;
141 if ( phi2 > 6.2831852 ) phi2 -= 6.2831852;
142 float tmp1 = min( phi1, phi2 );
143 float tmp2 = max( phi1, phi2 );
144 phi1 = tmp1;
145 phi2 = tmp2;
146 }
147 else
148 {
149 phi1 += delta;
150 phi2 -= delta;
151 }
152 if ( ( phi2 - phi1 ) < 3.1415926 )
153 {
154 if ( ph <= phi2 && ph >= phi1 ) return true;
155 else return false;
156 }
157 else
158 {
159 if ( ph >= phi2 || ph <= phi1 ) return true;
160 else return false;
161 }
162}
double p2[4]
double p1[4]
Double_t phi2
Double_t phi1
#define min(a, b)
#define max(a, b)
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()
StatusCode execute()
EFSectorHits(const std::string &name, ISvcLocator *pSvcLocator)
virtual ~EFSectorHits()
virtual StatusCode initialize()
StatusCode finalize()
EFResult * m_ef
IEFAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize()
HltStoreSvc * m_HltStoreSvc
static int layer(const Identifier &id)
Values of different levels (failure returns 0).
Definition MdcID.cxx:47
static int wire(const Identifier &id)
Definition MdcID.cxx:52