[atlas] / groups / Asap / pilotcorba / AsapIOVTreeImpl.cc Repository:
ViewVC logotype

Annotation of /groups/Asap/pilotcorba/AsapIOVTreeImpl.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (view) (download)

1 : giraudpf 1.1 #include "AsapIOVTreeImpl.hh"
2 :     #include "AsapSensorSummary.hh"
3 :     #include "AsapCorrection.hh"
4 :     #include "AsapSensorResidual.hh"
5 :     #include "ScopedLock.hh"
6 :     #include "TFile.h"
7 :     #include "TROOT.h"
8 :    
9 :     using namespace asap::pilot::facade::corba;
10 :     using namespace asap::jdbtree::facade::corba;
11 :    
12 :     AsapIOVTreeFactoryImpl* AsapIOVTreeFactoryImpl::iovtreeFactory = NULL;
13 :    
14 :    
15 :     #include <iostream>
16 :     using namespace std;
17 :    
18 :     AsapIOVTreeFactoryImpl::AsapIOVTreeFactoryImpl() :
19 :     PortableServer::RefCountServantBase(),
20 :     POA_asap::pilot::facade::corba::AsapIOVTreeFactory()
21 :     {
22 :     }
23 :    
24 :     AsapIOVTreeFactoryImpl::~AsapIOVTreeFactoryImpl() {
25 :     }
26 :    
27 :    
28 :     AsapIOVTree_ptr AsapIOVTreeFactoryImpl::createTree(const char* name,
29 :     const char* title,
30 :     const char* cacheFilePath) {
31 :     // Synchronize this method
32 :     ScopedLock lock;
33 :    
34 :     TFile* rootFile = NULL;
35 :     if (cacheFilePath && cacheFilePath[0] != '\0') {
36 :     rootFile = TFile::Open(cacheFilePath, "RECREATE");
37 :     if (!rootFile) throw RootException(Form("Cannot open file %s",cacheFilePath));
38 :     rootFile->cd();
39 :     } else {
40 :     gROOT->cd();
41 :     }
42 :    
43 :     AsapIOVTreeImpl* impl = new AsapIOVTreeImpl(new TTree(name, title), rootFile);
44 :     // ServantBase takes ownership of the new object. This is mandatory for correct reference counting.
45 :     PortableServer::ServantBase_var servant = impl;
46 :     AsapIOVTree_var rootTree = impl->POA_asap::pilot::facade::corba::AsapIOVTree::_this(); // side effect: increment reference count.
47 :     return rootTree._retn(); // give up ownership of the servant
48 :     }
49 :    
50 :     AsapIOVTreeFactoryImpl* AsapIOVTreeFactoryImpl::getInstance() {
51 :     if(!iovtreeFactory) {
52 :     iovtreeFactory = new AsapIOVTreeFactoryImpl;
53 :     }
54 :     return iovtreeFactory;
55 :     }
56 :    
57 :    
58 :     AsapIOVTreeImpl::AsapIOVTreeImpl(TTree *tree, TFile *rootFile)
59 :     : RootTreeImpl (tree, rootFile)
60 :     {
61 :     _iov = new AsapIOV();
62 :     tree->Branch("iov", "AsapIOV", &_iov);
63 :     // a few aliases for easy command line plotting
64 :     tree->SetAlias("rh", "iov.resultHeader");
65 :     tree->SetAlias("dr", "iov.resultHeader.distanceResult");
66 :     tree->SetAlias("cr", "iov.resultHeader.correction");
67 :     tree->SetAlias("sr", "iov.resultHeader.sensorResidual");
68 :     tree->SetAlias("fr", "iov.resultHeader.fitresult");
69 :     }
70 :     AsapIOVTreeImpl::~AsapIOVTreeImpl() {
71 :    
72 :     }
73 :     void AsapIOVTreeImpl::addIOV(const AlignIOV& corbaIOV) {
74 :     // Synchronize this method
75 :     ScopedLock lock;
76 :    
77 :     _iov -> Clear ();
78 :    
79 :     _iov -> setSinceT (corbaIOV.since);
80 :     _iov -> setTillT (corbaIOV.till);
81 :     _iov -> setIovId (corbaIOV.iov_id);
82 :     _iov -> setTag ("");
83 :    
84 :     if (corbaIOV.results.length() == 0) return;
85 :     const AlignResult& corbaResult = corbaIOV.results[0];
86 :     AsapResultHeader* header = _iov -> newResultHeader ();
87 :     header -> setSinceT (corbaResult.icarasSince);
88 :     header -> setTillT (corbaResult.icarasTill);
89 :     header -> setCycleStart (corbaResult.cycleStart);
90 :     header -> setCycleEnd (corbaResult.cycleEnd);
91 :     header -> setChi2 (corbaResult.chi2);
92 :     header -> setNDOF (corbaResult.nDOF);
93 :     header -> setChi2Norm (corbaResult.chi2norm);
94 :    
95 :     header -> setNIteration (corbaResult.nIteration);
96 :     header -> setNMaxIteration (corbaResult.nMaxIteration);
97 :     header -> setExitReason (corbaResult.exitReason);
98 :    
99 :     int nSensorSummary = corbaIOV.sensorsummary.length();
100 :     for (int i=0; i<nSensorSummary; i++) {
101 :     AsapSensorSummary* summary = header -> newSensorSummary ();
102 :     summary -> setSensorType ((const char*)corbaIOV.sensorsummary[i].sensorType);
103 :     summary -> setNSensorsTotal (corbaIOV.sensorsummary[i].nSensorTotal);
104 :     summary -> setNSensorsFailure (corbaIOV.sensorsummary[i].nSensorFailure);
105 :     }
106 :    
107 :     int nCorr = corbaIOV.corrections.length();
108 :     for (int i=0; i<nCorr; i++) {
109 :     AsapCorrection* corr = header -> newCorrection ();
110 :     const AlignCorrection& corbaCorr = corbaIOV.corrections[i];
111 :    
112 :     corr -> setSinceT (corbaIOV.since);
113 :     corr -> setTillT (corbaIOV.till);
114 :     corr -> setAsapID ((const char*)corbaCorr.asap_id);
115 :     corr -> setAsapType ((const char*)corbaCorr.asap_type);
116 :    
117 :     corr -> setAmdbTyp ((const char*)corbaCorr.amdb_typ);
118 :     corr -> setAmdbJff (corbaCorr.amdb_jff);
119 :     corr -> setAmdbJzz (corbaCorr.amdb_jzz);
120 :     corr -> setAmdbJob (corbaCorr.amdb_job);
121 :    
122 :     corr -> setS (corbaCorr.s);
123 :     corr -> setZ (corbaCorr.z);
124 :     corr -> setT (corbaCorr.t);
125 :     corr -> setThetaS (corbaCorr.thetas);
126 :     corr -> setThetaZ (corbaCorr.thetaz);
127 :     corr -> setThetaT (corbaCorr.thetat);
128 :    
129 :     corr -> setXAtlas (corbaCorr.xatlas);
130 :     corr -> setYAtlas (corbaCorr.yatlas);
131 :    
132 : giraudpf 1.2 // corr -> setTORTION(corbaCorr.tortion);
133 :     // corr -> setSAGRO (corbaCorr.sagro );
134 :     // corr -> setSAGHV (corbaCorr.saghv );
135 :     // corr -> setDWRO (corbaCorr.dwro );
136 :     // corr -> setDWHV (corbaCorr.dwhv );
137 :     // corr -> setSAGLBV (corbaCorr.saglbv);
138 :     // corr -> setSAGLBH (corbaCorr.saglbh);
139 :     // corr -> setDWAC (corbaCorr.dwac );
140 :     // corr -> setTEMP (corbaCorr.temp );
141 : giraudpf 1.1 }
142 :    
143 :     int nSensorResidual = corbaIOV.sensorresidual.length();
144 :     for(int i = 0; i < nSensorResidual; i++) {
145 :     AsapSensorResidual* res = header -> newSensorResidual ();
146 :     const AlignSensorResidual& corbaSensorResidual = corbaIOV.sensorresidual[i];
147 :    
148 :     res -> setChannelName ((const char*)corbaSensorResidual.channelName );
149 :     res -> setType ((const char*)corbaSensorResidual.type );
150 :     res -> setNMeas (corbaSensorResidual.nmeas );
151 :     res -> setDistCL (corbaSensorResidual.distCL );
152 :     res -> setDistLM (corbaSensorResidual.distLM );
153 :    
154 :     for (int imes = 0; imes < res->getNMeas(); imes++) {
155 :     AsapSensorMeasurement& m = res->at(imes);
156 :     const AlignSensorMeasurement& c = corbaSensorResidual.meas[imes];
157 :     m.setId ((const char*)c.id);
158 :     m.setMeas (c.meas );
159 :     m.setModel (c.model );
160 :     m.setError (c.error );
161 :     m.setMeasraw (c.measraw );
162 :     m.setMeasrawerror (c.measrawerror );
163 :     m.setMeasrawnpoints (c.measrawnpoints);
164 :     }
165 :     }
166 :    
167 :     tree -> Fill ();
168 :    
169 :     }

CERN Central CVS service
ViewVC Help
Powered by ViewVC 1.0.9