CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
TrackerOfflineValidationSummary Class Reference

#include <Alignment/TrackerOfflineValidationSummary/src/TrackerOfflineValidationSummary.cc>

Inheritance diagram for TrackerOfflineValidationSummary:
edm::EDAnalyzer edm::EDConsumerBase

Classes

struct  HarvestingHierarchy
 
struct  HarvestingHistos
 Put here the histograms created during harvesting. More...
 
struct  ModuleHistos
 

Public Member Functions

 TrackerOfflineValidationSummary (const edm::ParameterSet &)
 
 ~TrackerOfflineValidationSummary ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

virtual void analyze (const edm::Event &evt, const edm::EventSetup &) override
 
void applyHarvestingHierarchy (TTree &treeMem)
 
const std::string associateModuleHistsWithTree (const TkOffTreeVariables &treeMem, TrackerOfflineValidationSummary::ModuleHistos &moduleHists, std::map< std::string, std::string > &substructureName)
 
void bookHarvestingHists ()
 
void collateHarvestingHists (TTree &tree)
 
virtual void endJob () override
 
void fillHarvestingHists (TTree &tree)
 
void fillTree (TTree &tree, std::map< int, TrackerOfflineValidationSummary::ModuleHistos > &moduleHist, TkOffTreeVariables &treeMem, const TrackerGeometry &tkgeom, std::map< std::string, std::string > &substructureName, const TrackerTopology *tTopo)
 
std::pair< float, float > fitResiduals (TH1 *hist) const
 
void getBinning (const std::string &binningPSetName, int &nBinsX, double &lowerBoundX, double &upperBoundX) const
 
float getMedian (const TH1 *hist) const
 

Private Attributes

DQMStoredbe_
 
const edm::EventSetuplastSetup_
 
const std::string moduleDirectory_
 
bool moduleMapsInitialized
 
std::map< int, TrackerOfflineValidationSummary::ModuleHistosmPxbResiduals_
 
std::map< int, TrackerOfflineValidationSummary::ModuleHistosmPxeResiduals_
 
std::map< int, TrackerOfflineValidationSummary::ModuleHistosmTecResiduals_
 
std::map< int, TrackerOfflineValidationSummary::ModuleHistosmTibResiduals_
 
std::map< int, TrackerOfflineValidationSummary::ModuleHistosmTidResiduals_
 
std::map< int, TrackerOfflineValidationSummary::ModuleHistosmTobResiduals_
 
const edm::ParameterSet parSet_
 
edm::ESHandle< TrackerGeometrytkGeom_
 
const bool useFit_
 
std::vector< HarvestingHierarchyvHarvestingHierarchy_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 62 of file TrackerOfflineValidationSummary.cc.

Constructor & Destructor Documentation

TrackerOfflineValidationSummary::TrackerOfflineValidationSummary ( const edm::ParameterSet iConfig)
explicit
TrackerOfflineValidationSummary::~TrackerOfflineValidationSummary ( )

Definition at line 163 of file TrackerOfflineValidationSummary.cc.

164 {
165 
166  // do anything here that needs to be done at desctruction time
167  // (e.g. close files, deallocate resources etc.)
168 
169 }

Member Function Documentation

void TrackerOfflineValidationSummary::analyze ( const edm::Event evt,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Definition at line 178 of file TrackerOfflineValidationSummary.cc.

References DetId::det(), TrackerGeometry::detIds(), Exception, edm::EventSetup::get(), lastSetup_, moduleMapsInitialized, mPxbResiduals_, mPxeResiduals_, mTecResiduals_, mTibResiduals_, mTidResiduals_, mTobResiduals_, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, DetId::rawId(), DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, tkGeom_, and StripSubdetector::TOB.

179 {
180  lastSetup_ = &iSetup;
181 
182  // Access of EventSetup is needed to get the list of silicon-modules and their IDs
183  // Since they do not change, it is accessed only once
184  if(moduleMapsInitialized)return;
185  iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom_ );
186  const TrackerGeometry* bareTkGeomPtr = &(*tkGeom_);
187  const TrackingGeometry::DetIdContainer& detIdContainer = bareTkGeomPtr->detIds();
188  std::vector<DetId>::const_iterator iDet;
189  for(iDet = detIdContainer.begin(); iDet != detIdContainer.end(); ++iDet){
190  const DetId& detId = *iDet;
191  const uint32_t rawId = detId.rawId();
192  const unsigned int subdetId = detId.subdetId();
193  if (subdetId == PixelSubdetector::PixelBarrel) mPxbResiduals_[rawId];
194  else if(subdetId == PixelSubdetector::PixelEndcap) mPxeResiduals_[rawId];
195  else if(subdetId == StripSubdetector::TIB) mTibResiduals_[rawId];
196  else if(subdetId == StripSubdetector::TID) mTidResiduals_[rawId];
197  else if(subdetId == StripSubdetector::TOB) mTobResiduals_[rawId];
198  else if(subdetId == StripSubdetector::TEC) mTecResiduals_[rawId];
199  else {
200  throw cms::Exception("Geometry Error")
201  << "[TrackerOfflineValidationSummary] Error, tried to get reference for non-tracker subdet " << subdetId
202  << " from detector " << detId.det();
203  }
204  }
205  moduleMapsInitialized = true;
206 }
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mPxbResiduals_
edm::ESHandle< TrackerGeometry > tkGeom_
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mTibResiduals_
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mTobResiduals_
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mPxeResiduals_
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mTidResiduals_
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:56
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mTecResiduals_
const DetIdContainer & detIds() const
Returm a vector of all GeomDet DetIds (including those of GeomDetUnits)
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
std::vector< DetId > DetIdContainer
void TrackerOfflineValidationSummary::applyHarvestingHierarchy ( TTree &  treeMem)
private

Definition at line 667 of file TrackerOfflineValidationSummary.cc.

References bookHarvestingHists(), TkOffTreeVariables::isDoubleSide, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, TkOffTreeVariables::side, AlCaHLTBitMon_QueryRunRegistry::string, TkOffTreeVariables::subDetId, StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, and vHarvestingHierarchy_.

Referenced by collateHarvestingHists().

