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