140 if (newDir.length()!=0){
148 if (newDir.length()==0)
tfd.reset(&(*upDir.
tfd));
163 if (newDir.length()==0){
172 if (newDir.length()!=0){
181 template <
typename T> TH1*
make(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX);
182 template <
typename T> TH1*
make(
const char*
name,
const char*
title,
int nBinX,
double *xBins);
183 template <
typename T> TH1*
make(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX,
int nBinY,
double minBinY,
double maxBinY);
184 template <
typename T> TH1*
make(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX,
double minBinY,
double maxBinY);
186 std::auto_ptr<TFileDirectory>
tfd;
197 virtual void endJob()
override;
206 std::vector<TrackerOfflineValidation::SummaryContainer>& vLevelProfiles);
208 void fillTree(TTree&
tree,
const std::map<int, TrackerOfflineValidation::ModuleHistos>& moduleHist_,
223 int nBinsX,
double lowX,
double highX);
226 int nBinsX,
double lowX,
double highX);
229 int nBinsX,
double lowX,
double highX,
double lowY,
double highY);
232 int& nBinsX,
double& lowerBoundX,
double& upperBoundX);
247 template <
class OBJECT_TYPE>
int GetIndex(
const std::vector<OBJECT_TYPE*>& vec,
const TString&
name);
295 template <
class OBJECT_TYPE>
299 for (
typename std::vector<OBJECT_TYPE*>::const_iterator iter = vec.begin(), iterEnd = vec.end();
300 iter != iterEnd; ++iter, ++
result) {
301 if (*iter && (*iter)->GetName() ==
name)
return result;
303 edm::LogError(
"Alignment") <<
"@SUB=TrackerOfflineValidation::GetIndex" <<
" could not find " <<
name;
308 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TH1F>(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX){
309 if(dqmMode){theDbe->setCurrentFolder(directoryString);
return theDbe->book1D(
name,
title,nBinX,minBinX,maxBinX)->getTH1();}
310 else{
return tfd->make<TH1F>(
name,
title,nBinX,minBinX,maxBinX);}
313 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TProfile>(
const char*
name,
const char*
title,
int nBinX,
double *xBins){
315 theDbe->setCurrentFolder(directoryString);
317 TProfile *tmpProfile=
new TProfile(
name,
title,nBinX,xBins);
318 tmpProfile->SetDirectory(0);
319 return theDbe->bookProfile(
name,tmpProfile)->getTH1();
321 else{
return tfd->make<TProfile>(
name,
title,nBinX,xBins);}
324 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TProfile>(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX){
326 theDbe->setCurrentFolder(directoryString);
328 TProfile *tmpProfile=
new TProfile(
name,
title,nBinX,minBinX,maxBinX);
329 tmpProfile->SetDirectory(0);
330 return theDbe->bookProfile(
name,tmpProfile)->getTH1();
332 else{
return tfd->make<TProfile>(
name,
title,nBinX,minBinX,maxBinX);}
335 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TProfile>(
const char*
name ,
const char*
title,
int nbinX,
double minX ,
double maxX,
double minY,
double maxY){
337 theDbe->setCurrentFolder(directoryString);
339 return (theDbe->bookProfile(
name,
title,nbinX,minX,maxX,dummy,minY,maxY)->getTH1());
342 return tfd->make<TProfile>(
name,
title,nbinX,minX,maxX,minY,maxY);
346 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TH2F>(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX,
int nBinY,
double minBinY,
double maxBinY){
347 if(dqmMode){theDbe->setCurrentFolder(directoryString);
return theDbe->book2D(
name,
title,nBinX,minBinX,maxBinX,nBinY,minBinY,maxBinY)->getTH1();}
348 else{
return tfd->make<TH2F>(
name,
title,nBinX,minBinX,maxBinX,nBinY,minBinY,maxBinY);}
356 : parSet_(iConfig), bareTkGeomPtr_(0), lCoorHistOn_(parSet_.getParameter<bool>(
"localCoorHistosOn")),
357 moduleLevelHistsTransient_(parSet_.getParameter<bool>(
"moduleLevelHistsTransient")),
358 moduleLevelProfiles_(parSet_.getParameter<bool>(
"moduleLevelProfiles")),
359 stripYResiduals_(parSet_.getParameter<bool>(
"stripYResiduals")),
360 useFwhm_(parSet_.getParameter<bool>(
"useFwhm")),
361 useFit_(parSet_.getParameter<bool>(
"useFit")),
362 useOverflowForRMS_(parSet_.getParameter<bool>(
"useOverflowForRMS")),
363 dqmMode_(parSet_.getParameter<bool>(
"useInDqmMode")),
364 moduleDirectory_(parSet_.getParameter<std::
string>(
"moduleDirectoryInOutput")),
366 avalidator_(iConfig, consumesCollector())
404 edm::LogInfo(
"TrackerOfflineValidation") <<
"There are " << newBareTkGeomPtr->
detIds().size()
405 <<
" dets in the Geometry record.\n"
406 <<
"Out of these "<<newBareTkGeomPtr->
detUnitIds().size()
420 <<
"TrackerGeometry changed, but will not re-book hists!";
431 "Track #eta;#eta_{Track};Number of Tracks",
434 "Track #phi;#phi_{Track};Number of Tracks",
437 "Track # of valid hits;# of valid hits _{Track};Number of Tracks",
440 "Track # of lost hits;# of lost hits _{Track};Number of Tracks",
443 "Curvature #kappa;#kappa_{Track};Number of Tracks",
446 "Curvature |#kappa| Positive Tracks;|#kappa_{pos Track}|;Number of Tracks",
449 "Curvature |#kappa| Negative Tracks;|#kappa_{neg Track}|;Number of Tracks",
452 "Curvature |#kappa| Tracks Difference;|#kappa_{Track}|;# Pos Tracks - # Neg Tracks",
455 "#chi^{2};#chi^{2}_{Track};Number of Tracks",
458 "#chi^{2} probability;#chi^{2}prob_{Track};Number of Tracks",
461 "#chi^{2}/ndof;#chi^{2}/ndof;Number of Tracks",
464 "p_{T}^{track};p_{T}^{track} [GeV];Number of Tracks",
467 "#delta_{p_{T}}/p_{T}^{track};#delta_{p_{T}}/p_{T}^{track};Number of Tracks",
470 "Transverse Impact Parameter vs. #phi;#phi_{Track};#LT d_{0} #GT [cm]",
473 "Longitudinal Impact Parameter vs. #phi;#phi_{Track};#LT d_{z} #GT [cm]",
476 "Transverse Impact Parameter vs. #eta;#eta_{Track};#LT d_{0} #GT [cm]",
479 "Longitudinal Impact Parameter vs. #eta;#eta_{Track};#LT d_{z} #GT [cm]",
482 "#chi^{2} vs. #phi;#phi_{Track};#LT #chi^{2} #GT",
485 "#chi^{2} probablility vs. #phi;#phi_{Track};#LT #chi^{2} probability#GT",
488 "#chi^{2} probablility vs. |d_{0}|;|d_{0}|[cm];#LT #chi^{2} probability#GT",
491 "#chi^{2}/ndof vs. #phi;#phi_{Track};#LT #chi^{2}/ndof #GT",
494 "#chi^{2} vs. #eta;#eta_{Track};#LT #chi^{2} #GT",
497 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.};
499 "norm #chi^{2} vs. p_{T}_{Track}; p_{T}_{Track};#LT #chi^{2}/ndof #GT",
503 "#chi^{2}/ndof vs. p_{Track};p_{Track};#LT #chi^{2}/ndof #GT",
506 "#chi^{2} probability vs. #eta;#eta_{Track};#LT #chi^{2} probability #GT",
509 "#chi^{2}/ndof vs. #eta;#eta_{Track};#LT #chi^{2}/ndof #GT",
512 "#kappa vs. #phi;#phi_{Track};#kappa",
515 "#kappa vs. #eta;#eta_{Track};#kappa",
518 "#delta_{p_{T}}/p_{T}^{track};#phi^{track};#delta_{p_{T}}/p_{T}^{track}",
521 "#delta_{p_{T}}/p_{T}^{track};#eta^{track};#delta_{p_{T}}/p_{T}^{track}",
525 "Transverse Impact Parameter vs. #phi;#phi_{Track};d_{0} [cm]",
526 100, -3.15, 3.15, 100,-1.,1.) );
528 "Longitudinal Impact Parameter vs. #phi;#phi_{Track};d_{z} [cm]",
529 100, -3.15, 3.15, 100,-100.,100.));
531 "Transverse Impact Parameter vs. #eta;#eta_{Track};d_{0} [cm]",
532 100, -3.15, 3.15, 100,-1.,1.));
534 "Longitudinal Impact Parameter vs. #eta;#eta_{Track};d_{z} [cm]",
535 100, -3.15, 3.15, 100,-100.,100.));
537 "#chi^{2} vs. #phi;#phi_{Track};#chi^{2}",
538 100, -3.15, 3.15, 500, 0., 500.));
540 "#chi^{2} probability vs. #phi;#phi_{Track};#chi^{2} probability",
541 100, -3.15, 3.15, 100, 0., 1.));
543 "#chi^{2} probability vs. |d_{0}|;|d_{0}| [cm];#chi^{2} probability",
544 100, 0, 80, 100, 0., 1.));
546 "#chi^{2}/ndof vs. #phi;#phi_{Track};#chi^{2}/ndof",
547 100, -3.15, 3.15, 100, 0., 10.));
549 "#chi^{2} vs. #eta;#eta_{Track};#chi^{2}",
550 100, -3.15, 3.15, 500, 0., 500.));
552 "#chi^{2} probaility vs. #eta;#eta_{Track};#chi^{2} probability",
553 100, -3.15, 3.15, 100, 0., 1.));
555 "#chi^{2}/ndof vs. #eta;#eta_{Track};#chi^{2}/ndof",
556 100,-3.15,3.15, 100, 0., 10.));
558 "#kappa vs. #phi;#phi_{Track};#kappa",
559 100,-3.15,3.15, 100, .0,.05));
561 "#kappa vs. #eta;#eta_{Track};#kappa",
562 100,-3.15,3.15, 100, .0,.05));
564 "#kappa vs. #chi^{2}/ndof;#chi^{2}/ndof;#kappa",
565 100,0.,10, 100,-.03,.03));
569 "res_{x'} vs momentum in BPix;p [GeV]; res_{x'}",
570 15,0.,15., 200, -0.1,0.1));
572 "res_{x'} vs momentum in FPix;p [GeV]; res_{x'}",
573 15,0.,15., 200, -0.1,0.1));
575 "res_{x'} vs momentum in TIB;p [GeV]; res_{x'}",
576 15,0.,15., 200, -0.1,0.1));
578 "res_{x'} vs momentum in TID;p [GeV]; res_{x'}",
579 15,0.,15., 200, -0.1,0.1));
581 "res_{x'} vs momentum in TOB;p [GeV]; res_{x'}",
582 15,0.,15., 200, -0.1,0.1));
584 "res_{x'} vs momentum in TEC;p [GeV]; res_{x'}",
585 15,0.,15., 200, -0.1,0.1));
589 "res_{y'} vs momentum in BPix;p [GeV]; res_{y'}",
590 15,0.,15., 200, -0.1,0.1));
592 "res_{y'} vs momentum in FPix;p [GeV]; res_{y'}",
593 15,0.,15., 200, -0.1,0.1));
601 std::vector<Alignable*> alivec(ali.
components());
604 LogDebug(
"TrackerOfflineValidation") <<
"StructureName = " << structurename;
606 dirname << structurename;
608 if (structurename !=
"Strip" && structurename !=
"Pixel") dirname <<
"_" <<
i+1;
610 if (structurename.find(
"Endcap",0) != std::string::npos ) {
614 }
else if( !(this->
isDetOrDetUnit( (alivec)[i]->alignableObjectId()) )
644 std::stringstream histoname, histotitle, normhistoname, normhistotitle,
645 yhistoname, yhistotitle,
646 xprimehistoname, xprimehistotitle, normxprimehistoname, normxprimehistotitle,
647 yprimehistoname, yprimehistotitle, normyprimehistoname, normyprimehistotitle,
648 localxname, localxtitle, localyname, localytitle,
649 resxvsxprofilename, resxvsxprofiletitle, resyvsxprofilename, resyvsxprofiletitle,
650 resxvsyprofilename, resxvsyprofiletitle, resyvsyprofilename, resyvsyprofiletitle;
654 if( this->
isEndCap(static_cast<uint32_t>(subdetandlayer.first)) ) wheel_or_layer =
"_wheel_";
655 else if ( this->
isBarrel(static_cast<uint32_t>(subdetandlayer.first)) ) wheel_or_layer =
"_layer_";
656 else edm::LogWarning(
"TrackerOfflineValidation") <<
"@SUB=TrackerOfflineValidation::bookHists"
657 <<
"Unknown subdetid: " << subdetandlayer.first;
659 histoname <<
"h_residuals_subdet_" << subdetandlayer.first
660 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
661 yhistoname <<
"h_y_residuals_subdet_" << subdetandlayer.first
662 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
663 xprimehistoname <<
"h_xprime_residuals_subdet_" << subdetandlayer.first
664 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
665 yprimehistoname <<
"h_yprime_residuals_subdet_" << subdetandlayer.first
666 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
667 normhistoname <<
"h_normresiduals_subdet_" << subdetandlayer.first
668 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
669 normxprimehistoname <<
"h_normxprimeresiduals_subdet_" << subdetandlayer.first
670 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
671 normyprimehistoname <<
"h_normyprimeresiduals_subdet_" << subdetandlayer.first
672 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
673 histotitle <<
"X Residual for module " <<
id.rawId() <<
";x_{tr} - x_{hit} [cm]";
674 yhistotitle <<
"Y Residual for module " <<
id.rawId() <<
";y_{tr} - y_{hit} [cm]";
675 normhistotitle <<
"Normalized Residual for module " <<
id.rawId() <<
";x_{tr} - x_{hit}/#sigma";
676 xprimehistotitle <<
"X' Residual for module " <<
id.rawId() <<
";(x_{tr} - x_{hit})' [cm]";
677 normxprimehistotitle <<
"Normalized X' Residual for module " <<
id.rawId() <<
";(x_{tr} - x_{hit})'/#sigma";
678 yprimehistotitle <<
"Y' Residual for module " <<
id.rawId() <<
";(y_{tr} - y_{hit})' [cm]";
679 normyprimehistotitle <<
"Normalized Y' Residual for module " <<
id.rawId() <<
";(y_{tr} - y_{hit})'/#sigma";
682 localxname <<
"h_localx_subdet_" << subdetandlayer.first
683 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
684 localyname <<
"h_localy_subdet_" << subdetandlayer.first
685 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
686 localxtitle <<
"u local for module " <<
id.rawId() <<
"; u_{tr,r}";
687 localytitle <<
"v local for module " <<
id.rawId() <<
"; v_{tr,r}";
689 resxvsxprofilename <<
"p_residuals_x_vs_x_subdet_" << subdetandlayer.first
690 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
691 resyvsxprofilename <<
"p_residuals_y_vs_x_subdet_" << subdetandlayer.first
692 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
693 resxvsyprofilename <<
"p_residuals_x_vs_y_subdet_" << subdetandlayer.first
694 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
695 resyvsyprofilename <<
"p_residuals_y_vs_y_subdet_" << subdetandlayer.first
696 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
697 resxvsxprofiletitle <<
"U Residual vs u for module " <<
id.rawId() <<
"; u_{tr,r} ;(u_{tr} - u_{hit})/tan#alpha [cm]";
698 resyvsxprofiletitle <<
"V Residual vs u for module " <<
id.rawId() <<
"; u_{tr,r} ;(v_{tr} - v_{hit})/tan#beta [cm]";
699 resxvsyprofiletitle <<
"U Residual vs v for module " <<
id.rawId() <<
"; v_{tr,r} ;(u_{tr} - u_{hit})/tan#alpha [cm]";
700 resyvsyprofiletitle <<
"V Residual vs v for module " <<
id.rawId() <<
"; v_{tr,r} ;(v_{tr} - v_{hit})/tan#beta [cm]";
711 if (
dqmMode_) moduleLevelHistsTransient =
false;
717 histoname.str().c_str(),histotitle.str().c_str(),
721 normhistoname.str().c_str(),normhistotitle.str().c_str(),
726 xprimehistoname.str().c_str(),xprimehistotitle.str().c_str(),
730 normxprimehistoname.str().c_str(),normxprimehistotitle.str().c_str(),
736 histStruct.
LocalX = this->
bookTH1F(moduleLevelHistsTransient, tfd,
737 localxname.str().c_str(),localxtitle.str().c_str(),
739 histStruct.
LocalY = this->
bookTH1F(moduleLevelHistsTransient, tfd,
740 localyname.str().c_str(),localytitle.str().c_str(),
743 resxvsxprofilename.str().c_str(),resxvsxprofiletitle.str().c_str(),
747 resxvsyprofilename.str().c_str(),resxvsyprofiletitle.str().c_str(),
755 yprimehistoname.str().c_str(),yprimehistotitle.str().c_str(),
760 yhistoname.str().c_str(), yhistotitle.str().c_str(),
765 normyprimehistoname.str().c_str(),normyprimehistotitle.str().c_str(),
772 resyvsxprofilename.str().c_str(),resyvsxprofiletitle.str().c_str(),
776 resyvsyprofilename.str().c_str(),resyvsyprofiletitle.str().c_str(),
786 int nBinsX,
double lowX,
double highX)
789 vDeleteObjects_.push_back(
new TH1F(histName, histTitle, nBinsX, lowX, highX));
793 return tfd.
make<TH1F>(histName, histTitle, nBinsX, lowX, highX);
797 int nBinsX,
double lowX,
double highX)
800 TProfile * profile =
new TProfile(histName, histTitle, nBinsX, lowX, highX);
805 return (TProfile*)tfd.
make<TProfile>(histName, histTitle, nBinsX, lowX, highX);
810 int nBinsX,
double lowX,
double highX,
double lowY,
double highY)
813 TProfile * profile =
new TProfile(histName, histTitle, nBinsX, lowX, highX, lowY, highY);
818 return (TProfile*)tfd.
make<TProfile>(histName, histTitle, nBinsX, lowX, highX, lowY, highY);
854 int& nBinsX,
double& lowerBoundX,
double& upperBoundX)
907 if(targetHist && sourceHist) {
908 targetHist->SetBinContent(bin, sourceHist->GetMean(1));
909 if(
useFwhm_) targetHist->SetBinError(bin,
Fwhm(sourceHist)/2.);
910 else targetHist->SetBinError(bin, sourceHist->GetRMS(1) );
964 <<
"[TrackerOfflineValidation] Error, tried to get reference for non-tracker subdet " << subdetid
965 <<
" from detector " << detid.
det();
978 std::vector<TrackerValidationVariables::AVTrackStruct> vTrackstruct;
981 for (std::vector<TrackerValidationVariables::AVTrackStruct>::const_iterator itT = vTrackstruct.begin();
982 itT != vTrackstruct.end();
991 vTrackHistos_[numOfValidHitsindex]->Fill(itT->numberOfValidHits);
993 vTrackHistos_[numOfLostHitsindex]->Fill(itT->numberOfLostHits);
1000 if (itT->charge < 0)
1010 if (itT->ptError != 0.) {
1012 vTrackHistos_[ptResolutionindex]->Fill(itT->ptError/itT->pt);
1028 vTrackProfiles_[chiProbabsd0index]->Fill(fabs(itT->d0),itT->chi2Prob);
1064 vTrack2DHistos_[chiProbabsd0index_2d]->Fill(fabs(itT->d0),itT->chi2Prob);
1081 for (std::vector<TrackerValidationVariables::AVHitStruct>::const_iterator itH = itT->hits.begin();
1082 itH != itT->hits.end();
1090 histStruct.
ResHisto->Fill(itH->resX);
1091 if(itH->resErrX != 0) histStruct.
NormResHisto->Fill(itH->resX/itH->resErrX);
1097 if (itH->resXprime != -999.) {
1128 float tgalpha =
tan(itH->localAlpha);
1129 if ( fabs(tgalpha)!=0 ){
1130 histStruct.
LocalX->Fill(itH->localXnorm, tgalpha*tgalpha);
1131 histStruct.
LocalY->Fill(itH->localYnorm, tgalpha*tgalpha);
1143 histStruct.
ResXvsXProfile->Fill(itH->localXnorm, itH->resXatTrkY/tgalpha, tgalpha*tgalpha);
1144 histStruct.
ResXvsYProfile->Fill(itH->localYnorm, itH->resXatTrkY/tgalpha, tgalpha*tgalpha);
1151 if(itH->resXprimeErr != 0 && itH->resXprimeErr != -999 ) {
1156 if (itH->resYprime != -999.) {
1172 float tgbeta =
tan(itH->localBeta);
1173 if ( fabs(tgbeta)!=0 ){
1186 histStruct.
ResYvsXProfile->Fill(itH->localXnorm, itH->resY/tgbeta, tgbeta*tgbeta);
1187 histStruct.
ResYvsYProfile->Fill(itH->localYnorm, itH->resY/tgbeta, tgbeta*tgbeta);
1192 if (itH->resYprimeErr != 0 && itH->resYprimeErr != -999. ) {
1225 std::vector<TrackerOfflineValidation::SummaryContainer> vTrackerprofiles;
1234 TTree *
tree = fs->
make<TTree>(
"TkOffVal",
"TkOffVal");
1240 tree->Branch(
"TkOffTreeVariables", &treeMemPtr);
1249 delete treeMemPtr; treeMemPtr = 0;
1255 std::vector<TrackerOfflineValidation::SummaryContainer>& vLevelProfiles)
1257 std::vector<Alignable*> alivec(ali.
components());
1258 if( this->
isDetOrDetUnit((alivec)[0]->alignableObjectId()) )
return;
1260 for(
int iComp=0, iCompEnd = ali.
components().size();iComp < iCompEnd; ++iComp) {
1261 std::vector< TrackerOfflineValidation::SummaryContainer > vProfiles;
1264 LogDebug(
"TrackerOfflineValidation") <<
"StructureName = " << structurename;
1266 dirname << structurename;
1269 if (structurename !=
"Strip" && structurename !=
"Pixel") dirname <<
"_" << iComp+1;
1271 if( !(this->
isDetOrDetUnit( (alivec)[iComp]->alignableObjectId()) )
1276 TH1 *hY = vLevelProfiles[iComp].sumYResiduals_;
1277 TH1 *hNormY = vLevelProfiles[iComp].sumNormYResiduals_;
1278 for(uint
n = 0;
n < vProfiles.size(); ++
n) {
1280 vLevelProfiles[iComp].sumXResiduals_->Add(vProfiles[n].sumXResiduals_);
1281 vLevelProfiles[iComp].sumNormXResiduals_->Add(vProfiles[n].sumNormXResiduals_);
1282 if (hY) hY->Add(vProfiles[n].sumYResiduals_);
1283 if (hNormY) hNormY->Add(vProfiles[n].sumNormYResiduals_);
1287 this->
fitResiduals(vLevelProfiles[iComp].sumXResiduals_);
1288 this->
fitResiduals(vLevelProfiles[iComp].sumNormXResiduals_);
1303 const uint aliSize = ali.
components().size();
1310 const DetId aliDetId = ali.
id();
1320 const uint subcompSize = ali.
components()[0]->components().size();
1322 const TString
title(Form(
"Summary for substructures in %s %d;%s;",aliTypeName,i,aliSubtypeName));
1324 sumContainer.summaryXResiduals_ = tfd.
make<TH1F>(Form(
"h_summaryX%s_%d",aliTypeName,i),
1325 title +
"#LT #Delta x' #GT",
1326 aliSize, 0.5, aliSize+0.5);
1327 sumContainer.summaryNormXResiduals_ = tfd.
make<TH1F>(Form(
"h_summaryNormX%s_%d",aliTypeName,i),
1328 title +
"#LT #Delta x'/#sigma #GT",
1329 aliSize,0.5,aliSize+0.5);
1332 sumContainer.summaryYResiduals_ = tfd.
make<TH1F>(Form(
"h_summaryY%s_%d",aliTypeName,i),
1333 title +
"#LT #Delta y' #GT",
1334 aliSize, 0.5, aliSize+0.5);
1335 sumContainer.summaryNormYResiduals_ = tfd.
make<TH1F>(Form(
"h_summaryNormY%s_%d",aliTypeName,i),
1336 title +
"#LT #Delta y'/#sigma #GT",
1337 aliSize,0.5,aliSize+0.5);
1341 if (subcompSize != 2) {
1344 <<
"Det with " << subcompSize <<
" components";
1347 const TString
title(Form(
"Summary for substructures in %s %d;%s;", aliTypeName, i,
1350 sumContainer.summaryXResiduals_
1351 = tfd.
make<TH1F>(Form(
"h_summaryX%s_%d", aliTypeName, i),
1352 title +
"#LT #Delta x' #GT", (2*aliSize), 0.5, 2*aliSize+0.5);
1353 sumContainer.summaryNormXResiduals_
1354 = tfd.
make<TH1F>(Form(
"h_summaryNormX%s_%d", aliTypeName, i),
1355 title +
"#LT #Delta x'/#sigma #GT", (2*aliSize), 0.5, 2*aliSize+0.5);
1358 sumContainer.summaryYResiduals_
1359 = tfd.
make<TH1F>(Form(
"h_summaryY%s_%d", aliTypeName, i),
1360 title +
"#LT #Delta y' #GT", (2*aliSize), 0.5, 2*aliSize+0.5);
1361 sumContainer.summaryNormYResiduals_
1362 = tfd.
make<TH1F>(Form(
"h_summaryNormY%s_%d", aliTypeName, i),
1363 title +
"#LT #Delta y'/#sigma #GT", (2*aliSize), 0.5, 2*aliSize+0.5);
1367 edm::LogError(
"TrackerOfflineValidation") <<
"@SUB=TrackerOfflineValidation::bookSummaryHists"
1368 <<
"No summary histogramm for hierarchy level "
1369 << aliTypeName <<
" in subdet " << aliDetId.
subdetId();
1377 const TString sumTitle(Form(
"Residual for %s %d in %s;", aliTypeName, i, typeName));
1381 sumContainer.sumXResiduals_ = tfd.
make<TH1F>(Form(
"h_Xprime_%s_%d", aliTypeName, i),
1386 sumContainer.sumNormXResiduals_ = tfd.
make<TH1F>(Form(
"h_NormXprime_%s_%d",aliTypeName,i),
1391 sumContainer.sumYResiduals_ = tfd.
make<TH1F>(Form(
"h_Yprime_%s_%d",aliTypeName,i),
1396 sumContainer.sumNormYResiduals_ = tfd.
make<TH1F>(Form(
"h_NormYprime_%s_%d",aliTypeName,i),
1405 for(uint
k = 0;
k < aliSize; ++
k) {
1418 for(uint
k = 0;
k < aliSize; ++
k) {
1419 for(uint
j = 0;
j < subcompSize; ++
j) {
1432 return sumContainer;
1439 float max = hist->GetMaximum();
1440 int left = -1, right = -1;
1441 for(
unsigned int i = 1, iEnd = hist->GetNbinsX();
i <= iEnd; ++
i) {
1442 if(hist->GetBinContent(
i) < max/2. && hist->GetBinContent(
i+1) > max/2. && left == -1) {
1443 if(max/2. - hist->GetBinContent(
i) < hist->GetBinContent(
i+1) - max/2.) {
1451 if(left != -1 && right == -1) {
1452 if(hist->GetBinContent(
i) > max/2. && hist->GetBinContent(
i+1) < max/2.) {
1453 if( hist->GetBinContent(
i) - max/2. < max/2. - hist->GetBinContent(
i+1)) {
1462 return hist->GetXaxis()->GetBinCenter(right) - hist->GetXaxis()->GetBinCenter(left);
1468 const std::map<int, TrackerOfflineValidation::ModuleHistos>& moduleHist_,
1472 for(std::map<int, TrackerOfflineValidation::ModuleHistos>::const_iterator it = moduleHist_.begin(),
1473 itEnd= moduleHist_.end(); it != itEnd;++it ) {
1477 DetId detId_ = it->first;
1483 unsigned int whichHalfBarrel(1), rawId(detId_.
rawId());
1484 if( (rawId>=302056964 && rawId<302059300) || (rawId>=302123268 && rawId<302127140) ||
1485 (rawId>=302189572 && rawId<302194980) ) whichHalfBarrel=2;
1487 treeMem.
half = whichHalfBarrel;
1491 unsigned int whichHalfCylinder(1), rawId(detId_.
rawId());
1492 if( (rawId>=352394500 && rawId<352406032) || (rawId>=352460036 && rawId<352471568) ||
1493 (rawId>=344005892 && rawId<344017424) || (rawId>=344071428 && rawId<344082960) ) whichHalfCylinder=2;
1496 treeMem.
half = whichHalfCylinder;
1501 unsigned int whichHalfShell(1), rawId(detId_.
rawId());
1502 if ( (rawId>=369120484 && rawId<369120688) || (rawId>=369121540 && rawId<369121776) ||
1503 (rawId>=369136932 && rawId<369137200) || (rawId>=369137988 && rawId<369138288) ||
1504 (rawId>=369153396 && rawId<369153744) || (rawId>=369154436 && rawId<369154800) ||
1505 (rawId>=369169844 && rawId<369170256) || (rawId>=369170900 && rawId<369171344) ||
1506 (rawId>=369124580 && rawId<369124784) || (rawId>=369125636 && rawId<369125872) ||
1507 (rawId>=369141028 && rawId<369141296) || (rawId>=369142084 && rawId<369142384) ||
1508 (rawId>=369157492 && rawId<369157840) || (rawId>=369158532 && rawId<369158896) ||
1509 (rawId>=369173940 && rawId<369174352) || (rawId>=369174996 && rawId<369175440) ) whichHalfShell=2;
1512 treeMem.
half = whichHalfShell;
1549 treeMem.
posX = gPModule.
x();
1550 treeMem.
posY = gPModule.
y();
1551 treeMem.
posZ = gPModule.
z();
1556 LocalPoint lUDirection(1.,0.,0.), lVDirection(0.,1.,0.), lWDirection(0.,0.,1.);
1558 gVDirection = surface.
toGlobal(lVDirection),
1559 gWDirection = surface.
toGlobal(lWDirection);
1560 double dR(999.),
dPhi(999.), dZ(999.);
1562 dR = gWDirection.perp() - gPModule.
perp();
1564 dZ = gVDirection.z() - gPModule.
z();
1569 dZ = gWDirection.z() - gPModule.
z();
1572 dR = gVDirection.perp() - gPModule.
perp();
1574 dZ = gWDirection.z() - gPModule.
z();
1582 treeMem.
entries =
static_cast<UInt_t
>(it->second.ResXprimeHisto->GetEntries());
1583 treeMem.
meanX = it->second.ResXprimeHisto->GetMean();
1584 treeMem.
rmsX = it->second.ResXprimeHisto->GetRMS();
1590 std::pair<float,float> fitResult1 = this->
fitResiduals(it->second.ResXprimeHisto);
1591 treeMem.
fitMeanX = fitResult1.first;
1594 std::pair<float,float> fitResult2 = this->
fitResiduals(it->second.NormResXprimeHisto);
1602 int numberOfBins=it->second.ResXprimeHisto->GetNbinsX();
1604 treeMem.
numberOfOverflows = it->second.ResXprimeHisto->GetBinContent(numberOfBins+1);
1605 treeMem.
numberOfOutliers = it->second.ResXprimeHisto->GetBinContent(0)+it->second.ResXprimeHisto->GetBinContent(numberOfBins+1);
1608 treeMem.
meanNormX = it->second.NormResXprimeHisto->GetMean();
1609 treeMem.
rmsNormX = it->second.NormResXprimeHisto->GetRMS();
1612 it->second.NormResXprimeHisto->GetStats(stats);
1614 if (stats[0]) treeMem.
chi2PerDofX = stats[3]/stats[0];
1617 treeMem.
histNameX = it->second.ResXprimeHisto->GetName();
1618 treeMem.
histNameNormX = it->second.NormResXprimeHisto->GetName();
1622 treeMem.
meanLocalX = it->second.ResHisto->GetMean();
1623 treeMem.
rmsLocalX = it->second.ResHisto->GetRMS();
1629 if (it->second.ResYHisto) treeMem.
histNameLocalY = it->second.ResYHisto->GetName();
1634 if (it->second.ResYprimeHisto) {
1635 TH1 *
h = it->second.ResYprimeHisto;
1636 treeMem.
meanY = h->GetMean();
1637 treeMem.
rmsY = h->GetRMS();
1640 std::pair<float,float> fitMeanSigma = this->
fitResiduals(h);
1641 treeMem.
fitMeanY = fitMeanSigma.first;
1642 treeMem.
fitSigmaY = fitMeanSigma.second;
1650 if (it->second.NormResYprimeHisto) {
1651 TH1 *
h = it->second.NormResYprimeHisto;
1655 if (stats[0]) treeMem.
chi2PerDofY = stats[3]/stats[0];
1658 std::pair<float,float> fitMeanSigma = this->
fitResiduals(h);
1666 if (it->second.ResXvsXProfile) {
1667 TH1 *
h = it->second.ResXvsXProfile;
1672 if (it->second.ResXvsYProfile) {
1673 TH1 *
h = it->second.ResXvsYProfile;
1678 if (it->second.ResYvsXProfile) {
1679 TH1 *
h = it->second.ResYvsXProfile;
1684 if (it->second.ResYvsYProfile) {
1685 TH1 *
h = it->second.ResYvsYProfile;
1697 std::pair<float,float>
1700 std::pair<float,float> fitResult(9999., 9999.);
1701 if (!hist || hist->GetEntries() < 20)
return fitResult;
1703 float mean = hist->GetMean();
1704 float sigma = hist->GetRMS();
1709 TF1 func(
"tmp",
"gaus", mean - 2.*sigma, mean + 2.*sigma);
1710 if (0 == hist->Fit(&func,
"QNR")) {
1711 mean = func.GetParameter(1);
1712 sigma = func.GetParameter(2);
1714 func.SetRange(mean - 3.*sigma, mean + 3.*sigma);
1717 if (0 == hist->Fit(&func,
"Q0LR")) {
1718 if (hist->GetFunction(func.GetName())) {
1719 hist->GetFunction(func.GetName())->ResetBit(TF1::kNotDraw);
1721 fitResult.first = func.GetParameter(1);
1722 fitResult.second = func.GetParameter(2);
1726 edm::LogWarning(
"Alignment") <<
"@SUB=TrackerOfflineValidation::fitResiduals"
1727 <<
"Caught this exception during ROOT fit: "
1738 int nbins = histo->GetNbinsX();
1741 double *
x =
new double[
nbins];
1742 double *
y =
new double[
nbins];
1744 x[
j] = histo->GetBinCenter(
j+1);
1745 y[
j] = histo->GetBinContent(
j+1);
1747 median = TMath::Median(nbins, x, y);
const TrackerGeometry * bareTkGeomPtr_
virtual char const * what() const
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_
~TrackerOfflineValidation()
bool tibIsDoubleSide(const DetId &id) const
void collateSummaryHists(DirectoryWrapper &tfd, const Alignable &ali, int i, std::vector< TrackerOfflineValidation::SummaryContainer > &vLevelProfiles)
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
TH1 * make(const char *name, const char *title, int nBinX, double minBinX, double maxBinX)
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::map< int, TrackerOfflineValidation::ModuleHistos > mTecResiduals_
#define DEFINE_FWK_MODULE(type)
std::string directoryString
unsigned int pxfDisk(const DetId &id) const
container to hold data to be written into TTree
std::string profileNameResXvsX
unsigned int tecRing(const DetId &id) const
ring id
const bool stripYResiduals_
const bool useOverflowForRMS_
uint32_t tobStereo(const DetId &id) const
Geom::Phi< T > phi() const
unsigned int pxbLadder(const DetId &id) const
edm::ESHandle< TrackerGeometry > tkGeom_
int GetIndex(const std::vector< OBJECT_TYPE * > &vec, const TString &name)
unsigned int tidWheel(const DetId &id) const
unsigned int pxbModule(const DetId &id) const
T * make(const Args &...args) const
make new ROOT object
void fillTree(TTree &tree, const std::map< int, TrackerOfflineValidation::ModuleHistos > &moduleHist_, TkOffTreeVariables &treeMem, const TrackerGeometry &tkgeom, const TrackerTopology *tTopo)
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
virtual Alignables components() const =0
Return vector of all direct components.
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.
TProfile * ResXvsYProfile
TH1 * summaryNormYResiduals_
std::string profileNameResYvsX
std::map< int, TrackerOfflineValidation::ModuleHistos > mTidResiduals_
uint32_t rawId() const
get the raw id
TProfile * ResYvsYProfile
virtual const DetIdContainer & detIds() const
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
TFileDirectory & tFileDirectory()
std::vector< unsigned int > tecPetalInfo(const DetId &id) const
const Surface::PositionType & position() const
The position (origin of the R.F.)
TH1 * summaryNormXResiduals_
unsigned int tidSide(const DetId &id) const
std::string histNameNormX
double dPhi(double phi1, double phi2)
uint32_t tidStereo(const DetId &id) const
void getBinning(uint32_t subDetId, TrackerOfflineValidation::HistogrammType residualtype, int &nBinsX, double &lowerBoundX, double &upperBoundX)
std::vector< unsigned int > tobRodInfo(const DetId &id) const
unsigned int subDetId[18]
Tan< T >::type tan(const T &t)
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
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)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::string histNameLocalY
std::string histNameNormLocalX
unsigned int tibModule(const DetId &id) const
unsigned int pxfModule(const DetId &id) const
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
std::string histNameLocalX
std::auto_ptr< TFileDirectory > tfd
bool tidIsDoubleSide(const DetId &id) const
T const * product() 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
void clear()
set to empty values
void bookGlobalHists(DirectoryWrapper &tfd)
DirectoryWrapper(const DirectoryWrapper &upDir, const std::string &newDir, const std::string &basedir, bool useDqmMode)
TrackerValidationVariables avalidator_
uint32_t tecStereo(const DetId &id) const
virtual const DetIdContainer & detUnitIds() const
Returm a vector of all GeomDetUnit DetIds.
TProfile * ResXvsXProfile
std::vector< TH1 * > vTrackProfiles_
unsigned int pxfSide(const DetId &id) const
void bookDirHists(DirectoryWrapper &tfd, const Alignable &ali, const TrackerTopology *tTopo)
static const char * idToString(align::StructureType type)
std::map< int, TrackerOfflineValidation::ModuleHistos > mPxbResiduals_
virtual void endJob() override
std::string histNameNormY
uint32_t tibStereo(const DetId &id) const
Detector det() const
get the detector field from this detid
const edm::ParameterSet parSet_
TrackerOfflineValidation(const edm::ParameterSet &)
float Fwhm(const TH1 *hist) const
unsigned int tecWheel(const DetId &id) const
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
tuple size
Write out results.
const edm::EventSetup * lastSetup_
unsigned int pxfPanel(const DetId &id) const
unsigned int pxfBlade(const DetId &id) const
TProfile * ResYvsXProfile
virtual 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
virtual const TrackerGeomDet * idToDet(DetId) const
bool isBarrel(uint32_t subDetId)