47 setConfig(ps,
"DTLocalTriggerSynch");
48 baseFolderDCC =
"DT/90-LocalTriggerSynch/";
49 baseFolderDDU =
"DT/90-LocalTriggerSynch/";
63 numHistoTag =
parameters.getParameter<
string>(
"numHistoTag");
64 denHistoTag =
parameters.getParameter<
string>(
"denHistoTag");
65 ratioHistoTag =
parameters.getParameter<
string>(
"ratioHistoTag");
66 bxTime =
parameters.getParameter<
double>(
"bxTimeInterval");
67 rangeInBX =
parameters.getParameter<
bool>(
"rangeWithinBX");
68 nBXLow =
parameters.getParameter<
int>(
"nBXLow");
69 nBXHigh =
parameters.getParameter<
int>(
"nBXHigh");
79 if (bookingdone)
return;
81 vector<string>::const_iterator iTr = trigSources.begin();
82 vector<string>::const_iterator trEnd = trigSources.end();
83 vector<string>::const_iterator iHw = hwSources.begin();
84 vector<string>::const_iterator hwEnd = hwSources.end();
87 if(
parameters.getUntrackedParameter<
bool>(
"staticBooking",
true)){
88 for (; iTr != trEnd; ++iTr){
90 for (; iHw != hwEnd; ++iHw){
92 std::vector<const DTChamber*>::const_iterator chambIt = muonGeom->chambers().begin();
93 std::vector<const DTChamber*>::const_iterator chambEnd = muonGeom->chambers().end();
94 for (; chambIt!=chambEnd; ++chambIt) {
96 bookChambHistos(ibooker,chId,ratioHistoTag);
104 if (
parameters.getParameter<
bool>(
"fineParamDiff")) {
107 wPhaseMap = (*wPhaseHandle);
118 for (vector<string>::const_iterator iTr = trigSources.begin(); iTr != trigSources.end(); ++iTr){
120 for (vector<string>::const_iterator iHw = hwSources.begin(); iHw != hwSources.end(); ++iHw){
122 std::vector<const DTChamber*>::const_iterator chambIt = muonGeom->chambers().begin();
123 std::vector<const DTChamber*>::const_iterator chambEnd = muonGeom->chambers().end();
124 for (; chambIt!=chambEnd; ++chambIt) {
126 uint32_t indexCh = chId.
rawId();
130 TH1F *numH = getHisto<TH1F>(igetter.
get(getMEName(numHistoTag,
"", chId)));
131 TH1F *denH = getHisto<TH1F>(igetter.
get(getMEName(denHistoTag,
"", chId)));
134 std::map<std::string,MonitorElement*> innerME = chambME[indexCh];
136 makeRatioME(numH,denH,ratioH);
139 TF1 mypol8(
"mypol8",
"pol8");
140 getHisto<TH1F>(ratioH)->
Fit(&mypol8,
"CQO");
143 <<
"Test]: Error fitting "
144 << ratioH->
getName() <<
" returned 0" << endl;
147 if (!numH || !denH) {
149 <<
"Test]: At least one of the required Histograms was not found for chamber "
150 << chId <<
". Peaks not computed" << endl;
153 <<
"Test]: Number of plots entries for "
154 << chId <<
" is less than minEntries="
155 <<
minEntries <<
". Peaks not computed" << endl;
169 if (
parameters.getParameter<
bool>(
"writeDB")) {
171 <<
"Test]: writeDB flag set to true. Producing peak position database." << endl;
174 hwSource =
parameters.getParameter<
bool>(
"dbFromDCC") ?
"DCC" :
"DDU";
175 std::vector<const DTChamber*>::const_iterator chambIt = muonGeom->chambers().begin();
176 std::vector<const DTChamber*>::const_iterator chambEnd = muonGeom->chambers().end();
177 for (; chambIt!=chambEnd; ++chambIt) {
181 int coarseDelay =
static_cast<int>((getFloatFromME(igetter,chId,
"tTrig_SL1") +
182 getFloatFromME(igetter,chId,
"tTrig_SL3"))*0.5/bxTime);
184 bool fineDiff =
parameters.getParameter<
bool>(
"fineParamDiff");
185 bool coarseDiff =
parameters.getParameter<
bool>(
"coarseParamDiff");
187 TH1F *ratioH = getHisto<TH1F>(igetter.
get(getMEName(ratioHistoTag,
"", chId)));
189 TF1 *fitF=ratioH->GetFunction(
"mypol8");
190 if (fitF) { fineDelay=fitF->GetMaximumX(0,bxTime); }
193 <<
"Test]: Ratio histogram for chamber " << chId
194 <<
" is empty. Worst Phase value set to 0." << endl;
197 if (fineDiff || coarseDiff) {
201 if (fineDiff) { fineDelay = wFine - fineDelay; }
202 if (coarseDiff) { coarseDelay = wCoarse - coarseDelay; }
207 std::vector< std::pair<DTTPGParametersId,DTTPGParametersData> >::const_iterator dbIt = delayMap->
begin();
208 std::vector< std::pair<DTTPGParametersId,DTTPGParametersData> >::const_iterator dbEnd = delayMap->
end();
209 for (; dbIt!=dbEnd; ++dbIt) {
210 LogVerbatim(
category()) <<
"[" << testName <<
"Test]: DB entry for Wh " << (*dbIt).first.wheelId
211 <<
" Sec " << (*dbIt).first.sectorId
212 <<
" St " << (*dbIt).first.stationId
213 <<
" has coarse " << (*dbIt).second.nClock
214 <<
" and phase " << (*dbIt).second.tPhase << std::endl;
217 string delayRecord =
"DTTPGParametersRcd";
229 efficiency->Divide(numerator,denominator,1,1,
"");
236 stringstream wheel; wheel << chId.
wheel();
238 stringstream sector; sector << chId.
sector();
240 string folderName = topFolder(hwSource==
"DCC") +
"Wheel" + wheel.str() +
241 "/Sector" + sector.str() +
"/Station" + station.str() +
"/" ;
243 string histoname = sourceFolder + folderName
246 +
"_Sec" + sector.str()
247 +
"_St" + station.str();
254 LogProblem(
category()) <<
"[" << testName <<
"Test]: " << histoname <<
" is not a valid ME. 0 returned" << std::endl;
262 DTChamberId chambId,
string htype,
string subfolder) {
264 stringstream wheel; wheel << chambId.
wheel();
266 stringstream sector; sector << chambId.
sector();
269 bool isDCC = hwSource==
"DCC" ;
270 string HistoName = fullType +
"_W" + wheel.str() +
"_Sec" + sector.str() +
"_St" + station.str();
272 string folder = topFolder(isDCC) +
"Wheel" + wheel.str() +
"/Sector" + sector.str() +
"/Station" + station.str();
273 if ( subfolder!=
"") { folder +=
"7" + subfolder; }
280 uint32_t indexChId = chambId.
rawId();
281 float min = rangeInBX ? 0 : nBXLow*bxTime;
282 float max = rangeInBX ? bxTime : nBXHigh*bxTime;
283 int nbins =
static_cast<int>(ceil( rangeInBX ? bxTime : (nBXHigh-nBXLow)*bxTime));
285 chambME[indexChId][fullType] = ibooker.
book1D(HistoName.c_str(),
"All/HH ratio vs Muon Arrival Time",
nbins,
min,
max);
const std::string & getName(void) const
get name of ME
const_iterator begin() const
int set(int wheelId, int stationId, int sectorId, int nc, float ph, DTTimeUnits::type unit)
MonitorElement * get(const std::string &path)
void beginRun(edm::Run const &run, edm::EventSetup const &context)
BeginRun.
void beginRun(const edm::Run &run, const edm::EventSetup &c)
begin Run
uint32_t rawId() const
get the raw id
virtual ~DTLocalTriggerSynchTest()
Destructor.
double getFloatValue(void) const
MonitorElement * book1D(Args &&...args)
EventID const & min(EventID const &lh, EventID const &rh)
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
Perform client diagnostic in online.
const_iterator end() const
float getFloatFromME(DQMStore::IGetter &, DTChamberId chId, std::string meType)
Get float MEs.
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &)
DTLocalTriggerSynchTest(const edm::ParameterSet &ps)
Constructor.
void setCurrentFolder(const std::string &fullpath)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &)
TH1F * getTH1F(void) const
void makeRatioME(TH1F *numerator, TH1F *denominator, MonitorElement *result)
Compute efficiency plots.
void bookChambHistos(DQMStore::IBooker &, DTChamberId chambId, std::string htype, std::string subfolder="")
Book the new MEs (for each chamber)
int station() const
Return the station number.
int wheel() const
Return the wheel number.
static void writeToDB(std::string record, T *payload)
void runClientDiagnostic(DQMStore::IBooker &, DQMStore::IGetter &)
DQM Client Diagnostic.
EventID const & max(EventID const &lh, EventID const &rh)