668 {
669  TkOffTreeVariables *treeMemPtr = 0;
670  std::map<std::string,std::string> *substructureName = 0;
671  tree.SetBranchAddress("TkOffTreeVariables", &treeMemPtr);
672  tree.SetBranchAddress("SubstructureName", &substructureName);
673 
674  // Loop over modules to select accumulation criteria for harvesting plots
675  for(unsigned int iSubdet = 1; iSubdet<7; ++iSubdet){
676  std::string hierarchyName("");
677  std::string componentName("");
678  std::vector<unsigned int> treeEntries;
679  for(unsigned int iSide = 1; iSide<3; ++iSide){
680  // Set up only one collection for Barrels, not separated for side
681  if(iSide==1 && (iSubdet==PixelSubdetector::PixelBarrel || iSubdet==StripSubdetector::TIB || iSubdet==StripSubdetector::TOB))continue;
682  for(int iTree=0; iTree<tree.GetEntries(); ++iTree){
683  tree.GetEntry(iTree);
684  // Do not use glued Dets
685  if(treeMemPtr->isDoubleSide)continue;
686  if(treeMemPtr->subDetId == iSubdet){
687  if(iSide!=treeMemPtr->side && (iSubdet==PixelSubdetector::PixelEndcap || iSubdet==StripSubdetector::TID || iSubdet==StripSubdetector::TEC))continue;
688  treeEntries.push_back(iTree);
689  if(hierarchyName.length() == 0){
690  hierarchyName = (*substructureName)["subdet"];
691  componentName = (*substructureName)["component"];
692  }
693  }
694  }
695  HarvestingHierarchy harvestingHierarchy(hierarchyName,componentName,treeEntries);
696  vHarvestingHierarchy_.push_back(harvestingHierarchy);
697  hierarchyName = ""; componentName = ""; treeEntries.clear();
698  }
699  }
700  // Here could be a further separation of the HarvestingHierarchy.
701  // E.g. separate the existing ones by layer and add them to the vector without deleting any element from the vector.
702  // The existing hists will stay and the new ones are added
703 
704  // Now, book the corresponding histos
705  this->bookHarvestingHists();
706 }
container to hold data to be written into TTree
std::vector< HarvestingHierarchy > vHarvestingHierarchy_
Definition: tree.py:1
const std::string TrackerOfflineValidationSummary::associateModuleHistsWithTree ( const TkOffTreeVariables treeMem,
TrackerOfflineValidationSummary::ModuleHistos moduleHists,
std::map< std::string, std::string > &  substructureName 
)
private

Definition at line 472 of file TrackerOfflineValidationSummary.cc.

References TkOffTreeVariables::blade, dbe_, DQMStore::get(), MonitorElement::getTH1(), TkOffTreeVariables::half, ecalSelectiveReadoutValidation_cfi::histDir, TkOffTreeVariables::isDoubleSide, TkOffTreeVariables::layer, TkOffTreeVariables::module, moduleDirectory_, TkOffTreeVariables::moduleId, TrackerOfflineValidationSummary::ModuleHistos::NormResHisto, TrackerOfflineValidationSummary::ModuleHistos::NormResXprimeHisto, TrackerOfflineValidationSummary::ModuleHistos::NormResYprimeHisto, TkOffTreeVariables::outerInner, TkOffTreeVariables::panel, TkOffTreeVariables::petal, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, TrackerOfflineValidationSummary::ModuleHistos::ResHisto, TrackerOfflineValidationSummary::ModuleHistos::ResXprimeHisto, TrackerOfflineValidationSummary::ModuleHistos::ResYprimeHisto, relativeConstraints::ring, TkOffTreeVariables::ring, TkOffTreeVariables::rod, TkOffTreeVariables::side, AlCaHLTBitMon_QueryRunRegistry::string, TkOffTreeVariables::subDetId, StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, and StripSubdetector::TOB.

Referenced by fillTree().

