46 setConfig(ps,
"DTLocalTriggerSynch");
47 baseFolderDCC =
"DT/90-LocalTriggerSynch/";
48 baseFolderDDU =
"DT/90-LocalTriggerSynch/";
60 numHistoTag =
parameters.getParameter<
string>(
"numHistoTag");
61 denHistoTag =
parameters.getParameter<
string>(
"denHistoTag");
62 ratioHistoTag =
parameters.getParameter<
string>(
"ratioHistoTag");
63 bxTime =
parameters.getParameter<
double>(
"bxTimeInterval");
64 rangeInBX =
parameters.getParameter<
bool>(
"rangeWithinBX");
65 nBXLow =
parameters.getParameter<
int>(
"nBXLow");
66 nBXHigh =
parameters.getParameter<
int>(
"nBXHigh");
67 minEntries =
parameters.getParameter<
int>(
"minEntries");
75 vector<string>::const_iterator iTr = trigSources.begin();
76 vector<string>::const_iterator trEnd = trigSources.end();
77 vector<string>::const_iterator iHw = hwSources.begin();
78 vector<string>::const_iterator hwEnd = hwSources.end();
81 if(
parameters.getUntrackedParameter<
bool>(
"staticBooking",
true)){
82 for (; iTr != trEnd; ++iTr){
84 for (; iHw != hwEnd; ++iHw){
86 std::vector<DTChamber*>::const_iterator chambIt = muonGeom->chambers().begin();
87 std::vector<DTChamber*>::const_iterator chambEnd = muonGeom->chambers().end();
88 for (; chambIt!=chambEnd; ++chambIt) {
90 bookChambHistos(chId,ratioHistoTag);
98 if (
parameters.getParameter<
bool>(
"fineParamDiff")) {
101 wPhaseMap = (*wPhaseHandle);
111 for (vector<string>::const_iterator iTr = trigSources.begin(); iTr != trigSources.end(); ++iTr){
113 for (vector<string>::const_iterator iHw = hwSources.begin(); iHw != hwSources.end(); ++iHw){
115 std::vector<DTChamber*>::const_iterator chambIt = muonGeom->chambers().begin();
116 std::vector<DTChamber*>::const_iterator chambEnd = muonGeom->chambers().end();
117 for (; chambIt!=chambEnd; ++chambIt) {
119 uint32_t indexCh = chId.
rawId();
122 TH1F *numH = getHisto<TH1F>(dbe->get(getMEName(numHistoTag,
"", chId)));
123 TH1F *denH = getHisto<TH1F>(dbe->get(getMEName(denHistoTag,
"", chId)));
125 if (numH && denH && numH->GetEntries()>minEntries && denH->GetEntries()>minEntries) {
126 std::map<std::string,MonitorElement*> innerME = chambME[indexCh];
128 makeRatioME(numH,denH,ratioH);
130 getHisto<TH1F>(ratioH)->
Fit(
"pol8",
"CQO");
133 <<
"Test]: Error fitting "
134 << ratioH->
getName() <<
" returned 0" << endl;
137 if (!numH || !denH) {
139 <<
"Test]: At least one of the required Histograms was not found for chamber "
140 << chId <<
". Peaks not computed" << endl;
143 <<
"Test]: Number of plots entries for "
144 << chId <<
" is less than minEntries="
145 << minEntries <<
". Peaks not computed" << endl;
159 if (
parameters.getParameter<
bool>(
"writeDB")) {
161 <<
"Test]: writeDB flag set to true. Producing peak position database." << endl;
164 hwSource =
parameters.getParameter<
bool>(
"dbFromDCC") ?
"DCC" :
"DDU";
165 std::vector<DTChamber*>::const_iterator chambIt = muonGeom->chambers().begin();
166 std::vector<DTChamber*>::const_iterator chambEnd = muonGeom->chambers().end();
167 for (; chambIt!=chambEnd; ++chambIt) {
171 int coarseDelay =
static_cast<int>((getFloatFromME(chId,
"tTrig_SL1") + getFloatFromME(chId,
"tTrig_SL3"))*0.5/bxTime);
173 bool fineDiff =
parameters.getParameter<
bool>(
"fineParamDiff");
174 bool coarseDiff =
parameters.getParameter<
bool>(
"coarseParamDiff");
177 TH1F *ratioH = getHisto<TH1F>(dbe->get(getMEName(ratioHistoTag,
"", chId)));
178 if (ratioH->GetEntries()>minEntries) {
179 TF1 *fitF=ratioH->GetFunction(
"pol8");
180 if (fitF) { fineDelay=fitF->GetMaximumX(0,bxTime); }
183 <<
"Test]: Ratio histogram for chamber " << chId
184 <<
" is empty. Worst Phase value set to 0." << endl;
187 if (fineDiff || coarseDiff) {
191 if (fineDiff) { fineDelay = wFine - fineDelay; }
192 if (coarseDiff) { coarseDelay = wCoarse - coarseDelay; }
197 std::vector< std::pair<DTTPGParametersId,DTTPGParametersData> >::const_iterator dbIt = delayMap->
begin();
198 std::vector< std::pair<DTTPGParametersId,DTTPGParametersData> >::const_iterator dbEnd = delayMap->
end();
199 for (; dbIt!=dbEnd; ++dbIt) {
200 LogVerbatim(
category()) <<
"[" << testName <<
"Test]: DB entry for Wh " << (*dbIt).first.wheelId
201 <<
" Sec " << (*dbIt).first.sectorId
202 <<
" St " << (*dbIt).first.stationId
203 <<
" has coarse " << (*dbIt).second.nClock
204 <<
" and phase " << (*dbIt).second.tPhase << std::endl;
207 string delayRecord =
"DTTPGParametersRcd";
219 efficiency->Divide(numerator,denominator,1,1,
"");
225 stringstream wheel; wheel << chId.
wheel();
227 stringstream sector; sector << chId.
sector();
229 string folderName = topFolder(hwSource==
"DCC") +
"Wheel" + wheel.str() +
230 "/Sector" + sector.str() +
"/Station" + station.str() +
"/" ;
232 string histoname = sourceFolder + folderName
235 +
"_Sec" + sector.str()
236 +
"_St" + station.str();
243 LogProblem(
category()) <<
"[" << testName <<
"Test]: " << histoname <<
" is not a valid ME. 0 returned" << std::endl;
252 stringstream wheel; wheel << chambId.
wheel();
254 stringstream sector; sector << chambId.
sector();
257 bool isDCC = hwSource==
"DCC" ;
258 string HistoName = fullType +
"_W" + wheel.str() +
"_Sec" + sector.str() +
"_St" + station.str();
260 string folder = topFolder(isDCC) +
"Wheel" + wheel.str() +
"/Sector" + sector.str() +
"/Station" + station.str();
261 if ( subfolder!=
"") { folder +=
"7" + subfolder; }
263 dbe->setCurrentFolder(folder);
268 uint32_t indexChId = chambId.
rawId();
269 float min = rangeInBX ? 0 : nBXLow*bxTime;
270 float max = rangeInBX ? bxTime : nBXHigh*bxTime;
271 int nbins =
static_cast<int>(ceil( rangeInBX ? bxTime : (nBXHigh-nBXLow)*bxTime));
273 chambME[indexChId][fullType] = dbe->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)
void beginRun(edm::Run const &run, edm::EventSetup const &context)
BeginRun.
void beginRun(const edm::Run &run, const edm::EventSetup &c)
begin Run
float getFloatFromME(DTChamberId chId, std::string meType)
Get float MEs.
uint32_t rawId() const
get the raw id
virtual ~DTLocalTriggerSynchTest()
Destructor.
double getFloatValue(void) const
EventID const & min(EventID const &lh, EventID const &rh)
const_iterator end() const
void runClientDiagnostic()
DQM Client Diagnostic.
DTLocalTriggerSynchTest(const edm::ParameterSet &ps)
Constructor.
TH1F * getTH1F(void) const
void makeRatioME(TH1F *numerator, TH1F *denominator, MonitorElement *result)
Compute efficiency plots.
static const std::string category("Muon|RecoMuon|L3MuonCandidateProducerFromMuons")
void beginJob()
Begin Job.
int station() const
Return the station number.
int wheel() const
Return the wheel number.
void bookChambHistos(DTChamberId chambId, std::string htype, std::string subfolder="")
Book the new MEs (for each chamber)
static void writeToDB(std::string record, T *payload)
EventID const & max(EventID const &lh, EventID const &rh)