CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
MonitorTrackResiduals Class Reference

#include <DQM/TrackerMonitorTrack/interface/MonitorTrackResiduals.cc>

Inheritance diagram for MonitorTrackResiduals:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob (void)
 
virtual void beginRun (edm::Run const &run, edm::EventSetup const &iSetup)
 
void createMEs (const edm::EventSetup &)
 
virtual void endJob (void)
 
virtual void endRun (const edm::Run &, const edm::EventSetup &)
 
 MonitorTrackResiduals (const edm::ParameterSet &)
 
void resetLayerMEs (const std::pair< std::string, int32_t > &)
 
void resetModuleMEs (int32_t modid)
 
 ~MonitorTrackResiduals ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::ParameterSet conf_
 
DQMStoredqmStore_
 
SiStripFolderOrganizer folder_organizer
 
GenericTriggerEventFlaggenTriggerEventFlag_
 
HistoClass HitResidual
 
unsigned long long m_cacheID_
 
std::map< std::pair
< std::string, int32_t >
, MonitorElement * > 
m_SubdetLayerNormedResiduals
 
std::map< std::pair
< std::string, int32_t >
, MonitorElement * > 
m_SubdetLayerResiduals
 
bool ModOn
 
HistoClass NormedHitResiduals
 
edm::ParameterSet Parameters
 
bool reset_me_after_each_run
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- 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

Monitoring source for track residuals on each detector module

Definition at line 31 of file MonitorTrackResiduals.h.

Constructor & Destructor Documentation

MonitorTrackResiduals::MonitorTrackResiduals ( const edm::ParameterSet iConfig)
explicit

Definition at line 24 of file MonitorTrackResiduals.cc.

26  , conf_(iConfig), m_cacheID_(0)
28 }
unsigned long long m_cacheID_
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
GenericTriggerEventFlag * genTriggerEventFlag_
MonitorTrackResiduals::~MonitorTrackResiduals ( )

Definition at line 30 of file MonitorTrackResiduals.cc.

References genTriggerEventFlag_.

30  {
32 }
GenericTriggerEventFlag * genTriggerEventFlag_

Member Function Documentation

void MonitorTrackResiduals::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 179 of file MonitorTrackResiduals.cc.

References GenericTriggerEventFlag::accept(), conf_, TrackerValidationVariables::fillHitQuantities(), folder_organizer, genTriggerEventFlag_, edm::EventSetup::get(), SiStripFolderOrganizer::GetSubDetAndLayer(), HitResidual, m_SubdetLayerNormedResiduals, m_SubdetLayerResiduals, ModOn, NormedHitResiduals, GenericTriggerEventFlag::on(), edm::ESHandle< class >::product(), and SiStripDetId::subDetector().

179  {
180 
181  // Filter out events if Trigger Filtering is requested
182  if (genTriggerEventFlag_->on()&& ! genTriggerEventFlag_->accept( iEvent, iSetup) ) return;
183 
184  //Retrieve tracker topology from geometry
185  edm::ESHandle<TrackerTopology> tTopoHandle;
186  iSetup.get<IdealGeometryRecord>().get(tTopoHandle);
187  const TrackerTopology* const tTopo = tTopoHandle.product();
188 
189  TrackerValidationVariables avalidator_(iSetup,conf_);
190  std::vector<TrackerValidationVariables::AVHitStruct> v_hitstruct;
191  avalidator_.fillHitQuantities(iEvent,v_hitstruct);
192  for (std::vector<TrackerValidationVariables::AVHitStruct>::const_iterator it = v_hitstruct.begin(),
193  itEnd = v_hitstruct.end(); it != itEnd; ++it) {
194  uint RawId = it->rawDetId;
195 
196  // fill if hit belongs to StripDetector and its error is not zero
197  if( it->resXprimeErr != 0 && SiStripDetId(RawId).subDetector() != 0 ) {
198  if (ModOn && HitResidual[RawId]) {
199  HitResidual[RawId]->Fill(it->resXprime);
200  NormedHitResiduals[RawId]->Fill(it->resXprime/it->resXprimeErr);
201  }
202  std::pair<std::string, int32_t> subdetandlayer = folder_organizer.GetSubDetAndLayer(RawId, tTopo);
203  if(m_SubdetLayerResiduals[subdetandlayer]) {
204  m_SubdetLayerResiduals[subdetandlayer]->Fill(it->resXprime);
205  m_SubdetLayerNormedResiduals[subdetandlayer]->Fill(it->resXprime/it->resXprimeErr);
206  }
207  }
208  }
209 
210 }
std::pair< std::string, int32_t > GetSubDetAndLayer(const uint32_t &detid, const TrackerTopology *tTopo, bool ring_flag=0)
SiStripFolderOrganizer folder_organizer
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
SubDetector subDetector() const
Definition: SiStripDetId.h:114
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
std::map< std::pair< std::string, int32_t >, MonitorElement * > m_SubdetLayerNormedResiduals
GenericTriggerEventFlag * genTriggerEventFlag_
std::map< std::pair< std::string, int32_t >, MonitorElement * > m_SubdetLayerResiduals
void MonitorTrackResiduals::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 35 of file MonitorTrackResiduals.cc.

