Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /*
0002  * \file L1TDTTF.cc
0003  *
0004  * \author J. Berryhill
0005  *
0006  *
0007  * Revision 1.27  2010/11/01 11:27:53  gcodispo
0008  * Cleaned up 2nd track sections
0009  *
0010  * Revision 1.26  2010/10/27 13:59:25  gcodispo
0011  * Changed name to 2nd track quality (same convention as for all tracks)
0012  *
0013  * Revision 1.25  2010/10/27 13:37:08  gcodispo
0014  * Changed name to 2nd track quality (same convention as for all tracks)
0015  *
0016  * Revision 1.24  2010/10/27 08:08:52  gcodispo
0017  * Graphic improvements (names, titles, labels...)
0018  *
0019  * Revision 1.23  2010/10/19 12:14:56  gcodispo
0020  * New DTTF DQM version
0021  * - added L1TDTTFClient in order to use proper normalization
0022  * - cleaned up most of the code, removed useless plots
0023  * - reduced overall number of bins from 118325 to 104763 plus saved 1920 bins from wrongly called L1TDTTPGClient
0024  * - added match with GMT inputremoved useless plots
0025  * - added eta fine fraction plots
0026  * - added quality distribution plots
0027  *
0028  * Revision 1.22  2009/11/19 15:09:18  puigh
0029  * modify beginJob
0030  *
0031  * Revision 1.21  2009/10/12 10:16:42  nuno
0032  * bug fix; letting the package compile again
0033  *
0034  * Revision 1.20  2009/08/03 21:11:22  lorenzo
0035  * added dttf phi and theta
0036  *
0037  * Revision 1.19  2008/07/29 14:18:27  wteo
0038  * updated and added more MEs
0039  *
0040  * Revision 1.15  2008/06/10 18:01:55  lorenzo
0041  * reduced n histos
0042  *
0043  * Revision 1.14  2008/05/09 16:42:27  ameyer
0044  * *** empty log message ***
0045  *
0046  * Revision 1.13  2008/04/30 08:44:21  lorenzo
0047  * new dttf source, not based on gmt record
0048  *
0049  * Revision 1.20  2008/03/20 19:38:25  berryhil
0050  *
0051  *
0052  * organized message logger
0053  *
0054  * Revision 1.19  2008/03/14 20:35:46  berryhil
0055  *
0056  *
0057  * stripped out obsolete parameter settings
0058  *
0059  * rpc tpg restored with correct dn access and dbe handling
0060  *
0061  * Revision 1.18  2008/03/12 17:24:24  berryhil
0062  *
0063  *
0064  * eliminated log files, truncated HCALTPGXana histo output
0065  *
0066  * Revision 1.17  2008/03/10 09:29:52  lorenzo
0067  * added MEs
0068  *
0069  * Revision 1.16  2008/03/01 00:40:00  lat
0070  * DQM core migration.
0071  *
0072  *
0073  * Revision 1.27  2010/11/01 11:27:53  gcodispo
0074  * Cleaned up 2nd track sections
0075  *
0076  * Revision 1.26  2010/10/27 13:59:25  gcodispo
0077  * Changed name to 2nd track quality (same convention as for all tracks)
0078  *
0079  * Revision 1.25  2010/10/27 13:37:08  gcodispo
0080  * Changed name to 2nd track quality (same convention as for all tracks)
0081  *
0082  * Revision 1.24  2010/10/27 08:08:52  gcodispo
0083  * Graphic improvements (names, titles, labels...)
0084  *
0085  * Revision 1.23  2010/10/19 12:14:56  gcodispo
0086  * New DTTF DQM version
0087  * - added L1TDTTFClient in order to use proper normalization
0088  * - cleaned up most of the code, removed useless plots
0089  * - reduced overall number of bins from 118325 to 104763 plus saved 1920 bins from wrongly called L1TDTTPGClient
0090  * - added match with GMT inputremoved useless plots
0091  * - added eta fine fraction plots
0092  * - added quality distribution plots
0093  *
0094  * Revision 1.22  2009/11/19 15:09:18  puigh
0095  * modify beginJob
0096  *
0097  * Revision 1.21  2009/10/12 10:16:42  nuno
0098  * bug fix; letting the package compile again
0099  *
0100  * Revision 1.20  2009/08/03 21:11:22  lorenzo
0101  * added dttf phi and theta
0102  *
0103  * Revision 1.19  2008/07/29 14:18:27  wteo
0104  * updated and added more MEs
0105  *
0106  * Revision 1.15  2008/06/10 18:01:55  lorenzo
0107  * reduced n histos
0108  *
0109  * Revision 1.14  2008/05/09 16:42:27  ameyer
0110  * *** empty log message ***
0111  *
0112  * Revision 1.13  2008/04/30 08:44:21  lorenzo
0113  * new dttf source, not based on gmt record
0114  *
0115  * Revision 1.20  2008/03/20 19:38:25  berryhil
0116  *
0117  *
0118  * organized message logger
0119  *
0120  * Revision 1.19  2008/03/14 20:35:46  berryhil
0121  *
0122  *
0123  * stripped out obsolete parameter settings
0124  *
0125  * rpc tpg restored with correct dn access and dbe handling
0126  *
0127  * Revision 1.18  2008/03/12 17:24:24  berryhil
0128  *
0129  *
0130  * eliminated log files, truncated HCALTPGXana histo output
0131  *
0132  * Revision 1.17  2008/03/10 09:29:52  lorenzo
0133  * added MEs
0134  *
0135  * Revision 1.15  2008/01/22 18:56:01  muzaffar
0136  * include cleanup. Only for cc/cpp files
0137  *
0138  * Revision 1.14  2007/12/21 17:41:20  berryhil
0139  *
0140  *
0141  * try/catch removal
0142  *
0143  * Revision 1.13  2007/11/19 15:08:22  lorenzo
0144  * changed top folder name
0145  *
0146  * Revision 1.12  2007/08/15 18:56:25  berryhil
0147  *
0148  *
0149  * split histograms by bx; add Maiken's bx classifier plots
0150  *
0151  * Revision 1.11  2007/07/26 09:37:09  berryhil
0152  *
0153  *
0154  * set verbose false for all modules
0155  * set verbose fix for DTTPG tracks
0156  *
0157  * Revision 1.10  2007/07/25 09:03:58  berryhil
0158  *
0159  *
0160  * conform to DTTFFEDReader input tag.... for now
0161  *
0162  * Revision 1.9  2007/07/12 16:06:18  wittich
0163  * add simple phi output track histograms.
0164  * note that the label of this class is different than others
0165  * from the DTFFReader creates.
0166  *
0167  */
0168 
0169 #include "DQM/L1TMonitor/interface/L1TDTTF.h"
0170 
0171 /// base services
0172 #include "FWCore/ServiceRegistry/interface/Service.h"
0173 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0174 #include "DQMServices/Core/interface/DQMStore.h"
0175 
0176 /// DT input
0177 // #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h"
0178 // #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhDigi.h"
0179 // #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h"
0180 // #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThDigi.h"
0181 
0182 /// output tracks
0183 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTTrackContainer.h"
0184 
0185 /// GMT
0186 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
0187 
0188 /// GlobalMuon try
0189 #include "DataFormats/MuonReco/interface/Muon.h"
0190 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0191 
0192 //--------------------------------------------------------
0193 L1TDTTF::L1TDTTF(const edm::ParameterSet& ps)
0194     : dttpgSource_(ps.getParameter<edm::InputTag>("dttpgSource")),
0195       gmtSource_(ps.getParameter<edm::InputTag>("gmtSource")),
0196       muonCollectionLabel_(ps.getParameter<edm::InputTag>("MuonCollection")),
0197       l1tsubsystemfolder_(ps.getUntrackedParameter<std::string>("l1tSystemFolder", "L1T/L1TDTTF")),
0198       online_(ps.getUntrackedParameter<bool>("online", true)),
0199       verbose_(ps.getUntrackedParameter<bool>("verbose", false))
0200 
0201 {
0202   std::string trstring = dttpgSource_.label() + ":DATA:" + dttpgSource_.process();
0203   trackInputTag_ = edm::InputTag(trstring);
0204 
0205   /// Verbose?
0206   if (verbose_)
0207     edm::LogInfo("L1TDTTF: constructor") << "Verbose enabled";
0208 
0209   /// Use ROOT Output?
0210   if (ps.getUntrackedParameter<bool>("disableROOToutput", false)) {
0211     outputFile_ = "";
0212 
0213   } else {
0214     outputFile_ = ps.getUntrackedParameter<std::string>("outputFile", "");
0215     if (!outputFile_.empty()) {
0216       edm::LogInfo("L1TDTTF: constructor") << "L1T Monitoring histograms will be saved to " << outputFile_;
0217     }
0218   }
0219 
0220   //set Token(-s)
0221   trackInputToken_ = consumes<L1MuDTTrackContainer>(trackInputTag_);
0222   muonCollectionToken_ = consumes<reco::MuonCollection>(ps.getParameter<edm::InputTag>("MuonCollection"));
0223   gmtSourceToken_ = consumes<L1MuGMTReadoutCollection>(ps.getParameter<edm::InputTag>("gmtSource"));
0224 }
0225 
0226 //--------------------------------------------------------
0227 L1TDTTF::~L1TDTTF() {
0228   /// Nothing to destroy
0229 }
0230 
0231 //------------------------------------------------------
0232 void L1TDTTF::dqmBeginRun(const edm::Run& r, const edm::EventSetup& c) {
0233   //empty
0234 }
0235 
0236 //--------------------------------------------------------
0237 void L1TDTTF::bookHistograms(DQMStore::IBooker& ibooker, const edm::Run&, const edm::EventSetup&) {
0238   /// testing purposes
0239   nev_ = 0;
0240   nev_dttf_ = 0;
0241   nev_dttf_track2_ = 0;
0242 
0243   // get hold of back-end interface
0244 
0245   std::string dttf_trk_folder = l1tsubsystemfolder_;
0246 
0247   char hname[100];   /// histo name
0248   char htitle[100];  /// histo title
0249 
0250   ///////////// OPTIMIZE
0251   float start = 0;
0252   float stop = 0;
0253   int nbins = 0;
0254   ///////////// OPTIMIZE
0255 
0256   /// DTTF Output (6 wheels)
0257   ibooker.setCurrentFolder(dttf_trk_folder);
0258 
0259   std::string wheelpath[6] = {
0260       "/02-WHEEL_N2", "/03-WHEEL_N1", "/04-WHEEL_N0", "/05-WHEEL_P0", "/06-WHEEL_P1", "/07-WHEEL_P2"};
0261 
0262   char c_whn[6][3] = {"N2", "N1", "N0", "P0", "P1", "P2"};
0263   // char bxn [3][3] = { "N1", "0", "P1" };
0264   // char bxn[3][25] = {"/BX_NONZERO_ONLY/BX_N1", "", "/BX_NONZERO_ONLY/BX_P1"};
0265 
0266   for (int iwh = 0; iwh < 6; ++iwh) {
0267     bookEta(iwh, nbins, start, stop);  ///******************
0268 
0269     ////////////////////////////
0270     /// Per wheel summaries
0271     ////////////////////////////
0272     std::string dttf_trk_folder_wheel = dttf_trk_folder + wheelpath[iwh];
0273     ibooker.setCurrentFolder(dttf_trk_folder_wheel);
0274 
0275     /// number of  tracks per event per wheel
0276     sprintf(hname, "dttf_01_nTracksPerEvent_wh%s", c_whn[iwh]);
0277     sprintf(htitle, "Wheel %s - Number Tracks Per Event", c_whn[iwh]);
0278     dttf_nTracksPerEvent_wheel[iwh] = ibooker.book1D(hname, htitle, 10, 0.5, 10.5);
0279     dttf_nTracksPerEvent_wheel[iwh]->setAxisTitle("# tracks/event", 1);
0280 
0281     /// phi vs etafine - for each wheel
0282     sprintf(hname, "dttf_07_phi_vs_etaFine_wh%s", c_whn[iwh]);
0283     sprintf(htitle, "Wheel %s -   #eta-#phi DTTF Tracks occupancy (fine #eta only, unpacked values)", c_whn[iwh]);
0284     dttf_phi_eta_fine_wheel[iwh] = ibooker.book2D(hname, htitle, nbins, start - 0.5, stop - 0.5, 144, -6, 138);
0285     // 144, -0.5, 143.5);
0286 
0287     dttf_phi_eta_fine_wheel[iwh]->setAxisTitle("#eta", 1);
0288     dttf_phi_eta_fine_wheel[iwh]->setAxisTitle("#phi", 2);
0289 
0290     /// phi vs etacoarse - for each wheel
0291     sprintf(hname, "dttf_08_phi_vs_etaCoarse_wh%s", c_whn[iwh]);
0292     sprintf(htitle, "Wheel %s -   #eta-#phi DTTF Tracks occupancy (coarse #eta only, unpacked values)", c_whn[iwh]);
0293     dttf_phi_eta_coarse_wheel[iwh] = ibooker.book2D(hname, htitle, nbins, start - 0.5, stop - 0.5, 144, -6, 138);
0294     // 144, -0.5, 143.5);
0295     dttf_phi_eta_coarse_wheel[iwh]->setAxisTitle("#eta", 1);
0296     dttf_phi_eta_coarse_wheel[iwh]->setAxisTitle("#phi", 2);
0297 
0298     /////////////////////////////////////////////
0299     /// Per wheel summaries : 2ND_TRACK_ONLY
0300     std::string dttf_trk_folder_wheel_2ndtrack = dttf_trk_folder_wheel + "/2ND_TRACK_ONLY";
0301     ibooker.setCurrentFolder(dttf_trk_folder_wheel_2ndtrack);
0302 
0303     /// DTTF Tracks Quality distribution
0304     sprintf(hname, "dttf_04_quality_wh%s_2ndTrack", c_whn[iwh]);
0305     sprintf(htitle, "Wheel %s - 2nd Tracks Quality distribution", c_whn[iwh]);
0306     dttf_quality_wheel_2ndTrack[iwh] = ibooker.book1D(hname, htitle, 7, 1, 8);
0307     setQualLabel(dttf_quality_wheel_2ndTrack[iwh], 1);
0308 
0309     /// quality per wheel  2ND TRACK
0310     sprintf(hname, "dttf_05_quality_summary_wh%s_2ndTrack", c_whn[iwh]);
0311     sprintf(htitle, "Wheel %s - 2nd Tracks - Quality", c_whn[iwh]);
0312     dttf_quality_summary_wheel_2ndTrack[iwh] = ibooker.book2D(hname, htitle, 12, 1, 13, 7, 1, 8);
0313     dttf_quality_summary_wheel_2ndTrack[iwh]->setAxisTitle("Sector", 1);
0314     setQualLabel(dttf_quality_summary_wheel_2ndTrack[iwh], 2);
0315     // dttf_quality_summary_wheel_2ndTrack[iwh]->setAxisTitle("Quality", 2);
0316 
0317     /// phi vs eta - for each wheel 2ND TRACK
0318     sprintf(hname, "dttf_06_phi_vs_eta_wh%s_2ndTrack", c_whn[iwh]);
0319     sprintf(htitle, "Wheel %s -   #eta-#phi Distribution of DTTF 2nd Tracks", c_whn[iwh]);
0320 
0321     dttf_phi_eta_wheel_2ndTrack[iwh] = ibooker.book2D(hname, htitle, nbins, start - 0.5, stop - 0.5, 144, -6, 138);
0322     // 144, -0.5, 143.5);
0323     dttf_phi_eta_wheel_2ndTrack[iwh]->setAxisTitle("#eta", 1);
0324     dttf_phi_eta_wheel_2ndTrack[iwh]->setAxisTitle("#phi", 2);
0325 
0326     /// DTTF Tracks #eta distribution (Packed values)
0327     sprintf(hname, "dttf_07_eta_wh%s_2ndTrack", c_whn[iwh]);
0328     sprintf(htitle, "Wheel %s - DTTF 2nd Tracks #eta distribution (Packed values)", c_whn[iwh]);
0329     dttf_eta_wheel_2ndTrack[iwh] = ibooker.book1D(hname, htitle, 64, -0.5, 63.5);
0330     dttf_eta_wheel_2ndTrack[iwh]->setAxisTitle("#eta", 1);
0331 
0332     /// DTTF Tracks Phi distribution (Packed values)
0333     sprintf(hname, "dttf_08_phi_wh%s_2ndTrack", c_whn[iwh]);
0334     sprintf(htitle, "Wheel %s - DTTF 2nd Tracks Phi distribution (Packed values)", c_whn[iwh]);
0335     dttf_phi_wheel_2ndTrack[iwh] = ibooker.book1D(hname, htitle, 144, -6, 138.);
0336     dttf_phi_wheel_2ndTrack[iwh]->setAxisTitle("#phi", 1);
0337 
0338     /// DTTF Tracks p_{T} distribution (Packed values)
0339     sprintf(hname, "dttf_09_pt_wh%s_2ndTrack", c_whn[iwh]);
0340     sprintf(htitle, "Wheel %s - DTTF 2nd Tracks p_{T} distribution (Packed values)", c_whn[iwh]);
0341     dttf_pt_wheel_2ndTrack[iwh] = ibooker.book1D(hname, htitle, 32, -0.5, 31.5);
0342     dttf_pt_wheel_2ndTrack[iwh]->setAxisTitle("p_{T}", 1);
0343 
0344     /// DTTF Tracks Charge distribution
0345     sprintf(hname, "dttf_10_charge_wh%s_2ndTrack", c_whn[iwh]);
0346     sprintf(htitle, "Wheel %s - DTTF 2nd Tracks Charge distribution", c_whn[iwh]);
0347     dttf_q_wheel_2ndTrack[iwh] = ibooker.book1D(hname, htitle, 2, -0.5, 1.5);
0348     dttf_q_wheel_2ndTrack[iwh]->setAxisTitle("Charge", 1);
0349 
0350     ///////////////////////////////////////////////////////
0351     /// Go in detailed subfolders
0352     ///////////////////////////////////////////////////////
0353 
0354     /// number of tracks per event folder
0355     std::string dttf_trk_folder_nTracksPerEvent = dttf_trk_folder_wheel + "/TracksPerEvent";
0356     ibooker.setCurrentFolder(dttf_trk_folder_nTracksPerEvent);
0357 
0358     for (int ise = 0; ise < 12; ++ise) {
0359       sprintf(hname, "dttf_nTracksPerEvent_wh%s_se%d", c_whn[iwh], ise + 1);
0360       sprintf(htitle, "Wheel %s Sector %d - Number of Tracks Per Event", c_whn[iwh], ise + 1);
0361       dttf_nTracksPerEv[iwh][ise] = ibooker.book1D(hname, htitle, 2, 0.5, 2.5);
0362       dttf_nTracksPerEv[iwh][ise]->setAxisTitle("# tracks/event", 1);
0363     }
0364 
0365     /// BX_SECTORS for each wheel
0366     std::string dttf_trk_folder_wh_bxsec_all = dttf_trk_folder_wheel + "/BX_BySector";
0367     ibooker.setCurrentFolder(dttf_trk_folder_wh_bxsec_all);
0368 
0369     for (int ise = 0; ise < 12; ++ise) {
0370       sprintf(hname, "dttf_bx_wh%s_se%d", c_whn[iwh], ise + 1);
0371       sprintf(htitle, "Wheel %s Sector %d - BX Distribution", c_whn[iwh], ise + 1);
0372       dttf_bx[iwh][ise] = ibooker.book1D(hname, htitle, 3, -1.5, 1.5);
0373       dttf_bx[iwh][ise]->setAxisTitle("BX", 1);
0374     }
0375 
0376     std::string dttf_trk_folder_wh_bxsec_trk2 = dttf_trk_folder_wheel + "/BX_BySector/2ND_TRACK_ONLY";
0377     ibooker.setCurrentFolder(dttf_trk_folder_wh_bxsec_trk2);
0378 
0379     for (int ise = 0; ise < 12; ++ise) {
0380       sprintf(hname, "dttf_bx_2ndTrack_wh%s_se%d", c_whn[iwh], ise + 1);
0381       sprintf(htitle, "Wheel %s Sector %d - BX 2nd Tracks only", c_whn[iwh], ise + 1);
0382       dttf_bx_2ndTrack[iwh][ise] = ibooker.book1D(hname, htitle, 3, -1.5, 1.5);
0383       dttf_bx_2ndTrack[iwh][ise]->setAxisTitle("BX", 1);
0384     }
0385 
0386     /// CHARGE folder
0387     std::string dttf_trk_folder_charge = dttf_trk_folder_wheel + "/Charge";
0388     ibooker.setCurrentFolder(dttf_trk_folder_charge);
0389 
0390     for (int ise = 0; ise < 12; ++ise) {
0391       sprintf(hname, "dttf_charge_wh%s_se%d", c_whn[iwh], ise + 1);
0392       sprintf(htitle, "Wheel %s Sector %d - Packed Charge", c_whn[iwh], ise + 1);
0393       dttf_q[iwh][ise] = ibooker.book1D(hname, htitle, 2, -0.5, 1.5);
0394       dttf_q[iwh][ise]->setAxisTitle("Charge", 1);
0395     }
0396 
0397     /// PT folder
0398     std::string dttf_trk_folder_pt = dttf_trk_folder_wheel + "/PT";
0399     ibooker.setCurrentFolder(dttf_trk_folder_pt);
0400 
0401     for (int ise = 0; ise < 12; ++ise) {
0402       sprintf(hname, "dttf_pt_wh%s_se%d", c_whn[iwh], ise + 1);
0403       sprintf(htitle, "Wheel %s Sector %d - Packed p_{T}", c_whn[iwh], ise + 1);
0404       dttf_pt[iwh][ise] = ibooker.book1D(hname, htitle, 32, -0.5, 31.5);
0405       dttf_pt[iwh][ise]->setAxisTitle("p_{T}", 1);
0406     }
0407 
0408     /// PHI folder
0409     std::string dttf_trk_folder_phi = dttf_trk_folder_wheel + "/Phi";
0410     ibooker.setCurrentFolder(dttf_trk_folder_phi);
0411 
0412     for (int ise = 0; ise < 12; ++ise) {
0413       sprintf(hname, "dttf_phi_wh%s_se%d", c_whn[iwh], ise + 1);
0414       sprintf(htitle, "Wheel %s Sector %d - Packed Phi", c_whn[iwh], ise + 1);
0415       dttf_phi[iwh][ise] = ibooker.book1D(hname, htitle, 144, -6, 138);
0416       dttf_phi[iwh][ise]->setAxisTitle("#phi", 1);
0417       //dttf_phi[iwh][ise] = dbe_->book1D(title,title, 32,-16.5, 15.5);
0418     }
0419 
0420     /// QUALITY folder
0421     std::string dttf_trk_folder_quality = dttf_trk_folder_wheel + "/Quality";
0422     ibooker.setCurrentFolder(dttf_trk_folder_quality);
0423 
0424     for (int ise = 0; ise < 12; ++ise) {
0425       sprintf(hname, "dttf_qual_wh%s_se%d", c_whn[iwh], ise + 1);
0426       sprintf(htitle, "Wheel %s Sector %d - Packed Quality", c_whn[iwh], ise + 1);
0427       dttf_qual[iwh][ise] = ibooker.book1D(hname, htitle, 7, 1, 8);
0428       dttf_qual[iwh][ise]->setAxisTitle("Quality", 1);
0429       setQualLabel(dttf_qual[iwh][ise], 1);
0430     }
0431 
0432     /// ETA folder
0433     std::string dttf_trk_folder_eta = dttf_trk_folder_wheel + "/Eta";
0434     ibooker.setCurrentFolder(dttf_trk_folder_eta);
0435 
0436     for (int ise = 0; ise < 12; ++ise) {
0437       sprintf(hname, "dttf_eta_wh%s_se%d", c_whn[iwh], ise + 1);
0438       sprintf(htitle, "Wheel %s Sector %d - Packed #eta", c_whn[iwh], ise + 1);
0439       dttf_eta[iwh][ise] = ibooker.book1D(hname, htitle, 64, -0.5, 63.5);
0440       dttf_eta[iwh][ise]->setAxisTitle("#eta", 1);
0441     }
0442 
0443     /// ETA folder
0444     dttf_trk_folder_eta = dttf_trk_folder_wheel + "/EtaFineFraction";
0445     ibooker.setCurrentFolder(dttf_trk_folder_eta);
0446 
0447     for (int ise = 0; ise < 12; ++ise) {
0448       sprintf(hname, "dttf_etaFine_fraction_wh%s_se%d", c_whn[iwh], ise + 1);
0449       sprintf(htitle, "Wheel %s Sector %d - Eta Fine Fraction", c_whn[iwh], ise + 1);
0450       dttf_eta_fine_fraction[iwh][ise] = ibooker.book1D(hname, htitle, 2, 0, 2);
0451       dttf_eta_fine_fraction[iwh][ise]->setAxisTitle("#eta", 1);
0452       dttf_eta_fine_fraction[iwh][ise]->setBinLabel(1, "fine", 1);
0453       dttf_eta_fine_fraction[iwh][ise]->setBinLabel(2, "coarse", 1);
0454     }
0455   }
0456 
0457   ///////////////////////////////////////////////////////
0458   /// integrated values: always packed
0459   ///////////////////////////////////////////////////////
0460   std::string dttf_trk_folder_inclusive = dttf_trk_folder + "/01-INCLUSIVE";
0461   ibooker.setCurrentFolder(dttf_trk_folder_inclusive);
0462 
0463   sprintf(hname, "dttf_01_nTracksPerEvent_integ");
0464   sprintf(htitle, "Number of DTTF Tracks Per Event");
0465   dttf_nTracksPerEvent_integ = ibooker.book1D(hname, htitle, 20, 0.5, 20.5);
0466   dttf_nTracksPerEvent_integ->setAxisTitle("# tracks/event", 1);
0467 
0468   ///////// ?????????
0469   // sprintf(hname, "dttf_10_qual_eta_distr");
0470   // sprintf(htitle, "DTTF Tracks Quality vs Eta Distribution");
0471   // dttf_qual_eta_integ = dbe_->book2D(hname, htitle, 64, 0, 64, 7, 1, 8);
0472   // setQualLabel( dttf_qual_eta_integ, 2);
0473 
0474   /// Only for online: occupancy summary - reset
0475   if (online_) {
0476     sprintf(hname, "dttf_04_tracks_occupancy_by_lumi");
0477     sprintf(htitle, "DTTF Tracks in the last LumiSections");
0478     dttf_spare = ibooker.book2D(hname, htitle, 6, 0, 6, 12, 1, 13);
0479     setWheelLabel(dttf_spare);
0480     dttf_spare->setAxisTitle("Sector", 2);
0481     dttf_spare->getTH2F()->GetXaxis()->SetNdivisions(12);
0482   } else {
0483     sprintf(hname, "dttf_04_global_muons_request");
0484     sprintf(htitle, "Tracks compatible with a Global Muon in the Barrel");
0485     dttf_spare = ibooker.book1D(hname, htitle, 4, -0.5, 3.5);
0486     dttf_spare->setBinLabel(1, "No tracks", 1);
0487     dttf_spare->setBinLabel(2, "No tracks but GM", 1);
0488     dttf_spare->setBinLabel(3, "Tracks wo GM", 1);
0489     dttf_spare->setBinLabel(4, "Tracks w GM", 1);
0490   }
0491 
0492   std::string dttf_trk_folder_integrated_gmt = dttf_trk_folder + "/08-GMT_MATCH";
0493   ibooker.setCurrentFolder(dttf_trk_folder_integrated_gmt);
0494 
0495   sprintf(hname, "dttf_tracks_with_gmt_match");
0496   sprintf(htitle, "DTTF Tracks With a Match in GMT");
0497   dttf_gmt_match = ibooker.book2D(hname, htitle, 6, 0., 6., 12, 1., 13.);
0498   setWheelLabel(dttf_gmt_match);
0499 
0500   sprintf(hname, "dttf_tracks_without_gmt_match");
0501   sprintf(htitle, "DTTF Tracks Without a Match in GMT");
0502   dttf_gmt_missed = ibooker.book2D(hname, htitle, 6, 0., 6., 12, 1., 13.);
0503   setWheelLabel(dttf_gmt_missed);
0504 
0505   sprintf(hname, "dttf_missing_tracks_in_gmt");
0506   sprintf(htitle, "GMT Tracks Without a Corresponding Track in DTTF");
0507   dttf_gmt_ghost = ibooker.book2D(hname, htitle, 5, -2, 3, 12, 1, 13.);
0508 
0509   dttf_gmt_ghost->setBinLabel(1, "N2", 1);
0510   dttf_gmt_ghost->setBinLabel(2, "N1", 1);
0511   dttf_gmt_ghost->setBinLabel(3, "N0/P0", 1);
0512   dttf_gmt_ghost->setBinLabel(4, "P1", 1);
0513   dttf_gmt_ghost->setBinLabel(5, "P2", 1);
0514 
0515   // sprintf(hname, "dttf_eta_phi_missing_tracks_in_gmt");
0516   // sprintf(htitle, "GMT Tracks Without a Corresponding Track in DTTF");
0517   // dttf_gmt_ghost_phys = dbe_->book2D(hname, htitle, 64, 0., 64., 144, 0., 144. );
0518 }
0519 
0520 //--------------------------------------------------------
0521 void L1TDTTF::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) {
0522   if (verbose_)
0523     edm::LogInfo("L1TDTTF::Analyze::start") << "#################### START";
0524 
0525   /// counters
0526   ++nev_;
0527   memset(numTracks, 0, 72 * sizeof(int));
0528 
0529   /// tracks handle
0530   edm::Handle<L1MuDTTrackContainer> myL1MuDTTrackContainer;
0531   try {
0532     event.getByToken(trackInputToken_, myL1MuDTTrackContainer);
0533   } catch (cms::Exception& iException) {
0534     edm::LogError("L1TDTTF::analyze::DataNotFound") << "can't getByToken L1MuDTTrackContainer with label "
0535                                                     << dttpgSource_.label() << ":DATA:" << dttpgSource_.process();
0536     return;
0537   }
0538 
0539   if (!myL1MuDTTrackContainer.isValid()) {
0540     edm::LogError("L1TDTTF::analyze::DataNotFound")
0541         << "can't find L1MuDTTrackContainer with label " << dttpgSource_.label() << ":DATA:" << dttpgSource_.process();
0542     return;
0543   }
0544 
0545   L1MuDTTrackContainer::TrackContainer const* trackContainer = myL1MuDTTrackContainer->getContainer();
0546 
0547   /// dttf counters
0548   if (!trackContainer->empty()) {
0549     ++nev_dttf_;
0550     if (trackContainer->size() > 1)
0551       ++nev_dttf_track2_;
0552   }
0553 
0554   ///////////////////////////
0555   /// selection for offline
0556   //////////////////////////
0557   bool accept = true;
0558   if (!online_) {
0559     try {
0560       edm::Handle<reco::MuonCollection> muons;
0561       event.getByToken(muonCollectionToken_, muons);
0562       accept = false;
0563       if (muons.isValid()) {
0564         for (reco::MuonCollection::const_iterator recoMu = muons->begin(); recoMu != muons->end(); ++recoMu) {
0565           if (fabs(recoMu->eta()) < 1.4) {
0566             if (verbose_) {
0567               edm::LogInfo("L1TDTTFClient::Analyze:GM") << "Found a global muon!";
0568             }
0569             accept = true;
0570             break;
0571           }
0572         }
0573 
0574         /// global muon selection plot
0575         if (!accept) {
0576           dttf_spare->Fill(!trackContainer->empty() ? 1 : 0);
0577 
0578           if (verbose_) {
0579             edm::LogInfo("L1TDTTFClient::Analyze:GM") << "No global muons in this event!";
0580           }
0581 
0582         } else {
0583           dttf_spare->Fill(!trackContainer->empty() ? 2 : 3);
0584         }
0585 
0586       } else {
0587         /// in case of problems accept all
0588         accept = true;
0589         edm::LogWarning("L1TDTTFClient::Analyze:GM")
0590             << "Invalid MuonCollection with label " << muonCollectionLabel_.label();
0591       }
0592 
0593     } catch (cms::Exception& iException) {
0594       /// in case of problems accept all
0595       accept = true;
0596       edm::LogError("DataNotFound") << "Unable to getByToken MuonCollection with label "
0597                                     << muonCollectionLabel_.label();
0598     }
0599   }
0600 
0601   ////////GMT
0602   std::vector<L1MuRegionalCand> gmtBx0DttfCandidates;
0603 
0604   try {
0605     edm::Handle<L1MuGMTReadoutCollection> pCollection;
0606     event.getByToken(gmtSourceToken_, pCollection);
0607 
0608     if (!pCollection.isValid()) {
0609       edm::LogError("DataNotFound") << "can't find L1MuGMTReadoutCollection with label " << gmtSource_.label();
0610     }
0611 
0612     // get GMT readout collection
0613     L1MuGMTReadoutCollection const* gmtrc = pCollection.product();
0614     std::vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
0615 
0616     std::vector<L1MuGMTReadoutRecord>::const_iterator RRItr;
0617 
0618     for (RRItr = gmt_records.begin(); RRItr != gmt_records.end(); ++RRItr) {
0619       std::vector<L1MuRegionalCand> dttfCands = RRItr->getDTBXCands();
0620       std::vector<L1MuRegionalCand>::iterator dttfCand;
0621 
0622       for (dttfCand = dttfCands.begin(); dttfCand != dttfCands.end(); ++dttfCand) {
0623         if (dttfCand->empty())
0624           continue;
0625         /// take only bx=0
0626         if (RRItr->getBxInEvent())
0627           continue;
0628 
0629         //       dttf_gmt_ghost_phys->Fill( dttfCand->eta_packed(),
0630         //               dttfCand->phi_packed() );
0631         gmtBx0DttfCandidates.push_back(*dttfCand);
0632       }
0633     }
0634 
0635   } catch (cms::Exception& iException) {
0636     edm::LogError("DataNotFound") << "Unable to getByToken L1MuGMTReadoutCollection with label " << gmtSource_.label();
0637   }
0638 
0639   // fill MEs if all selections are passed
0640   if (accept)
0641     fillMEs(trackContainer, gmtBx0DttfCandidates);
0642 
0643   /// in Gmt but not in DTTF
0644   std::vector<L1MuRegionalCand>::iterator dttfCand;
0645   for (dttfCand = gmtBx0DttfCandidates.begin(); dttfCand != gmtBx0DttfCandidates.end(); ++dttfCand) {
0646     if (dttfCand->empty())
0647       continue;
0648 
0649     /// in phys values
0650     /// double phi= dttfCand->phiValue();
0651     /// int sector = 1 + (phi + 15)/30; /// in phys values
0652     int phi = dttfCand->phi_packed();
0653     int sector = 1 + (phi + 6) / 12;
0654     if (sector > 12)
0655       sector -= 12;
0656     double eta = dttfCand->etaValue();
0657 
0658     int wheel = -3;
0659     if (eta < -0.74) {
0660       wheel = -2;
0661     } else if (eta < -0.3) {
0662       wheel = -1;
0663 
0664     } else if (eta < 0.3) {
0665       wheel = 0;
0666 
0667     } else if (eta < 0.74) {
0668       wheel = 1;
0669     } else {
0670       wheel = 2;
0671     }
0672 
0673     dttf_gmt_ghost->Fill(wheel, sector);
0674     // dttf_gmt_ghost_phys->Fill( dttfCand->eta_packed(),
0675     //                            dttfCand->phi_packed() );
0676   }
0677 
0678   /// Per event summaries
0679   int numTracksInt = 0;
0680 
0681   for (int w = 0; w < 6; ++w) {
0682     int numTracks_wh = 0;
0683     for (int s = 0; s < 12; ++s) {
0684       dttf_nTracksPerEv[w][s]->Fill(numTracks[w][s]);
0685 
0686       numTracks_wh += numTracks[w][s];
0687     }
0688 
0689     numTracksInt += numTracks_wh;
0690     dttf_nTracksPerEvent_wheel[w]->Fill(numTracks_wh);
0691   }
0692 
0693   dttf_nTracksPerEvent_integ->Fill(numTracksInt);
0694 }
0695 
0696 //--------------------------------------------------------
0697 void L1TDTTF::fillMEs(std::vector<L1MuDTTrackCand> const* trackContainer, std::vector<L1MuRegionalCand>& gmtDttfCands) {
0698   L1MuDTTrackContainer::TrackContainer::const_iterator track = trackContainer->begin();
0699   L1MuDTTrackContainer::TrackContainer::const_iterator trackEnd = trackContainer->end();
0700 
0701   for (; track != trackEnd; ++track) {
0702     if (verbose_) {
0703       edm::LogInfo("L1TDTTF::Analyze") << "bx = " << track->bx();
0704       edm::LogInfo("L1TDTTF::Analyze") << "quality (packed) = " << track->quality_packed();
0705       edm::LogInfo("L1TDTTF::Analyze") << "pt      (packed) = " << track->pt_packed()
0706                                        << "  , pt  (GeV) = " << track->ptValue();
0707       edm::LogInfo("L1TDTTF::Analyze") << "phi     (packed) = " << track->phi_packed()
0708                                        << " , phi (rad) = " << track->phiValue();
0709       edm::LogInfo("L1TDTTF::Analyze") << "charge  (packed) = " << track->charge_packed();
0710     }
0711 
0712     /// Forget  N0 with zero eta value for physical values
0713     if ((track->whNum() == -1) && !track->eta_packed()) {
0714       edm::LogInfo("L1TDTTF::Analyze") << "Skipping N0 with zero eta value";
0715 
0716       continue;
0717     }
0718 
0719     int bxindex = track->bx() + 1;
0720     int se = track->scNum();       /// from 0 to 11
0721     int sector = se + 1;           /// from 1 to 12
0722     int whindex = track->whNum();  /// wh has possible values {-3,-2,-1,1,2,3}
0723 
0724     whindex = (whindex < 0) ? whindex + 3 : whindex + 2;  /// make wh2 go from 0 to 5
0725 
0726     if (whindex < 0 || whindex > 5) {
0727       edm::LogError("L1TDTTF::Analyze::WHEEL_ERROR") << track->whNum() << "(" << whindex << ")";
0728       continue;
0729     }
0730 
0731     if (se < 0 || se > 11) {
0732       edm::LogError("L1TDTTF::Analyze::SECTOR_ERROR") << se;
0733       continue;
0734     }
0735 
0736     /// useful conversions
0737 
0738     /// calculate phi in physical coordinates: keep it int, set labels later
0739     // int phi_local = track->phi_packed();//range: 0 < phi_local < 31
0740     // if ( phi_local > 15 ) phi_local -= 32; //range: -16 < phi_local < 15
0741 
0742     // int phi_global = phi_local + se * 12; //range: -16 < phi_global < 147
0743     // if(phi_global < 0) phi_global += 144; //range: 0 < phi_global < 147
0744     // if(phi_global > 143) phi_global -= 144; //range: 0 < phi_global < 143
0745     // // float phi_phys = phi_global * 2.5 + 1.25;
0746 
0747     /// new attempt
0748     int phi_global = track->phi_packed();
0749     phi_global = (phi_global > 15 ? phi_global - 32 : phi_global) + se * 12;
0750     if (phi_global < -6)
0751       phi_global += 144;  //range: 0 < phi_global < 147
0752     if (phi_global > 137)
0753       phi_global -= 144;  //range: 0 < phi_global < 143
0754 
0755     // int eta_global = track->eta_packed();
0756     // int eta_global = track->eta_packed() - 32;
0757     // dttf_eta[bxindex][whindex][se]->Fill(eta_global);
0758     // float eta_phys = eta_global / 2.4 ;
0759 
0760     ///////////////////////////////////
0761     //// Starting BX distributions
0762     ///////////////////////////////////
0763 
0764     /// Fill per sector bx   WHEEL_%s/dttf_bx_wh%s
0765     dttf_bx[whindex][se]->Fill(track->bx());
0766 
0767     /// Fill per sector 2nd bx
0768     if (track->TrkTag() == 1) {
0769       /// WHEEL_%s/BX_SECTORS/TRACK_2_ONLY/dttf_bx_2ndTrack_wh%s_se%d
0770       dttf_bx_2ndTrack[whindex][se]->Fill(track->bx());
0771     }
0772 
0773     /////////////////////////////////////////
0774     //// use only bx=0 for for othe plots!
0775     /////////////////////////////////////////
0776 
0777     if (bxindex == 1) {
0778       /// COUNTERS global
0779       ++numTracks[whindex][se];
0780 
0781       /// Fill per sector phi:    WHEEL_%s/BX_%d/dttf_phi_wh%s_se%d
0782       dttf_phi[whindex][se]->Fill(phi_global);
0783 
0784       /// Fill per sector quality WHEEL_%s/BX_%d/dttf_qual_wh%s_se%d
0785       dttf_qual[whindex][se]->Fill(track->quality_packed());
0786 
0787       /// Fill per sector pt      WHEEL_%s/BX_%d/dttf_pt_wh%s_se%d
0788       dttf_pt[whindex][se]->Fill(track->pt_packed());
0789 
0790       /// Fill per sector charge  WHEEL_%s/BX_%d/dttf_q_wh%s_se%d
0791       dttf_q[whindex][se]->Fill(track->charge_packed());
0792 
0793       /// Fill per sector eta     WHEEL_%s/BX_%d/dttf_eta_wh%s_se%d
0794       dttf_eta[whindex][se]->Fill(track->eta_packed());
0795 
0796       if (track->isFineHalo()) {
0797         dttf_eta_fine_fraction[whindex][se]->Fill(0);
0798 
0799         /// WHEEL_%s/dttf_phi_eta_wh%s
0800         dttf_phi_eta_fine_wheel[whindex]->Fill(track->eta_packed(), phi_global);
0801 
0802       } else {
0803         dttf_eta_fine_fraction[whindex][se]->Fill(1);
0804 
0805         /// WHEEL_%s/dttf_phi_eta_wh%s
0806         dttf_phi_eta_coarse_wheel[whindex]->Fill(track->eta_packed(), phi_global);
0807       }
0808 
0809       /// Only for online: INCLUSIVE/dttf_occupancy_summary_r
0810       if (online_) {
0811         dttf_spare->Fill(whindex, sector);
0812       }
0813 
0814       ///////// ?????????
0815       // dttf_qual_eta_integ->Fill(track->eta_packed(), track->quality_packed());
0816 
0817       /// second track summary
0818       if (track->TrkTag() == 1) {
0819         /// WHEEL_%s/dttf_phi_integ
0820         dttf_phi_wheel_2ndTrack[whindex]->Fill(phi_global);
0821 
0822         /// WHEEL_%s/dttf_pt_integ
0823         dttf_pt_wheel_2ndTrack[whindex]->Fill(track->pt_packed());
0824 
0825         /// WHEEL_%s/dttf_eta_integ
0826         dttf_eta_wheel_2ndTrack[whindex]->Fill(track->eta_packed());
0827 
0828         /// WHEEL_%s/dttf_qual_integ
0829         dttf_quality_wheel_2ndTrack[whindex]->Fill(track->quality_packed());
0830 
0831         /// WHEEL_%s/dttf_q_integ
0832         dttf_q_wheel_2ndTrack[whindex]->Fill(track->charge_packed());
0833 
0834         /// WHEEL_%s/dttf_quality_wh%s
0835         dttf_quality_summary_wheel_2ndTrack[whindex]->Fill(sector, track->quality_packed());
0836 
0837         /// WHEEL_%s/dttf_phi_eta_wh%s
0838         dttf_phi_eta_wheel_2ndTrack[whindex]->Fill(track->eta_packed(), phi_global);
0839       }
0840 
0841       ///////// GMT
0842       bool match = false;
0843       std::vector<L1MuRegionalCand>::iterator dttfCand;
0844       /// gmt phi_packed() goes from 0 to 143
0845       unsigned int gmt_phi = (phi_global < 0 ? phi_global + 144 : phi_global);
0846 
0847       for (dttfCand = gmtDttfCands.begin(); dttfCand != gmtDttfCands.end(); ++dttfCand) {
0848         /// calculate phi in physical coordinates: keep it int, set labels later
0849         if (dttfCand->empty())
0850           continue;
0851         if ((dttfCand->phi_packed() == gmt_phi) && dttfCand->quality_packed() == track->quality_packed()) {
0852           match = true;
0853           dttfCand->reset();
0854           break;
0855         }
0856       }
0857 
0858       if (match) {
0859         dttf_gmt_match->Fill(whindex, sector);
0860       } else {
0861         dttf_gmt_missed->Fill(whindex, sector);
0862       }
0863     }
0864   }
0865 }
0866 
0867 //--------------------------------------------------------
0868 void L1TDTTF::setQualLabel(MonitorElement* me, int axis) {
0869   if (axis == 1)
0870     me->setAxisTitle("Quality", axis);
0871   me->setBinLabel(1, "T34", axis);
0872   me->setBinLabel(2, "T23/24", axis);
0873   me->setBinLabel(3, "T12/13/14", axis);
0874   me->setBinLabel(4, "T234", axis);
0875   me->setBinLabel(5, "T134", axis);
0876   me->setBinLabel(6, "T123/124", axis);
0877   me->setBinLabel(7, "T1234", axis);
0878 }
0879 
0880 //--------------------------------------------------------
0881 void L1TDTTF::setWheelLabel(MonitorElement* me) {
0882   me->setAxisTitle("Wheel", 1);
0883   me->setBinLabel(1, "N2", 1);
0884   me->setBinLabel(2, "N1", 1);
0885   me->setBinLabel(3, "N0", 1);
0886   me->setBinLabel(4, "P0", 1);
0887   me->setBinLabel(5, "P1", 1);
0888   me->setBinLabel(6, "P2", 1);
0889 }
0890 
0891 //--------------------------------------------------------
0892 void L1TDTTF::bookEta(int wh, int& nbins, float& start, float& stop) {
0893   switch (wh) {
0894     case 0:
0895       start = 0;
0896       stop = 18;
0897       nbins = 18;
0898       break;  // N2
0899     case 1:
0900       start = 8;
0901       stop = 28;
0902       nbins = 20;
0903       break;  // N1
0904     case 2:
0905       start = 22;
0906       stop = 32;
0907       nbins = 10;
0908       break;  // N0
0909     case 3:
0910       start = 22;
0911       stop = 42;
0912       nbins = 20;
0913       break;  // P0
0914     case 4:
0915       start = 36;
0916       stop = 56;
0917       nbins = 20;
0918       break;  // P1
0919     case 5:
0920       start = 46;
0921       stop = 64;
0922       nbins = 18;
0923       break;  // P2
0924     default:
0925       start = 0;
0926       stop = 0;
0927       nbins = 0;
0928       break;  // BOH
0929   }
0930 }