New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[10.0.x] Add dump plot of AlignPCLThreshold in the payload inspector #21417
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
152 changes: 152 additions & 0 deletions
152
CondCore/PCLConfigPlugins/plugins/AlignPCLThresholds_PayloadInspector.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
/*! | ||
\file AlignPCLThresholds_PayloadInspector | ||
\Payload Inspector Plugin for Alignment PCL thresholds | ||
\author M. Musich | ||
\version $Revision: 1.0 $ | ||
\date $Date: 2017/10/19 12:51:00 $ | ||
*/ | ||
|
||
#include "CondCore/Utilities/interface/PayloadInspectorModule.h" | ||
#include "CondCore/Utilities/interface/PayloadInspector.h" | ||
#include "CondCore/CondDB/interface/Time.h" | ||
|
||
// the data format of the condition to be inspected | ||
#include "CondFormats/PCLConfig/interface/AlignPCLThresholds.h" | ||
|
||
#include <memory> | ||
#include <sstream> | ||
#include <iostream> | ||
#include <functional> | ||
|
||
// include ROOT | ||
#include "TH2F.h" | ||
#include "TLegend.h" | ||
#include "TCanvas.h" | ||
#include "TLine.h" | ||
#include "TStyle.h" | ||
|
||
namespace { | ||
|
||
enum types {DELTA, | ||
SIG, | ||
MAXMOVE, | ||
MAXERR, | ||
END_OF_TYPES}; | ||
|
||
/************************************************ | ||
Display of AlignPCLThresholds | ||
*************************************************/ | ||
class AlignPCLThresholds_Display : public cond::payloadInspector::PlotImage<AlignPCLThresholds> { | ||
public: | ||
AlignPCLThresholds_Display() : cond::payloadInspector::PlotImage<AlignPCLThresholds>( "Display of threshold parameters for SiPixelAli PCL" ){ | ||
setSingleIov( true ); | ||
} | ||
|
||
bool fill( const std::vector<std::tuple<cond::Time_t,cond::Hash> >& iovs ) override{ | ||
auto iov = iovs.front(); | ||
std::shared_ptr<AlignPCLThresholds> payload = fetchPayload( std::get<1>(iov) ); | ||
auto alignables = payload->getAlignableList(); | ||
|
||
TCanvas canvas("Alignment PCL thresholds summary","Alignment PCL thresholds summary",1500,800); | ||
canvas.cd(); | ||
|
||
canvas.SetTopMargin(0.07); | ||
canvas.SetBottomMargin(0.06); | ||
canvas.SetLeftMargin(0.11); | ||
canvas.SetRightMargin(0.05); | ||
canvas.Modified(); | ||
canvas.SetGrid(); | ||
|
||
auto Thresholds = std::unique_ptr<TH2F>(new TH2F("Thresholds","Alignment parameter thresholds",alignables.size(),0,alignables.size(),24,0,24)); | ||
Thresholds->SetStats(false); | ||
|
||
std::function<float(types,std::string,AlignPCLThresholds::coordType)> cutFunctor = [&payload](types my_type,std::string alignable,AlignPCLThresholds::coordType coord) { | ||
float ret(-999.); | ||
switch(my_type){ | ||
case DELTA : return payload->getCut(alignable,coord); | ||
case SIG : return payload->getSigCut(alignable,coord); | ||
case MAXMOVE : return payload->getMaxMoveCut(alignable,coord); | ||
case MAXERR : return payload->getMaxErrorCut(alignable,coord); | ||
case END_OF_TYPES : return ret; | ||
default : return ret; | ||
} | ||
}; | ||
|
||
unsigned int xBin=0; | ||
for(const auto &alignable : alignables){ | ||
xBin++; | ||
|
||
auto xLabel = replaceAll(replaceAll(alignable,"minus","(-)"),"plus","(+)"); | ||
Thresholds->GetXaxis()->SetBinLabel(xBin,(xLabel).c_str()); | ||
unsigned int yBin=24; | ||
for(int foo = AlignPCLThresholds::X; foo != AlignPCLThresholds::extra_DOF; foo++ ){ | ||
AlignPCLThresholds::coordType coord = static_cast<AlignPCLThresholds::coordType>(foo); | ||
for(int bar = types::DELTA; bar != types::END_OF_TYPES; bar++ ){ | ||
types type = static_cast<types>(bar); | ||
std::string theLabel = getStringFromTypeEnum(type)+getStringFromCoordEnum(coord); | ||
if(xBin==1){ | ||
Thresholds->GetYaxis()->SetBinLabel(yBin,theLabel.c_str()); | ||
} | ||
|
||
Thresholds->SetBinContent(xBin,yBin,cutFunctor(type,alignable,coord)); | ||
|
||
yBin--; | ||
}// loop on types | ||
}// loop on coordinates | ||
} // loop on alignables | ||
|
||
|
||
Thresholds->GetXaxis()->LabelsOption("h"); | ||
Thresholds->Draw("TEXT"); | ||
|
||
std::string fileName(m_imageFileName); | ||
canvas.SaveAs(fileName.c_str()); | ||
|
||
return true; | ||
} | ||
|
||
/************************************************/ | ||
std::string getStringFromCoordEnum (const AlignPCLThresholds::coordType &coord){ | ||
switch(coord){ | ||
case AlignPCLThresholds::X : return "X"; | ||
case AlignPCLThresholds::Y : return "Y"; | ||
case AlignPCLThresholds::Z : return "Z"; | ||
case AlignPCLThresholds::theta_X : return "#theta_{X}"; | ||
case AlignPCLThresholds::theta_Y : return "#theta_{Y}"; | ||
case AlignPCLThresholds::theta_Z : return "#theta_{Z}"; | ||
default : return "should never be here"; | ||
} | ||
} | ||
|
||
/************************************************/ | ||
std::string getStringFromTypeEnum (const types &type){ | ||
switch(type){ | ||
case types::DELTA : return "#Delta"; | ||
case types::SIG : return "#Delta/#sigma "; | ||
case types::MAXMOVE : return "max. move "; | ||
case types::MAXERR : return "max. err "; | ||
default: return "should never be here"; | ||
} | ||
} | ||
|
||
/************************************************/ | ||
std::string replaceAll(const std::string& str, const std::string& from, const std::string& to) { | ||
std::string out(str); | ||
|
||
if(from.empty()) | ||
return out; | ||
size_t start_pos = 0; | ||
while((start_pos = out.find(from, start_pos)) != std::string::npos) { | ||
out.replace(start_pos, from.length(), to); | ||
start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx' | ||
} | ||
return out; | ||
} | ||
|
||
}; | ||
} // close namespace | ||
|
||
// Register the classes as boost python plugin | ||
PAYLOAD_INSPECTOR_MODULE(AlignPCLThresholds){ | ||
PAYLOAD_INSPECTOR_CLASS(AlignPCLThresholds_Display); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<library file="AlignPCLThresholds_PayloadInspector.cc" name="AlignPCLThresholds_PayloadInspector"> | ||
<use name="CondCore/Utilities"/> | ||
<use name="CondCore/CondDB"/> | ||
<use name="CondFormats/Common"/> | ||
<use name="boost_python"/> | ||
</library> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
# Save current working dir so img can be outputted there later | ||
W_DIR=$(pwd); | ||
# Set SCRAM architecture var | ||
SCRAM_ARCH=slc6_amd64_gcc630; | ||
export SCRAM_ARCH; | ||
source /afs/cern.ch/cms/cmsset_default.sh; | ||
eval `scram run -sh`; | ||
# Go back to original working directory | ||
cd $W_DIR; | ||
# Run get payload data script | ||
|
||
#################### | ||
# Test Gains | ||
#################### | ||
/afs/cern.ch/user/c/condbpro/public/BROWSER_PI/getPayloadData.py \ | ||
--plugin pluginAlignPCLThresholds_PayloadInspector \ | ||
--plot plot_AlignPCLThresholds_Display \ | ||
--tag SiPixelAliThresholds_offline_v0 \ | ||
--time_type Run \ | ||
--iovs '{"start_iov": "1", "end_iov": "1"}' \ | ||
--db Prod \ | ||
--test; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @ggovi - can you make that PR for getPayloadData now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are the use cases for this thing? The password of the direct oracle access won't be available to the users anyways...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ggovi, as of now, mostly for those who have direct oracle (i.e. developers) to test the code when making changes and also to use the tool in local check-outs, which is still useful to produce plots.
Anyway, what prevents to provide direct oracle (reading) access to to the cms-bot to make this become part of a unit test? Incidentally I think we could use the same mechanism to test the O2Os.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provide read-access to the cms-bot means essentially store the password in the repository... Not viable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The O2O tests could be done with frontier+sqlite... Oracle is not required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mmusich , cmsbuild has grid certificate which we use for cmsweb authentication
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smuzaffar yes thanks I imagined so, but there's not password associated with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mmusich , yes, no password is associated with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smuzaffar OK, thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I should rephrase: "The O2O tests" like all the tests requiring access to the database "MUST be implemented with frontier/sqlite". There is a deployment/distribution issue for the password. No way to store it in github.
Also, the OCCI problem is in... OCCI. It's an external, I don't think we should have the ambition to test our externals. But we should have the ambition to choose them according to some criteria of maintenance and solidity. From this point of view, we have been discouraging the usage of OCCI since years.