BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
RootMdcCalibDataCnv Class Reference

#include <RootMdcCalibDataCnv.h>

Inheritance diagram for RootMdcCalibDataCnv:

Public Member Functions

const CLID & objType () const
 RootMdcCalibDataCnv (ISvcLocator *svc)
virtual ~RootMdcCalibDataCnv ()
virtual StatusCode createRoot (const std::string &fname, CalibData::CalibBase1 *pTDSObj)
virtual long repSvcType () const
Public Member Functions inherited from RootCalBaseCnv
virtual ~RootCalBaseCnv ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode createObj (IOpaqueAddress *addr, DataObject *&refpObject)
ICalibRootSvcgetCalibRootSvc ()
 RootCalBaseCnv (ISvcLocator *svc, const CLID &clid)
virtual StatusCode readRootObj (const std::string &treename, const std::string &branch, TObject *&pCalib, unsigned index=0)
virtual StatusCode readRootObj (TTree *tree, const std::string &branch, TObject *&pCalib, unsigned index=0)
Public Member Functions inherited from Converter< Ty1, Ty2 >
destinationoperator (const source &) const
destinationoperator (const source &) const
destinationoperator (const source &) const

Static Public Member Functions

static const CLID & classID ()
Static Public Member Functions inherited from RootCalBaseCnv
static const unsigned char storageType ()

Protected Member Functions

virtual StatusCode i_createObj (const std::string &fname, DataObject *&refpObject)
Protected Member Functions inherited from RootCalBaseCnv
virtual StatusCode internalCreateObj (const std::string &fname, DataObject *&refpObject, IOpaqueAddress *address)
virtual StatusCode i_processObj (DataObject *pObject, IOpaqueAddress *address)
 In case there is additional work to do on the created object.
virtual StatusCode fillRoot (CalibData::CalibBase *pTDSObj, TObject *pRootObj)
virtual StatusCode openWrite (const std::string &fname)
StatusCode closeWrite ()
StatusCode openRead (const std::string &fname)
StatusCode closeRead ()
void setBaseInfo (CalibData::CalibBase1 *pObj)
 Another utility for derived classes to use.
Protected Member Functions inherited from Converter< Ty1, Ty2 >
virtual destinationconvert (const source &) const =0
virtual destinationconvert (const source &) const =0
virtual destinationconvert (const source &) const =0

Friends

class CnvFactory< RootMdcCalibDataCnv >

Additional Inherited Members

Public Types inherited from Converter< Ty1, Ty2 >
typedef Ty1 source
typedef Ty2 destination
typedef Ty1 source
typedef Ty2 destination
typedef Ty1 source
typedef Ty2 destination
Protected Attributes inherited from RootCalBaseCnv
ICalibRootSvcm_rootSvc
ICalibMetaCnvSvcm_metaSvc
IInstrumentNamem_instrSvc
int m_serNo
ITime * m_vstart
ITime * m_vend
int m_runfrm
int m_runto
TFile * m_outFile
TTree * m_ttree
TFile * m_inFile
TDirectory * m_saveDir

Detailed Description

Base class for CAL calibration converters from ROOT files to TCDS. All such converters need to do certain things, which are handled here. Methods common to all calibrations are in the base class RootCalBaseCnv

Author
J. Bogart

Definition at line 23 of file RootMdcCalibDataCnv.h.

Constructor & Destructor Documentation

◆ RootMdcCalibDataCnv()

RootMdcCalibDataCnv::RootMdcCalibDataCnv ( ISvcLocator * svc)

Definition at line 33 of file RootMdcCalibDataCnv.cxx.

RootCalBaseCnv(ISvcLocator *svc, const CLID &clid)

◆ ~RootMdcCalibDataCnv()

virtual RootMdcCalibDataCnv::~RootMdcCalibDataCnv ( )
inlinevirtual

Definition at line 32 of file RootMdcCalibDataCnv.h.

32{};

Member Function Documentation

◆ classID()

const CLID & RootMdcCalibDataCnv::classID ( )
static

Definition at line 38 of file RootMdcCalibDataCnv.cxx.

38{ return CLID_Calib_MdcCal; }

Referenced by CalibRootCnvSvc::createConverter().

◆ createRoot()

StatusCode RootMdcCalibDataCnv::createRoot ( const std::string & fname,
CalibData::CalibBase1 * pTDSObj )
virtual

Create ROOT file corresponding to TDS object input. Default implementation is to return an error. Must be separately implemented for each calibration type.

Parameters
fnameFilename for output file
pTDSObjPointer to tds object to be converted

Reimplemented from RootCalBaseCnv.

Definition at line 151 of file RootMdcCalibDataCnv.cxx.

