120 sumNormXResiduals_(), summaryNormXResiduals_(),
121 sumYResiduals_(), summaryYResiduals_(),
122 sumNormYResiduals_(), summaryNormYResiduals_(),
123 sumResXvsXProfile_(), sumResXvsYProfile_(),
124 sumResYvsXProfile_(), sumResYvsYProfile_() {}
148 if (newDir.length()!=0){
150 else directoryString = newDir;
156 if (newDir.length()==0) tfd.reset(&(*upDir.
tfd));
171 if (newDir.length()==0){
176 directoryString=newDir;
180 if (newDir.length()!=0){
181 if(basedir.length()!=0)directoryString=basedir+
"/"+newDir;
182 else directoryString = newDir;
189 template <
typename T> TH1*
make(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX);
190 template <
typename T> TH1*
make(
const char* name,
const char* title,
int nBinX,
double *xBins);
191 template <
typename T> TH1*
make(
const char* name,
const char* title,
int nBinX,
double minBinX,
double maxBinX,
int nBinY,
double minBinY,
double maxBinY);
192 template <
typename T> TH1*
make(
const char* name,
const char* title,
int nBinX,
double minBinX,
double maxBinX,
double minBinY,
double maxBinY);
194 std::unique_ptr<TFileDirectory>
tfd;
214 std::vector<TrackerOfflineValidation::SummaryContainer>& vLevelProfiles);
217 void setUpTreeMembers(
const std::map<int, TrackerOfflineValidation::ModuleHistos>& moduleHist_,
233 int nBinsX,
double lowX,
double highX);
236 int nBinsX,
double lowX,
double highX);
239 int nBinsX,
double lowX,
double highX,
double lowY,
double highY);
242 int& nBinsX,
double& lowerBoundX,
double& upperBoundX);
257 template <
class OBJECT_TYPE>
int GetIndex(
const std::vector<OBJECT_TYPE*>& vec,
const TString&
name);
324 template <
class OBJECT_TYPE>
328 for (
typename std::vector<OBJECT_TYPE*>::const_iterator iter = vec.begin(), iterEnd = vec.end();
329 iter != iterEnd; ++iter, ++
result) {
330 if (*iter && (*iter)->GetName() ==
name)
return result;
332 edm::LogError(
"Alignment") <<
"@SUB=TrackerOfflineValidation::GetIndex" <<
" could not find " <<
name;
337 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TH1F>(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX){
338 if(dqmMode){theDbe->setCurrentFolder(directoryString);
return theDbe->book1D(
name,
title,
nBinX,minBinX,maxBinX)->getTH1();}
342 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TProfile>(
const char*
name,
const char*
title,
int nBinX,
double *xBins){
344 theDbe->setCurrentFolder(directoryString);
347 tmpProfile->SetDirectory(
nullptr);
348 return theDbe->bookProfile(
name,tmpProfile)->getTH1();
353 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TProfile>(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX){
355 theDbe->setCurrentFolder(directoryString);
357 TProfile *tmpProfile=
new TProfile(
name,
title,
nBinX,minBinX,maxBinX);
358 tmpProfile->SetDirectory(
nullptr);
359 return theDbe->bookProfile(
name,tmpProfile)->getTH1();
361 else{
return tfd->make<TProfile>(
name,
title,
nBinX,minBinX,maxBinX);}
364 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TProfile>(
const char*
name ,
const char*
title,
int nbinX,
double minX ,
double maxX,
double minY,
double maxY){
366 theDbe->setCurrentFolder(directoryString);
368 return (theDbe->bookProfile(
name,
title,nbinX,minX,maxX,dummy,minY,maxY)->getTH1());
371 return tfd->make<TProfile>(
name,
title,nbinX,minX,maxX,minY,maxY);
375 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TH2F>(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX,
int nBinY,
double minBinY,
double maxBinY){
376 if(dqmMode){theDbe->setCurrentFolder(directoryString);
return theDbe->book2D(
name,
title,
nBinX,minBinX,maxBinX,
nBinY,minBinY,maxBinY)->getTH1();}
435 edm::LogInfo(
"TrackerOfflineValidation") <<
"There are " << newBareTkGeomPtr->
detIds().size()
436 <<
" dets in the Geometry record.\n" 437 <<
"Out of these "<<newBareTkGeomPtr->
detUnitIds().size()
449 std::vector<TrackerOfflineValidation::SummaryContainer> vTrackerprofiles;
461 <<
"TrackerGeometry changed, but will not re-book hists!";
472 "Track #eta;#eta_{Track};Number of Tracks",
475 "Track #phi;#phi_{Track};Number of Tracks",
478 "Track # of valid hits;# of valid hits _{Track};Number of Tracks",
481 "Track # of lost hits;# of lost hits _{Track};Number of Tracks",
484 "Curvature #kappa;#kappa_{Track};Number of Tracks",
487 "Curvature |#kappa| Positive Tracks;|#kappa_{pos Track}|;Number of Tracks",
490 "Curvature |#kappa| Negative Tracks;|#kappa_{neg Track}|;Number of Tracks",
493 "Curvature |#kappa| Tracks Difference;|#kappa_{Track}|;# Pos Tracks - # Neg Tracks",
496 "#chi^{2};#chi^{2}_{Track};Number of Tracks",
499 "#chi^{2} probability;#chi^{2}prob_{Track};Number of Tracks",
502 "#chi^{2}/ndof;#chi^{2}/ndof;Number of Tracks",
505 "p_{T}^{track};p_{T}^{track} [GeV];Number of Tracks",
508 "#delta_{p_{T}}/p_{T}^{track};#delta_{p_{T}}/p_{T}^{track};Number of Tracks",
511 "Transverse Impact Parameter vs. #phi;#phi_{Track};#LT d_{0} #GT [cm]",
514 "Longitudinal Impact Parameter vs. #phi;#phi_{Track};#LT d_{z} #GT [cm]",
517 "Transverse Impact Parameter vs. #eta;#eta_{Track};#LT d_{0} #GT [cm]",
520 "Longitudinal Impact Parameter vs. #eta;#eta_{Track};#LT d_{z} #GT [cm]",
523 "#chi^{2} vs. #phi;#phi_{Track};#LT #chi^{2} #GT",
526 "#chi^{2} probablility vs. #phi;#phi_{Track};#LT #chi^{2} probability#GT",
529 "#chi^{2} probablility vs. |d_{0}|;|d_{0}|[cm];#LT #chi^{2} probability#GT",
532 "#chi^{2}/ndof vs. #phi;#phi_{Track};#LT #chi^{2}/ndof #GT",
535 "#chi^{2} vs. #eta;#eta_{Track};#LT #chi^{2} #GT",
538 double xBins[19]={0.,0.15,0.5,1.,1.5,2.,2.5,3.,3.5,4.,4.5,5.,7.,10.,15.,25.,40.,100.,200.};
540 "norm #chi^{2} vs. p_{T}_{Track}; p_{T}_{Track};#LT #chi^{2}/ndof #GT",
544 "#chi^{2}/ndof vs. p_{Track};p_{Track};#LT #chi^{2}/ndof #GT",
547 "#chi^{2} probability vs. #eta;#eta_{Track};#LT #chi^{2} probability #GT",
550 "#chi^{2}/ndof vs. #eta;#eta_{Track};#LT #chi^{2}/ndof #GT",
553 "#kappa vs. #phi;#phi_{Track};#kappa",
556 "#kappa vs. #eta;#eta_{Track};#kappa",
559 "#delta_{p_{T}}/p_{T}^{track};#phi^{track};#delta_{p_{T}}/p_{T}^{track}",
562 "#delta_{p_{T}}/p_{T}^{track};#eta^{track};#delta_{p_{T}}/p_{T}^{track}",
566 "Transverse Impact Parameter vs. #phi;#phi_{Track};d_{0} [cm]",
567 100, -3.15, 3.15, 100,-1.,1.) );
569 "Longitudinal Impact Parameter vs. #phi;#phi_{Track};d_{z} [cm]",
570 100, -3.15, 3.15, 100,-100.,100.));
572 "Transverse Impact Parameter vs. #eta;#eta_{Track};d_{0} [cm]",
573 100, -3.15, 3.15, 100,-1.,1.));
575 "Longitudinal Impact Parameter vs. #eta;#eta_{Track};d_{z} [cm]",
576 100, -3.15, 3.15, 100,-100.,100.));
578 "#chi^{2} vs. #phi;#phi_{Track};#chi^{2}",
579 100, -3.15, 3.15, 500, 0., 500.));
581 "#chi^{2} probability vs. #phi;#phi_{Track};#chi^{2} probability",
582 100, -3.15, 3.15, 100, 0., 1.));
584 "#chi^{2} probability vs. |d_{0}|;|d_{0}| [cm];#chi^{2} probability",
585 100, 0, 80, 100, 0., 1.));
587 "#chi^{2}/ndof vs. #phi;#phi_{Track};#chi^{2}/ndof",
588 100, -3.15, 3.15, 100, 0., 10.));
590 "#chi^{2} vs. #eta;#eta_{Track};#chi^{2}",
591 100, -3.15, 3.15, 500, 0., 500.));
593 "#chi^{2} probaility vs. #eta;#eta_{Track};#chi^{2} probability",
594 100, -3.15, 3.15, 100, 0., 1.));
596 "#chi^{2}/ndof vs. #eta;#eta_{Track};#chi^{2}/ndof",
597 100,-3.15,3.15, 100, 0., 10.));
599 "#kappa vs. #phi;#phi_{Track};#kappa",
600 100,-3.15,3.15, 100, .0,.05));
602 "#kappa vs. #eta;#eta_{Track};#kappa",
603 100,-3.15,3.15, 100, .0,.05));
605 "#kappa vs. #chi^{2}/ndof;#chi^{2}/ndof;#kappa",
606 100,0.,10, 100,-.03,.03));
610 "res_{x'} vs momentum in BPix;p [GeV]; res_{x'}",
611 15,0.,15., 200, -0.1,0.1));
613 "res_{x'} vs momentum in FPix;p [GeV]; res_{x'}",
614 15,0.,15., 200, -0.1,0.1));
616 "res_{x'} vs momentum in TIB;p [GeV]; res_{x'}",
617 15,0.,15., 200, -0.1,0.1));
619 "res_{x'} vs momentum in TID;p [GeV]; res_{x'}",
620 15,0.,15., 200, -0.1,0.1));
622 "res_{x'} vs momentum in TOB;p [GeV]; res_{x'}",
623 15,0.,15., 200, -0.1,0.1));
625 "res_{x'} vs momentum in TEC;p [GeV]; res_{x'}",
626 15,0.,15., 200, -0.1,0.1));
630 "res_{y'} vs momentum in BPix;p [GeV]; res_{y'}",
631 15,0.,15., 200, -0.1,0.1));
633 "res_{y'} vs momentum in FPix;p [GeV]; res_{y'}",
634 15,0.,15., 200, -0.1,0.1));
645 LogDebug(
"TrackerOfflineValidation") <<
"StructureName = " << structurename;
647 dirname << structurename;
649 if (structurename !=
"Strip" && structurename !=
"Pixel") dirname <<
"_" <<
i+1;
651 if (structurename.find(
"Endcap",0) != std::string::npos ) {
655 }
else if( !(this->
isDetOrDetUnit( (alivec)[i]->alignableObjectId()) )
685 std::stringstream histoname, histotitle, normhistoname, normhistotitle,
686 yhistoname, yhistotitle,
687 xprimehistoname, xprimehistotitle, normxprimehistoname, normxprimehistotitle,
688 yprimehistoname, yprimehistotitle, normyprimehistoname, normyprimehistotitle,
689 localxname, localxtitle, localyname, localytitle,
690 resxvsxprofilename, resxvsxprofiletitle, resyvsxprofilename, resyvsxprofiletitle,
691 resxvsyprofilename, resxvsyprofiletitle, resyvsyprofilename, resyvsyprofiletitle;
695 if( this->
isEndCap(static_cast<uint32_t>(subdetandlayer.first)) ) wheel_or_layer =
"_wheel_";
696 else if ( this->
isBarrel(static_cast<uint32_t>(subdetandlayer.first)) ) wheel_or_layer =
"_layer_";
697 else edm::LogWarning(
"TrackerOfflineValidation") <<
"@SUB=TrackerOfflineValidation::bookHists" 698 <<
"Unknown subdetid: " << subdetandlayer.first;
700 histoname <<
"h_residuals_subdet_" << subdetandlayer.first
701 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
702 yhistoname <<
"h_y_residuals_subdet_" << subdetandlayer.first
703 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
704 xprimehistoname <<
"h_xprime_residuals_subdet_" << subdetandlayer.first
705 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
706 yprimehistoname <<
"h_yprime_residuals_subdet_" << subdetandlayer.first
707 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
708 normhistoname <<
"h_normresiduals_subdet_" << subdetandlayer.first
709 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
710 normxprimehistoname <<
"h_normxprimeresiduals_subdet_" << subdetandlayer.first
711 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
712 normyprimehistoname <<
"h_normyprimeresiduals_subdet_" << subdetandlayer.first
713 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
714 histotitle <<
"X Residual for module " <<
id.rawId() <<
";x_{tr} - x_{hit} [cm]";
715 yhistotitle <<
"Y Residual for module " <<
id.rawId() <<
";y_{tr} - y_{hit} [cm]";
716 normhistotitle <<
"Normalized Residual for module " <<
id.rawId() <<
";x_{tr} - x_{hit}/#sigma";
717 xprimehistotitle <<
"X' Residual for module " <<
id.rawId() <<
";(x_{tr} - x_{hit})' [cm]";
718 normxprimehistotitle <<
"Normalized X' Residual for module " <<
id.rawId() <<
";(x_{tr} - x_{hit})'/#sigma";
719 yprimehistotitle <<
"Y' Residual for module " <<
id.rawId() <<
";(y_{tr} - y_{hit})' [cm]";
720 normyprimehistotitle <<
"Normalized Y' Residual for module " <<
id.rawId() <<
";(y_{tr} - y_{hit})'/#sigma";
723 localxname <<
"h_localx_subdet_" << subdetandlayer.first
724 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
725 localyname <<
"h_localy_subdet_" << subdetandlayer.first
726 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
727 localxtitle <<
"u local for module " <<
id.rawId() <<
"; u_{tr,r}";
728 localytitle <<
"v local for module " <<
id.rawId() <<
"; v_{tr,r}";
730 resxvsxprofilename <<
"p_residuals_x_vs_x_subdet_" << subdetandlayer.first
731 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
732 resyvsxprofilename <<
"p_residuals_y_vs_x_subdet_" << subdetandlayer.first
733 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
734 resxvsyprofilename <<
"p_residuals_x_vs_y_subdet_" << subdetandlayer.first
735 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
736 resyvsyprofilename <<
"p_residuals_y_vs_y_subdet_" << subdetandlayer.first
737 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
738 resxvsxprofiletitle <<
"U Residual vs u for module " <<
id.rawId() <<
"; u_{tr,r} ;(u_{tr} - u_{hit})/tan#alpha [cm]";
739 resyvsxprofiletitle <<
"V Residual vs u for module " <<
id.rawId() <<
"; u_{tr,r} ;(v_{tr} - v_{hit})/tan#beta [cm]";
740 resxvsyprofiletitle <<
"U Residual vs v for module " <<
id.rawId() <<
"; v_{tr,r} ;(u_{tr} - u_{hit})/tan#alpha [cm]";
741 resyvsyprofiletitle <<
"V Residual vs v for module " <<
id.rawId() <<
"; v_{tr,r} ;(v_{tr} - v_{hit})/tan#beta [cm]";
752 if (
dqmMode_) moduleLevelHistsTransient =
false;
758 histoname.str().c_str(),histotitle.str().c_str(),
762 normhistoname.str().c_str(),normhistotitle.str().c_str(),
767 xprimehistoname.str().c_str(),xprimehistotitle.str().c_str(),
771 normxprimehistoname.str().c_str(),normxprimehistotitle.str().c_str(),
777 histStruct.
LocalX = this->
bookTH1F(moduleLevelHistsTransient, tfd,
778 localxname.str().c_str(),localxtitle.str().c_str(),
780 histStruct.
LocalY = this->
bookTH1F(moduleLevelHistsTransient, tfd,
781 localyname.str().c_str(),localytitle.str().c_str(),
784 resxvsxprofilename.str().c_str(),resxvsxprofiletitle.str().c_str(),
788 resxvsyprofilename.str().c_str(),resxvsyprofiletitle.str().c_str(),
796 yprimehistoname.str().c_str(),yprimehistotitle.str().c_str(),
801 yhistoname.str().c_str(), yhistotitle.str().c_str(),
806 normyprimehistoname.str().c_str(),normyprimehistotitle.str().c_str(),
813 resyvsxprofilename.str().c_str(),resyvsxprofiletitle.str().c_str(),
817 resyvsyprofilename.str().c_str(),resyvsyprofiletitle.str().c_str(),
827 int nBinsX,
double lowX,
double highX)
830 vDeleteObjects_.push_back(
new TH1F(histName, histTitle, nBinsX, lowX, highX));
834 return tfd.
make<TH1F>(histName, histTitle, nBinsX, lowX, highX);
838 int nBinsX,
double lowX,
double highX)
841 TProfile *
profile =
new TProfile(histName, histTitle, nBinsX, lowX, highX);
846 return (TProfile*)tfd.
make<TProfile>(histName, histTitle, nBinsX, lowX, highX);
851 int nBinsX,
double lowX,
double highX,
double lowY,
double highY)
854 TProfile *
profile =
new TProfile(histName, histTitle, nBinsX, lowX, highX, lowY, highY);
859 return (TProfile*)tfd.
make<TProfile>(histName, histTitle, nBinsX, lowX, highX, lowY, highY);
895 int& nBinsX,
double& lowerBoundX,
double& upperBoundX)
948 if(targetHist && sourceHist) {
949 targetHist->SetBinContent(bin, sourceHist->GetMean(1));
950 if(
useFwhm_) targetHist->SetBinError(bin,
Fwhm(sourceHist)/2.);
951 else targetHist->SetBinError(bin, sourceHist->GetRMS(1) );
1005 <<
"[TrackerOfflineValidation] Error, tried to get reference for non-tracker subdet " << subdetid
1006 <<
" from detector " << detid.
det();
1022 std::vector<TrackerValidationVariables::AVTrackStruct> vTrackstruct;
1025 for (std::vector<TrackerValidationVariables::AVTrackStruct>::const_iterator itT = vTrackstruct.begin();
1026 itT != vTrackstruct.end();
1038 vTrackHistos_[numOfValidHitsindex]->Fill(itT->numberOfValidHits);
1040 vTrackHistos_[numOfLostHitsindex]->Fill(itT->numberOfLostHits);
1044 if (itT->charge > 0)
1047 if (itT->charge < 0)
1057 if (itT->ptError != 0.) {
1059 vTrackHistos_[ptResolutionindex]->Fill(itT->ptError/itT->pt);
1075 vTrackProfiles_[chiProbabsd0index]->Fill(fabs(itT->d0),itT->chi2Prob);
1111 vTrack2DHistos_[chiProbabsd0index_2d]->Fill(fabs(itT->d0),itT->chi2Prob);
1128 for (std::vector<TrackerValidationVariables::AVHitStruct>::const_iterator itH = itT->hits.begin();
1129 itH != itT->hits.end();
1132 DetId detid(itH->rawDetId);
1137 histStruct.
ResHisto->Fill(itH->resX);
1138 if(itH->resErrX != 0) histStruct.
NormResHisto->Fill(itH->resX/itH->resErrX);
1144 if (itH->resXprime != -999.) {
1175 float tgalpha =
tan(itH->localAlpha);
1176 if ( fabs(tgalpha)!=0 ){
1177 histStruct.
LocalX->Fill(itH->localXnorm, tgalpha*tgalpha);
1178 histStruct.
LocalY->Fill(itH->localYnorm, tgalpha*tgalpha);
1190 histStruct.
ResXvsXProfile->Fill(itH->localXnorm, itH->resXatTrkY/tgalpha, tgalpha*tgalpha);
1191 histStruct.
ResXvsYProfile->Fill(itH->localYnorm, itH->resXatTrkY/tgalpha, tgalpha*tgalpha);
1198 if(itH->resXprimeErr != 0 && itH->resXprimeErr != -999 ) {
1203 if (itH->resYprime != -999.) {
1219 float tgbeta =
tan(itH->localBeta);
1220 if ( fabs(tgbeta)!=0 ){
1233 histStruct.
ResYvsXProfile->Fill(itH->localXnorm, itH->resY/tgbeta, tgbeta*tgbeta);
1234 histStruct.
ResYvsYProfile->Fill(itH->localYnorm, itH->resY/tgbeta, tgbeta*tgbeta);
1239 if (itH->resYprimeErr != 0 && itH->resYprimeErr != -999. ) {
1271 TTree *
tree = fs->
make<TTree>(
"TkOffVal",
"TkOffVal");
1277 tree->Branch(
"TkOffTreeVariables", &treeMemPtr);
1286 delete treeMemPtr; treeMemPtr =
nullptr;
1292 std::vector<TrackerOfflineValidation::SummaryContainer>& vLevelProfiles)
1295 if( this->
isDetOrDetUnit((alivec)[0]->alignableObjectId()) )
return;
1297 for(
int iComp=0, iCompEnd = ali.
components().size();iComp < iCompEnd; ++iComp) {
1298 std::vector< TrackerOfflineValidation::SummaryContainer > vProfiles;
1301 LogDebug(
"TrackerOfflineValidation") <<
"StructureName = " << structurename;
1303 dirname << structurename;
1306 if (structurename !=
"Strip" && structurename !=
"Pixel") dirname <<
"_" << iComp+1;
1308 if( !(this->
isDetOrDetUnit( (alivec)[iComp]->alignableObjectId()) )
1313 TH1 *hX = vLevelProfiles[iComp].sumXResiduals_;
1314 TH1 *hNormX = vLevelProfiles[iComp].sumNormXResiduals_;
1315 TH1 *hY = vLevelProfiles[iComp].sumYResiduals_;
1316 TH1 *hNormY = vLevelProfiles[iComp].sumNormYResiduals_;
1317 TH1 *pXX = vLevelProfiles[iComp].sumResXvsXProfile_;
1318 TH1 *pXY = vLevelProfiles[iComp].sumResXvsYProfile_;
1319 TH1 *pYX = vLevelProfiles[iComp].sumResYvsXProfile_;
1320 TH1 *pYY = vLevelProfiles[iComp].sumResYvsYProfile_;
1321 for(
uint n = 0;
n < vProfiles.size(); ++
n) {
1326 if (hNormY)
sumHistStructure_.emplace_back(hNormY, vProfiles[n].sumNormYResiduals_);
1334 toFit_.push_back(vLevelProfiles[iComp].sumXResiduals_);
1335 toFit_.push_back(vLevelProfiles[iComp].sumNormXResiduals_);
1336 if (hY)
toFit_.push_back(hY);
1337 if (hNormY)
toFit_.push_back(hNormY);
1348 for (std::vector<std::pair<TH1*,TH1*> >::const_iterator it =
sumHistStructure_.begin();
1351 it->first->Add(it->second);
1353 for (std::vector<std::tuple<int,TH1*,TH1*> >::const_iterator it =
summaryBins_.begin();
1356 setSummaryBin(std::get<0>(*it), std::get<1>(*it), std::get<2>(*it));
1358 for (std::vector<TH1*>::const_iterator it =
toFit_.begin();
1372 const char *aliTypeName =
alignableTracker_->objectIdProvider().idToString(alitype);
1373 const char *aliSubtypeName =
alignableTracker_->objectIdProvider().idToString(subtype);
1376 const DetId aliDetId = ali.
id();
1386 const uint subcompSize = ali.
components()[0]->components().size();
1388 const TString
title(Form(
"Summary for substructures in %s %d;%s;",aliTypeName,i,aliSubtypeName));
1390 sumContainer.summaryXResiduals_ = tfd.
make<TH1F>(Form(
"h_summaryX%s_%d",aliTypeName,i),
1391 title +
"#LT #Delta x' #GT",
1392 aliSize, 0.5, aliSize+0.5);
1393 sumContainer.summaryNormXResiduals_ = tfd.
make<TH1F>(Form(
"h_summaryNormX%s_%d",aliTypeName,i),
1394 title +
"#LT #Delta x'/#sigma #GT",
1395 aliSize,0.5,aliSize+0.5);
1398 sumContainer.summaryYResiduals_ = tfd.
make<TH1F>(Form(
"h_summaryY%s_%d",aliTypeName,i),
1399 title +
"#LT #Delta y' #GT",
1400 aliSize, 0.5, aliSize+0.5);
1401 sumContainer.summaryNormYResiduals_ = tfd.
make<TH1F>(Form(
"h_summaryNormY%s_%d",aliTypeName,i),
1402 title +
"#LT #Delta y'/#sigma #GT",
1403 aliSize,0.5,aliSize+0.5);
1407 if (subcompSize != 2) {
1410 <<
"Det with " << subcompSize <<
" components";
1413 const TString
title(Form(
"Summary for substructures in %s %d;%s;", aliTypeName, i,
1416 sumContainer.summaryXResiduals_
1417 = tfd.
make<TH1F>(Form(
"h_summaryX%s_%d", aliTypeName, i),
1418 title +
"#LT #Delta x' #GT", (2*aliSize), 0.5, 2*aliSize+0.5);
1419 sumContainer.summaryNormXResiduals_
1420 = tfd.
make<TH1F>(Form(
"h_summaryNormX%s_%d", aliTypeName, i),
1421 title +
"#LT #Delta x'/#sigma #GT", (2*aliSize), 0.5, 2*aliSize+0.5);
1424 sumContainer.summaryYResiduals_
1425 = tfd.
make<TH1F>(Form(
"h_summaryY%s_%d", aliTypeName, i),
1426 title +
"#LT #Delta y' #GT", (2*aliSize), 0.5, 2*aliSize+0.5);
1427 sumContainer.summaryNormYResiduals_
1428 = tfd.
make<TH1F>(Form(
"h_summaryNormY%s_%d", aliTypeName, i),
1429 title +
"#LT #Delta y'/#sigma #GT", (2*aliSize), 0.5, 2*aliSize+0.5);
1433 edm::LogError(
"TrackerOfflineValidation") <<
"@SUB=TrackerOfflineValidation::bookSummaryHists" 1434 <<
"No summary histogram for hierarchy level " 1435 << aliTypeName <<
" in subdet " << aliDetId.
subdetId();
1443 const TString sumTitle(Form(
"Residual for %s %d in %s;", aliTypeName, i, typeName));
1447 sumContainer.sumXResiduals_ = tfd.
make<TH1F>(Form(
"h_Xprime_%s_%d", aliTypeName, i),
1452 sumContainer.sumNormXResiduals_ = tfd.
make<TH1F>(Form(
"h_NormXprime_%s_%d",aliTypeName,i),
1458 sumContainer.sumResXvsXProfile_ = tfd.
make<TProfile>(Form(
"p_resXX_%s_%d",aliTypeName,i),
1462 sumContainer.sumResXvsXProfile_->Sumw2();
1463 sumContainer.sumResXvsYProfile_ = tfd.
make<TProfile>(Form(
"p_resXY_%s_%d",aliTypeName,i),
1467 sumContainer.sumResXvsYProfile_->Sumw2();
1472 sumContainer.sumYResiduals_ = tfd.
make<TH1F>(Form(
"h_Yprime_%s_%d",aliTypeName,i),
1477 sumContainer.sumNormYResiduals_ = tfd.
make<TH1F>(Form(
"h_NormYprime_%s_%d",aliTypeName,i),
1483 sumContainer.sumResYvsXProfile_ = tfd.
make<TProfile>(Form(
"p_resYX_%s_%d",aliTypeName,i),
1487 sumContainer.sumResYvsXProfile_->Sumw2();
1488 sumContainer.sumResYvsYProfile_ = tfd.
make<TProfile>(Form(
"p_resYY_%s_%d",aliTypeName,i),
1492 sumContainer.sumResYvsYProfile_->Sumw2();
1500 for(
uint k = 0;
k < aliSize; ++
k) {
1521 for(
uint k = 0;
k < aliSize; ++
k) {
1522 for(
uint j = 0; j < subcompSize; ++j) {
1543 return sumContainer;
1550 float max = hist->GetMaximum();
1551 int left = -1, right = -1;
1552 for(
unsigned int i = 1, iEnd = hist->GetNbinsX();
i <= iEnd; ++
i) {
1553 if(hist->GetBinContent(
i) < max/2. && hist->GetBinContent(
i+1) > max/2. && left == -1) {
1554 if(max/2. - hist->GetBinContent(
i) < hist->GetBinContent(
i+1) - max/2.) {
1562 if(left != -1 && right == -1) {
1563 if(hist->GetBinContent(
i) > max/2. && hist->GetBinContent(
i+1) < max/2.) {
1564 if( hist->GetBinContent(
i) - max/2. < max/2. - hist->GetBinContent(
i+1)) {
1573 return hist->GetXaxis()->GetBinCenter(right) - hist->GetXaxis()->GetBinCenter(left);
1582 for(std::map<int, TrackerOfflineValidation::ModuleHistos>::const_iterator it = moduleHist_.begin(),
1583 itEnd= moduleHist_.end(); it != itEnd;++it ) {
1587 DetId detId_ = it->first;
1593 unsigned int whichHalfBarrel(1), rawId(detId_.
rawId());
1594 if( (rawId>=302056964 && rawId<302059300) || (rawId>=302123268 && rawId<302127140) ||
1595 (rawId>=302189572 && rawId<302194980) ) whichHalfBarrel=2;
1597 treeMem.
half = whichHalfBarrel;
1601 unsigned int whichHalfCylinder(1), rawId(detId_.
rawId());
1602 if( (rawId>=352394500 && rawId<352406032) || (rawId>=352460036 && rawId<352471568) ||
1603 (rawId>=344005892 && rawId<344017424) || (rawId>=344071428 && rawId<344082960) ) whichHalfCylinder=2;
1606 treeMem.
half = whichHalfCylinder;
1611 unsigned int whichHalfShell(1), rawId(detId_.
rawId());
1612 if ( (rawId>=369120484 && rawId<369120688) || (rawId>=369121540 && rawId<369121776) ||
1613 (rawId>=369136932 && rawId<369137200) || (rawId>=369137988 && rawId<369138288) ||
1614 (rawId>=369153396 && rawId<369153744) || (rawId>=369154436 && rawId<369154800) ||
1615 (rawId>=369169844 && rawId<369170256) || (rawId>=369170900 && rawId<369171344) ||
1616 (rawId>=369124580 && rawId<369124784) || (rawId>=369125636 && rawId<369125872) ||
1617 (rawId>=369141028 && rawId<369141296) || (rawId>=369142084 && rawId<369142384) ||
1618 (rawId>=369157492 && rawId<369157840) || (rawId>=369158532 && rawId<369158896) ||
1619 (rawId>=369173940 && rawId<369174352) || (rawId>=369174996 && rawId<369175440) ) whichHalfShell=2;
1622 treeMem.
half = whichHalfShell;
1659 treeMem.
posX = gPModule.
x();
1660 treeMem.
posY = gPModule.
y();
1661 treeMem.
posZ = gPModule.
z();
1666 LocalPoint lUDirection(1.,0.,0.), lVDirection(0.,1.,0.), lWDirection(0.,0.,1.);
1668 gVDirection = surface.
toGlobal(lVDirection),
1669 gWDirection = surface.
toGlobal(lWDirection);
1670 double dR(999.),
dPhi(999.), dZ(999.);
1672 dR = gWDirection.perp() - gPModule.
perp();
1674 dZ = gVDirection.z() - gPModule.
z();
1677 dR = gUDirection.
perp() - gPModule.
perp();
1679 dZ = gWDirection.z() - gPModule.
z();
1682 dR = gVDirection.perp() - gPModule.
perp();
1684 dZ = gWDirection.z() - gPModule.
z();
1695 const std::map<int, TrackerOfflineValidation::ModuleHistos>& moduleHist_)
1697 for(std::map<int, TrackerOfflineValidation::ModuleHistos>::const_iterator it = moduleHist_.begin(),
1698 itEnd= moduleHist_.end(); it != itEnd;++it ) {
1702 treeMem.
entries =
static_cast<UInt_t
>(it->second.ResXprimeHisto->GetEntries());
1703 treeMem.
meanX = it->second.ResXprimeHisto->GetMean();
1704 treeMem.
rmsX = it->second.ResXprimeHisto->GetRMS();
1710 std::pair<float,float> fitResult1 = this->
fitResiduals(it->second.ResXprimeHisto);
1711 treeMem.
fitMeanX = fitResult1.first;
1714 std::pair<float,float> fitResult2 = this->
fitResiduals(it->second.NormResXprimeHisto);
1722 int numberOfBins=it->second.ResXprimeHisto->GetNbinsX();
1724 treeMem.
numberOfOverflows = it->second.ResXprimeHisto->GetBinContent(numberOfBins+1);
1725 treeMem.
numberOfOutliers = it->second.ResXprimeHisto->GetBinContent(0)+it->second.ResXprimeHisto->GetBinContent(numberOfBins+1);
1728 treeMem.
meanNormX = it->second.NormResXprimeHisto->GetMean();
1729 treeMem.
rmsNormX = it->second.NormResXprimeHisto->GetRMS();
1732 it->second.NormResXprimeHisto->GetStats(stats);
1734 if (stats[0]) treeMem.
chi2PerDofX = stats[3]/stats[0];
1737 treeMem.
histNameX = it->second.ResXprimeHisto->GetName();
1738 treeMem.
histNameNormX = it->second.NormResXprimeHisto->GetName();
1742 treeMem.
meanLocalX = it->second.ResHisto->GetMean();
1743 treeMem.
rmsLocalX = it->second.ResHisto->GetRMS();
1749 if (it->second.ResYHisto) treeMem.
histNameLocalY = it->second.ResYHisto->GetName();
1754 if (it->second.ResYprimeHisto) {
1755 TH1 *
h = it->second.ResYprimeHisto;
1756 treeMem.
meanY = h->GetMean();
1757 treeMem.
rmsY = h->GetRMS();
1760 std::pair<float,float> fitMeanSigma = this->
fitResiduals(h);
1761 treeMem.
fitMeanY = fitMeanSigma.first;
1762 treeMem.
fitSigmaY = fitMeanSigma.second;
1770 if (it->second.NormResYprimeHisto) {
1771 TH1 *
h = it->second.NormResYprimeHisto;
1775 if (stats[0]) treeMem.
chi2PerDofY = stats[3]/stats[0];
1778 std::pair<float,float> fitMeanSigma = this->
fitResiduals(h);
1786 if (it->second.ResXvsXProfile) {
1787 TH1 *
h = it->second.ResXvsXProfile;
1792 if (it->second.ResXvsYProfile) {
1793 TH1 *
h = it->second.ResXvsYProfile;
1798 if (it->second.ResYvsXProfile) {
1799 TH1 *
h = it->second.ResYvsXProfile;
1804 if (it->second.ResYvsYProfile) {
1805 TH1 *
h = it->second.ResYvsYProfile;
1817 std::pair<float,float>
1820 std::pair<float,float> fitResult(9999., 9999.);
1821 if (!hist || hist->GetEntries() < 20)
return fitResult;
1823 float mean = hist->GetMean();
1824 float sigma = hist->GetRMS();
1829 TF1
func(
"tmp",
"gaus", mean - 2.*sigma, mean + 2.*sigma);
1830 if (0 == hist->Fit(&func,
"QNR")) {
1831 mean = func.GetParameter(1);
1832 sigma = func.GetParameter(2);
1834 func.SetRange(mean - 3.*sigma, mean + 3.*sigma);
1837 if (0 == hist->Fit(&func,
"Q0LR")) {
1838 if (hist->GetFunction(func.GetName())) {
1839 hist->GetFunction(func.GetName())->ResetBit(TF1::kNotDraw);
1841 fitResult.first = func.GetParameter(1);
1842 fitResult.second = func.GetParameter(2);
1846 edm::LogWarning(
"Alignment") <<
"@SUB=TrackerOfflineValidation::fitResiduals" 1847 <<
"Caught this exception during ROOT fit: " 1858 int nbins = histo->GetNbinsX();
1861 double *
x =
new double[
nbins];
1862 double *
y =
new double[
nbins];
1863 for (
int j = 0; j <
nbins; j++) {
1864 x[j] = histo->GetBinCenter(j+1);
1865 y[j] = histo->GetBinContent(j+1);
1867 median = TMath::Median(nbins, x, y);
1869 delete[]
x; x =
nullptr;
1870 delete []
y; y =
nullptr;
const TrackerGeometry * bareTkGeomPtr_
const DetIdContainer & detUnitIds() const override
Returm a vector of all GeomDetUnit DetIds.
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
T getParameter(std::string const &) const
align::ID id() const
Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit).
bool tecIsDoubleSide(const DetId &id) const
bool tobIsDoubleSide(const DetId &id) const
std::vector< TH1 * > vDeleteObjects_
std::map< int, TrackerOfflineValidation::ModuleHistos > mPxeResiduals_
std::vector< TH1 * > vTrackHistos_
bool tibIsDoubleSide(const DetId &id) const
unsigned int tibLayer(const DetId &id) const
std::pair< int, int > typeAndLayerFromDetId(const DetId &detId, const TrackerTopology *tTopo) const
unsigned int tidRing(const DetId &id) const
const unsigned long long maxTracks_
TH1 * make(const char *name, const char *title, int nBinX, double minBinX, double maxBinX)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Float_t numberOfOverflows
bool isPixel(uint32_t subDetId)
std::vector< unsigned int > tidModuleInfo(const DetId &id) const
std::vector< TH1 * > vTrack2DHistos_
TH1 * bookTH1F(bool isTransient, DirectoryWrapper &tfd, const char *histName, const char *histTitle, int nBinsX, double lowX, double highX)
std::unique_ptr< AlignableTracker > alignableTracker_
std::map< int, TrackerOfflineValidation::ModuleHistos > mTecResiduals_
std::string directoryString
unsigned int pxfDisk(const DetId &id) const
container to hold data to be written into TTree
moduleLevelHistsTransient
std::string profileNameResXvsX
void fillTree(TTree &tree, TkOffTreeVariables &treeMem, const std::map< int, TrackerOfflineValidation::ModuleHistos > &moduleHist_)
unsigned int tecRing(const DetId &id) const
ring id
const bool stripYResiduals_
const bool useOverflowForRMS_
uint32_t tobStereo(const DetId &id) const
S make(const edm::ParameterSet &cfg)
Geom::Phi< T > phi() const
unsigned int pxbLadder(const DetId &id) const
constexpr uint32_t rawId() const
get the raw id
edm::ESHandle< TrackerGeometry > tkGeom_
int GetIndex(const std::vector< OBJECT_TYPE * > &vec, const TString &name)
def setup(process, global_tag, zero_tesla=False)
unsigned int tidWheel(const DetId &id) const
unsigned int pxbModule(const DetId &id) const
T * make(const Args &...args) const
make new ROOT object
char const * what() const override
virtual const Alignables & components() const =0
Return vector of all direct components.
float getMedian(const TH1 *hist) const
ModuleHistos & getHistStructFromMap(const DetId &detid)
const bool moduleLevelProfiles_
Float_t numberOfUnderflows
void setSummaryBin(int bin, TH1 *targetHist, TH1 *sourceHist)
std::vector< unsigned int > tibStringInfo(const DetId &id) const
std::map< int, TrackerOfflineValidation::ModuleHistos > mTibResiduals_
TrackerOfflineValidation::SummaryContainer bookSummaryHists(DirectoryWrapper &tfd, const Alignable &ali, align::StructureType type, int i)
const Plane & surface() const
The nominal surface of the GeomDet.
std::vector< std::tuple< int, TH1 *, TH1 * > > summaryBins_
TProfile * ResXvsYProfile
TH1 * summaryNormYResiduals_
std::string profileNameResYvsX
std::map< int, TrackerOfflineValidation::ModuleHistos > mTidResiduals_
TProfile * ResYvsYProfile
std::vector< std::pair< TH1 *, TH1 * > > sumHistStructure_
TFileDirectory & tFileDirectory()
unsigned int subDetId[21]
std::vector< unsigned int > tecPetalInfo(const DetId &id) const
#define DEFINE_FWK_MODULE(type)
const Surface::PositionType & position() const
The position (origin of the R.F.)
TH1 * summaryNormXResiduals_
unsigned int tidSide(const DetId &id) const
std::string histNameNormX
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
void setUpTreeMembers(const std::map< int, TrackerOfflineValidation::ModuleHistos > &moduleHist_, const TrackerGeometry &tkgeom, const TrackerTopology *tTopo)
uint32_t tidStereo(const DetId &id) const
std::vector< unsigned int > tobRodInfo(const DetId &id) const
unsigned long long nTracks_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
const DetIdContainer & detIds() const override
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
Tan< T >::type tan(const T &t)
void getBinning(uint32_t subDetId, TrackerOfflineValidation::HistogramType residualtype, int &nBinsX, double &lowerBoundX, double &upperBoundX)
virtual void checkBookHists(const edm::EventSetup &setup)
TProfile * bookTProfile(bool isTransient, DirectoryWrapper &tfd, const char *histName, const char *histTitle, int nBinsX, double lowX, double highX)
void prepareSummaryHists(DirectoryWrapper &tfd, const Alignable &ali, std::vector< TrackerOfflineValidation::SummaryContainer > &vLevelProfiles)
std::string histNameLocalY
std::string histNameNormLocalX
unsigned int tibModule(const DetId &id) const
unsigned int pxfModule(const DetId &id) const
bin
set the eta bin as selection string.
bool isDetOrDetUnit(align::StructureType type)
std::map< int, TrackerOfflineValidation::ModuleHistos > mTobResiduals_
unsigned int pxbLayer(const DetId &id) const
unsigned int tecModule(const DetId &id) const
DirectoryWrapper(const std::string &newDir, const std::string &basedir, bool useDqmMode)
void fillTrackQuantities(const edm::Event &, const edm::EventSetup &, std::vector< AVTrackStruct > &v_avtrackout)
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
const std::string moduleDirectory_
std::pair< float, float > fitResiduals(TH1 *hist) const
void collateSummaryHists()
std::unique_ptr< TFileDirectory > tfd
std::string histNameLocalX
bool tidIsDoubleSide(const DetId &id) const
void summarizeBinInContainer(int bin, SummaryContainer &targetContainer, SummaryContainer &sourceContainer)
const bool moduleLevelHistsTransient_
bool isEndCap(uint32_t subDetId)
unsigned int tobModule(const DetId &id) const
std::string profileNameResXvsY
std::vector< TH1 * > toFit_
void bookGlobalHists(DirectoryWrapper &tfd)
DirectoryWrapper(const DirectoryWrapper &upDir, const std::string &newDir, const std::string &basedir, bool useDqmMode)
TrackerValidationVariables avalidator_
std::map< int, TkOffTreeVariables > mTreeMembers_
uint32_t tecStereo(const DetId &id) const
const TrackerGeomDet * idToDet(DetId) const override
~TrackerOfflineValidation() override
TProfile * ResXvsXProfile
std::vector< TH1 * > vTrackProfiles_
unsigned int pxfSide(const DetId &id) const
void bookDirHists(DirectoryWrapper &tfd, const Alignable &ali, const TrackerTopology *tTopo)
std::map< int, TrackerOfflineValidation::ModuleHistos > mPxbResiduals_
std::string histNameNormY
uint32_t tibStereo(const DetId &id) const
const edm::ParameterSet parSet_
TrackerOfflineValidation(const edm::ParameterSet &)
float Fwhm(const TH1 *hist) const
unsigned int tecWheel(const DetId &id) const
T const * product() const
unsigned int pxfPanel(const DetId &id) const
unsigned int pxfBlade(const DetId &id) const
TProfile * ResYvsXProfile
void analyze(const edm::Event &, const edm::EventSetup &) override
std::string profileNameResYvsY
unsigned int tobLayer(const DetId &id) const
void bookHists(DirectoryWrapper &tfd, const Alignable &ali, const TrackerTopology *tTopo, align::StructureType type, int i)
unsigned int tecSide(const DetId &id) const
constexpr Detector det() const
get the detector field from this detid
bool isBarrel(uint32_t subDetId)