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
DTFineDelayCorr Class Reference

#include <DTFineDelayCorr.h>

Inheritance diagram for DTFineDelayCorr:
DTLocalTriggerBaseTest DQMEDHarvester edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 DTFineDelayCorr (const edm::ParameterSet &ps)
 Constructor. More...
 
virtual ~DTFineDelayCorr ()
 Destructor. More...
 
- Public Member Functions inherited from DTLocalTriggerBaseTest
 DTLocalTriggerBaseTest ()
 Constructor. More...
 
virtual ~DTLocalTriggerBaseTest ()
 Destructor. More...
 
- Public Member Functions inherited from DQMEDHarvester
virtual void analyze (edm::Event const &, edm::EventSetup const &) final
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
 DQMEDHarvester (void)
 
virtual void endJob () final
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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 beginRun (const edm::Run &run, const edm::EventSetup &evSU)
 Begin Run. More...
 
void dqmEndJob (DQMStore::IBooker &, DQMStore::IGetter &)
 
void runClientDiagnostic (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
 DQM Client Diagnostic. More...
 
void writeConsts (const std::string &outputFileName) const
 
- Protected Member Functions inherited from DTLocalTriggerBaseTest
void beginRun (edm::Run const &run, edm::EventSetup const &context)
 BeginRun. More...
 
void bookCmsHistos (DQMStore::IBooker &, std::string hTag, std::string folder="", bool isGlb=false)
 Book the new MEs (CMS summary) More...
 
void bookSectorHistos (DQMStore::IBooker &, int wheel, int sector, std::string hTag, std::string folder="")
 Book the new MEs (for each sector) More...
 
void bookWheelHistos (DQMStore::IBooker &, 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 dqmEndJob (DQMStore::IBooker &, DQMStore::IGetter &)
 
void dqmEndLuminosityBlock (DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
 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::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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

std::map< DTChamberId,
std::vector< float > > 
delayMap
 
edm::ESHandle< DTConfigManagerdtConfig
 
bool gaussMean
 
int minEntries
 
int nEvents
 
std::map< DTChamberId,
std::pair< int, float > > 
oldDelayMap
 
std::string oldDelaysInputFile
 
std::string outputFileName
 
bool readOldFromDb
 
std::string t0MeanHistoTag
 
std::string trSource
 
edm::ESHandle< DTTPGParametersworstPhaseMap
 
bool writeDB
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Attributes inherited from DTLocalTriggerBaseTest
std::string baseFolderDCC
 
std::string baseFolderDDU
 
std::map< std::string,
MonitorElement * > 
cmsME
 
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 29 of file DTFineDelayCorr.h.

Constructor & Destructor Documentation

DTFineDelayCorr::DTFineDelayCorr ( const edm::ParameterSet ps)

Constructor.

Definition at line 47 of file DTFineDelayCorr.cc.

47  {
48 
49  setConfig(ps,"DTFineDelayCorr"); // sets parameter values and name used in log file
50  baseFolderDCC = "DT/90-LocalTriggerSynch/";
51  baseFolderDDU = "DT/90-LocalTriggerSynch/";
52 
53 }
void setConfig(const edm::ParameterSet &ps, std::string name)
Set configuration variables.
DTFineDelayCorr::~DTFineDelayCorr ( )
virtual

Destructor.

Definition at line 56 of file DTFineDelayCorr.cc.

56  {
57 
58 }

Member Function Documentation

void DTFineDelayCorr::beginRun ( const edm::Run run,
const edm::EventSetup evSU 
)
protectedvirtual

Begin Run.

Reimplemented from DQMEDHarvester.

Definition at line 60 of file DTFineDelayCorr.cc.

References DTLocalTriggerBaseTest::beginRun(), edm::EventSetup::get(), TrigPrimClient_cfi::minEntries, dumpDBToFile_GT_ttrig_cfg::outputFileName, and Parameters::parameters.

60  {
61 
62  // Tag for Hardware Source (DDU or DCC)
63  hwSource = parameters.getParameter<string>("hwSource");
64  // Tag for the t0Mean Histograms
65  t0MeanHistoTag = parameters.getParameter<string>("t0MeanHistoTag");
66  // Read old delays from file or from Db
67  readOldFromDb = parameters.getParameter<bool>("readOldFromDb");
68  // Input file name for old delays
69  oldDelaysInputFile = parameters.getParameter<string>("oldDelaysInputFile"),
70  // Write new delays to file or to Db
71  writeDB = parameters.getParameter<bool>("writeDB");
72  // Output File Name
73  outputFileName = parameters.getParameter<string>("outputFile");
74  // Choose to use Hist Mean or Gaussian Fit Mean
75  gaussMean = parameters.getParameter<bool>("gaussMean");
76  // Require Minimum Number Of Entries in the t0Mean Histogram
77  minEntries = parameters.getUntrackedParameter<int>("minEntries",5);
78 
80  evSU.get< DTConfigManagerRcd >().get(dtConfig);
81  evSU.get< DTTPGParametersRcd >().get(worstPhaseMap);
82 
83 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::ESHandle< DTConfigManager > dtConfig
void beginRun(edm::Run const &run, edm::EventSetup const &context)
BeginRun.
std::string outputFileName
const T & get() const
Definition: EventSetup.h:55
std::string t0MeanHistoTag
edm::ESHandle< DTTPGParameters > worstPhaseMap
std::string oldDelaysInputFile
void DTFineDelayCorr::dqmEndJob ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter 
)
protectedvirtual

Implements DQMEDHarvester.

Definition at line 184 of file DTFineDelayCorr.cc.

References filterCSVwithJSON::copy, DTLocalTriggerBaseTest::dqmEndJob(), getDQMSummary::iter, python.multivaluedict::map(), GetRecoTauVFromDQM_MC_cff::outFile, and dumpDBToFile_GT_ttrig_cfg::outputFileName.

184  {
185 
186  DTLocalTriggerBaseTest::dqmEndJob( ibooker,igetter);
187 
188  if (writeDB) {
189  // to be added if needed
190  }
191  else { // write txt file
192  // ** Open output file **
193  ofstream outFile(outputFileName.c_str());
194  for(map< DTChamberId, vector<float> >::const_iterator iter = delayMap.begin();
195  iter != delayMap.end() ; iter++) {
196  // writing
197  ostream_iterator<float> oit(outFile, " ");
198  copy((*iter).second.begin(), (*iter).second.end(), oit);
199  outFile << endl;
200  }
201  outFile.close();
202  }
203 }
std::string outputFileName
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &)
std::map< DTChamberId, std::vector< float > > delayMap
void DTFineDelayCorr::runClientDiagnostic ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter 
)
protectedvirtual

DQM Client Diagnostic.

Implements DTLocalTriggerBaseTest.

Definition at line 85 of file DTFineDelayCorr.cc.

References python.rootplot.argparse::category, gather_cfg::cout, DTChamberId, DTLayerId, DTTopology::firstChannel(), DQMStore::IGetter::get(), DTConfigPedestals::getOffset(), DTLayer::id(), geometryCSVtoXML::line, timingPdfMaker::mean, TrigPrimClient_cfi::minEntries, DTTimeUnits::ns, DetId::rawId(), DTChamberId::sector(), DTLayer::specificTopology(), DTChamberId::station(), relativeConstraints::station, and DTChamberId::wheel().

85  {
86  int coarseDelay = -999;
87  float oldFineDelay = -999;
88  if(!readOldFromDb) { // read old delays from txt file
89  // ** Open and read old delays input file **
90  ifstream oldDelaysFile(oldDelaysInputFile.c_str());
91  string line;
92 
93  while (getline(oldDelaysFile, line)) {
94  if( line == "" || line[0] == '#' ) continue;
95  stringstream linestr;
96  int wheelKey,sectorKey, stationKey;
97  linestr << line;
98 
99  linestr >> wheelKey
100  >> sectorKey
101  >> stationKey
102  >> coarseDelay
103  >> oldFineDelay;
104 
105  pair<int,float> oldDelays = make_pair(coarseDelay,oldFineDelay);
106  DTChamberId oldDelayKey = DTChamberId(wheelKey,stationKey,sectorKey);
107  oldDelayMap.insert(make_pair(oldDelayKey,oldDelays));
108  }
109  }
110 
111  // ** Loop over the chambers **
112  vector<const DTChamber*>::const_iterator chambIt = muonGeom->chambers().begin();
113  vector<const DTChamber*>::const_iterator chambEnd = muonGeom->chambers().end();
114  for (; chambIt!=chambEnd; ++chambIt) {
115  DTChamberId chId = (*chambIt)->id();
116  uint32_t indexCh = chId.rawId();
117  int wheel = chId.wheel();
118  int sector = chId.sector();
119  int station = chId.station();
120 
121  // ** Compute corrected values and write them to file or database **
122  vector<float> newDelays;
123 
124  // ** Retrieve Delays Loaded in MiniCrates **
125  if(readOldFromDb) { // read from db
126  const DTConfigPedestals *pedestals = dtConfig->getDTConfigPedestals();
127  const DTLayer *layer = muonGeom->layer(DTLayerId(chId,1,1));
128  float delay = pedestals->getOffset(DTWireId(layer->id(),layer->specificTopology().firstChannel()));
129  coarseDelay = int(delay/25.);
130  oldFineDelay = delay - coarseDelay * 25.;
131  }
132  else { // read from map created from txt file
133  coarseDelay = oldDelayMap[chId].first;
134  oldFineDelay = oldDelayMap[chId].second;
135  }
136 
137  // ** Retrieve t0Mean histograms **
138  TH1F *t0H = getHisto<TH1F>(igetter.get(getMEName(t0MeanHistoTag,"", chId)));
139  float newFineDelay = -999; // initialize to dummy number
140  cout <<"MG: " << getMEName(t0MeanHistoTag,"", chId) << " entries: " << t0H->GetEntries() << endl;
141  if (t0H->GetEntries() > minEntries) {
142  Double_t mean;
143  // ** Find Mean Value of the distribution **
144  if(gaussMean) {
145  TF1 *funct = t0H->GetFunction("gaus");
146  mean = funct->GetParameter(1);
147  }
148  else {
149  mean = t0H->GetMean();
150  }
151 
152  // ** Retrieve Worst Phase values **
153  int wpCoarseDelay;
154  float wpFineDelay;
155  worstPhaseMap->get(chId, wpCoarseDelay, wpFineDelay, DTTimeUnits::ns);
156 // cout << "wpFineDelay, oldFineDelay, mean: " << wpFineDelay << " "
157 // << oldFineDelay << " " << mean << endl;
158  float bpFineDelay = (wpFineDelay < 12.5)? (wpFineDelay + 12.5) : (wpFineDelay - 12.5); // Best Phase: half BX far from the worst phase
159  // ** Calculate correction **
160  float diffFineDelays = oldFineDelay + (mean - bpFineDelay); // positive mean shift implies positive delay correction
161  int bxDiff = (int) (diffFineDelays / 25);
162  coarseDelay += bxDiff;
163  newFineDelay = fmodf(diffFineDelays, 25);
164 // cout << "diffFineDelays, newFineDelay, bxDiff, coarseDelay: " << diffFineDelays
165 // << " "<< newFineDelay << " " << bxDiff << " " << coarseDelay << endl;
166  }
167  else {
168  LogProblem(category()) << "[" << testName << "Test]: Not enough entries in hist for Chamber "
169  << indexCh << endl;
170  }
171 
172  newDelays.push_back(wheel);
173  newDelays.push_back(sector);
174  newDelays.push_back(station);
175  newDelays.push_back(coarseDelay);
176  newDelays.push_back(newFineDelay);
177  pair< DTChamberId, vector<float> > chDelays;
178  chDelays.first = chId;
179  chDelays.second = newDelays;
180  delayMap.insert(chDelays);
181  }
182 }
edm::ESHandle< DTConfigManager > dtConfig
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:302
DTLayerId id() const
Return the DetId of this SL.
Definition: DTLayer.cc:46
std::map< DTChamberId, std::pair< int, float > > oldDelayMap
edm::ESHandle< DTGeometry > muonGeom
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:78
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const DTTopology & specificTopology() const
Definition: DTLayer.cc:42
float getOffset(const DTWireId &wire) const
Get wire by wire delay.
std::string category()
Get message logger name.
std::map< DTChamberId, std::vector< float > > delayMap
std::string t0MeanHistoTag
std::string getMEName(std::string histoTag, std::string subfolder, const DTChamberId &chambid)
Get the ME name (by chamber)
edm::ESHandle< DTTPGParameters > worstPhaseMap
int sector() const
Definition: DTChamberId.h:61
std::string oldDelaysInputFile
tuple cout
Definition: gather_cfg.py:121
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
void DTFineDelayCorr::writeConsts ( const std::string &  outputFileName) const
protected

Member Data Documentation

std::map< DTChamberId, std::vector<float> > DTFineDelayCorr::delayMap
private

Definition at line 71 of file DTFineDelayCorr.h.

edm::ESHandle< DTConfigManager > DTFineDelayCorr::dtConfig
private

Definition at line 64 of file DTFineDelayCorr.h.

bool DTFineDelayCorr::gaussMean
private

Definition at line 61 of file DTFineDelayCorr.h.

int DTFineDelayCorr::minEntries
private

Definition at line 62 of file DTFineDelayCorr.h.

int DTFineDelayCorr::nEvents
private

Definition at line 63 of file DTFineDelayCorr.h.

Referenced by looper.Looper::loop().

std::map< DTChamberId, std::pair<int,float> > DTFineDelayCorr::oldDelayMap
private

Definition at line 68 of file DTFineDelayCorr.h.

std::string DTFineDelayCorr::oldDelaysInputFile
private

Definition at line 57 of file DTFineDelayCorr.h.

std::string DTFineDelayCorr::outputFileName
private

Definition at line 56 of file DTFineDelayCorr.h.

bool DTFineDelayCorr::readOldFromDb
private

Definition at line 59 of file DTFineDelayCorr.h.

std::string DTFineDelayCorr::t0MeanHistoTag
private

Definition at line 55 of file DTFineDelayCorr.h.

std::string DTFineDelayCorr::trSource
private

Definition at line 58 of file DTFineDelayCorr.h.

edm::ESHandle< DTTPGParameters > DTFineDelayCorr::worstPhaseMap
private

Definition at line 65 of file DTFineDelayCorr.h.

bool DTFineDelayCorr::writeDB
private

Definition at line 60 of file DTFineDelayCorr.h.