BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
McCor.cxx
Go to the documentation of this file.
1#include "EventModel/Event.h"
2#include "EventModel/EventModel.h"
3#include "GaudiKernel/IDataProviderSvc.h"
4#include "GaudiKernel/ISvcLocator.h"
5#include "GaudiKernel/MsgStream.h"
6#include "GaudiKernel/PropertyMgr.h"
7#include "GaudiKernel/SmartDataPtr.h"
8
9#include "EvtRecEvent/EvtRecEvent.h"
10#include "EvtRecEvent/EvtRecTrack.h"
11
12#include "CLHEP/Vector/LorentzVector.h"
13#include "CLHEP/Vector/ThreeVector.h"
14#include "CLHEP/Vector/TwoVector.h"
15#include "GaudiKernel/Bootstrap.h"
16#include "GaudiKernel/IHistogramSvc.h"
17#include "GaudiKernel/INTupleSvc.h"
18#include "GaudiKernel/NTuple.h"
19#include "TMath.h"
20using CLHEP::Hep2Vector;
21using CLHEP::Hep3Vector;
22using CLHEP::HepLorentzVector;
23#include "CLHEP/Geometry/Point3D.h"
24#ifndef ENABLE_BACKWARDS_COMPATIBILITY
25typedef HepGeom::Point3D<double> HepPoint3D;
26#endif
27#include "McCor.h"
28
29#include "Identifier/Identifier.h"
30
31#include "TGraph2D.h"
32#include "TGraph2DErrors.h"
33#include "TGraphErrors.h"
34#include <fstream>
35#include <string>
36#include <strstream>
37#include <vector>
38
39/////////////////////////////////////////////////////////////////////////////
40//
41TGraph2DErrors* dt = new TGraph2DErrors();
42
44McCor::McCor( const std::string& name, ISvcLocator* pSvcLocator )
45 : Algorithm( name, pSvcLocator ) {
46
47 // Declare the properties
48 ntOut = true;
49 declareProperty( "NTupleOut", ntOut );
50
51 /*
52 declareProperty("b0",m_b[0] = 0.9976);
53 declareProperty("b1",m_b[1] = -0.01718);
54 declareProperty("b2",m_b[2] = 0.01634);
55 */
56}
57
58// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
59StatusCode McCor::initialize() {
60 MsgStream log( msgSvc(), name() );
61 log << MSG::INFO << "in initialize()" << endmsg;
62 StatusCode status;
63 if ( ntOut == true )
64 {
65 NTuplePtr nt1( ntupleSvc(), "FILE1/ec" );
66 if ( nt1 ) m_tuple1 = nt1;
67 else
68 {
69 m_tuple1 = ntupleSvc()->book( "FILE1/ec", CLID_ColumnWiseTuple, "ks N-Tuple example" );
70 if ( m_tuple1 )
71 {
72 status = m_tuple1->addItem( "ef", m_ef );
73 status = m_tuple1->addItem( "e5", m_e5 );
74 status = m_tuple1->addItem( "ec", m_ec );
75 status = m_tuple1->addItem( "ct", m_ct );
76 }
77 else
78 {
79 log << MSG::ERROR << " Cannot book N-tuple:" << long( m_tuple1 ) << endmsg;
80 return StatusCode::FAILURE;
81 }
82 }
83 }
84 /*
85 string CoeffPath=getenv("MCCORROOT");
86 CoeffPath +="/share/McCorCoeff.txt";
87 ifstream in;
88 in.open(CoeffPath.c_str(),ios::in);
89 for(int i=0;i<4;i++){
90 in>>m_a[i];
91 in>>m_ae[i];
92 }
93 */
94 double energy, thetaid, peak, peakerr, res, reserr;
95 string DataPath;
96 DataPath = getenv( "MCCORROOT" );
97 DataPath += "/share/evset.txt";
98 ifstream in1;
99 in1.open( DataPath.c_str(), ios::in );
100 // in.open("$MCCORROOT/share/evsc.txt");
101 double ep[18] = { 0.03, 0.04, 0.05, 0.075, 0.1, 0.125, 0.15, 0.2, 0.25,
102 0.3, 0.4, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0 };
103 for ( int i = 0; i < 504; i++ )
104 {
105 in1 >> energy;
106 in1 >> thetaid;
107 in1 >> peak;
108 in1 >> peakerr;
109 in1 >> res;
110 in1 >> reserr;
111 int j = i / 28;
112 dt->SetPoint( i, energy, thetaid, peak );
113 dt->SetPointError( i, 0, 0, peakerr );
114 }
115 in1.close();
116 log << MSG::INFO << "successfully return from initialize()" << endmsg;
117 return StatusCode::SUCCESS;
118}
119
120// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
121StatusCode McCor::execute() {
122
123 MsgStream log( msgSvc(), name() );
124 log << MSG::INFO << "in execute()" << endmsg;
125
126 SmartDataPtr<Event::EventH> eventHeader( eventSvc(), "/Event" );
127 SmartDataPtr<EvtRecEvent> evtRecEvent( eventSvc(), EventModel::EvtRec::EvtRecEvent );
128 // log << MSG::INFO << "get event tag OK" << endmsg;
129 log << MSG::DEBUG << "ncharg, nneu, tottks = " << evtRecEvent->totalCharged() << " , "
130 << evtRecEvent->totalNeutral() << " , " << evtRecEvent->totalTracks() << endmsg;
131
132 SmartDataPtr<EvtRecTrackCol> evtRecTrkCol( eventSvc(), EventModel::EvtRec::EvtRecTrackCol );
133
134 for ( int i = 0; i < evtRecEvent->totalTracks(); i++ )
135 {
136
137 EvtRecTrackIterator itTrk = evtRecTrkCol->begin() + i;
138 if ( !( *itTrk )->isEmcShowerValid() ) continue;
139 RecEmcShower* emcTrk = ( *itTrk )->emcShower();
140
141 int intid = emcTrk->cellId();
142 Identifier id = Identifier( intid );
143 int getthetaid = EmcID::theta_module( id );
144 int getmodule = EmcID::barrel_ec( id );
145 if ( getthetaid > 21 ) getthetaid = 43 - getthetaid;
146 if ( getmodule == 1 ) getthetaid = getthetaid + 6;
147 double energyF = emcTrk->energy();
148 double e5x5 = emcTrk->e5x5();
149 double costheta = cos( emcTrk->theta() );
150 double dthetaid = double( getthetaid );
151 double energyC = McCor::corEnergyMc( e5x5, dthetaid );
152
153 if ( ntOut == true )
154 {
155 m_ct = costheta;
156 m_ef = energyF;
157 m_e5 = e5x5;
158 m_ec = energyC;
159 m_tuple1->write();
160 }
161 emcTrk->setEnergy( energyC );
162 }
163
164 return StatusCode::SUCCESS;
165}
166
167// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
168StatusCode McCor::finalize() {
169
170 MsgStream log( msgSvc(), name() );
171 log << MSG::INFO << "in finalize()" << endmsg;
172 return StatusCode::SUCCESS;
173}
174
175double McCor::corEnergyMc( double eg, double theid ) {
176
177 double Energy5x5 = eg;
178 if ( eg < 0.029 ) eg = 0.029;
179 if ( eg > 1.76 ) eg = 1.76;
180 if ( theid <= 0 ) theid = 0.001;
181 if ( theid >= 27 ) theid = 26.999;
182 Float_t einter = eg + 0.00001;
183 Float_t tinter = theid + 0.0001;
184 double ecor = dt->Interpolate( einter, tinter );
185 if ( !( ecor ) ) return Energy5x5;
186 if ( ecor < 0.5 ) return Energy5x5;
187 double EnergyCor = Energy5x5 / ecor;
188 return EnergyCor;
189}
DECLARE_COMPONENT(BesBdkRc)
HepGeom::Point3D< double > HepPoint3D
EvtRecTrackCol::iterator EvtRecTrackIterator
************Class m_ypar INTEGER m_KeyWgt INTEGER m_KeyIHVP INTEGER m_KeyGPS INTEGER m_IsBeamPolarized INTEGER m_EvtGenInterface DOUBLE PRECISION m_Emin DOUBLE PRECISION m_sphot DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_q2 DOUBLE PRECISION m_PolBeam2 DOUBLE PRECISION m_xErrPb *COMMON c_KK2f $ !CMS energy average $ !Spin Polarization vector first beam $ !Spin Polarization vector second beam $ !Beam energy spread[GeV] $ !minimum hadronization energy[GeV] $ !input READ never touch them !$ !debug facility $ !maximum weight $ !inverse alfaQED $ !minimum real photon energy
Definition KK2f.h:50
TGraph2DErrors * dt
Definition McCor.cxx:41
INTupleSvc * ntupleSvc()
IMessageSvc * msgSvc()
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0).
Definition EmcID.cxx:36
static unsigned int theta_module(const Identifier &id)
Definition EmcID.cxx:41
Definition McCor.h:8
StatusCode initialize()
Definition McCor.cxx:59
StatusCode finalize()
Definition McCor.cxx:168
double corEnergyMc(double eg, double theid)
Definition McCor.cxx:175
McCor(const std::string &name, ISvcLocator *pSvcLocator)
Definition McCor.cxx:44
StatusCode execute()
Definition McCor.cxx:121
double int * ep
Definition qcdloop1.h:82