44 void setDDU(
int qual,
int bx) { theQual[0] = qual; theBX[0] = bx; }
45 void setTM(
int qual,
int bx) { theQual[1] = qual; theBX[1] = bx; }
47 bool hasOne()
const {
return theQual[0]!=-1 || theQual[1]!=-1; };
48 bool hasBoth()
const {
return theQual[0]!=-1 && theQual[1]!=-1; };
49 bool hasSameQual()
const {
return hasBoth() && theQual[0]==theQual[1]; };
50 int deltaBX()
const {
return theBX[0] - theBX[1]; }
51 int qualDDU()
const {
return theQual[0]; }
52 int qualTM()
const {
return theQual[1]; }
64 nEvents(0), nLumis(0), theTrigGeomUtils(0) {
66 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
67 <<
"[DTLocalTriggerBaseTask]: Constructor"<<endl;
88 if (processTM)
theTypes.push_back(
"TM");
89 if (processDDU)
theTypes.push_back(
"DDU");
92 topFolder(
"TM") =
"DT/11-LocalTriggerTP-TM/";
93 topFolder(
"DDU") =
"DT/12-LocalTriggerTP-DDU/";
95 topFolder(
"TM") =
"DT/03-LocalTrigger-TM/";
96 topFolder(
"DDU") =
"DT/04-LocalTrigger-DDU/";
106 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
107 <<
"[DTLocalTriggerBaseTask]: analyzed " <<
nEvents <<
" events" << endl;
116 for (
int wh=-2;wh<3;++wh){
117 for (
int stat=1;stat<5;++stat){
118 for (
int sect=1;sect<13;++sect){
133 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
134 <<
"[DTLocalTriggerBaseTask]: Begin of LS transition" << endl;
136 if(
nLumis%resetCycle == 0 ) {
137 map<uint32_t,map<string,MonitorElement*> >::const_iterator chambIt =
chamberHistos.begin();
138 map<uint32_t,map<string,MonitorElement*> >::const_iterator chambEnd =
chamberHistos.end();
139 for(;chambIt!=chambEnd;++chambIt) {
140 map<string,MonitorElement*>::const_iterator histoIt = chambIt->second.begin();
141 map<string,MonitorElement*>::const_iterator histoEnd = chambIt->second.end();
142 for(;histoIt!=histoEnd;++histoIt) {
143 histoIt->second->Reset();
152 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
153 <<
"[DTLocalTriggerBaseTask]: End of LS transition" << endl;
155 map<uint32_t,DTTimeEvolutionHisto* >::const_iterator chambIt =
trendHistos.begin();
156 map<uint32_t,DTTimeEvolutionHisto* >::const_iterator chambEnd =
trendHistos.end();
157 for(;chambIt!=chambEnd;++chambIt) {
166 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
167 <<
"[DTLocalTriggerBaseTask]: BeginRun" << endl;
198 runTMAnalysis(phiInTrigsTM->getContainer(),phiOutTrigsTM->getContainer(),thetaTrigsTM->getContainer());
200 LogVerbatim(
"DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
201 <<
"[DTLocalTriggerBaseTask]: one or more TM handles for Input Tag "
202 << inputTagTM <<
" not found!" << endl;
214 LogVerbatim(
"DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
215 <<
"[DTLocalTriggerBaseTask]: one or more DDU handles for Input Tag "
216 << inputTagDDU <<
" not found!" << endl;
229 uint32_t rawId = dtCh.
rawId();
231 stringstream wheel; wheel << dtCh.
wheel();
233 stringstream sector; sector << dtCh.
sector();
235 map<string,int> minBX;
236 map<string,int> maxBX;
246 string chTag =
"_W" + wheel.str() +
"_Sec" + sector.str() +
"_St" + station.str();
247 string labelInOut =
"";
249 vector<string>::const_iterator typeIt =
theTypes.begin();
250 vector<string>::const_iterator typeEnd =
theTypes.end();
252 for (; typeIt!=typeEnd; ++typeIt) {
254 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
255 <<
"[DTLocalTriggerBaseTask]: booking histos for " <<
topFolder((*typeIt)) <<
"Wheel"
256 << wheel.str() <<
"/Sector" << sector.str() <<
"/Station"<< station.str() << endl;
258 for (
int InOut=0; InOut<2;InOut++){
263 + sector.str() +
"/Station" + station.str() +
"/LocalTriggerPhiIn");
267 + sector.str() +
"/Station" + station.str() +
"/LocalTriggerPhiOut");
268 labelInOut =
"_Out";}
271 string histoTag = (*typeIt) +
"_BXvsQual" + labelInOut;
273 7,-0.5,6.5,(
int)(maxBX[(*typeIt)]-minBX[*typeIt]+1),minBX[*typeIt]-.5,maxBX[*typeIt]+.5);
277 histoTag = (*typeIt) +
"_BestQual" + labelInOut;
279 "Trigger quality of best primitives",7,-0.5,6.5);
282 histoTag = (*typeIt) +
"_Flag1stvsQual" + labelInOut;
284 "1st/2nd trig flag vs quality",7,-0.5,6.5,2,-0.5,1.5);
289 float minPh, maxPh;
int nBinsPh;
292 histoTag = (*typeIt) +
"_QualvsPhirad" + labelInOut;
294 "Trigger quality vs local position",nBinsPh,minPh,maxPh,7,-0.5,6.5);
298 histoTag = (*typeIt) +
"_QualvsPhibend" + labelInOut;
300 "Trigger quality vs local direction",200,-40.,40.,7,-0.5,6.5);
308 + sector.str() +
"/Station" + station.str() +
"/LocalTriggerTheta");
310 string histoTag =
"";
311 if((*typeIt)==
"TM" && dtCh.
station()!=4) {
312 histoTag = (*typeIt) +
"_PositionvsBX";
313 chamberHistos[rawId][histoTag] = ibooker.
book2D(histoTag+chTag,
"Theta trigger position vs BX",
314 (
int)(maxBX[(*typeIt)]-minBX[*typeIt]+1),minBX[*typeIt]-.5,maxBX[*typeIt]+.5,7,-0.5,6.5);
315 histoTag = (*typeIt) +
"_PositionvsQual";
316 chamberHistos[rawId][histoTag] = ibooker.
book2D(histoTag+chTag,
"Theta trigger position vs quality",
317 2,0.5,2.5,7,-0.5,6.5);
319 histoTag = (*typeIt) +
"_ThetaBXvsQual";
321 2,0.5,2.5,(
int)(maxBX[(*typeIt)]-minBX[*typeIt]+1),minBX[*typeIt]-.5,maxBX[*typeIt]+.5);
329 histoTag = (*typeIt) +
"_ThetaBXvsQual";
330 chamberHistos[rawId][histoTag] = ibooker.
book2D(histoTag+chTag,
"BX vs trigger quality",7,-0.5,6.5,
331 (
int)(maxBX[(*typeIt)]-minBX[*typeIt]+1),minBX[*typeIt]-.5,maxBX[*typeIt]+.5);
334 histoTag = (*typeIt) +
"_ThetaBestQual";
336 "Trigger quality of best primitives (theta)",7,-0.5,6.5);
345 for (
int InOut=0; InOut<2;InOut++){
348 + sector.str() +
"/Station" + station.str() +
"/LocalTriggerPhiIn");
351 + sector.str() +
"/Station" + station.str() +
"/LocalTriggerPhiOut");
354 string histoTag =
"COM_QualDDUvsQualTM";
356 "DDU quality vs TM quality",8,-1.5,6.5,8,-1.5,6.5);
360 histoTag =
"COM_MatchingTrend";
362 "Fraction of DDU-TM matches w.r.t. proc evts",
363 nTimeBins,nLSTimeBin,
true,0);
371 stringstream wheel; wheel << wh;
373 string whTag =
"_W" + wheel.str();
375 LogTrace(
"DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
376 <<
"[DTLocalTriggerBaseTask]: booking wheel histos for "
377 <<
topFolder(
"DDU") <<
"Wheel" << wh << endl;
379 string histoTag =
"COM_BXDiff";
381 "DDU-TM BX Difference",12,1,13,4,1,5,0.,20.);
390 std::vector<L1MuDTChambPhDigi>
const* phOutTrigs,
391 std::vector<L1MuDTChambThDigi>
const* thTrigs )
393 vector<L1MuDTChambPhDigi>::const_iterator iph = phInTrigs->begin();
394 vector<L1MuDTChambPhDigi>::const_iterator iphe = phInTrigs->end();
396 for(; iph !=iphe ; ++iph) {
398 int wh = iph->whNum();
399 int sec = iph->scNum() + 1;
400 int st = iph->stNum();
401 int qual = iph->code();
402 int is1st = iph->Ts2Tag() ? 1 : 0;
403 int bx = iph->bxNum() - is1st;
405 if (qual <0 || qual>6)
continue;
408 uint32_t rawId = dtChId.
rawId();
417 map<string, MonitorElement*> &innerME =
chamberHistos[rawId];
419 innerME[
"TM_BXvsQual_In"]->Fill(qual,bx);
420 innerME[
"TM_QualvsPhirad_In"]->Fill(pos,qual);
422 innerME[
"TM_BXvsQual_In"]->Fill(qual,bx);
423 innerME[
"TM_Flag1stvsQual_In"]->Fill(qual,is1st);
424 if (!is1st) innerME[
"TM_QualvsPhirad_In"]->Fill(pos,qual);
426 innerME[
"TM_QualvsPhibend_In"]->Fill(dir,qual);
432 iph = phOutTrigs->begin();
433 iphe = phOutTrigs->end();
435 for(; iph !=iphe ; ++iph) {
437 int wh = iph->whNum();
438 int sec = iph->scNum() + 1;
439 int st = iph->stNum();
440 int qual = iph->code();
441 int is1st = iph->Ts2Tag() ? 1 : 0;
442 int bx = iph->bxNum() - is1st;
444 if (qual <0 || qual>6)
continue;
447 uint32_t rawId = dtChId.
rawId();
456 map<string, MonitorElement*> &innerME =
chamberHistos[rawId];
458 innerME[
"TM_BXvsQual_Out"]->Fill(qual,bx);
459 innerME[
"TM_QualvsPhirad_Out"]->Fill(pos,qual);
461 innerME[
"TM_BXvsQual_Out"]->Fill(qual,bx);
462 innerME[
"TM_Flag1stvsQual_Out"]->Fill(qual,is1st);
463 if (!is1st) innerME[
"TM_QualvsPhirad_Out"]->Fill(pos,qual);
465 innerME[
"TM_QualvsPhibend_Out"]->Fill(dir,qual);
471 vector<L1MuDTChambThDigi>::const_iterator ith = thTrigs->begin();
472 vector<L1MuDTChambThDigi>::const_iterator ithe = thTrigs->end();
474 for(; ith != ithe; ++ith) {
475 int wh = ith->whNum();
476 int sec = ith->scNum() + 1;
477 int st = ith->stNum();
478 int bx = ith->bxNum();
482 for (
int pos=0; pos<7; pos++)
483 thcode[pos] = ith->code(pos);
486 uint32_t rawId = dtChId.
rawId();
488 map<string, MonitorElement*> &innerME =
chamberHistos[rawId];
490 for (
int pos=0; pos<7; pos++)
492 innerME[
"TM_PositionvsBX"]->Fill(bx,pos);
493 innerME[
"TM_PositionvsQual"]->Fill(thcode[pos],pos);
494 innerME[
"TM_ThetaBXvsQual"]->Fill(thcode[pos],bx);
499 map<uint32_t,DTTPGCompareUnit>::const_iterator compIt =
theCompMapIn.begin();
500 map<uint32_t,DTTPGCompareUnit>::const_iterator compEnd =
theCompMapIn.end();
501 for (; compIt!=compEnd; ++compIt) {
502 int bestQual = compIt->second.qualTM();
504 chamberHistos[compIt->first][
"TM_BestQual_In"]->Fill(bestQual);
510 map<uint32_t,DTTPGCompareUnit>::const_iterator compIt =
theCompMapOut.begin();
511 map<uint32_t,DTTPGCompareUnit>::const_iterator compEnd =
theCompMapOut.end();
512 for (; compIt!=compEnd; ++compIt) {
513 int bestQual = compIt->second.qualTM();
515 chamberHistos[compIt->first][
"TM_BestQual_Out"]->Fill(bestQual);
527 for (; detUnitIt!=detUnitEnd; ++detUnitIt){
530 uint32_t rawId = chId.
rawId();
534 map<string, MonitorElement*> &innerME =
chamberHistos[rawId];
536 int bestQualTheta = -1;
538 for (; trigIt!=range.second; ++trigIt){
540 int qualPhi = trigIt->quality();
541 int qualTheta = trigIt->trTheta();
542 int flag1st = trigIt->secondTrack() ? 1 : 0;
543 int bx = trigIt->bx();
544 int bxPhi = bx - flag1st;
546 if( qualPhi>-1 && qualPhi<7 ) {
551 innerME[
"DDU_BXvsQual"]->Fill(qualPhi,bxPhi);
553 innerME[
"DDU_BXvsQual"]->Fill(qualPhi,bxPhi);
554 innerME[
"DDU_Flag1stvsQual"]->Fill(qualPhi,flag1st);
558 if( qualTheta>0 && !
tpMode ){
559 if (qualTheta > bestQualTheta){
560 bestQualTheta = qualTheta;
562 innerME[
"DDU_ThetaBXvsQual"]->Fill(qualTheta,bx);
570 innerME[
"DDU_BestQual"]->Fill(bestQualPhi);
571 if(bestQualTheta>0) {
572 innerME[
"DDU_ThetaBestQual"]->Fill(bestQualTheta);
582 map<uint32_t,DTTPGCompareUnit>::const_iterator compIt =
theCompMapIn.begin();
583 map<uint32_t,DTTPGCompareUnit>::const_iterator compEnd =
theCompMapIn.end();
585 for (; compIt!=compEnd; ++compIt) {
587 uint32_t rawId = compIt->first;
589 map<string, MonitorElement*> &innerME =
chamberHistos[rawId];
593 innerME[
"COM_QualDDUvsQualTM"]->Fill(compUnit.
qualTM(),compUnit.
qualDDU());
613 axis=histo->GetXaxis();
616 axis=histo->GetYaxis();
620 string labels[7] = {
"LI",
"LO",
"HI",
"HO",
"LL",
"HL",
"HH"};
621 int istart = axis->GetXmin()<-1 ? 2 : 1;
622 for (
int i=0;
i<7;
i++) {
623 axis->SetBinLabel(
i+istart,labels[
i].c_str());
635 axis=histo->GetXaxis();
638 axis=histo->GetYaxis();
642 string labels[2] = {
"L",
"H"};
643 int istart = axis->GetXmin()<-1 ? 2 : 1;
644 for (
int i=0;
i<2;
i++) {
645 axis->SetBinLabel(
i+istart,labels[
i].c_str());
T getUntrackedParameter(std::string const &, T const &) const
void runDDUvsTMAnalysis()
Run analysis on ROS data.
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
Beginrun.
void bookHistos(DQMStore::IBooker &, const DTChamberId &chamb)
Book the histograms.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
float trigDir(const L1MuDTChambPhDigi *trig)
Return local direction (trigger RF) for a given trigger primitive.
void setDDU(int qual, int bx)
std::map< int, std::map< std::string, MonitorElement * > > wheelHistos
void setTM(int qual, int bx)
virtual ~DTLocalTriggerBaseTask()
Destructor.
std::vector< std::string > theTypes
LuminosityBlockNumber_t luminosityBlock() const
uint32_t rawId() const
get the raw id
DTTrigGeomUtils * theTrigGeomUtils
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context) override
Perform trend plot operations.
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
MonitorElement * bookProfile2D(Args &&...args)
edm::EDGetTokenT< L1MuDTChambThContainer > tm_theta_Token_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * book1D(Args &&...args)
Abs< T >::type abs(const T &t)
std::map< uint32_t, DTTPGCompareUnit > theCompMapOut
edm::EDGetTokenT< DTLocalTriggerCollection > trig_Token_
void runTMAnalysis(std::vector< L1MuDTChambPhDigi > const *phInTrigs, std::vector< L1MuDTChambPhDigi > const *phOutTrigs, std::vector< L1MuDTChambThDigi > const *thTrigs)
Run analysis on TM data.
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context) override
To reset the MEs.
MonitorElement * nEventMonitor
void phiRange(const DTChamberId &id, float &min, float &max, int &nbins, float step=15)
Compute phi range in local chamber coordinates.
std::map< uint32_t, DTTPGCompareUnit > theCompMapIn
std::string & topFolder(std::string const &type)
Get the Top folder (different between Physics and TP and TM/DDU)
std::map< uint32_t, std::map< std::string, MonitorElement * > > chamberHistos
void setQLabelsTheta(MonitorElement *me, short int iaxis)
void setCurrentFolder(const std::string &fullpath)
MonitorElement * book2D(Args &&...args)
edm::ParameterSet theParams
std::vector< DTLocalTrigger >::const_iterator const_iterator
void setQLabels(MonitorElement *me, short int iaxis)
Set Quality labels.
edm::EDGetTokenT< L1MuDTChambPhContainer > tm_phiIn_Token_
std::map< uint32_t, DTTimeEvolutionHisto * > trendHistos
std::pair< const_iterator, const_iterator > Range
MonitorElement * bookFloat(Args &&...args)
void runDDUAnalysis(edm::Handle< DTLocalTriggerCollection > &trigsDDU)
Run analysis on ROS data.
float trigPos(const L1MuDTChambPhDigi *trig)
Return local position (trigger RF) for a given trigger primitive.
int station() const
Return the station number.
edm::EDGetTokenT< L1MuDTChambPhContainer > tm_phiOut_Token_
DTLocalTriggerBaseTask(const edm::ParameterSet &ps)
Constructor.
int wheel() const
Return the wheel number.
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)