[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.1 - (view) (download)

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

CERN Central CVS service
ViewVC Help
Powered by ViewVC 1.0.9