diff --git a/Alignment/OfflineValidation/macros/PlotAlignmentValidation.C b/Alignment/OfflineValidation/macros/PlotAlignmentValidation.C index 694a19881faeb..6e6c9577094a4 100644 --- a/Alignment/OfflineValidation/macros/PlotAlignmentValidation.C +++ b/Alignment/OfflineValidation/macros/PlotAlignmentValidation.C @@ -49,8 +49,8 @@ PlotAlignmentValidation::PlotAlignmentValidation(const char *inputFile,std::stri // Force ROOT to use scientific notation even with smaller datasets TGaxis::SetMaxDigits(4); - // (This sets a static variable: correct in .eps-images but must be set - // again manually when viewing the .root-files) + // (This sets a static variable: correct in .eps images but must be set + // again manually when viewing the .root files) // Make ROOT calculate histogram statistics using all data, // regardless of displayed range @@ -162,8 +162,13 @@ void PlotAlignmentValidation::plotSubDetResiduals(bool plotNormHisto,unsigned in } //hstack->Draw("nostack"); char PlotName[1000]; + sprintf( PlotName, "%s/%s.png", outputDir.c_str(), histoName.Data() ); + c->Print(PlotName); sprintf( PlotName, "%s/%s.eps", outputDir.c_str(), histoName.Data() ); - + c->Print(PlotName); + sprintf( PlotName, "%s/%s.pdf", outputDir.c_str(), histoName.Data() ); + c->Print(PlotName); + sprintf( PlotName, "%s/%s.root", outputDir.c_str(), histoName.Data() ); c->Print(PlotName); //delete c; //c=0; @@ -195,8 +200,13 @@ void PlotAlignmentValidation::plotHitMaps() tree->Draw("entries:posR:posPhi","","COLZ2Prof"); char PlotName[1000]; + sprintf( PlotName, "%s/%s.png", outputDir.c_str(), histName_.c_str() ); + c->Print(PlotName); sprintf( PlotName, "%s/%s.eps", outputDir.c_str(), histName_.c_str() ); - + c->Print(PlotName); + sprintf( PlotName, "%s/%s.pdf", outputDir.c_str(), histName_.c_str() ); + c->Print(PlotName); + sprintf( PlotName, "%s/%s.root", outputDir.c_str(), histName_.c_str() ); c->Print(PlotName); // //c->Update(); c->Close(); @@ -526,11 +536,13 @@ void PlotAlignmentValidation::plotSS( const std::string& options, const std::str if (isTEC && iTEC>0) plotName << "_" << "R5-7"; - // EPS-file + // PNG,EPS,PDF files c.Update(); + c.Print((plotName.str() + ".png").c_str()); c.Print((plotName.str() + ".eps").c_str()); + c.Print((plotName.str() + ".pdf").c_str()); - // ROOT-file + // ROOT file TFile f((plotName.str() + ".root").c_str(), "recreate"); c.Write(); f.Close(); @@ -799,11 +811,13 @@ void PlotAlignmentValidation::plotDMR(const std::string& variable, Int_t minHits plotName << plotLayerN; } - // EPS-file + // PNG,EPS,PDF files c.Update(); + c.Print((plotName.str() + ".png").c_str()); c.Print((plotName.str() + ".eps").c_str()); + c.Print((plotName.str() + ".pdf").c_str()); - // ROOT-file + // ROOT file TFile f((plotName.str() + ".root").c_str(), "recreate"); c.Write(); f.Close(); @@ -887,11 +901,15 @@ void PlotAlignmentValidation::plotChi2(const char *inputFile) chiprob->Draw(); normchi->Draw(); - // EPS-files + // PNG,EPS,PDF files + normchi->Print((outputDir + "/h_normchi2.png").c_str()); + chiprob->Print((outputDir + "/h_chi2Prob.png").c_str()); normchi->Print((outputDir + "/h_normchi2.eps").c_str()); chiprob->Print((outputDir + "/h_chi2Prob.eps").c_str()); + normchi->Print((outputDir + "/h_normchi2.pdf").c_str()); + chiprob->Print((outputDir + "/h_chi2Prob.pdf").c_str()); - // ROOT-files + // ROOT files TFile fi2((outputDir + "/h_normchi2.root").c_str(), "recreate"); normchi->Write(); fi2.Close(); @@ -906,7 +924,7 @@ void PlotAlignmentValidation::plotChi2(const char *inputFile) } //------------------------------------------------------------------------------ -THStack* PlotAlignmentValidation::addHists(const char *selection, const TString &residType, +THStack* PlotAlignmentValidation::addHists(const TString& selection, const TString &residType, TLegend **myLegend, bool printModuleIds) { enum ResidType { @@ -943,76 +961,183 @@ THStack* PlotAlignmentValidation::addHists(const char *selection, const TString for(std::vector::iterator itSourceFile = sourceList.begin(); itSourceFile != sourceList.end(); ++itSourceFile) { - // TFile *f = (*sourceList.begin())->getFile(); + std::vector histnames; + TFile *f = (*itSourceFile)->getFile(); - // TTree *tree= (*sourceList.begin())->getTree(); TTree *tree= (*itSourceFile)->getTree(); int myLineColor = (*itSourceFile)->getLineColor(); int myLineStyle = (*itSourceFile)->getLineStyle(); TString myLegendName = (*itSourceFile)->getName(); + TH1 *h = 0; // becomes result + UInt_t nEmpty = 0;// selected, but empty hists + Long64_t nentries = tree->GetEntriesFast(); if (!f || !tree) { std::cout << "PlotAlignmentValidation::addHists: no tree or no file" << std::endl; return 0; } - - // first loop on tree to find out which entries (i.e. modules) fulfill the selection - // 'Entry$' gives the entry number in the tree - Long64_t nSel = tree->Draw("Entry$", selection, "goff"); - if (nSel == -1) return 0; // error in selection - if (nSel == 0) { - std::cout << "PlotAlignmentValidation::addHists: no selected module." << std::endl; - return 0; + bool histnamesfilled = false; + if (residType.Contains("Res") && residType.Contains("Profile")) + { + TString basename = TString(residType).ReplaceAll("Res","p_res") + .ReplaceAll("vs","") + .ReplaceAll("Profile","_"); //gives e.g.: p_resXX_ + if (selection == "subDetId==1") { + histnames.push_back(TString(basename) += "TPBBarrel_1"); + histnamesfilled = true; + } else if (selection == "subDetId==2") { + histnames.push_back(TString(basename) += "TPEEndcap_2"); + histnames.push_back(TString(basename) += "TPEEndcap_3"); + histnamesfilled = true; + } else if (selection == "subDetId==3") { + histnames.push_back(TString(basename) += "TIBBarrel_1"); + histnamesfilled = true; + } else if (selection == "subDetId==4") { + histnames.push_back(TString(basename) += "TIDEndcap_2"); + histnames.push_back(TString(basename) += "TIDEndcap_3"); + histnamesfilled = true; + } else if (selection == "subDetId==5") { + histnames.push_back(TString(basename) += "TOBBarrel_4"); + histnamesfilled = true; + } else if (selection == "subDetId==6") { //whole TEC - doesn't happen by default but easy enough to account for + histnames.push_back(TString(basename) += "TECEndcap_5"); + histnames.push_back(TString(basename) += "TECEndcap_6"); + histnamesfilled = true; + } else if (selection == "subDetId==6 && ring <= 4") { + //There are multiple with the same name and all are needed, so give the full path. For these TFile::Get is used later instead of FindKeyAny. + for (int iEndcap = 5; iEndcap <= 6; iEndcap++) + for (int iDisk = 1; iDisk <= 9; iDisk++) + for (int iSide = 1; iSide <= 2; iSide++) + for (int iPetal = 1; iPetal <= 8; iPetal++) + for (int iRing = 1; iRing <= 4 - (iDisk>=4) - (iDisk>=7) - (iDisk>=9); iRing++) + //in the higher disks, the inner rings go away. But the numbering in the file structure removes the higher numbers + // so the numbers there do not correspond to the actual ring numbers + { + stringstream s; + s << "TrackerOfflineValidationStandalone/Strip/TECEndcap_" << iEndcap + << "/TECDisk_" << iDisk + << "/TECSide_" << iSide + << "/TECPetal_" << iPetal + << "/" << basename << "TECRing_" << iRing; + histnames.push_back(TString(s.str())); + } + histnamesfilled = true; + } else if (selection == "subDetId==6 && ring > 4") { + //There are multiple with the same name and all are needed, so give the full path. For these TFile::Get is used later instead of FindKeyAny. + for (int iEndcap = 5; iEndcap <= 6; iEndcap++) + for (int iDisk = 1; iDisk <= 9; iDisk++) + for (int iSide = 1; iSide <= 2; iSide++) + for (int iPetal = 1; iPetal <= 8; iPetal++) + for (int iRing = 5 - (iDisk>=4) - (iDisk>=7) - (iDisk>=9); iRing <= 7 - (iDisk>=4) - (iDisk>=7) - (iDisk>=9); iRing++) + //in the higher disks, the inner rings go away. But the numbering in the file structure removes the higher numbers + // so the numbers there do not correspond to the actual ring numbers + { + stringstream s; + s << "TrackerOfflineValidationStandalone/Strip/TECEndcap_" << iEndcap + << "/TECDisk_" << iDisk + << "/TECSide_" << iSide + << "/TECPetal_" << iPetal + << "/" << basename << "TECRing_" << iRing; + histnames.push_back(TString(s.str())); + } + histnamesfilled = true; + } } - // copy entry numbers that fulfil the selection - const std::vector selected(tree->GetV1(), tree->GetV1() + nSel); - TH1 *h = 0; // becomes result - UInt_t nEmpty = 0;// selected, but empty hists - Long64_t nentries = tree->GetEntriesFast(); - std::vector::const_iterator iterEnt = selected.begin(); - - // second loop on tree: - // for each selected entry get the hist from the file and merge - TkOffTreeVariables *treeMem = 0; // ROOT will initialise - tree->SetBranchAddress("TkOffTreeVariables", &treeMem); - for (Long64_t i = 0; i < nentries; i++){ - if (i < *iterEnt - 0.1 // smaller index (with tolerance): skip - || iterEnt == selected.end()) { // at the end: skip - continue; - } else if (TMath::Abs(i - *iterEnt) < 0.11) { - ++iterEnt; // take this entry! - } else std::cout << "Must not happen: " << i << " " << *iterEnt << std::endl; - - tree->GetEntry(i); - if (printModuleIds) { - std::cout << treeMem->moduleId << ": " << treeMem->entries << " entries" << std::endl; + + Long64_t nSel = 0; + if (histnamesfilled && histnames.size() > 0) { + nSel = (Long64_t)histnames.size(); + + //============================================================ + //for compatibility - please remove this at some point + //it's now the end of August 2015 + TH1 *firstHist = 0; + if (histnames[0].Contains("/")) { + firstHist = (TH1*)f->Get(histnames[0]); + } else { + TKey *histKey = f->FindKeyAny(histnames[0]); + if (histKey) + firstHist = (histKey ? static_cast(histKey->ReadObj()) : 0); + } + if (!firstHist) //then the validation was done with an older version of TrackerOfflineValidation + { // ==> have to make the plots the old (long) way + histnamesfilled = false; + histnames.clear(); + } + //============================================================ + + } + if (!histnamesfilled) { + // first loop on tree to find out which entries (i.e. modules) fulfill the selection + // 'Entry$' gives the entry number in the tree + nSel = tree->Draw("Entry$", selection, "goff"); + if (nSel == -1) return 0; // error in selection + if (nSel == 0) { + std::cout << "PlotAlignmentValidation::addHists: no selected module." << std::endl; + return 0; } - if (treeMem->entries <= 0) { // little speed up: skip empty hists - ++nEmpty; - continue; + // copy entry numbers that fulfil the selection + const std::vector selected(tree->GetV1(), tree->GetV1() + nSel); + + std::vector::const_iterator iterEnt = selected.begin(); + + // second loop on tree: + // for each selected entry get the hist from the file and merge + TkOffTreeVariables *treeMem = 0; // ROOT will initialise + tree->SetBranchAddress("TkOffTreeVariables", &treeMem); + for (Long64_t i = 0; i < nentries; i++){ + if (i < *iterEnt - 0.1 // smaller index (with tolerance): skip + || iterEnt == selected.end()) { // at the end: skip + continue; + } else if (TMath::Abs(i - *iterEnt) < 0.11) { + ++iterEnt; // take this entry! + } else std::cout << "Must not happen: " << i << " " << *iterEnt << std::endl; + + tree->GetEntry(i); + if (printModuleIds) { + std::cout << treeMem->moduleId << ": " << treeMem->entries << " entries" << std::endl; + } + if (treeMem->entries <= 0) { // little speed up: skip empty hists + ++nEmpty; + continue; + } + TString hName; + switch(rType) { + case xPrimeRes: hName = treeMem->histNameX.c_str(); break; + case yPrimeRes: hName = treeMem->histNameY.c_str(); break; + case xPrimeNormRes: hName = treeMem->histNameNormX.c_str(); break; + case yPrimeNormRes: hName = treeMem->histNameNormY.c_str(); break; + case xRes: hName = treeMem->histNameLocalX.c_str(); break; + case yRes: hName = treeMem->histNameLocalY.c_str(); break; + case xNormRes: hName = treeMem->histNameNormLocalX.c_str(); break; + /*case yResNorm: hName = treeMem->histNameNormLocalY.c_str(); break;*/ + case ResXvsXProfile: hName = treeMem->profileNameResXvsX.c_str(); break; + case ResXvsYProfile: hName = treeMem->profileNameResXvsY.c_str(); break; + case ResYvsXProfile: hName = treeMem->profileNameResYvsX.c_str(); break; + case ResYvsYProfile: hName = treeMem->profileNameResYvsY.c_str(); break; + } + histnames.push_back(hName); } - TString hName; - switch(rType) { - case xPrimeRes: hName = treeMem->histNameX.c_str(); break; - case yPrimeRes: hName = treeMem->histNameY.c_str(); break; - case xPrimeNormRes: hName = treeMem->histNameNormX.c_str(); break; - case yPrimeNormRes: hName = treeMem->histNameNormY.c_str(); break; - case xRes: hName = treeMem->histNameLocalX.c_str(); break; - case yRes: hName = treeMem->histNameLocalY.c_str(); break; - case xNormRes: hName = treeMem->histNameNormLocalX.c_str(); break; - /*case yResNorm: hName = treeMem->histNameNormLocalY.c_str(); break;*/ - case ResXvsXProfile: hName = treeMem->profileNameResXvsX.c_str(); break; - case ResXvsYProfile: hName = treeMem->profileNameResXvsY.c_str(); break; - case ResYvsXProfile: hName = treeMem->profileNameResYvsX.c_str(); break; - case ResYvsYProfile: hName = treeMem->profileNameResYvsY.c_str(); break; + } + + for (std::vector::iterator ithistname = histnames.begin(); + ithistname != histnames.end(); ++ithistname) { + TH1 *newHist; + if (ithistname->Contains("/")) { + newHist = (TH1*)f->Get(*ithistname); + } else { + TKey *histKey = f->FindKeyAny(*ithistname); + newHist = (histKey ? static_cast(histKey->ReadObj()) : 0); } - TKey *histKey = f->FindKeyAny(hName); - TH1 *newHist = (histKey ? static_cast(histKey->ReadObj()) : 0); if (!newHist) { - std::cout << "Hist " << hName << " not found in file, break loop." << std::endl; + std::cout << "Hist " << *ithistname << " not found in file, break loop." << std::endl; break; } + if (newHist->GetEntries() == 0) { + nEmpty++; + continue; + } newHist->SetLineColor(myLineColor); newHist->SetLineStyle(myLineStyle); if (!h) { // first hist: clone, but rename keeping only first part of name @@ -1030,7 +1155,7 @@ THStack* PlotAlignmentValidation::addHists(const char *selection, const TString } std::cout << "PlotAlignmentValidation::addHists" << "Result is merged from " << nSel-nEmpty - << " modules, " << nEmpty << " hists were empty." << std::endl; + << " hists, " << nEmpty << " hists were empty." << std::endl; if (nSel-nEmpty == 0) continue; diff --git a/Alignment/OfflineValidation/macros/PlotAlignmentValidation.h b/Alignment/OfflineValidation/macros/PlotAlignmentValidation.h index 7006842020768..cff5f61778ffe 100644 --- a/Alignment/OfflineValidation/macros/PlotAlignmentValidation.h +++ b/Alignment/OfflineValidation/macros/PlotAlignmentValidation.h @@ -87,7 +87,7 @@ class PlotAlignmentValidation { void setOutputDir( std::string dir ); void setTreeBaseDir( std::string dir = "TrackerOfflineValidationStandalone"); - THStack* addHists(const char *selection, const TString &residType = "xPrime", TLegend **myLegend = 0, bool printModuleIds = false);//add hists fulfilling 'selection' on TTree; residType: xPrime,yPrime,xPrimeNorm,yPrimeNorm,x,y,xNorm; if (printModuleIds): cout DetIds + THStack* addHists(const TString& selection, const TString &residType = "xPrime", TLegend **myLegend = 0, bool printModuleIds = false);//add hists fulfilling 'selection' on TTree; residType: xPrime,yPrime,xPrimeNorm,yPrimeNorm,x,y,xNorm; if (printModuleIds): cout DetIds // These are helpers for DMR plotting diff --git a/Alignment/OfflineValidation/plugins/CosmicSplitterValidation.cc b/Alignment/OfflineValidation/plugins/CosmicSplitterValidation.cc index fcff92e64ad40..a09166eb65e1c 100644 --- a/Alignment/OfflineValidation/plugins/CosmicSplitterValidation.cc +++ b/Alignment/OfflineValidation/plugins/CosmicSplitterValidation.cc @@ -439,7 +439,7 @@ void CosmicSplitterValidation::analyze(const edm::Event& iEvent, const edm::Even if(type==int(StripSubdetector::TIB)){++nhitinTIB2;} if(type==int(StripSubdetector::TOB)){++nhitinTOB2;} if(type==int(StripSubdetector::TID)){++nhitinTID2;} - //\\if(type==int(StripSubdetector::TEC)){++nhitinTEC2;} + if(type==int(StripSubdetector::TEC)){++nhitinTEC2;} if(type==int( kBPIX)){++nhitinBPIX2;} if(type==int( kFPIX)){++nhitinFPIX2;} @@ -486,7 +486,7 @@ void CosmicSplitterValidation::analyze(const edm::Event& iEvent, const edm::Even if(type==int(StripSubdetector::TIB)){++nhitinTIBorg;} if(type==int(StripSubdetector::TOB)){++nhitinTOBorg;} if(type==int(StripSubdetector::TID)){++nhitinTIDorg;} - //\\if(type==int(StripSubdetector::TEC)){++nhitinTECorg;} + if(type==int(StripSubdetector::TEC)){++nhitinTECorg;} if(type==int( kBPIX)){++nhitinBPIXorg;} if(type==int( kFPIX)){++nhitinFPIXorg;} diff --git a/Alignment/OfflineValidation/plugins/TrackerOfflineValidation.cc b/Alignment/OfflineValidation/plugins/TrackerOfflineValidation.cc index 1e5852e40d7f1..4f4485dd1f1a9 100644 --- a/Alignment/OfflineValidation/plugins/TrackerOfflineValidation.cc +++ b/Alignment/OfflineValidation/plugins/TrackerOfflineValidation.cc @@ -117,8 +117,10 @@ class TrackerOfflineValidation : public edm::EDAnalyzer { struct SummaryContainer{ SummaryContainer() : sumXResiduals_(), summaryXResiduals_(), sumNormXResiduals_(), summaryNormXResiduals_(), - sumYResiduals_(), summaryYResiduals_() , - sumNormYResiduals_(), summaryNormYResiduals_() {} + sumYResiduals_(), summaryYResiduals_(), + sumNormYResiduals_(), summaryNormYResiduals_(), + sumResXvsXProfile_(), sumResXvsYProfile_(), + sumResYvsXProfile_(), sumResYvsYProfile_() {} TH1* sumXResiduals_; TH1* summaryXResiduals_; @@ -128,6 +130,11 @@ class TrackerOfflineValidation : public edm::EDAnalyzer { TH1* summaryYResiduals_; TH1* sumNormYResiduals_; TH1* summaryNormYResiduals_; + + TH1* sumResXvsXProfile_; + TH1* sumResXvsYProfile_; + TH1* sumResYvsXProfile_; + TH1* sumResYvsYProfile_; }; @@ -1281,6 +1288,15 @@ TrackerOfflineValidation::collateSummaryHists( DirectoryWrapper& tfd, const Alig vLevelProfiles[iComp].sumNormXResiduals_->Add(vProfiles[n].sumNormXResiduals_); if (hY) hY->Add(vProfiles[n].sumYResiduals_); // only if existing if (hNormY) hNormY->Add(vProfiles[n].sumNormYResiduals_); // dito (pxl, stripYResiduals_) + + TH1 *pXX = vLevelProfiles[iComp].sumResXvsXProfile_; + TH1 *pXY = vLevelProfiles[iComp].sumResXvsYProfile_; + TH1 *pYX = vLevelProfiles[iComp].sumResYvsXProfile_; + TH1 *pYY = vLevelProfiles[iComp].sumResYvsYProfile_; + if (pXX) pXX->Add(vProfiles[n].sumResXvsXProfile_); + if (pXY) pXY->Add(vProfiles[n].sumResXvsYProfile_); + if (pYX) pYX->Add(vProfiles[n].sumResYvsXProfile_); + if (pYY) pYY->Add(vProfiles[n].sumResYvsYProfile_); } if(dqmMode_)continue; // No fits in dqmMode //add fit values to stat box @@ -1386,6 +1402,21 @@ TrackerOfflineValidation::bookSummaryHists(DirectoryWrapper& tfd, const Alignabl sumContainer.sumNormXResiduals_ = tfd.make(Form("h_NormXprime_%s_%d",aliTypeName,i), sumTitle + xTitHists.NormResXprimeHisto->GetXaxis()->GetTitle(), nbins, xmin, xmax); + + if ( moduleLevelProfiles_ ) { + this->getBinning(aliDetId.subdetId(), XResidualProfile, nbins, xmin, xmax); + sumContainer.sumResXvsXProfile_ = tfd.make(Form("p_resXX_%s_%d",aliTypeName,i), + sumTitle + xTitHists.ResXvsXProfile->GetXaxis()->GetTitle() + + ";" + xTitHists.ResXvsXProfile->GetYaxis()->GetTitle(), + nbins, xmin, xmax); + sumContainer.sumResXvsXProfile_->Sumw2(); + sumContainer.sumResXvsYProfile_ = tfd.make(Form("p_resXY_%s_%d",aliTypeName,i), + sumTitle + xTitHists.ResXvsYProfile->GetXaxis()->GetTitle() + + ";" + xTitHists.ResXvsYProfile->GetYaxis()->GetTitle(), + nbins, xmin, xmax); + sumContainer.sumResXvsYProfile_->Sumw2(); + } + if (bookResidY) { this->getBinning(aliDetId.subdetId(), YprimeResidual, nbins, xmin, xmax); sumContainer.sumYResiduals_ = tfd.make(Form("h_Yprime_%s_%d",aliTypeName,i), @@ -1396,6 +1427,20 @@ TrackerOfflineValidation::bookSummaryHists(DirectoryWrapper& tfd, const Alignabl sumContainer.sumNormYResiduals_ = tfd.make(Form("h_NormYprime_%s_%d",aliTypeName,i), sumTitle + xTitHists.NormResYprimeHisto->GetXaxis()->GetTitle(), nbins, xmin, xmax); + + if ( moduleLevelProfiles_ ) { + this->getBinning(aliDetId.subdetId(), YResidualProfile, nbins, xmin, xmax); + sumContainer.sumResYvsXProfile_ = tfd.make(Form("p_resYX_%s_%d",aliTypeName,i), + sumTitle + xTitHists.ResYvsXProfile->GetXaxis()->GetTitle() + + ";" + xTitHists.ResYvsXProfile->GetYaxis()->GetTitle(), + nbins, xmin, xmax); + sumContainer.sumResYvsXProfile_->Sumw2(); + sumContainer.sumResYvsYProfile_ = tfd.make(Form("p_resYY_%s_%d",aliTypeName,i), + sumTitle + xTitHists.ResYvsYProfile->GetXaxis()->GetTitle() + + ";" + xTitHists.ResYvsYProfile->GetYaxis()->GetTitle(), + nbins, xmin, xmax); + sumContainer.sumResYvsYProfile_->Sumw2(); + } } // If we are at the lowest level, we already sum up and fill the summary. @@ -1408,9 +1453,17 @@ TrackerOfflineValidation::bookSummaryHists(DirectoryWrapper& tfd, const Alignabl this->summarizeBinInContainer(k+1, detid.subdetId() ,sumContainer, histStruct ); sumContainer.sumXResiduals_->Add(histStruct.ResXprimeHisto); sumContainer.sumNormXResiduals_->Add(histStruct.NormResXprimeHisto); + if ( moduleLevelProfiles_ ) { + sumContainer.sumResXvsXProfile_->Add(histStruct.ResXvsXProfile); + sumContainer.sumResXvsYProfile_->Add(histStruct.ResXvsYProfile); + } if( this->isPixel(detid.subdetId()) || stripYResiduals_ ) { sumContainer.sumYResiduals_->Add(histStruct.ResYprimeHisto); sumContainer.sumNormYResiduals_->Add(histStruct.NormResYprimeHisto); + if ( moduleLevelProfiles_ ) { + sumContainer.sumResYvsXProfile_->Add(histStruct.ResYvsXProfile); + sumContainer.sumResYvsYProfile_->Add(histStruct.ResYvsYProfile); + } } } } else if( subtype == align::AlignableDet && subcompSize > 1) { // fixed: was aliSize before @@ -1422,9 +1475,17 @@ TrackerOfflineValidation::bookSummaryHists(DirectoryWrapper& tfd, const Alignabl this->summarizeBinInContainer(2*k+j+1, detid.subdetId() ,sumContainer, histStruct ); sumContainer.sumXResiduals_->Add( histStruct.ResXprimeHisto); sumContainer.sumNormXResiduals_->Add( histStruct.NormResXprimeHisto); + if ( moduleLevelProfiles_ ) { + sumContainer.sumResXvsXProfile_->Add(histStruct.ResXvsXProfile); + sumContainer.sumResXvsYProfile_->Add(histStruct.ResXvsYProfile); + } if( this->isPixel(detid.subdetId()) || stripYResiduals_ ) { sumContainer.sumYResiduals_->Add( histStruct.ResYprimeHisto); sumContainer.sumNormYResiduals_->Add( histStruct.NormResYprimeHisto); + if ( moduleLevelProfiles_ ) { + sumContainer.sumResYvsXProfile_->Add(histStruct.ResYvsXProfile); + sumContainer.sumResYvsYProfile_->Add(histStruct.ResYvsYProfile); + } } } } diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/alternateValidationTemplates.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/alternateValidationTemplates.py index cee56ed869d23..281f7a6c97cbf 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/alternateValidationTemplates.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/alternateValidationTemplates.py @@ -5,192 +5,6 @@ """ -###################################################################### -###################################################################### -yResidualsOfflineValidation=""" -import FWCore.ParameterSet.Config as cms - -process = cms.Process("OfflineValidator") - -process.load("Alignment.OfflineValidation..oO[dataset]Oo._cff") - -process.source.inputCommands = cms.untracked.vstring('keep *', 'drop *_MEtoEDMConverter_*_*') # hack to get rid of the memory consumption problem in 2_2_X and beond -process.options = cms.untracked.PSet( - wantSummary = cms.untracked.bool(False), - Rethrow = cms.untracked.vstring("ProductNotFound"), # make this exception fatal - fileMode = cms.untracked.string('NOMERGE') # no ordering needed, but calls endRun/beginRun etc. at file boundaries -) - - ## - ## Maximum number of Events - ## -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(.oO[nEvents]Oo.) - ) - - ## - ## Messages & Convenience - ## -process.load("FWCore.MessageLogger.MessageLogger_cfi") -process.MessageLogger = cms.Service("MessageLogger", - destinations = cms.untracked.vstring('LOGFILE_Offline_.oO[name]Oo.', - 'cout') -) - - ## report only every 100th record - ##process.MessageLogger.cerr.FwkReport.reportEvery = 100 - - - ## - ## Alignment Track Selection - ## -process.load("Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi") -process.AlignmentTrackSelector.src = 'TrackRefitter1' -process.AlignmentTrackSelector.filter = True -process.AlignmentTrackSelector.applyBasicCuts = True -process.AlignmentTrackSelector.pMin = 4. -process.AlignmentTrackSelector.pMax = 9999. -process.AlignmentTrackSelector.ptMin = 0. -process.AlignmentTrackSelector.ptMax = 9999. -process.AlignmentTrackSelector.etaMin = -999. -process.AlignmentTrackSelector.etaMax = 999. -process.AlignmentTrackSelector.nHitMin = 8 -process.AlignmentTrackSelector.nHitMin2D = 2 -process.AlignmentTrackSelector.chi2nMax = 999. -process.AlignmentTrackSelector.applyMultiplicityFilter = False -process.AlignmentTrackSelector.maxMultiplicity = 1 -process.AlignmentTrackSelector.applyNHighestPt = False -process.AlignmentTrackSelector.nHighestPt = 1 -process.AlignmentTrackSelector.seedOnlyFrom = 0 -process.AlignmentTrackSelector.applyIsolationCut = False -process.AlignmentTrackSelector.minHitIsolation = 0.8 -process.AlignmentTrackSelector.applyChargeCheck = False -process.AlignmentTrackSelector.minHitChargeStrip = 50. -#process.AlignmentTrackSelector.trackQualities = ["highPurity"] -#process.AlignmentTrackSelector.iterativeTrackingSteps = ["iter1","iter2"] - -#### new FILTER -#-- new track hit filter -# TrackerTrackHitFilter takes as input the tracks/trajectories coming out from TrackRefitter1 -process.load("RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff") -process.TrackerTrackHitFilter.src = 'TrackRefitter1' -process.TrackerTrackHitFilter.useTrajectories= True # this is needed only if you require some selections; but it will work even if you don't ask for them -process.TrackerTrackHitFilter.minimumHits = 8 -process.TrackerTrackHitFilter.commands = cms.vstring("keep PXB","keep PXE","keep TIB","keep TID","keep TOB","keep TEC") -process.TrackerTrackHitFilter.detsToIgnore = [] -process.TrackerTrackHitFilter.replaceWithInactiveHits = True -process.TrackerTrackHitFilter.stripAllInvalidHits = False -process.TrackerTrackHitFilter.rejectBadStoNHits = True -process.TrackerTrackHitFilter.StoNcommands = cms.vstring("ALL 14.0") -process.TrackerTrackHitFilter.rejectLowAngleHits= True -process.TrackerTrackHitFilter.TrackAngleCut= 0.35 # in rads, starting from the module surface -process.TrackerTrackHitFilter.usePixelQualityFlag= True - -#now we give the TrackCandidate coming out of the TrackerTrackHitFilter to the track producer -import RecoTracker.TrackProducer.CosmicFinalFitWithMaterialP5_cff -process.HitFilteredTracks = RecoTracker.TrackProducer.CosmicFinalFitWithMaterialP5_cff.cosmictrackfinderP5.clone( - src = 'TrackerTrackHitFilter' -) - - ## - ## Load and Configure TrackRefitter1 - ## - -process.load("RecoTracker.TrackProducer.TrackRefitters_cff") - -process.TrackRefitter1 = RecoTracker.TrackProducer.TrackRefitterP5_cfi.TrackRefitterP5.clone( - src = '.oO[TrackCollection]Oo.', - TrajectoryInEvent = True, - TTRHBuilder = "WithTrackAngle", - NavigationSchool = "" -) - -process.TrackRefitter2 = process.TrackRefitter1.clone( - src = 'HitFilteredTracks') - - - ## - ## Get the BeamSpot - ## -process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff") - - ## - ## GlobalTag Conditions (if needed) - ## -process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") -process.GlobalTag.globaltag = ".oO[GlobalTag]Oo." -#process.GlobalTag.connect="frontier://FrontierProd/CMS_COND_21X_GLOBALTAG" -# process.GlobalTag.connect="frontier://FrontierProd/CMS_COND_31X_GLOBALTAG" - -## LAYERWISE Lorentz Angle ################### - -process.SiStripLorentzAngle = cms.ESSource("PoolDBESSource", - BlobStreamerName = -cms.untracked.string('TBufferBlobStreamingService'), - DBParameters = cms.PSet( - messageLevel = cms.untracked.int32(2), - authenticationPath = -cms.untracked.string('/afs/cern.ch/cms/DB/conddb') - ), - timetype = cms.string('runnumber'), - toGet = cms.VPSet(cms.PSet( - record = cms.string('SiStripLorentzAngleRcd'), - tag = cms.string('SiStripLA_CRAFT_layers') - )), - connect = cms.string('sqlite_file:/afs/cern.ch/user/j/jdraeger/public/LA_object/LA_CRAFT_layers.db') -) -process.es_prefer_SiStripLorentzAngle = cms.ESPrefer("PoolDBESSource","SiStripLorentzAngle") - - ## - ## Geometry - ## -process.load("Configuration.Geometry.GeometryDB_cff") - - ## - ## Magnetic Field - ## -process.load("Configuration/StandardSequences/.oO[magneticField]Oo._cff") - -.oO[condLoad]Oo. - -## to apply misalignments -#TrackerDigiGeometryESModule.applyAlignment = True - - ## - ## Load and Configure OfflineValidation - ## -process.load("Alignment.OfflineValidation.TrackerOfflineValidation_.oO[offlineValidationMode]Oo._cff") -process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..Tracks = 'TrackRefitter2' -process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..trajectoryInput = 'TrackRefitter2' -process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelHistsTransient = cms.bool(.oO[offlineModuleLevelHistsTransient]Oo.) -process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..stripYResiduals = True -.oO[offlineValidationFileOutput]Oo. - - ## - ## PATH - ## -process.p = cms.Path(process.offlineBeamSpot*process.TrackRefitter1*process.TrackerTrackHitFilter*process.HitFilteredTracks - *process.TrackRefitter2*process.AlignmentTrackSelector*process.seqTrackerOfflineValidation.oO[offlineValidationMode]Oo.) - -""" - - -###################################################################### -###################################################################### -zeroAPETemplate=""" -from CondCore.DBCommon.CondDBSetup_cfi import * -process.APE = cms.ESSource("PoolDBESSource",CondDBSetup, - connect = cms.string('frontier://FrontierProd/CMS_COND_31X_FROM21X'), - timetype = cms.string("runnumber"), - toGet = cms.VPSet( - cms.PSet(record = cms.string('TrackerAlignmentErrorExtendedRcd'), - tag = cms.string('TrackerIdealGeometryErrors210_mc') - )) - ) -process.es_prefer_APE = cms.ESPrefer("PoolDBESSource", "APE") -""" - - ###################################################################### ###################################################################### CosmicsOfflineValidation=""" @@ -316,6 +130,7 @@ process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..trajectoryInput = 'TrackRefitter2' process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelHistsTransient = cms.bool(.oO[offlineModuleLevelHistsTransient]Oo.) process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelProfiles = cms.bool(.oO[offlineModuleLevelProfiles]Oo.) +process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..stripYResiduals = .oO[stripYResiduals]Oo. process.TFileService.fileName = '.oO[outputFile]Oo.' ## @@ -466,6 +281,8 @@ process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..Tracks = 'TrackRefitter2' process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..trajectoryInput = 'TrackRefitter2' process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelHistsTransient = cms.bool(.oO[offlineModuleLevelHistsTransient]Oo.) +process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelProfiles = cms.bool(.oO[offlineModuleLevelProfiles]Oo.) +process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..stripYResiduals = .oO[stripYResiduals]Oo. process.TFileService.fileName = '.oO[outputFile]Oo.' ## @@ -880,148 +697,6 @@ -""" - - -###################################################################### -###################################################################### -CosmicsOfflineValidation_Deformations=""" -import FWCore.ParameterSet.Config as cms - -process = cms.Process("OfflineValidator") - -process.load("Alignment.OfflineValidation..oO[dataset]Oo._cff") - -#process.source.inputCommands = cms.untracked.vstring('keep *', 'drop *_MEtoEDMConverter_*_*') # hack to get rid of the memory consumption problem in 2_2_X and beond -process.options = cms.untracked.PSet( - wantSummary = cms.untracked.bool(False), - Rethrow = cms.untracked.vstring("ProductNotFound"), # make this exception fatal - fileMode = cms.untracked.string('NOMERGE') # no ordering needed, but calls endRun/beginRun etc. at file boundaries -) - - ## - ## Maximum number of Events - ## -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(.oO[nEvents]Oo.) - ) - - ## - ## Messages & Convenience - ## -process.load("FWCore.MessageLogger.MessageLogger_cfi") -process.MessageLogger.cerr = cms.untracked.PSet(placeholder = cms.untracked.bool(True)) -process.MessageLogger.cout = cms.untracked.PSet(INFO = cms.untracked.PSet( -reportEvery = cms.untracked.int32(1000) # every 1000th only -# limit = cms.untracked.int32(10) # or limit to 10 printouts... -)) -process.MessageLogger.statistics.append('cout') - - -#-- Track hit filter -# TrackerTrackHitFilter takes as input the tracks/trajectories coming out from TrackRefitter1 -process.load("RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff") -process.TrackerTrackHitFilter.src = 'TrackRefitter1' - - - -#-- Alignment Track Selection -process.load("Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi") -process.AlignmentTrackSelector.src = 'HitFilteredTracks' -process.AlignmentTrackSelector.filter = True - -.oO[TrackSelectionTemplate]Oo. - -#now we give the TrackCandidate coming out of the TrackerTrackHitFilter to the track producer -import RecoTracker.TrackProducer.CTFFinalFitWithMaterialP5_cff -process.HitFilteredTracks = RecoTracker.TrackProducer.CTFFinalFitWithMaterialP5_cff.ctfWithMaterialTracksCosmics.clone( - src = 'TrackerTrackHitFilter', -### TrajectoryInEvent = True, - NavigationSchool = '', - TTRHBuilder = "WithAngleAndTemplate" -) - - ## - ## Load and Configure TrackRefitter1 - ## - - -############# -process.load("RecoTracker.TrackProducer.TrackRefitters_cff") - -process.TrackRefitter1 = process.TrackRefitterP5.clone( - src = 'ALCARECOTkAlCosmicsCTF0T', - TrajectoryInEvent = True, - NavigationSchool = '', - TTRHBuilder = "WithAngleAndTemplate" -) -process.TrackRefitter2 = process.TrackRefitter1.clone( - src = 'AlignmentTrackSelector', - - ) - - - ## - ## Get the BeamSpot - ## -process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff") - - ## - ## GlobalTag Conditions (if needed) - ## -process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") -# process.GlobalTag.connect = "frontier://FrontierProd/CMS_COND_31X_GLOBALTAG" -process.GlobalTag.globaltag = ".oO[GlobalTag]Oo." - - -.oO[LorentzAngleTemplate]Oo. - - ## - ## Geometry - ## -process.load("Configuration.Geometry.GeometryDB_cff") - - ## - ## Magnetic Field - ## -process.load("Configuration/StandardSequences/.oO[magneticField]Oo._cff") - -.oO[condLoad]Oo. - -from CondCore.DBCommon.CondDBSetup_cfi import * -process.trackerSurfaces = cms.ESSource( - "PoolDBESSource", - CondDBSetup, - connect = cms.string('.oO[dbpath]Oo.'), - toGet = cms.VPSet(cms.PSet(record = cms.string("TrackerSurfaceDeformationRcd"), - tag = cms.string("Deformations") - ) - ) - ) -process.es_prefer_trackerSurfaces = cms.ESPrefer("PoolDBESSource", "trackerSurfaces") - -## to apply misalignments -#TrackerDigiGeometryESModule.applyAlignment = True - - ## - ## Load and Configure OfflineValidation - ## - -process.load("Alignment.OfflineValidation.TrackerOfflineValidation_.oO[offlineValidationMode]Oo._cff") -process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..Tracks = 'TrackRefitter2' -process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..trajectoryInput = 'TrackRefitter2' -#process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelHistsTransient = cms.bool(.oO[offlineModuleLevelHistsTransient]Oo.) -process.TrackerOfflineValidationStandalone.moduleLevelHistsTransient = cms.bool(False) -process.TrackerOfflineValidationStandalone.moduleLevelProfiles = cms.bool(True) -process.TFileService.fileName = '.oO[outputFile]Oo.' - - ## - ## PATH - ## -process.p = cms.Path(process.offlineBeamSpot*process.TrackRefitter1*process.TrackerTrackHitFilter*process.HitFilteredTracks - *process.AlignmentTrackSelector*process.TrackRefitter2*process.seqTrackerOfflineValidation.oO[offlineValidationMode]Oo.) - - """ diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/dataset.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/dataset.py index cd9bb95f4af48..9d078d7140d39 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/dataset.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/dataset.py @@ -202,15 +202,30 @@ def __createSnippet( self, jsonPath = None, begin = None, end = None, lumiSecExtend = jsoncontents splitLumiList = [[""]] - if not len(splitLumiList[0][0]) == 0: - lumiSecStr = [ "',\n'".join( lumis ) \ - for lumis in splitLumiList ] - lumiSecStr = [ "lumiSecs.extend( [\n'" + lumis + "'\n] )" \ - for lumis in lumiSecStr ] - lumiSecExtend = "\n".join( lumiSecStr ) - runlist = self.__getRunList() - self.__firstusedrun = max(int(splitLumiList[0][0].split(":")[0]), int(self.__findInJson(runlist[0],"run_number"))) - self.__lastusedrun = min(int(splitLumiList[-1][-1].split(":")[0]), int(self.__findInJson(runlist[-1],"run_number"))) + if splitLumiList and splitLumiList[0]: + if splitLumiList[0][0]: + lumiSecStr = [ "',\n'".join( lumis ) \ + for lumis in splitLumiList ] + lumiSecStr = [ "lumiSecs.extend( [\n'" + lumis + "'\n] )" \ + for lumis in lumiSecStr ] + lumiSecExtend = "\n".join( lumiSecStr ) + runlist = self.__getRunList() + self.__firstusedrun = max(int(splitLumiList[0][0].split(":")[0]), int(self.__findInJson(runlist[0],"run_number"))) + self.__lastusedrun = min(int(splitLumiList[-1][-1].split(":")[0]), int(self.__findInJson(runlist[-1],"run_number"))) + else: + msg = "You are trying to run a validation without any runs! Check that:" + if firstRun or lastRun: + msg += "\n - firstRun and lastRun are correct for this dataset, and there are runs in between containing data" + if jsonPath: + msg += "\n - your JSON file is correct for this dataset, and the runs contain data" + if (firstRun or lastRun) and jsonPath: + msg += "\n - firstRun and lastRun are consistent with your JSON file" + if begin: + msg = msg.replace("firstRun", "begin") + if end: + msg = msg.replace("lastRun", "end") + raise AllInOneError(msg) + else: runlist = self.__getRunList() self.__firstusedrun = int(self.__findInJson(self.__getRunList()[0],"run_number")) diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/offlineValidation.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/offlineValidation.py index c1a255c774bba..63c698be0c53f 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/offlineValidation.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/offlineValidation.py @@ -15,9 +15,10 @@ def __init__(self, valName, alignment, config, addDefaults = {}, addMandatories "DMRMinimum":"30", "DMROptions":"", "offlineModuleLevelHistsTransient":"False", - "offlineModuleLevelProfiles":"False", + "offlineModuleLevelProfiles":"True", "OfflineTreeBaseDir":"TrackHitFilter", - "SurfaceShapes":"none" + "SurfaceShapes":"coarse", + "stripYResiduals":"False", } mandatories = [ "trackcollection" ] defaults.update(addDefaults) diff --git a/Alignment/OfflineValidation/python/TkAlAllInOneTool/offlineValidationTemplates.py b/Alignment/OfflineValidation/python/TkAlAllInOneTool/offlineValidationTemplates.py index 53e9ea9db26dd..d070c85fc568b 100644 --- a/Alignment/OfflineValidation/python/TkAlAllInOneTool/offlineValidationTemplates.py +++ b/Alignment/OfflineValidation/python/TkAlAllInOneTool/offlineValidationTemplates.py @@ -175,6 +175,7 @@ process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..trajectoryInput = 'TrackRefitter2' process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelHistsTransient = .oO[offlineModuleLevelHistsTransient]Oo. process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelProfiles = .oO[offlineModuleLevelProfiles]Oo. +process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..stripYResiduals = .oO[stripYResiduals]Oo. .oO[offlineValidationFileOutput]Oo. ##