472  {
473  std::stringstream histDir, sSubdetName;
474  std::string componentName;
475  if(moduleDirectory_.length() != 0)histDir<<moduleDirectory_<<"/";
476  std::string wheelOrLayer("_layer_");
478  unsigned int half(treeMem.half), layer(treeMem.layer), ladder(0);
479  if(layer==1){
480  if(half==2)ladder = treeMem.rod -5;
481  else if(treeMem.rod>15)ladder = treeMem.rod -10;
482  else ladder = treeMem.rod;
483  }else if(layer==2){
484  if(half==2)ladder = treeMem.rod -8;
485  else if(treeMem.rod>24)ladder = treeMem.rod -16;
486  else ladder = treeMem.rod;
487  }else if(layer==3){
488  if(half==2)ladder = treeMem.rod -11;
489  else if(treeMem.rod>33)ladder = treeMem.rod -22;
490  else ladder = treeMem.rod;
491  }
492  componentName = "Pixel";
493  sSubdetName<<"TPBBarrel_1";
494  histDir<<componentName<<"/"<<sSubdetName.str()<<"/TPBHalfBarrel_"<<treeMem.half<<"/TPBLayer_"<<treeMem.layer<<"/TPBLadder_"<<ladder;
495  }else if(treeMem.subDetId == PixelSubdetector::PixelEndcap){
496  unsigned int side(treeMem.side), half(treeMem.half), blade(0);
497  if(side==1)side=3;
498  if(half==2)blade = treeMem.blade -6;
499  else if(treeMem.blade>18)blade = treeMem.blade -12;
500  else blade = treeMem.blade;
501  componentName = "Pixel";
502  sSubdetName<<"TPEEndcap_"<<side;
503  histDir<<componentName<<"/"<<sSubdetName.str()<<"/TPEHalfCylinder_"<<treeMem.half<<"/TPEHalfDisk_"<<treeMem.layer<<"/TPEBlade_"<<blade<<"/TPEPanel_"<<treeMem.panel;
504  wheelOrLayer = "_wheel_";
505  }else if(treeMem.subDetId == StripSubdetector::TIB){
506  unsigned int half(treeMem.half), layer(treeMem.layer), surface(treeMem.outerInner), string(0);
507  if(half==2){
508  if(layer==1){
509  if(surface==1)string = treeMem.rod -13;
510  else if(surface==2)string = treeMem.rod -15;
511  }
512  if(layer==2){
513  if(surface==1)string = treeMem.rod -17;
514  else if(surface==2)string = treeMem.rod -19;
515  }
516  if(layer==3){
517  if(surface==1)string = treeMem.rod -22;
518  else if(surface==2)string = treeMem.rod -23;
519  }
520  if(layer==4){
521  if(surface==1)string = treeMem.rod -26;
522  else if(surface==2)string = treeMem.rod -28;
523  }
524  }
525  else string = treeMem.rod;
526  std::stringstream detString;
527  if(treeMem.layer<3 && !treeMem.isDoubleSide)detString<<"/Det_"<<treeMem.module;
528  else detString<<"";
529  componentName = "Strip";
530  sSubdetName<<"TIBBarrel_1";
531  histDir<<componentName<<"/"<<sSubdetName.str()<<"/TIBHalfBarrel_"<<treeMem.side<<"/TIBLayer_"<<treeMem.layer<<"/TIBHalfShell_"<<treeMem.half<<"/TIBSurface_"<<treeMem.outerInner<<"/TIBString_"<<string<<detString.str();
532  }else if(treeMem.subDetId == StripSubdetector::TID){
533  unsigned int side(treeMem.side), outerInner(0);
534  if(side==1)side=3;
535  if(treeMem.outerInner==1)outerInner=2;
536  else if(treeMem.outerInner==2)outerInner=1;
537  std::stringstream detString;
538  if(treeMem.ring<3 && !treeMem.isDoubleSide)detString<<"/Det_"<<treeMem.module;
539  else detString<<"";
540  componentName = "Strip";
541  sSubdetName<<"TIDEndcap_"<<side;
542  histDir<<componentName<<"/"<<sSubdetName.str()<<"/TIDDisk_"<<treeMem.layer<<"/TIDRing_"<<treeMem.ring<<"/TIDSide_"<<outerInner<<detString.str();
543  wheelOrLayer = "_wheel_";
544  }else if(treeMem.subDetId == StripSubdetector::TOB){
545  std::stringstream detString;
546  if(treeMem.layer<3 && !treeMem.isDoubleSide)detString<<"/Det_"<<treeMem.module;
547  else detString<<"";
548  componentName = "Strip";
549  sSubdetName<<"TOBBarrel_4";
550  histDir<<componentName<<"/"<<sSubdetName.str()<<"/TOBHalfBarrel_"<<treeMem.side<<"/TOBLayer_"<<treeMem.layer<<"/TOBRod_"<<treeMem.rod<<detString.str();
551  }else if(treeMem.subDetId == StripSubdetector::TEC) {
552  unsigned int side(0), outerInner(0), ring(0);
553  if(treeMem.side==1)side=6;
554  else if(treeMem.side==2)side=5;
555  if(treeMem.outerInner==1)outerInner = 2;
556  else if(treeMem.outerInner==2)outerInner=1;
557  if(treeMem.layer>3 && treeMem.layer<7)ring = treeMem.ring -1;
558  else if(treeMem.layer==7 || treeMem.layer==8)ring = treeMem.ring -2;
559  else if(treeMem.layer==9)ring = treeMem.ring -3;
560  else ring = treeMem.ring;
561  std::stringstream detString;
562  if((treeMem.ring<3 || treeMem.ring==5) && !treeMem.isDoubleSide)detString<<"/Det_"<<treeMem.module;
563  else detString<<"";
564  componentName = "Strip";
565  sSubdetName<<"TECEndcap_"<<side;
566  histDir<<componentName<<"/"<<sSubdetName.str()<<"/TECDisk_"<<treeMem.layer<<"/TECSide_"<<outerInner<<"/TECPetal_"<<treeMem.petal<<"/TECRing_"<<ring<<detString.str();
567  wheelOrLayer = "_wheel_";
568  }
569 
570  substructureName["component"] = componentName;
571  substructureName["subdet"] = sSubdetName.str();
572 
573  std::stringstream histName;
574  histName<<"residuals_subdet_"<<treeMem.subDetId<<wheelOrLayer<<treeMem.layer<<"_module_"<<treeMem.moduleId;
575 
576  std::string fullPath;
577  fullPath = histDir.str()+"/h_xprime_"+histName.str();
578  if(dbe_->get(fullPath)) moduleHists.ResXprimeHisto = dbe_->get(fullPath)->getTH1();
579  else{edm::LogError("TrackerOfflineValidationSummary")<<"Problem with names in input file produced in TrackerOfflineValidation ...\n"
580  <<"This histogram should exist in every configuration, "
581  <<"but no histogram with name "<<fullPath<<" is found!";
582  return "";
583  }
584  fullPath = histDir.str()+"/h_normxprime"+histName.str();
585  if(dbe_->get(fullPath)) moduleHists.NormResXprimeHisto = dbe_->get(fullPath)->getTH1();
586  fullPath = histDir.str()+"/h_yprime_"+histName.str();
587  if(dbe_->get(fullPath)) moduleHists.ResYprimeHisto = dbe_->get(fullPath)->getTH1();
588  fullPath = histDir.str()+"/h_normyprime"+histName.str();
589  if(dbe_->get(fullPath)) moduleHists.NormResYprimeHisto = dbe_->get(fullPath)->getTH1();
590  fullPath = histDir.str()+"/h_"+histName.str();
591  if(dbe_->get(fullPath)) moduleHists.ResHisto = dbe_->get(fullPath)->getTH1();
592  fullPath = histDir.str()+"/h_norm"+histName.str();
593  if(dbe_->get(fullPath)) moduleHists.NormResHisto = dbe_->get(fullPath)->getTH1();
594 
595  return histDir.str();
596 }
TH1 * getTH1(void) const
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
Definition: DQMStore.cc:1788
void TrackerOfflineValidationSummary::bookHarvestingHists ( )
private

Definition at line 710 of file TrackerOfflineValidationSummary.cc.

References DQMStore::book1D(), dbe_, getBinning(), edm::ParameterSet::getParameter(), moduleDirectory_, parSet_, DQMStore::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, vHarvestingHierarchy_, anotherprimaryvertexanalyzer_cfi::xMax, and anotherprimaryvertexanalyzer_cfi::xMin.

Referenced by applyHarvestingHierarchy().

711 {
712  edm::LogInfo("TrackerOfflineValidationSummary")<<"Harvesting histograms will be booked for "<<vHarvestingHierarchy_.size()<<" different hierarchy selections";
713  for(std::vector<HarvestingHierarchy>::iterator iHier = vHarvestingHierarchy_.begin(); iHier != vHarvestingHierarchy_.end(); ++iHier){
714 
715  std::stringstream dmrXprimeHistoName, dmrYprimeHistoName, dmrXprimeHistoTitle, dmrYprimeHistoTitle;
716  dmrXprimeHistoName << "h_DmrXprime_" << iHier->hierarchyName;
717  dmrYprimeHistoName << "h_DmrYprime_" << iHier->hierarchyName;
718  dmrXprimeHistoTitle<< "DMR for " << iHier->hierarchyName <<";<#DeltaX> [cm];# modules";
719  dmrYprimeHistoTitle<< "DMR for " << iHier->hierarchyName <<";<#DeltaY> [cm];# modules";
720 
721  std::string directoryString(moduleDirectory_);
722  if(directoryString.length()!=0)directoryString += "/";
723  directoryString += iHier->componentName;
724  dbe_->setCurrentFolder(directoryString);
725 
726  int nBinsX(0); double xMin(0.), xMax(0.);
727  if(iHier->componentName == "Pixel"){
728  this->getBinning("TH1DmrXprimePixelModules",nBinsX,xMin,xMax);
729  iHier->harvestingHistos.DmrXprime = dbe_->book1D(dmrXprimeHistoName.str(),dmrXprimeHistoTitle.str(),nBinsX,xMin,xMax)->getTH1();
730  this->getBinning("TH1DmrYprimePixelModules",nBinsX,xMin,xMax);
731  iHier->harvestingHistos.DmrYprime = dbe_->book1D(dmrYprimeHistoName.str(),dmrYprimeHistoTitle.str(),nBinsX,xMin,xMax)->getTH1();
732  }
733  else if(iHier->componentName == "Strip"){
734  this->getBinning("TH1DmrXprimeStripModules",nBinsX,xMin,xMax);
735  iHier->harvestingHistos.DmrXprime = dbe_->book1D(dmrXprimeHistoName.str(),dmrXprimeHistoTitle.str(),nBinsX,xMin,xMax)->getTH1();
736  if(!parSet_.getParameter<bool>("stripYDmrs"))continue;
737  this->getBinning("TH1DmrYprimeStripModules",nBinsX,xMin,xMax);
738  iHier->harvestingHistos.DmrYprime = dbe_->book1D(dmrYprimeHistoName.str(),dmrYprimeHistoTitle.str(),nBinsX,xMin,xMax)->getTH1();
739  }
740  }
741 }
T getParameter(std::string const &) const
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:1034
std::vector< HarvestingHierarchy > vHarvestingHierarchy_
void getBinning(const std::string &binningPSetName, int &nBinsX, double &lowerBoundX, double &upperBoundX) const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:740
void TrackerOfflineValidationSummary::collateHarvestingHists ( TTree &  tree)
private

