100 std::map<int, TrackerOfflineValidationSummary::ModuleHistos>& moduleHist,
103 std::map<std::string, std::string>& substructureName,
111 std::map<std::string, std::string>& substructureName);
116 void getBinning(
const std::string& binningPSetName,
int& nBinsX,
double& lowerBoundX,
double& upperBoundX)
const;
157 moduleDirectory_(parSet_.getParameter<
std::
string>(
"moduleDirectoryInOutput")),
158 useFit_(parSet_.getParameter<
bool>(
"useFit")),
160 moduleMapsInitialized(
false),
161 lastSetup_(nullptr) {
186 std::vector<DetId>::const_iterator iDet;
187 for (iDet = detIdContainer.begin(); iDet != detIdContainer.end(); ++iDet) {
188 const DetId& detId = *iDet;
189 const uint32_t rawId = detId.
rawId();
190 const unsigned int subdetId = detId.
subdetId();
205 <<
"[TrackerOfflineValidationSummary] Error, tried to get reference for non-tracker subdet " << subdetId
206 <<
" from detector " << detId.
det();
221 TTree*
tree =
new TTree(
"TkOffVal",
"TkOffVal");
227 tree->Branch(
"TkOffTreeVariables", &treeMemPtr);
229 std::map<std::string, std::string>* substructureName =
new std::map<std::string, std::string>;
230 tree->Branch(
"SubstructureName", &substructureName, 32000, 00);
248 treeMemPtr =
nullptr;
249 delete substructureName;
250 substructureName =
nullptr;
254 std::map<int, TrackerOfflineValidationSummary::ModuleHistos>& moduleHist,
257 std::map<std::string, std::string>& substructureName,
259 for (std::map<int, TrackerOfflineValidationSummary::ModuleHistos>::iterator it = moduleHist.begin(),
260 itEnd = moduleHist.end();
266 const DetId detId = it->first;
271 unsigned int whichHalfBarrel(1), rawId(detId.
rawId());
272 if ((rawId >= 302056964 && rawId < 302059300) || (rawId >= 302123268 && rawId < 302127140) ||
273 (rawId >= 302189572 && rawId < 302194980))
276 treeMem.
half = whichHalfBarrel;
281 unsigned int whichHalfCylinder(1), rawId(detId.
rawId());
282 if ((rawId >= 352394500 && rawId < 352406032) || (rawId >= 352460036 && rawId < 352471568) ||
283 (rawId >= 344005892 && rawId < 344017424) || (rawId >= 344071428 && rawId < 344082960))
284 whichHalfCylinder = 2;
287 treeMem.
half = whichHalfCylinder;
292 unsigned int whichHalfShell(1), rawId(detId.
rawId());
293 if ((rawId >= 369120484 && rawId < 369120688) || (rawId >= 369121540 && rawId < 369121776) ||
294 (rawId >= 369136932 && rawId < 369137200) || (rawId >= 369137988 && rawId < 369138288) ||
295 (rawId >= 369153396 && rawId < 369153744) || (rawId >= 369154436 && rawId < 369154800) ||
296 (rawId >= 369169844 && rawId < 369170256) || (rawId >= 369170900 && rawId < 369171344) ||
297 (rawId >= 369124580 && rawId < 369124784) || (rawId >= 369125636 && rawId < 369125872) ||
298 (rawId >= 369141028 && rawId < 369141296) || (rawId >= 369142084 && rawId < 369142384) ||
299 (rawId >= 369157492 && rawId < 369157840) || (rawId >= 369158532 && rawId < 369158896) ||
300 (rawId >= 369173940 && rawId < 369174352) || (rawId >= 369174996 && rawId < 369175440))
304 treeMem.
half = whichHalfShell;
342 treeMem.
posX = gPModule.
x();
343 treeMem.
posY = gPModule.
y();
344 treeMem.
posZ = gPModule.
z();
349 LocalPoint lUDirection(1., 0., 0.), lVDirection(0., 1., 0.), lWDirection(0., 0., 1.);
351 gWDirection = surface.
toGlobal(lWDirection);
352 double dR(999.),
dPhi(999.), dZ(999.);
355 dR = gWDirection.perp() - gPModule.
perp();
357 dZ = gVDirection.z() - gPModule.
z();
365 dZ = gWDirection.z() - gPModule.
z();
371 dR = gVDirection.perp() - gPModule.
perp();
373 dZ = gWDirection.z() - gPModule.
z();
396 treeMem.
entries = static_cast<UInt_t>(it->second.ResXprimeHisto->GetEntries());
397 treeMem.
meanX = it->second.ResXprimeHisto->GetMean();
398 treeMem.
rmsX = it->second.ResXprimeHisto->GetRMS();
403 std::pair<float, float> fitResult1 = this->
fitResiduals(it->second.ResXprimeHisto);
404 treeMem.
fitMeanX = fitResult1.first;
407 std::pair<float, float> fitResult2 = this->
fitResiduals(it->second.NormResXprimeHisto);
415 int numberOfBins = it->second.ResXprimeHisto->GetNbinsX();
419 it->second.ResXprimeHisto->GetBinContent(0) + it->second.ResXprimeHisto->GetBinContent(
numberOfBins + 1);
421 treeMem.
meanNormX = it->second.NormResXprimeHisto->GetMean();
422 treeMem.
rmsNormX = it->second.NormResXprimeHisto->GetRMS();
425 it->second.NormResXprimeHisto->GetStats(
stats);
431 treeMem.
histNameX = it->second.ResXprimeHisto->GetName();
432 treeMem.
histNameNormX = it->second.NormResXprimeHisto->GetName();
435 if (it->second.ResHisto && it->second.NormResHisto) {
436 treeMem.
meanLocalX = it->second.ResHisto->GetMean();
437 treeMem.
rmsLocalX = it->second.ResHisto->GetRMS();
446 if (it->second.ResYprimeHisto) {
447 TH1*
h = it->second.ResYprimeHisto;
448 treeMem.
meanY =
h->GetMean();
449 treeMem.
rmsY =
h->GetRMS();
452 std::pair<float, float> fitMeanSigma = this->
fitResiduals(h);
453 treeMem.
fitMeanY = fitMeanSigma.first;
463 if (it->second.NormResYprimeHisto) {
464 TH1*
h = it->second.NormResYprimeHisto;
472 std::pair<float, float> fitMeanSigma = this->
fitResiduals(h);
486 std::map<std::string, std::string>& substructureName) {
487 std::stringstream
histDir, sSubdetName;
497 else if (treeMem.
rod > 15)
501 }
else if (layer == 2) {
504 else if (treeMem.
rod > 24)
508 }
else if (layer == 3) {
511 else if (treeMem.
rod > 33)
516 componentName =
"Pixel";
517 sSubdetName <<
"TPBBarrel_1";
518 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TPBHalfBarrel_" << treeMem.
half <<
"/TPBLayer_"
521 unsigned int side(treeMem.
side), half(treeMem.
half), blade(0);
525 blade = treeMem.
blade - 6;
526 else if (treeMem.
blade > 18)
527 blade = treeMem.
blade - 12;
529 blade = treeMem.
blade;
530 componentName =
"Pixel";
531 sSubdetName <<
"TPEEndcap_" << side;
532 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TPEHalfCylinder_" << treeMem.
half <<
"/TPEHalfDisk_"
533 << treeMem.
layer <<
"/TPEBlade_" << blade <<
"/TPEPanel_" << treeMem.
panel;
534 wheelOrLayer =
"_wheel_";
540 string = treeMem.
rod - 13;
541 else if (surface == 2)
542 string = treeMem.
rod - 15;
546 string = treeMem.
rod - 17;
547 else if (surface == 2)
548 string = treeMem.
rod - 19;
552 string = treeMem.
rod - 22;
553 else if (surface == 2)
554 string = treeMem.
rod - 23;
558 string = treeMem.
rod - 26;
559 else if (surface == 2)
560 string = treeMem.
rod - 28;
563 string = treeMem.
rod;
564 std::stringstream detString;
566 detString <<
"/Det_" << treeMem.
module;
569 componentName =
"Strip";
570 sSubdetName <<
"TIBBarrel_1";
571 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TIBHalfBarrel_" << treeMem.
side <<
"/TIBLayer_"
572 << treeMem.
layer <<
"/TIBHalfShell_" << treeMem.
half <<
"/TIBSurface_" << treeMem.
outerInner
573 <<
"/TIBString_" <<
string << detString.str();
575 unsigned int side(treeMem.
side), outerInner(0);
582 std::stringstream detString;
584 detString <<
"/Det_" << treeMem.
module;
587 componentName =
"Strip";
588 sSubdetName <<
"TIDEndcap_" << side;
589 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TIDDisk_" << treeMem.
layer <<
"/TIDRing_" << treeMem.
ring
590 <<
"/TIDSide_" << outerInner << detString.str();
591 wheelOrLayer =
"_wheel_";
593 std::stringstream detString;
595 detString <<
"/Det_" << treeMem.
module;
598 componentName =
"Strip";
599 sSubdetName <<
"TOBBarrel_4";
600 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TOBHalfBarrel_" << treeMem.
side <<
"/TOBLayer_"
601 << treeMem.
layer <<
"/TOBRod_" << treeMem.
rod << detString.str();
603 unsigned int side(0), outerInner(0),
ring(0);
604 if (treeMem.
side == 1)
606 else if (treeMem.
side == 2)
614 else if (treeMem.
layer == 7 || treeMem.
layer == 8)
616 else if (treeMem.
layer == 9)
620 std::stringstream detString;
622 detString <<
"/Det_" << treeMem.
module;
625 componentName =
"Strip";
626 sSubdetName <<
"TECEndcap_" << side;
627 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TECDisk_" << treeMem.
layer <<
"/TECSide_" << outerInner
628 <<
"/TECPetal_" << treeMem.
petal <<
"/TECRing_" <<
ring << detString.str();
629 wheelOrLayer =
"_wheel_";
632 substructureName[
"component"] = componentName;
633 substructureName[
"subdet"] = sSubdetName.str();
635 std::stringstream histName;
636 histName <<
"residuals_subdet_" << treeMem.
subDetId << wheelOrLayer << treeMem.
layer <<
"_module_"
645 <<
"Problem with names in input file produced in TrackerOfflineValidation ...\n"
646 <<
"This histogram should exist in every configuration, "
647 <<
"but no histogram with name " <<
fullPath <<
" is found!";
670 std::pair<float, float> fitResult(9999., 9999.);
671 if (!
hist ||
hist->GetEntries() < 20)
675 float sigma =
hist->GetRMS();
683 sigma =
func.GetParameter(2);
688 if (0 ==
hist->Fit(&
func,
"Q0LR")) {
689 if (
hist->GetFunction(
func.GetName())) {
690 hist->GetFunction(
func.GetName())->ResetBit(TF1::kNotDraw);
692 fitResult.first =
func.GetParameter(1);
693 fitResult.second =
func.GetParameter(2);
697 edm::LogWarning(
"Alignment") <<
"@SUB=TrackerOfflineValidation::fitResiduals"
698 <<
"Caught this exception during ROOT fit: " <<
e.what();
708 double*
x =
new double[
nbins];
709 double*
y =
new double[
nbins];
731 std::map<std::string, std::string>* substructureName =
nullptr;
732 tree.SetBranchAddress(
"TkOffTreeVariables", &treeMemPtr);
733 tree.SetBranchAddress(
"SubstructureName", &substructureName);
736 for (
unsigned int iSubdet = 1; iSubdet < 7; ++iSubdet) {
739 std::vector<unsigned int> treeEntries;
740 for (
unsigned int iSide = 1; iSide < 3; ++iSide) {
745 for (
int iTree = 0; iTree <
tree.GetEntries(); ++iTree) {
746 tree.GetEntry(iTree);
750 if (treeMemPtr->
subDetId == iSubdet) {
754 treeEntries.push_back(iTree);
755 if (hierarchyName.length() == 0) {
756 hierarchyName = (*substructureName)[
"subdet"];
757 componentName = (*substructureName)[
"component"];
777 edm::LogInfo(
"TrackerOfflineValidationSummary") <<
"Harvesting histograms will be booked for "
782 std::stringstream dmrXprimeHistoName, dmrYprimeHistoName, dmrXprimeHistoTitle, dmrYprimeHistoTitle;
783 dmrXprimeHistoName <<
"h_DmrXprime_" << iHier->hierarchyName;
784 dmrYprimeHistoName <<
"h_DmrYprime_" << iHier->hierarchyName;
785 dmrXprimeHistoTitle <<
"DMR for " << iHier->hierarchyName <<
";<#DeltaX> [cm];# modules";
786 dmrYprimeHistoTitle <<
"DMR for " << iHier->hierarchyName <<
";<#DeltaY> [cm];# modules";
789 if (directoryString.length() != 0)
790 directoryString +=
"/";
791 directoryString += iHier->componentName;
796 if (iHier->componentName ==
"Pixel") {
798 iHier->harvestingHistos.DmrXprime =
799 dbe_->
book1D(dmrXprimeHistoName.str(), dmrXprimeHistoTitle.str(), nBinsX,
xMin,
xMax)->getTH1();
801 iHier->harvestingHistos.DmrYprime =
802 dbe_->
book1D(dmrYprimeHistoName.str(), dmrYprimeHistoTitle.str(), nBinsX,
xMin,
xMax)->getTH1();
803 }
else if (iHier->componentName ==
"Strip") {
805 iHier->harvestingHistos.DmrXprime =
806 dbe_->
book1D(dmrXprimeHistoName.str(), dmrXprimeHistoTitle.str(), nBinsX,
xMin,
xMax)->getTH1();
810 iHier->harvestingHistos.DmrYprime =
811 dbe_->
book1D(dmrYprimeHistoName.str(), dmrYprimeHistoTitle.str(), nBinsX,
xMin,
xMax)->getTH1();
819 double& upperBoundX)
const {
828 std::map<std::string, std::string>* substructureName =
nullptr;
829 tree.SetBranchAddress(
"TkOffTreeVariables", &treeMemPtr);
830 tree.SetBranchAddress(
"SubstructureName", &substructureName);
832 const unsigned int minEntriesPerModule(
parSet_.
getParameter<
unsigned int>(
"minEntriesPerModuleForDmr"));
834 <<
"Median of a module is added to DMR plots if it contains at least " << minEntriesPerModule <<
" hits";
839 for (std::vector<unsigned int>::const_iterator iTreeEntries = iHier->treeEntries.begin();
840 iTreeEntries != iHier->treeEntries.end();
842 tree.GetEntry(*iTreeEntries);
843 if (treeMemPtr->
entries < minEntriesPerModule)
845 iHier->harvestingHistos.DmrXprime->Fill(treeMemPtr->
medianX);
846 if (iHier->harvestingHistos.DmrYprime)
847 iHier->harvestingHistos.DmrYprime->Fill(treeMemPtr->
medianY);