References conf_, edm::ParameterSet::getParameter(), ModOn, and reset_me_after_each_run.

35  {
36  ModOn = conf_.getParameter<bool>("Mod_On");
37  reset_me_after_each_run = conf_.getParameter<bool>("ResetAfterRun");
38 }
T getParameter(std::string const &) const
void MonitorTrackResiduals::beginRun ( edm::Run const &  run,
edm::EventSetup const &  iSetup 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 40 of file MonitorTrackResiduals.cc.

References createMEs(), folder_organizer, genTriggerEventFlag_, edm::EventSetup::get(), SiStripFolderOrganizer::GetSubDetAndLayer(), HitResidual, GenericTriggerEventFlag::initRun(), m_cacheID_, m_SubdetLayerResiduals, Association::map, ModOn, GenericTriggerEventFlag::on(), edm::ESHandle< class >::product(), reset_me_after_each_run, resetLayerMEs(), and resetModuleMEs().

40  {
41 
42  //Retrieve tracker topology from geometry
44  iSetup.get<IdealGeometryRecord>().get(tTopoHandle);
45  const TrackerTopology* const tTopo = tTopoHandle.product();
46 
47  unsigned long long cacheID = iSetup.get<SiStripDetCablingRcd>().cacheIdentifier();
48  if (m_cacheID_ != cacheID) {
49  m_cacheID_ = cacheID;
50  this->createMEs(iSetup);
51  }
53  if(ModOn) {
54  for(std::map<int32_t, MonitorElement*>::const_iterator it = HitResidual.begin(),
55  itEnd = HitResidual.end(); it!= itEnd;++it) {
56  this->resetModuleMEs(it->first);
57  this->resetLayerMEs(folder_organizer.GetSubDetAndLayer(it->first, tTopo));
58  }
59  } else {
60  for(std::map< std::pair<std::string,int32_t>, MonitorElement*>::const_iterator it = m_SubdetLayerResiduals.begin(),
61  itEnd = m_SubdetLayerResiduals.end(); it!= itEnd;++it) {
62  this->resetLayerMEs(it->first);
63  }
64  } // end if-else Module level on
65  } // end reset after run
66 
67  // Initialize the GenericTriggerEventFlag
69 }
void createMEs(const edm::EventSetup &)
void resetModuleMEs(int32_t modid)
unsigned long long m_cacheID_
std::pair< std::string, int32_t > GetSubDetAndLayer(const uint32_t &detid, const TrackerTopology *tTopo, bool ring_flag=0)
SiStripFolderOrganizer folder_organizer
dictionary map
Definition: Association.py:205
void resetLayerMEs(const std::pair< std::string, int32_t > &)
T const * product() const
Definition: ESHandle.h:62
GenericTriggerEventFlag * genTriggerEventFlag_
std::map< std::pair< std::string, int32_t >, MonitorElement * > m_SubdetLayerResiduals
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
void MonitorTrackResiduals::createMEs ( const edm::EventSetup iSetup)

Definition at line 71 of file MonitorTrackResiduals.cc.

References abs, DQMStore::book1D(), conf_, dqmStore_, folder_organizer, edm::EventSetup::get(), edm::ParameterSet::getParameter(), SiStripFolderOrganizer::GetSubDetAndLayer(), HitResidual, m_SubdetLayerNormedResiduals, m_SubdetLayerResiduals, ModOn, NormedHitResiduals, edm::ESHandle< class >::product(), MonitorElement::setAxisTitle(), SiStripFolderOrganizer::setDetectorFolder(), SiStripFolderOrganizer::setLayerFolder(), SiStripFolderOrganizer::setSiStripFolder(), AlCaHLTBitMon_QueryRunRegistry::string, and SiStripDetId::subDetector().

Referenced by beginRun().

