CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MonitorTrackResiduals.cc
Go to the documentation of this file.
23 
25  : dqmStore_( edm::Service<DQMStore>().operator->() )
26  , conf_(iConfig), m_cacheID_(0)
27  , genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig, consumesCollector())) {
28  ModOn = conf_.getParameter<bool>("Mod_On");
29 }
30 
33 }
34 
35 
37 }
38 
40 {
41  unsigned long long cacheID = iSetup.get<SiStripDetCablingRcd>().cacheIdentifier();
42  if (m_cacheID_ != cacheID) {
43  m_cacheID_ = cacheID;
44  this->createMEs( ibooker , iSetup);
45  }
46 }
47 
49 
50  // Initialize the GenericTriggerEventFlag
51  if ( genTriggerEventFlag_->on() ) genTriggerEventFlag_->initRun( run, iSetup );
52 }
53 
55 
56  //Retrieve tracker topology from geometry
58  iSetup.get<IdealGeometryRecord>().get(tTopoHandle);
59  const TrackerTopology* const tTopo = tTopoHandle.product();
60 
61  Parameters = conf_.getParameter<edm::ParameterSet>("TH1ResModules");
62  int32_t i_residuals_Nbins = Parameters.getParameter<int32_t>("Nbinx");
63  double d_residual_xmin = Parameters.getParameter<double>("xmin");
64  double d_residual_xmax = Parameters.getParameter<double>("xmax");
65  Parameters = conf_.getParameter<edm::ParameterSet>("TH1NormResModules");
66  int32_t i_normres_Nbins = Parameters.getParameter<int32_t>("Nbinx");
67  double d_normres_xmin = Parameters.getParameter<double>("xmin");
68  double d_normres_xmax = Parameters.getParameter<double>("xmax");
69 
70 
71  // use SistripHistoId for producing histogram id (and title)
72  SiStripHistoId hidmanager;
73  folder_organizer.setSiStripFolder(); // top SiStrip folder
74 
75  // take from eventSetup the SiStripDetCabling object
77  iSetup.get<SiStripDetCablingRcd>().get(tkmechstruct);
78 
79  // get list of active detectors from SiStripDetCabling
80  std::vector<uint32_t> activeDets;
81  activeDets.clear(); // just in case
82  tkmechstruct->addActiveDetectorsRawIds(activeDets);
83 
84  // use SiStripSubStructure for selecting certain regions
85  SiStripSubStructure substructure;
86  std::vector<uint32_t> DetIds = activeDets;
87 
88  // book histo per each detector module
89  for (std::vector<uint32_t>::const_iterator DetItr=activeDets.begin(),
90  DetItrEnd = activeDets.end(); DetItr!=DetItrEnd; ++DetItr)
91  {
92  uint ModuleID = (*DetItr);
93 
94  // is this a StripModule?
95  if( SiStripDetId(ModuleID).subDetector() != 0 ) {
96 
97  folder_organizer.setDetectorFolder(ModuleID, tTopo); // detid sets appropriate detector folder
98  // Book module histogramms?
99  if (ModOn) {
100  std::string hid = hidmanager.createHistoId("HitResiduals","det",ModuleID);
101  std::string normhid = hidmanager.createHistoId("NormalizedHitResiduals","det",ModuleID);
102  HitResidual[ModuleID] = ibooker.book1D(hid, hid,
103  i_residuals_Nbins,d_residual_xmin,d_residual_xmax);
104  HitResidual[ModuleID]->setAxisTitle("(x_{pred} - x_{rec})' [cm]");
105  NormedHitResiduals[ModuleID] = ibooker.book1D(normhid, normhid,
106  i_normres_Nbins,d_normres_xmin,d_normres_xmax);
107  NormedHitResiduals[ModuleID]->setAxisTitle("(x_{pred} - x_{rec})'/#sigma");
108  }
109  // book layer level histogramms
110  std::pair<std::string,int32_t> subdetandlayer = folder_organizer.GetSubDetAndLayer(ModuleID, tTopo);
111  folder_organizer.setLayerFolder(ModuleID,tTopo,subdetandlayer.second);
112  if(! m_SubdetLayerResiduals[subdetandlayer ] ) {
113  // book histogramms on layer level, check for barrel for correct labeling
114  std::string histoname = Form(subdetandlayer.first.find("B") != std::string::npos ?
115  "HitResiduals_%s__Layer__%d" : "HitResiduals_%s__wheel__%d" ,
116  subdetandlayer.first.c_str(),std::abs(subdetandlayer.second));
117  std::string normhistoname =
118  Form(subdetandlayer.first.find("B") != std::string::npos ?
119  "NormalizedHitResidual_%s__Layer__%d" : "NormalizedHitResidual_%s__wheel__%d" ,
120  subdetandlayer.first.c_str(),std::abs(subdetandlayer.second));
121  m_SubdetLayerResiduals[subdetandlayer] =
122  ibooker.book1D(histoname.c_str(),histoname.c_str(),
123  i_residuals_Nbins,d_residual_xmin,d_residual_xmax);
124  m_SubdetLayerResiduals[subdetandlayer]->setAxisTitle("(x_{pred} - x_{rec})' [cm]");
125  m_SubdetLayerNormedResiduals[subdetandlayer] =
126  ibooker.book1D(normhistoname.c_str(),normhistoname.c_str(),
127  i_normres_Nbins,d_normres_xmin,d_normres_xmax);
128  m_SubdetLayerNormedResiduals[subdetandlayer]->setAxisTitle("(x_{pred} - x_{rec})'/#sigma");
129  }
130  } // end 'is strip module'
131  } // end loop over activeDets
132 }
133 
134 
136 }
137 
138 
140 
141  //dqmStore_->showDirStructure();
142  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
144  if(outputMEsInRootFile){
145  dqmStore_->save(outputFileName);
146  }
147 }
148 
149 
151 
152  // Filter out events if Trigger Filtering is requested
153  if (genTriggerEventFlag_->on()&& ! genTriggerEventFlag_->accept( iEvent, iSetup) ) return;
154 
155  //Retrieve tracker topology from geometry
156  edm::ESHandle<TrackerTopology> tTopoHandle;
157  iSetup.get<IdealGeometryRecord>().get(tTopoHandle);
158  const TrackerTopology* const tTopo = tTopoHandle.product();
159 
160  TrackerValidationVariables avalidator_(iSetup,conf_);
161  std::vector<TrackerValidationVariables::AVHitStruct> v_hitstruct;
162  avalidator_.fillHitQuantities(iEvent,v_hitstruct);
163  for (std::vector<TrackerValidationVariables::AVHitStruct>::const_iterator it = v_hitstruct.begin(),
164  itEnd = v_hitstruct.end(); it != itEnd; ++it) {
165  uint RawId = it->rawDetId;
166 
167  // fill if hit belongs to StripDetector and its error is not zero
168  if( it->resXprimeErr != 0 && SiStripDetId(RawId).subDetector() != 0 ) {
169  if (ModOn && HitResidual[RawId]) {
170  HitResidual[RawId]->Fill(it->resXprime);
171  NormedHitResiduals[RawId]->Fill(it->resXprime/it->resXprimeErr);
172  }
173  std::pair<std::string, int32_t> subdetandlayer = folder_organizer.GetSubDetAndLayer(RawId, tTopo);
174  if(m_SubdetLayerResiduals[subdetandlayer]) {
175  m_SubdetLayerResiduals[subdetandlayer]->Fill(it->resXprime);
176  m_SubdetLayerNormedResiduals[subdetandlayer]->Fill(it->resXprime/it->resXprimeErr);
177  }
178  }
179  }
180 
181 }
182 
183 
184 
186 
T getParameter(std::string const &) const
virtual void analyze(const edm::Event &, const edm::EventSetup &)
void dqmBeginRun(const edm::Run &, const edm::EventSetup &)
unsigned long long m_cacheID_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::pair< std::string, int32_t > GetSubDetAndLayer(const uint32_t &detid, const TrackerTopology *tTopo, bool ring_flag=0)
void fillHitQuantities(const Trajectory *trajectory, std::vector< AVHitStruct > &v_avhitout)
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
void createMEs(DQMStore::IBooker &, const edm::EventSetup &)
SiStripFolderOrganizer folder_organizer
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
int iEvent
Definition: GenABIO.cc:230
vector< ParameterSet > Parameters
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual void endRun(const edm::Run &, const edm::EventSetup &)
virtual void beginJob(void)
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)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
std::map< std::pair< std::string, int32_t >, MonitorElement * > m_SubdetLayerNormedResiduals
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
Definition: DQMStore.cc:2608
GenericTriggerEventFlag * genTriggerEventFlag_
std::map< std::pair< std::string, int32_t >, MonitorElement * > m_SubdetLayerResiduals
MonitorTrackResiduals(const edm::ParameterSet &)
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: Run.h:41