107 std::map<int, TrackerOfflineValidationSummary::ModuleHistos>& moduleHist,
110 std::map<std::string, std::string>& substructureName,
118 std::map<std::string, std::string>& substructureName);
123 void getBinning(
const std::string& binningPSetName,
int& nBinsX,
double& lowerBoundX,
double& upperBoundX)
const;
158 moduleDirectory_(parSet_.getParameter<
std::
string>(
"moduleDirectoryInOutput")),
159 useFit_(parSet_.getParameter<
bool>(
"useFit")),
161 moduleMapsInitialized(
false) {
168 desc.setComment(
"Summary of alignment payloads validation by evaluating unbiased track-hit resisuals");
170 desc.add<
bool>(
"useFit",
false);
171 desc.add<
bool>(
"stripYDmrs",
false);
172 desc.add<
unsigned int>(
"minEntriesPerModuleForDmr", 100);
175 const std::vector<std::string> listOfDMRPSets = {
176 "TH1DmrXprimeStripModules",
"TH1DmrYprimeStripModules",
"TH1DmrXprimePixelModules",
"TH1DmrYprimePixelModules"};
178 for (
const auto& myPSetName : listOfDMRPSets) {
180 myPSet.
add<
int>(
"Nbinx", 100);
181 myPSet.
add<
double>(
"xmin", -5.f);
182 myPSet.
add<
double>(
"xmax", 5.f);
202 std::vector<DetId>::const_iterator iDet;
203 for (iDet = detIdContainer.begin(); iDet != detIdContainer.end(); ++iDet) {
206 const unsigned int subdetId =
detId.subdetId();
221 <<
"[TrackerOfflineValidationSummary] Error, tried to get reference for non-tracker subdet " << subdetId
222 <<
" from detector " <<
detId.det();
239 TTree*
tree =
new TTree(
"TkOffVal",
"TkOffVal");
245 tree->Branch(
"TkOffTreeVariables", &treeMemPtr);
247 std::map<std::string, std::string>* substructureName =
new std::map<std::string, std::string>;
248 tree->Branch(
"SubstructureName", &substructureName, 32000, 00);
266 treeMemPtr =
nullptr;
267 delete substructureName;
268 substructureName =
nullptr;
272 std::map<int, TrackerOfflineValidationSummary::ModuleHistos>& moduleHist,
275 std::map<std::string, std::string>& substructureName,
277 for (std::map<int, TrackerOfflineValidationSummary::ModuleHistos>::iterator
it = moduleHist.begin(),
278 itEnd = moduleHist.end();
289 unsigned int whichHalfBarrel(1),
rawId(
detId.rawId());
294 treeMem.
half = whichHalfBarrel;
299 unsigned int whichHalfCylinder(1),
rawId(
detId.rawId());
302 whichHalfCylinder = 2;
305 treeMem.
half = whichHalfCylinder;
310 unsigned int whichHalfShell(1),
rawId(
detId.rawId());
322 treeMem.
half = whichHalfShell;
360 treeMem.
posX = gPModule.
x();
361 treeMem.
posY = gPModule.
y();
362 treeMem.
posZ = gPModule.
z();
367 LocalPoint lUDirection(1., 0., 0.), lVDirection(0., 1., 0.), lWDirection(0., 0., 1.);
369 gWDirection = surface.
toGlobal(lWDirection);
370 double dR(999.),
dPhi(999.),
dZ(999.);
373 dR = gWDirection.perp() - gPModule.
perp();
375 dZ = gVDirection.z() - gPModule.
z();
383 dZ = gWDirection.z() - gPModule.
z();
389 dR = gVDirection.perp() - gPModule.
perp();
391 dZ = gWDirection.z() - gPModule.
z();
414 treeMem.
entries =
static_cast<UInt_t
>(
it->second.ResXprimeHisto->GetEntries());
415 treeMem.
meanX =
it->second.ResXprimeHisto->GetMean();
416 treeMem.
rmsX =
it->second.ResXprimeHisto->GetRMS();
421 std::pair<float, float> fitResult1 = this->
fitResiduals(
it->second.ResXprimeHisto);
422 treeMem.
fitMeanX = fitResult1.first;
425 std::pair<float, float> fitResult2 = this->
fitResiduals(
it->second.NormResXprimeHisto);
437 it->second.ResXprimeHisto->GetBinContent(0) +
it->second.ResXprimeHisto->GetBinContent(
numberOfBins + 1);
439 treeMem.
meanNormX =
it->second.NormResXprimeHisto->GetMean();
440 treeMem.
rmsNormX =
it->second.NormResXprimeHisto->GetRMS();
443 it->second.NormResXprimeHisto->GetStats(
stats);
449 treeMem.
histNameX =
it->second.ResXprimeHisto->GetName();
453 if (
it->second.ResHisto &&
it->second.NormResHisto) {
464 if (
it->second.ResYprimeHisto) {
465 TH1*
h =
it->second.ResYprimeHisto;
466 treeMem.
meanY =
h->GetMean();
467 treeMem.
rmsY =
h->GetRMS();
470 std::pair<float, float> fitMeanSigma = this->
fitResiduals(h);
471 treeMem.
fitMeanY = fitMeanSigma.first;
481 if (
it->second.NormResYprimeHisto) {
482 TH1*
h =
it->second.NormResYprimeHisto;
490 std::pair<float, float> fitMeanSigma = this->
fitResiduals(h);
504 std::map<std::string, std::string>& substructureName) {
505 std::stringstream
histDir, sSubdetName;
515 else if (treeMem.
rod > 15)
519 }
else if (
layer == 2) {
522 else if (treeMem.
rod > 24)
526 }
else if (
layer == 3) {
529 else if (treeMem.
rod > 33)
534 componentName =
"Pixel";
535 sSubdetName <<
"TPBBarrel_1";
536 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TPBHalfBarrel_" << treeMem.
half <<
"/TPBLayer_" 539 unsigned int side(treeMem.
side), half(treeMem.
half), blade(0);
543 blade = treeMem.
blade - 6;
544 else if (treeMem.
blade > 18)
545 blade = treeMem.
blade - 12;
547 blade = treeMem.
blade;
548 componentName =
"Pixel";
549 sSubdetName <<
"TPEEndcap_" <<
side;
550 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TPEHalfCylinder_" << treeMem.
half <<
"/TPEHalfDisk_" 551 << treeMem.
layer <<
"/TPEBlade_" << blade <<
"/TPEPanel_" << treeMem.
panel;
552 wheelOrLayer =
"_wheel_";
558 string = treeMem.
rod - 13;
559 else if (surface == 2)
560 string = treeMem.
rod - 15;
564 string = treeMem.
rod - 17;
565 else if (surface == 2)
566 string = treeMem.
rod - 19;
570 string = treeMem.
rod - 22;
571 else if (surface == 2)
572 string = treeMem.
rod - 23;
576 string = treeMem.
rod - 26;
577 else if (surface == 2)
578 string = treeMem.
rod - 28;
581 string = treeMem.
rod;
582 std::stringstream detString;
584 detString <<
"/Det_" << treeMem.
module;
587 componentName =
"Strip";
588 sSubdetName <<
"TIBBarrel_1";
589 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TIBHalfBarrel_" << treeMem.
side <<
"/TIBLayer_" 590 << treeMem.
layer <<
"/TIBHalfShell_" << treeMem.
half <<
"/TIBSurface_" << treeMem.
outerInner 591 <<
"/TIBString_" <<
string << detString.str();
593 unsigned int side(treeMem.
side), outerInner(0);
600 std::stringstream detString;
602 detString <<
"/Det_" << treeMem.
module;
605 componentName =
"Strip";
606 sSubdetName <<
"TIDEndcap_" <<
side;
607 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TIDDisk_" << treeMem.
layer <<
"/TIDRing_" << treeMem.
ring 608 <<
"/TIDSide_" << outerInner << detString.str();
609 wheelOrLayer =
"_wheel_";
611 std::stringstream detString;
613 detString <<
"/Det_" << treeMem.
module;
616 componentName =
"Strip";
617 sSubdetName <<
"TOBBarrel_4";
618 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TOBHalfBarrel_" << treeMem.
side <<
"/TOBLayer_" 619 << treeMem.
layer <<
"/TOBRod_" << treeMem.
rod << detString.str();
621 unsigned int side(0), outerInner(0),
ring(0);
622 if (treeMem.
side == 1)
624 else if (treeMem.
side == 2)
632 else if (treeMem.
layer == 7 || treeMem.
layer == 8)
634 else if (treeMem.
layer == 9)
638 std::stringstream detString;
640 detString <<
"/Det_" << treeMem.
module;
643 componentName =
"Strip";
644 sSubdetName <<
"TECEndcap_" <<
side;
645 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TECDisk_" << treeMem.
layer <<
"/TECSide_" << outerInner
646 <<
"/TECPetal_" << treeMem.
petal <<
"/TECRing_" <<
ring << detString.str();
647 wheelOrLayer =
"_wheel_";
650 substructureName[
"component"] = componentName;
651 substructureName[
"subdet"] = sSubdetName.str();
653 std::stringstream histName;
654 histName <<
"residuals_subdet_" << treeMem.
subDetId << wheelOrLayer << treeMem.
layer <<
"_module_" 663 <<
"Problem with names in input file produced in TrackerOfflineValidation ...\n" 664 <<
"This histogram should exist in every configuration, " 665 <<
"but no histogram with name " <<
fullPath <<
" is found!";
688 std::pair<float, float> fitResult(9999., 9999.);
689 if (!
hist ||
hist->GetEntries() < 20)
693 float sigma =
hist->GetRMS();
698 TF1
func(
"tmp",
"gaus",
mean - 2. * sigma,
mean + 2. * sigma);
701 sigma =
func.GetParameter(2);
706 if (0 ==
hist->Fit(&
func,
"Q0LR")) {
707 if (
hist->GetFunction(
func.GetName())) {
708 hist->GetFunction(
func.GetName())->ResetBit(TF1::kNotDraw);
710 fitResult.first =
func.GetParameter(1);
711 fitResult.second =
func.GetParameter(2);
715 edm::LogWarning(
"Alignment") <<
"@SUB=TrackerOfflineValidation::fitResiduals" 716 <<
"Caught this exception during ROOT fit: " <<
e.what();
726 double*
x =
new double[
nbins];
727 double*
y =
new double[
nbins];
749 std::map<std::string, std::string>* substructureName =
nullptr;
750 tree.SetBranchAddress(
"TkOffTreeVariables", &treeMemPtr);
751 tree.SetBranchAddress(
"SubstructureName", &substructureName);
754 for (
unsigned int iSubdet = 1; iSubdet < 7; ++iSubdet) {
757 std::vector<unsigned int> treeEntries;
758 for (
unsigned int iSide = 1; iSide < 3; ++iSide) {
763 for (
int iTree = 0; iTree <
tree.GetEntries(); ++iTree) {
764 tree.GetEntry(iTree);
768 if (treeMemPtr->
subDetId == iSubdet) {
772 treeEntries.push_back(iTree);
773 if (hierarchyName.length() == 0) {
774 hierarchyName = (*substructureName)[
"subdet"];
775 componentName = (*substructureName)[
"component"];
795 edm::LogInfo(
"TrackerOfflineValidationSummary") <<
"Harvesting histograms will be booked for " 800 std::stringstream dmrXprimeHistoName, dmrYprimeHistoName, dmrXprimeHistoTitle, dmrYprimeHistoTitle;
801 dmrXprimeHistoName <<
"h_DmrXprime_" << iHier->hierarchyName;
802 dmrYprimeHistoName <<
"h_DmrYprime_" << iHier->hierarchyName;
803 dmrXprimeHistoTitle <<
"DMR for " << iHier->hierarchyName <<
";<#DeltaX> [cm];# modules";
804 dmrYprimeHistoTitle <<
"DMR for " << iHier->hierarchyName <<
";<#DeltaY> [cm];# modules";
807 if (directoryString.length() != 0)
808 directoryString +=
"/";
809 directoryString += iHier->componentName;
814 if (iHier->componentName ==
"Pixel") {
816 iHier->harvestingHistos.DmrXprime =
817 dbe_->
book1D(dmrXprimeHistoName.str(), dmrXprimeHistoTitle.str(), nBinsX,
xMin,
xMax)->getTH1();
819 iHier->harvestingHistos.DmrYprime =
820 dbe_->
book1D(dmrYprimeHistoName.str(), dmrYprimeHistoTitle.str(), nBinsX,
xMin,
xMax)->getTH1();
821 }
else if (iHier->componentName ==
"Strip") {
823 iHier->harvestingHistos.DmrXprime =
824 dbe_->
book1D(dmrXprimeHistoName.str(), dmrXprimeHistoTitle.str(), nBinsX,
xMin,
xMax)->getTH1();
828 iHier->harvestingHistos.DmrYprime =
829 dbe_->
book1D(dmrYprimeHistoName.str(), dmrYprimeHistoTitle.str(), nBinsX,
xMin,
xMax)->getTH1();
837 double& upperBoundX)
const {
846 std::map<std::string, std::string>* substructureName =
nullptr;
847 tree.SetBranchAddress(
"TkOffTreeVariables", &treeMemPtr);
848 tree.SetBranchAddress(
"SubstructureName", &substructureName);
850 const unsigned int minEntriesPerModule(
parSet_.
getParameter<
unsigned int>(
"minEntriesPerModuleForDmr"));
852 <<
"Median of a module is added to DMR plots if it contains at least " << minEntriesPerModule <<
" hits";
857 for (std::vector<unsigned int>::const_iterator iTreeEntries = iHier->treeEntries.begin();
858 iTreeEntries != iHier->treeEntries.end();
860 tree.GetEntry(*iTreeEntries);
861 if (treeMemPtr->
entries < minEntriesPerModule)
863 iHier->harvestingHistos.DmrXprime->Fill(treeMemPtr->
medianX);
864 if (iHier->harvestingHistos.DmrYprime)
865 iHier->harvestingHistos.DmrYprime->Fill(treeMemPtr->
medianY);
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mTobResiduals_
void collateHarvestingHists(TTree &tree)
static constexpr auto TEC
bool tibIsDoubleSide(const DetId &id) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
bool tecIsDoubleSide(const DetId &id) const
bool tidIsDoubleSide(const DetId &id) const
T getParameter(std::string const &) const
unsigned int tobLayer(const DetId &id) const
unsigned int pxbLayer(const DetId &id) const
void applyHarvestingHierarchy(TTree &treeMem)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
std::vector< unsigned int > tidModuleInfo(const DetId &id) const
Float_t numberOfOverflows
unsigned int pxfBlade(const DetId &id) const
std::string hierarchyName
Put here the histograms created during harvesting.
const DetIdContainer & detIds() const override
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
uint32_t tidStereo(const DetId &id) const
unsigned int tibModule(const DetId &id) const
unsigned int tidSide(const DetId &id) const
container to hold data to be written into TTree
Geom::Phi< T > phi() const
unsigned int pxfModule(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
void setCurrentFolder(std::string const &fullpath) override
std::vector< HarvestingHierarchy > vHarvestingHierarchy_
ALPAKA_FN_ACC int side(int ieta, int iphi)
void getBinning(const std::string &binningPSetName, int &nBinsX, double &lowerBoundX, double &upperBoundX) const
edm::ESHandle< TrackerGeometry > tkGeom_
unsigned int pxbLadder(const DetId &id) const
Log< level::Error, false > LogError
Float_t numberOfUnderflows
unsigned int tecRing(const DetId &id) const
ring id
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mTibResiduals_
bool tobIsDoubleSide(const DetId &id) const
const edm::ParameterSet parSet_
unsigned int tecModule(const DetId &id) const
uint32_t tobStereo(const DetId &id) const
std::string histNameNormX
unsigned int tecSide(const DetId &id) const
const std::string associateModuleHistsWithTree(const TkOffTreeVariables &treeMem, TrackerOfflineValidationSummary::ModuleHistos &moduleHists, std::map< std::string, std::string > &substructureName)
bool moduleMapsInitialized
unsigned int pxfDisk(const DetId &id) const
#define DEFINE_FWK_MODULE(type)
static constexpr auto TOB
ParameterDescriptionBase * add(U const &iLabel, T const &value)
histDir
Location of output EventInfo/reportSummaryContents.
TrackerOfflineValidationSummary(const edm::ParameterSet &)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
void analyze(const edm::Event &evt, const edm::EventSetup &) override
std::pair< float, float > fitResiduals(TH1 *hist) const
const TrackerGeomDet * idToDet(DetId) const override
std::string histNameNormLocalX
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mTecResiduals_
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
unsigned int pxfPanel(const DetId &id) const
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mPxbResiduals_
Log< level::Info, false > LogInfo
HarvestingHierarchy(const std::string &name, const std::string &component, const std::vector< unsigned int > &entries)
unsigned int pxfSide(const DetId &id) const
std::vector< unsigned int > tibStringInfo(const DetId &id) const
static constexpr auto TIB
const Plane & surface() const
The nominal surface of the GeomDet.
void beginRun(const edm::Run &, const edm::EventSetup &iSetup) override
dqm::legacy::DQMStore DQMStore
std::string histNameLocalX
float getMedian(const TH1 *hist) const
virtual MonitorElement * get(std::string const &fullpath) const
void endRun(const edm::Run &, const edm::EventSetup &iSetup) override
const Surface::PositionType & position() const
The position (origin of the R.F.)
std::vector< DetId > DetIdContainer
const std::string moduleDirectory_
virtual TH1 * getTH1() const
HarvestingHistos harvestingHistos
std::vector< unsigned int > tobRodInfo(const DetId &id) const
void clear()
set to empty values
void bookHarvestingHists()
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
unsigned int tidRing(const DetId &id) const
std::unique_ptr< TrackerTopology > tTopo_
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mPxeResiduals_
uint32_t tecStereo(const DetId &id) const
~TrackerOfflineValidationSummary() override=default
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
unsigned int tibLayer(const DetId &id) const
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mTidResiduals_
unsigned int tobModule(const DetId &id) const
unsigned int pxbModule(const DetId &id) const
Log< level::Warning, false > LogWarning
std::string histNameNormY
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
void fillTree(TTree &tree, std::map< int, TrackerOfflineValidationSummary::ModuleHistos > &moduleHist, TkOffTreeVariables &treeMem, const TrackerGeometry &tkgeom, std::map< std::string, std::string > &substructureName, const TrackerTopology *tTopo)
static constexpr auto TID
std::string componentName
uint32_t tibStereo(const DetId &id) const
std::vector< unsigned int > treeEntries
void fillHarvestingHists(TTree &tree)