Definition at line 659 of file TrackerOfflineValidationSummary.cc.

References applyHarvestingHierarchy(), and fillHarvestingHists().

Referenced by endJob().

660 {
662  this->fillHarvestingHists(tree);
663 }
Definition: tree.py:1
void TrackerOfflineValidationSummary::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 211 of file TrackerOfflineValidationSummary.cc.

References collateHarvestingHists(), fillTree(), edm::EventSetup::get(), lastSetup_, mPxbResiduals_, mPxeResiduals_, mTecResiduals_, mTibResiduals_, mTidResiduals_, mTobResiduals_, edm::ESHandle< T >::product(), tkGeom_, and compare::tree.

Referenced by o2olib.O2ORunMgr::executeJob().

212 {
213  //Retrieve tracker topology from geometry
214  edm::ESHandle<TrackerTopology> tTopoHandle;
215  lastSetup_->get<TrackerTopologyRcd>().get(tTopoHandle);
216  const TrackerTopology* const tTopo = tTopoHandle.product();
217 
218  AlignableTracker aliTracker(&(*tkGeom_), tTopo);
219 
220  TTree* tree = new TTree("TkOffVal","TkOffVal");
221 
222  TkOffTreeVariables *treeMemPtr = new TkOffTreeVariables;
223  // We create branches for all members of 'TkOffTreeVariables' (even if not needed).
224  // This works because we have a dictionary for 'TkOffTreeVariables'
225  // (see src/classes_def.xml and src/classes.h):
226  tree->Branch("TkOffTreeVariables", &treeMemPtr); // address of pointer!
227  // second branch needed for assigning names and titles to harvesting histograms consistent to others
228  std::map<std::string,std::string> *substructureName = new std::map<std::string,std::string>;
229  tree->Branch("SubstructureName", &substructureName, 32000, 00); // SplitLevel must be set to zero
230 
231 
232  this->fillTree(*tree, mPxbResiduals_, *treeMemPtr, *tkGeom_, *substructureName, tTopo);
233  this->fillTree(*tree, mPxeResiduals_, *treeMemPtr, *tkGeom_, *substructureName, tTopo);
234  this->fillTree(*tree, mTibResiduals_, *treeMemPtr, *tkGeom_, *substructureName, tTopo);
235  this->fillTree(*tree, mTidResiduals_, *treeMemPtr, *tkGeom_, *substructureName, tTopo);
236  this->fillTree(*tree, mTobResiduals_, *treeMemPtr, *tkGeom_, *substructureName, tTopo);
237  this->fillTree(*tree, mTecResiduals_, *treeMemPtr, *tkGeom_, *substructureName, tTopo);
238 
239  //dbe_->showDirStructure();
240  //dbe_->save("dqmOut.root");
241 
242  // Method for filling histograms which show summarized values (mean, rms, median ...)
243  // of the module-based histograms from TrackerOfflineValidation
244  this->collateHarvestingHists(*tree);
245 
246  delete tree; tree = 0;
247  delete treeMemPtr; treeMemPtr = 0;
248  delete substructureName; substructureName = 0;
249 }
container to hold data to be written into TTree
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mPxbResiduals_
edm::ESHandle< TrackerGeometry > tkGeom_
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mTibResiduals_
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mTobResiduals_
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mPxeResiduals_
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mTidResiduals_
const T & get() const
Definition: EventSetup.h:56
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > mTecResiduals_
Definition: tree.py:1
void fillTree(TTree &tree, std::map< int, TrackerOfflineValidationSummary::ModuleHistos > &moduleHist, TkOffTreeVariables &treeMem, const TrackerGeometry &tkgeom, std::map< std::string, std::string > &substructureName, const TrackerTopology *tTopo)
T const * product() const
Definition: ESHandle.h:86
void TrackerOfflineValidationSummary::fillHarvestingHists ( TTree &  tree)
private

Definition at line 755 of file TrackerOfflineValidationSummary.cc.

References DEFINE_FWK_MODULE, TkOffTreeVariables::entries, edm::ParameterSet::getParameter(), TkOffTreeVariables::medianX, TkOffTreeVariables::medianY, parSet_, and vHarvestingHierarchy_.

Referenced by collateHarvestingHists().

756 {
757  TkOffTreeVariables *treeMemPtr = 0;
758  std::map<std::string,std::string> *substructureName = 0;
759  tree.SetBranchAddress("TkOffTreeVariables", &treeMemPtr);
760  tree.SetBranchAddress("SubstructureName", &substructureName);
761 
762  const unsigned int minEntriesPerModule(parSet_.getParameter<unsigned int>("minEntriesPerModuleForDmr"));
763  edm::LogInfo("TrackerOfflineValidationSummary")<<"Median of a module is added to DMR plots if it contains at least "<<minEntriesPerModule<<" hits";
764 
765  for(std::vector<HarvestingHierarchy>::iterator iHier = vHarvestingHierarchy_.begin(); iHier != vHarvestingHierarchy_.end(); ++iHier){
766  for(std::vector<unsigned int>::const_iterator iTreeEntries = iHier->treeEntries.begin(); iTreeEntries != iHier->treeEntries.end(); ++iTreeEntries){
767  tree.GetEntry(*iTreeEntries);
768  if(treeMemPtr->entries < minEntriesPerModule)continue;
769  iHier->harvestingHistos.DmrXprime->Fill(treeMemPtr->medianX);
770  if(iHier->harvestingHistos.DmrYprime)iHier->harvestingHistos.DmrYprime->Fill(treeMemPtr->medianY);
771  }
772  }
773 }
T getParameter(std::string const &) const
container to hold data to be written into TTree
std::vector< HarvestingHierarchy > vHarvestingHierarchy_
Definition: tree.py:1
void TrackerOfflineValidationSummary::fillTree ( TTree &  tree,
std::map< int, TrackerOfflineValidationSummary::ModuleHistos > &  moduleHist,
TkOffTreeVariables treeMem,
const TrackerGeometry tkgeom,
std::map< std::string, std::string > &  substructureName,
const TrackerTopology tTopo 
)
private

