1 #ifndef CONDCORE_ALIGNMENTPLUGINS_ALIGNMENTPAYLOADINSPECTORHELPER_H 2 #define CONDCORE_ALIGNMENTPLUGINS_ALIGNMENTPAYLOADINSPECTORHELPER_H 11 #include "TPaveStats.h" 27 #define COUT std::cout << "MM " 29 #define COUT edm::LogVerbatim("") 51 t2.SetTextColor(kRed);
53 t2.DrawLatexNDC(0.6, 0.50, Form(
"%s NOT SUPPORTED!",
phase.c_str()));
55 t2.DrawLatexNDC(0.6, 0.50,
"MISMATCHED PAYLOAD SIZE!");
62 const double tol = 2.e-7;
360 bool isOuter =
false;
365 isOuter = !odd_ladder;
367 isOuter = odd_ladder;
370 isOuter = !odd_ladder;
372 isOuter = odd_ladder;
437 unsigned int subdetId =
static_cast<unsigned int>(
detId.subdetId());
656 return "x-translation";
658 return "y-translation";
660 return "z-translation";
662 return "#alpha angle rotation";
664 return "#beta angle rotation";
666 return "#gamma angle rotation";
668 return "should never be here!";
690 return "should never be here!";
704 return (
isPhase2 ?
"TIB-invalid" :
"TIB");
706 return (
isPhase2 ?
"P2OTEC" :
"TID");
708 return (
isPhase2 ?
"P2OTB" :
"TOB");
710 return (
isPhase2 ?
"TEC-invalid" :
"TEC");
712 return "should never be here!";
722 return std::make_pair(0, 0);
724 return std::make_pair(0, 1);
726 return std::make_pair(0, 2);
728 return std::make_pair(1, 0);
730 return std::make_pair(1, 1);
732 return std::make_pair(2, 2);
734 return std::make_pair(-1, -1);
742 hist->SetStats(kFALSE);
744 hist->GetXaxis()->SetTitleColor(color);
745 hist->SetLineColor(color);
746 hist->SetTitleSize(0.08);
747 hist->SetLineWidth(2);
748 hist->GetXaxis()->CenterTitle(
true);
749 hist->GetYaxis()->CenterTitle(
true);
750 hist->GetXaxis()->SetTitleFont(42);
751 hist->GetYaxis()->SetTitleFont(42);
752 hist->GetXaxis()->SetNdivisions(505);
753 hist->GetXaxis()->SetTitleSize(0.06);
754 hist->GetYaxis()->SetTitleSize(0.06);
755 hist->GetXaxis()->SetTitleOffset(1.0);
756 hist->GetYaxis()->SetTitleOffset(1.3);
757 hist->GetXaxis()->SetLabelFont(42);
758 hist->GetYaxis()->SetLabelFont(42);
759 hist->GetYaxis()->SetLabelSize(.05);
760 hist->GetXaxis()->SetLabelSize(.05);
768 TPaveText*
stat =
new TPaveText(0.71, 0.75, 0.95, 0.88,
"NDC");
772 sprintf(
buffer,
"Entries : %i\n", (
int)
hist->GetEntries());
776 sprintf(
buffer,
"Mean : %6.2f\n",
hist->GetMean());
778 sprintf(
buffer,
"Mean : %6.2f e-2\n", 100 *
hist->GetMean());
783 sprintf(
buffer,
"RMS : %6.2f\n",
hist->GetRMS());
785 sprintf(
buffer,
"RMS : %6.2f e-2\n", 100 *
hist->GetRMS());
789 stat->SetLineColor(0);
790 stat->SetTextColor(color);
791 stat->SetFillColor(10);
792 stat->SetShadowColor(10);
797 inline std::pair<float, float>
getTheRange(std::map<uint32_t, float>
values,
const float nsigma)
800 float sum = std::accumulate(
809 accum += (
p.second -
m) * (
p.second -
m);
815 return std::make_pair(
m - nsigma *
stdev,
m + nsigma *
stdev);
817 return std::make_pair(
m > 0. ? 0.95 *
m : 1.05 *
m,
m > 0 ? 1.05 *
m : 0.95 *
m);
827 int iw = myPad->GetWw();
828 int ih = myPad->GetWh();
829 double x1p, y1p, x2p, y2p;
830 myPad->GetPadPar(x1p, y1p, x2p, y2p);
831 ix1 = (
int)(iw * x1p);
832 ix2 = (
int)(iw * x2p);
833 double wndc =
std::min(1., (
double)iw / (
double)ih);
834 double rw = wndc / (double)iw;
835 double x1ndc = (double)ix1 * rw;
836 double x2ndc = (double)ix2 * rw;
837 double rx1, ry1, rx2, ry2;
838 myPad->GetRange(rx1, ry1, rx2, ry2);
839 double rx = (x2ndc - x1ndc) / (rx2 - rx1);
841 _sx =
rx * (boundary - rx1) + x1ndc;
842 double _dx = _sx + 0.05;
844 return std::make_pair(_sx, _dx);
861 const std::map<AlignmentPI::coordinate, float>& GPR);
869 const std::array<double, 6>
getX()
881 const std::array<double, 6>
getY()
893 const std::array<double, 6>
getZ()
927 const std::map<AlignmentPI::coordinate, float>& GPR)
933 for (
const auto& ali :
input) {
936 <<
"Encountered invalid Tracker DetId:" << ali.rawId() <<
" " <<
DetId(ali.rawId()).det()
941 int subid =
DetId(ali.rawId()).subdetId();
1008 edm::LogError(
"TrackerAlignment_PayloadInspector") <<
"Unrecognized partition " << subid << std::endl;
1024 COUT <<
"Partition: " <<
p <<
" n. modules: " <<
nmodules[
p] <<
"|" 1025 <<
" X: " << std::right << std::setw(12) <<
Xbarycenters[
p] <<
" Y: " << std::right << std::setw(12)
1032 std::map<int, AlignmentPI::partitions>& boundaries,
1033 const std::vector<AlignTransform>& ref_ali,
1034 const std::vector<AlignTransform>& target_ali,
1035 std::unique_ptr<TH1F>&
compare)
1040 for (
unsigned int i = 0;
i < ref_ali.size();
i++) {
1041 if (ref_ali[
i].
rawId() == target_ali[
i].rawId()) {
1046 if (thePart != currentPart) {
1047 currentPart = thePart;
1048 boundaries.insert({
counter, thePart});
1051 CLHEP::HepRotation target_rot(target_ali[
i].
rotation());
1052 CLHEP::HepRotation ref_rot(ref_ali[
i].
rotation());
1078 const auto& deltaTrans = target_ali[
i].translation() - ref_ali[
i].translation();
1100 edm::LogError(
"TrackerAlignment_PayloadInspector") <<
"Unrecognized coordinate " << coord << std::endl;
1109 const std::vector<AlignTransform>& ref_ali,
1110 const std::vector<AlignTransform>& target_ali,
1118 for (
unsigned int i = 0;
i < ref_ali.size();
i++) {
1119 if (ref_ali[
i].
rawId() == target_ali[
i].rawId()) {
1126 if (checkPart > 0 && thePart != checkPart) {
1130 if (thePart != currentPart) {
1131 currentPart = thePart;
1132 boundaries.insert({
counter, thePart});
1135 CLHEP::HepRotation target_rot(target_ali[
i].
rotation());
1136 CLHEP::HepRotation ref_rot(ref_ali[
i].
rotation());
1162 const auto& deltaTrans = target_ali[
i].translation() - ref_ali[
i].translation();
1225 unsigned int diskStartBit_ = 18;
1226 unsigned int bladeStartBit_ = 12;
1227 unsigned int panelStartBit_ = 10;
1230 unsigned int diskMask_ = 0xF;
1231 unsigned int bladeMask_ = 0x3F;
1232 unsigned int panelMask_ = 0x3;
1235 int disk = (
rawId >> diskStartBit_) & diskMask_;
1236 int blade = (
rawId >> bladeStartBit_) & bladeMask_;
1237 int panel = (
rawId >> panelStartBit_) & panelMask_;
1238 return std::make_tuple(disk, blade, panel);
1240 return std::make_tuple(-1, -1, -1);
1243 bool foundZeroDisk =
false;
1246 auto [disk, blade, panel] = extractBladePanel(
transform);
1251 <<
" disk: " << disk <<
" blade: " << blade <<
" panel: " << panel;
1252 foundZeroDisk =
true;
1257 return foundZeroDisk;
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
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()
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)
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
bool isReorderedTFPXTEPX(const std::vector< AlignTransform > &transforms)
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) ...
static const unsigned int phase1size
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)
Log< level::Info, false > LogInfo
void fillComparisonHistograms(std::map< int, AlignmentPI::partitions > &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)
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
static std::atomic< unsigned int > counter
unsigned int tidRing(const DetId &id) const
void displayNotSupported(TCanvas &canv, const unsigned int size)
void fillComparisonHistogram(const AlignmentPI::coordinate &coord, std::map< int, AlignmentPI::partitions > &boundaries, const std::vector< AlignTransform > &ref_ali, const std::vector< AlignTransform > &target_ali, std::unique_ptr< TH1F > &compare)
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()
std::string getStringFromPart(AlignmentPI::partitions i, bool isPhase2=false)
static constexpr auto TID
static const unsigned int mismatched