BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
TreeTofSimCnv.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2#include "TreeTofSimCnv.h"
6#include "TFile.h"
7#include "TTree.h"
8#include "TDirectory.h"
9#include "TObject.h"
10#include "TBuffer.h"
11
12#include "GaudiKernel/CnvFactory.h"
13#include "GaudiKernel/IOpaqueAddress.h"
14#include "GaudiKernel/DataObject.h"
15#include "GaudiKernel/IAddressCreator.h"
16#include "GaudiKernel/IDataProviderSvc.h"
17#include "GaudiKernel/IConversionSvc.h"
18#include "GaudiKernel/GenericAddress.h"
19
20#include "CalibDataSvc/ICalibTreeSvc.h" //maybe
22
23// Temporary. Hope to find a better way to do this
25using namespace CalibData;
26//static CnvFactory<TreeTofSimDataCnv> TofCal_factory;
27//const ICnvFactory& TreeTofSimDataCnvFactory = TofCal_factory;
28
29
30
35
36
37const CLID& TreeTofSimDataCnv::objType() const {
38 return CLID_Calib_TofSim;
39}
40
42 return CLID_Calib_TofSim;
43}
44
45StatusCode TreeTofSimDataCnv::i_createObj(IOpaqueAddress* addr,
46 DataObject*& refpObject) {
47
48 MsgStream log(msgSvc(), "TreeTofSimDataCnv");
49 log<<MSG::DEBUG<<"SetProperty"<<endreq;
50
51 TreeAddress* add = dynamic_cast<TreeAddress*>(addr);
52
53 DatabaseRecord *records=add->pp();
54
55 TBufferFile *buf1 = new TBufferFile(TBuffer::kRead);
56 TBufferFile *buf2 = new TBufferFile(TBuffer::kRead);
57 TBufferFile *buf3 = new TBufferFile(TBuffer::kRead);
58
59 buf1->SetBuffer((*records)["BTofSim"],512000,kFALSE);
60 buf2->SetBuffer((*records)["ETofSim"],512000,kFALSE);
61 buf3->SetBuffer((*records)["SimConstants"],512000,kFALSE);
62
63
64 std::cout<<" SftVer is "<<(*records)["SftVer"];
65 std::cout<<" CalVerSft is "<<(*records)["TofSimParVer"];
66 std::cout<<" File name is "<<(*records)["FileName"]<<std::endl;
67
68
69
70 TTree *btoftree= new TTree();
71 TTree *etoftree= new TTree();
72 TTree *btofcommontree = new TTree();
73 btoftree->Streamer(*buf1);
74 etoftree->Streamer(*buf2);
75 btofcommontree->Streamer(*buf3);
76
80 std::vector<CalibData::BTofSimBase> tmpbTof;//; = new vector<CalibData::bTofCalibBase>;
81 std::vector<CalibData::ETofSimBase> tmpeTof;
82 std::vector<CalibData::TofSimConstBase> tofbaseCol;
83 // Read in the object
84 int cnt;
85 // read btoftree ------------------------------------------------------------
86 double AttenLength;
87 double Gain;
88 double Ratio;
89 double NoiseSmear;
90 btoftree -> SetBranchAddress("AttenLength", &AttenLength);
91 btoftree -> SetBranchAddress("Gain", &Gain);
92 btoftree -> SetBranchAddress("Ratio", &Ratio);
93 int entries=btoftree->GetEntries();
94 for(cnt=0; cnt<entries; cnt++){
95 btoftree -> GetEntry(cnt);
96 bTof.setGain(Gain);
97 bTof.setRatio(Ratio);
98 bTof.setAttenLength(AttenLength);
99 tmpbTof.push_back(bTof);
100 }
101 //read etoftree
102 etoftree -> SetBranchAddress("Gain", &Gain);
103 etoftree -> SetBranchAddress("AttenLength", &AttenLength);
104 etoftree -> SetBranchAddress("NoiseSmear", &NoiseSmear );
105 entries=etoftree->GetEntries();
106 for(cnt=0; cnt<entries; cnt++){
107 etoftree->GetEntry(cnt);
108 eTof.setGain(Gain);
109 eTof.setAttenLength(AttenLength);
110 eTof.setNoiseSmear(NoiseSmear);
111 tmpeTof.push_back(eTof);
112 }
113 //read SimConstants
114 double BarConstant,BarPMTGain,BarHighThres,BarLowThres,EndConstant,EndPMTGain,EndHighThres,EndLowThres,EndNoiseSwitch;
115 btofcommontree-> SetBranchAddress("BarConstant", &BarConstant);
116 btofcommontree-> SetBranchAddress("BarPMTGain", &BarPMTGain);
117 btofcommontree-> SetBranchAddress("BarHighThres", &BarHighThres);
118 btofcommontree-> SetBranchAddress("BarLowThres", &BarLowThres);
119 btofcommontree-> SetBranchAddress("EndConstant", &EndConstant);
120 btofcommontree-> SetBranchAddress("EndPMTGain", &EndPMTGain);
121 btofcommontree-> SetBranchAddress("EndHighThres", &EndHighThres);
122 btofcommontree-> SetBranchAddress("EndLowThres", &EndLowThres);
123 btofcommontree-> SetBranchAddress("EndNoiseSwitch", &EndNoiseSwitch);
124 entries = btofcommontree->GetEntries();
125 for(cnt=0;cnt<entries;cnt++){
126 btofcommontree->GetEntry(cnt);
127 tofbase.setBarLowThres(BarLowThres);
128 tofbase.setBarHighThres(BarHighThres);
129 tofbase.setEndLowThres(EndLowThres);
130 tofbase.setEndHighThres(EndHighThres);
131 tofbase.setBarPMTGain(BarPMTGain);
132 tofbase.setEndPMTGain(EndPMTGain);
133 tofbase.setBarConstant(BarConstant);
134 tofbase.setEndConstant(EndConstant);
135 tofbase.setEndNoiseSwitch(EndNoiseSwitch);
136 tofbaseCol.push_back(tofbase);
137 }
138
139 CalibData::TofSimData *tmpObject = new CalibData::TofSimData(&tofbaseCol,&tmpbTof,&tmpeTof);
140 refpObject=tmpObject;
141 delete btoftree;
142 delete etoftree;
143 delete btofcommontree;
144
145 return StatusCode::SUCCESS;
146
147
148}
149
const CLID CLID_Calib_TofSim
Definition CalibModel.h:59
data GetEntry(0)
data SetBranchAddress("time",&time)
IMessageSvc * msgSvc()
void setRatio(double ratio)
Definition BTofSimBase.h:16
void setGain(double gain)
Definition BTofSimBase.h:15
void setAttenLength(double length)
Definition BTofSimBase.h:17
void setGain(double gain)
Definition ETofSimBase.h:14
void setAttenLength(double length)
Definition ETofSimBase.h:15
void setNoiseSmear(double noisesmear)
Definition ETofSimBase.h:16
void setBarConstant(const double bc)
void setBarHighThres(const double bhth)
void setEndNoiseSwitch(const double eswitch)
void setEndHighThres(const double ehth)
void setEndConstant(const double ec)
void setBarPMTGain(const double bg)
void setEndPMTGain(const double eg)
void setEndLowThres(const double elth)
void setBarLowThres(const double blth)
virtual DatabaseRecord * pp()
virtual StatusCode i_createObj(IOpaqueAddress *address, DataObject *&refpObject)
const CLID & objType() const
TreeTofSimDataCnv(ISvcLocator *svc)
static const CLID & classID()