Definition at line 253 of file TrackerOfflineValidationSummary.cc.

References associateModuleHistsWithTree(), PV3DBase< T, PVType, FrameType >::barePhi(), TkOffTreeVariables::blade, TkOffTreeVariables::chi2PerDofX, TkOffTreeVariables::chi2PerDofY, TkOffTreeVariables::clear(), dbe_, MuonCkfTrajectoryBuilder_cfi::deltaPhi, dPhi(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, TkOffTreeVariables::entries, PV3DBase< T, PVType, FrameType >::eta(), TkOffTreeVariables::fitMeanNormX, TkOffTreeVariables::fitMeanNormY, TkOffTreeVariables::fitMeanX, TkOffTreeVariables::fitMeanY, fitResiduals(), TkOffTreeVariables::fitSigmaNormX, TkOffTreeVariables::fitSigmaNormY, TkOffTreeVariables::fitSigmaX, TkOffTreeVariables::fitSigmaY, getMedian(), edm::ParameterSet::getParameter(), TkOffTreeVariables::half, ecalSelectiveReadoutValidation_cfi::histDir, TkOffTreeVariables::histNameLocalX, TkOffTreeVariables::histNameNormLocalX, TkOffTreeVariables::histNameNormX, TkOffTreeVariables::histNameNormY, TkOffTreeVariables::histNameX, TkOffTreeVariables::histNameY, TrackerGeometry::idToDet(), TkOffTreeVariables::isDoubleSide, TkOffTreeVariables::isStereo, TkOffTreeVariables::layer, TkOffTreeVariables::meanLocalX, TkOffTreeVariables::meanNormLocalX, TkOffTreeVariables::meanNormX, TkOffTreeVariables::meanNormY, TkOffTreeVariables::meanX, TkOffTreeVariables::meanY, TkOffTreeVariables::medianX, TkOffTreeVariables::medianY, TkOffTreeVariables::module, TkOffTreeVariables::moduleId, TkOffTreeVariables::numberOfOutliers, TkOffTreeVariables::numberOfOverflows, TkOffTreeVariables::numberOfUnderflows, TkOffTreeVariables::outerInner, TkOffTreeVariables::panel, parSet_, PV3DBase< T, PVType, FrameType >::perp(), TkOffTreeVariables::petal, PV3DBase< T, PVType, FrameType >::phi(), TkOffTreeVariables::phiDirection, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, TkOffTreeVariables::posEta, GeomDet::position(), TkOffTreeVariables::posPhi, TkOffTreeVariables::posR, TkOffTreeVariables::posX, TkOffTreeVariables::posY, TkOffTreeVariables::posZ, TrackerTopology::pxbLadder(), TrackerTopology::pxbLayer(), TrackerTopology::pxbModule(), TrackerTopology::pxfBlade(), TrackerTopology::pxfDisk(), TrackerTopology::pxfModule(), TrackerTopology::pxfPanel(), TrackerTopology::pxfSide(), DetId::rawId(), TkOffTreeVariables::rDirection, DQMStore::removeElement(), TrackerOfflineValidationSummary_cfi::removeModuleLevelHists, TkOffTreeVariables::ring, TkOffTreeVariables::rmsLocalX, TkOffTreeVariables::rmsNormLocalX, TkOffTreeVariables::rmsNormX, TkOffTreeVariables::rmsNormY, TkOffTreeVariables::rmsX, TkOffTreeVariables::rmsY, TkOffTreeVariables::rod, TkOffTreeVariables::rOrZDirection, DQMStore::setCurrentFolder(), TkOffTreeVariables::side, AlCaHLTBitMon_QueryRunRegistry::string, DetId::subdetId(), TkOffTreeVariables::subDetId, GeomDet::surface(), StripSubdetector::TEC, TrackerTopology::tecIsDoubleSide(), TrackerTopology::tecModule(), TrackerTopology::tecPetalInfo(), TrackerTopology::tecRing(), TrackerTopology::tecSide(), TrackerTopology::tecStereo(), TrackerTopology::tecWheel(), StripSubdetector::TIB, TrackerTopology::tibIsDoubleSide(), TrackerTopology::tibLayer(), TrackerTopology::tibModule(), TrackerTopology::tibStereo(), TrackerTopology::tibStringInfo(), StripSubdetector::TID, TrackerTopology::tidIsDoubleSide(), TrackerTopology::tidModuleInfo(), TrackerTopology::tidRing(), TrackerTopology::tidSide(), TrackerTopology::tidStereo(), TrackerTopology::tidWheel(), StripSubdetector::TOB, TrackerTopology::tobIsDoubleSide(), TrackerTopology::tobLayer(), TrackerTopology::tobModule(), TrackerTopology::tobRodInfo(), TrackerTopology::tobStereo(), Surface::toGlobal(), useFit_, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::z(), and TkOffTreeVariables::zDirection.

Referenced by endJob(), and core.AutoFillTreeProducer.AutoFillTreeProducer::process().

257 {
258  for(std::map<int, TrackerOfflineValidationSummary::ModuleHistos>::iterator it = moduleHist.begin(),
259  itEnd= moduleHist.end(); it != itEnd;++it ) {
260  treeMem.clear(); // make empty/default
261 
262  //variables concerning the tracker components/hierarchy levels
263  const DetId detId = it->first;
264  treeMem.moduleId = detId;
265  treeMem.subDetId = detId.subdetId();
266 
268 
269  unsigned int whichHalfBarrel(1), rawId(detId.rawId()); //DetId does not know about halfBarrels is PXB ...
270  if( (rawId>=302056964 && rawId<302059300) || (rawId>=302123268 && rawId<302127140) || (rawId>=302189572 && rawId<302194980) )whichHalfBarrel=2;
271  treeMem.layer = tTopo->pxbLayer(detId);
272  treeMem.half = whichHalfBarrel;
273  treeMem.rod = tTopo->pxbLadder(detId); // ... so, ladder is not per halfBarrel-Layer, but per barrel-layer! Needs complicated calculation in associateModuleHistsWithTree()
274  treeMem.module = tTopo->pxbModule(detId);
275  } else if(treeMem.subDetId == PixelSubdetector::PixelEndcap){
276 
277  unsigned int whichHalfCylinder(1), rawId(detId.rawId()); //DetId does not kmow about halfCylinders in PXF
278  if( (rawId>=352394500 && rawId<352406032) || (rawId>=352460036 && rawId<352471568) || (rawId>=344005892 && rawId<344017424) || (rawId>=344071428 && rawId<344082960) )whichHalfCylinder=2;
279  treeMem.layer = tTopo->pxfDisk(detId);
280  treeMem.side = tTopo->pxfSide(detId);
281  treeMem.half = whichHalfCylinder;
282  treeMem.blade = tTopo->pxfBlade(detId);
283  treeMem.panel = tTopo->pxfPanel(detId);
284  treeMem.module = tTopo->pxfModule(detId);
285  } else if(treeMem.subDetId == StripSubdetector::TIB){
286 
287  unsigned int whichHalfShell(1), rawId(detId.rawId()); //DetId does not kmow about halfShells in TIB
288  if ( (rawId>=369120484 && rawId<369120688) || (rawId>=369121540 && rawId<369121776) || (rawId>=369136932 && rawId<369137200) || (rawId>=369137988 && rawId<369138288) ||
289  (rawId>=369153396 && rawId<369153744) || (rawId>=369154436 && rawId<369154800) || (rawId>=369169844 && rawId<369170256) || (rawId>=369170900 && rawId<369171344) ||
290  (rawId>=369124580 && rawId<369124784) || (rawId>=369125636 && rawId<369125872) || (rawId>=369141028 && rawId<369141296) || (rawId>=369142084 && rawId<369142384) ||
291  (rawId>=369157492 && rawId<369157840) || (rawId>=369158532 && rawId<369158896) || (rawId>=369173940 && rawId<369174352) || (rawId>=369174996 && rawId<369175440) ) whichHalfShell=2;
292  treeMem.layer = tTopo->tibLayer(detId);
293  treeMem.side = tTopo->tibStringInfo(detId)[0];
294  treeMem.half = whichHalfShell;
295  treeMem.rod = tTopo->tibStringInfo(detId)[2];
296  treeMem.outerInner = tTopo->tibStringInfo(detId)[1];
297  treeMem.module = tTopo->tibModule(detId);
298  treeMem.isStereo = tTopo->tibStereo(detId);
299  treeMem.isDoubleSide = tTopo->tibIsDoubleSide(detId);
300  } else if(treeMem.subDetId == StripSubdetector::TID){
301 
302  treeMem.layer = tTopo->tidWheel(detId);
303  treeMem.side = tTopo->tidSide(detId);
304  treeMem.ring = tTopo->tidRing(detId);
305  treeMem.outerInner = tTopo->tidModuleInfo(detId)[0];
306  treeMem.module = tTopo->tidModuleInfo(detId)[1];
307  treeMem.isStereo = tTopo->tidStereo(detId);
308  treeMem.isDoubleSide = tTopo->tidIsDoubleSide(detId);
309  } else if(treeMem.subDetId == StripSubdetector::TOB){
310 
311  treeMem.layer = tTopo->tobLayer(detId);
312  treeMem.side = tTopo->tobRodInfo(detId)[0];
313  treeMem.rod = tTopo->tobRodInfo(detId)[1];
314  treeMem.module = tTopo->tobModule(detId);
315  treeMem.isStereo = tTopo->tobStereo(detId);
316  treeMem.isDoubleSide = tTopo->tobIsDoubleSide(detId);
317  } else if(treeMem.subDetId == StripSubdetector::TEC) {
318 
319  treeMem.layer = tTopo->tecWheel(detId);
320  treeMem.side = tTopo->tecSide(detId);
321  treeMem.ring = tTopo->tecRing(detId);
322  treeMem.petal = tTopo->tecPetalInfo(detId)[1];
323  treeMem.outerInner = tTopo->tecPetalInfo(detId)[0];
324  treeMem.module = tTopo->tecModule(detId);
325  treeMem.isStereo = tTopo->tecStereo(detId);
326  treeMem.isDoubleSide = tTopo->tecIsDoubleSide(detId);
327  }
328 
329  //variables concerning the tracker geometry
330 
331  const Surface::PositionType &gPModule = tkgeom.idToDet(detId)->position();
332  treeMem.posPhi = gPModule.phi();
333  treeMem.posEta = gPModule.eta();
334  treeMem.posR = gPModule.perp();
335  treeMem.posX = gPModule.x();
336  treeMem.posY = gPModule.y();
337  treeMem.posZ = gPModule.z();
338 
339  const Surface& surface = tkgeom.idToDet(detId)->surface();
340 
341  //global Orientation of local coordinate system of dets/detUnits
342  LocalPoint lUDirection(1.,0.,0.), lVDirection(0.,1.,0.), lWDirection(0.,0.,1.);
343  GlobalPoint gUDirection = surface.toGlobal(lUDirection),
344  gVDirection = surface.toGlobal(lVDirection),
345  gWDirection = surface.toGlobal(lWDirection);
346  double dR(999.), dPhi(999.), dZ(999.);
348  dR = gWDirection.perp() - gPModule.perp();
349  dPhi = deltaPhi(gUDirection.barePhi(),gPModule.barePhi());
350  dZ = gVDirection.z() - gPModule.z();
351  if(dZ>=0.)treeMem.rOrZDirection = 1; else treeMem.rOrZDirection = -1;
352  }else if(treeMem.subDetId==PixelSubdetector::PixelEndcap){
353  dR = gUDirection.perp() - gPModule.perp();
354  dPhi = deltaPhi(gVDirection.barePhi(),gPModule.barePhi());
355  dZ = gWDirection.z() - gPModule.z();
356  if(dR>=0.)treeMem.rOrZDirection = 1; else treeMem.rOrZDirection = -1;
357  }else if(treeMem.subDetId==StripSubdetector::TID || treeMem.subDetId==StripSubdetector::TEC){
358  dR = gVDirection.perp() - gPModule.perp();
359  dPhi = deltaPhi(gUDirection.barePhi(),gPModule.barePhi());
360  dZ = gWDirection.z() - gPModule.z();
361  if(dR>=0.)treeMem.rOrZDirection = 1; else treeMem.rOrZDirection = -1;
362  }
363  if(dR>=0.)treeMem.rDirection = 1; else treeMem.rDirection = -1;
364  if(dPhi>=0.)treeMem.phiDirection = 1; else treeMem.phiDirection = -1;
365  if(dZ>=0.)treeMem.zDirection = 1; else treeMem.zDirection = -1;
366 
367 
368  // Assign histos from first step (TrackerOfflineValidation) to the module's entry in the TTree for retrieving mean, rms, median ...
369  const std::string histDir = associateModuleHistsWithTree(treeMem, it->second, substructureName);
370 
371 
372  //mean and RMS values (extracted from histograms Xprime on module level)
373  treeMem.entries = static_cast<UInt_t>(it->second.ResXprimeHisto->GetEntries());
374  treeMem.meanX = it->second.ResXprimeHisto->GetMean();
375  treeMem.rmsX = it->second.ResXprimeHisto->GetRMS();
376  //treeMem.sigmaX = Fwhm(it->second.ResXprimeHisto)/2.355;
377  if (useFit_) {
378  //call fit function which returns mean and sigma from the fit
379  //for absolute residuals
380  std::pair<float,float> fitResult1 = this->fitResiduals(it->second.ResXprimeHisto);
381  treeMem.fitMeanX = fitResult1.first;
382  treeMem.fitSigmaX = fitResult1.second;
383  //for normalized residuals
384  std::pair<float,float> fitResult2 = this->fitResiduals(it->second.NormResXprimeHisto);
385  treeMem.fitMeanNormX = fitResult2.first;
386  treeMem.fitSigmaNormX = fitResult2.second;
387  }
388 
389  //get median for absolute residuals
390  treeMem.medianX = this->getMedian(it->second.ResXprimeHisto);
391 
392  int numberOfBins=it->second.ResXprimeHisto->GetNbinsX();
393  treeMem.numberOfUnderflows = it->second.ResXprimeHisto->GetBinContent(0);
394  treeMem.numberOfOverflows = it->second.ResXprimeHisto->GetBinContent(numberOfBins+1);
395  treeMem.numberOfOutliers = it->second.ResXprimeHisto->GetBinContent(0)+it->second.ResXprimeHisto->GetBinContent(numberOfBins+1);
396  //mean and RMS values (extracted from histograms(normalized Xprime on module level)
397  treeMem.meanNormX = it->second.NormResXprimeHisto->GetMean();
398  treeMem.rmsNormX = it->second.NormResXprimeHisto->GetRMS();
399 
400  double stats[20];
401  it->second.NormResXprimeHisto->GetStats(stats);
402  // GF treeMem.chi2PerDofX = stats[3]/(stats[0]-1);
403  if (stats[0]) treeMem.chi2PerDofX = stats[3]/stats[0];
404 
405  //treeMem.sigmaNormX = Fwhm(it->second.NormResXprimeHisto)/2.355;
406  treeMem.histNameX = it->second.ResXprimeHisto->GetName();
407  treeMem.histNameNormX = it->second.NormResXprimeHisto->GetName();
408 
409 
410  // fill tree variables in local coordinates if set in cfg of TrackerOfllineValidation
411  if(it->second.ResHisto && it->second.NormResHisto){ // if(lCoorHistOn_) {
412  treeMem.meanLocalX = it->second.ResHisto->GetMean();
413  treeMem.rmsLocalX = it->second.ResHisto->GetRMS();
414  treeMem.meanNormLocalX = it->second.NormResHisto->GetMean();
415  treeMem.rmsNormLocalX = it->second.NormResHisto->GetRMS();
416  treeMem.histNameLocalX = it->second.ResHisto->GetName();
417  treeMem.histNameNormLocalX = it->second.NormResHisto->GetName();
418  }
419 
420  // mean and RMS values in local y (extracted from histograms Yprime on module level)
421  // might exist in pixel only
422  if (it->second.ResYprimeHisto) { //(stripYResiduals_){
423  TH1 *h = it->second.ResYprimeHisto;
424  treeMem.meanY = h->GetMean();
425  treeMem.rmsY = h->GetRMS();
426 
427  if (useFit_) { // fit function which returns mean and sigma from the fit
428  std::pair<float,float> fitMeanSigma = this->fitResiduals(h);
429  treeMem.fitMeanY = fitMeanSigma.first;
430  treeMem.fitSigmaY = fitMeanSigma.second;
431  }
432 
433  //get median for absolute residuals
434  treeMem.medianY = this->getMedian(h);
435 
436  treeMem.histNameY = h->GetName();
437  }
438 
439  if (it->second.NormResYprimeHisto) {
440  TH1 *h = it->second.NormResYprimeHisto;
441  treeMem.meanNormY = h->GetMean();
442  treeMem.rmsNormY = h->GetRMS();
443  h->GetStats(stats); // stats buffer defined above
444  if (stats[0]) treeMem.chi2PerDofY = stats[3]/stats[0];
445 
446  if (useFit_) { // fit function which returns mean and sigma from the fit
447  std::pair<float,float> fitMeanSigma = this->fitResiduals(h);
448  treeMem.fitMeanNormY = fitMeanSigma.first;
449  treeMem.fitSigmaNormY = fitMeanSigma.second;
450  }
451  treeMem.histNameNormY = h->GetName();
452  }
453 
454  // Delete module level hists if set in cfg
455  const bool removeModuleLevelHists(parSet_.getParameter<bool>("removeModuleLevelHists"));
457  dbe_->setCurrentFolder("");
458  if(it->second.ResHisto) dbe_->removeElement(histDir + "/" + it->second.ResHisto->GetName());
459  if(it->second.NormResHisto) dbe_->removeElement(histDir + "/" + it->second.NormResHisto->GetName());
460  if(it->second.ResXprimeHisto) dbe_->removeElement(histDir + "/" + it->second.ResXprimeHisto->GetName());
461  if(it->second.NormResXprimeHisto)dbe_->removeElement(histDir + "/" + it->second.NormResXprimeHisto->GetName());
462  if(it->second.ResYprimeHisto) dbe_->removeElement(histDir + "/" + it->second.ResYprimeHisto->GetName());
463  if(it->second.NormResYprimeHisto)dbe_->removeElement(histDir + "/" + it->second.NormResYprimeHisto->GetName());
464  }
465 
466  tree.Fill();
467  }
468 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
T getParameter(std::string const &) const
bool tecIsDoubleSide(const DetId &id) const
bool tobIsDoubleSide(const DetId &id) const
bool tibIsDoubleSide(const DetId &id) const
T perp() const
Definition: PV3DBase.h:72
unsigned int tibLayer(const DetId &id) const
unsigned int tidRing(const DetId &id) const
std::vector< unsigned int > tidModuleInfo(const DetId &id) const
unsigned int pxfDisk(const DetId &id) const
unsigned int tecRing(const DetId &id) const
ring id
uint32_t tobStereo(const DetId &id) const
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
unsigned int pxbLadder(const DetId &id) const
T y() const
Definition: PV3DBase.h:63
unsigned int tidWheel(const DetId &id) const
unsigned int pxbModule(const DetId &id) const
std::vector< unsigned int > tibStringInfo(const DetId &id) const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
T barePhi() const
Definition: PV3DBase.h:68
std::vector< unsigned int > tecPetalInfo(const DetId &id) const
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:48
unsigned int tidSide(const DetId &id) const
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
uint32_t tidStereo(const DetId &id) const
std::vector< unsigned int > tobRodInfo(const DetId &id) const
const std::string associateModuleHistsWithTree(const TkOffTreeVariables &treeMem, TrackerOfflineValidationSummary::ModuleHistos &moduleHists, std::map< std::string, std::string > &substructureName)
T z() const
Definition: PV3DBase.h:64
void removeElement(const std::string &name)
Definition: DQMStore.cc:3255
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
std::pair< float, float > fitResiduals(TH1 *hist) const
std::string histNameNormLocalX
unsigned int tibModule(const DetId &id) const
unsigned int pxfModule(const DetId &id) const
unsigned int pxbLayer(const DetId &id) const
unsigned int tecModule(const DetId &id) const
Definition: DetId.h:18
std::string histNameLocalX
bool tidIsDoubleSide(const DetId &id) const
unsigned int tobModule(const DetId &id) const
T eta() const
Definition: PV3DBase.h:76
void clear()
set to empty values
uint32_t tecStereo(const DetId &id) const
unsigned int pxfSide(const DetId &id) const
Definition: tree.py:1
uint32_t tibStereo(const DetId &id) const
T x() const
Definition: PV3DBase.h:62
unsigned int tecWheel(const DetId &id) const
unsigned int pxfPanel(const DetId &id) const
unsigned int pxfBlade(const DetId &id) const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:740
unsigned int tobLayer(const DetId &id) const
unsigned int tecSide(const DetId &id) const
const TrackerGeomDet * idToDet(DetId) const
std::pair< float, float > TrackerOfflineValidationSummary::fitResiduals ( TH1 *  hist) const
private

