CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/DQM/DTMonitorModule/src/DTLocalTriggerBaseTask.cc

Go to the documentation of this file.
00001 /*
00002  * \file DTLocalTriggerBaseTask.cc
00003  * 
00004  * $Date: 2011/06/10 13:23:26 $
00005  * $Revision: 1.1 $
00006  * \author C. Battilana - CIEMAT
00007  *
00008 */
00009 
00010 #include "DQM/DTMonitorModule/src/DTLocalTriggerBaseTask.h"
00011 
00012 // Framework
00013 #include "FWCore/Framework/interface/EventSetup.h"
00014 
00015 // DT DQM
00016 #include "DQM/DTMonitorModule/interface/DTTimeEvolutionHisto.h"
00017 
00018 // DT trigger
00019 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h"
00020 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h"
00021 #include "DQM/DTMonitorModule/interface/DTTrigGeomUtils.h"
00022 
00023 // Geometry
00024 #include "DataFormats/GeometryVector/interface/Pi.h"
00025 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00026 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00027 #include "Geometry/DTGeometry/interface/DTLayer.h"
00028 #include "Geometry/DTGeometry/interface/DTTopology.h"
00029 
00030 //Root
00031 #include"TH1.h"
00032 #include"TAxis.h"
00033 
00034 #include <sstream>
00035 #include <iostream>
00036 #include <fstream>
00037 
00038 using namespace edm;
00039 using namespace std;
00040 
00041 class DTTPGCompareUnit {
00042   
00043 public:
00044 
00045   DTTPGCompareUnit()  { theQual[0]=-1 ; theQual[1]=-1; }
00046   ~DTTPGCompareUnit() { };
00047 
00048   void setDDU(int qual, int bx) { theQual[0] = qual; theBX[0] = bx; }
00049   void setDCC(int qual, int bx) { theQual[1] = qual; theBX[1] = bx; }
00050 
00051   bool hasOne()      const { return theQual[0]!=-1 || theQual[1]!=-1; };
00052   bool hasBoth()     const { return theQual[0]!=-1 && theQual[1]!=-1; };
00053   bool hasSameQual() const { return hasBoth() && theQual[0]==theQual[1]; };
00054   int  deltaBX() const { return theBX[0] - theBX[1]; }
00055   int  qualDDU() const { return theQual[0]; }
00056   int  qualDCC() const { return theQual[1]; }
00057 
00058 private:
00059   
00060   int theQual[2]; // 0=DDU 1=DCC
00061   int theBX[2];   // 0=DDU 1=DCC
00062 
00063 };    
00064 
00065 
00066 
00067 DTLocalTriggerBaseTask::DTLocalTriggerBaseTask(const edm::ParameterSet& ps) : 
00068   nEvents(0), nLumis(0), theTrigGeomUtils(0) {
00069   
00070   LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask") 
00071     << "[DTLocalTriggerBaseTask]: Constructor"<<endl;
00072 
00073   tpMode           = ps.getUntrackedParameter<bool>("testPulseMode");
00074   detailedAnalysis = ps.getUntrackedParameter<bool>("detailedAnalysis");
00075 
00076   targetBXDCC  = ps.getUntrackedParameter<int>("targetBXDCC");
00077   targetBXDDU  = ps.getUntrackedParameter<int>("targetBXDDU");
00078   bestAccRange = ps.getUntrackedParameter<int>("bestTrigAccRange");
00079 
00080   processDCC   = ps.getUntrackedParameter<bool>("processDCC");
00081   processDDU   = ps.getUntrackedParameter<bool>("processDDU");
00082 
00083   if (processDCC) theTypes.push_back("DCC");
00084   if (processDDU) theTypes.push_back("DDU");
00085 
00086   if (tpMode) {
00087     topFolder("DCC") = "DT/11-LocalTriggerTP-DCC/";
00088     topFolder("DDU") = "DT/12-LocalTriggerTP-DDU/";
00089   } else {
00090     topFolder("DCC") = "DT/03-LocalTrigger-DCC/";
00091     topFolder("DDU") = "DT/04-LocalTrigger-DDU/";
00092   }
00093 
00094   theParams = ps; 
00095   theDQMStore = edm::Service<DQMStore>().operator->();
00096 
00097 }
00098 
00099 
00100 DTLocalTriggerBaseTask::~DTLocalTriggerBaseTask() {
00101 
00102   LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask") 
00103     << "[DTLocalTriggerBaseTask]: analyzed " << nEvents << " events" << endl;
00104   if (theTrigGeomUtils) { delete theTrigGeomUtils; }
00105 
00106 }
00107 
00108 
00109 void DTLocalTriggerBaseTask::beginJob() {
00110  
00111   LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask") 
00112     << "[DTLocalTriggerBaseTask]: BeginJob" << endl;
00113 
00114 }
00115 
00116 
00117 void DTLocalTriggerBaseTask::beginRun(const edm::Run& run, const edm::EventSetup& context) {
00118 
00119   LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask") 
00120     << "[DTLocalTriggerBaseTask]: BeginRun" << endl;   
00121 
00122   ESHandle<DTGeometry> theGeom;  
00123   context.get<MuonGeometryRecord>().get(theGeom);
00124   theTrigGeomUtils = new DTTrigGeomUtils(theGeom);
00125 
00126   theDQMStore->setCurrentFolder("DT/EventInfo/Counters");
00127   nEventMonitor = theDQMStore->bookFloat("nProcessedEventsTrigger");
00128   for (int wh=-2;wh<3;++wh){
00129     for (int stat=1;stat<5;++stat){
00130       for (int sect=1;sect<13;++sect){
00131         bookHistos(DTChamberId(wh,stat,sect));
00132       }
00133     }
00134     bookHistos(wh);
00135   }
00136 
00137 }
00138 
00139 
00140 void DTLocalTriggerBaseTask::beginLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& context) {
00141 
00142   nEventsInLS=0;
00143   nLumis++;
00144   int resetCycle = theParams.getUntrackedParameter<int>("ResetCycle"); 
00145 
00146   LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask") 
00147     << "[DTLocalTriggerBaseTask]: Begin of LS transition" << endl;
00148   
00149   if( nLumis%resetCycle == 0 ) {
00150     map<uint32_t,map<string,MonitorElement*> >::const_iterator chambIt  = chamberHistos.begin();
00151     map<uint32_t,map<string,MonitorElement*> >::const_iterator chambEnd = chamberHistos.end();
00152     for(;chambIt!=chambEnd;++chambIt) {
00153       map<string,MonitorElement*>::const_iterator histoIt  = chambIt->second.begin();
00154       map<string,MonitorElement*>::const_iterator histoEnd = chambIt->second.end();
00155       for(;histoIt!=histoEnd;++histoIt) {
00156         histoIt->second->Reset();
00157       }
00158     }
00159   }
00160   
00161 }
00162 
00163 void DTLocalTriggerBaseTask::endLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& context) {
00164 
00165   LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask") 
00166     << "[DTLocalTriggerBaseTask]: End of LS transition" << endl;
00167   
00168   map<uint32_t,DTTimeEvolutionHisto* >::const_iterator chambIt  = trendHistos.begin();
00169   map<uint32_t,DTTimeEvolutionHisto* >::const_iterator chambEnd = trendHistos.end();
00170   for(;chambIt!=chambEnd;++chambIt) {
00171     chambIt->second->updateTimeSlot(lumiSeg.luminosityBlock(), nEventsInLS);
00172   }
00173   
00174 }
00175 
00176 
00177 void DTLocalTriggerBaseTask::endJob() {
00178 
00179   LogVerbatim("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask") 
00180     << "[DTLocalTriggerBaseTask]: analyzed " << nEvents << " events" << endl;
00181 
00182   if (processDCC) theDQMStore->rmdir(topFolder("DCC"));
00183   if (processDDU) theDQMStore->rmdir(topFolder("DDU"));
00184 
00185 }
00186 
00187 
00188 void DTLocalTriggerBaseTask::analyze(const edm::Event& e, const edm::EventSetup& c){
00189   
00190   nEvents++;
00191   nEventsInLS++;
00192   nEventMonitor->Fill(nEvents);
00193 
00194   theCompMap.clear();
00195 
00196   Handle<L1MuDTChambPhContainer> phiTrigsDCC;
00197   Handle<L1MuDTChambThContainer> thetaTrigsDCC;
00198   Handle<DTLocalTriggerCollection> trigsDDU;
00199 
00200   if (processDCC) {
00201     InputTag inputTagDCC = theParams.getUntrackedParameter<InputTag>("inputTagDCC");
00202 
00203     e.getByLabel(inputTagDCC,phiTrigsDCC);
00204     e.getByLabel(inputTagDCC,thetaTrigsDCC);
00205 
00206     if (phiTrigsDCC.isValid() && thetaTrigsDCC.isValid()) {
00207       runDCCAnalysis(phiTrigsDCC->getContainer(),thetaTrigsDCC->getContainer());
00208     } else {
00209       LogVerbatim("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask") 
00210         << "[DTLocalTriggerBaseTask]: one or more DCC handles for Input Tag " 
00211         << inputTagDCC <<" not found!" << endl;
00212       return;
00213     }
00214   }
00215 
00216   if (processDDU) {
00217     InputTag inputTagDDU = theParams.getUntrackedParameter<InputTag>("inputTagDDU");
00218     e.getByLabel(inputTagDDU,trigsDDU);
00219 
00220     if (trigsDDU.isValid()) {
00221       runDDUAnalysis(trigsDDU);
00222     } else {
00223       LogVerbatim("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask") 
00224         << "[DTLocalTriggerBaseTask]: one or more DDU handles for Input Tag " 
00225         << inputTagDDU <<" not found!" << endl;
00226       return;
00227     }
00228   }
00229   
00230   if (processDCC && processDDU)
00231     runDDUvsDCCAnalysis();
00232 
00233 }
00234 
00235 
00236 void DTLocalTriggerBaseTask::bookHistos(const DTChamberId& dtCh) {
00237 
00238   uint32_t rawId = dtCh.rawId();
00239 
00240   stringstream wheel; wheel << dtCh.wheel();    
00241   stringstream station; station << dtCh.station();      
00242   stringstream sector; sector << dtCh.sector(); 
00243 
00244   map<string,int> minBX;
00245   map<string,int> maxBX;
00246 
00247   minBX["DCC"] = theParams.getUntrackedParameter<int>("minBXDCC");
00248   maxBX["DCC"] = theParams.getUntrackedParameter<int>("maxBXDCC");
00249   minBX["DDU"] = theParams.getUntrackedParameter<int>("minBXDDU");
00250   maxBX["DDU"] = theParams.getUntrackedParameter<int>("maxBXDDU");
00251 
00252   int nTimeBins  = theParams.getUntrackedParameter<int>("nTimeBins");
00253   int nLSTimeBin = theParams.getUntrackedParameter<int>("nLSTimeBin");
00254 
00255   string chTag = "_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
00256 
00257   vector<string>::const_iterator typeIt  = theTypes.begin();
00258   vector<string>::const_iterator typeEnd = theTypes.end();
00259 
00260   for (; typeIt!=typeEnd; ++typeIt) {
00261 
00262     LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask") 
00263       << "[DTLocalTriggerBaseTask]: booking histos for " << topFolder((*typeIt)) << "Wheel" 
00264       << wheel.str() << "/Sector" << sector.str() << "/Station"<< station.str() << endl;
00265 
00266     // Book Phi View Related Plots
00267     theDQMStore->setCurrentFolder(topFolder(*typeIt) + "Wheel" + wheel.str() + "/Sector" 
00268                           + sector.str() + "/Station" + station.str() + "/LocalTriggerPhi");      
00269 
00270     string histoTag = (*typeIt) + "_BXvsQual";
00271     chamberHistos[rawId][histoTag] = theDQMStore->book2D(histoTag+chTag,"BX vs trigger quality",
00272        7,-0.5,6.5,(int)(maxBX[(*typeIt)]-minBX[*typeIt]+1),minBX[*typeIt]-.5,maxBX[*typeIt]+.5);
00273     setQLabels((chamberHistos[rawId])[histoTag],1);
00274 
00275     if (!tpMode) {
00276       histoTag = (*typeIt) + "_BestQual";
00277       chamberHistos[rawId][histoTag] = theDQMStore->book1D(histoTag+chTag,
00278                  "Trigger quality of best primitives",7,-0.5,6.5);
00279       setQLabels(chamberHistos[rawId][histoTag],1);
00280 
00281       histoTag = (*typeIt) + "_Flag1stvsQual";
00282       chamberHistos[dtCh.rawId()][histoTag] = theDQMStore->book2D(histoTag+chTag,
00283                   "1st/2nd trig flag vs quality",7,-0.5,6.5,2,-0.5,1.5);
00284       setQLabels(chamberHistos[rawId][histoTag],1);
00285     }
00286 
00287     if (*typeIt=="DCC") {
00288       float minPh, maxPh; int nBinsPh;
00289       theTrigGeomUtils->phiRange(dtCh,minPh,maxPh,nBinsPh);
00290 
00291       histoTag = (*typeIt) + "_QualvsPhirad";    
00292       chamberHistos[rawId][histoTag] = theDQMStore->book2D(histoTag+chTag,
00293            "Trigger quality vs local position",nBinsPh,minPh,maxPh,7,-0.5,6.5);
00294       setQLabels(chamberHistos[rawId][histoTag],2);
00295 
00296       if (detailedAnalysis && !tpMode) {
00297         histoTag == (*typeIt) + "_QualvsPhibend";
00298         chamberHistos[rawId][histoTag] = theDQMStore->book2D(histoTag+chTag,
00299               "Trigger quality vs local direction",200,-40.,40.,7,-0.5,6.5);
00300         setQLabels((chamberHistos[dtCh.rawId()])[histoTag],2);
00301       }   
00302     }
00303           
00304     // Book Theta View Related Plots
00305     theDQMStore->setCurrentFolder(topFolder(*typeIt) + "Wheel" + wheel.str() + "/Sector" 
00306                  + sector.str() + "/Station" + station.str() + "/LocalTriggerTheta");
00307 
00308     if((*typeIt)=="DCC") {
00309       histoTag = (*typeIt) + "_PositionvsBX";      
00310       chamberHistos[rawId][histoTag] = theDQMStore->book2D(histoTag+chTag,"Theta trigger position vs BX",
00311                               (int)(maxBX[(*typeIt)]-minBX[*typeIt]+1),minBX[*typeIt]-.5,maxBX[*typeIt]+.5,7,-0.5,6.5);
00312     } else {
00313       histoTag = (*typeIt) + "_ThetaBXvsQual";      
00314       chamberHistos[rawId][histoTag] =  theDQMStore->book2D(histoTag+chTag,"BX vs trigger quality",7,-0.5,6.5,
00315                                            (int)(maxBX[(*typeIt)]-minBX[*typeIt]+1),minBX[*typeIt]-.5,maxBX[*typeIt]+.5);
00316       setQLabels((chamberHistos[dtCh.rawId()])[histoTag],1);
00317 
00318       histoTag = (*typeIt) + "_ThetaBestQual";      
00319       chamberHistos[rawId][histoTag] = theDQMStore->book1D(histoTag+chTag,
00320       "Trigger quality of best primitives (theta)",7,-0.5,6.5);
00321       setQLabels((chamberHistos[dtCh.rawId()])[histoTag],1);
00322     }
00323 
00324   }
00325 
00326   if (processDCC && processDDU) {
00327     // Book DCC/DDU Comparison Plots
00328     theDQMStore->setCurrentFolder(topFolder("DDU") + "Wheel" + wheel.str() + "/Sector" 
00329                        + sector.str() + "/Station" + station.str() + "/LocalTriggerPhi");      
00330 
00331     string histoTag = "COM_QualDDUvsQualDCC";
00332     chamberHistos[rawId][histoTag] = theDQMStore->book2D(histoTag+chTag,
00333                         "DDU quality vs DCC quality",8,-1.5,6.5,8,-1.5,6.5);
00334     setQLabels((chamberHistos[rawId])[histoTag],1);
00335     setQLabels((chamberHistos[rawId])[histoTag],2);
00336 
00337     histoTag = "COM_MatchingTrend";
00338     trendHistos[rawId] = new DTTimeEvolutionHisto(&(*theDQMStore),histoTag+chTag,
00339                                                   "Fraction of DDU-DCC matches w.r.t. proc evts",
00340                                                   nTimeBins,nLSTimeBin,true,0);
00341   }      
00342 
00343 }
00344 
00345 void DTLocalTriggerBaseTask::bookHistos(int wh) {
00346   
00347   stringstream wheel; wheel << wh;      
00348   theDQMStore->setCurrentFolder(topFolder("DDU") + "Wheel" + wheel.str() + "/");
00349   string whTag = "_W" + wheel.str();
00350     
00351   LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask") 
00352     << "[DTLocalTriggerBaseTask]: booking wheel histos for " 
00353     << topFolder("DDU") << "Wheel" << wh << endl;
00354   
00355   string histoTag = "COM_BXDiff";
00356   MonitorElement *me = theDQMStore->bookProfile2D(histoTag+whTag,
00357         "DDU-DCC BX Difference",12,1,13,4,1,5,0.,20.);
00358   me->setAxisTitle("Sector",1);
00359   me->setAxisTitle("station",2);
00360   wheelHistos[wh][histoTag] = me;
00361   
00362 }
00363 
00364 
00365 void DTLocalTriggerBaseTask::runDCCAnalysis( std::vector<L1MuDTChambPhDigi>* phTrigs, 
00366                                          std::vector<L1MuDTChambThDigi>* thTrigs ){
00367 
00368   vector<L1MuDTChambPhDigi>::const_iterator iph  = phTrigs->begin();
00369   vector<L1MuDTChambPhDigi>::const_iterator iphe = phTrigs->end();
00370 
00371   for(; iph !=iphe ; ++iph) {
00372 
00373     int wh    = iph->whNum();
00374     int sec   = iph->scNum() + 1; // DTTF->DT Convention
00375     int st    = iph->stNum();
00376     int qual  = iph->code();
00377     int is1st = iph->Ts2Tag() ? 1 : 0;
00378     int bx    = iph->bxNum() - is1st;
00379 
00380     if (qual <0 || qual>6) continue; // Check that quality is in a valid range
00381 
00382     DTChamberId dtChId(wh,st,sec);
00383     uint32_t rawId = dtChId.rawId();
00384       
00385     float pos = theTrigGeomUtils->trigPos(&(*iph));
00386     float dir = theTrigGeomUtils->trigDir(&(*iph));
00387 
00388     if (abs(bx-targetBXDCC)<= bestAccRange &&
00389         theCompMap[rawId].qualDCC() <= qual) 
00390       theCompMap[rawId].setDCC(qual,bx);
00391     
00392     map<string, MonitorElement*> &innerME = chamberHistos[rawId];
00393     if (tpMode) {
00394       innerME["DCC_BXvsQual"]->Fill(qual,bx);      // SM BX vs Qual Phi view (1st tracks) 
00395       innerME["DCC_QualvsPhirad"]->Fill(pos,qual); // SM Qual vs radial angle Phi view
00396     } else {
00397       innerME["DCC_BXvsQual"]->Fill(qual,bx);         // SM BX vs Qual Phi view (1st tracks) 
00398       innerME["DCC_Flag1stvsQual"]->Fill(qual,is1st); // SM Qual 1st/2nd track flag Phi view
00399       if (!is1st) innerME["DCC_QualvsPhirad"]->Fill(pos,qual);  // SM Qual vs radial angle Phi view ONLY for 1st tracks
00400       if (detailedAnalysis) {
00401         innerME["DCC_QualvsPhibend"]->Fill(dir,qual); // SM Qual vs bending Phi view
00402       }
00403     }
00404     
00405   } 
00406 
00407   vector<L1MuDTChambThDigi>::const_iterator ith  = thTrigs->begin();
00408   vector<L1MuDTChambThDigi>::const_iterator ithe = thTrigs->end();
00409 
00410   for(; ith != ithe; ++ith) {
00411     int wh  = ith->whNum();
00412     int sec = ith->scNum() + 1; // DTTF -> DT Convention
00413     int st  = ith->stNum();
00414     int bx  = ith->bxNum();
00415       
00416     int thcode[7];
00417     
00418     for (int pos=0; pos<7; pos++)
00419       thcode[pos] = ith->code(pos);    
00420       
00421     DTChamberId dtChId(wh,st,sec);
00422     uint32_t rawId = dtChId.rawId();   
00423 
00424     map<string, MonitorElement*> &innerME = chamberHistos[rawId];
00425 
00426     for (int pos=0; pos<7; pos++)
00427       if (thcode[pos])
00428         innerME["DCC_PositionvsBX"]->Fill(bx,pos); // SM BX vs Position Theta view
00429 
00430   }
00431   
00432   // Fill Quality plots with best DCC triggers (phi view)
00433   if (!tpMode) {
00434     map<uint32_t,DTTPGCompareUnit>::const_iterator compIt  = theCompMap.begin();
00435     map<uint32_t,DTTPGCompareUnit>::const_iterator compEnd = theCompMap.end();
00436     for (; compIt!=compEnd; ++compIt) {
00437       int bestQual = compIt->second.qualDCC();
00438       if (bestQual > -1) 
00439         chamberHistos[compIt->first]["DCC_BestQual"]->Fill(bestQual);  // SM Best Qual Trigger Phi view
00440     }
00441   }
00442 
00443 }
00444 
00445 
00446 void DTLocalTriggerBaseTask::runDDUAnalysis(Handle<DTLocalTriggerCollection>& trigsDDU){
00447     
00448   DTLocalTriggerCollection::DigiRangeIterator detUnitIt  = trigsDDU->begin();
00449   DTLocalTriggerCollection::DigiRangeIterator detUnitEnd = trigsDDU->end();
00450 
00451   for (; detUnitIt!=detUnitEnd; ++detUnitIt){
00452       
00453     const DTChamberId& chId = (*detUnitIt).first;
00454     uint32_t rawId = chId.rawId();
00455 
00456     const DTLocalTriggerCollection::Range& range = (*detUnitIt).second;
00457     DTLocalTriggerCollection::const_iterator trigIt = range.first;
00458     map<string, MonitorElement*> &innerME = chamberHistos[rawId];
00459 
00460     int bestQualTheta = -1;
00461 
00462     for (; trigIt!=range.second; ++trigIt){
00463         
00464       int qualPhi   = trigIt->quality();
00465       int qualTheta = trigIt->trTheta();
00466       int flag1st   = trigIt->secondTrack() ? 1 : 0;
00467       int bx = trigIt->bx();
00468       int bxPhi = bx - flag1st; // phi BX assign is different for 1st & 2nd tracks
00469       
00470       if( qualPhi>-1 && qualPhi<7 ) { // it is a phi trigger
00471         if (abs(bx-targetBXDDU) <= bestAccRange &&
00472             theCompMap[rawId].qualDDU()<= qualPhi)
00473           theCompMap[rawId].setDDU(qualPhi,bxPhi);
00474         if(tpMode) {      
00475           innerME["DDU_BXvsQual"]->Fill(qualPhi,bxPhi); // SM BX vs Qual Phi view       
00476         } else {
00477           innerME["DDU_BXvsQual"]->Fill(qualPhi,bxPhi); // SM BX vs Qual Phi view       
00478           innerME["DDU_Flag1stvsQual"]->Fill(qualPhi,flag1st); // SM Quality vs 1st/2nd track flag Phi view
00479         }
00480       }
00481 
00482       if( qualTheta>0 && !tpMode ){// it is a theta trigger & is not TP
00483         if (qualTheta > bestQualTheta){
00484           bestQualTheta = qualTheta;
00485         }
00486         innerME["DDU_ThetaBXvsQual"]->Fill(qualTheta,bx); // SM BX vs Qual Theta view
00487       }
00488     }
00489     
00490     // Fill Quality plots with best ddu triggers
00491     if (!tpMode && theCompMap.find(rawId)!= theCompMap.end()) {
00492       int bestQualPhi = theCompMap[rawId].qualDDU();
00493       if (bestQualPhi>-1)
00494         innerME["DDU_BestQual"]->Fill(bestQualPhi); // SM Best Qual Trigger Phi view
00495       if(bestQualTheta>0) {
00496         innerME["DDU_ThetaBestQual"]->Fill(bestQualTheta); // SM Best Qual Trigger Theta view
00497       }  
00498     }
00499   }
00500   
00501 }
00502 
00503 
00504 void DTLocalTriggerBaseTask::runDDUvsDCCAnalysis(){
00505 
00506   map<uint32_t,DTTPGCompareUnit>::const_iterator compIt  = theCompMap.begin();
00507   map<uint32_t,DTTPGCompareUnit>::const_iterator compEnd = theCompMap.end();
00508 
00509   for (; compIt!=compEnd; ++compIt) {
00510 
00511     uint32_t rawId = compIt->first;
00512     DTChamberId chId(rawId);
00513     map<string, MonitorElement*> &innerME = chamberHistos[rawId];
00514 
00515     const DTTPGCompareUnit & compUnit = compIt->second;   
00516     if ( compUnit.hasOne() ){
00517       innerME["COM_QualDDUvsQualDCC"]->Fill(compUnit.qualDCC(),compUnit.qualDDU());
00518     }
00519     if ( compUnit.hasBoth() ){
00520       wheelHistos[chId.wheel()]["COM_BXDiff"]->Fill(chId.sector(),chId.station(),compUnit.deltaBX());
00521       if (  compUnit.hasSameQual() ) {
00522         trendHistos[rawId]->accumulateValueTimeSlot(1);
00523       }
00524     }
00525   }
00526 
00527 }
00528 
00529 
00530 void DTLocalTriggerBaseTask::setQLabels(MonitorElement* me, short int iaxis){
00531 
00532   TH1* histo = me->getTH1();
00533   if (!histo) return;
00534   
00535   TAxis* axis=0;
00536   if (iaxis==1) {
00537     axis=histo->GetXaxis();
00538   }
00539   else if(iaxis==2) {
00540     axis=histo->GetYaxis();
00541   }
00542   if (!axis) return;
00543 
00544   string labels[7] = {"LI","LO","HI","HO","LL","HL","HH"};
00545   int istart = axis->GetXmin()<-1 ? 2 : 1;
00546   for (int i=0;i<7;i++) {
00547     axis->SetBinLabel(i+istart,labels[i].c_str());
00548   }
00549 
00550 }