32 #include "TVirtualPad.h"
36 #include "TMultiGraph.h"
39 #include "TPaveStats.h"
40 #include "TPaveText.h"
52 #include <boost/ref.hpp>
53 #include <boost/bind.hpp>
54 #include <boost/function.hpp>
55 #include <boost/shared_ptr.hpp>
56 #include <boost/iterator/transform_iterator.hpp>
67 std::vector<RPCObTemp::T_Item>
const & imon = pl.
ObTemp_rpc;
68 for(
unsigned int i = 0;
i < imon.size(); ++
i ){
70 result.push_back(imon[
i].dpid);
73 if(imon[
i].dpid == which[0])
74 result.push_back(imon[
i].dpid);
80 std::vector<RPCObTemp::T_Item>
const & imon = pl.
ObTemp_rpc;
81 for(
unsigned int i = 0;
i < imon.size(); ++
i ){
83 result.push_back(imon[
i].
day);
86 if(imon[
i].dpid == which[0])
87 result.push_back(imon[
i].
day);
93 std::vector<RPCObTemp::T_Item>
const & imon = pl.
ObTemp_rpc;
94 for(
unsigned int i = 0;
i < imon.size(); ++
i ){
96 result.push_back(imon[
i].
time);
99 if(imon[
i].dpid == which[0])
100 result.push_back(imon[
i].
time);
106 std::vector<RPCObTemp::T_Item>
const & imon = pl.
ObTemp_rpc;
107 for(
unsigned int i = 0;
i < imon.size(); ++
i ){
109 result.push_back(imon[
i].
value);
112 if(imon[
i].dpid == which[0])
113 result.push_back(imon[
i].
value);
130 std::vector<int>
const &
which()
const {
return m_which;}
132 float const &
endTime()
const {
return m_endtime;}
169 std::vector<float> res;
170 extractor(m_what.how())(it,m_what.which(),res,m_what.startTime(),m_what.endTime());
181 std::stringstream
ss;
185 std::string conString=
"oracle://cms_orcoff_prod/CMS_COND_31X_RPC";
188 std::string token=
"[DB=00000000-0000-0000-0000-000000000000][CNT=RPCObPVSSmap][CLID=53B2D2D9-1F4E-9CA9-4D71-FFCCA123A454][TECH=00000B01][OID=0000000C-00000000]";
201 dbSes.
open(conString,
true);
207 boost::shared_ptr<RPCObPVSSmap> pvssPtr;
211 std::vector<RPCObPVSSmap::Item> pvssCont=pvssPtr->
ObIDMap_rpc;
213 std::vector<RPCObTemp::T_Item>
const & tmon =
object().ObTemp_rpc;
215 ss <<
"DetID\t\t"<<
"T(C)\t"<<
"Time\t"<<
"Day\n";
216 for(
unsigned int i = 0;
i < tmon.size(); ++
i ){
217 for(
unsigned int p = 0;
p < pvssCont.size(); ++
p){
218 if(tmon[
i].dpid!=pvssCont[
p].dpid || pvssCont[
p].suptype!=4 || pvssCont[
p].region!=0)
continue;
219 RPCDetId rpcId(pvssCont[
p].region,pvssCont[
p].
ring,pvssCont[
p].
station,pvssCont[
p].sector,pvssCont[
p].layer,pvssCont[
p].subsector,1);
222 ss <<chName <<
"\t"<<tmon[
i].value<<
"\t"<<tmon[
i].time<<
"\t"<<tmon[
i].day<<
"\n";
232 Double_t
linearF(Double_t *
x, Double_t *par){
241 std::string const &, std::vector<int>
const&, std::vector<float>
const& )
const {
243 std::map<std::string,std::pair<float,float> > geoMap;
244 std::ifstream mapFile(
"/afs/cern.ch/user/s/stupputi/public/barDetPositions.txt",
std::ifstream::in);
247 while(mapFile >> chamb >> xPos >> yPos)
248 geoMap[chamb]=make_pair(xPos,yPos);
249 std::cout<<
"size "<<geoMap.size()<<std::endl;
250 gStyle->SetPalette(1);
255 std::string conString=
"oracle://cms_orcoff_prod/CMS_COND_31X_RPC";
258 std::string token=
"[DB=00000000-0000-0000-0000-000000000000][CNT=RPCObPVSSmap][CLID=53B2D2D9-1F4E-9CA9-4D71-FFCCA123A454][TECH=00000B01][OID=0000000C-00000000]";
271 dbSes.
open(conString,
true);
277 boost::shared_ptr<RPCObPVSSmap> pvssPtr;
281 std::vector<RPCObPVSSmap::Item> pvssCont=pvssPtr->
ObIDMap_rpc;
284 std::vector<RPCObTemp::T_Item>
const &
temp =
object().ObTemp_rpc;
286 std::map<int,std::map<int,std::vector<double> > > valMap;
287 std::map<int,std::string> detMap;
288 for(
unsigned int i = 0;
i < temp.size(); ++
i){
289 for(
unsigned int p = 0;
p < pvssCont.size(); ++
p){
290 if(temp[
i].dpid!=pvssCont[
p].dpid || pvssCont[
p].suptype!=4 || pvssCont[
p].region!=0)
continue;
291 int whl(pvssCont[
p].
ring);
292 if(valMap.find(whl)==valMap.end()){
293 std::map<int,std::vector<double> > dumMap;
294 std::vector<double> dumVec;dumVec.push_back(temp[
i].
value);
295 dumMap[temp[
i].dpid]=dumVec;
299 if(valMap[whl].
find(temp[
i].dpid)==valMap[whl].
end()){
300 std::vector<double> dumVec;dumVec.push_back(temp[
i].
value);
301 (valMap[whl])[temp[
i].dpid]=dumVec;
304 (valMap[whl])[temp[
i].dpid].push_back(temp[
i].
value);
306 if(detMap.find(temp[
i].dpid)==detMap.end()){
307 RPCDetId rpcId(pvssCont[
p].region,pvssCont[
p].ring,pvssCont[
p].
station,pvssCont[
p].sector,pvssCont[
p].layer,pvssCont[
p].subsector,1);
311 if(pos!=std::string::npos)
312 chName=chName.substr(0,pos+5);
314 chName=chName.substr(0,chName.find(
"_CH")+5);
315 detMap[temp[
i].dpid]=chName;
320 float histoScale(710),axisScale(750);
322 float incr(0.045*histoScale);
323 float midSc(0.267949192431123),diagSc(
sqrt((1.+(midSc*midSc))/2.));
324 float dists[]={0.558f*histoScale,0.607f*histoScale,0.697f*histoScale,0.823f*histoScale,0.967f*histoScale};
326 TCanvas *
c=
new TCanvas(
"Temp",
"Temp",1200,700);
329 for(
int w=-2;
w<3;
w++){
335 sprintf(wNumb,
"Wheel %i",
w);
337 TH2F *
histo=
new TH2F(
"",
"",(2*axisScale)/incr,(-1)*axisScale,axisScale,(2*axisScale)/incr,(-1)*axisScale,axisScale);
338 histo->GetXaxis()->SetTickLength(0);histo->GetXaxis()->SetLabelColor(0);histo->GetXaxis()->SetTitle(
"Temperature (#circC)");
339 histo->GetYaxis()->SetTickLength(0);histo->GetYaxis()->SetLabelColor(0);
342 for(
std::map<
int,std::vector<double> >::const_iterator mIt=valMap[
w].
begin();
343 mIt!=valMap[
w].end();mIt++){
345 std::pair<double, std::vector<double> > meanAndVals =
346 make_pair(accumulate(mIt->second.begin(),mIt->second.end(),0.)/(double)mIt->second.size(),mIt->second);
348 histo->Fill(geoMap[chName].
first,geoMap[chName].
second,meanAndVals.first);
349 if(meanAndVals.first<
min)
min=meanAndVals.first;
350 if(meanAndVals.first>max)max=meanAndVals.first;
351 std::cout<<chName<<
" "<<geoMap[chName].first<<
" "<<geoMap[chName].second<<
" "<<meanAndVals.first<<std::endl;
354 histo->GetZaxis()->SetRangeUser(
min,max);
357 TPaveStats *ptstats =
new TPaveStats(0.98,0.98,0.99,0.99,
"br");
358 histo->GetListOfFunctions()->Add(ptstats);
361 TPaveText *
pt=
new TPaveText(-235,763,248,860,
"br");
362 pt->SetFillColor(19);
366 TLine *
line =
new TLine();
367 for(
int i=0;
i<5;
i++){
368 float scDist(midSc*dists[
i]),onDiag(diagSc*dists[i]);
369 float furDist(dists[i]+incr),scFurDist(midSc*furDist),furOnDiag(diagSc*furDist);
371 line=
new TLine(dists[i],flip*scDist,dists[i],scDist);line->Draw();
372 line=
new TLine(dists[i],flip*scDist,furDist,flip*scDist);line->Draw();
373 line=
new TLine(dists[i],scDist,furDist,scDist);line->Draw();
374 line=
new TLine(furDist,flip*scDist,furDist,scDist);line->Draw();
375 line=
new TLine(flip*dists[i],flip*scDist,flip*dists[i],scDist);line->Draw();
376 line=
new TLine(flip*dists[i],flip*scDist,flip*furDist,flip*scDist);line->Draw();
377 line=
new TLine(flip*dists[i],scDist,flip*furDist,scDist);line->Draw();
378 line=
new TLine(flip*furDist,flip*scDist,flip*furDist,scDist);line->Draw();
379 line=
new TLine(onDiag,onDiag,dists[i],scDist);line->Draw();
380 line=
new TLine(onDiag,onDiag,furOnDiag,furOnDiag);line->Draw();
381 line=
new TLine(dists[i],scDist,furDist,scFurDist);line->Draw();
382 line=
new TLine(furOnDiag,furOnDiag,furDist,scFurDist);line->Draw();
383 line=
new TLine(flip*onDiag,flip*onDiag,flip*dists[i],flip*scDist);line->Draw();
384 line=
new TLine(flip*onDiag,flip*onDiag,flip*furOnDiag,flip*furOnDiag);line->Draw();
385 line=
new TLine(flip*dists[i],flip*scDist,flip*furDist,flip*scFurDist);line->Draw();
386 line=
new TLine(flip*furOnDiag,flip*furOnDiag,flip*furDist,flip*scFurDist);line->Draw();
387 line=
new TLine(onDiag,onDiag,scDist,dists[i]);line->Draw();
388 line=
new TLine(onDiag,onDiag,furOnDiag,furOnDiag);line->Draw();
389 line=
new TLine(scDist,dists[i],scFurDist,furDist);line->Draw();
390 line=
new TLine(furOnDiag,furOnDiag,scFurDist,furDist);line->Draw();
391 line=
new TLine(flip*onDiag,flip*onDiag,flip*scDist,flip*dists[i]);line->Draw();
392 line=
new TLine(flip*onDiag,flip*onDiag,flip*furOnDiag,flip*furOnDiag);line->Draw();
393 line=
new TLine(flip*scDist,flip*dists[i],flip*scFurDist,flip*furDist);line->Draw();
394 line=
new TLine(flip*furOnDiag,flip*furOnDiag,flip*scFurDist,flip*furDist);line->Draw();
397 line=
new TLine(flip*scDist,dists[i],-0.005,dists[i]);line->Draw();
398 line=
new TLine(flip*scDist,dists[i],flip*scDist,furDist);line->Draw();
399 line=
new TLine(-0.005,dists[i],-0.005,furDist);line->Draw();
400 line=
new TLine(flip*scDist,furDist,-0.005,furDist);line->Draw();
401 line=
new TLine(0.005,dists[i],scDist,dists[i]);line->Draw();
402 line=
new TLine(scDist,dists[i],scDist,furDist);line->Draw();
403 line=
new TLine(0.005,dists[i],0.005,furDist);line->Draw();
404 line=
new TLine(scDist,furDist,0.005,furDist);line->Draw();
405 line=
new TLine(flip*scDist,flip*dists[i],-0.005,flip*dists[i]);line->Draw();
406 line=
new TLine(flip*scDist,flip*dists[i],flip*scDist,flip*furDist);line->Draw();
407 line=
new TLine(-0.005,flip*dists[i],-0.005,flip*furDist);line->Draw();
408 line=
new TLine(flip*scDist,flip*furDist,-0.005,flip*furDist);line->Draw();
409 line=
new TLine(0.005,flip*dists[i],scDist,flip*dists[i]);line->Draw();
410 line=
new TLine(0.005,flip*dists[i],0.005,flip*furDist);line->Draw();
411 line=
new TLine(scDist,flip*dists[i],scDist,flip*furDist);line->Draw();
412 line=
new TLine(scDist,flip*furDist,0.005,flip*furDist);line->Draw();
415 line=
new TLine(flip*scDist,dists[i],scDist,dists[i]);line->Draw();
416 line=
new TLine(flip*scDist,dists[i],flip*scDist,furDist);line->Draw();
417 line=
new TLine(scDist,dists[i],scDist,furDist);line->Draw();
418 line=
new TLine(flip*scDist,furDist,scDist,furDist);line->Draw();
419 line=
new TLine(flip*scDist,flip*dists[i],scDist,flip*dists[i]);line->Draw();
420 line=
new TLine(flip*scDist,flip*dists[i],flip*scDist,flip*furDist);line->Draw();
421 line=
new TLine(scDist,flip*dists[i],scDist,flip*furDist);line->Draw();
422 line=
new TLine(flip*scDist,flip*furDist,scDist,flip*furDist);line->Draw();
424 line=
new TLine(flip*onDiag,onDiag,flip*scDist,dists[i]);line->Draw();
425 line=
new TLine(flip*onDiag,onDiag,flip*furOnDiag,furOnDiag);line->Draw();
426 line=
new TLine(flip*scDist,dists[i],flip*scFurDist,furDist);line->Draw();
427 line=
new TLine(flip*furOnDiag,furOnDiag,flip*scFurDist,furDist);line->Draw();
428 line=
new TLine(onDiag,flip*onDiag,scDist,flip*dists[i]);line->Draw();
429 line=
new TLine(onDiag,flip*onDiag,furOnDiag,flip*furOnDiag);line->Draw();
430 line=
new TLine(scDist,flip*dists[i],scFurDist,flip*furDist);line->Draw();
431 line=
new TLine(furOnDiag,flip*furOnDiag,scFurDist,flip*furDist);line->Draw();
432 line=
new TLine(flip*onDiag,onDiag,flip*dists[i],scDist);line->Draw();
433 line=
new TLine(flip*onDiag,onDiag,flip*furOnDiag,furOnDiag);line->Draw();
434 line=
new TLine(flip*dists[i],scDist,flip*furDist,scFurDist);line->Draw();
435 line=
new TLine(flip*furOnDiag,furOnDiag,flip*furDist,scFurDist);line->Draw();
436 line=
new TLine(onDiag,flip*onDiag,dists[i],flip*scDist);line->Draw();
437 line=
new TLine(onDiag,flip*onDiag,furOnDiag,flip*furOnDiag);line->Draw();
438 line=
new TLine(dists[i],flip*scDist,furDist,flip*scFurDist);line->Draw();
439 line=
new TLine(furOnDiag,flip*furOnDiag,furDist,flip*scFurDist);line->Draw();
443 c->SaveAs(filename.c_str());
444 return filename.c_str();
453 std::vector<int>
const& nts,
454 std::vector<float>
const& floats,
455 std::vector<std::string>
const& strings)
const {
457 std::stringstream
ss(
"");
460 return (
"Error!Not enough data for initializing connection for making plots!(from template<> std::string PayLoadInspector<BeamSpotObjects>::trend_plot)");
462 std::vector<std::string>::const_iterator strIt=strings.begin();
480 dbSes.
open(conString,
true);
485 std::string pvssToken=
"[DB=00000000-0000-0000-0000-000000000000][CNT=RPCObPVSSmap][CLID=53B2D2D9-1F4E-9CA9-4D71-FFCCA123A454][TECH=00000B01][OID=0000000C-00000000]";
487 boost::shared_ptr<RPCObTemp> tempPtr;
488 boost::shared_ptr<RPCObPVSSmap> pvssPtr;
492 std::vector<RPCObPVSSmap::Item> pvssCont=pvssPtr->
ObIDMap_rpc,pvssZero;
494 for(
unsigned int p=0;
p<pvssCont.size();
p++){
495 if(pvssCont[
p].suptype!=4)
496 pvssZero.push_back(pvssCont[
p]);
500 std::vector<float> vecI;vecI.assign(floats.size(),0.);
503 for(;strIt!=strings.end();++strIt){
507 std::vector<RPCObTemp::T_Item>
const &
temp = tempPtr->ObTemp_rpc;
510 for(
unsigned int i=0;
i<temp.size();
i++){
511 for(
unsigned int p=0;
p<pvssZero.size();
p++){
512 if(temp[
i].dpid!=pvssZero[
p].dpid || pvssZero[
p].region!=0)
continue;
533 namespace condPython {
536 using namespace boost::python;
537 enum_<cond::rpcobtemp::How>(
"How")
545 class_<What>(
"What",init<>())
546 .def(
"set_how",&What::set_how)
547 .def(
"set_which",&What::set_which)
548 .def(
"how",&What::how, return_value_policy<copy_const_reference>())
549 .def(
"which",&What::which, return_value_policy<copy_const_reference>())
550 .def(
"set_starttime",&What::set_starttime)
551 .def(
"set_endtime",&What::set_endtime)
552 .def(
"startTime",&
What::startTime, return_value_policy<copy_const_reference>())
553 .def(
"endTime",&What::endTime, return_value_policy<copy_const_reference>())
std::string trend_plot(std::string const &, std::string const &, std::vector< int > const &, std::vector< float > const &, std::vector< std::string > const &) const
std::vector< Item > ObIDMap_rpc
std::vector< T_Item > ObTemp_rpc
std::string plot(std::string const &, std::string const &, std::vector< int > const &, std::vector< float > const &) const
DbTransaction & transaction()
void open(const std::string &connectionString, bool readOnly=false)
void extractDetId(RPCObTemp const &pl, std::vector< int > const &which, std::vector< float > &result, const float &starttime, const float &endtime)
DbConnectionConfiguration & configuration()
#define PYTHON_WRAPPER(_class, _name)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void extractTime(RPCObTemp const &pl, std::vector< int > const &which, std::vector< float > &result, const float &starttime, const float &endtime)
Double_t linearF(Double_t *x, Double_t *par)
boost::function< void(RPCObTemp const &pl, std::vector< int > const &which, std::vector< float > &result, const float &starttime, const float &endtime)> RPCObTempExtractor
U second(std::pair< T, U > const &p)
std::string summary() const
void extractTemp(RPCObTemp const &pl, std::vector< int > const &which, std::vector< float > &result, const float &starttime, const float &endtime)
int start(bool readOnly=false)
start transaction
virtual std::string name()
const T & max(const T &a, const T &b)
DbSession createSession() const
void setAuthenticationPath(const std::string &p)
boost::shared_ptr< T > getTypedObject(const std::string &objectId)
void extractDay(RPCObTemp const &pl, std::vector< int > const &which, std::vector< float > &result, const float &starttime, const float &endtime)
void defineWhat< RPCObTemp >()