Definition at line 600 of file TrackerOfflineValidationSummary.cc.

References MillePedeFileConverter_cfg::e, RecoEcal_EventContent_cff::func, RecoTauDiscriminantConfiguration::mean, ctppsDiamondLocalTracks_cfi::sigma, and cms::Exception::what().

Referenced by fillTree().

601 {
602  std::pair<float,float> fitResult(9999., 9999.);
603  if (!hist || hist->GetEntries() < 20) return fitResult;
604 
605  float mean = hist->GetMean();
606  float sigma = hist->GetRMS();
607 
608  try { // for < CMSSW_2_2_0 since ROOT warnings from fit are converted to exceptions
609  // Remove the try/catch for more recent CMSSW!
610  // first fit: two RMS around mean
611  TF1 func("tmp", "gaus", mean - 2.*sigma, mean + 2.*sigma);
612  if (0 == hist->Fit(&func,"QNR")) { // N: do not blow up file by storing fit!
613  mean = func.GetParameter(1);
614  sigma = func.GetParameter(2);
615  // second fit: three sigma of first fit around mean of first fit
616  func.SetRange(mean - 3.*sigma, mean + 3.*sigma);
617  // I: integral gives more correct results if binning is too wide
618  // L: Likelihood can treat empty bins correctly (if hist not weighted...)
619  if (0 == hist->Fit(&func, "Q0LR")) {
620  if (hist->GetFunction(func.GetName())) { // Take care that it is later on drawn:
621  hist->GetFunction(func.GetName())->ResetBit(TF1::kNotDraw);
622  }
623  fitResult.first = func.GetParameter(1);
624  fitResult.second = func.GetParameter(2);
625  }
626  }
627  } catch (cms::Exception const & e) {
628  edm::LogWarning("Alignment") << "@SUB=TrackerOfflineValidation::fitResiduals"
629  << "Caught this exception during ROOT fit: "
630  << e.what();
631  }
632  return fitResult;
633 }
virtual char const * what() const
Definition: Exception.cc:141
void TrackerOfflineValidationSummary::getBinning ( const std::string &  binningPSetName,
int &  nBinsX,
double &  lowerBoundX,
double &  upperBoundX 
) const
private

