CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/CondCore/RPCPlugins/plugins/RPCObTempPyWrapper.cc

Go to the documentation of this file.
00001 #include "CondFormats/RPCObjects/interface/RPCObCond.h"
00002 #include "CondFormats/RPCObjects/interface/RPCObPVSSmap.h"
00003 
00004 #include "CondCore/Utilities/interface/PayLoadInspector.h"
00005 #include "CondCore/Utilities/interface/InspectorPythonWrapper.h"
00006 
00007 #include "CondCore/DBCommon/interface/DbConnection.h"
00008 #include "CondCore/DBCommon/interface/DbConnectionConfiguration.h"
00009 //#include "CondCore/DBCommon/interface/DbSession.h"
00010 #include "CondCore/DBCommon/interface/DbTransaction.h"
00011 
00012 //#include "CondCore/ORA/interface/Database.h"
00013 //#include "CondCore/DBCommon/interface/PoolToken.h"
00014 
00015 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
00016 //#include "DataFormats/GeometryVector/interface/LocalPoint.h"
00017 //#include "DataFormats/GeometrySurface/interface/Surface.h"
00018 
00019 //#include "Geometry/RPCGeometry/interface/RPCGeometry.h"
00020 #include "Geometry/RPCGeometry/interface/RPCGeomServ.h"
00021 
00022 //timestamp stuff
00023 //#include "DataFormats/Provenance/interface/Timestamp.h"
00024 #include <sys/time.h>
00025 
00027 #include "TROOT.h"
00028 #include "TCanvas.h"
00029 #include "TStyle.h"
00030 #include "TColor.h"
00031 #include "TLine.h"
00032 #include "TVirtualPad.h"
00033 #include "TH1D.h"
00034 #include "TH2D.h"
00035 #include "TGraph.h"
00036 #include "TMultiGraph.h"
00037 #include "TLegend.h"
00038 #include "TF1.h"
00039 #include "TPaveStats.h"
00040 #include "TPaveText.h"
00041 
00042 #include <string>
00043 #include <fstream>
00044 #include <sstream>
00045 #include <algorithm>
00046 #include <numeric>
00047 #include <iterator>
00048 #include <iostream>
00049 #include <fstream>
00050 #include <utility>
00051 #include <iomanip>
00052 #include <boost/ref.hpp>
00053 #include <boost/bind.hpp>
00054 #include <boost/function.hpp>
00055 #include <boost/shared_ptr.hpp>
00056 #include <boost/iterator/transform_iterator.hpp>
00057 
00058 using std::pair;
00059 using std::make_pair;
00060 
00061 namespace cond {
00062 
00063   namespace rpcobtemp {
00064     enum How { detid, day, time, temp};
00065 
00066     void extractDetId(RPCObTemp const & pl, std::vector<int> const & which,std::vector<float> & result,const float& starttime, const float& endtime) {
00067       std::vector<RPCObTemp::T_Item> const & imon = pl.ObTemp_rpc;
00068       for(unsigned int i = 0; i < imon.size(); ++i ){
00069         if (which[0] == 0){
00070           result.push_back(imon[i].dpid);
00071         }
00072         else{
00073           if(imon[i].dpid == which[0])
00074             result.push_back(imon[i].dpid);
00075         }
00076       }
00077     }
00078     
00079     void extractDay(RPCObTemp const & pl, std::vector<int> const & which,std::vector<float> & result,const float& starttime, const float& endtime) {
00080       std::vector<RPCObTemp::T_Item> const & imon = pl.ObTemp_rpc;
00081       for(unsigned int i = 0; i < imon.size(); ++i ){
00082         if (which[0] == 0){
00083           result.push_back(imon[i].day);
00084         }
00085         else{
00086           if(imon[i].dpid == which[0])
00087             result.push_back(imon[i].day);
00088         }
00089       }
00090     }
00091 
00092     void extractTime(RPCObTemp const & pl, std::vector<int> const & which,std::vector<float> & result,const float& starttime, const float& endtime) {
00093       std::vector<RPCObTemp::T_Item> const & imon = pl.ObTemp_rpc;
00094       for(unsigned int i = 0; i < imon.size(); ++i ){
00095         if (which[0] == 0){
00096           result.push_back(imon[i].time);
00097         }
00098         else{
00099           if(imon[i].dpid == which[0])
00100             result.push_back(imon[i].time);
00101         }
00102       }
00103     }
00104 
00105     void extractTemp(RPCObTemp const & pl, std::vector<int> const & which,std::vector<float> & result,const float& starttime,const float& endtime) {
00106       std::vector<RPCObTemp::T_Item> const & imon = pl.ObTemp_rpc;
00107       for(unsigned int i = 0; i < imon.size(); ++i ){
00108         if (which[0] == 0){
00109           result.push_back(imon[i].value);
00110         }
00111         else{
00112           if(imon[i].dpid == which[0])
00113             result.push_back(imon[i].value);
00114         }
00115       }
00116     }
00117 
00118     typedef boost::function<void(RPCObTemp const & pl, std::vector<int> const & which,std::vector<float> & result,const float& starttime,const float& endtime)> RPCObTempExtractor;
00119   }
00120 
00121   template<>
00122   struct ExtractWhat<RPCObTemp> {
00123 
00124     rpcobtemp::How m_how;
00125     std::vector<int> m_which;
00126     float m_starttime;
00127     float m_endtime;
00128 
00129     rpcobtemp::How const & how() const { return m_how;}
00130     std::vector<int> const & which() const { return m_which;}
00131     float const & startTime() const {return m_starttime;}
00132     float const & endTime() const {return m_endtime;}
00133 
00134     void set_how(rpcobtemp::How i) {m_how=i;}
00135     void set_which(std::vector<int> & i) { m_which.swap(i);}
00136     void set_starttime(float& i){m_starttime = i;}
00137     void set_endtime(float& i){m_endtime = i;}
00138 
00139   };
00140 
00141 
00142   template<>
00143   class ValueExtractor<RPCObTemp>: public  BaseValueExtractor<RPCObTemp> {
00144   public:
00145 
00146     static rpcobtemp::RPCObTempExtractor & extractor(rpcobtemp::How how) {
00147       static  rpcobtemp::RPCObTempExtractor fun[4] = { 
00148         rpcobtemp::RPCObTempExtractor(rpcobtemp::extractDetId),
00149         rpcobtemp::RPCObTempExtractor(rpcobtemp::extractDay),
00150         rpcobtemp::RPCObTempExtractor(rpcobtemp::extractTime),
00151         rpcobtemp::RPCObTempExtractor(rpcobtemp::extractTemp)
00152       };
00153       return fun[how];
00154     }
00155 
00156     typedef RPCObTemp Class;
00157     typedef ExtractWhat<Class> What;
00158     static What what() { return What();}
00159 
00160     ValueExtractor(){}
00161     ValueExtractor(What const & what)
00162       : m_what(what)
00163     {
00164       // here one can make stuff really complicated... (select mean rms, 12,6,1)
00165       // ask to make average on selected channels...
00166     }
00167 
00168     void compute(Class const & it){
00169       std::vector<float> res;
00170       extractor(m_what.how())(it,m_what.which(),res,m_what.startTime(),m_what.endTime());
00171       swap(res);
00172     }
00173 
00174   private:
00175     What  m_what;
00176     
00177   };
00178   
00179   template<>
00180   std::string PayLoadInspector<RPCObTemp>::summary() const {
00181     std::stringstream ss;
00182 
00183     //hardcoded values
00184     std::string authPath="/afs/cern.ch/cms/DB/conddb";
00185     std::string conString="oracle://cms_orcoff_prod/CMS_COND_31X_RPC";
00186 
00187     //frontend sends token instead of filename
00188     std::string token="[DB=00000000-0000-0000-0000-000000000000][CNT=RPCObPVSSmap][CLID=53B2D2D9-1F4E-9CA9-4D71-FFCCA123A454][TECH=00000B01][OID=0000000C-00000000]";
00189 
00190     //make connection object
00191     DbConnection dbConn;
00192 
00193     //set in configuration object authentication path
00194     dbConn.configuration().setAuthenticationPath(authPath);
00195     dbConn.configure();
00196 
00197     //create session object from connection
00198     DbSession dbSes=dbConn.createSession();
00199 
00200     //try to make connection
00201     dbSes.open(conString,true);
00202     
00203     //start a transaction (true=readOnly)
00204     dbSes.transaction().start(true);
00205 
00206     //get the actual object
00207     boost::shared_ptr<RPCObPVSSmap> pvssPtr;
00208     pvssPtr=dbSes.getTypedObject<RPCObPVSSmap>(token);
00209 
00210     //we have the object...
00211     std::vector<RPCObPVSSmap::Item> pvssCont=pvssPtr->ObIDMap_rpc;
00212 
00213     std::vector<RPCObTemp::T_Item> const & tmon = object().ObTemp_rpc;
00214 
00215     ss <<"DetID\t\t"<<"T(C)\t"<<"Time\t"<<"Day\n";
00216     for(unsigned int i = 0; i < tmon.size(); ++i ){
00217       for(unsigned int p = 0; p < pvssCont.size(); ++p){
00218         if(tmon[i].dpid!=pvssCont[p].dpid || pvssCont[p].suptype!=4 || pvssCont[p].region!=0)continue;
00219         RPCDetId rpcId(pvssCont[p].region,pvssCont[p].ring,pvssCont[p].station,pvssCont[p].sector,pvssCont[p].layer,pvssCont[p].subsector,1);
00220         RPCGeomServ rGS(rpcId);
00221         std::string chName(rGS.name().substr(0,rGS.name().find("_Backward")));
00222         ss <<chName <<"\t"<<tmon[i].value<<"\t"<<tmon[i].time<<"\t"<<tmon[i].day<<"\n";
00223       }
00224     }
00225 
00226     dbSes.close();
00227 
00228     return ss.str();
00229 
00230   }
00231 
00232   Double_t linearF(Double_t *x, Double_t *par){
00233     Double_t y=0.;
00234     y=par[0]*(*x);
00235     return y;
00236   }
00237 
00238   // return the real name of the file including extension...
00239   template<>
00240   std::string PayLoadInspector<RPCObTemp>::plot(std::string const & filename,
00241                                                 std::string const &, std::vector<int> const&, std::vector<float> const& ) const {
00242 
00243     std::map<std::string,std::pair<float,float> > geoMap;
00244     std::ifstream mapFile("/afs/cern.ch/user/s/stupputi/public/barDetPositions.txt",ifstream::in);
00245     std::string chamb;
00246     float xPos,yPos;
00247     while(mapFile >> chamb >> xPos >> yPos)
00248       geoMap[chamb]=make_pair(xPos,yPos);
00249     std::cout<<"size "<<geoMap.size()<<std::endl;
00250     gStyle->SetPalette(1);    
00251 
00252     //BEGIN OF NEW DB-SESSION PART
00253     //hardcoded values
00254     std::string authPath="/afs/cern.ch/cms/DB/conddb";
00255     std::string conString="oracle://cms_orcoff_prod/CMS_COND_31X_RPC";
00256     
00257     //frontend sends token instead of filename
00258     std::string token="[DB=00000000-0000-0000-0000-000000000000][CNT=RPCObPVSSmap][CLID=53B2D2D9-1F4E-9CA9-4D71-FFCCA123A454][TECH=00000B01][OID=0000000C-00000000]";
00259     
00260     //make connection object
00261     DbConnection dbConn;
00262     
00263     //set in configuration object authentication path
00264     dbConn.configuration().setAuthenticationPath(authPath);
00265     dbConn.configure();
00266     
00267     //create session object from connection
00268     DbSession dbSes=dbConn.createSession();
00269     
00270     //try to make connection
00271     dbSes.open(conString,true);
00272     
00273     //start a transaction (true=readOnly)
00274     dbSes.transaction().start(true);
00275     
00276     //get the actual object
00277     boost::shared_ptr<RPCObPVSSmap> pvssPtr;
00278     pvssPtr=dbSes.getTypedObject<RPCObPVSSmap>(token);
00279 
00280     //we have the object...
00281     std::vector<RPCObPVSSmap::Item> pvssCont=pvssPtr->ObIDMap_rpc;
00282     //END OF NEW DB-SESSION PART
00283 
00284     std::vector<RPCObTemp::T_Item> const & temp = object().ObTemp_rpc;
00285     
00286     std::map<int,std::map<int,std::vector<double> > > valMap;
00287     std::map<int,std::string> detMap;
00288     for(unsigned int i = 0;i < temp.size(); ++i){
00289       for(unsigned int p = 0; p < pvssCont.size(); ++p){
00290         if(temp[i].dpid!=pvssCont[p].dpid || pvssCont[p].suptype!=4 || pvssCont[p].region!=0)continue;
00291         int whl(pvssCont[p].ring);
00292         if(valMap.find(whl)==valMap.end()){       
00293           std::map<int,std::vector<double> > dumMap;
00294           std::vector<double> dumVec;dumVec.push_back(temp[i].value);
00295           dumMap[temp[i].dpid]=dumVec;
00296           valMap[whl]=dumMap;
00297         }
00298         else {
00299           if(valMap[whl].find(temp[i].dpid)==valMap[whl].end()){
00300             std::vector<double> dumVec;dumVec.push_back(temp[i].value);
00301             (valMap[whl])[temp[i].dpid]=dumVec;
00302           }
00303           else 
00304             (valMap[whl])[temp[i].dpid].push_back(temp[i].value);
00305         }
00306         if(detMap.find(temp[i].dpid)==detMap.end()){
00307           RPCDetId rpcId(pvssCont[p].region,pvssCont[p].ring,pvssCont[p].station,pvssCont[p].sector,pvssCont[p].layer,pvssCont[p].subsector,1);
00308           RPCGeomServ chGS(rpcId);
00309           std::string chName(chGS.name());
00310           std::string::size_type pos(chName.find("_S"));
00311           if(pos!=std::string::npos)
00312             chName=chName.substr(0,pos+5);
00313           else
00314             chName=chName.substr(0,chName.find("_CH")+5);                 
00315           detMap[temp[i].dpid]=chName;
00316         }       
00317       }
00318     }
00319     
00320     float histoScale(710),axisScale(750);
00321     int flip(-1);
00322     float incr(0.045*histoScale);
00323     float midSc(0.267949192431123),diagSc(sqrt((1.+(midSc*midSc))/2.));
00324     float dists[]={0.558f*histoScale,0.607f*histoScale,0.697f*histoScale,/*0.6971f*xSc,0.7464f*xSc,*/0.823f*histoScale,0.967f*histoScale};
00325 
00326     TCanvas *c=new TCanvas("Temp","Temp",1200,700);
00327     c->Divide(3,2);
00328 
00329     for(int w=-2;w<3;w++){
00330       //  if(w!=1)continue;
00331       int canv(w+3);
00332       c->cd(canv);
00333 
00334       char wNumb[8];
00335       sprintf(wNumb,"Wheel %i",w);
00336 
00337       TH2F *histo= new TH2F("","",(2*axisScale)/incr,(-1)*axisScale,axisScale,(2*axisScale)/incr,(-1)*axisScale,axisScale);
00338       histo->GetXaxis()->SetTickLength(0);histo->GetXaxis()->SetLabelColor(0);histo->GetXaxis()->SetTitle("Temperature (#circC)");
00339       histo->GetYaxis()->SetTickLength(0);histo->GetYaxis()->SetLabelColor(0);
00340     
00341       double min(1000),max(-1);
00342       for(std::map<int,std::vector<double> >::const_iterator mIt=valMap[w].begin();
00343           mIt!=valMap[w].end();mIt++){
00344        
00345         std::pair<double, std::vector<double> > meanAndVals =
00346           make_pair(accumulate(mIt->second.begin(),mIt->second.end(),0.)/(double)mIt->second.size(),mIt->second);
00347         std::string chName(detMap[mIt->first]);
00348         histo->Fill(geoMap[chName].first,geoMap[chName].second,meanAndVals.first);
00349         if(meanAndVals.first<min)min=meanAndVals.first;
00350         if(meanAndVals.first>max)max=meanAndVals.first;
00351         std::cout<<chName<<" "<<geoMap[chName].first<<" "<<geoMap[chName].second<<" "<<meanAndVals.first<<std::endl;
00352       }
00353 
00354       histo->GetZaxis()->SetRangeUser(min,max);
00355       histo->Draw("colz");
00356 
00357       TPaveStats *ptstats = new TPaveStats(0.98,0.98,0.99,0.99,"br");
00358       histo->GetListOfFunctions()->Add(ptstats);
00359       histo->Draw("same");
00360 
00361       TPaveText *pt=new TPaveText(-235,763,248,860,"br");
00362       pt->SetFillColor(19);
00363       pt->AddText(wNumb);
00364       pt->Draw("same");
00365 
00366       TLine *line = new TLine();
00367       for(int i=0;i<5;i++){
00368         float scDist(midSc*dists[i]),onDiag(diagSc*dists[i]);
00369         float furDist(dists[i]+incr),scFurDist(midSc*furDist),furOnDiag(diagSc*furDist);
00370       
00371         line=new TLine(dists[i],flip*scDist,dists[i],scDist);line->Draw();//S01
00372         line=new TLine(dists[i],flip*scDist,furDist,flip*scDist);line->Draw();
00373         line=new TLine(dists[i],scDist,furDist,scDist);line->Draw();
00374         line=new TLine(furDist,flip*scDist,furDist,scDist);line->Draw();
00375         line=new TLine(flip*dists[i],flip*scDist,flip*dists[i],scDist);line->Draw();//S07               
00376         line=new TLine(flip*dists[i],flip*scDist,flip*furDist,flip*scDist);line->Draw();
00377         line=new TLine(flip*dists[i],scDist,flip*furDist,scDist);line->Draw();
00378         line=new TLine(flip*furDist,flip*scDist,flip*furDist,scDist);line->Draw();              
00379         line=new TLine(onDiag,onDiag,dists[i],scDist);line->Draw();//S02
00380         line=new TLine(onDiag,onDiag,furOnDiag,furOnDiag);line->Draw();
00381         line=new TLine(dists[i],scDist,furDist,scFurDist);line->Draw();
00382         line=new TLine(furOnDiag,furOnDiag,furDist,scFurDist);line->Draw();
00383         line=new TLine(flip*onDiag,flip*onDiag,flip*dists[i],flip*scDist);line->Draw();//S08            
00384         line=new TLine(flip*onDiag,flip*onDiag,flip*furOnDiag,flip*furOnDiag);line->Draw();
00385         line=new TLine(flip*dists[i],flip*scDist,flip*furDist,flip*scFurDist);line->Draw();
00386         line=new TLine(flip*furOnDiag,flip*furOnDiag,flip*furDist,flip*scFurDist);line->Draw();
00387         line=new TLine(onDiag,onDiag,scDist,dists[i]);line->Draw();//S03
00388         line=new TLine(onDiag,onDiag,furOnDiag,furOnDiag);line->Draw();
00389         line=new TLine(scDist,dists[i],scFurDist,furDist);line->Draw();
00390         line=new TLine(furOnDiag,furOnDiag,scFurDist,furDist);line->Draw();
00391         line=new TLine(flip*onDiag,flip*onDiag,flip*scDist,flip*dists[i]);line->Draw();//S09
00392         line=new TLine(flip*onDiag,flip*onDiag,flip*furOnDiag,flip*furOnDiag);line->Draw();
00393         line=new TLine(flip*scDist,flip*dists[i],flip*scFurDist,flip*furDist);line->Draw();
00394         line=new TLine(flip*furOnDiag,flip*furOnDiag,flip*scFurDist,flip*furDist);line->Draw();
00395         if(i==4){
00396         
00397           line=new TLine(flip*scDist,dists[i],-0.005,dists[i]);line->Draw();//S04-
00398           line=new TLine(flip*scDist,dists[i],flip*scDist,furDist);line->Draw();
00399           line=new TLine(-0.005,dists[i],-0.005,furDist);line->Draw();
00400           line=new TLine(flip*scDist,furDist,-0.005,furDist);line->Draw();                      
00401           line=new TLine(0.005,dists[i],scDist,dists[i]);line->Draw();//S04+
00402           line=new TLine(scDist,dists[i],scDist,furDist);line->Draw();
00403           line=new TLine(0.005,dists[i],0.005,furDist);line->Draw();
00404           line=new TLine(scDist,furDist,0.005,furDist);line->Draw();                    
00405           line=new TLine(flip*scDist,flip*dists[i],-0.005,flip*dists[i]);line->Draw();//S10+
00406           line=new TLine(flip*scDist,flip*dists[i],flip*scDist,flip*furDist);line->Draw();
00407           line=new TLine(-0.005,flip*dists[i],-0.005,flip*furDist);line->Draw();
00408           line=new TLine(flip*scDist,flip*furDist,-0.005,flip*furDist);line->Draw();
00409           line=new TLine(0.005,flip*dists[i],scDist,flip*dists[i]);line->Draw();//S10-
00410           line=new TLine(0.005,flip*dists[i],0.005,flip*furDist);line->Draw();
00411           line=new TLine(scDist,flip*dists[i],scDist,flip*furDist);line->Draw();
00412           line=new TLine(scDist,flip*furDist,0.005,flip*furDist);line->Draw();                  
00413         }
00414         else{
00415           line=new TLine(flip*scDist,dists[i],scDist,dists[i]);line->Draw();//S04
00416           line=new TLine(flip*scDist,dists[i],flip*scDist,furDist);line->Draw();
00417           line=new TLine(scDist,dists[i],scDist,furDist);line->Draw();
00418           line=new TLine(flip*scDist,furDist,scDist,furDist);line->Draw();
00419           line=new TLine(flip*scDist,flip*dists[i],scDist,flip*dists[i]);line->Draw();//S10
00420           line=new TLine(flip*scDist,flip*dists[i],flip*scDist,flip*furDist);line->Draw();
00421           line=new TLine(scDist,flip*dists[i],scDist,flip*furDist);line->Draw();
00422           line=new TLine(flip*scDist,flip*furDist,scDist,flip*furDist);line->Draw();
00423         }
00424         line=new TLine(flip*onDiag,onDiag,flip*scDist,dists[i]);line->Draw();//S05
00425         line=new TLine(flip*onDiag,onDiag,flip*furOnDiag,furOnDiag);line->Draw();
00426         line=new TLine(flip*scDist,dists[i],flip*scFurDist,furDist);line->Draw();
00427         line=new TLine(flip*furOnDiag,furOnDiag,flip*scFurDist,furDist);line->Draw();
00428         line=new TLine(onDiag,flip*onDiag,scDist,flip*dists[i]);line->Draw();//S11              
00429         line=new TLine(onDiag,flip*onDiag,furOnDiag,flip*furOnDiag);line->Draw();
00430         line=new TLine(scDist,flip*dists[i],scFurDist,flip*furDist);line->Draw();
00431         line=new TLine(furOnDiag,flip*furOnDiag,scFurDist,flip*furDist);line->Draw();
00432         line=new TLine(flip*onDiag,onDiag,flip*dists[i],scDist);line->Draw();//S06
00433         line=new TLine(flip*onDiag,onDiag,flip*furOnDiag,furOnDiag);line->Draw();
00434         line=new TLine(flip*dists[i],scDist,flip*furDist,scFurDist);line->Draw();
00435         line=new TLine(flip*furOnDiag,furOnDiag,flip*furDist,scFurDist);line->Draw();
00436         line=new TLine(onDiag,flip*onDiag,dists[i],flip*scDist);line->Draw();//S12
00437         line=new TLine(onDiag,flip*onDiag,furOnDiag,flip*furOnDiag);line->Draw();
00438         line=new TLine(dists[i],flip*scDist,furDist,flip*scFurDist);line->Draw();
00439         line=new TLine(furOnDiag,flip*furOnDiag,furDist,flip*scFurDist);line->Draw();
00440       }
00441     }
00442         
00443     c->SaveAs(filename.c_str());
00444     return filename.c_str();
00445 
00446   }
00447 
00448 
00449 
00450   template <>
00451   std::string PayLoadInspector<RPCObTemp>::trend_plot(std::string const & filename,
00452                                                       std::string const & opt_string, 
00453                                                       std::vector<int> const& nts,
00454                                                       std::vector<float> const& floats,
00455                                                       std::vector<std::string> const& strings) const {
00456 
00457     std::stringstream ss("");
00458     
00459     if(strings.size()<2)
00460       return ("Error!Not enough data for initializing connection for making plots!(from template<> std::string PayLoadInspector<BeamSpotObjects>::trend_plot)");
00461    
00462     std::vector<std::string>::const_iterator strIt=strings.begin();
00463 
00464     std::string conString=(*strIt);strIt++;
00465     std::string authPath=(*strIt);strIt++;
00466  
00467     //BEGIN OF NEW DB-SESSION PART
00468 
00469     //make connection object
00470     DbConnection dbConn;
00471     
00472     //set in configuration object authentication path
00473     dbConn.configuration().setAuthenticationPath(authPath);
00474     dbConn.configure();
00475     
00476     //create session object from connection
00477     DbSession dbSes=dbConn.createSession();
00478     
00479     //try to make connection
00480     dbSes.open(conString,true);
00481     
00482     //start a transaction (true=readOnly)
00483     dbSes.transaction().start(true);
00484     
00485     std::string pvssToken="[DB=00000000-0000-0000-0000-000000000000][CNT=RPCObPVSSmap][CLID=53B2D2D9-1F4E-9CA9-4D71-FFCCA123A454][TECH=00000B01][OID=0000000C-00000000]";
00486     //get the actual object
00487     boost::shared_ptr<RPCObTemp> tempPtr;
00488     boost::shared_ptr<RPCObPVSSmap> pvssPtr;
00489     pvssPtr=dbSes.getTypedObject<RPCObPVSSmap>(pvssToken);
00490 
00491     //we get the objects...
00492     std::vector<RPCObPVSSmap::Item> pvssCont=pvssPtr->ObIDMap_rpc,pvssZero;
00493 
00494     for(unsigned int p=0;p<pvssCont.size();p++){
00495       if(pvssCont[p].suptype!=4)
00496         pvssZero.push_back(pvssCont[p]);
00497     }
00498     
00499     std::string token;
00500     std::vector<float> vecI;vecI.assign(floats.size(),0.);
00501     int elCount(0);
00502 
00503     for(;strIt!=strings.end();++strIt){
00504       
00505       token=(*strIt);
00506       tempPtr=dbSes.getTypedObject<RPCObTemp>(token);      
00507       std::vector<RPCObTemp::T_Item> const & temp = tempPtr->ObTemp_rpc;
00508 
00509       float iCount(0.);
00510       for(unsigned int i=0;i<temp.size();i++){
00511         for(unsigned int p=0;p<pvssZero.size();p++){
00512           if(temp[i].dpid!=pvssZero[p].dpid || pvssZero[p].region!=0)continue;
00513           iCount++;
00514           vecI[elCount]+=temp[i].value;
00515         }
00516       }
00517       if(iCount!=0)
00518         vecI[elCount]/=iCount;
00519       elCount++;
00520     }
00521     
00522     //END OF NEW DB-SESSION PART
00523     
00524     dbSes.close();
00525     
00526     return ss.str();
00527     
00528   }
00529   
00530 }
00531 
00532 
00533 namespace condPython {
00534   template<>
00535   void defineWhat<RPCObTemp>() {
00536     using namespace boost::python;
00537     enum_<cond::rpcobtemp::How>("How")
00538       .value("detid",cond::rpcobtemp::detid)
00539       .value("day",cond::rpcobtemp::day) 
00540       .value("time",cond::rpcobtemp::time)
00541       .value("temp",cond::rpcobtemp::temp)
00542       ;
00543 
00544     typedef cond::ExtractWhat<RPCObTemp> What;
00545     class_<What>("What",init<>())
00546       .def("set_how",&What::set_how)
00547       .def("set_which",&What::set_which)
00548       .def("how",&What::how, return_value_policy<copy_const_reference>())
00549       .def("which",&What::which, return_value_policy<copy_const_reference>())
00550       .def("set_starttime",&What::set_starttime)
00551       .def("set_endtime",&What::set_endtime)
00552       .def("startTime",&What::startTime, return_value_policy<copy_const_reference>())
00553       .def("endTime",&What::endTime, return_value_policy<copy_const_reference>())
00554       ;
00555   }
00556 }
00557 
00558 PYTHON_WRAPPER(RPCObTemp,RPCObTemp);