146 if (newDir.length()!=0){
154 if (newDir.length()==0)
tfd.reset(&(*upDir.
tfd));
169 if (newDir.length()==0){
178 if (newDir.length()!=0){
187 template <
typename T> TH1*
make(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX);
188 template <
typename T> TH1*
make(
const char*
name,
const char*
title,
int nBinX,
double *xBins);
189 template <
typename T> TH1*
make(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX,
int nBinY,
double minBinY,
double maxBinY);
190 template <
typename T> TH1*
make(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX,
double minBinY,
double maxBinY);
192 std::auto_ptr<TFileDirectory>
tfd;
203 virtual void endJob()
override;
212 std::vector<TrackerOfflineValidation::SummaryContainer>& vLevelProfiles);
215 void setUpTreeMembers(
const std::map<int, TrackerOfflineValidation::ModuleHistos>& moduleHist_,
231 int nBinsX,
double lowX,
double highX);
234 int nBinsX,
double lowX,
double highX);
237 int nBinsX,
double lowX,
double highX,
double lowY,
double highY);
240 int& nBinsX,
double& lowerBoundX,
double& upperBoundX);
255 template <
class OBJECT_TYPE>
int GetIndex(
const std::vector<OBJECT_TYPE*>& vec,
const TString&
name);
314 template <
class OBJECT_TYPE>
318 for (
typename std::vector<OBJECT_TYPE*>::const_iterator
iter = vec.begin(), iterEnd = vec.end();
320 if (*
iter && (*iter)->GetName() ==
name)
return result;
322 edm::LogError(
"Alignment") <<
"@SUB=TrackerOfflineValidation::GetIndex" <<
" could not find " <<
name;
327 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TH1F>(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX){
328 if(dqmMode){theDbe->setCurrentFolder(directoryString);
return theDbe->book1D(
name,
title,nBinX,minBinX,maxBinX)->getTH1();}
329 else{
return tfd->make<TH1F>(
name,
title,nBinX,minBinX,maxBinX);}
332 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TProfile>(
const char*
name,
const char*
title,
int nBinX,
double *xBins){
334 theDbe->setCurrentFolder(directoryString);
336 TProfile *tmpProfile=
new TProfile(
name,
title,nBinX,xBins);
337 tmpProfile->SetDirectory(0);
338 return theDbe->bookProfile(
name,tmpProfile)->getTH1();
340 else{
return tfd->make<TProfile>(
name,
title,nBinX,xBins);}
343 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TProfile>(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX){
345 theDbe->setCurrentFolder(directoryString);
347 TProfile *tmpProfile=
new TProfile(
name,
title,nBinX,minBinX,maxBinX);
348 tmpProfile->SetDirectory(0);
349 return theDbe->bookProfile(
name,tmpProfile)->getTH1();
351 else{
return tfd->make<TProfile>(
name,
title,nBinX,minBinX,maxBinX);}
354 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TProfile>(
const char*
name ,
const char*
title,
int nbinX,
double minX ,
double maxX,
double minY,
double maxY){
356 theDbe->setCurrentFolder(directoryString);
358 return (theDbe->bookProfile(
name,
title,nbinX,minX,maxX,dummy,minY,maxY)->getTH1());
361 return tfd->make<TProfile>(
name,
title,nbinX,minX,maxX,minY,maxY);
365 template <> TH1* TrackerOfflineValidation::DirectoryWrapper::make<TH2F>(
const char*
name,
const char*
title,
int nBinX,
double minBinX,
double maxBinX,
int nBinY,
double minBinY,
double maxBinY){
366 if(dqmMode){theDbe->setCurrentFolder(directoryString);
return theDbe->book2D(
name,
title,nBinX,minBinX,maxBinX,nBinY,minBinY,maxBinY)->getTH1();}
367 else{
return tfd->make<TH2F>(
name,
title,nBinX,minBinX,maxBinX,nBinY,minBinY,maxBinY);}
375 : parSet_(iConfig), bareTkGeomPtr_(0), lCoorHistOn_(parSet_.getParameter<bool>(
"localCoorHistosOn")),
376 moduleLevelHistsTransient_(parSet_.getParameter<bool>(
"moduleLevelHistsTransient")),
377 moduleLevelProfiles_(parSet_.getParameter<bool>(
"moduleLevelProfiles")),
378 stripYResiduals_(parSet_.getParameter<bool>(
"stripYResiduals")),
379 useFwhm_(parSet_.getParameter<bool>(
"useFwhm")),
380 useFit_(parSet_.getParameter<bool>(
"useFit")),
381 useOverflowForRMS_(parSet_.getParameter<bool>(
"useOverflowForRMS")),
382 dqmMode_(parSet_.getParameter<bool>(
"useInDqmMode")),
383 moduleDirectory_(parSet_.getParameter<std::
string>(
"moduleDirectoryInOutput"))
421 edm::LogInfo(
"TrackerOfflineValidation") <<
"There are " << newBareTkGeomPtr->
detIds().size()
422 <<
" dets in the Geometry record.\n"
423 <<
"Out of these "<<newBareTkGeomPtr->
detUnitIds().size()
435 std::vector<TrackerOfflineValidation::SummaryContainer> vTrackerprofiles;
447 <<
"TrackerGeometry changed, but will not re-book hists!";
458 "Track #eta;#eta_{Track};Number of Tracks",
461 "Track #phi;#phi_{Track};Number of Tracks",
464 "Track # of valid hits;# of valid hits _{Track};Number of Tracks",
467 "Track # of lost hits;# of lost hits _{Track};Number of Tracks",
470 "Curvature #kappa;#kappa_{Track};Number of Tracks",
473 "Curvature |#kappa| Positive Tracks;|#kappa_{pos Track}|;Number of Tracks",
476 "Curvature |#kappa| Negative Tracks;|#kappa_{neg Track}|;Number of Tracks",
479 "Curvature |#kappa| Tracks Difference;|#kappa_{Track}|;# Pos Tracks - # Neg Tracks",
482 "#chi^{2};#chi^{2}_{Track};Number of Tracks",
485 "#chi^{2} probability;#chi^{2}prob_{Track};Number of Tracks",
488 "#chi^{2}/ndof;#chi^{2}/ndof;Number of Tracks",
491 "p_{T}^{track};p_{T}^{track} [GeV];Number of Tracks",
494 "#delta_{p_{T}}/p_{T}^{track};#delta_{p_{T}}/p_{T}^{track};Number of Tracks",
497 "Transverse Impact Parameter vs. #phi;#phi_{Track};#LT d_{0} #GT [cm]",
500 "Longitudinal Impact Parameter vs. #phi;#phi_{Track};#LT d_{z} #GT [cm]",
503 "Transverse Impact Parameter vs. #eta;#eta_{Track};#LT d_{0} #GT [cm]",
506 "Longitudinal Impact Parameter vs. #eta;#eta_{Track};#LT d_{z} #GT [cm]",
509 "#chi^{2} vs. #phi;#phi_{Track};#LT #chi^{2} #GT",
512 "#chi^{2} probablility vs. #phi;#phi_{Track};#LT #chi^{2} probability#GT",
515 "#chi^{2} probablility vs. |d_{0}|;|d_{0}|[cm];#LT #chi^{2} probability#GT",
518 "#chi^{2}/ndof vs. #phi;#phi_{Track};#LT #chi^{2}/ndof #GT",
521 "#chi^{2} vs. #eta;#eta_{Track};#LT #chi^{2} #GT",
524 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.};
526 "norm #chi^{2} vs. p_{T}_{Track}; p_{T}_{Track};#LT #chi^{2}/ndof #GT",
530 "#chi^{2}/ndof vs. p_{Track};p_{Track};#LT #chi^{2}/ndof #GT",
533 "#chi^{2} probability vs. #eta;#eta_{Track};#LT #chi^{2} probability #GT",
536 "#chi^{2}/ndof vs. #eta;#eta_{Track};#LT #chi^{2}/ndof #GT",
539 "#kappa vs. #phi;#phi_{Track};#kappa",
542 "#kappa vs. #eta;#eta_{Track};#kappa",
545 "#delta_{p_{T}}/p_{T}^{track};#phi^{track};#delta_{p_{T}}/p_{T}^{track}",
548 "#delta_{p_{T}}/p_{T}^{track};#eta^{track};#delta_{p_{T}}/p_{T}^{track}",
552 "Transverse Impact Parameter vs. #phi;#phi_{Track};d_{0} [cm]",
553 100, -3.15, 3.15, 100,-1.,1.) );
555 "Longitudinal Impact Parameter vs. #phi;#phi_{Track};d_{z} [cm]",
556 100, -3.15, 3.15, 100,-100.,100.));
558 "Transverse Impact Parameter vs. #eta;#eta_{Track};d_{0} [cm]",
559 100, -3.15, 3.15, 100,-1.,1.));
561 "Longitudinal Impact Parameter vs. #eta;#eta_{Track};d_{z} [cm]",
562 100, -3.15, 3.15, 100,-100.,100.));
564 "#chi^{2} vs. #phi;#phi_{Track};#chi^{2}",
565 100, -3.15, 3.15, 500, 0., 500.));
567 "#chi^{2} probability vs. #phi;#phi_{Track};#chi^{2} probability",
568 100, -3.15, 3.15, 100, 0., 1.));
570 "#chi^{2} probability vs. |d_{0}|;|d_{0}| [cm];#chi^{2} probability",
571 100, 0, 80, 100, 0., 1.));
573 "#chi^{2}/ndof vs. #phi;#phi_{Track};#chi^{2}/ndof",
574 100, -3.15, 3.15, 100, 0., 10.));
576 "#chi^{2} vs. #eta;#eta_{Track};#chi^{2}",
577 100, -3.15, 3.15, 500, 0., 500.));
579 "#chi^{2} probaility vs. #eta;#eta_{Track};#chi^{2} probability",
580 100, -3.15, 3.15, 100, 0., 1.));
582 "#chi^{2}/ndof vs. #eta;#eta_{Track};#chi^{2}/ndof",
583 100,-3.15,3.15, 100, 0., 10.));
585 "#kappa vs. #phi;#phi_{Track};#kappa",
586 100,-3.15,3.15, 100, .0,.05));
588 "#kappa vs. #eta;#eta_{Track};#kappa",
589 100,-3.15,3.15, 100, .0,.05));
591 "#kappa vs. #chi^{2}/ndof;#chi^{2}/ndof;#kappa",
592 100,0.,10, 100,-.03,.03));
596 "res_{x'} vs momentum in BPix;p [GeV]; res_{x'}",
597 15,0.,15., 200, -0.1,0.1));
599 "res_{x'} vs momentum in FPix;p [GeV]; res_{x'}",
600 15,0.,15., 200, -0.1,0.1));
602 "res_{x'} vs momentum in TIB;p [GeV]; res_{x'}",
603 15,0.,15., 200, -0.1,0.1));
605 "res_{x'} vs momentum in TID;p [GeV]; res_{x'}",
606 15,0.,15., 200, -0.1,0.1));
608 "res_{x'} vs momentum in TOB;p [GeV]; res_{x'}",
609 15,0.,15., 200, -0.1,0.1));
611 "res_{x'} vs momentum in TEC;p [GeV]; res_{x'}",
612 15,0.,15., 200, -0.1,0.1));
616 "res_{y'} vs momentum in BPix;p [GeV]; res_{y'}",
617 15,0.,15., 200, -0.1,0.1));
619 "res_{y'} vs momentum in FPix;p [GeV]; res_{y'}",
620 15,0.,15., 200, -0.1,0.1));
628 std::vector<Alignable*> alivec(ali.
components());
631 LogDebug(
"TrackerOfflineValidation") <<
"StructureName = " << structurename;
633 dirname << structurename;
635 if (structurename !=
"Strip" && structurename !=
"Pixel") dirname <<
"_" <<
i+1;
637 if (structurename.find(
"Endcap",0) != std::string::npos ) {
641 }
else if( !(this->
isDetOrDetUnit( (alivec)[i]->alignableObjectId()) )
671 std::stringstream histoname, histotitle, normhistoname, normhistotitle,
672 yhistoname, yhistotitle,
673 xprimehistoname, xprimehistotitle, normxprimehistoname, normxprimehistotitle,
674 yprimehistoname, yprimehistotitle, normyprimehistoname, normyprimehistotitle,
675 localxname, localxtitle, localyname, localytitle,
676 resxvsxprofilename, resxvsxprofiletitle, resyvsxprofilename, resyvsxprofiletitle,
677 resxvsyprofilename, resxvsyprofiletitle, resyvsyprofilename, resyvsyprofiletitle;
681 if( this->
isEndCap(static_cast<uint32_t>(subdetandlayer.first)) ) wheel_or_layer =
"_wheel_";
682 else if ( this->
isBarrel(static_cast<uint32_t>(subdetandlayer.first)) ) wheel_or_layer =
"_layer_";
683 else edm::LogWarning(
"TrackerOfflineValidation") <<
"@SUB=TrackerOfflineValidation::bookHists"
684 <<
"Unknown subdetid: " << subdetandlayer.first;
686 histoname <<
"h_residuals_subdet_" << subdetandlayer.first
687 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
688 yhistoname <<
"h_y_residuals_subdet_" << subdetandlayer.first
689 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
690 xprimehistoname <<
"h_xprime_residuals_subdet_" << subdetandlayer.first
691 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
692 yprimehistoname <<
"h_yprime_residuals_subdet_" << subdetandlayer.first
693 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
694 normhistoname <<
"h_normresiduals_subdet_" << subdetandlayer.first
695 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
696 normxprimehistoname <<
"h_normxprimeresiduals_subdet_" << subdetandlayer.first
697 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
698 normyprimehistoname <<
"h_normyprimeresiduals_subdet_" << subdetandlayer.first
699 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
700 histotitle <<
"X Residual for module " <<
id.rawId() <<
";x_{tr} - x_{hit} [cm]";
701 yhistotitle <<
"Y Residual for module " <<
id.rawId() <<
";y_{tr} - y_{hit} [cm]";
702 normhistotitle <<
"Normalized Residual for module " <<
id.rawId() <<
";x_{tr} - x_{hit}/#sigma";
703 xprimehistotitle <<
"X' Residual for module " <<
id.rawId() <<
";(x_{tr} - x_{hit})' [cm]";
704 normxprimehistotitle <<
"Normalized X' Residual for module " <<
id.rawId() <<
";(x_{tr} - x_{hit})'/#sigma";
705 yprimehistotitle <<
"Y' Residual for module " <<
id.rawId() <<
";(y_{tr} - y_{hit})' [cm]";
706 normyprimehistotitle <<
"Normalized Y' Residual for module " <<
id.rawId() <<
";(y_{tr} - y_{hit})'/#sigma";
709 localxname <<
"h_localx_subdet_" << subdetandlayer.first
710 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
711 localyname <<
"h_localy_subdet_" << subdetandlayer.first
712 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
713 localxtitle <<
"u local for module " <<
id.rawId() <<
"; u_{tr,r}";
714 localytitle <<
"v local for module " <<
id.rawId() <<
"; v_{tr,r}";
716 resxvsxprofilename <<
"p_residuals_x_vs_x_subdet_" << subdetandlayer.first
717 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
718 resyvsxprofilename <<
"p_residuals_y_vs_x_subdet_" << subdetandlayer.first
719 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
720 resxvsyprofilename <<
"p_residuals_x_vs_y_subdet_" << subdetandlayer.first
721 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
722 resyvsyprofilename <<
"p_residuals_y_vs_y_subdet_" << subdetandlayer.first
723 << wheel_or_layer << subdetandlayer.second <<
"_module_" <<
id.rawId();
724 resxvsxprofiletitle <<
"U Residual vs u for module " <<
id.rawId() <<
"; u_{tr,r} ;(u_{tr} - u_{hit})/tan#alpha [cm]";
725 resyvsxprofiletitle <<
"V Residual vs u for module " <<
id.rawId() <<
"; u_{tr,r} ;(v_{tr} - v_{hit})/tan#beta [cm]";
726 resxvsyprofiletitle <<
"U Residual vs v for module " <<
id.rawId() <<
"; v_{tr,r} ;(u_{tr} - u_{hit})/tan#alpha [cm]";
727 resyvsyprofiletitle <<
"V Residual vs v for module " <<
id.rawId() <<
"; v_{tr,r} ;(v_{tr} - v_{hit})/tan#beta [cm]";
738 if (
dqmMode_) moduleLevelHistsTransient =
false;
744 histoname.str().c_str(),histotitle.str().c_str(),
748 normhistoname.str().c_str(),normhistotitle.str().c_str(),
753 xprimehistoname.str().c_str(),xprimehistotitle.str().c_str(),
757 normxprimehistoname.str().c_str(),normxprimehistotitle.str().c_str(),
763 histStruct.
LocalX = this->
bookTH1F(moduleLevelHistsTransient, tfd,
764 localxname.str().c_str(),localxtitle.str().c_str(),
766 histStruct.
LocalY = this->
bookTH1F(moduleLevelHistsTransient, tfd,
767 localyname.str().c_str(),localytitle.str().c_str(),
770 resxvsxprofilename.str().c_str(),resxvsxprofiletitle.str().c_str(),
774 resxvsyprofilename.str().c_str(),resxvsyprofiletitle.str().c_str(),
782 yprimehistoname.str().c_str(),yprimehistotitle.str().c_str(),
787 yhistoname.str().c_str(), yhistotitle.str().c_str(),
792 normyprimehistoname.str().c_str(),normyprimehistotitle.str().c_str(),
799 resyvsxprofilename.str().c_str(),resyvsxprofiletitle.str().c_str(),
803 resyvsyprofilename.str().c_str(),resyvsyprofiletitle.str().c_str(),
813 int nBinsX,
double lowX,
double highX)
816 vDeleteObjects_.push_back(
new TH1F(histName, histTitle, nBinsX, lowX, highX));
820 return tfd.
make<TH1F>(histName, histTitle, nBinsX, lowX, highX);
824 int nBinsX,
double lowX,
double highX)
827 TProfile * profile =
new TProfile(histName, histTitle, nBinsX, lowX, highX);
832 return (TProfile*)tfd.
make<TProfile>(histName, histTitle, nBinsX, lowX, highX);
837 int nBinsX,
double lowX,
double highX,
double lowY,
double highY)
840 TProfile * profile =
new TProfile(histName, histTitle, nBinsX, lowX, highX, lowY, highY);
845 return (TProfile*)tfd.
make<TProfile>(histName, histTitle, nBinsX, lowX, highX, lowY, highY);
881 int& nBinsX,
double& lowerBoundX,
double& upperBoundX)
934 if(targetHist && sourceHist) {
935 targetHist->SetBinContent(bin, sourceHist->GetMean(1));
936 if(
useFwhm_) targetHist->SetBinError(bin,
Fwhm(sourceHist)/2.);
937 else targetHist->SetBinError(bin, sourceHist->GetRMS(1) );
991 <<
"[TrackerOfflineValidation] Error, tried to get reference for non-tracker subdet " << subdetid
992 <<
" from detector " << detid.
det();
1007 std::vector<TrackerValidationVariables::AVTrackStruct> vTrackstruct;
1010 for (std::vector<TrackerValidationVariables::AVTrackStruct>::const_iterator itT = vTrackstruct.begin();
1011 itT != vTrackstruct.end();
1020 vTrackHistos_[numOfValidHitsindex]->Fill(itT->numberOfValidHits);
1022 vTrackHistos_[numOfLostHitsindex]->Fill(itT->numberOfLostHits);
1026 if (itT->charge > 0)
1029 if (itT->charge < 0)
1039 if (itT->ptError != 0.) {
1041 vTrackHistos_[ptResolutionindex]->Fill(itT->ptError/itT->pt);
1057 vTrackProfiles_[chiProbabsd0index]->Fill(fabs(itT->d0),itT->chi2Prob);
1093 vTrack2DHistos_[chiProbabsd0index_2d]->Fill(fabs(itT->d0),itT->chi2Prob);
1110 for (std::vector<TrackerValidationVariables::AVHitStruct>::const_iterator itH = itT->hits.begin();
1111 itH != itT->hits.end();
1119 histStruct.
ResHisto->Fill(itH->resX);
1120 if(itH->resErrX != 0) histStruct.
NormResHisto->Fill(itH->resX/itH->resErrX);
1126 if (itH->resXprime != -999.) {
1157 float tgalpha =
tan(itH->localAlpha);
1158 if ( fabs(tgalpha)!=0 ){
1159 histStruct.
LocalX->Fill(itH->localXnorm, tgalpha*tgalpha);
1160 histStruct.
LocalY->Fill(itH->localYnorm, tgalpha*tgalpha);
1172 histStruct.
ResXvsXProfile->Fill(itH->localXnorm, itH->resXatTrkY/tgalpha, tgalpha*tgalpha);
1173 histStruct.
ResXvsYProfile->Fill(itH->localYnorm, itH->resXatTrkY/tgalpha, tgalpha*tgalpha);
1180 if(itH->resXprimeErr != 0 && itH->resXprimeErr != -999 ) {
1185 if (itH->resYprime != -999.) {
1201 float tgbeta =
tan(itH->localBeta);
1202 if ( fabs(tgbeta)!=0 ){
1215 histStruct.
ResYvsXProfile->Fill(itH->localXnorm, itH->resY/tgbeta, tgbeta*tgbeta);
1216 histStruct.
ResYvsYProfile->Fill(itH->localYnorm, itH->resY/tgbeta, tgbeta*tgbeta);
1221 if (itH->resYprimeErr != 0 && itH->resYprimeErr != -999. ) {
1253 TTree *
tree = fs->
make<TTree>(
"TkOffVal",
"TkOffVal");
1259 tree->Branch(
"TkOffTreeVariables", &treeMemPtr);
1268 delete treeMemPtr; treeMemPtr = 0;
1274 std::vector<TrackerOfflineValidation::SummaryContainer>& vLevelProfiles)
1276 std::vector<Alignable*> alivec(ali.
components());
1277 if( this->
isDetOrDetUnit((alivec)[0]->alignableObjectId()) )
return;
1279 for(
int iComp=0, iCompEnd = ali.
components().size();iComp < iCompEnd; ++iComp) {
1280 std::vector< TrackerOfflineValidation::SummaryContainer > vProfiles;
1283 LogDebug(
"TrackerOfflineValidation") <<
"StructureName = " << structurename;
1285 dirname << structurename;
1288 if (structurename !=
"Strip" && structurename !=
"Pixel") dirname <<
"_" << iComp+1;
1290 if( !(this->
isDetOrDetUnit( (alivec)[iComp]->alignableObjectId()) )
1295 TH1 *hX = vLevelProfiles[iComp].sumXResiduals_;
1296 TH1 *hNormX = vLevelProfiles[iComp].sumNormXResiduals_;
1297 TH1 *hY = vLevelProfiles[iComp].sumYResiduals_;
1298 TH1 *hNormY = vLevelProfiles[iComp].sumNormYResiduals_;
1299 TH1 *pXX = vLevelProfiles[iComp].sumResXvsXProfile_;
1300 TH1 *pXY = vLevelProfiles[iComp].sumResXvsYProfile_;
1301 TH1 *pYX = vLevelProfiles[iComp].sumResYvsXProfile_;
1302 TH1 *pYY = vLevelProfiles[iComp].sumResYvsYProfile_;
1303 for(uint
n = 0;
n < vProfiles.size(); ++
n) {
1308 if (hNormY)
sumHistStructure_.emplace_back(hNormY, vProfiles[n].sumNormYResiduals_);
1316 toFit_.push_back(vLevelProfiles[iComp].sumXResiduals_);
1317 toFit_.push_back(vLevelProfiles[iComp].sumNormXResiduals_);
1318 if (hY)
toFit_.push_back(hY);
1319 if (hNormY)
toFit_.push_back(hNormY);
1330 for (std::vector<std::pair<TH1*,TH1*> >::const_iterator it =
sumHistStructure_.begin();
1333 it->first->Add(it->second);
1335 for (std::vector<std::tuple<int,TH1*,TH1*> >::const_iterator it =
summaryBins_.begin();
1338 setSummaryBin(std::get<0>(*it), std::get<1>(*it), std::get<2>(*it));
1340 for (std::vector<TH1*>::const_iterator it =
toFit_.begin();
1351 const uint aliSize = ali.
components().size();
1358 const DetId aliDetId = ali.
id();
1368 const uint subcompSize = ali.
components()[0]->components().size();
1370 const TString
title(Form(
"Summary for substructures in %s %d;%s;",aliTypeName,i,aliSubtypeName));
1372 sumContainer.summaryXResiduals_ = tfd.
make<TH1F>(Form(
"h_summaryX%s_%d",aliTypeName,i),
1373 title +
"#LT #Delta x' #GT",
1374 aliSize, 0.5, aliSize+0.5);
1375 sumContainer.summaryNormXResiduals_ = tfd.
make<TH1F>(Form(
"h_summaryNormX%s_%d",aliTypeName,i),
1376 title +
"#LT #Delta x'/#sigma #GT",
1377 aliSize,0.5,aliSize+0.5);
1380 sumContainer.summaryYResiduals_ = tfd.
make<TH1F>(Form(
"h_summaryY%s_%d",aliTypeName,i),
1381 title +
"#LT #Delta y' #GT",
1382 aliSize, 0.5, aliSize+0.5);
1383 sumContainer.summaryNormYResiduals_ = tfd.
make<TH1F>(Form(
"h_summaryNormY%s_%d",aliTypeName,i),
1384 title +
"#LT #Delta y'/#sigma #GT",
1385 aliSize,0.5,aliSize+0.5);
1389 if (subcompSize != 2) {
1392 <<
"Det with " << subcompSize <<
" components";
1395 const TString
title(Form(
"Summary for substructures in %s %d;%s;", aliTypeName, i,
1398 sumContainer.summaryXResiduals_
1399 = tfd.
make<TH1F>(Form(
"h_summaryX%s_%d", aliTypeName, i),
1400 title +
"#LT #Delta x' #GT", (2*aliSize), 0.5, 2*aliSize+0.5);
1401 sumContainer.summaryNormXResiduals_
1402 = tfd.
make<TH1F>(Form(
"h_summaryNormX%s_%d", aliTypeName, i),
1403 title +
"#LT #Delta x'/#sigma #GT", (2*aliSize), 0.5, 2*aliSize+0.5);
1406 sumContainer.summaryYResiduals_
1407 = tfd.
make<TH1F>(Form(
"h_summaryY%s_%d", aliTypeName, i),
1408 title +
"#LT #Delta y' #GT", (2*aliSize), 0.5, 2*aliSize+0.5);
1409 sumContainer.summaryNormYResiduals_
1410 = tfd.
make<TH1F>(Form(
"h_summaryNormY%s_%d", aliTypeName, i),
1411 title +
"#LT #Delta y'/#sigma #GT", (2*aliSize), 0.5, 2*aliSize+0.5);
1415 edm::LogError(
"TrackerOfflineValidation") <<
"@SUB=TrackerOfflineValidation::bookSummaryHists"
1416 <<
"No summary histogram for hierarchy level "
1417 << aliTypeName <<
" in subdet " << aliDetId.
subdetId();
1425 const TString sumTitle(Form(
"Residual for %s %d in %s;", aliTypeName, i, typeName));
1429 sumContainer.sumXResiduals_ = tfd.
make<TH1F>(Form(
"h_Xprime_%s_%d", aliTypeName, i),
1434 sumContainer.sumNormXResiduals_ = tfd.
make<TH1F>(Form(
"h_NormXprime_%s_%d",aliTypeName,i),
1440 sumContainer.sumResXvsXProfile_ = tfd.
make<TProfile>(Form(
"p_resXX_%s_%d",aliTypeName,i),
1443 sumContainer.sumResXvsXProfile_->Sumw2();
1444 sumContainer.sumResXvsYProfile_ = tfd.
make<TProfile>(Form(
"p_resXY_%s_%d",aliTypeName,i),
1447 sumContainer.sumResXvsYProfile_->Sumw2();
1452 sumContainer.sumYResiduals_ = tfd.
make<TH1F>(Form(
"h_Yprime_%s_%d",aliTypeName,i),
1457 sumContainer.sumNormYResiduals_ = tfd.
make<TH1F>(Form(
"h_NormYprime_%s_%d",aliTypeName,i),
1463 sumContainer.sumResYvsXProfile_ = tfd.
make<TProfile>(Form(
"p_resYX_%s_%d",aliTypeName,i),
1466 sumContainer.sumResYvsXProfile_->Sumw2();
1467 sumContainer.sumResYvsYProfile_ = tfd.
make<TProfile>(Form(
"p_resYY_%s_%d",aliTypeName,i),
1470 sumContainer.sumResYvsYProfile_->Sumw2();
1478 for(uint
k = 0;
k < aliSize; ++
k) {
1499 for(uint
k = 0;
k < aliSize; ++
k) {
1500 for(uint
j = 0;
j < subcompSize; ++
j) {
1521 return sumContainer;
1528 float max = hist->GetMaximum();
1529 int left = -1, right = -1;
1530 for(
unsigned int i = 1, iEnd = hist->GetNbinsX();
i <= iEnd; ++
i) {
1531 if(hist->GetBinContent(
i) < max/2. && hist->GetBinContent(
i+1) > max/2. && left == -1) {
1532 if(max/2. - hist->GetBinContent(
i) < hist->GetBinContent(
i+1) - max/2.) {
1540 if(left != -1 && right == -1) {
1541 if(hist->GetBinContent(
i) > max/2. && hist->GetBinContent(
i+1) < max/2.) {
1542 if( hist->GetBinContent(
i) - max/2. < max/2. - hist->GetBinContent(
i+1)) {
1551 return hist->GetXaxis()->GetBinCenter(right) - hist->GetXaxis()->GetBinCenter(left);
1560 for(std::map<int, TrackerOfflineValidation::ModuleHistos>::const_iterator it = moduleHist_.begin(),
1561 itEnd= moduleHist_.end(); it != itEnd;++it ) {
1565 DetId detId_ = it->first;
1571 unsigned int whichHalfBarrel(1), rawId(detId_.
rawId());
1572 if( (rawId>=302056964 && rawId<302059300) || (rawId>=302123268 && rawId<302127140) ||
1573 (rawId>=302189572 && rawId<302194980) ) whichHalfBarrel=2;
1575 treeMem.
half = whichHalfBarrel;
1579 unsigned int whichHalfCylinder(1), rawId(detId_.
rawId());
1580 if( (rawId>=352394500 && rawId<352406032) || (rawId>=352460036 && rawId<352471568) ||
1581 (rawId>=344005892 && rawId<344017424) || (rawId>=344071428 && rawId<344082960) ) whichHalfCylinder=2;
1584 treeMem.
half = whichHalfCylinder;
1589 unsigned int whichHalfShell(1), rawId(detId_.
rawId());
1590 if ( (rawId>=369120484 && rawId<369120688) || (rawId>=369121540 && rawId<369121776) ||
1591 (rawId>=369136932 && rawId<369137200) || (rawId>=369137988 && rawId<369138288) ||
1592 (rawId>=369153396 && rawId<369153744) || (rawId>=369154436 && rawId<369154800) ||
1593 (rawId>=369169844 && rawId<369170256) || (rawId>=369170900 && rawId<369171344) ||
1594 (rawId>=369124580 && rawId<369124784) || (rawId>=369125636 && rawId<369125872) ||
1595 (rawId>=369141028 && rawId<369141296) || (rawId>=369142084 && rawId<369142384) ||
1596 (rawId>=369157492 && rawId<369157840) || (rawId>=369158532 && rawId<369158896) ||
1597 (rawId>=369173940 && rawId<369174352) || (rawId>=369174996 && rawId<369175440) ) whichHalfShell=2;
1600 treeMem.
half = whichHalfShell;
1637 treeMem.
posX = gPModule.
x();
1638 treeMem.
posY = gPModule.
y();
1639 treeMem.
posZ = gPModule.
z();
1644 LocalPoint lUDirection(1.,0.,0.), lVDirection(0.,1.,0.), lWDirection(0.,0.,1.);
1646 gVDirection = surface.
toGlobal(lVDirection),
1647 gWDirection = surface.
toGlobal(lWDirection);
1648 double dR(999.),
dPhi(999.), dZ(999.);
1650 dR = gWDirection.perp() - gPModule.
perp();
1652 dZ = gVDirection.z() - gPModule.
z();
1657 dZ = gWDirection.z() - gPModule.
z();
1660 dR = gVDirection.perp() - gPModule.
perp();
1662 dZ = gWDirection.z() - gPModule.
z();
1673 const std::map<int, TrackerOfflineValidation::ModuleHistos>& moduleHist_)
1675 for(std::map<int, TrackerOfflineValidation::ModuleHistos>::const_iterator it = moduleHist_.begin(),
1676 itEnd= moduleHist_.end(); it != itEnd;++it ) {
1680 treeMem.
entries =
static_cast<UInt_t
>(it->second.ResXprimeHisto->GetEntries());
1681 treeMem.
meanX = it->second.ResXprimeHisto->GetMean();
1682 treeMem.
rmsX = it->second.ResXprimeHisto->GetRMS();
1688 std::pair<float,float> fitResult1 = this->
fitResiduals(it->second.ResXprimeHisto);
1689 treeMem.
fitMeanX = fitResult1.first;
1692 std::pair<float,float> fitResult2 = this->
fitResiduals(it->second.NormResXprimeHisto);
1700 int numberOfBins=it->second.ResXprimeHisto->GetNbinsX();
1702 treeMem.
numberOfOverflows = it->second.ResXprimeHisto->GetBinContent(numberOfBins+1);
1703 treeMem.
numberOfOutliers = it->second.ResXprimeHisto->GetBinContent(0)+it->second.ResXprimeHisto->GetBinContent(numberOfBins+1);
1706 treeMem.
meanNormX = it->second.NormResXprimeHisto->GetMean();
1707 treeMem.
rmsNormX = it->second.NormResXprimeHisto->GetRMS();
1710 it->second.NormResXprimeHisto->GetStats(stats);
1712 if (stats[0]) treeMem.
chi2PerDofX = stats[3]/stats[0];
1715 treeMem.
histNameX = it->second.ResXprimeHisto->GetName();
1716 treeMem.
histNameNormX = it->second.NormResXprimeHisto->GetName();
1720 treeMem.
meanLocalX = it->second.ResHisto->GetMean();
1721 treeMem.
rmsLocalX = it->second.ResHisto->GetRMS();
1727 if (it->second.ResYHisto) treeMem.
histNameLocalY = it->second.ResYHisto->GetName();
1732 if (it->second.ResYprimeHisto) {
1733 TH1 *
h = it->second.ResYprimeHisto;
1734 treeMem.
meanY = h->GetMean();
1735 treeMem.
rmsY = h->GetRMS();
1738 std::pair<float,float> fitMeanSigma = this->
fitResiduals(h);
1739 treeMem.
fitMeanY = fitMeanSigma.first;
1740 treeMem.
fitSigmaY = fitMeanSigma.second;
1748 if (it->second.NormResYprimeHisto) {
1749 TH1 *
h = it->second.NormResYprimeHisto;
1753 if (stats[0]) treeMem.
chi2PerDofY = stats[3]/stats[0];
1756 std::pair<float,float> fitMeanSigma = this->
fitResiduals(h);
1764 if (it->second.ResXvsXProfile) {
1765 TH1 *
h = it->second.ResXvsXProfile;
1770 if (it->second.ResXvsYProfile) {
1771 TH1 *
h = it->second.ResXvsYProfile;
1776 if (it->second.ResYvsXProfile) {
1777 TH1 *
h = it->second.ResYvsXProfile;
1782 if (it->second.ResYvsYProfile) {
1783 TH1 *
h = it->second.ResYvsYProfile;
1795 std::pair<float,float>
1798 std::pair<float,float> fitResult(9999., 9999.);
1799 if (!hist || hist->GetEntries() < 20)
return fitResult;
1801 float mean = hist->GetMean();
1802 float sigma = hist->GetRMS();
1807 TF1 func(
"tmp",
"gaus", mean - 2.*sigma, mean + 2.*sigma);
1808 if (0 == hist->Fit(&func,
"QNR")) {
1809 mean = func.GetParameter(1);
1810 sigma = func.GetParameter(2);
1812 func.SetRange(mean - 3.*sigma, mean + 3.*sigma);
1815 if (0 == hist->Fit(&func,
"Q0LR")) {
1816 if (hist->GetFunction(func.GetName())) {
1817 hist->GetFunction(func.GetName())->ResetBit(TF1::kNotDraw);
1819 fitResult.first = func.GetParameter(1);
1820 fitResult.second = func.GetParameter(2);
1824 edm::LogWarning(
"Alignment") <<
"@SUB=TrackerOfflineValidation::fitResiduals"
1825 <<
"Caught this exception during ROOT fit: "
1836 int nbins = histo->GetNbinsX();
1839 double *
x =
new double[
nbins];
1840 double *
y =
new double[
nbins];
1842 x[
j] = histo->GetBinCenter(
j+1);
1843 y[
j] = histo->GetBinContent(
j+1);
1845 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
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
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
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
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.
std::vector< std::tuple< int, TH1 *, TH1 * > > summaryBins_
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)
std::vector< std::pair< TH1 *, TH1 * > > sumHistStructure_
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)
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 int subDetId[18]
Tan< T >::type tan(const T &t)
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
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)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
void prepareSummaryHists(DirectoryWrapper &tfd, const Alignable &ali, std::vector< TrackerOfflineValidation::SummaryContainer > &vLevelProfiles)
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)
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::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)
void fillTrackQuantities(const edm::Event &, std::vector< AVTrackStruct > &v_avtrackout)
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)
std::map< int, TkOffTreeVariables > mTreeMembers_
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.
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)