152 {
153
154 MsgStream log( msgSvc(), "RootMdcCalibDataCnv" );
155 // Open the file, create the branch
156 StatusCode sc = openWrite( fname );
157 if ( !sc ) { log << MSG::ERROR << "unable to open files" << endmsg; }
158 // write the Data in the TCDS to RootFile
159 CalibData::MdcCalibData* tmpObject = dynamic_cast<CalibData::MdcCalibData*>( pTDSObj );
160 int tmpNo;
161 int key;
162 double xtpar;
163 double t0;
164 double delt0;
165 double qtpar[2];
166 double sdpar;
167 int i;
168
169 // xttree------------------------------------------------------------------
170 TTree* xttree = new TTree( "XtTree", "XtTree" );
171 xttree->Branch( "xtkey", &key, "key/I" );
172 xttree->Branch( "xtpar", &xtpar, "xtpar/D" );
173 tmpObject->setXtBegin();
174 while ( tmpObject->getNextXtpar( key, xtpar ) ) { xttree->Fill(); }
175 // newxttree------------------------------------------------------------------
176 // FIXME
177 /*
178 TObjArray newxttrees_1;
179 //TBufferFile newxttrees_buf(TBuffer::kWrite);
180 int nTree=0;
181 for(int t_layer=0; t_layer<43; t_layer++){
182 for(int t_bin=0; t_bin<18; t_bin++){
183 for(int t_lr=0; t_lr<2; t_lr++){
184 char newXtTreeName[20];
185 sprintf(newXtTreeName,"trNewXt%02d_%02d_%d",t_layer,t_bin,t_lr);
186 TTree *newXttree = ((TTree*)f->Get(newXtTreeName))->CloneTree();
187 newxttrees_1.Add(newXttree);
188 nTree++;
189 }
190 }
191 }
192 newxttrees_1.Streamer(newxttrees_buf);
193 */
194
195 // t0tree-------------------------------------------------------------------
196 TTree* t0tree = new TTree( "T0Tree", "T0Tree" );
197 t0tree->Branch( "t0", &t0, "t0/D" );
198 t0tree->Branch( "delt0", &delt0, "delt0/D" );
199 tmpNo = tmpObject->gett0No();
200 for ( i = 0; i < tmpNo; i++ )
201 {
202 t0 = tmpObject->getT0( i );
203 delt0 = tmpObject->getDelT0( i );
204 t0tree->Fill();
205 }
206
207 // qttree--------------------------------------------------------------------
208 TTree* qttree = new TTree( "QtTree", "QtTree" );
209 qttree->Branch( "qtpar0", &( qtpar[0] ), "qtpar0/D" );
210 qttree->Branch( "qtpar1", &( qtpar[1] ), "qtpar1/D" );
211 tmpNo = tmpObject->getqtparNo();
212 for ( i = 0; i < tmpNo; i++ )
213 {
214 qtpar[0] = tmpObject->getQtpar0( i );
215 qtpar[1] = tmpObject->getQtpar1( i );
216 qttree->Fill();
217 }
218
219 // sdtree--------------------------------------------------------------------
220 TTree* sdtree = new TTree( "SdTree", "SdTree" );
221 sdtree->Branch( "sdkey", &key, "key/I" );
222 sdtree->Branch( "sdpar", &sdpar, "sdpar/D" );
223 tmpObject->setSdBegin();
224 while ( tmpObject->getNextSdpar( key, sdpar ) ) { sdtree->Fill(); }
225
226 xttree->Write();
227 t0tree->Write();
228 qttree->Write();
229 sdtree->Write();
230
231 delete xttree;
232 delete t0tree;
233 delete qttree;
234 delete sdtree;
235
236 closeWrite();
237 log << MSG::INFO << "successfully create RootFile" << endmsg;
238 return sc;
239}
IMessageSvc * msgSvc()
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
Definition Taupair.h:42
int getNextXtpar(int &key, double &xtpar)
int getNextSdpar(int &key, double &sdpar)
StatusCode closeWrite()
virtual StatusCode openWrite(const std::string &fname)

◆ i_createObj()

StatusCode RootMdcCalibDataCnv::i_createObj ( const std::string & fname,
DataObject *& refpObject )
protectedvirtual

This creates the transient representation of an object from the corresponding ROOT object. This actually does the "new" operation and deals with the attributes of the node. This base class implementation does nothing; it should not normally be called because it doesn't correspond to any TCDS class. Instead, i_createObj of some derived class will be called.

Parameters
fnameThe ROOT file to be read in to be used to builds the object
refpObjectthe object to be built
Returns
status depending on the completion of the call

Reimplemented from RootCalBaseCnv.

Definition at line 40 of file RootMdcCalibDataCnv.cxx.

