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 edm::EDAnalyzer 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 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) 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 &evSU)
 Begin Run. More...
 
void endJob ()
 End Job. More...
 
void runClientDiagnostic ()
 DQM Client Diagnostic. More...
 
void writeConsts (const std::string &outputFileName) const
 
- Protected Member Functions inherited from DTLocalTriggerBaseTest
void analyze (const edm::Event &e, const edm::EventSetup &c)
 Analyze. More...
 
void beginJob ()
 BeginJob. More...
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
 Perform begin lumiblock operations. More...
 
void beginRun (edm::Run const &run, edm::EventSetup const &context)
 BeginRun. 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 endJob ()
 EndJob. 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

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::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 26 of file DTFineDelayCorr.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 43 of file DTFineDelayCorr.cc.

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

Destructor.

Definition at line 52 of file DTFineDelayCorr.cc.

52  {
53 
54 }

Member Function Documentation

void DTFineDelayCorr::beginJob ( void  )
protectedvirtual

Begin Job.

Reimplemented from edm::EDAnalyzer.

Definition at line 57 of file DTFineDelayCorr.cc.

References TrigPrimClient_cfi::minEntries, dumpDBToFile_GT_ttrig_cfg::outputFileName, and Parameters::parameters.

57  {
58 
59  // Tag for Hardware Source (DDU or DCC)
60  hwSource = parameters.getParameter<string>("hwSource");
61  // Tag for the t0Mean Histograms
62  t0MeanHistoTag = parameters.getParameter<string>("t0MeanHistoTag");
63  // Read old delays from file or from Db
64  readOldFromDb = parameters.getParameter<bool>("readOldFromDb");
65  // Input file name for old delays
66  oldDelaysInputFile = parameters.getParameter<string>("oldDelaysInputFile"),
67  // Write new delays to file or to Db
68  writeDB = parameters.getParameter<bool>("writeDB");
69  // Output File Name
70  outputFileName = parameters.getParameter<string>("outputFile");
71  // Choose to use Hist Mean or Gaussian Fit Mean
72  gaussMean = parameters.getParameter<bool>("gaussMean");
73  // Require Minimum Number Of Entries in the t0Mean Histogram
74  minEntries = parameters.getUntrackedParameter<int>("minEntries",5);
75 
76 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::string outputFileName
std::string t0MeanHistoTag
std::string oldDelaysInputFile
void DTFineDelayCorr::beginRun ( const edm::Run run,
const edm::EventSetup evSU 
)
protectedvirtual

Begin Run.

Reimplemented from edm::EDAnalyzer.

Definition at line 78 of file DTFineDelayCorr.cc.

References DTLocalTriggerBaseTest::beginRun(), and edm::EventSetup::get().

78  {
79 
81  evSU.get< DTConfigManagerRcd >().get(dtConfig);
82  evSU.get< DTTPGParametersRcd >().get(worstPhaseMap);
83 
84 }
edm::ESHandle< DTConfigManager > dtConfig
void beginRun(edm::Run const &run, edm::EventSetup const &context)
BeginRun.
const T & get() const
Definition: EventSetup.h:55
edm::ESHandle< DTTPGParameters > worstPhaseMap
void DTFineDelayCorr::endJob ( void  )
protectedvirtual

End Job.

Reimplemented from edm::EDAnalyzer.

Definition at line 185 of file DTFineDelayCorr.cc.

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

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

DQM Client Diagnostic.

Implements DTLocalTriggerBaseTest.

Definition at line 86 of file DTFineDelayCorr.cc.

References python.rootplot.argparse::category, gather_cfg::cout, DTChamberId, DTLayerId, DTTopology::firstChannel(), 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().

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

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

Definition at line 63 of file DTFineDelayCorr.h.

bool DTFineDelayCorr::gaussMean
private

Definition at line 60 of file DTFineDelayCorr.h.

int DTFineDelayCorr::minEntries
private

Definition at line 61 of file DTFineDelayCorr.h.

int DTFineDelayCorr::nEvents
private

Definition at line 62 of file DTFineDelayCorr.h.

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

Definition at line 67 of file DTFineDelayCorr.h.

std::string DTFineDelayCorr::oldDelaysInputFile
private

Definition at line 56 of file DTFineDelayCorr.h.

std::string DTFineDelayCorr::outputFileName
private

Definition at line 55 of file DTFineDelayCorr.h.

bool DTFineDelayCorr::readOldFromDb
private

Definition at line 58 of file DTFineDelayCorr.h.

std::string DTFineDelayCorr::t0MeanHistoTag
private

Definition at line 54 of file DTFineDelayCorr.h.

std::string DTFineDelayCorr::trSource
private

Definition at line 57 of file DTFineDelayCorr.h.

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

Definition at line 64 of file DTFineDelayCorr.h.

bool DTFineDelayCorr::writeDB
private

Definition at line 59 of file DTFineDelayCorr.h.