71  {
72 
73  //Retrieve tracker topology from geometry
75  iSetup.get<IdealGeometryRecord>().get(tTopoHandle);
76  const TrackerTopology* const tTopo = tTopoHandle.product();
77 
78  Parameters = conf_.getParameter<edm::ParameterSet>("TH1ResModules");
79  int32_t i_residuals_Nbins = Parameters.getParameter<int32_t>("Nbinx");
80  double d_residual_xmin = Parameters.getParameter<double>("xmin");
81  double d_residual_xmax = Parameters.getParameter<double>("xmax");
82  Parameters = conf_.getParameter<edm::ParameterSet>("TH1NormResModules");
83  int32_t i_normres_Nbins = Parameters.getParameter<int32_t>("Nbinx");
84  double d_normres_xmin = Parameters.getParameter<double>("xmin");
85  double d_normres_xmax = Parameters.getParameter<double>("xmax");
86 
87 
88  // use SistripHistoId for producing histogram id (and title)
89  SiStripHistoId hidmanager;
90  folder_organizer.setSiStripFolder(); // top SiStrip folder
91 
92  // take from eventSetup the SiStripDetCabling object
94  iSetup.get<SiStripDetCablingRcd>().get(tkmechstruct);
95 
96  // get list of active detectors from SiStripDetCabling
97  std::vector<uint32_t> activeDets;
98  activeDets.clear(); // just in case
99  tkmechstruct->addActiveDetectorsRawIds(activeDets);
100 
101  // use SiStripSubStructure for selecting certain regions
102  SiStripSubStructure substructure;
103  std::vector<uint32_t> DetIds = activeDets;
104 
105  // book histo per each detector module
106  for (std::vector<uint32_t>::const_iterator DetItr=activeDets.begin(),
107  DetItrEnd = activeDets.end(); DetItr!=DetItrEnd; ++DetItr)
108  {
109  uint ModuleID = (*DetItr);
110 
111  // is this a StripModule?
112  if( SiStripDetId(ModuleID).subDetector() != 0 ) {
113 
114  folder_organizer.setDetectorFolder(ModuleID, tTopo); // detid sets appropriate detector folder
115  // Book module histogramms?
116  if (ModOn) {
117  std::string hid = hidmanager.createHistoId("HitResiduals","det",ModuleID);
118  std::string normhid = hidmanager.createHistoId("NormalizedHitResiduals","det",ModuleID);
119  HitResidual[ModuleID] = dqmStore_->book1D(hid, hid,
120  i_residuals_Nbins,d_residual_xmin,d_residual_xmax);
121  HitResidual[ModuleID]->setAxisTitle("(x_{pred} - x_{rec})' [cm]");
122  NormedHitResiduals[ModuleID] = dqmStore_->book1D(normhid, normhid,
123  i_normres_Nbins,d_normres_xmin,d_normres_xmax);
124  NormedHitResiduals[ModuleID]->setAxisTitle("(x_{pred} - x_{rec})'/#sigma");
125  }
126  // book layer level histogramms
127  std::pair<std::string,int32_t> subdetandlayer = folder_organizer.GetSubDetAndLayer(ModuleID, tTopo);
128  folder_organizer.setLayerFolder(ModuleID,tTopo,subdetandlayer.second);
129  if(! m_SubdetLayerResiduals[subdetandlayer ] ) {
130  // book histogramms on layer level, check for barrel for correct labeling
131  std::string histoname = Form(subdetandlayer.first.find("B") != std::string::npos ?
132  "HitResiduals_%s__Layer__%d" : "HitResiduals_%s__wheel__%d" ,
133  subdetandlayer.first.c_str(),std::abs(subdetandlayer.second));
134  std::string normhistoname =
135  Form(subdetandlayer.first.find("B") != std::string::npos ?
136  "NormalizedHitResidual_%s__Layer__%d" : "NormalizedHitResidual_%s__wheel__%d" ,
137  subdetandlayer.first.c_str(),std::abs(subdetandlayer.second));
138  m_SubdetLayerResiduals[subdetandlayer] =
139  dqmStore_->book1D(histoname.c_str(),histoname.c_str(),
140  i_residuals_Nbins,d_residual_xmin,d_residual_xmax);
141  m_SubdetLayerResiduals[subdetandlayer]->setAxisTitle("(x_{pred} - x_{rec})' [cm]");
142  m_SubdetLayerNormedResiduals[subdetandlayer] =
143  dqmStore_->book1D(normhistoname.c_str(),normhistoname.c_str(),
144  i_normres_Nbins,d_normres_xmin,d_normres_xmax);
145  m_SubdetLayerNormedResiduals[subdetandlayer]->setAxisTitle("(x_{pred} - x_{rec})'/#sigma");
146  }
147  } // end 'is strip module'
148  } // end loop over activeDets
149 }
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:722
#define abs(x)
Definition: mlp_lapack.h:159
std::pair< std::string, int32_t > GetSubDetAndLayer(const uint32_t &detid, const TrackerTopology *tTopo, bool ring_flag=0)
SiStripFolderOrganizer folder_organizer
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
vector< ParameterSet > Parameters
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
SubDetector subDetector() const
Definition: SiStripDetId.h:114
void setLayerFolder(uint32_t rawdetid, const TrackerTopology *tTopo, int32_t layer=0, bool ring_flag=0)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
std::map< std::pair< std::string, int32_t >, MonitorElement * > m_SubdetLayerNormedResiduals
std::map< std::pair< std::string, int32_t >, MonitorElement * > m_SubdetLayerResiduals
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void MonitorTrackResiduals::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 168 of file MonitorTrackResiduals.cc.

References conf_, dqmStore_, edm::ParameterSet::getParameter(), dumpDBToFile_GT_ttrig_cfg::outputFileName, DQMStore::save(), and AlCaHLTBitMon_QueryRunRegistry::string.

168  {
169 
170  //dqmStore_->showDirStructure();
171  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
173  if(outputMEsInRootFile){
174  dqmStore_->save(outputFileName);
175  }
176 }
T getParameter(std::string const &) const
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2118
void MonitorTrackResiduals::endRun ( const edm::Run ,
const edm::EventSetup  
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 164 of file MonitorTrackResiduals.cc.

164  {
165 }
void MonitorTrackResiduals::resetLayerMEs ( const std::pair< std::string, int32_t > &  subdetandlayer)

Definition at line 157 of file MonitorTrackResiduals.cc.

References m_SubdetLayerNormedResiduals, and m_SubdetLayerResiduals.

Referenced by beginRun().

157  {
158  m_SubdetLayerResiduals [subdetandlayer]->Reset();
159  m_SubdetLayerNormedResiduals[subdetandlayer]->Reset();
160 }
std::map< std::pair< std::string, int32_t >, MonitorElement * > m_SubdetLayerNormedResiduals
std::map< std::pair< std::string, int32_t >, MonitorElement * > m_SubdetLayerResiduals
void MonitorTrackResiduals::resetModuleMEs ( int32_t  modid)

Definition at line 152 of file MonitorTrackResiduals.cc.

References HitResidual, and NormedHitResiduals.

Referenced by beginRun().

152  {
153  HitResidual[modid]->Reset();
154  NormedHitResiduals[modid]->Reset();
155 }

Member Data Documentation

edm::ParameterSet MonitorTrackResiduals::conf_
private

Definition at line 48 of file MonitorTrackResiduals.h.

Referenced by analyze(), beginJob(), createMEs(), and endJob().

DQMStore* MonitorTrackResiduals::dqmStore_
private

Definition at line 47 of file MonitorTrackResiduals.h.

Referenced by createMEs(), and endJob().

SiStripFolderOrganizer MonitorTrackResiduals::folder_organizer
private

Definition at line 54 of file MonitorTrackResiduals.h.

Referenced by analyze(), beginRun(), and createMEs().

GenericTriggerEventFlag* MonitorTrackResiduals::genTriggerEventFlag_
private

Definition at line 58 of file MonitorTrackResiduals.h.

Referenced by analyze(), beginRun(), and ~MonitorTrackResiduals().

HistoClass MonitorTrackResiduals::HitResidual
private

Definition at line 52 of file MonitorTrackResiduals.h.

Referenced by analyze(), beginRun(), createMEs(), and resetModuleMEs().

unsigned long long MonitorTrackResiduals::m_cacheID_
private

Definition at line 55 of file MonitorTrackResiduals.h.

Referenced by beginRun().

std::map< std::pair<std::string,int32_t>, MonitorElement* > MonitorTrackResiduals::m_SubdetLayerNormedResiduals
private

Definition at line 51 of file MonitorTrackResiduals.h.

Referenced by analyze(), createMEs(), and resetLayerMEs().

std::map< std::pair<std::string,int32_t>, MonitorElement* > MonitorTrackResiduals::m_SubdetLayerResiduals
private

Definition at line 50 of file MonitorTrackResiduals.h.

Referenced by analyze(), beginRun(), createMEs(), and resetLayerMEs().

bool MonitorTrackResiduals::ModOn
private

Definition at line 57 of file MonitorTrackResiduals.h.

Referenced by analyze(), beginJob(), beginRun(), and createMEs().

HistoClass MonitorTrackResiduals::NormedHitResiduals
private

Definition at line 53 of file MonitorTrackResiduals.h.

Referenced by analyze(), createMEs(), and resetModuleMEs().

edm::ParameterSet MonitorTrackResiduals::Parameters
private

Definition at line 49 of file MonitorTrackResiduals.h.

bool MonitorTrackResiduals::reset_me_after_each_run
private

Definition at line 56 of file MonitorTrackResiduals.h.

Referenced by beginJob(), and beginRun().