41 {
42
43 MsgStream log( msgSvc(), "RootMdcCalibDataCnv" );
44 log << MSG::DEBUG << "SetProperty" << endmsg;
45
46 StatusCode sc = openRead( fname );
47 if ( !sc ) { log << MSG::ERROR << "unable to open files" << endmsg; }
48
49 CalibData::MdcCalibData* tmpObject = new CalibData::MdcCalibData;
50 // Read in our object
51 int i;
52 int nentries;
53 // read xttree ------------------------------------------------------------
54 double xtpar;
55 int xtkey;
56 TTree* xttree = (TTree*)m_inFile->Get( "XtTree" );
57 xttree->SetBranchAddress( "xtpar", &xtpar );
58 xttree->SetBranchAddress( "xtkey", &xtkey );
59 nentries = xttree->GetEntries();
60 for ( i = 0; i < nentries; i++ )
61 {
62 xttree->GetEntry( i );
63 tmpObject->setXtpar( xtkey, xtpar );
64 }
65
66 // read newxttree ------------------------------------------------------------
67 TObjArray newXtTrees;
68 if ( NULL != m_inFile->Get( "trNewXt00_00_0" ) )
69 {
70 for ( int layid = 0; layid < 43; layid++ )
71 {
72 for ( int entr = 0; entr < 18; entr++ )
73 {
74 for ( int lr = 0; lr < 2; lr++ )
75 {
76 char newXtTreeName[20];
77 sprintf( newXtTreeName, "trNewXt%02d_%02d_%d", layid, entr, lr );
78 TTree* newXtTree = ( (TTree*)m_inFile->Get( newXtTreeName ) );
79 newXtTree->SetCacheSize(10000000);
80 if ( !newXtTree ) break;
81 newXtTrees.Add( newXtTree->CloneTree() );
82 } // end lr
83 } // end entr
84 } // end layid
85 if ( ( 43 * 18 * 2 ) == newXtTrees.GetEntries() ) tmpObject->setNewXtpar( &newXtTrees );
86 }
87
88 // read r2ttree ------------------------------------------------------------
89 TObjArray r2tTrees;
90 if ( NULL != m_inFile->Get( "r2t00" ) )
91 {
92 for ( int layid = 0; layid < 43; layid++ )
93 {
94 char r2tTreeName[20];
95 sprintf( r2tTreeName, "r2t%02d", layid );
96 TTree* r2tTree = ( (TTree*)m_inFile->Get( r2tTreeName ) );
97 if ( !r2tTree ) break;
98 // reduce Memerey use
99 r2tTree->SetCacheSize( 2500 );
100 r2tTrees.Add( r2tTree->CloneTree() );
101 }
102 if ( 43 == r2tTrees.GetEntries() ) tmpObject->setR2tpar( &r2tTrees );
103 }
104
105 // read t0tree ------------------------------------------------------------
106 double t0;
107 double delt0;
108 TTree* t0tree = (TTree*)m_inFile->Get( "T0Tree" );
109 t0tree->SetBranchAddress( "t0", &t0 );
110 t0tree->SetBranchAddress( "delt0", &delt0 );
111 nentries = t0tree->GetEntries();
112 for ( i = 0; i < nentries; i++ )
113 {
114 t0tree->GetEntry( i );
115 tmpObject->setT0( t0 );
116 tmpObject->setDelT0( delt0 );
117 }
118
119 // read qttree ------------------------------------------------------------
120 double qtpar0;
121 double qtpar1;
122 TTree* qttree = (TTree*)m_inFile->Get( "QtTree" );
123 qttree->SetBranchAddress( "qtpar0", &qtpar0 );
124 qttree->SetBranchAddress( "qtpar1", &qtpar1 );
125 nentries = qttree->GetEntries();
126 for ( i = 0; i < nentries; i++ )
127 {
128 qttree->GetEntry( i );
129 tmpObject->setQtpar0( qtpar0 );
130 tmpObject->setQtpar1( qtpar1 );
131 }
132
133 // read Sdtree ---------------------------------------------------------
134 double sdpar;
135 int sdkey;
136 TTree* sdtree = (TTree*)m_inFile->Get( "SdTree" );
137 sdtree->SetBranchAddress( "sdpar", &sdpar );
138 sdtree->SetBranchAddress( "sdkey", &sdkey );
139 nentries = sdtree->GetEntries();
140
141 for ( i = 0; i < nentries; i++ )
142 {
143 sdtree->GetEntry( i );
144 tmpObject->setSdpar( sdkey, sdpar );
145 }
146
147 refpObject = tmpObject;
148 return StatusCode::SUCCESS;
149}
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)
Int_t nentries
void setR2tpar(TObjArray *r2tTrees)
void setQtpar1(double val)
void setXtpar(int xtkey, double val)
void setNewXtpar(TObjArray *newXtTrees)
void setSdpar(int sdkey, double val)
void setDelT0(double val)
void setQtpar0(double val)
StatusCode openRead(const std::string &fname)

◆ objType()

const CLID & RootMdcCalibDataCnv::objType ( ) const

Definition at line 36 of file RootMdcCalibDataCnv.cxx.

36{ return CLID_Calib_MdcCal; }

◆ repSvcType()

virtual long RootMdcCalibDataCnv::repSvcType ( ) const
inlinevirtual

Definition at line 36 of file RootMdcCalibDataCnv.h.

◆ CnvFactory< RootMdcCalibDataCnv >

friend class CnvFactory< RootMdcCalibDataCnv >
friend

Definition at line 1 of file RootMdcCalibDataCnv.h.


The documentation for this class was generated from the following files: