CMS 3D CMS Logo

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

#include <DTLocalTriggerSynchTest.h>

Inheritance diagram for DTLocalTriggerSynchTest:
DTLocalTriggerBaseTest edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 DTLocalTriggerSynchTest (const edm::ParameterSet &ps)
 Constructor. More...
 
virtual ~DTLocalTriggerSynchTest ()
 Destructor. More...
 
- Public Member Functions inherited from DTLocalTriggerBaseTest
 DTLocalTriggerBaseTest ()
 Constructor. More...
 
virtual ~DTLocalTriggerBaseTest ()
 Destructor. More...
 
- 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
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Member Functions

void beginJob ()
 Begin Job. More...
 
void beginRun (const edm::Run &run, const edm::EventSetup &c)
 begin Run More...
 
void bookChambHistos (DTChamberId chambId, std::string htype, std::string subfolder="")
 Book the new MEs (for each chamber) More...
 
void endJob ()
 End Job. More...
 
float getFloatFromME (DTChamberId chId, std::string meType)
 Get float MEs. More...
 
void makeRatioME (TH1F *numerator, TH1F *denominator, MonitorElement *result)
 Compute efficiency plots. More...
 
void runClientDiagnostic ()
 DQM Client Diagnostic. More...
 
- Protected Member Functions inherited from DTLocalTriggerBaseTest
void analyze (const edm::Event &e, const edm::EventSetup &c)
 Analyze. More...
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
 Perform begin lumiblock operations. More...
 
void bookCmsHistos (std::string hTag, std::string folder="", bool isGlb=false)
 Book the new MEs (CMS summary) More...
 
void bookSectorHistos (int wheel, int sector, std::string hTag, std::string folder="")
 Book the new MEs (for each sector) More...
 
void bookWheelHistos (int wheel, std::string hTag, std::string folder="")
 Book the new MEs (for each wheel) More...
 
std::string category ()
 Get message logger name. More...
 
void endLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
 Perform client diagnostic in online. More...
 
void endRun (edm::Run const &run, edm::EventSetup const &context)
 Perform client diagnostic in offline. More...
 
std::string fullName (std::string htype)
 Create fullname from histo partial name. More...
 
template<class T >
TgetHisto (MonitorElement *me)
 Convert ME to Histogram fo type T. More...
 
std::string getMEName (std::string histoTag, std::string subfolder, const DTChamberId &chambid)
 Get the ME name (by chamber) More...
 
std::string getMEName (std::string histoTag, std::string subfolder, int wh)
 Get the ME name (by wheel) More...
 
std::pair< float, float > phiRange (const DTChamberId &id)
 Calculate phi range for histograms. More...
 
void setConfig (const edm::ParameterSet &ps, std::string name)
 Set configuration variables. More...
 
std::string & topFolder (bool isDCC)
 Get top folder name. More...
 
- 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)
 

Private Attributes

double bxTime
 
std::map< uint32_t, std::map
< std::string, MonitorElement * > > 
chambME
 
std::string denHistoTag
 
int minEntries
 
int nBXHigh
 
int nBXLow
 
std::string numHistoTag
 
bool rangeInBX
 
std::string ratioHistoTag
 
DTTPGParameters wPhaseMap
 
bool writeDB
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Attributes inherited from DTLocalTriggerBaseTest
std::string baseFolderDCC
 
std::string baseFolderDDU
 
std::map< std::string,
MonitorElement * > 
cmsME
 
DQMStoredbe
 
std::string hwSource
 
std::vector< std::string > hwSources
 
edm::ESHandle< DTGeometrymuonGeom
 
int nevents
 
unsigned int nLumiSegs
 
edm::ParameterSet parameters
 
int prescaleFactor
 
int run
 
bool runOnline
 
std::map< int, std::map
< std::string, MonitorElement * > > 
secME
 
std::string sourceFolder
 
std::string testName
 
std::string trigSource
 
std::vector< std::string > trigSources
 
std::map< int, std::map
< std::string, MonitorElement * > > 
whME
 

Detailed Description

Definition at line 19 of file DTLocalTriggerSynchTest.h.

Constructor & Destructor Documentation

DTLocalTriggerSynchTest::DTLocalTriggerSynchTest ( const edm::ParameterSet ps)

Constructor.

Definition at line 42 of file DTLocalTriggerSynchTest.cc.

42  {
43 
44  setConfig(ps,"DTLocalTriggerSynch");
45  baseFolderDCC = "DT/90-LocalTriggerSynch/";
46  baseFolderDDU = "DT/90-LocalTriggerSynch/";
47 
48 }
void setConfig(const edm::ParameterSet &ps, std::string name)
Set configuration variables.
DTLocalTriggerSynchTest::~DTLocalTriggerSynchTest ( )
virtual

Destructor.

Definition at line 51 of file DTLocalTriggerSynchTest.cc.

51  {
52 
53 }

Member Function Documentation

void DTLocalTriggerSynchTest::beginJob ( void  )
protectedvirtual

Begin Job.

Reimplemented from DTLocalTriggerBaseTest.

Definition at line 56 of file DTLocalTriggerSynchTest.cc.

References Parameters::parameters.

56  {
57 
58  numHistoTag = parameters.getParameter<string>("numHistoTag");
59  denHistoTag = parameters.getParameter<string>("denHistoTag");
60  ratioHistoTag = parameters.getParameter<string>("ratioHistoTag");
61  bxTime = parameters.getParameter<double>("bxTimeInterval");
62  rangeInBX = parameters.getParameter<bool>("rangeWithinBX");
63  nBXLow = parameters.getParameter<int>("nBXLow");
64  nBXHigh = parameters.getParameter<int>("nBXHigh");
65  minEntries = parameters.getParameter<int>("minEntries");
66 
67 }
T getParameter(std::string const &) const
void DTLocalTriggerSynchTest::beginRun ( const edm::Run run,
const edm::EventSetup c 
)
protectedvirtual

begin Run

Reimplemented from DTLocalTriggerBaseTest.

Definition at line 69 of file DTLocalTriggerSynchTest.cc.

References DTLocalTriggerBaseTest::beginRun(), python.rootplot.argparse::category, edm::EventSetup::get(), and Parameters::parameters.

69  {
70 
72 
73  vector<string>::const_iterator iTr = trigSources.begin();
74  vector<string>::const_iterator trEnd = trigSources.end();
75  vector<string>::const_iterator iHw = hwSources.begin();
76  vector<string>::const_iterator hwEnd = hwSources.end();
77 
78  //Booking
79  if(parameters.getUntrackedParameter<bool>("staticBooking", true)){
80  for (; iTr != trEnd; ++iTr){
81  trigSource = (*iTr);
82  for (; iHw != hwEnd; ++iHw){
83  hwSource = (*iHw);
84  std::vector<DTChamber*>::const_iterator chambIt = muonGeom->chambers().begin();
85  std::vector<DTChamber*>::const_iterator chambEnd = muonGeom->chambers().end();
86  for (; chambIt!=chambEnd; ++chambIt) {
87  DTChamberId chId = ((*chambIt)->id());
89  }
90  }
91  }
92  }
93 
94  LogVerbatim(category()) << "[" << testName << "Test]: beginRun" << endl;
95 
96  if (parameters.getParameter<bool>("fineParamDiff")) {
97  ESHandle<DTTPGParameters> wPhaseHandle;
98  c.get<DTTPGParametersRcd>().get(wPhaseHandle);
99  wPhaseMap = (*wPhaseHandle);
100  }
101 
102 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > trigSources
void beginRun(edm::Run const &run, edm::EventSetup const &context)
BeginRun.
edm::ESHandle< DTGeometry > muonGeom
std::string category()
Get message logger name.
const T & get() const
Definition: EventSetup.h:55
std::vector< std::string > hwSources
void bookChambHistos(DTChamberId chambId, std::string htype, std::string subfolder="")
Book the new MEs (for each chamber)
void DTLocalTriggerSynchTest::bookChambHistos ( DTChamberId  chambId,
std::string  htype,
std::string  subfolder = "" 
)
protected

Book the new MEs (for each chamber)

Definition at line 248 of file DTLocalTriggerSynchTest.cc.

References python.rootplot.argparse::category, newFWLiteAna::fullName, edm::max(), edm::min(), pileupCalc::nbins, DetId::rawId(), DTChamberId::sector(), DTChamberId::station(), relativeConstraints::station, and DTChamberId::wheel().

248  {
249 
250  stringstream wheel; wheel << chambId.wheel();
251  stringstream station; station << chambId.station();
252  stringstream sector; sector << chambId.sector();
253 
254  string fullType = fullName(htype);
255  bool isDCC = hwSource=="DCC" ;
256  string HistoName = fullType + "_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
257 
258  string folder = topFolder(isDCC) + "Wheel" + wheel.str() + "/Sector" + sector.str() + "/Station" + station.str();
259  if ( subfolder!="") { folder += "7" + subfolder; }
260 
261  dbe->setCurrentFolder(folder);
262 
263  LogPrint(category()) << "[" << testName << "Test]: booking " << folder << "/" <<HistoName;
264 
265 
266  uint32_t indexChId = chambId.rawId();
267  float min = rangeInBX ? 0 : nBXLow*bxTime;
268  float max = rangeInBX ? bxTime : nBXHigh*bxTime;
269  int nbins = static_cast<int>(ceil( rangeInBX ? bxTime : (nBXHigh-nBXLow)*bxTime));
270 
271  chambME[indexChId][fullType] = dbe->book1D(HistoName.c_str(),"All/HH ratio vs Muon Arrival Time",nbins,min,max);
272 
273 }
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:873
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const T & max(const T &a, const T &b)
std::string category()
Get message logger name.
std::string HistoName
int sector() const
Definition: DTChamberId.h:61
std::map< uint32_t, std::map< std::string, MonitorElement * > > chambME
std::string & topFolder(bool isDCC)
Get top folder name.
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
std::string fullName(std::string htype)
Create fullname from histo partial name.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:585
void DTLocalTriggerSynchTest::endJob ( void  )
protectedvirtual

End Job.

Reimplemented from DTLocalTriggerBaseTest.

Definition at line 153 of file DTLocalTriggerSynchTest.cc.

References DTTPGParameters::begin(), python.rootplot.argparse::category, DTTPGParameters::end(), DTLocalTriggerBaseTest::endJob(), DTTimeUnits::ns, Parameters::parameters, DTTPGParameters::set(), and DTCalibDBUtils::writeToDB().

153  {
154 
156 
157  if ( parameters.getParameter<bool>("writeDB")) {
158  LogVerbatim(category()) << "[" << testName
159  << "Test]: writeDB flag set to true. Producing peak position database." << endl;
160 
161  DTTPGParameters* delayMap = new DTTPGParameters();
162  hwSource = parameters.getParameter<bool>("dbFromDCC") ? "DCC" : "DDU";
163  std::vector<DTChamber*>::const_iterator chambIt = muonGeom->chambers().begin();
164  std::vector<DTChamber*>::const_iterator chambEnd = muonGeom->chambers().end();
165  for (; chambIt!=chambEnd; ++chambIt) {
166 
167  DTChamberId chId = (*chambIt)->id();
168  float fineDelay = 0;
169  int coarseDelay = static_cast<int>((getFloatFromME(chId,"tTrig_SL1") + getFloatFromME(chId,"tTrig_SL3"))*0.5/bxTime);
170 
171  bool fineDiff = parameters.getParameter<bool>("fineParamDiff");
172  bool coarseDiff = parameters.getParameter<bool>("coarseParamDiff");
173 
174 
175  TH1F *ratioH = getHisto<TH1F>(dbe->get(getMEName(ratioHistoTag,"", chId)));
176  if (ratioH->GetEntries()>minEntries) {
177  TF1 *fitF=ratioH->GetFunction("pol8");
178  if (fitF) { fineDelay=fitF->GetMaximumX(0,bxTime); }
179  } else {
180  LogInfo(category()) << "[" << testName
181  << "Test]: Ratio histogram for chamber " << chId
182  << " is empty. Worst Phase value set to 0." << endl;
183  }
184 
185  if (fineDiff || coarseDiff) {
186  float wFine;
187  int wCoarse;
188  wPhaseMap.get(chId,wCoarse,wFine,DTTimeUnits::ns);
189  if (fineDiff) { fineDelay = wFine - fineDelay; }
190  if (coarseDiff) { coarseDelay = wCoarse - coarseDelay; }
191  }
192  delayMap->set(chId,coarseDelay,fineDelay,DTTimeUnits::ns);
193  }
194 
195  std::vector< std::pair<DTTPGParametersId,DTTPGParametersData> >::const_iterator dbIt = delayMap->begin();
196  std::vector< std::pair<DTTPGParametersId,DTTPGParametersData> >::const_iterator dbEnd = delayMap->end();
197  for (; dbIt!=dbEnd; ++dbIt) {
198  LogVerbatim(category()) << "[" << testName << "Test]: DB entry for Wh " << (*dbIt).first.wheelId
199  << " Sec " << (*dbIt).first.sectorId
200  << " St " << (*dbIt).first.stationId
201  << " has coarse " << (*dbIt).second.nClock
202  << " and phase " << (*dbIt).second.tPhase << std::endl;
203  }
204 
205  string delayRecord = "DTTPGParametersRcd";
206  DTCalibDBUtils::writeToDB(delayRecord,delayMap);
207 
208  }
209 
210 }
T getParameter(std::string const &) const
const_iterator begin() const
int set(int wheelId, int stationId, int sectorId, int nc, float ph, DTTimeUnits::type unit)
float getFloatFromME(DTChamberId chId, std::string meType)
Get float MEs.
edm::ESHandle< DTGeometry > muonGeom
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1624
const_iterator end() const
std::string category()
Get message logger name.
std::string getMEName(std::string histoTag, std::string subfolder, const DTChamberId &chambid)
Get the ME name (by chamber)
int get(int wheelId, int stationId, int sectorId, int &nc, float &ph, DTTimeUnits::type unit) const
get content
static void writeToDB(std::string record, T *payload)
float DTLocalTriggerSynchTest::getFloatFromME ( DTChamberId  chId,
std::string  meType 
)
protected

Get float MEs.

Definition at line 221 of file DTLocalTriggerSynchTest.cc.

References python.rootplot.argparse::category, MonitorElement::getFloatValue(), DTChamberId::sector(), DTChamberId::station(), relativeConstraints::station, and DTChamberId::wheel().

221  {
222 
223  stringstream wheel; wheel << chId.wheel();
224  stringstream station; station << chId.station();
225  stringstream sector; sector << chId.sector();
226 
227  string folderName = topFolder(hwSource=="DCC") + "Wheel" + wheel.str() +
228  "/Sector" + sector.str() + "/Station" + station.str() + "/" ;
229 
230  string histoname = sourceFolder + folderName
231  + meType
232  + "_W" + wheel.str()
233  + "_Sec" + sector.str()
234  + "_St" + station.str();
235 
236  MonitorElement* me = dbe->get(histoname);
237  if (me) {
238  return me->getFloatValue();
239  }
240  else {
241  LogProblem(category()) << "[" << testName << "Test]: " << histoname << " is not a valid ME. 0 returned" << std::endl;
242  }
243 
244  return 0;
245 
246  }
double getFloatValue(void) const
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1624
std::string category()
Get message logger name.
int sector() const
Definition: DTChamberId.h:61
std::string & topFolder(bool isDCC)
Get top folder name.
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
void DTLocalTriggerSynchTest::makeRatioME ( TH1F *  numerator,
TH1F *  denominator,
MonitorElement result 
)
protected

Compute efficiency plots.

Definition at line 214 of file DTLocalTriggerSynchTest.cc.

References postValidation_cfi::efficiency, and MonitorElement::getTH1F().

214  {
215 
216  TH1F* efficiency = result->getTH1F();
217  efficiency->Divide(numerator,denominator,1,1,"");
218 
219 }
list numerator
Definition: cuy.py:483
list denominator
Definition: cuy.py:484
TH1F * getTH1F(void) const
void DTLocalTriggerSynchTest::runClientDiagnostic ( )
protectedvirtual

DQM Client Diagnostic.

Implements DTLocalTriggerBaseTest.

Definition at line 106 of file DTLocalTriggerSynchTest.cc.

References python.rootplot.argparse::category, newFWLiteAna::fullName, MonitorElement::getName(), and DetId::rawId().

106  {
107 
108  // Loop over Trig & Hw sources
109  for (vector<string>::const_iterator iTr = trigSources.begin(); iTr != trigSources.end(); ++iTr){
110  trigSource = (*iTr);
111  for (vector<string>::const_iterator iHw = hwSources.begin(); iHw != hwSources.end(); ++iHw){
112  hwSource = (*iHw);
113  std::vector<DTChamber*>::const_iterator chambIt = muonGeom->chambers().begin();
114  std::vector<DTChamber*>::const_iterator chambEnd = muonGeom->chambers().end();
115  for (; chambIt!=chambEnd; ++chambIt) {
116  DTChamberId chId = (*chambIt)->id();
117  uint32_t indexCh = chId.rawId();
118 
119  // Perform peak finding
120  TH1F *numH = getHisto<TH1F>(dbe->get(getMEName(numHistoTag,"", chId)));
121  TH1F *denH = getHisto<TH1F>(dbe->get(getMEName(denHistoTag,"", chId)));
122 
123  if (numH && denH && numH->GetEntries()>minEntries && denH->GetEntries()>minEntries) {
124  std::map<std::string,MonitorElement*> innerME = chambME[indexCh];
125  MonitorElement* ratioH = innerME.find(fullName(ratioHistoTag))->second;
126  makeRatioME(numH,denH,ratioH);
127  try {
128  getHisto<TH1F>(ratioH)->Fit("pol8","CQO");
129  } catch (cms::Exception& iException) {
130  edm::LogPrint(category()) << "[" << testName
131  << "Test]: Error fitting "
132  << ratioH->getName() << " returned 0" << endl;
133  }
134  } else {
135  if (!numH || !denH) {
136  LogPrint(category()) << "[" << testName
137  << "Test]: At least one of the required Histograms was not found for chamber "
138  << chId << ". Peaks not computed" << endl;
139  } else {
140  LogPrint(category()) << "[" << testName
141  << "Test]: Number of plots entries for "
142  << chId << " is less than minEntries="
143  << minEntries <<". Peaks not computed" << endl;
144  }
145  }
146 
147  }
148  }
149  }
150 
151 }
const std::string & getName(void) const
get name of ME
std::vector< std::string > trigSources
edm::ESHandle< DTGeometry > muonGeom
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
Definition: Fit.h:34
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1624
std::string category()
Get message logger name.
void makeRatioME(TH1F *numerator, TH1F *denominator, MonitorElement *result)
Compute efficiency plots.
std::string getMEName(std::string histoTag, std::string subfolder, const DTChamberId &chambid)
Get the ME name (by chamber)
std::map< uint32_t, std::map< std::string, MonitorElement * > > chambME
std::vector< std::string > hwSources
std::string fullName(std::string htype)
Create fullname from histo partial name.

Member Data Documentation

double DTLocalTriggerSynchTest::bxTime
private

Definition at line 58 of file DTLocalTriggerSynchTest.h.

std::map<uint32_t,std::map<std::string,MonitorElement*> > DTLocalTriggerSynchTest::chambME
private

Definition at line 54 of file DTLocalTriggerSynchTest.h.

std::string DTLocalTriggerSynchTest::denHistoTag
private

Definition at line 56 of file DTLocalTriggerSynchTest.h.

int DTLocalTriggerSynchTest::minEntries
private

Definition at line 62 of file DTLocalTriggerSynchTest.h.

int DTLocalTriggerSynchTest::nBXHigh
private

Definition at line 61 of file DTLocalTriggerSynchTest.h.

int DTLocalTriggerSynchTest::nBXLow
private

Definition at line 60 of file DTLocalTriggerSynchTest.h.

std::string DTLocalTriggerSynchTest::numHistoTag
private

Definition at line 55 of file DTLocalTriggerSynchTest.h.

bool DTLocalTriggerSynchTest::rangeInBX
private

Definition at line 59 of file DTLocalTriggerSynchTest.h.

std::string DTLocalTriggerSynchTest::ratioHistoTag
private

Definition at line 57 of file DTLocalTriggerSynchTest.h.

DTTPGParameters DTLocalTriggerSynchTest::wPhaseMap
private

Definition at line 64 of file DTLocalTriggerSynchTest.h.

bool DTLocalTriggerSynchTest::writeDB
private

Definition at line 63 of file DTLocalTriggerSynchTest.h.