1 #ifndef CONDCORE_ALIGNMENTPLUGINS_ALIGNMENTPAYLOADINSPECTORHELPER_H 2 #define CONDCORE_ALIGNMENTPLUGINS_ALIGNMENTPAYLOADINSPECTORHELPER_H 11 #include "TPaveStats.h" 25 #define COUT std::cout << "MM " 27 #define COUT edm::LogVerbatim("") 40 const double tol = 2.e-7;
333 bool isOuter =
false;
338 isOuter = !odd_ladder;
340 isOuter = odd_ladder;
343 isOuter = odd_ladder;
345 isOuter = !odd_ladder;
410 unsigned int subdetId =
static_cast<unsigned int>(detId.
subdetId());
629 return "x-translation";
631 return "y-translation";
633 return "z-translation";
635 return "#alpha angle rotation";
637 return "#beta angle rotation";
639 return "#gamma angle rotation";
641 return "should never be here!";
663 return "should never be here!";
685 return "should never be here!";
695 return std::make_pair(0, 0);
697 return std::make_pair(0, 1);
699 return std::make_pair(0, 2);
701 return std::make_pair(1, 0);
703 return std::make_pair(1, 1);
705 return std::make_pair(2, 2);
707 return std::make_pair(-1, -1);
715 hist->SetStats(kFALSE);
717 hist->GetXaxis()->SetTitleColor(color);
718 hist->SetLineColor(color);
719 hist->SetTitleSize(0.08);
720 hist->SetLineWidth(2);
721 hist->GetXaxis()->CenterTitle(
true);
722 hist->GetYaxis()->CenterTitle(
true);
723 hist->GetXaxis()->SetTitleFont(42);
724 hist->GetYaxis()->SetTitleFont(42);
725 hist->GetXaxis()->SetNdivisions(505);
726 hist->GetXaxis()->SetTitleSize(0.06);
727 hist->GetYaxis()->SetTitleSize(0.06);
728 hist->GetXaxis()->SetTitleOffset(1.0);
729 hist->GetYaxis()->SetTitleOffset(1.3);
730 hist->GetXaxis()->SetLabelFont(42);
731 hist->GetYaxis()->SetLabelFont(42);
732 hist->GetYaxis()->SetLabelSize(.05);
733 hist->GetXaxis()->SetLabelSize(.05);
741 TPaveText*
stat =
new TPaveText(0.60, 0.75, 0.95, 0.95,
"NDC");
745 sprintf(
buffer,
"Entries : %i\n", (
int)
hist->GetEntries());
749 sprintf(
buffer,
"Mean : %6.2f\n",
hist->GetMean());
751 sprintf(
buffer,
"Mean : %6.2f e-2\n", 100 *
hist->GetMean());
756 sprintf(
buffer,
"RMS : %6.2f\n",
hist->GetRMS());
758 sprintf(
buffer,
"RMS : %6.2f e-2\n", 100 *
hist->GetRMS());
762 stat->SetLineColor(color);
763 stat->SetTextColor(color);
764 stat->SetFillColor(10);
765 stat->SetShadowColor(10);
770 inline std::pair<float, float>
getTheRange(std::map<uint32_t, float>
values,
const float nsigma)
773 float sum = std::accumulate(
782 accum += (
p.second -
m) * (
p.second -
m);
788 return std::make_pair(
m - nsigma *
stdev,
m + nsigma *
stdev);
790 return std::make_pair(
m > 0. ? 0.95 *
m : 1.05 *
m,
m > 0 ? 1.05 *
m : 0.95 *
m);
800 int iw = myPad->GetWw();
801 int ih = myPad->GetWh();
802 double x1p, y1p, x2p, y2p;
803 myPad->GetPadPar(x1p, y1p, x2p, y2p);
804 ix1 = (
int)(iw * x1p);
805 ix2 = (
int)(iw * x2p);
806 double wndc =
std::min(1., (
double)iw / (
double)ih);
807 double rw = wndc / (double)iw;
808 double x1ndc = (double)ix1 * rw;
809 double x2ndc = (double)ix2 * rw;
810 double rx1, ry1, rx2, ry2;
811 myPad->GetRange(rx1, ry1, rx2, ry2);
812 double rx = (x2ndc - x1ndc) / (rx2 - rx1);
814 _sx =
rx * (boundary - rx1) + x1ndc;
815 double _dx = _sx + 0.05;
817 return std::make_pair(_sx, _dx);
834 const std::map<AlignmentPI::coordinate, float>& GPR);
842 const std::array<double, 6>
getX()
854 const std::array<double, 6>
getY()
866 const std::array<double, 6>
getZ()
889 const std::map<AlignmentPI::coordinate, float>& GPR)
897 for (
const auto& ali :
input) {
900 <<
"Encountered invalid Tracker DetId:" << ali.rawId() <<
" " <<
DetId(ali.rawId()).det()
905 int subid =
DetId(ali.rawId()).subdetId();
972 edm::LogError(
"TrackerAlignment_PayloadInspector") <<
"Unrecognized partition " << subid << std::endl;
988 COUT <<
"Partition: " <<
p <<
" n. modules: " <<
nmodules[
p] <<
"|" 989 <<
" X: " << std::right << std::setw(12) <<
Xbarycenters[
p] <<
" Y: " << std::right << std::setw(12)
996 std::vector<int>& boundaries,
997 const std::vector<AlignTransform>& ref_ali,
998 const std::vector<AlignTransform>& target_ali,
999 std::unique_ptr<TH1F>&
compare)
1004 for (
unsigned int i = 0;
i < ref_ali.size();
i++) {
1005 if (ref_ali[
i].rawId() == target_ali[
i].rawId()) {
1010 if (thePart != currentPart) {
1011 currentPart = thePart;
1012 boundaries.push_back(
counter);
1015 CLHEP::HepRotation target_rot(target_ali[
i].
rotation());
1016 CLHEP::HepRotation ref_rot(ref_ali[
i].
rotation());
1042 const auto& deltaTrans = target_ali[
i].translation() - ref_ali[
i].translation();
1064 edm::LogError(
"TrackerAlignment_PayloadInspector") <<
"Unrecognized coordinate " << coord << std::endl;
1073 const std::vector<AlignTransform>& ref_ali,
1074 const std::vector<AlignTransform>& target_ali,
1082 for (
unsigned int i = 0;
i < ref_ali.size();
i++) {
1083 if (ref_ali[
i].rawId() == target_ali[
i].rawId()) {
1090 if (checkPart > 0 && thePart != checkPart) {
1094 if (thePart != currentPart) {
1095 currentPart = thePart;
1096 boundaries.push_back(
counter);
1099 CLHEP::HepRotation target_rot(target_ali[
i].
rotation());
1100 CLHEP::HepRotation ref_rot(ref_ali[
i].
rotation());
1126 const auto& deltaTrans = target_ali[
i].translation() - ref_ali[
i].translation();
const std::array< double, 6 > getY()
const double getNModules(AlignmentPI::PARTITION p)
static constexpr auto TEC
bool tibIsDoubleSide(const DetId &id) const
bool tecIsDoubleSide(const DetId &id) const
bool tidIsDoubleSide(const DetId &id) const
unsigned int tobLayer(const DetId &id) const
unsigned int pxbLayer(const DetId &id) const
unsigned int tibSide(const DetId &id) const
void fillComparisonHistogram(const AlignmentPI::coordinate &coord, std::vector< int > &boundaries, const std::vector< AlignTransform > &ref_ali, const std::vector< AlignTransform > &target_ali, std::unique_ptr< TH1F > &compare)
unsigned int tobSide(const DetId &id) const
double trim2PIs(const double phi, const double tolerance=1.f)
std::ostream & operator<<(std::ostream &o, PARTITION x)
std::vector< unsigned int > tidModuleInfo(const DetId &id) const
void makeNicePlotStyle(TH1 *hist, int color)
void computeBarycenters(const std::vector< AlignTransform > &input, const TrackerTopology &tTopo, const std::map< AlignmentPI::coordinate, float > &GPR)
ret
prodAgent to be discontinued
unsigned int tidSide(const DetId &id) const
std::vector< unsigned int > tecPetalInfo(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
const PARTITION PARTITIONS[(int) PARTITION::LAST+1]
Global3DPoint GlobalPoint
virtual ~TkAlBarycenters()
std::string getStringFromPart(AlignmentPI::partitions i)
bool isBPixOuterLadder(const DetId &detid, const TrackerTopology &tTopo, bool isPhase0)
bool isRPhi(const DetId &id) const
unsigned int pxbLadder(const DetId &id) const
Log< level::Error, false > LogError
unsigned int tecRing(const DetId &id) const
ring id
bool tobIsDoubleSide(const DetId &id) const
static const float cmToUm
static std::string const input
void makeNiceStats(TH1F *hist, AlignmentPI::partitions part, int color)
void fillComparisonHistograms(std::vector< int > &boundaries, const std::vector< AlignTransform > &ref_ali, const std::vector< AlignTransform > &target_ali, std::unordered_map< AlignmentPI::coordinate, std::unique_ptr< TH1F > > &compare, bool diff=false, AlignmentPI::partitions checkPart=AlignmentPI::INVALID)
const std::array< double, 6 > getX()
static const unsigned int phase0size
Container::value_type value_type
unsigned int tecSide(const DetId &id) const
static const float tomRad
void fillGeometryInfo(const DetId &detId, const TrackerTopology &tTopo, bool isPhase0)
unsigned int pxfDisk(const DetId &id) const
Abs< T >::type abs(const T &t)
double returnZeroIfNear2PI(const double phi)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::map< AlignmentPI::PARTITION, double > Zbarycenters
EulerAngles toAngles(const RotationType &)
Convert rotation matrix to angles about x-, y-, z-axes (frame rotation).
static constexpr auto TOB
std::pair< int, int > getIndices(AlignmentPI::index i)
constexpr valType roundIfNear0(valType value, double tolerance=1.e-7)
std::pair< float, float > getTheRange(std::map< uint32_t, float > values, const float nsigma)
GlobalPoint getPartitionAvg(AlignmentPI::PARTITION p)
unsigned int pxfSide(const DetId &id) const
static constexpr auto TIB
constexpr uint32_t rawId() const
get the raw id
std::string getStringFromCoordinate(AlignmentPI::coordinate coord)
AlignmentPI::regions filterThePartition()
bool tibIsInternalString(const DetId &id) const
std::string getStringFromIndex(AlignmentPI::index i)
std::map< AlignmentPI::PARTITION, double > Ybarycenters
std::pair< double, double > calculatePosition(TVirtualPad *myPad, int boundary)
std::map< AlignmentPI::PARTITION, double > nmodules
unsigned int tidRing(const DetId &id) const
std::map< AlignmentPI::PARTITION, double > Xbarycenters
unsigned int tibLayer(const DetId &id) const
std::string getStringFromRegionEnum(AlignmentPI::regions e)
unsigned int tobModule(const DetId &id) const
Log< level::Warning, false > LogWarning
const std::array< double, 6 > getZ()
static constexpr auto TID