105 std::map<int, TrackerOfflineValidationSummary::ModuleHistos>& moduleHist,
108 std::map<std::string, std::string>& substructureName,
116 std::map<std::string, std::string>& substructureName);
121 void getBinning(
const std::string& binningPSetName,
int& nBinsX,
double& lowerBoundX,
double& upperBoundX)
const;
156 moduleDirectory_(parSet_.getParameter<
std::
string>(
"moduleDirectoryInOutput")),
157 useFit_(parSet_.getParameter<
bool>(
"useFit")),
159 moduleMapsInitialized(
false) {
179 std::vector<DetId>::const_iterator iDet;
180 for (iDet = detIdContainer.begin(); iDet != detIdContainer.end(); ++iDet) {
181 const DetId& detId = *iDet;
182 const uint32_t rawId = detId.
rawId();
183 const unsigned int subdetId = detId.
subdetId();
198 <<
"[TrackerOfflineValidationSummary] Error, tried to get reference for non-tracker subdet " << subdetId
199 <<
" from detector " << detId.
det();
216 TTree*
tree =
new TTree(
"TkOffVal",
"TkOffVal");
222 tree->Branch(
"TkOffTreeVariables", &treeMemPtr);
224 std::map<std::string, std::string>* substructureName =
new std::map<std::string, std::string>;
225 tree->Branch(
"SubstructureName", &substructureName, 32000, 00);
243 treeMemPtr =
nullptr;
244 delete substructureName;
245 substructureName =
nullptr;
249 std::map<int, TrackerOfflineValidationSummary::ModuleHistos>& moduleHist,
252 std::map<std::string, std::string>& substructureName,
254 for (std::map<int, TrackerOfflineValidationSummary::ModuleHistos>::iterator it = moduleHist.begin(),
255 itEnd = moduleHist.end();
261 const DetId detId = it->first;
266 unsigned int whichHalfBarrel(1), rawId(detId.
rawId());
267 if ((rawId >= 302056964 && rawId < 302059300) || (rawId >= 302123268 && rawId < 302127140) ||
268 (rawId >= 302189572 && rawId < 302194980))
271 treeMem.
half = whichHalfBarrel;
276 unsigned int whichHalfCylinder(1), rawId(detId.
rawId());
277 if ((rawId >= 352394500 && rawId < 352406032) || (rawId >= 352460036 && rawId < 352471568) ||
278 (rawId >= 344005892 && rawId < 344017424) || (rawId >= 344071428 && rawId < 344082960))
279 whichHalfCylinder = 2;
282 treeMem.
half = whichHalfCylinder;
287 unsigned int whichHalfShell(1), rawId(detId.
rawId());
288 if ((rawId >= 369120484 && rawId < 369120688) || (rawId >= 369121540 && rawId < 369121776) ||
289 (rawId >= 369136932 && rawId < 369137200) || (rawId >= 369137988 && rawId < 369138288) ||
290 (rawId >= 369153396 && rawId < 369153744) || (rawId >= 369154436 && rawId < 369154800) ||
291 (rawId >= 369169844 && rawId < 369170256) || (rawId >= 369170900 && rawId < 369171344) ||
292 (rawId >= 369124580 && rawId < 369124784) || (rawId >= 369125636 && rawId < 369125872) ||
293 (rawId >= 369141028 && rawId < 369141296) || (rawId >= 369142084 && rawId < 369142384) ||
294 (rawId >= 369157492 && rawId < 369157840) || (rawId >= 369158532 && rawId < 369158896) ||
295 (rawId >= 369173940 && rawId < 369174352) || (rawId >= 369174996 && rawId < 369175440))
299 treeMem.
half = whichHalfShell;
337 treeMem.
posX = gPModule.
x();
338 treeMem.
posY = gPModule.
y();
339 treeMem.
posZ = gPModule.
z();
344 LocalPoint lUDirection(1., 0., 0.), lVDirection(0., 1., 0.), lWDirection(0., 0., 1.);
346 gWDirection = surface.
toGlobal(lWDirection);
347 double dR(999.),
dPhi(999.), dZ(999.);
350 dR = gWDirection.perp() - gPModule.
perp();
352 dZ = gVDirection.z() - gPModule.
z();
360 dZ = gWDirection.z() - gPModule.
z();
366 dR = gVDirection.perp() - gPModule.
perp();
368 dZ = gWDirection.z() - gPModule.
z();
391 treeMem.
entries =
static_cast<UInt_t
>(it->second.ResXprimeHisto->GetEntries());
392 treeMem.
meanX = it->second.ResXprimeHisto->GetMean();
393 treeMem.
rmsX = it->second.ResXprimeHisto->GetRMS();
398 std::pair<float, float> fitResult1 = this->
fitResiduals(it->second.ResXprimeHisto);
399 treeMem.
fitMeanX = fitResult1.first;
402 std::pair<float, float> fitResult2 = this->
fitResiduals(it->second.NormResXprimeHisto);
410 int numberOfBins = it->second.ResXprimeHisto->GetNbinsX();
414 it->second.ResXprimeHisto->GetBinContent(0) + it->second.ResXprimeHisto->GetBinContent(
numberOfBins + 1);
416 treeMem.
meanNormX = it->second.NormResXprimeHisto->GetMean();
417 treeMem.
rmsNormX = it->second.NormResXprimeHisto->GetRMS();
420 it->second.NormResXprimeHisto->GetStats(
stats);
426 treeMem.
histNameX = it->second.ResXprimeHisto->GetName();
427 treeMem.
histNameNormX = it->second.NormResXprimeHisto->GetName();
430 if (it->second.ResHisto && it->second.NormResHisto) {
431 treeMem.
meanLocalX = it->second.ResHisto->GetMean();
432 treeMem.
rmsLocalX = it->second.ResHisto->GetRMS();
441 if (it->second.ResYprimeHisto) {
442 TH1*
h = it->second.ResYprimeHisto;
443 treeMem.
meanY =
h->GetMean();
444 treeMem.
rmsY =
h->GetRMS();
447 std::pair<float, float> fitMeanSigma = this->
fitResiduals(h);
448 treeMem.
fitMeanY = fitMeanSigma.first;
458 if (it->second.NormResYprimeHisto) {
459 TH1*
h = it->second.NormResYprimeHisto;
467 std::pair<float, float> fitMeanSigma = this->
fitResiduals(h);
481 std::map<std::string, std::string>& substructureName) {
482 std::stringstream
histDir, sSubdetName;
492 else if (treeMem.
rod > 15)
496 }
else if (
layer == 2) {
499 else if (treeMem.
rod > 24)
503 }
else if (
layer == 3) {
506 else if (treeMem.
rod > 33)
511 componentName =
"Pixel";
512 sSubdetName <<
"TPBBarrel_1";
513 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TPBHalfBarrel_" << treeMem.
half <<
"/TPBLayer_" 516 unsigned int side(treeMem.
side), half(treeMem.
half), blade(0);
520 blade = treeMem.
blade - 6;
521 else if (treeMem.
blade > 18)
522 blade = treeMem.
blade - 12;
524 blade = treeMem.
blade;
525 componentName =
"Pixel";
526 sSubdetName <<
"TPEEndcap_" << side;
527 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TPEHalfCylinder_" << treeMem.
half <<
"/TPEHalfDisk_" 528 << treeMem.
layer <<
"/TPEBlade_" << blade <<
"/TPEPanel_" << treeMem.
panel;
529 wheelOrLayer =
"_wheel_";
535 string = treeMem.
rod - 13;
536 else if (surface == 2)
537 string = treeMem.
rod - 15;
541 string = treeMem.
rod - 17;
542 else if (surface == 2)
543 string = treeMem.
rod - 19;
547 string = treeMem.
rod - 22;
548 else if (surface == 2)
549 string = treeMem.
rod - 23;
553 string = treeMem.
rod - 26;
554 else if (surface == 2)
555 string = treeMem.
rod - 28;
558 string = treeMem.
rod;
559 std::stringstream detString;
561 detString <<
"/Det_" << treeMem.
module;
564 componentName =
"Strip";
565 sSubdetName <<
"TIBBarrel_1";
566 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TIBHalfBarrel_" << treeMem.
side <<
"/TIBLayer_" 567 << treeMem.
layer <<
"/TIBHalfShell_" << treeMem.
half <<
"/TIBSurface_" << treeMem.
outerInner 568 <<
"/TIBString_" <<
string << detString.str();
570 unsigned int side(treeMem.
side), outerInner(0);
577 std::stringstream detString;
579 detString <<
"/Det_" << treeMem.
module;
582 componentName =
"Strip";
583 sSubdetName <<
"TIDEndcap_" << side;
584 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TIDDisk_" << treeMem.
layer <<
"/TIDRing_" << treeMem.
ring 585 <<
"/TIDSide_" << outerInner << detString.str();
586 wheelOrLayer =
"_wheel_";
588 std::stringstream detString;
590 detString <<
"/Det_" << treeMem.
module;
593 componentName =
"Strip";
594 sSubdetName <<
"TOBBarrel_4";
595 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TOBHalfBarrel_" << treeMem.
side <<
"/TOBLayer_" 596 << treeMem.
layer <<
"/TOBRod_" << treeMem.
rod << detString.str();
598 unsigned int side(0), outerInner(0),
ring(0);
599 if (treeMem.
side == 1)
601 else if (treeMem.
side == 2)
609 else if (treeMem.
layer == 7 || treeMem.
layer == 8)
611 else if (treeMem.
layer == 9)
615 std::stringstream detString;
617 detString <<
"/Det_" << treeMem.
module;
620 componentName =
"Strip";
621 sSubdetName <<
"TECEndcap_" << side;
622 histDir << componentName <<
"/" << sSubdetName.str() <<
"/TECDisk_" << treeMem.
layer <<
"/TECSide_" << outerInner
623 <<
"/TECPetal_" << treeMem.
petal <<
"/TECRing_" <<
ring << detString.str();
624 wheelOrLayer =
"_wheel_";
627 substructureName[
"component"] = componentName;
628 substructureName[
"subdet"] = sSubdetName.str();
630 std::stringstream histName;
631 histName <<
"residuals_subdet_" << treeMem.
subDetId << wheelOrLayer << treeMem.
layer <<
"_module_" 640 <<
"Problem with names in input file produced in TrackerOfflineValidation ...\n" 641 <<
"This histogram should exist in every configuration, " 642 <<
"but no histogram with name " <<
fullPath <<
" is found!";
665 std::pair<float, float> fitResult(9999., 9999.);
666 if (!
hist ||
hist->GetEntries() < 20)
670 float sigma =
hist->GetRMS();
675 TF1
func(
"tmp",
"gaus",
mean - 2. * sigma,
mean + 2. * sigma);
678 sigma =
func.GetParameter(2);
683 if (0 ==
hist->Fit(&
func,
"Q0LR")) {
684 if (
hist->GetFunction(
func.GetName())) {
685 hist->GetFunction(
func.GetName())->ResetBit(TF1::kNotDraw);
687 fitResult.first =
func.GetParameter(1);
688 fitResult.second =
func.GetParameter(2);
692 edm::LogWarning(
"Alignment") <<
"@SUB=TrackerOfflineValidation::fitResiduals" 693 <<
"Caught this exception during ROOT fit: " <<
e.what();
703 double*
x =
new double[
nbins];
704 double*
y =
new double[
nbins];
726 std::map<std::string, std::string>* substructureName =
nullptr;
727 tree.SetBranchAddress(
"TkOffTreeVariables", &treeMemPtr);
728 tree.SetBranchAddress(
"SubstructureName", &substructureName);
731 for (
unsigned int iSubdet = 1; iSubdet < 7; ++iSubdet) {
734 std::vector<unsigned int> treeEntries;
735 for (
unsigned int iSide = 1; iSide < 3; ++iSide) {
740 for (
int iTree = 0; iTree <
tree.GetEntries(); ++iTree) {
741 tree.GetEntry(iTree);
745 if (treeMemPtr->
subDetId == iSubdet) {
749 treeEntries.push_back(iTree);
750 if (hierarchyName.length() == 0) {
751 hierarchyName = (*substructureName)[
"subdet"];
752 componentName = (*substructureName)[
"component"];
772 edm::LogInfo(
"TrackerOfflineValidationSummary") <<
"Harvesting histograms will be booked for " 777 std::stringstream dmrXprimeHistoName, dmrYprimeHistoName, dmrXprimeHistoTitle, dmrYprimeHistoTitle;
778 dmrXprimeHistoName <<
"h_DmrXprime_" << iHier->hierarchyName;
779 dmrYprimeHistoName <<
"h_DmrYprime_" << iHier->hierarchyName;
780 dmrXprimeHistoTitle <<
"DMR for " << iHier->hierarchyName <<
";<#DeltaX> [cm];# modules";
781 dmrYprimeHistoTitle <<
"DMR for " << iHier->hierarchyName <<
";<#DeltaY> [cm];# modules";
784 if (directoryString.length() != 0)
785 directoryString +=
"/";
786 directoryString += iHier->componentName;
791 if (iHier->componentName ==
"Pixel") {
793 iHier->harvestingHistos.DmrXprime =
794 dbe_->
book1D(dmrXprimeHistoName.str(), dmrXprimeHistoTitle.str(), nBinsX,
xMin,
xMax)->getTH1();
796 iHier->harvestingHistos.DmrYprime =
797 dbe_->
book1D(dmrYprimeHistoName.str(), dmrYprimeHistoTitle.str(), nBinsX,
xMin,
xMax)->getTH1();
798 }
else if (iHier->componentName ==
"Strip") {
800 iHier->harvestingHistos.DmrXprime =
801 dbe_->
book1D(dmrXprimeHistoName.str(), dmrXprimeHistoTitle.str(), nBinsX,
xMin,
xMax)->getTH1();
805 iHier->harvestingHistos.DmrYprime =
806 dbe_->
book1D(dmrYprimeHistoName.str(), dmrYprimeHistoTitle.str(), nBinsX,
xMin,
xMax)->getTH1();
814 double& upperBoundX)
const {
823 std::map<std::string, std::string>* substructureName =
nullptr;
824 tree.SetBranchAddress(
"TkOffTreeVariables", &treeMemPtr);
825 tree.SetBranchAddress(
"SubstructureName", &substructureName);
827 const unsigned int minEntriesPerModule(
parSet_.
getParameter<
unsigned int>(
"minEntriesPerModuleForDmr"));
829 <<
"Median of a module is added to DMR plots if it contains at least " << minEntriesPerModule <<
" hits";
834 for (std::vector<unsigned int>::const_iterator iTreeEntries = iHier->treeEntries.begin();
835 iTreeEntries != iHier->treeEntries.end();
837 tree.GetEntry(*iTreeEntries);
838 if (treeMemPtr->
entries < minEntriesPerModule)
840 iHier->harvestingHistos.DmrXprime->Fill(treeMemPtr->
medianX);
841 if (iHier->harvestingHistos.DmrYprime)
842 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
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)
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
#define DEFINE_FWK_MODULE(type)
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
dqm::legacy::DQMStore * dbe_
std::vector< HarvestingHierarchy > vHarvestingHierarchy_
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
constexpr Detector det() const
get the detector field from this detid
unsigned int tecRing(const DetId &id) const
ring id
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mTibResiduals_
bool tobIsDoubleSide(const DetId &id) const
constexpr std::array< uint8_t, layerIndexSize > layer
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
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool getData(T &iHolder) const
static constexpr auto TOB
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
constexpr uint32_t rawId() const
get the raw id
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()
~TrackerOfflineValidationSummary() override
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
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)