44 setConfig(ps,
"DTLocalTriggerSynch");
45 baseFolderDCC =
"DT/90-LocalTriggerSynch/";
46 baseFolderDDU =
"DT/90-LocalTriggerSynch/";
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");
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();
79 if(
parameters.getUntrackedParameter<
bool>(
"staticBooking",
true)){
80 for (; iTr != trEnd; ++iTr){
82 for (; iHw != hwEnd; ++iHw){
84 std::vector<const DTChamber*>::const_iterator chambIt = muonGeom->chambers().begin();
85 std::vector<const DTChamber*>::const_iterator chambEnd = muonGeom->chambers().end();
86 for (; chambIt!=chambEnd; ++chambIt) {
88 bookChambHistos(chId,ratioHistoTag);
96 if (
parameters.getParameter<
bool>(
"fineParamDiff")) {
99 wPhaseMap = (*wPhaseHandle);
109 for (vector<string>::const_iterator iTr = trigSources.begin(); iTr != trigSources.end(); ++iTr){
111 for (vector<string>::const_iterator iHw = hwSources.begin(); iHw != hwSources.end(); ++iHw){
113 std::vector<const DTChamber*>::const_iterator chambIt = muonGeom->chambers().begin();
114 std::vector<const DTChamber*>::const_iterator chambEnd = muonGeom->chambers().end();
115 for (; chambIt!=chambEnd; ++chambIt) {
117 uint32_t indexCh = chId.
rawId();
120 TH1F *numH = getHisto<TH1F>(dbe->get(getMEName(numHistoTag,
"", chId)));
121 TH1F *denH = getHisto<TH1F>(dbe->get(getMEName(denHistoTag,
"", chId)));
124 std::map<std::string,MonitorElement*> innerME = chambME[indexCh];
126 makeRatioME(numH,denH,ratioH);
128 getHisto<TH1F>(ratioH)->
Fit(
"pol8",
"CQO");
131 <<
"Test]: Error fitting "
132 << ratioH->
getName() <<
" returned 0" << endl;
135 if (!numH || !denH) {
137 <<
"Test]: At least one of the required Histograms was not found for chamber "
138 << chId <<
". Peaks not computed" << endl;
141 <<
"Test]: Number of plots entries for "
142 << chId <<
" is less than minEntries="
143 <<
minEntries <<
". Peaks not computed" << endl;
157 if (
parameters.getParameter<
bool>(
"writeDB")) {
159 <<
"Test]: writeDB flag set to true. Producing peak position database." << endl;
162 hwSource =
parameters.getParameter<
bool>(
"dbFromDCC") ?
"DCC" :
"DDU";
163 std::vector<const DTChamber*>::const_iterator chambIt = muonGeom->chambers().begin();
164 std::vector<const DTChamber*>::const_iterator chambEnd = muonGeom->chambers().end();
165 for (; chambIt!=chambEnd; ++chambIt) {
169 int coarseDelay =
static_cast<int>((getFloatFromME(chId,
"tTrig_SL1") + getFloatFromME(chId,
"tTrig_SL3"))*0.5/bxTime);
171 bool fineDiff =
parameters.getParameter<
bool>(
"fineParamDiff");
172 bool coarseDiff =
parameters.getParameter<
bool>(
"coarseParamDiff");
175 TH1F *ratioH = getHisto<TH1F>(dbe->get(getMEName(ratioHistoTag,
"", chId)));
177 TF1 *fitF=ratioH->GetFunction(
"pol8");
178 if (fitF) { fineDelay=fitF->GetMaximumX(0,bxTime); }
181 <<
"Test]: Ratio histogram for chamber " << chId
182 <<
" is empty. Worst Phase value set to 0." << endl;
185 if (fineDiff || coarseDiff) {
189 if (fineDiff) { fineDelay = wFine - fineDelay; }
190 if (coarseDiff) { coarseDelay = wCoarse - coarseDelay; }
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;
205 string delayRecord =
"DTTPGParametersRcd";
217 efficiency->Divide(numerator,denominator,1,1,
"");
223 stringstream wheel; wheel << chId.
wheel();
225 stringstream sector; sector << chId.
sector();
227 string folderName = topFolder(hwSource==
"DCC") +
"Wheel" + wheel.str() +
228 "/Sector" + sector.str() +
"/Station" + station.str() +
"/" ;
230 string histoname = sourceFolder + folderName
233 +
"_Sec" + sector.str()
234 +
"_St" + station.str();
241 LogProblem(
category()) <<
"[" << testName <<
"Test]: " << histoname <<
" is not a valid ME. 0 returned" << std::endl;
250 stringstream wheel; wheel << chambId.
wheel();
252 stringstream sector; sector << chambId.
sector();
255 bool isDCC = hwSource==
"DCC" ;
256 string HistoName = fullType +
"_W" + wheel.str() +
"_Sec" + sector.str() +
"_St" + station.str();
258 string folder = topFolder(isDCC) +
"Wheel" + wheel.str() +
"/Sector" + sector.str() +
"/Station" + station.str();
259 if ( subfolder!=
"") { folder +=
"7" + subfolder; }
261 dbe->setCurrentFolder(folder);
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));
271 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.
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)