BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TreeDedxSimDataCnv.cxx
Go to the documentation of this file.
2#include "CalibData/Dedx/DedxSimData.h"
3#include "CalibDataSvc/IInstrumentName.h"
4#include "CalibMySQLCnvSvc/TreeAddress.h"
5#include "GaudiKernel/MsgStream.h"
6#include "TBuffer.h"
7#include "TBufferFile.h"
8#include "TDirectory.h"
9#include "TFile.h"
10#include "TObject.h"
11#include "TROOT.h"
12#include "TTree.h"
13
14#include "GaudiKernel/DataObject.h"
15#include "GaudiKernel/GenericAddress.h"
16#include "GaudiKernel/IAddressCreator.h"
17#include "GaudiKernel/IConversionSvc.h"
18#include "GaudiKernel/IDataProviderSvc.h"
19#include "GaudiKernel/IOpaqueAddress.h"
20
21#include "CalibDataSvc/ICalibMetaCnvSvc.h"
22#include "CalibDataSvc/ICalibTreeSvc.h" //maybe
23
24// Temporary. Hope to find a better way to do this
25#include "CalibData/CalibModel.h"
26using namespace CalibData;
27// static CnvFactory<TreeDedxSimDataCnv> DedxCal_factory;
28// const ICnvFactory& TreeDedxSimDataCnvFactory = DedxCal_factory;
29
32
33const CLID& TreeDedxSimDataCnv::objType() const { return CLID_Dedx_Sim; }
34
36
37StatusCode TreeDedxSimDataCnv::i_createObj( IOpaqueAddress* addr, DataObject*& refpObject ) {
38
39 MsgStream log( msgSvc(), "TreeDedxSimDataCnv" );
40
42 TreeAddress* add = dynamic_cast<TreeAddress*>( addr );
43 DatabaseRecord* records = add->pp();
44
45 TBufferFile* buf1 = new TBufferFile( TBuffer::kRead );
46 TBufferFile* buf2 = new TBufferFile( TBuffer::kRead );
47
48 buf1->SetBuffer( ( *records )["TH1F_Col"], 51200000, kFALSE );
49 buf2->SetBuffer( ( *records )["bin"], 512000, kFALSE );
50
51 std::cout << " SftVer is " << ( *records )["SftVer"];
52 std::cout << " CalVerSft is " << ( *records )["CalParVer"];
53 std::cout << " File name is " << ( *records )["FileName"] << std::endl;
54
55 // TClass *myclass=gROOT->GetClass("TTree");
56 // TTree *tree =(TTree*)buf1->ReadObject(myclass);
57 TTree* tree = new TTree();
58 tree->Streamer( *buf1 );
59
60 TTree* bin = new TTree();
61 bin->Streamer( *buf2 );
62
63 TH1F* h1 = new TH1F();
64
65 std::vector<TH1F> hist;
66 std::vector<double> hRange;
67 // Read in the object
68 int cnt;
69 tree->SetBranchAddress( "TH1F_Col", &h1 );
70 int entries = tree->GetEntries();
71 for ( cnt = 0; cnt < entries; cnt++ )
72 {
73 tree->GetEntry( cnt );
74 gROOT->cd();
75 TH1F* h2 = new TH1F();
76 h2 = (TH1F*)h1->Clone();
77 hist.push_back( *h2 );
78 }
79 int ver;
80 double betagamma[5000];
81 int totalNum;
82 int bgNum;
83 int thetaNum;
84 if ( bin->FindBranch( "version" ) ) bin->SetBranchAddress( "version", &ver );
85 else ver = 0;
86 if ( bin->FindBranch( "thetaNum" ) ) bin->SetBranchAddress( "thetaNum", &thetaNum );
87 else thetaNum = 16;
88 bin->SetBranchAddress( "totalNum", &totalNum );
89 bin->SetBranchAddress( "betagamma", betagamma );
90 bin->SetBranchAddress( "betagammaBounds", &bgNum );
91 bin->GetEntry( 0 );
92 // int tot=totalNum*2;
93 for ( cnt = 0; cnt < bgNum; cnt++ ) { hRange.push_back( betagamma[cnt] ); }
94 tmpObject->setVersion( ver );
95 tmpObject->setRangeNo( bgNum );
96 tmpObject->setRange( &hRange );
97 tmpObject->setHistNo( totalNum );
98 tmpObject->setThetaNo( thetaNum );
99 tmpObject->setHist( &hist );
100 refpObject = tmpObject;
101
102 delete tree;
103 delete bin;
104
105 return StatusCode::SUCCESS;
106}
*******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 bin
Definition FoamA.h:85
IMessageSvc * msgSvc()
void setHist(const vector< TH1F > *hist)
void setRange(const vector< double > *hRange)
TreeCalBaseCnv(ISvcLocator *svc, const CLID &clid)
TreeDedxSimDataCnv(ISvcLocator *svc)
virtual StatusCode i_createObj(IOpaqueAddress *address, DataObject *&refpObject)
const CLID & objType() const
static const CLID & classID()