138 const std::string& basedir,
bool useDqmMode)
142 if (newDir.length()!=0){
150 if (newDir.length()==0)
tfd.reset(&(*upDir.
tfd));
165 if (newDir.length()==0){
174 if (newDir.length()!=0){
183 template <
typename T> TH1*
make(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX);
184 template <
typename T> TH1*
make(
const char*
name,
const char*
title,
int nBinX,
double *xBins);
185 template <
typename T> TH1*
make(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX,
int nBinY,
double minBinY,
double maxBinY);
186 template <
typename T> TH1*
make(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX,
double minBinY,
double maxBinY);
188 std::auto_ptr<TFileDirectory>
tfd;
210 std::vector<TrackerOfflineValidation::SummaryContainer>& vLevelProfiles);
212 void fillTree(TTree&
tree,
const std::map<int, TrackerOfflineValidation::ModuleHistos>& moduleHist_,
228 int nBinsX,
double lowX,
double highX);
231 int nBinsX,
double lowX,
double highX);
234 int nBinsX,
double lowX,
double highX,
double lowY,
double highY);
237 int& nBinsX,
double& lowerBoundX,
double& upperBoundX);
252 template <
class OBJECT_TYPE>
int GetIndex(
const std::vector<OBJECT_TYPE*>& vec,
const TString&
name);
296 template <
class OBJECT_TYPE>
300 for (
typename std::vector<OBJECT_TYPE*>::const_iterator iter = vec.begin(), iterEnd = vec.end();
301 iter != iterEnd; ++iter, ++
result) {
302 if (*iter && (*iter)->GetName() ==
name)
return result;
304 edm::LogError(
"Alignment") <<
"@SUB=TrackerOfflineValidation::GetIndex" <<
" could not find " <<
name;
309 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TH1F>(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX){
310 if(dqmMode){theDbe->setCurrentFolder(directoryString);
return theDbe->book1D(
name,
title,nBinX,minBinX,maxBinX)->getTH1();}
311 else{
return tfd->make<TH1F>(
name,
title,nBinX,minBinX,maxBinX);}
314 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TProfile>(
const char*
name,
const char*
title,
int nBinX,
double *xBins){
316 theDbe->setCurrentFolder(directoryString);
318 TProfile *tmpProfile=
new TProfile(
name,
title,nBinX,xBins);
319 tmpProfile->SetDirectory(0);
320 return theDbe->bookProfile(
name,tmpProfile)->getTH1();
322 else{
return tfd->make<TProfile>(
name,
title,nBinX,xBins);}
325 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TProfile>(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX){
327 theDbe->setCurrentFolder(directoryString);
329 TProfile *tmpProfile=
new TProfile(
name,
title,nBinX,minBinX,maxBinX);
330 tmpProfile->SetDirectory(0);
331 return theDbe->bookProfile(
name,tmpProfile)->getTH1();
333 else{
return tfd->make<TProfile>(
name,
title,nBinX,minBinX,maxBinX);}
336 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TProfile>(
const char*
name ,
const char*
title,
int nbinX,
double minX ,
double maxX,
double minY,
double maxY){
338 theDbe->setCurrentFolder(directoryString);
347 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TH2F>(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX,
int nBinY,
double minBinY,
double maxBinY){
348 if(dqmMode){theDbe->setCurrentFolder(directoryString);
return theDbe->book2D(
name,
title,nBinX,minBinX,maxBinX,nBinY,minBinY,maxBinY)->getTH1();}
349 else{
return tfd->make<TH2F>(
name,
title,nBinX,minBinX,maxBinX,nBinY,minBinY,maxBinY);}
357 : parSet_(iConfig), bareTkGeomPtr_(0), lCoorHistOn_(parSet_.getParameter<bool>(
"localCoorHistosOn")),
358 moduleLevelHistsTransient_(parSet_.getParameter<bool>(
"moduleLevelHistsTransient")),
359 moduleLevelProfiles_(parSet_.getParameter<bool>(
"moduleLevelProfiles")),
360 stripYResiduals_(parSet_.getParameter<bool>(
"stripYResiduals")),
361 useFwhm_(parSet_.getParameter<bool>(
"useFwhm")),
362 useFit_(parSet_.getParameter<bool>(
"useFit")),
363 useOverflowForRMS_(parSet_.getParameter<bool>(
"useOverflowForRMS")),
364 dqmMode_(parSet_.getParameter<bool>(
"useInDqmMode")),
365 moduleDirectory_(parSet_.getParameter<std::string>(
"moduleDirectoryInOutput"))
399 edm::LogInfo(
"TrackerOfflineValidation") <<
"There are " << newBareTkGeomPtr->
detIds().size()
400 <<
" dets in the Geometry record.\n"
401 <<
"Out of these "<<newBareTkGeomPtr->
detUnitIds().size()
405 std::string globDir(
"GlobalTrackVariables");
415 <<
"TrackerGeometry changed, but will not re-book hists!";
426 "Track #eta;#eta_{Track};Number of Tracks",
429 "Track #phi;#phi_{Track};Number of Tracks",
432 "Track # of valid hits;# of valid hits _{Track};Number of Tracks",
435 "Track # of lost hits;# of lost hits _{Track};Number of Tracks",
438 "Curvature #kappa;#kappa_{Track};Number of Tracks",
441 "Curvature |#kappa| Positive Tracks;|#kappa_{pos Track}|;Number of Tracks",
444 "Curvature |#kappa| Negative Tracks;|#kappa_{neg Track}|;Number of Tracks",
447 "Curvature |#kappa| Tracks Difference;|#kappa_{Track}|;# Pos Tracks - # Neg Tracks",
450 "#chi^{2};#chi^{2}_{Track};Number of Tracks",
453 "#chi^{2} probability;#chi^{2}prob_{Track};Number of Tracks",
456 "#chi^{2}/ndof;#chi^{2}/ndof;Number of Tracks",
459 "p_{T}^{track};p_{T}^{track} [GeV];Number of Tracks",
462 "#delta{p_{T}/p_{T}^{track}};#delta_{p_{T}/p_{T}^{track}};Number of Tracks",
466 "Transverse Impact Parameter vs. #phi;#phi_{Track};#LT d_{0} #GT [cm]",
469 "Longitudinal Impact Parameter vs. #phi;#phi_{Track};#LT d_{z} #GT [cm]",
472 "Transverse Impact Parameter vs. #eta;#eta_{Track};#LT d_{0} #GT [cm]",
475 "Longitudinal Impact Parameter vs. #eta;#eta_{Track};#LT d_{z} #GT [cm]",
478 "#chi^{2} vs. #phi;#phi_{Track};#LT #chi^{2} #GT",
481 "#chi^{2} probablility vs. #phi;#phi_{Track};#LT #chi^{2} probability#GT",
484 "#chi^{2} probablility vs. |d_{0}|;|d_{0}|[cm];#LT #chi^{2} probability#GT",
487 "#chi^{2}/ndof vs. #phi;#phi_{Track};#LT #chi^{2}/ndof #GT",
490 "#chi^{2} vs. #eta;#eta_{Track};#LT #chi^{2} #GT",
493 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.};
495 "norm #chi^{2} vs. p_{T}_{Track}; p_{T}_{Track};#LT #chi^{2}/ndof #GT",
499 "#chi^{2}/ndof vs. p_{Track};p_{Track};#LT #chi^{2}/ndof #GT",
502 "#chi^{2} probability vs. #eta;#eta_{Track};#LT #chi^{2} probability #GT",
505 "#chi^{2}/ndof vs. #eta;#eta_{Track};#LT #chi^{2}/ndof #GT",
508 "#kappa vs. #phi;#phi_{Track};#kappa",
511 "#kappa vs. #eta;#eta_{Track};#kappa",
514 "#delta_{p_{T}}/p_{T}^{track};#phi^{track};#delta_{p_{T}}/p_{T}^{track}",
517 "#delta_{p_{T}}/p_{T}^{track};#eta^{track};#delta_{p_{T}}/p_{T}^{track}",
521 "Transverse Impact Parameter vs. #phi;#phi_{Track};d_{0} [cm]",
522 100, -3.15, 3.15, 100,-1.,1.) );
524 "Longitudinal Impact Parameter vs. #phi;#phi_{Track};d_{z} [cm]",
525 100, -3.15, 3.15, 100,-100.,100.));
527 "Transverse Impact Parameter vs. #eta;#eta_{Track};d_{0} [cm]",
528 100, -3.15, 3.15, 100,-1.,1.));
530 "Longitudinal Impact Parameter vs. #eta;#eta_{Track};d_{z} [cm]",
531 100, -3.15, 3.15, 100,-100.,100.));
533 "#chi^{2} vs. #phi;#phi_{Track};#chi^{2}",
534 100, -3.15, 3.15, 500, 0., 500.));
536 "#chi^{2} probability vs. #phi;#phi_{Track};#chi^{2} probability",
537 100, -3.15, 3.15, 100, 0., 1.));
539 "#chi^{2} probability vs. |d_{0}|;|d_{0}| [cm];#chi^{2} probability",
540 100, 0, 80, 100, 0., 1.));
542 "#chi^{2}/ndof vs. #phi;#phi_{Track};#chi^{2}/ndof",
543 100, -3.15, 3.15, 100, 0., 10.));
545 "#chi^{2} vs. #eta;#eta_{Track};#chi^{2}",
546 100, -3.15, 3.15, 500, 0., 500.));
548 "#chi^{2} probaility vs. #eta;#eta_{Track};#chi^{2} probability",
549 100, -3.15, 3.15, 100, 0., 1.));
551 "#chi^{2}/ndof vs. #eta;#eta_{Track};#chi^{2}/ndof",
552 100,-3.15,3.15, 100, 0., 10.));
554 "#kappa vs. #phi;#phi_{Track};#kappa",
555 100,-3.15,3.15, 100, .0,.05));
557 "#kappa vs. #eta;#eta_{Track};#kappa",
558 100,-3.15,3.15, 100, .0,.05));
560 "#kappa vs. #chi^{2}/ndof;#chi^{2}/ndof;#kappa",
561 100,0.,10, 100,-.03,.03));
565 "#momentum vs. #resX in pixB;#momentum;#resX",
566 15,0.,15., 200, -0.1,0.1));
568 "#momentum vs. #resX in pixE;#momentum;#resX",
569 15,0.,15., 200, -0.1,0.1));
571 "#momentum vs. #resX in TIB;#momentum;#resX",
572 15,0.,15., 200, -0.1,0.1));
574 "#momentum vs. #resX in TID;#momentum;#resX",
575 15,0.,15., 200, -0.1,0.1));
577 "#momentum vs. #resX in TOB;#momentum;#resX",
578 15,0.,15., 200, -0.1,0.1));
580 "#momentum vs. #resX in TEC;#momentum;#resX",
581 15,0.,15., 200, -0.1,0.1));
585 "#momentum vs. #resY in pixB;#momentum;#resY",
586 15,0.,15., 200, -0.1,0.1));
588 "#momentum vs. #resY in pixE;#momentum;#resY",
589 15,0.,15., 200, -0.1,0.1));
597 std::vector<Alignable*> alivec(ali.
components());
599 std::string structurename = aliobjid.
typeToName((alivec)[
i]->alignableObjectId());
600 LogDebug(
"TrackerOfflineValidation") <<
"StructureName = " << structurename;
602 dirname << structurename;
604 if (structurename !=
"Strip" && structurename !=
"Pixel") dirname <<
"_" <<
i+1;
606 if (structurename.find(
"Endcap",0) != std::string::npos ) {
610 }
else if( !(this->
isDetOrDetUnit( (alivec)[i]->alignableObjectId()) )
640 std::stringstream histoname, histotitle, normhistoname, normhistotitle,
641 yhistoname, yhistotitle,
642 xprimehistoname, xprimehistotitle, normxprimehistoname, normxprimehistotitle,
643 yprimehistoname, yprimehistotitle, normyprimehistoname, normyprimehistotitle,
644 localxname, localxtitle, localyname, localytitle,
645 resxvsxprofilename, resxvsxprofiletitle, resyvsxprofilename, resyvsxprofiletitle,
646 resxvsyprofilename, resxvsyprofiletitle, resyvsyprofilename, resyvsyprofiletitle;
648 std::string wheel_or_layer;
650 if( this->
isEndCap(static_cast<uint32_t>(subdetandlayer.first)) ) wheel_or_layer =
"_wheel_";
651 else if ( this->
isBarrel(static_cast<uint32_t>(subdetandlayer.first)) ) wheel_or_layer =
"_layer_";
652 else edm::LogWarning(
"TrackerOfflineValidation") <<
"@SUB=TrackerOfflineValidation::bookHists"
653 <<
"Unknown subdetid: " << subdetandlayer.first;
655 histoname <<
"h_residuals_subdet_" << subdetandlayer.first
656 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
657 yhistoname <<
"h_y_residuals_subdet_" << subdetandlayer.first
658 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
659 xprimehistoname <<
"h_xprime_residuals_subdet_" << subdetandlayer.first
660 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
661 yprimehistoname <<
"h_yprime_residuals_subdet_" << subdetandlayer.first
662 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
663 normhistoname <<
"h_normresiduals_subdet_" << subdetandlayer.first
664 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
665 normxprimehistoname <<
"h_normxprimeresiduals_subdet_" << subdetandlayer.first
666 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
667 normyprimehistoname <<
"h_normyprimeresiduals_subdet_" << subdetandlayer.first
668 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
669 histotitle <<
"X Residual for module " <<
id.rawId() <<
";x_{tr} - x_{hit} [cm]";
670 yhistotitle <<
"Y Residual for module " <<
id.rawId() <<
";y_{tr} - y_{hit} [cm]";
671 normhistotitle <<
"Normalized Residual for module " <<
id.rawId() <<
";x_{tr} - x_{hit}/#sigma";
672 xprimehistotitle <<
"X' Residual for module " <<
id.rawId() <<
";(x_{tr} - x_{hit})' [cm]";
673 normxprimehistotitle <<
"Normalized X' Residual for module " <<
id.rawId() <<
";(x_{tr} - x_{hit})'/#sigma";
674 yprimehistotitle <<
"Y' Residual for module " <<
id.rawId() <<
";(y_{tr} - y_{hit})' [cm]";
675 normyprimehistotitle <<
"Normalized Y' Residual for module " <<
id.rawId() <<
";(y_{tr} - y_{hit})'/#sigma";
678 localxname <<
"h_localx_subdet_" << subdetandlayer.first
679 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
680 localyname <<
"h_localy_subdet_" << subdetandlayer.first
681 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
682 localxtitle <<
"u local for module " <<
id.rawId() <<
"; u_{tr,r}";
683 localytitle <<
"v local for module " <<
id.rawId() <<
"; v_{tr,r}";
685 resxvsxprofilename <<
"p_residuals_x_vs_x_subdet_" << subdetandlayer.first
686 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
687 resyvsxprofilename <<
"p_residuals_y_vs_x_subdet_" << subdetandlayer.first
688 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
689 resxvsyprofilename <<
"p_residuals_x_vs_y_subdet_" << subdetandlayer.first
690 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
691 resyvsyprofilename <<
"p_residuals_y_vs_y_subdet_" << subdetandlayer.first
692 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
693 resxvsxprofiletitle <<
"U Residual vs u for module " <<
id.rawId() <<
"; u_{tr,r} ;(u_{tr} - u_{hit})/tan#alpha [cm]";
694 resyvsxprofiletitle <<
"V Residual vs u for module " <<
id.rawId() <<
"; u_{tr,r} ;(v_{tr} - v_{hit})/tan#beta [cm]";
695 resxvsyprofiletitle <<
"U Residual vs v for module " <<
id.rawId() <<
"; v_{tr,r} ;(u_{tr} - u_{hit})/tan#alpha [cm]";
696 resyvsyprofiletitle <<
"V Residual vs v for module " <<
id.rawId() <<
"; v_{tr,r} ;(v_{tr} - v_{hit})/tan#beta [cm]";
702 double xmin = 0., xmax = 0.;
703 double ymin = -0.1, ymax = 0.1;
707 if (
dqmMode_) moduleLevelHistsTransient =
false;
713 histoname.str().c_str(),histotitle.str().c_str(),
717 normhistoname.str().c_str(),normhistotitle.str().c_str(),
722 xprimehistoname.str().c_str(),xprimehistotitle.str().c_str(),
726 normxprimehistoname.str().c_str(),normxprimehistotitle.str().c_str(),
732 histStruct.
LocalX = this->
bookTH1F(moduleLevelHistsTransient, tfd,
733 localxname.str().c_str(),localxtitle.str().c_str(),
735 histStruct.
LocalY = this->
bookTH1F(moduleLevelHistsTransient, tfd,
736 localyname.str().c_str(),localytitle.str().c_str(),
739 resxvsxprofilename.str().c_str(),resxvsxprofiletitle.str().c_str(),
740 nbins, xmin, xmax, ymin, ymax);
743 resxvsyprofilename.str().c_str(),resxvsyprofiletitle.str().c_str(),
744 nbins, xmin, xmax, ymin, ymax);
751 yprimehistoname.str().c_str(),yprimehistotitle.str().c_str(),
756 yhistoname.str().c_str(), yhistotitle.str().c_str(),
761 normyprimehistoname.str().c_str(),normyprimehistotitle.str().c_str(),
768 resyvsxprofilename.str().c_str(),resyvsxprofiletitle.str().c_str(),
769 nbins, xmin, xmax, ymin, ymax);
772 resyvsyprofilename.str().c_str(),resyvsyprofiletitle.str().c_str(),
773 nbins, xmin, xmax, ymin, ymax);
782 int nBinsX,
double lowX,
double highX)
785 vDeleteObjects_.push_back(
new TH1F(histName, histTitle, nBinsX, lowX, highX));
789 return tfd.
make<TH1F>(histName, histTitle, nBinsX, lowX, highX);
793 int nBinsX,
double lowX,
double highX)
796 TProfile *
profile =
new TProfile(histName, histTitle, nBinsX, lowX, highX);
801 return (TProfile*)tfd.
make<TProfile>(histName, histTitle, nBinsX, lowX, highX);
806 int nBinsX,
double lowX,
double highX,
double lowY,
double highY)
809 TProfile *
profile =
new TProfile(histName, histTitle, nBinsX, lowX, highX, lowY, highY);
814 return (TProfile*)tfd.
make<TProfile>(histName, histTitle, nBinsX, lowX, highX, lowY, highY);
850 int& nBinsX,
double& lowerBoundX,
double& upperBoundX)
903 if(targetHist && sourceHist) {
904 targetHist->SetBinContent(bin, sourceHist->GetMean(1));
905 if(
useFwhm_) targetHist->SetBinError(bin,
Fwhm(sourceHist)/2.);
906 else targetHist->SetBinError(bin, sourceHist->GetRMS(1) );
960 <<
"[TrackerOfflineValidation] Error, tried to get reference for non-tracker subdet " << subdetid
961 <<
" from detector " << detid.
det();
976 std::vector<TrackerValidationVariables::AVTrackStruct> vTrackstruct;
979 for (std::vector<TrackerValidationVariables::AVTrackStruct>::const_iterator itT = vTrackstruct.begin();
980 itT != vTrackstruct.end();
989 vTrackHistos_[numOfValidHitsindex]->Fill(itT->numberOfValidHits);
991 vTrackHistos_[numOfLostHitsindex]->Fill(itT->numberOfLostHits);
1008 if (itT->ptError != 0.) {
1010 vTrackHistos_[ptResolutionindex]->Fill(itT->ptError/itT->pt);
1026 vTrackProfiles_[chiProbabsd0index]->Fill(fabs(itT->d0),itT->chi2Prob);
1062 vTrack2DHistos_[chiProbabsd0index_2d]->Fill(fabs(itT->d0),itT->chi2Prob);
1079 for (std::vector<TrackerValidationVariables::AVHitStruct>::const_iterator itH = itT->hits.begin();
1080 itH != itT->hits.end();
1088 histStruct.
ResHisto->Fill(itH->resX);
1089 if(itH->resErrX != 0) histStruct.
NormResHisto->Fill(itH->resX/itH->resErrX);
1095 if (itH->resXprime != -999.) {
1126 float tgalpha =
tan(itH->localAlpha);
1127 if ( fabs(tgalpha)!=0 ){
1128 histStruct.
LocalX->Fill(itH->localXnorm, tgalpha*tgalpha);
1129 histStruct.
LocalY->Fill(itH->localYnorm, tgalpha*tgalpha);
1141 histStruct.
ResXvsXProfile->Fill(itH->localXnorm, itH->resXatTrkY/tgalpha, tgalpha*tgalpha);
1142 histStruct.
ResXvsYProfile->Fill(itH->localYnorm, itH->resXatTrkY/tgalpha, tgalpha*tgalpha);
1149 if(itH->resXprimeErr != 0 && itH->resXprimeErr != -999 ) {
1154 if (itH->resYprime != -999.) {
1170 float tgbeta =
tan(itH->localBeta);
1171 if ( fabs(tgbeta)!=0 ){
1184 histStruct.
ResYvsXProfile->Fill(itH->localXnorm, itH->resY/tgbeta, tgbeta*tgbeta);
1185 histStruct.
ResYvsYProfile->Fill(itH->localYnorm, itH->resY/tgbeta, tgbeta*tgbeta);
1190 if (itH->resYprimeErr != 0 && itH->resYprimeErr != -999. ) {
1220 std::vector<TrackerOfflineValidation::SummaryContainer> vTrackerprofiles;
1229 TTree *
tree = fs->
make<TTree>(
"TkOffVal",
"TkOffVal");
1235 tree->Branch(
"TkOffTreeVariables", &treeMemPtr);
1244 delete treeMemPtr; treeMemPtr = 0;
1251 std::vector<TrackerOfflineValidation::SummaryContainer>& vLevelProfiles)
1253 std::vector<Alignable*> alivec(ali.
components());
1254 if( this->
isDetOrDetUnit((alivec)[0]->alignableObjectId()) )
return;
1256 for(
int iComp=0, iCompEnd = ali.
components().size();iComp < iCompEnd; ++iComp) {
1257 std::vector< TrackerOfflineValidation::SummaryContainer > vProfiles;
1258 std::string structurename = aliobjid.
typeToName((alivec)[iComp]->alignableObjectId());
1260 LogDebug(
"TrackerOfflineValidation") <<
"StructureName = " << structurename;
1262 dirname << structurename;
1265 if (structurename !=
"Strip" && structurename !=
"Pixel") dirname <<
"_" << iComp+1;
1267 if( !(this->
isDetOrDetUnit( (alivec)[iComp]->alignableObjectId()) )
1272 TH1 *hY = vLevelProfiles[iComp].sumYResiduals_;
1273 TH1 *hNormY = vLevelProfiles[iComp].sumNormYResiduals_;
1274 for(uint
n = 0;
n < vProfiles.size(); ++
n) {
1276 vLevelProfiles[iComp].sumXResiduals_->Add(vProfiles[n].sumXResiduals_);
1277 vLevelProfiles[iComp].sumNormXResiduals_->Add(vProfiles[n].sumNormXResiduals_);
1278 if (hY) hY->Add(vProfiles[n].sumYResiduals_);
1279 if (hNormY) hNormY->Add(vProfiles[n].sumNormYResiduals_);
1283 this->
fitResiduals(vLevelProfiles[iComp].sumXResiduals_);
1284 this->
fitResiduals(vLevelProfiles[iComp].sumNormXResiduals_);
1300 const uint aliSize = ali.
components().size();
1303 const char *aliTypeName = aliobjid.
typeToName(alitype).c_str();
1304 const char *aliSubtypeName = aliobjid.
typeToName(subtype).c_str();
1305 const char *typeName = aliobjid.
typeToName(type).c_str();
1307 const DetId aliDetId = ali.
id();
1317 const uint subcompSize = ali.
components()[0]->components().size();
1319 const TString
title(Form(
"Summary for substructures in %s %d;%s;",aliTypeName,i,aliSubtypeName));
1321 sumContainer.summaryXResiduals_ = tfd.
make<TH1F>(Form(
"h_summaryX%s_%d",aliTypeName,i),
1322 title +
"#LT #Delta x' #GT",
1323 aliSize, 0.5, aliSize+0.5);
1324 sumContainer.summaryNormXResiduals_ = tfd.
make<TH1F>(Form(
"h_summaryNormX%s_%d",aliTypeName,i),
1325 title +
"#LT #Delta x'/#sigma #GT",
1326 aliSize,0.5,aliSize+0.5);
1329 sumContainer.summaryYResiduals_ = tfd.
make<TH1F>(Form(
"h_summaryY%s_%d",aliTypeName,i),
1330 title +
"#LT #Delta y' #GT",
1331 aliSize, 0.5, aliSize+0.5);
1332 sumContainer.summaryNormYResiduals_ = tfd.
make<TH1F>(Form(
"h_summaryNormY%s_%d",aliTypeName,i),
1333 title +
"#LT #Delta y'/#sigma #GT",
1334 aliSize,0.5,aliSize+0.5);
1338 if (subcompSize != 2) {
1341 <<
"Det with " << subcompSize <<
" components";
1344 const TString
title(Form(
"Summary for substructures in %s %d;%s;", aliTypeName, i,
1347 sumContainer.summaryXResiduals_
1348 = tfd.
make<TH1F>(Form(
"h_summaryX%s_%d", aliTypeName, i),
1349 title +
"#LT #Delta x' #GT", (2*aliSize), 0.5, 2*aliSize+0.5);
1350 sumContainer.summaryNormXResiduals_
1351 = tfd.
make<TH1F>(Form(
"h_summaryNormX%s_%d", aliTypeName, i),
1352 title +
"#LT #Delta x'/#sigma #GT", (2*aliSize), 0.5, 2*aliSize+0.5);
1355 sumContainer.summaryYResiduals_
1356 = tfd.
make<TH1F>(Form(
"h_summaryY%s_%d", aliTypeName, i),
1357 title +
"#LT #Delta y' #GT", (2*aliSize), 0.5, 2*aliSize+0.5);
1358 sumContainer.summaryNormYResiduals_
1359 = tfd.
make<TH1F>(Form(
"h_summaryNormY%s_%d", aliTypeName, i),
1360 title +
"#LT #Delta y'/#sigma #GT", (2*aliSize), 0.5, 2*aliSize+0.5);
1364 edm::LogError(
"TrackerOfflineValidation") <<
"@SUB=TrackerOfflineValidation::bookSummaryHists"
1365 <<
"No summary histogramm for hierarchy level "
1366 << aliTypeName <<
" in subdet " << aliDetId.
subdetId();
1373 double xmin = 0., xmax = 0.;
1374 const TString sumTitle(Form(
"Residual for %s %d in %s;", aliTypeName, i, typeName));
1378 sumContainer.sumXResiduals_ = tfd.
make<TH1F>(Form(
"h_Xprime_%s_%d", aliTypeName, i),
1383 sumContainer.sumNormXResiduals_ = tfd.
make<TH1F>(Form(
"h_NormXprime_%s_%d",aliTypeName,i),
1388 sumContainer.sumYResiduals_ = tfd.
make<TH1F>(Form(
"h_Yprime_%s_%d",aliTypeName,i),
1393 sumContainer.sumNormYResiduals_ = tfd.
make<TH1F>(Form(
"h_NormYprime_%s_%d",aliTypeName,i),
1402 for(uint
k = 0;
k < aliSize; ++
k) {
1415 for(uint
k = 0;
k < aliSize; ++
k) {
1416 for(uint
j = 0;
j < subcompSize; ++
j) {
1429 return sumContainer;
1436 float max = hist->GetMaximum();
1437 int left = -1, right = -1;
1438 for(
unsigned int i = 1, iEnd = hist->GetNbinsX();
i <= iEnd; ++
i) {
1439 if(hist->GetBinContent(
i) < max/2. && hist->GetBinContent(
i+1) > max/2. && left == -1) {
1440 if(max/2. - hist->GetBinContent(
i) < hist->GetBinContent(
i+1) - max/2.) {
1448 if(left != -1 && right == -1) {
1449 if(hist->GetBinContent(
i) > max/2. && hist->GetBinContent(
i+1) < max/2.) {
1450 if( hist->GetBinContent(
i) - max/2. < max/2. - hist->GetBinContent(
i+1)) {
1459 return hist->GetXaxis()->GetBinCenter(right) - hist->GetXaxis()->GetBinCenter(left);
1465 const std::map<int, TrackerOfflineValidation::ModuleHistos>& moduleHist_,
1469 for(std::map<int, TrackerOfflineValidation::ModuleHistos>::const_iterator it = moduleHist_.begin(),
1470 itEnd= moduleHist_.end(); it != itEnd;++it ) {
1474 DetId detId_ = it->first;
1481 unsigned int whichHalfBarrel(1), rawId(detId_.
rawId());
1482 if( (rawId>=302056964 && rawId<302059300) || (rawId>=302123268 && rawId<302127140) ||
1483 (rawId>=302189572 && rawId<302194980) ) whichHalfBarrel=2;
1485 treeMem.
half = whichHalfBarrel;
1490 unsigned int whichHalfCylinder(1), rawId(detId_.
rawId());
1491 if( (rawId>=352394500 && rawId<352406032) || (rawId>=352460036 && rawId<352471568) ||
1492 (rawId>=344005892 && rawId<344017424) || (rawId>=344071428 && rawId<344082960) ) whichHalfCylinder=2;
1495 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;
1530 treeMem.
side = tobId.
rod()[0];
1531 treeMem.
rod = tobId.
rod()[1];
1552 treeMem.
posX = gPModule.
x();
1553 treeMem.
posY = gPModule.
y();
1554 treeMem.
posZ = gPModule.
z();
1559 LocalPoint lUDirection(1.,0.,0.), lVDirection(0.,1.,0.), lWDirection(0.,0.,1.);
1561 gVDirection = surface.
toGlobal(lVDirection),
1562 gWDirection = surface.
toGlobal(lWDirection);
1563 double dR(999.),
dPhi(999.), dZ(999.);
1565 dR = gWDirection.perp() - gPModule.
perp();
1567 dZ = gVDirection.z() - gPModule.
z();
1572 dZ = gWDirection.z() - gPModule.
z();
1575 dR = gVDirection.perp() - gPModule.
perp();
1577 dZ = gWDirection.z() - gPModule.
z();
1585 treeMem.
entries =
static_cast<UInt_t>(it->second.ResXprimeHisto->GetEntries());
1586 treeMem.
meanX = it->second.ResXprimeHisto->GetMean();
1587 treeMem.
rmsX = it->second.ResXprimeHisto->GetRMS();
1593 std::pair<float,float> fitResult1 = this->
fitResiduals(it->second.ResXprimeHisto);
1594 treeMem.
fitMeanX = fitResult1.first;
1597 std::pair<float,float> fitResult2 = this->
fitResiduals(it->second.NormResXprimeHisto);
1605 int numberOfBins=it->second.ResXprimeHisto->GetNbinsX();
1607 treeMem.
numberOfOverflows = it->second.ResXprimeHisto->GetBinContent(numberOfBins+1);
1608 treeMem.
numberOfOutliers = it->second.ResXprimeHisto->GetBinContent(0)+it->second.ResXprimeHisto->GetBinContent(numberOfBins+1);
1611 treeMem.
meanNormX = it->second.NormResXprimeHisto->GetMean();
1612 treeMem.
rmsNormX = it->second.NormResXprimeHisto->GetRMS();
1615 it->second.NormResXprimeHisto->GetStats(stats);
1617 if (stats[0]) treeMem.
chi2PerDofX = stats[3]/stats[0];
1620 treeMem.
histNameX = it->second.ResXprimeHisto->GetName();
1621 treeMem.
histNameNormX = it->second.NormResXprimeHisto->GetName();
1625 treeMem.
meanLocalX = it->second.ResHisto->GetMean();
1626 treeMem.
rmsLocalX = it->second.ResHisto->GetRMS();
1632 if (it->second.ResYHisto) treeMem.
histNameLocalY = it->second.ResYHisto->GetName();
1637 if (it->second.ResYprimeHisto) {
1638 TH1 *
h = it->second.ResYprimeHisto;
1639 treeMem.
meanY = h->GetMean();
1640 treeMem.
rmsY = h->GetRMS();
1643 std::pair<float,float> fitMeanSigma = this->
fitResiduals(h);
1644 treeMem.
fitMeanY = fitMeanSigma.first;
1645 treeMem.
fitSigmaY = fitMeanSigma.second;
1653 if (it->second.NormResYprimeHisto) {
1654 TH1 *
h = it->second.NormResYprimeHisto;
1658 if (stats[0]) treeMem.
chi2PerDofY = stats[3]/stats[0];
1661 std::pair<float,float> fitMeanSigma = this->
fitResiduals(h);
1669 if (it->second.ResXvsXProfile) {
1670 TH1 *
h = it->second.ResXvsXProfile;
1675 if (it->second.ResXvsYProfile) {
1676 TH1 *
h = it->second.ResXvsYProfile;
1681 if (it->second.ResYvsXProfile) {
1682 TH1 *
h = it->second.ResYvsXProfile;
1687 if (it->second.ResYvsYProfile) {
1688 TH1 *
h = it->second.ResYvsYProfile;
1700 std::pair<float,float>
1703 std::pair<float,float> fitResult(9999., 9999.);
1704 if (!hist || hist->GetEntries() < 20)
return fitResult;
1706 float mean = hist->GetMean();
1707 float sigma = hist->GetRMS();
1712 TF1 func(
"tmp",
"gaus", mean - 2.*sigma, mean + 2.*sigma);
1713 if (0 == hist->Fit(&func,
"QNR")) {
1714 mean = func.GetParameter(1);
1715 sigma = func.GetParameter(2);
1717 func.SetRange(mean - 3.*sigma, mean + 3.*sigma);
1720 if (0 == hist->Fit(&func,
"Q0LR")) {
1721 if (hist->GetFunction(func.GetName())) {
1722 hist->GetFunction(func.GetName())->ResetBit(TF1::kNotDraw);
1724 fitResult.first = func.GetParameter(1);
1725 fitResult.second = func.GetParameter(2);
1729 edm::LogWarning(
"Alignment") <<
"@SUB=TrackerOfflineValidation::fitResiduals"
1730 <<
"Caught this exception during ROOT fit: "
1741 int nbins = histo->GetNbinsX();
1744 double *
x =
new double[
nbins];
1745 double *
y =
new double[
nbins];
1747 x[
j] = histo->GetBinCenter(
j+1);
1748 y[
j] = histo->GetBinContent(
j+1);
1750 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 isDoubleSide() const
unsigned int panel() const
panel id
std::vector< TH1 * > vDeleteObjects_
void bookDirHists(DirectoryWrapper &tfd, const Alignable &ali, const AlignableObjectId &aliobjid)
std::map< int, TrackerOfflineValidation::ModuleHistos > mPxeResiduals_
std::vector< TH1 * > vTrackHistos_
~TrackerOfflineValidation()
unsigned int layer() const
layer id
void bookHists(DirectoryWrapper &tfd, const Alignable &ali, align::StructureType type, int i, const AlignableObjectId &aliobjid)
TH1 * make(const char *name, const char *title, int nBinX, double minBinX, double maxBinX)
Float_t numberOfOverflows
bool isPixel(uint32_t subDetId)
void fillTree(TTree &tree, const std::map< int, TrackerOfflineValidation::ModuleHistos > &moduleHist_, TkOffTreeVariables &treeMem, const TrackerGeometry &tkgeom)
bool isDoubleSide() 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)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::string directoryString
container to hold data to be written into TTree
std::string profileNameResXvsX
const bool stripYResiduals_
const bool useOverflowForRMS_
Geom::Phi< T > phi() const
edm::ESHandle< TrackerGeometry > tkGeom_
int GetIndex(const std::vector< OBJECT_TYPE * > &vec, const TString &name)
unsigned int ladder() const
ladder id
const std::string & typeToName(align::StructureType type) const
Convert type to name.
float getMedian(const TH1 *hist) const
constexpr unsigned int subDetId[11]
ModuleHistos & getHistStructFromMap(const DetId &detid)
const bool moduleLevelProfiles_
Float_t numberOfUnderflows
void setSummaryBin(int bin, TH1 *targetHist, TH1 *sourceHist)
virtual Alignables components() const =0
Return vector of all direct components.
std::map< int, TrackerOfflineValidation::ModuleHistos > mTibResiduals_
std::vector< unsigned int > string() const
string id
unsigned int module() const
det id
unsigned int layer() const
layer id
unsigned int side() const
positive or negative id
TProfile * ResXvsYProfile
TH1 * summaryNormYResiduals_
std::vector< unsigned int > rod() const
rod id
std::string profileNameResYvsX
unsigned int blade() const
blade id
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)
std::vector< unsigned int > petal() const
petal id
const Surface::PositionType & position() const
The position (origin of the R.F.)
TH1 * summaryNormXResiduals_
std::string histNameNormX
double dPhi(double phi1, double phi2)
void getBinning(uint32_t subDetId, TrackerOfflineValidation::HistogrammType residualtype, int &nBinsX, double &lowerBoundX, double &upperBoundX)
const T & max(const T &a, const T &b)
unsigned int ring() const
ring id
Tan< T >::type tan(const T &t)
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
unsigned int module() const
det id
Allows conversion between type and name, and vice-versa.
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)
unsigned int module() const
det id
std::vector< unsigned int > module() const
det id
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::string histNameLocalY
virtual const GeomDet * idToDet(DetId) const
unsigned int disk() const
disk id
std::string histNameNormLocalX
bool isDetOrDetUnit(align::StructureType type)
std::map< int, TrackerOfflineValidation::ModuleHistos > mTobResiduals_
DirectoryWrapper(const std::string &newDir, const std::string &basedir, bool useDqmMode)
void collateSummaryHists(DirectoryWrapper &tfd, const Alignable &ali, int i, const AlignableObjectId &aliobjid, std::vector< TrackerOfflineValidation::SummaryContainer > &vLevelProfiles)
const std::string moduleDirectory_
std::pair< float, float > fitResiduals(TH1 *hist) const
unsigned int module() const
detector id
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
unsigned int side() const
positive or negative id
std::string histNameLocalX
std::auto_ptr< TFileDirectory > tfd
T const * product() const
void summarizeBinInContainer(int bin, SummaryContainer &targetContainer, SummaryContainer &sourceContainer)
void fillTrackQuantities(const edm::Event &, std::vector< AVTrackStruct > &v_avtrackout)
const bool moduleLevelHistsTransient_
bool isEndCap(uint32_t subDetId)
unsigned int wheel() const
wheel id
unsigned int layer() const
layer id
std::string profileNameResXvsY
void clear()
set to empty values
void bookGlobalHists(DirectoryWrapper &tfd)
const BoundPlane & surface() const
The nominal surface of the GeomDet.
DirectoryWrapper(const DirectoryWrapper &upDir, const std::string &newDir, const std::string &basedir, bool useDqmMode)
virtual const DetIdContainer & detUnitIds() const
Returm a vector of all GeomDetUnit DetIds.
unsigned int ring() const
ring id
TrackerOfflineValidation::SummaryContainer bookSummaryHists(DirectoryWrapper &tfd, const Alignable &ali, align::StructureType type, int i, const AlignableObjectId &aliobjid)
T * make() const
make new ROOT object
bool isDoubleSide() const
unsigned int side() const
positive or negative id
TProfile * ResXvsXProfile
std::vector< TH1 * > vTrackProfiles_
std::pair< int, int > typeAndLayerFromDetId(const DetId &detId) const
unsigned int module() const
detector id
std::map< int, TrackerOfflineValidation::ModuleHistos > mPxbResiduals_
std::string histNameNormY
Detector det() const
get the detector field from this detid
const edm::ParameterSet parSet_
TrackerOfflineValidation(const edm::ParameterSet &)
float Fwhm(const TH1 *hist) const
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
tuple size
Write out results.
TProfile * ResYvsXProfile
bool isDoubleSide() const
std::string profileNameResYvsY
unsigned int wheel() const
wheel id
bool isBarrel(uint32_t subDetId)