Definition at line 745 of file TrackerOfflineValidationSummary.cc.

References edm::ParameterSet::getParameter(), and parSet_.

Referenced by bookHarvestingHists().

746 {
747  const edm::ParameterSet& binningPSet = parSet_.getParameter<edm::ParameterSet>(binningPSetName);
748  nBinsX = binningPSet.getParameter<int>("Nbinx");
749  lowerBoundX = binningPSet.getParameter<double>("xmin");
750  upperBoundX = binningPSet.getParameter<double>("xmax");
751 }
T getParameter(std::string const &) const
float TrackerOfflineValidationSummary::getMedian ( const TH1 *  hist) const
private

Definition at line 637 of file TrackerOfflineValidationSummary.cc.

References pileupCalc::nbins, x, and y.

Referenced by fillTree().

638 {
639  float median = 999;
640  const int nbins = histo->GetNbinsX();
641 
642  //extract median from histogram
643  double *x = new double[nbins];
644  double *y = new double[nbins];
645  for (int j = 0; j < nbins; j++) {
646  x[j] = histo->GetBinCenter(j+1);
647  y[j] = histo->GetBinContent(j+1);
648  }
649  median = TMath::Median(nbins, x, y);
650 
651  delete[] x; x = 0;
652  delete [] y; y = 0;
653 
654  return median;
655 }

