BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TreeMucCalibDataCnv.cxx
Go to the documentation of this file.
2#include "CalibData/Muc/MucCalibData.h"
3#include "CalibDataSvc/IInstrumentName.h"
4#include "CalibMySQLCnvSvc/TreeAddress.h"
5#include "GaudiKernel/MsgStream.h"
6#include "TBuffer.h"
7#include "TDirectory.h"
8#include "TFile.h"
9#include "TH1F.h"
10#include "TObject.h"
11#include "TTree.h"
12
13#include "GaudiKernel/DataObject.h"
14#include "GaudiKernel/GenericAddress.h"
15#include "GaudiKernel/IAddressCreator.h"
16#include "GaudiKernel/IConversionSvc.h"
17#include "GaudiKernel/IDataProviderSvc.h"
18#include "GaudiKernel/IOpaqueAddress.h"
19
20#include "CalibDataSvc/ICalibMetaCnvSvc.h"
21#include "CalibDataSvc/ICalibTreeSvc.h" //maybe
22
23// Temporary. Hope to find a better way to do this
24#include "CalibData/CalibModel.h"
25// using namespace CalibData;
26// static CnvFactory<TreeMucCalibDataCnv> MucCal_factory;
27// const ICnvFactory& TreeMucCalibDataCnvFactory = MucCal_factory;
28
31
34 m_ptrIdTr = new MucIdTransform();
35}
36
37const CLID& TreeMucCalibDataCnv::objType() const { return CLID_Calib_MucCal; }
38
40
41StatusCode TreeMucCalibDataCnv::i_createObj( IOpaqueAddress* addr, DataObject*& refpObject ) {
42
43 MsgStream log( msgSvc(), "TreeMucCalibDataCnv" );
44 log << MSG::DEBUG << "SetProperty" << endmsg;
46 TreeAddress* add = dynamic_cast<TreeAddress*>( addr );
47 DatabaseRecord* records = add->pp();
48
49 TBufferFile* buf1 = new TBufferFile( TBuffer::kRead );
50 TBufferFile* buf2 = new TBufferFile( TBuffer::kRead );
51 TBufferFile* buf3 = new TBufferFile( TBuffer::kRead );
52 buf1->SetBuffer( ( *records )["LayTree"], 512000, kFALSE );
53 buf2->SetBuffer( ( *records )["BoxTree"], 512000, kFALSE );
54 buf3->SetBuffer( ( *records )["StrTree"], 512000, kFALSE );
55 std::cout << " SftVer is " << ( *records )["SftVer"];
56 std::cout << " CalVerSft is " << ( *records )["CalParVer"];
57 std::cout << " File name is " << ( *records )["FileName"] << std::endl;
58
59 TTree* laytree = new TTree();
60 laytree->Streamer( *buf1 );
61 log << MSG::DEBUG << "laytree name:\t" << laytree->GetName() << endmsg;
62 TTree* boxtree = new TTree();
63 boxtree->Streamer( *buf2 );
64 log << MSG::DEBUG << "boxtree name:\t" << boxtree->GetName() << endmsg;
65 TTree* strtree = new TTree();
66 strtree->Streamer( *buf3 );
67 log << MSG::DEBUG << "strtree name:\t" << strtree->GetName() << endmsg;
68
69 // Read in the object
70 // read layerConst-----------------------------
71 Double_t lay_eff, box_eff, str_eff;
72 Double_t lay_cnt, box_cnt, str_cnt;
73 Double_t lay_nos, box_nos, str_nos;
74 Double_t lay_nos_ratio, box_nos_ratio, str_nos_ratio;
75 lay_eff = box_eff = str_eff = 0.0;
76 lay_cnt = box_cnt = str_cnt = 0.0;
77 lay_nos = box_nos = str_nos = 0.0;
78 lay_nos_ratio = box_nos_ratio = str_nos_ratio = 0.0;
79
80 char name[60];
81 laytree->SetBranchAddress( "layer_eff", &lay_eff );
82 laytree->SetBranchAddress( "layer_cnt", &lay_cnt );
83 laytree->SetBranchAddress( "layer_noise", &lay_nos );
84 laytree->SetBranchAddress( "layer_nosratio", &lay_nos_ratio );
85
86 boxtree->SetBranchAddress( "box_eff", &box_eff );
87 boxtree->SetBranchAddress( "box_cnt", &box_cnt );
88 boxtree->SetBranchAddress( "box_noise", &box_nos );
89 boxtree->SetBranchAddress( "box_nosratio", &box_nos_ratio );
90
91 strtree->SetBranchAddress( "strip_eff", &str_eff );
92 strtree->SetBranchAddress( "strip_cnt", &str_cnt );
93 strtree->SetBranchAddress( "strip_noise", &str_nos );
94 strtree->SetBranchAddress( "strip_nosratio", &str_nos_ratio );
95
96 int part, segment, layer, strip;
97 part = segment = layer = strip = 0;
98 for ( int i = 0; i < LAYER_MAX; i++ )
99 {
100 laytree->GetEntry( i );
101 tmpObject->setLayerEff( lay_eff, i );
102 tmpObject->setLayerCnt( lay_cnt, i );
103 tmpObject->setLayerNos( lay_nos, i );
104 tmpObject->setLayerNosRatio( lay_nos_ratio, i );
105 sprintf( name, "LayClstPro" );
106 for ( int j = 0; j < CLST_MAX; j++ )
107 {
108 // if( ht_Pro[0] != NULL )
109 // tmpObject->setLayerClstPro(ht_Pro[0]->GetBinContent(j),i,j);
110 // else tmpObject->setLayerClstPro(DEFAULT_CLST_PRO[j],i,j);
111 tmpObject->setLayerClstPro( DEFAULT_CLST_PRO[j], i, j );
112 }
113 log << MSG::DEBUG << "layer: " << i << "\t" << lay_eff << endmsg;
114 }
115
116 for ( int i = 0; i < BOX_MAX; i++ )
117 {
118 m_ptrIdTr->SetBoxPos( i, &part, &segment, &layer );
119 boxtree->GetEntry( i );
120 tmpObject->setBoxEff( box_eff, part, segment, layer );
121 tmpObject->setBoxCnt( box_cnt, part, segment, layer );
122 tmpObject->setBoxNos( box_nos, part, segment, layer );
123 tmpObject->setBoxNosRatio( box_nos_ratio, part, segment, layer );
124
125 sprintf( name, "BoxClstPro_B%d", i );
126 for ( int j = 0; j < CLST_MAX; j++ )
127 {
128 // if( ht_Pro[1] != NULL )
129 // tmpObject->setBoxClstPro(ht_Pro[1]->GetBinContent(j),part,segment,layer,j); else
130 tmpObject->setBoxClstPro( DEFAULT_CLST_PRO[j], part, segment, layer, j );
131 }
132 log << MSG::DEBUG << "box: " << i << "\t" << box_eff << endmsg;
133 }
134
135 log << MSG::DEBUG << "strtree entries:\t" << strtree->GetEntries() << endmsg;
136 for ( int i = 0; i < STRIP_MAX; i++ )
137 {
138 m_ptrIdTr->SetStripPos( i, &part, &segment, &layer, &strip );
139 strtree->GetEntry( i );
140 tmpObject->setStripEff( str_eff, part, segment, layer, strip );
141 tmpObject->setStripCnt( str_cnt, part, segment, layer, strip );
142 tmpObject->setStripNos( str_nos, part, segment, layer, strip );
143 tmpObject->setStripNosRatio( str_nos_ratio, part, segment, layer, strip );
144 log << MSG::DEBUG << "strip: " << i << "\t" << str_eff << endmsg;
145 }
146
147 refpObject = tmpObject;
148 delete laytree;
149 delete boxtree;
150 delete strtree;
151 return StatusCode::SUCCESS;
152}
sprintf(cut, "kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_" "pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
IMessageSvc * msgSvc()
void setLayerClstPro(const double layerpro, int i, int j)
void setBoxCnt(const double boxcnt, int i, int j, int k)
void setStripNos(const double stripnos, int i, int j, int k, int l)
void setBoxNosRatio(const double boxratio, int i, int j, int k)
void setStripEff(const double stripeff, int i, int j, int k, int l)
void setStripNosRatio(const double stripnosratio, int i, int j, int k, int l)
void setStripCnt(const double stripcnt, int i, int j, int k, int l)
void setBoxEff(const double boxeff, int i, int j, int k)
void setBoxNos(const double boxnos, int i, int j, int k)
void setBoxClstPro(const double boxpro, int i, int j, int k, int l)
TreeCalBaseCnv(ISvcLocator *svc, const CLID &clid)
virtual StatusCode i_createObj(IOpaqueAddress *address, DataObject *&refpObject)
const CLID & objType() const
static const CLID & classID()
TreeMucCalibDataCnv(ISvcLocator *svc)