Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:51

0001 /*
0002  * \file L1TDTTPG.cc
0003  *
0004  * \author J. Berryhill
0005  *
0006  *
0007  *
0008  * organized message logger
0009  *
0010  * Revision 1.19  2008/03/14 20:35:46  berryhil
0011  *
0012  *
0013  * stripped out obsolete parameter settings
0014  *
0015  * rpc tpg restored with correct dn access and dbe handling
0016  *
0017  * Revision 1.18  2008/03/12 17:24:24  berryhil
0018  *
0019  *
0020  * eliminated log files, truncated HCALTPGXana histo output
0021  *
0022  * Revision 1.17  2008/03/10 09:29:52  lorenzo
0023  * added MEs
0024  *
0025  * Revision 1.16  2008/03/01 00:40:00  lat
0026  * DQM core migration.
0027  *
0028  *
0029  *
0030  * organized message logger
0031  *
0032  * Revision 1.19  2008/03/14 20:35:46  berryhil
0033  *
0034  *
0035  * stripped out obsolete parameter settings
0036  *
0037  * rpc tpg restored with correct dn access and dbe handling
0038  *
0039  * Revision 1.18  2008/03/12 17:24:24  berryhil
0040  *
0041  *
0042  * eliminated log files, truncated HCALTPGXana histo output
0043  *
0044  * Revision 1.17  2008/03/10 09:29:52  lorenzo
0045  * added MEs
0046  *
0047  * Revision 1.15  2008/01/22 18:56:01  muzaffar
0048  * include cleanup. Only for cc/cpp files
0049  *
0050  * Revision 1.14  2007/12/21 17:41:20  berryhil
0051  *
0052  *
0053  * try/catch removal
0054  *
0055  * Revision 1.13  2007/11/19 15:08:22  lorenzo
0056  * changed top folder name
0057  *
0058  * Revision 1.12  2007/08/15 18:56:25  berryhil
0059  *
0060  *
0061  * split histograms by bx; add Maiken's bx classifier plots
0062  *
0063  * Revision 1.11  2007/07/26 09:37:09  berryhil
0064  *
0065  *
0066  * set verbose false for all modules
0067  * set verbose fix for DTTPG tracks
0068  *
0069  * Revision 1.10  2007/07/25 09:03:58  berryhil
0070  *
0071  *
0072  * conform to DTTFFEDReader input tag.... for now
0073  *
0074  * Revision 1.9  2007/07/12 16:06:18  wittich
0075  * add simple phi output track histograms.
0076  * note that the label of this class is different than others
0077  * from the DTFFReader creates.
0078  *
0079  */
0080 #include <iostream>
0081 #include <sstream>
0082 #include <fstream>
0083 #include <vector>
0084 
0085 #include "FWCore/ServiceRegistry/interface/Service.h"
0086 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0087 
0088 #include "DQM/L1TMonitor/interface/L1TDTTPG.h"
0089 
0090 using namespace std;
0091 using namespace edm;
0092 
0093 L1TDTTPG::L1TDTTPG(const ParameterSet &ps)
0094     : dttpgSourcePhContainer_token_(consumes<L1MuDTChambPhContainer>(ps.getParameter<InputTag>("dttpgSource"))),
0095       dttpgSourceThContainer_token_(consumes<L1MuDTChambThContainer>(ps.getParameter<InputTag>("dttpgSource"))),
0096       dttpgSource_(ps.getParameter<InputTag>("dttpgSource")) {
0097   trstring_ = dttpgSource_.label() + ":" + "DATA" + ":" + dttpgSource_.process();
0098   trToken_ = consumes<L1MuDTTrackContainer>(trstring_);
0099 
0100   // verbosity switch
0101   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
0102 
0103   if (verbose_)
0104     cout << "L1TDTTPG: constructor...." << endl;
0105 
0106   outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
0107   if (!outputFile_.empty()) {
0108     cout << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << endl;
0109   }
0110 
0111   bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
0112   if (disable) {
0113     outputFile_ = "";
0114   }
0115 }
0116 
0117 L1TDTTPG::~L1TDTTPG() {}
0118 
0119 void L1TDTTPG::dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) {
0120   //empty
0121 }
0122 
0123 void L1TDTTPG::bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &, edm::EventSetup const &) {
0124   nev_ = 0;
0125   ibooker.setCurrentFolder("L1T/L1TDTTPG");
0126 
0127   //hist1[0]
0128   dttpgphbx[0] = ibooker.book1D("BxEncoding_PHI", "Bunch encoding DTTF Phi", 11, 0, 11);
0129   //hist1[1]
0130   dttpgphbx[1] = ibooker.book1D("BxEncoding_OUT", "Bunch encoding DTTF Output", 11, 0, 11);
0131 
0132   //hist1[2]
0133   dttpgphbx[2] = ibooker.book1D("NumberOfSegmentsPHI_BunchNeg1", "Number of segments for bunch -1 Dttf Phi", 20, 0, 20);
0134   //hist1[3]
0135   dttpgphbx[3] = ibooker.book1D("NumberOfSegmentsPHI_Bunch0", "Number of segments for bunch 0 Dttf Phi", 20, 0, 20);
0136   //hist1[4]
0137   dttpgphbx[4] = ibooker.book1D("NumberOfSegmentsPHI_Bunch1", "Number of segments for bunch 1 Dttf Phi", 20, 0, 20);
0138 
0139   //hist1[5]
0140   dttpgphbx[5] =
0141       ibooker.book1D("NumberOfSegmentsOUT_BunchNeg1", "Number of segments for bunch -1 Dttf Output", 20, 0, 20);
0142   //hist1[6]
0143   dttpgphbx[6] = ibooker.book1D("NumberOfSegmentsOUT_Bunch0", "Number of segments for bunch 0 Dttf Output", 20, 0, 20);
0144   //hist1[7]
0145   dttpgphbx[7] = ibooker.book1D("NumberOfSegmentsOUT_Bunch1", "Number of segments for bunch 1 Dttf Output", 20, 0, 20);
0146 
0147   for (int i = 0; i < 2; i++) {
0148     dttpgphbx[i]->setBinLabel(1, "None");
0149     dttpgphbx[i]->setBinLabel(3, "Only bx=-1");
0150     dttpgphbx[i]->setBinLabel(4, "Only bx= 0");
0151     dttpgphbx[i]->setBinLabel(5, "Only bx=+1");
0152     dttpgphbx[i]->setBinLabel(7, "Bx=-1,0");
0153     dttpgphbx[i]->setBinLabel(8, "Bx=-1,1");
0154     dttpgphbx[i]->setBinLabel(9, "Bx= 0,1");
0155     dttpgphbx[i]->setBinLabel(11, "All bx");
0156   }
0157 
0158   dttpgphbxcomp = ibooker.book2D("BxEncoding_PHI_OUT", "Bunch encoding: DTTF Phi vs. Output", 11, 0, 11, 11, 0, 11);
0159   dttpgphbxcomp->setAxisTitle("DTTF (output)", 1);
0160   dttpgphbxcomp->setAxisTitle("PHI-TF", 2);
0161   for (int i = 1; i <= 2; i++) {
0162     dttpgphbxcomp->setBinLabel(1, "None", i);
0163     dttpgphbxcomp->setBinLabel(3, "Only bx=-1", i);
0164     dttpgphbxcomp->setBinLabel(4, "Only bx= 0", i);
0165     dttpgphbxcomp->setBinLabel(5, "Only bx=+1", i);
0166     dttpgphbxcomp->setBinLabel(7, "Bx=-1,0", i);
0167     dttpgphbxcomp->setBinLabel(8, "Bx=-1,1", i);
0168     dttpgphbxcomp->setBinLabel(9, "Bx= 0,1", i);
0169     dttpgphbxcomp->setBinLabel(11, "All bx", i);
0170   }
0171 
0172   dttpgphntrack = ibooker.book1D("DT_TPG_phi_ntrack", "DT TPG phi ntrack", 20, -0.5, 19.5);
0173   dttpgthntrack = ibooker.book1D("DT_TPG_theta_ntrack", "DT TPG theta ntrack", 20, -0.5, 19.5);
0174 
0175   for (int ibx = 0; ibx <= 2; ibx++) {
0176     ostringstream bxnum;
0177     bxnum << ibx - 1;
0178     string bxn;
0179     if (ibx < 2)
0180       bxn = bxnum.str();
0181     else
0182       bxn = "+" + bxnum.str();
0183 
0184     // Phi
0185     dttpgphwheel[ibx] =
0186         ibooker.book1D("DT_TPG_phi_wheel_number_" + bxn, "DT TPG phi wheel number " + bxn, 5, -2.5, 2.5);
0187     dttpgphsector[ibx] =
0188         ibooker.book1D("DT_TPG_phi_sector_number_" + bxn, "DT TPG phi sector number " + bxn, 12, -0.5, 11.5);
0189     dttpgphstation[ibx] =
0190         ibooker.book1D("DT_TPG_phi_station_number_" + bxn, "DT TPG phi station number " + bxn, 5, 0.5, 4.5);
0191     //  dttpgphphi[ibx] = dbe->book1D("DT_TPG_phi_"+bxn,
0192     //                    "DT TPG phi "+bxn, 100, -2100., 2100. ) ;
0193     //  dttpgphphiB[ibx] = dbe->book1D("DT_TPG_phiB_"+bxn,
0194     //                     "DT TPG phiB "+bxn, 100, -550., 550. ) ;
0195     dttpgphquality[ibx] = ibooker.book1D("DT_TPG_phi_quality_" + bxn, "DT TPG phi quality " + bxn, 8, -0.5, 7.5);
0196     dttpgphts2tag[ibx] = ibooker.book1D("DT_TPG_phi_Ts2Tag_" + bxn, "DT TPG phi Ts2Tag " + bxn, 2, -0.5, 1.5);
0197     //  dttpgphbxcnt[ibx] = dbe->book1D("DT_TPG_phi_BxCnt_"+bxn,
0198     //                  "DT TPG phi BxCnt "+bxn, 10, -0.5, 9.5 ) ;
0199     dttpgphmapbx[ibx] =
0200         ibooker.book2D("DT_TPG_phi_map_bx" + bxn, "Map of triggers per station (BX=" + bxn + ")", 20, 1, 21, 12, 0, 12);
0201     setMapPhLabel(dttpgphmapbx[ibx]);
0202 
0203     //Theta
0204     dttpgthbx[ibx] = ibooker.book1D("DT_TPG_theta_bx_" + bxn, "DT TPG theta bx " + bxn, 50, -24.5, 24.5);
0205     dttpgthwheel[ibx] =
0206         ibooker.book1D("DT_TPG_theta_wheel_number_" + bxn, "DT TPG theta wheel number " + bxn, 5, -2.5, 2.5);
0207     dttpgthsector[ibx] =
0208         ibooker.book1D("DT_TPG_theta_sector_number_" + bxn, "DT TPG theta sector number " + bxn, 12, -0.5, 11.5);
0209     dttpgthstation[ibx] =
0210         ibooker.book1D("DT_TPG_theta_station_number_" + bxn, "DT TPG theta station number " + bxn, 5, -0.5, 4.5);
0211     dttpgththeta[ibx] = ibooker.book1D("DT_TPG_theta_" + bxn, "DT TPG theta " + bxn, 20, -0.5, 19.5);
0212     dttpgthquality[ibx] = ibooker.book1D("DT_TPG_theta_quality_" + bxn, "DT TPG theta quality " + bxn, 8, -0.5, 7.5);
0213     dttpgthmapbx[ibx] = ibooker.book2D(
0214         "DT_TPG_theta_map_bx_" + bxn, "Map of triggers per station (BX=" + bxn + ")", 15, 1, 16, 12, 0, 12);
0215     setMapThLabel(dttpgthmapbx[ibx]);
0216 
0217     // Phi output
0218     dttf_p_phi[ibx] = ibooker.book1D("dttf_p_phi_" + bxn, "dttf phi output #phi " + bxn, 256, -0.5, 255.5);
0219     dttf_p_qual[ibx] = ibooker.book1D("dttf_p_qual_" + bxn, "dttf phi output qual " + bxn, 8, -0.5, 7.5);
0220     dttf_p_q[ibx] = ibooker.book1D("dttf_p_q_" + bxn, "dttf phi output q " + bxn, 2, -0.5, 1.5);
0221     dttf_p_pt[ibx] = ibooker.book1D("dttf_p_pt_" + bxn, "dttf phi output p_{t} " + bxn, 32, -0.5, 31.5);
0222   }
0223 
0224   dttpgphmap = ibooker.book2D("DT_TPG_phi_map", "Map of triggers per station", 20, 1, 21, 12, 0, 12);
0225   dttpgphmapcorr =
0226       ibooker.book2D("DT_TPG_phi_map_corr", "Map of correlated triggers per station", 20, 1, 21, 12, 0, 12);
0227   dttpgphmap2nd = ibooker.book2D("DT_TPG_phi_map_2nd", "Map of second tracks per station", 20, 1, 21, 12, 0, 12);
0228   dttpgphbestmap = ibooker.book2D("DT_TPG_phi_best_map", "Map of best triggers per station", 20, 1, 21, 12, 0, 12);
0229   dttpgphbestmapcorr =
0230       ibooker.book2D("DT_TPG_phi_best_map_corr", "Map of correlated best triggers per station", 20, 1, 21, 12, 0, 12);
0231   setMapPhLabel(dttpgphmap);
0232   setMapPhLabel(dttpgphmapcorr);
0233   setMapPhLabel(dttpgphmap2nd);
0234   setMapPhLabel(dttpgphbestmap);
0235   setMapPhLabel(dttpgphbestmapcorr);
0236 
0237   dttpgthmap = ibooker.book2D("DT_TPG_theta_map", "Map of triggers per station", 15, 1, 16, 12, 0, 12);
0238   dttpgthmaph = ibooker.book2D("DT_TPG_theta_map_h", "Map of H quality triggers per station", 15, 1, 16, 12, 0, 12);
0239   dttpgthbestmap = ibooker.book2D("DT_TPG_theta_best_map", "Map of besttriggers per station", 15, 1, 16, 12, 0, 12);
0240   dttpgthbestmaph =
0241       ibooker.book2D("DT_TPG_theta_best_map_h", "Map of H quality best triggers per station", 15, 1, 16, 12, 0, 12);
0242   setMapThLabel(dttpgthmap);
0243   setMapThLabel(dttpgthmaph);
0244   setMapThLabel(dttpgthbestmap);
0245   setMapThLabel(dttpgthbestmaph);
0246 }
0247 
0248 void L1TDTTPG::analyze(const Event &e, const EventSetup &c) {
0249   nev_++;
0250   if (verbose_)
0251     cout << "L1TDTTPG: analyze...." << endl;
0252 
0253   edm::Handle<L1MuDTChambPhContainer> myL1MuDTChambPhContainer;
0254   e.getByToken(dttpgSourcePhContainer_token_, myL1MuDTChambPhContainer);
0255 
0256   if (!myL1MuDTChambPhContainer.isValid()) {
0257     edm::LogInfo("DataNotFound") << "can't find L1MuDTChambPhContainer with label " << dttpgSource_.label();
0258     return;
0259   }
0260   L1MuDTChambPhContainer::Phi_Container const *myPhContainer = myL1MuDTChambPhContainer->getContainer();
0261 
0262   edm::Handle<L1MuDTChambThContainer> myL1MuDTChambThContainer;
0263   e.getByToken(dttpgSourceThContainer_token_, myL1MuDTChambThContainer);
0264 
0265   if (!myL1MuDTChambThContainer.isValid()) {
0266     edm::LogInfo("DataNotFound") << "can't find L1MuDTChambThContainer with label " << dttpgSource_.label();
0267     edm::LogInfo("DataNotFound") << "if this fails try to add DATA to the process name.";
0268 
0269     return;
0270   }
0271   L1MuDTChambThContainer::The_Container const *myThContainer = myL1MuDTChambThContainer->getContainer();
0272 
0273   int ndttpgphtrack = 0;
0274   int ndttpgthtrack = 0;
0275   int NumberOfSegmentsPhi[3] = {0, 0, 0};
0276 
0277   for (L1MuDTChambPhContainer::Phi_Container::const_iterator DTPhDigiItr = myPhContainer->begin();
0278        DTPhDigiItr != myPhContainer->end();
0279        ++DTPhDigiItr) {
0280     int bx = DTPhDigiItr->bxNum() - DTPhDigiItr->Ts2Tag();
0281     if (bx == -1)
0282       NumberOfSegmentsPhi[0]++;
0283     if (bx == 0)
0284       NumberOfSegmentsPhi[1]++;
0285     if (bx == 1)
0286       NumberOfSegmentsPhi[2]++;
0287   }
0288   /*Fill Histos for Segment counter for each bx separately */
0289 
0290   for (int k = 0; k < 3; k++) {
0291     dttpgphbx[k + 2]->Fill(NumberOfSegmentsPhi[k]);
0292   }
0293   int bxCounterDttfPhi = 0;  // = no. of BX's with non-zero data
0294   for (int k = 0; k < 3; k++) {
0295     if (NumberOfSegmentsPhi[k] > 0)
0296       bxCounterDttfPhi++;
0297   }
0298 
0299   /* the BX "code" */
0300 
0301   int bxCodePhi = 0;
0302   if (bxCounterDttfPhi == 0) {
0303     bxCodePhi = 0;
0304   } else if (bxCounterDttfPhi == 1) {
0305     for (int k = 0; k < 3; k++) {
0306       if (NumberOfSegmentsPhi[k] > 0)
0307         bxCodePhi = k + 2;
0308     }
0309   } else if (bxCounterDttfPhi == 2) {
0310     for (int k = 0; k < 3; k++) {
0311       if (NumberOfSegmentsPhi[k] == 0)
0312         bxCodePhi = 8 - k;
0313     }
0314   } else if (bxCounterDttfPhi == 3) {
0315     bxCodePhi = 10;
0316   }
0317 
0318   //The bx analyzer histo
0319   dttpgphbx[0]->Fill(bxCodePhi);
0320 
0321   const L1MuDTChambPhDigi *bestPhQualMap[5][12][4];
0322   memset(bestPhQualMap, 0, 240 * sizeof(L1MuDTChambPhDigi *));
0323 
0324   for (L1MuDTChambPhContainer::Phi_Container::const_iterator DTPhDigiItr = myPhContainer->begin();
0325        DTPhDigiItr != myPhContainer->end();
0326        ++DTPhDigiItr) {
0327     ndttpgphtrack++;
0328 
0329     int bxindex = DTPhDigiItr->bxNum() - DTPhDigiItr->Ts2Tag() + 1;
0330 
0331     dttpgphwheel[bxindex]->Fill(DTPhDigiItr->whNum());
0332     if (verbose_) {
0333       cout << "DTTPG phi wheel number " << DTPhDigiItr->whNum() << endl;
0334     }
0335     dttpgphstation[bxindex]->Fill(DTPhDigiItr->stNum());
0336     if (verbose_) {
0337       cout << "DTTPG phi station number " << DTPhDigiItr->stNum() << endl;
0338     }
0339     dttpgphsector[bxindex]->Fill(DTPhDigiItr->scNum());
0340     if (verbose_) {
0341       cout << "DTTPG phi sector number " << DTPhDigiItr->scNum() << endl;
0342     }
0343     dttpgphquality[bxindex]->Fill(DTPhDigiItr->code());
0344     if (verbose_) {
0345       cout << "DTTPG phi quality " << DTPhDigiItr->code() << endl;
0346     }
0347     dttpgphts2tag[bxindex]->Fill(DTPhDigiItr->Ts2Tag());
0348     if (verbose_) {
0349       cout << "DTTPG phi ts2tag " << DTPhDigiItr->Ts2Tag() << endl;
0350     }
0351     int ypos = DTPhDigiItr->scNum();
0352     int xpos = DTPhDigiItr->stNum() + 4 * (DTPhDigiItr->whNum() + 2);
0353     dttpgphmap->Fill(xpos, ypos);
0354     if (DTPhDigiItr->Ts2Tag())
0355       dttpgphmap2nd->Fill(xpos, ypos);
0356     dttpgphmapbx[bxindex]->Fill(xpos, ypos);
0357     if (DTPhDigiItr->code() > 3)
0358       dttpgphmapcorr->Fill(xpos, ypos);
0359 
0360     if (bestPhQualMap[DTPhDigiItr->whNum() + 2][DTPhDigiItr->scNum()][DTPhDigiItr->stNum() - 1] == nullptr ||
0361         bestPhQualMap[DTPhDigiItr->whNum() + 2][DTPhDigiItr->scNum()][DTPhDigiItr->stNum() - 1]->code() <
0362             DTPhDigiItr->code()) {
0363       bestPhQualMap[DTPhDigiItr->whNum() + 2][DTPhDigiItr->scNum()][DTPhDigiItr->stNum() - 1] = &(*DTPhDigiItr);
0364     }
0365   }
0366 
0367   for (int iwh = 0; iwh < 5; iwh++) {
0368     for (int isec = 0; isec < 12; isec++) {
0369       for (int ist = 0; ist < 4; ist++) {
0370         if (bestPhQualMap[iwh][isec][ist]) {
0371           int xpos = iwh * 4 + ist + 1;
0372           dttpgphbestmap->Fill(xpos, isec);
0373           if (bestPhQualMap[iwh][isec][ist]->code() > 3)
0374             dttpgphbestmapcorr->Fill(xpos, isec);
0375         }
0376       }
0377     }
0378   }
0379 
0380   int bestThQualMap[5][12][3];
0381   memset(bestThQualMap, 0, 180 * sizeof(int));
0382   //for( vector<L1MuDTChambThDigi>::const_iterator
0383   for (L1MuDTChambThContainer::The_Container::const_iterator DTThDigiItr = myThContainer->begin();
0384        DTThDigiItr != myThContainer->end();
0385        ++DTThDigiItr) {
0386     ndttpgthtrack++;
0387 
0388     int bxindex = DTThDigiItr->bxNum() + 1;
0389 
0390     dttpgthwheel[bxindex]->Fill(DTThDigiItr->whNum());
0391     if (verbose_) {
0392       cout << "DTTPG theta wheel number " << DTThDigiItr->whNum() << endl;
0393     }
0394     dttpgthstation[bxindex]->Fill(DTThDigiItr->stNum());
0395     if (verbose_) {
0396       cout << "DTTPG theta station number " << DTThDigiItr->stNum() << endl;
0397     }
0398     dttpgthsector[bxindex]->Fill(DTThDigiItr->scNum());
0399     if (verbose_) {
0400       cout << "DTTPG theta sector number " << DTThDigiItr->scNum() << endl;
0401     }
0402     dttpgthbx[bxindex]->Fill(DTThDigiItr->bxNum());
0403     if (verbose_) {
0404       cout << "DTTPG theta bx number " << DTThDigiItr->bxNum() << endl;
0405     }
0406     int thcode[7] = {0, 0, 0, 0, 0, 0, 0};
0407     for (int j = 0; j < 7; j++) {
0408       dttpgththeta[bxindex]->Fill(DTThDigiItr->position(j));
0409       if (verbose_) {
0410         cout << "DTTPG theta position " << DTThDigiItr->position(j) << endl;
0411       }
0412       thcode[j] = DTThDigiItr->code(j);
0413       dttpgthquality[bxindex]->Fill(thcode[j]);
0414       if (verbose_) {
0415         cout << "DTTPG theta quality " << DTThDigiItr->code(j) << endl;
0416       }
0417     }
0418 
0419     int ypos = DTThDigiItr->scNum();
0420     int xpos = DTThDigiItr->stNum() + 4 * (DTThDigiItr->whNum() + 2);
0421     int bestqual = 0;
0422     dttpgthmap->Fill(xpos, ypos);
0423     dttpgthmapbx[bxindex]->Fill(xpos, ypos);
0424     for (int pos = 0; pos < 7; pos++) {
0425       if (thcode[pos] > bestqual)
0426         bestqual = thcode[pos];
0427       if (thcode[pos] == 2)
0428         dttpgthmaph->Fill(xpos, ypos);
0429     }
0430 
0431     if (bestThQualMap[DTThDigiItr->whNum() + 2][DTThDigiItr->scNum()][DTThDigiItr->stNum() - 1] < bestqual) {
0432       bestThQualMap[DTThDigiItr->whNum() + 2][DTThDigiItr->scNum()][DTThDigiItr->stNum() - 1] = bestqual;
0433     }
0434   }
0435 
0436   for (int iwh = 0; iwh < 5; iwh++) {
0437     for (int isec = 0; isec < 12; isec++) {
0438       for (int ist = 0; ist < 3; ist++) {
0439         if (bestThQualMap[iwh][isec][ist]) {
0440           int xpos = iwh * 4 + ist + 1;
0441           dttpgthbestmap->Fill(xpos, isec);
0442           if (bestThQualMap[iwh][isec][ist] == 2)
0443             dttpgthbestmaph->Fill(xpos, isec);
0444         }
0445       }
0446     }
0447   }
0448 
0449   dttpgphntrack->Fill(ndttpgphtrack);
0450   if (verbose_) {
0451     cout << "DTTPG phi ntrack " << ndttpgphtrack << endl;
0452   }
0453   dttpgthntrack->Fill(ndttpgthtrack);
0454   if (verbose_) {
0455     cout << "DTTPG theta ntrack " << ndttpgthtrack << endl;
0456   }
0457 
0458   edm::Handle<L1MuDTTrackContainer> myL1MuDTTrackContainer;
0459   e.getByToken(trToken_, myL1MuDTTrackContainer);
0460 
0461   if (!myL1MuDTTrackContainer.isValid()) {
0462     edm::LogInfo("DataNotFound") << "can't find L1MuDTTrackContainer with label " << dttpgSource_.label();
0463     return;
0464   }
0465 
0466   L1MuDTTrackContainer::TrackContainer const *t = myL1MuDTTrackContainer->getContainer();
0467 
0468   int NumberOfSegmentsOut[3] = {0, 0, 0};
0469   for (L1MuDTTrackContainer::TrackContainer::const_iterator i = t->begin(); i != t->end(); ++i) {
0470     if (i->bx() == -1)
0471       NumberOfSegmentsOut[0]++;
0472     if (i->bx() == 0)
0473       NumberOfSegmentsOut[1]++;
0474     if (i->bx() == 1)
0475       NumberOfSegmentsOut[2]++;
0476   }
0477 
0478   /*Fill Histos for Segment counter*/
0479   for (int k = 0; k < 3; k++) {
0480     dttpgphbx[k + 5]->Fill(NumberOfSegmentsOut[k]);
0481   }
0482 
0483   /*Bunch assigments*/
0484 
0485   int bxCounterDttfOut = 0;
0486   for (int k = 0; k < 3; k++) {
0487     if (NumberOfSegmentsOut[k] > 0)
0488       bxCounterDttfOut++;
0489   }
0490 
0491   int bxCodeOut = 0;
0492   if (bxCounterDttfOut == 0) {
0493     bxCodeOut = 0;
0494   } else if (bxCounterDttfOut == 1) {
0495     for (int k = 0; k < 3; k++) {
0496       if (NumberOfSegmentsOut[k] > 0)
0497         bxCodeOut = k + 2;
0498     }
0499   } else if (bxCounterDttfOut == 2) {
0500     for (int k = 0; k < 3; k++) {
0501       if (NumberOfSegmentsOut[k] == 0)
0502         bxCodeOut = 8 - k;
0503     }
0504   } else if (bxCounterDttfOut == 3) {
0505     bxCodeOut = 10;
0506   }
0507 
0508   //The bx analyzer histo
0509   dttpgphbx[1]->Fill(bxCodeOut);
0510 
0511   /*End Dttf Output Bunch analysis*/
0512 
0513   // the 2-DIM histo with phi.input vs. output
0514   dttpgphbxcomp->Fill(bxCodePhi, bxCodeOut);
0515 
0516   for (L1MuDTTrackContainer::TrackContainer::const_iterator i = t->begin(); i != t->end(); ++i) {
0517     if (verbose_) {
0518       std::cout << "bx = " << i->bx() << std::endl;
0519       std::cout << "quality (packed) = " << i->quality_packed() << std::endl;
0520       std::cout << "pt      (packed) = " << i->pt_packed() << std::endl;
0521       std::cout << "phi     (packed) = " << i->phi_packed() << std::endl;
0522       std::cout << "charge  (packed) = " << i->charge_packed() << std::endl;
0523     }
0524 
0525     int bxindex = i->bx() + 1;
0526     dttf_p_phi[bxindex]->Fill(i->phi_packed());
0527     dttf_p_qual[bxindex]->Fill(i->quality_packed());
0528     dttf_p_pt[bxindex]->Fill(i->pt_packed());
0529     dttf_p_q[bxindex]->Fill(i->charge_packed());
0530   }
0531 }
0532 
0533 void L1TDTTPG::setMapPhLabel(MonitorElement *me) {
0534   me->setAxisTitle("DTTF Sector", 2);
0535   for (int i = 0; i < 5; i++) {
0536     ostringstream wheel;
0537     wheel << i - 2;
0538     me->setBinLabel(1 + i * 4, "Wheel " + wheel.str(), 1);
0539   }
0540 }
0541 
0542 void L1TDTTPG::setMapThLabel(MonitorElement *me) {
0543   me->setAxisTitle("DTTF Sector", 2);
0544   for (int i = 0; i < 5; i++) {
0545     ostringstream wheel;
0546     wheel << i - 2;
0547     me->setBinLabel(1 + i * 3, "Wheel " + wheel.str(), 1);
0548   }
0549 }