Member Data Documentation

DQMStore* TrackerOfflineValidationSummary::dbe_
private
const edm::EventSetup* TrackerOfflineValidationSummary::lastSetup_
private

Definition at line 140 of file TrackerOfflineValidationSummary.cc.

Referenced by analyze(), and endJob().

const std::string TrackerOfflineValidationSummary::moduleDirectory_
private
bool TrackerOfflineValidationSummary::moduleMapsInitialized
private

Definition at line 129 of file TrackerOfflineValidationSummary.cc.

Referenced by analyze().

std::map<int,TrackerOfflineValidationSummary::ModuleHistos> TrackerOfflineValidationSummary::mPxbResiduals_
private

Definition at line 131 of file TrackerOfflineValidationSummary.cc.

Referenced by analyze(), and endJob().

std::map<int,TrackerOfflineValidationSummary::ModuleHistos> TrackerOfflineValidationSummary::mPxeResiduals_
private

Definition at line 132 of file TrackerOfflineValidationSummary.cc.

Referenced by analyze(), and endJob().

std::map<int,TrackerOfflineValidationSummary::ModuleHistos> TrackerOfflineValidationSummary::mTecResiduals_
private

Definition at line 136 of file TrackerOfflineValidationSummary.cc.

Referenced by analyze(), and endJob().

std::map<int,TrackerOfflineValidationSummary::ModuleHistos> TrackerOfflineValidationSummary::mTibResiduals_
private

Definition at line 133 of file TrackerOfflineValidationSummary.cc.

Referenced by analyze(), and endJob().

std::map<int,TrackerOfflineValidationSummary::ModuleHistos> TrackerOfflineValidationSummary::mTidResiduals_
private

Definition at line 134 of file TrackerOfflineValidationSummary.cc.

Referenced by analyze(), and endJob().

std::map<int,TrackerOfflineValidationSummary::ModuleHistos> TrackerOfflineValidationSummary::mTobResiduals_
private

Definition at line 135 of file TrackerOfflineValidationSummary.cc.

Referenced by analyze(), and endJob().

const edm::ParameterSet TrackerOfflineValidationSummary::parSet_
private
edm::ESHandle<TrackerGeometry> TrackerOfflineValidationSummary::tkGeom_
private

Definition at line 121 of file TrackerOfflineValidationSummary.cc.

Referenced by analyze(), and endJob().

const bool TrackerOfflineValidationSummary::useFit_
private

Definition at line 125 of file TrackerOfflineValidationSummary.cc.

Referenced by fillTree().

std::vector<HarvestingHierarchy> TrackerOfflineValidationSummary::vHarvestingHierarchy_
private