CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DQM/HLTEvF/plugins/HLTMuonDQMSource.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    HLTMuonDQMSource
00004 // Class:      HLTMuonDQMSource
00005 // 
00013 //
00014 // Original Author:  Muriel VANDER DONCKT *:0
00015 //         Created:  Wed Dec 12 09:55:42 CET 2007
00016 // $Id: HLTMuonDQMSource.cc,v 1.40 2010/08/07 14:55:56 wmtan Exp $
00017 // Modification:  Hwidong Yoo (Purdue University)
00018 // contact: hdyoo@cern.ch
00019 //
00020 //
00021 
00022 
00023 
00024 #include "DQM/HLTEvF/interface/HLTMuonDQMSource.h"
00025 #include "DQMServices/Core/interface/DQMStore.h"
00026 
00027 #include "DataFormats/Common/interface/Handle.h"
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/EventSetup.h"
00030 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00031 #include "FWCore/ServiceRegistry/interface/Service.h"
00032 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
00033 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
00034 #include "DataFormats/TrackReco/interface/Track.h"
00035 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00036 #include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
00037 #include "DataFormats/RecoCandidate/interface/IsoDepositFwd.h"
00038 #include "DataFormats/Common/interface/AssociationMap.h"
00039 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00040 #include "DataFormats/MuonSeed/interface/L2MuonTrajectorySeed.h"
00041 #include "DataFormats/MuonSeed/interface/L2MuonTrajectorySeedCollection.h"
00042 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
00043 #include "DataFormats/L1Trigger/interface/L1MuonParticle.h"
00044 #include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h"
00045 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTCand.h"
00046 
00047 #include "DataFormats/MuonSeed/interface/L3MuonTrajectorySeed.h"
00048 #include "DataFormats/MuonSeed/interface/L3MuonTrajectorySeedCollection.h"
00049 #include "DataFormats/HLTReco/interface/TriggerEventWithRefs.h"
00050 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
00051 #include "DataFormats/Common/interface/TriggerResults.h"
00052 #include "FWCore/Common/interface/TriggerNames.h"
00053 
00054 #include "DataFormats/CaloTowers/interface/CaloTower.h"
00055 #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
00056 #include "FWCore/Framework/interface/ESHandle.h"
00057 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
00058 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
00059 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00060 #include "MagneticField/Engine/interface/MagneticField.h"
00061 
00062 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00063 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00064 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00065 
00066 #include "DataFormats/Math/interface/deltaR.h"
00067 
00068 #include "TMath.h" 
00069 
00070 //using namespace std;
00071 //using namespace edm;
00072 //using namespace reco;
00073 //using namespace l1extra;
00074 //
00075 // constructors and destructor
00076 //
00077 HLTMuonDQMSource::HLTMuonDQMSource( const edm::ParameterSet& ps ) :counterEvt_(0), nTrig_(0)
00078 {
00079   parameters_ = ps;
00080   verbose_ = parameters_.getUntrackedParameter < bool > ("verbose", false);
00081   monitorName_ = parameters_.getUntrackedParameter<std::string>("monitorName","HLT/HLTMonMuon");
00082   prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
00083   coneSize_ = parameters_.getUntrackedParameter<double>("coneSize", 0.24);
00084   l2seedscollectionTag_ = parameters_.getUntrackedParameter<edm::InputTag>("l2MuonSeedTag",edm::InputTag("hltL2MuonSeeds"));
00085   l3seedscollectionTag_ = parameters_.getUntrackedParameter<edm::InputTag>("l3MuonSeedTag",edm::InputTag("hltL3TrajectorySeed"));
00086   l2collectionTag_ = parameters_.getUntrackedParameter<edm::InputTag>("l2MuonTag",edm::InputTag("hltL2MuonCandidates"));
00087   l3collectionTag_ = parameters_.getUntrackedParameter<edm::InputTag>("l3MuonTag",edm::InputTag("hltL3MuonCandidates"));
00088   l2isolationTag_ = parameters_.getUntrackedParameter<edm::InputTag>("l2IsolationTag",edm::InputTag("hltL2MuonIsolations"));
00089   l3isolationTag_ = parameters_.getUntrackedParameter<edm::InputTag>("l3IsolationTag",edm::InputTag("hltL3MuonIsolations"));
00090 
00091   TrigResultInput = parameters_.getUntrackedParameter<edm::InputTag>("TrigResultInputTag", edm::InputTag("TriggerResults"));
00092 
00093   dbe_ = 0 ;
00094   dbe_ = edm::Service < DQMStore > ().operator->();
00095   dbe_->setVerbose(0);
00096  
00097   outputFile_ =
00098     parameters_.getUntrackedParameter < std::string > ("outputFile", "");
00099   if (outputFile_.size() != 0) {
00100     edm::LogWarning("HLTMuonDQMSource") << "Muon HLT Monitoring histograms will be saved to " 
00101                                    << outputFile_ << std::endl;
00102   }
00103   else {
00104     outputFile_ = "HLTMuonDQM.root";
00105   }
00106   
00107   bool disable =
00108     parameters_.getUntrackedParameter < bool > ("disableROOToutput", false);
00109   if (disable) {
00110     outputFile_ = "";
00111   }
00112   
00113   if (dbe_ != NULL) {
00114     dbe_->setCurrentFolder(monitorName_);
00115  }
00116   
00117   std::vector<edm::ParameterSet> filters = parameters_.getParameter<std::vector<edm::ParameterSet> >("filters");
00118 
00119   for(std::vector<edm::ParameterSet>::iterator filterconf = filters.begin() ; filterconf != filters.end() ; filterconf++){
00120     theDirectoryName.push_back(filterconf->getParameter<std::string>("directoryName"));
00121     //theHLTCollectionLevel.push_back(filterconf->getParameter<std::string>("level"));
00122     //theTriggerBits.push_back(filterconf->getParameter<std::vector<std::string> >("triggerBits"));
00123     std::string _tmp_level = filterconf->getParameter<std::string>("directoryName");
00124     std::vector<std::string> _tmp_bits = filterconf->getParameter<std::vector<std::string> >("triggerBits");
00125     for( size_t i = 0; i < _tmp_bits.size(); ++i ) {
00126         theTriggerBits.push_back(_tmp_bits[i]);
00127         theHLTCollectionLevel.push_back(_tmp_level);
00128     }
00129   }
00130   
00131   // L1PassThrough, L2PassThrough, L3PassThrough
00132   nTrigs = theDirectoryName.size();
00133 
00134   for( int trig = 0; trig < nTrigs; trig++ ) striggers_[trig] = "";
00135 }
00136 
00137 
00138 HLTMuonDQMSource::~HLTMuonDQMSource()
00139 {
00140   
00141   // do anything here that needs to be done at desctruction time
00142   // (e.g. close files, deallocate resources etc.)
00143   
00144 }
00145 
00146 
00147 //--------------------------------------------------------
00148 void HLTMuonDQMSource::beginJob()
00149 {
00150   if (dbe_) {
00151     //dbe_->setCurrentFolder("monitorName_");
00152     if (monitorName_ != "" ) monitorName_ = monitorName_+"/" ;
00153     edm::LogInfo("HLTMuonDQMSource") << "===>DQM event prescale = " << prescaleEvt_ << " events "<< std::endl;
00154     
00155     
00157     int NBINS = 50; XMIN = 0; XMAX = 50;
00158     
00159     // create and cd into new folder
00160     char name[512], title[512];
00161     double pt_max;
00162     std::string dirname;
00163 
00164     for( int trig = 0; trig < nTrigs; trig++ ) {
00165       dirname = theDirectoryName[trig]+"/";
00166 
00167       for(unsigned int i = 0; i < theHLTCollectionLevel.size(); ++i){
00168         if(theHLTCollectionLevel[i] == theDirectoryName[trig]) {
00169           if(!strcmp(striggers_[trig].c_str(), "")) striggers_[trig] = theTriggerBits[i];
00170           else striggers_[trig] += ", " + theTriggerBits[i];
00171         }
00172       }
00173       dbe_->setCurrentFolder(monitorName_ + dirname);
00174       sprintf(name,"%s triggers",theDirectoryName[trig].c_str());
00175       dbe_->bookString(name,striggers_[trig]);
00176 
00177       for ( int level = 1; level < 7; ++level ) {
00178         if( level < 4 ) sprintf(name,"Level%i",level);
00179         else if (level == 4 ) sprintf(name,"Level%iSeed", level-2);
00180         else if (level == 5 ) sprintf(name,"Level%iSeed", level-2);
00181         else if (level == 6 ) sprintf(name,"Level2Isolation");
00182         
00183         if( level == 1 ) pt_max = 145;
00184         else pt_max = 200;
00185         dbe_->setCurrentFolder(monitorName_+dirname+name);
00186         if( level == 1 ) hl1quality[trig] = dbe_->book1D("h1L1Quality","GMT quality Flag", 8, 0., 8.);
00187         if( level == 2 ) {
00188             hnHits[trig][level-1] = dbe_->book1D(name,title, NBINS, 0., 100.);
00189             hnValidHits[trig] = dbe_->book1D("HLTMuonL2_nValidHits", "L2 Number of Valid Hits", NBINS, 0., 100.);
00190             hnValidHits[trig]->setAxisTitle("Number of Valid Hits", 1);
00191         }
00192         if( level == 3 ) {
00193           hnTkValidHits[trig] = dbe_->book1D("HLTMuonL3_nTkValidHits", "L3 Number of Valid Tracker Hits", NBINS, 0., 100.);
00194           hnTkValidHits[trig]->setAxisTitle("Number of Valid Tracker Hits", 1);
00195           hnMuValidHits[trig] = dbe_->book1D("HLTMuonL3_nMuValidHits", "L3 Number of Valid Muon Hits", NBINS, 0., 100.);
00196           hnMuValidHits[trig]->setAxisTitle("Number of Valid Muon Hits", 1);
00197         }
00198         if( level == 1 ) {
00199           int eta_nbin = 62;
00200           float eta_bins[63] = {
00201                          -2.40, -2.35, -2.30, -2.25, -2.20, -2.15, -2.10, -2.05,
00202                          -2.00, -1.95, -1.90, -1.85, -1.80, -1.75, -1.70, -1.60,
00203                          -1.50, -1.40, -1.30, -1.20, -1.10, -1.00, -0.90, -0.80,
00204                          -0.70, -0.60, -0.50, -0.40, -0.30, -0.20, -0.10, -0.00,
00205                          0.10,  0.20,  0.30,  0.40,  0.50,  0.60,  0.70,  0.80,
00206                          0.90,  1.00,  1.10,  1.20,  1.30,  1.40,  1.50,  1.60,
00207                          1.70,  1.75,  1.80,  1.85,  1.90,  1.95,  2.00,  2.05,
00208                          2.10,  2.15,  2.20,  2.25,  2.30,  2.35,  2.40
00209                          };
00210           int phi_nbin = 144;            
00211           float phi_bins[145];
00212           for( int ibin = 0; ibin < 145; ibin++ ) {
00213               phi_bins[ibin] = -3.15 + (ibin)*(6.30/144);
00214           }
00215           float pt_bins[51];
00216           for( int ibin = 0; ibin < 51; ibin++ ) {
00217               pt_bins[ibin] = ibin*(145./50.);
00218           }
00219           sprintf(name,"HLTMuonL%i_NMu",level);
00220           sprintf(title,"L%i number of muons",level);
00221           hNMu[trig][level-1] = dbe_->book1D(name,title, 5, -0.5, 4.5);
00222           hNMu[trig][level-1]->setAxisTitle("Number of muons", 1);
00223           sprintf(name,"HLTMuonL%i_pt",level);
00224           sprintf(title,"L%i Pt",level);
00225           hpt[trig][level-1] = dbe_->book1D(name,title, NBINS, pt_bins);
00226           hpt[trig][level-1]->setAxisTitle("Pt", 1);
00227           sprintf(name,"HLTMuonL%i_eta",level);
00228           sprintf(title,"L%i Muon #eta",level);
00229           heta[trig][level-1] = dbe_->book1D(name,title, eta_nbin, eta_bins);
00230           heta[trig][level-1]->setAxisTitle("#eta", 1);
00231           sprintf(name,"HLTMuonL%i_phi",level);
00232           sprintf(title,"L%i Muon #phi",level);
00233           hphi[trig][level-1] = dbe_->book1D(name,title, phi_nbin, phi_bins);
00234           hphi[trig][level-1]->setAxisTitle("#phi", 1);
00235           sprintf(name,"HLTMuonL%i_phi_norm",level);
00236           sprintf(title,"L%i Muon #phi_norm",level);
00237           hphi_norm[trig][level-1] = dbe_->book1D(name,title, phi_nbin, phi_bins);
00238           hphi_norm[trig][level-1]->setAxisTitle("#phi", 1);
00239           sprintf(name,"HLTMuonL%i_etaphi",level);
00240           sprintf(title,"L%i Muon #eta vs #phi",level);
00241           hetaphi[trig][level-1] = dbe_->book2D(name,title, phi_nbin, phi_bins, eta_nbin, eta_bins);
00242           hetaphi[trig][level-1]->setAxisTitle("#phi", 1);
00243           hetaphi[trig][level-1]->setAxisTitle("#eta", 2); 
00244           sprintf(name,"HLTMuonL%i_ptphi",level);
00245           sprintf(title,"L%i Muon pt vs #phi",level);         
00246           hptphi[trig][level-1] = dbe_->book2D(name,title, NBINS, pt_bins, phi_nbin, phi_bins);
00247           hptphi[trig][level-1]->setAxisTitle("pt", 1);
00248           hptphi[trig][level-1]->setAxisTitle("#phi", 2);
00249           sprintf(name,"HLTMuonL%i_pteta",level);
00250           sprintf(title,"L%i Muon pt vs #eta",level);         
00251           hpteta[trig][level-1] = dbe_->book2D(name,title, NBINS, pt_bins, eta_nbin, eta_bins);
00252           hpteta[trig][level-1]->setAxisTitle("pt", 1);
00253           hpteta[trig][level-1]->setAxisTitle("#eta", 2);
00254           sprintf(name,"HLTMuonL%i_charge",level);
00255           sprintf(title,"L%i Muon Charge",level);         
00256           hcharge[trig][level-1]  = dbe_->book1D(name,title, 3, -1.5, 1.5);
00257           hcharge[trig][level-1]->setAxisTitle("Charge", 1);
00258         }
00259         if( level > 1 && level < 4 ) {
00260           sprintf(name,"HLTMuonL%i_NMu",level);
00261           sprintf(title,"L%i number of muons",level);
00262           hNMu[trig][level-1] = dbe_->book1D(name,title, 5, -0.5, 4.5);
00263           hNMu[trig][level-1]->setAxisTitle("Number of muons", 1);
00264           sprintf(name,"HLTMuonL%i_pt",level);
00265           sprintf(title,"L%i Pt",level);
00266           hpt[trig][level-1] = dbe_->book1D(name,title, NBINS, 0., pt_max);
00267           hpt[trig][level-1]->setAxisTitle("Pt", 1);
00268           sprintf(name,"HLTMuonL%i_eta",level);
00269           sprintf(title,"L%i Muon #eta",level);
00270           heta[trig][level-1] = dbe_->book1D(name,title, NBINS, -2.5, 2.5);
00271           heta[trig][level-1]->setAxisTitle("#eta", 1);
00272           sprintf(name,"HLTMuonL%i_phi",level);
00273           sprintf(title,"L%i Muon #phi",level);
00274           hphi[trig][level-1] = dbe_->book1D(name,title, NBINS, -3.15, 3.15);
00275           hphi[trig][level-1]->setAxisTitle("#phi", 1);
00276           sprintf(name,"HLTMuonL%i_phi_norm",level);
00277           sprintf(title,"L%i Muon #phi_norm",level);
00278           hphi_norm[trig][level-1] = dbe_->book1D(name,title, NBINS, -3.15, 3.15);
00279           hphi_norm[trig][level-1]->setAxisTitle("#phi", 1);
00280           sprintf(name,"HLTMuonL%i_etaphi",level);
00281           sprintf(title,"L%i Muon #eta vs #phi",level);
00282           hetaphi[trig][level-1] = dbe_->book2D(name,title, NBINS, -3.15, 3.15,NBINS,-2.5, 2.5);
00283           hetaphi[trig][level-1]->setAxisTitle("#phi", 1);
00284           hetaphi[trig][level-1]->setAxisTitle("#eta", 2); 
00285           sprintf(name,"HLTMuonL%i_ptphi",level);
00286           sprintf(title,"L%i Muon pt vs #phi",level);         
00287           hptphi[trig][level-1] = dbe_->book2D(name,title, NBINS, 0., pt_max,NBINS,-3.15, 3.15);
00288           hptphi[trig][level-1]->setAxisTitle("pt", 1);
00289           hptphi[trig][level-1]->setAxisTitle("#phi", 2);
00290           sprintf(name,"HLTMuonL%i_pteta",level);
00291           sprintf(title,"L%i Muon pt vs #eta",level);         
00292           hpteta[trig][level-1] = dbe_->book2D(name,title, NBINS, 0., pt_max,NBINS,-2.5, 2.5);
00293           hpteta[trig][level-1]->setAxisTitle("pt", 1);
00294           hpteta[trig][level-1]->setAxisTitle("#eta", 2);
00295           sprintf(name,"HLTMuonL%i_nHits",level);
00296           sprintf(title,"L%i Number of Hits",level);         
00297           hnHits[trig][level-1] = dbe_->book1D(name,title, NBINS, 0., 100.);
00298           hnHits[trig][level-1]->setAxisTitle("Number of Hits", 1);
00299           sprintf(name,"HLTMuonL%i_charge",level);
00300           sprintf(title,"L%i Muon Charge",level);         
00301           hcharge[trig][level-1]  = dbe_->book1D(name,title, 3, -1.5, 1.5);
00302           hcharge[trig][level-1]->setAxisTitle("Charge", 1);
00303         }
00304         else if( level == 4 || level == 5 ) {
00305           sprintf(name,"HLTMuonL%iSeed_NMu",level-2);
00306           sprintf(title,"L%iSeed number of muons",level-2);
00307           hNMu[trig][level-1] = dbe_->book1D(name,title, 5, -0.5, 4.5);
00308           hNMu[trig][level-1]->setAxisTitle("Number of muons", 1);
00309           sprintf(name,"HLTMuonL%iSeed_pt",level-2);
00310           sprintf(title,"L%iSeed Pt",level-2);
00311           hpt[trig][level-1] = dbe_->book1D(name,title, NBINS, 0., pt_max);
00312           hpt[trig][level-1]->setAxisTitle("Pt", 1);
00313           sprintf(name,"HLTMuonL%iSeed_eta",level-2);
00314           sprintf(title,"L%iSeed Muon #eta",level-2);
00315           heta[trig][level-1] = dbe_->book1D(name,title, NBINS, -2.5, 2.5);
00316           heta[trig][level-1]->setAxisTitle("#eta", 1);
00317           sprintf(name,"HLTMuonL%iSeed_phi",level-2);
00318           sprintf(title,"L%iSeed Muon #phi",level-2);
00319           hphi[trig][level-1] = dbe_->book1D(name,title, NBINS, -3.15, 3.15);
00320           hphi[trig][level-1]->setAxisTitle("#phi", 1);
00321           sprintf(name,"HLTMuonL%iSeed_etaphi",level-2);
00322           sprintf(title,"L%iSeed Muon #eta vs #phi",level-2);
00323           hetaphi[trig][level-1] = dbe_->book2D(name,title, NBINS, -3.15, 3.15,NBINS,-2.5, 2.5);
00324           hetaphi[trig][level-1]->setAxisTitle("#phi", 1);
00325           hetaphi[trig][level-1]->setAxisTitle("#eta", 2); 
00326           sprintf(name,"HLTMuonL%iSeed_ptphi",level-2);
00327           sprintf(title,"L%iSeed Muon pt vs #phi",level-2);         
00328           hptphi[trig][level-1] = dbe_->book2D(name,title, NBINS, 0., pt_max,NBINS,-3.15, 3.15);
00329           hptphi[trig][level-1]->setAxisTitle("pt", 1);
00330           hptphi[trig][level-1]->setAxisTitle("#phi", 2);
00331           sprintf(name,"HLTMuonL%iSeed_pteta",level-2);
00332           sprintf(title,"L%iSeed Muon pt vs #eta",level-2);         
00333           hpteta[trig][level-1] = dbe_->book2D(name,title, NBINS, 0., pt_max,NBINS,-2.5, 2.5);
00334           hpteta[trig][level-1]->setAxisTitle("pt", 1);
00335           hpteta[trig][level-1]->setAxisTitle("#eta", 2);
00336           sprintf(name,"HLTMuonL%iSeed_charge",level-2);
00337           sprintf(title,"L%iSeed Muon Charge",level-2);         
00338           hcharge[trig][level-1]  = dbe_->book1D(name,title, 3, -1.5, 1.5);
00339           hcharge[trig][level-1]->setAxisTitle("Charge", 1);
00340           // pt
00341           sprintf(name,"HLTMuonL%iSeedtoL%i_ptres",level-2,level-3);
00342           sprintf(title,"L%iSeed1/Pt - L%iMuon1/Pt",level-2,level-3);         
00343           hseedptres[trig][level-4] = dbe_->book1D(name,title, NBINS, -0.1, 0.1);
00344           sprintf(title,"1/PtL%iSeed - 1/PtL%i",level-2,level-3);         
00345           hseedptres[trig][level-4]->setAxisTitle(title, 1);
00346           sprintf(name,"HLTMuonL%iSeedtoL%i_ptrelres",level-2,level-3);
00347           sprintf(title,"(L%iSeed1/Pt - L%iMuon1/Pt)/(L%iMuon1/Pt)",level-2,level-3,level-3);         
00348           hseedptrelres[trig][level-4] = dbe_->book1D(name,title, NBINS, -1.0, 1.0);
00349           sprintf(title,"(1/PtL%iSeed - 1/PtL%i)/(1/PtL%i)",level-2,level-3,level-3);         
00350           hseedptrelres[trig][level-4]->setAxisTitle(title, 1);
00351           // eta
00352           sprintf(name,"HLTMuonL%iSeedtoL%i_etares",level-2,level-3);
00353           sprintf(title,"L%iSeed#eta - L%iMuon#eta",level-2,level-3);         
00354           hseedetares[trig][level-4] =dbe_->book1D(name,title, NBINS, -0.1, 0.1);
00355           sprintf(title,"L%iSeed #eta - L%i #eta",level-2,level-3);         
00356           hseedetares[trig][level-4]->setAxisTitle(title, 1);
00357           sprintf(name,"HLTMuonL%iSeedtoL%i_etarelres",level-2,level-3);
00358           sprintf(title,"(L%iSeed#eta - L%iMuon#eta)/L%iMuon#eta",level-2,level-3,level-3);         
00359           hseedetarelres[trig][level-4] =dbe_->book1D(name,title, NBINS, -1.0, 1.0);
00360           sprintf(title,"(L%iSeed #eta - L%i #eta)/L%i #eta",level-2,level-3,level-3);         
00361           hseedetarelres[trig][level-4]->setAxisTitle(title, 1);
00362           // phi
00363           sprintf(name,"HLTMuonL%iSeedtoL%i_phires",level-2,level-3);
00364           sprintf(title,"L%iSeed#phi - L%iMuon#phi",level-2,level-3);         
00365           hseedphires[trig][level-4] =dbe_->book1D(name,title, NBINS, -0.1, 0.1);
00366           sprintf(title,"L%iSeed #phi - L%i #phi",level-2,level-3);         
00367           hseedphires[trig][level-4]->setAxisTitle(title, 1);
00368           sprintf(name,"HLTMuonL%iSeedtoL%i_phirelres",level-2,level-3);
00369           sprintf(title,"(L%iSeed#phi - L%iMuon#phi)/L%iMuon#phi",level-2,level-3,level-3);         
00370           hseedphirelres[trig][level-4] =dbe_->book1D(name,title, NBINS, -0.1, 0.1);
00371           sprintf(title,"(L%iSeed #phi - L%i #phi)/L%i #phi",level-2,level-3,level-3);         
00372           hseedphirelres[trig][level-4]->setAxisTitle(title, 1);
00373 
00374           sprintf(name,"HLTMuonL%iSeed_NMuperL%i",level-2,level-3);
00375           sprintf(title,"L%iSeedNMu per L%i",level-2,level-3);         
00376           hseedNMuper[trig][level-4] = dbe_->book1D(name, title, 5, -0.5, 4.5);
00377           hseedNMuper[trig][level-4]->setAxisTitle(title, 1);
00378         }
00379         else if( level == 6 ) {
00380           double max_energy = 1.0;
00381           sprintf(name,"HLTMuonL2_driso");
00382           sprintf(title,"dR Cone Size");
00383           hL2muonIsoDR[trig] = dbe_->book2D(name, title, 10, 0, 0.24, NBINS, 0, 5.0);
00384           hL2muonIsoDR[trig]->setAxisTitle(title, 1);
00385           hL2muonIsoDR[trig]->setAxisTitle("Calo Energy in Iso Cone (GeV)", 2);
00386 
00387           sprintf(name,"HLTCaloTower_dRwithL2");
00388           sprintf(title,"#Delta R(L2muon, CaloTower)");
00389           htowerdRL2[trig] = dbe_->book1D(name, title, NBINS, 0, 0.5);
00390           htowerdRL2[trig]->setAxisTitle(title, 1);
00391           sprintf(name,"HLTCaloTower_dRwithL3");
00392           sprintf(title,"#Delta R(L3muon, CaloTower)");
00393           htowerdRL3[trig] = dbe_->book1D(name, title, NBINS, 0, 0.5);
00394           htowerdRL3[trig]->setAxisTitle(title, 1);
00395 
00396           sprintf(name,"HLTCaloTower_Et");
00397           sprintf(title,"HLT CaloTower Et");
00398           htowerEt[trig] = dbe_->book1D(name, title, NBINS, 0, max_energy);
00399           htowerEt[trig]->setAxisTitle(title, 1);
00400           sprintf(name,"HLTCaloTower_Eta");
00401           sprintf(title,"HLT CaloTower #eta");
00402           htowerEta[trig] = dbe_->book1D(name, title, NBINS, -2.5, 2.5);
00403           htowerEta[trig]->setAxisTitle(title, 1);
00404           sprintf(name,"HLTCaloTower_Phi");
00405           sprintf(title,"HLT CaloTower #phi");
00406           htowerPhi[trig] = dbe_->book1D(name, title, NBINS, -3.14, 3.14);
00407           htowerPhi[trig]->setAxisTitle(title, 1);
00408           
00409           sprintf(name,"HLTCaloTower_HadEnergy");
00410           sprintf(title,"HLT CaloTower hadEnergy");
00411           htowerHadEnergy[trig] = dbe_->book1D(name, title, NBINS, 0, max_energy);
00412           htowerHadEnergy[trig]->setAxisTitle(title, 1);
00413           sprintf(name,"HLTCaloTower_EmEnergy");
00414           sprintf(title,"HLT CaloTower emEnergy");
00415           htowerEmEnergy[trig] = dbe_->book1D(name, title, NBINS, 0, max_energy);
00416           htowerEmEnergy[trig]->setAxisTitle(title, 1);
00417           sprintf(name,"HLTCaloTower_OuterEnergy");
00418           sprintf(title,"HLT CaloTower outerEnergy");
00419           htowerOuterEnergy[trig] = dbe_->book1D(name, title, NBINS, 0, max_energy);
00420           htowerOuterEnergy[trig]->setAxisTitle(title, 1);
00421          
00422           sprintf(name,"HLTCaloTower_HadEt");
00423           sprintf(title,"HLT CaloTower hadEt");
00424           htowerHadEt[trig] = dbe_->book1D(name, title, NBINS, 0, max_energy);
00425           htowerHadEt[trig]->setAxisTitle(title, 1);
00426           sprintf(name,"HLTCaloTower_EmEt");
00427           sprintf(title,"HLT CaloTower emEt");
00428           htowerEmEt[trig] = dbe_->book1D(name, title, NBINS, 0, max_energy);
00429           htowerEmEt[trig]->setAxisTitle(title, 1);
00430           sprintf(name,"HLTCaloTower_OuterEt");
00431           sprintf(title,"HLT CaloTower outerEt");
00432           htowerOuterEt[trig] = dbe_->book1D(name, title, NBINS, 0, max_energy);
00433           htowerOuterEt[trig]->setAxisTitle(title, 1);
00434 
00435           sprintf(name,"HLTCaloTower_EtaHadEt");
00436           sprintf(title,"HLT CaloTower hadEt");
00437           htowerEtaHadEt[trig] = dbe_->book2D(name, title, NBINS, -2.5, 2.5, NBINS, 0, max_energy);
00438           htowerEtaHadEt[trig]->setAxisTitle("CaloTower #eta", 1);
00439           htowerEtaHadEt[trig]->setAxisTitle(title, 2);
00440           sprintf(name,"HLTCaloTower_EtaEmEt");
00441           sprintf(title,"HLT CaloTower emEt");
00442           htowerEtaEmEt[trig] = dbe_->book2D(name, title, NBINS, -2.5, 2.5, NBINS, 0, max_energy);
00443           htowerEtaEmEt[trig]->setAxisTitle("CaloTower #eta", 1);
00444           htowerEtaEmEt[trig]->setAxisTitle(title, 2);
00445           sprintf(name,"HLTCaloTower_EtaOuterEt");
00446           sprintf(title,"HLT CaloTower outerEt");
00447           htowerEtaOuterEt[trig] = dbe_->book2D(name, title, NBINS, -2.5, 2.5, NBINS, 0, max_energy);
00448           htowerEtaOuterEt[trig]->setAxisTitle("CaloTower #eta", 1);
00449           htowerEtaOuterEt[trig]->setAxisTitle(title, 2);
00450 
00451           sprintf(name,"HLTCaloTower_PhiHadEt");
00452           sprintf(title,"HLT CaloTower hadEt");
00453           htowerPhiHadEt[trig] = dbe_->book2D(name, title, NBINS, -3.15, 3.15, NBINS, 0, max_energy);
00454           htowerPhiHadEt[trig]->setAxisTitle("CaloTower #phi", 1);
00455           htowerPhiHadEt[trig]->setAxisTitle(title, 2);
00456           sprintf(name,"HLTCaloTower_PhiEmEt");
00457           sprintf(title,"HLT CaloTower emEt");
00458           htowerPhiEmEt[trig] = dbe_->book2D(name, title, NBINS, -3.15, 3.15, NBINS, 0, max_energy);
00459           htowerPhiEmEt[trig]->setAxisTitle("CaloTower #phi", 1);
00460           htowerPhiEmEt[trig]->setAxisTitle(title, 2);
00461           sprintf(name,"HLTCaloTower_PhiOuterEt");
00462           sprintf(title,"HLT CaloTower outerEt");
00463           htowerPhiOuterEt[trig] = dbe_->book2D(name, title, NBINS, -3.15, 3.15, NBINS, 0, max_energy);
00464           htowerPhiOuterEt[trig]->setAxisTitle("CaloTower #phi", 1);
00465           htowerPhiOuterEt[trig]->setAxisTitle(title, 2);
00466         }
00467         
00468         if (level>1&&level<4){
00469           sprintf(name,"HLTMuonL%i_dr",level);
00470           sprintf(title,"L%i Muon radial impact vs BeamSpot",level);         
00471           hdr[trig][level-2] = dbe_->book1D(name,title, NBINS, -0.3, 0.3);
00472           hdr[trig][level-2]->setAxisTitle("R Impact (cm) vs BeamSpot", 1);
00473           sprintf(name,"HLTMuonL%i_d0",level);
00474           sprintf(title,"L%i Muon radial impact vs (0,0)",level);         
00475           hd0[trig][level-2] = dbe_->book1D(name,title, NBINS, -0.3, 0.3);
00476           hd0[trig][level-2]->setAxisTitle("R Impact (cm) vs 0,0", 1);
00477           sprintf(name,"HLTMuonL%i_dz0",level);
00478           sprintf(title,"L%i Muon Z impact vs (0)",level);         
00479           hdz0[trig][level-2] = dbe_->book1D(name,title, NBINS, -25., 25.);
00480           hdz0[trig][level-2]->setAxisTitle("Z impact (cm) vs 0", 1);
00481           sprintf(name,"HLTMuonL%i_dz",level);
00482           sprintf(title,"L%i Muon Z impact vs BeamSpot",level);         
00483           hdz[trig][level-2] = dbe_->book1D(name,title, NBINS, -25., 25.);
00484           hdz[trig][level-2]->setAxisTitle("Z impact (cm) vs BeamSpot", 1);
00485           sprintf(name,"HLTMuonL%i_err0",level);
00486           sprintf(title,"L%i Muon Error on Pt",level);         
00487           herr0[trig][level-2] = dbe_->book1D(name,title,NBINS, 0., 0.03);
00488           herr0[trig][level-2]->setAxisTitle("Error on Pt", 1);
00489           sprintf(name,"HLTMuonL%i_iso",level);
00490           if (level==2)sprintf(title,"L%i Muon Energy in Isolation cone",level);         
00491           else if (level==3)sprintf(title,"L%i Muon SumPt in Isolation cone",level);               
00492           hiso[trig][level-2]  = dbe_->book1D(name,title, NBINS, 0., 5./(level-1));
00493           if ( level==2)hiso[trig][level-2]->setAxisTitle("Calo Energy in Iso Cone (GeV)", 1);
00494           else if ( level==3)hiso[trig][level-2]->setAxisTitle("Sum Pt in Iso Cone (GeV)", 1);
00495           sprintf(name,"HLTMuonL%i_DiMuMass",level);
00496           sprintf(title,"L%i Opposite charge DiMuon invariant Mass",level);         
00497           hdimumass[trig][level-2]= dbe_->book1D(name,title, NBINS, 0., 150.);
00498           hdimumass[trig][level-2]->setAxisTitle("Di Muon Invariant Mass (GeV)");
00499 
00500           sprintf(name,"HLTMuonL%i_drphi",level);
00501           sprintf(title,"L%i #Deltar vs #phi",level);         
00502           hdrphi[trig][level-2] = dbe_->bookProfile(name,title, NBINS, -3.15, 3.15,1,-999.,999.,"s");
00503           hdrphi[trig][level-2]->setAxisTitle("#phi", 1);
00504           sprintf(title,"L%i Muon radial impact vs BeamSpot",level);         
00505           hdrphi[trig][level-2]->setAxisTitle(title, 2);
00506 
00507           sprintf(name,"HLTMuonL%i_d0phi",level);
00508           sprintf(title,"L%i #Delta0 vs #phi",level);         
00509           hd0phi[trig][level-2] = dbe_->bookProfile(name,title, NBINS, -3.15, 3.15,1,-999.,999.,"s");
00510           hd0phi[trig][level-2]->setAxisTitle("#phi", 1);
00511           sprintf(title,"L%i Muon radial impact vs (0,0)",level);         
00512           hd0phi[trig][level-2]->setAxisTitle(title, 2);
00513 
00514           sprintf(name,"HLTMuonL%i_dz0eta",level);
00515           sprintf(title,"L%i #Deltaz0 vs #eta",level);         
00516           hdz0eta[trig][level-2] = dbe_->bookProfile(name,title, NBINS,-2.5, 2.5,1,-999.,999.,"s");
00517           hdz0eta[trig][level-2]->setAxisTitle("#eta", 1);
00518           sprintf(title,"L%i Muon Z impact vs (0)",level);         
00519           hdz0eta[trig][level-2]->setAxisTitle(title, 2);
00520 
00521           sprintf(name,"HLTMuonL%i_dzeta",level);
00522           sprintf(title,"L%i #Deltaz vs #eta",level);         
00523           hdzeta[trig][level-2] = dbe_->bookProfile(name,title, NBINS,-2.5, 2.5,1,-999.,999.,"s");
00524           hdzeta[trig][level-2]->setAxisTitle("#eta", 1);
00525           sprintf(title,"L%i Muon Z impact vs BeamSpot",level);         
00526           hdzeta[trig][level-2]->setAxisTitle(title, 2);
00527         }
00528         if(level == 2 ) {
00529           sprintf(name,"HLTMuonL%itoL%i_ptpull",level,level+1);
00530           sprintf(title,"(L%iMuon1/Pt - L%iMuon1/Pt)/#sigma_{pt}^{L2}",level,level+1);         
00531           hptpull[trig] = dbe_->book1D(name,title, NBINS, -10.0, 10.0);
00532           sprintf(title,"(1/PtL%i - 1/PtL%i)/#sigma_{pt}^{L2}",level,level+1);         
00533           hptpull[trig]->setAxisTitle(title, 1);
00534           sprintf(name,"HLTMuonL%itoL%i_etapull",level,level+1);
00535           sprintf(title,"(L%iMuon#eta - L%iMuon#eta)/#sigma_{#eta}^{L2}",level,level+1);         
00536           hetapull[trig] =dbe_->book1D(name,title, NBINS, -10.0, 10.0);
00537           sprintf(title,"(L%i #eta - L%i #eta)/#sigma_{#eta}^{L2}",level,level+1);         
00538           hetapull[trig]->setAxisTitle(title, 1);
00539           sprintf(name,"HLTMuonL%itoL%i_phipull",level,level+1);
00540           sprintf(title,"(L%iMuon#phi - L%iMuon#phi)/#sigma_{#phi}^{L2}",level,level+1);         
00541           hphipull[trig] =dbe_->book1D(name,title, NBINS, -10.0, 10.0);
00542           sprintf(title,"(L%i #phi - L%i #phi)/#sigma_{#phi}^{L2}",level,level+1);         
00543           hphipull[trig]->setAxisTitle(title, 1);
00544 
00545           sprintf(name,"HLTMuonL%itoL%i_ptpullpt",level,level+1);
00546           sprintf(title,"L%i Muon #Delta Pt/#sigma_{pt}^{L2} vs Pt ",level);         
00547           hptpullpt[trig] =dbe_->bookProfile(name,title, NBINS, 0, pt_max,1,-999.,999.,"s");
00548           sprintf(title,"(1/PtL%i - 1/PtL%i)/#sigma_{pt}^{L2}",level,level+1);         
00549           hptpullpt[trig]->setAxisTitle(title, 2);
00550           hptpullpt[trig]->setAxisTitle("Pt", 1);
00551           sprintf(name,"HLTMuonL%itoL%i_etapulleta",level,level+1);
00552           sprintf(title,"L%i Muon #Delta#eta/#sigma_{#eta}^{L2} vs #eta ",level);         
00553           hetapulleta[trig] =dbe_->bookProfile(name,title, NBINS,-2.5, 2.5,1,-999.,999.,"s");
00554           sprintf(title,"(L%i #eta - L%i #eta)/#sigma_{#eta}^{L2}",level,level+1);         
00555           hetapulleta[trig]->setAxisTitle(title, 2);
00556           hetapulleta[trig]->setAxisTitle("#eta", 1);
00557           sprintf(name,"HLTMuonL%itoL%i_phipullphi",level,level+1);
00558           sprintf(title,"L%i Muon #Delta#phi/#sigma_{#phi}^{L2} vs #phi ",level);         
00559           hphipullphi[trig] =dbe_->bookProfile(name,title, NBINS, -3.15, 3.15,1,-999.,999.,"s");
00560           sprintf(title,"(L%i #phi - L%i #phi)/#sigma_{#phi}^{L2}",level,level+1);         
00561           hphipullphi[trig]->setAxisTitle(title, 2);
00562           hphipullphi[trig]->setAxisTitle("#phi", 1);
00563         }
00564         if (level < 3 ) {
00565           // res
00566           sprintf(name,"HLTMuonL%itoL%i_ptres",level,level+1);
00567           sprintf(title,"L%iMuon1/Pt - L%iMuon1/Pt",level,level+1);         
00568           hptres[trig][level-1] = dbe_->book1D(name,title, NBINS, -0.1, 0.1);
00569           sprintf(title,"1/PtL%i - 1/PtL%i",level,level+1);         
00570           hptres[trig][level-1]->setAxisTitle(title, 1);
00571           sprintf(name,"HLTMuonL%itoL%i_etares",level,level+1);
00572           sprintf(title,"L%iMuon#eta - L%iMuon#eta",level,level+1);         
00573           hetares[trig][level-1] =dbe_->book1D(name,title, NBINS, -0.1, 0.1);
00574           sprintf(title,"L%i #eta - L%i #eta",level,level+1);         
00575           hetares[trig][level-1]->setAxisTitle(title, 1);
00576           sprintf(name,"HLTMuonL%itoL%i_phires",level,level+1);
00577           sprintf(title,"L%iMuon#phi - L%iMuon#phi",level,level+1);         
00578           hphires[trig][level-1] =dbe_->book1D(name,title, NBINS, -0.1, 0.1);
00579           sprintf(title,"L%i #phi - L%i #phi",level,level+1);         
00580           hphires[trig][level-1]->setAxisTitle(title, 1);
00581 
00582           sprintf(name,"HLTMuonL%itoL%i_ptrespt",level,level+1);
00583           sprintf(title,"L%i Muon #Delta Pt vs Pt ",level);         
00584           hptrespt[trig][level-1] =dbe_->bookProfile(name,title, NBINS, 0, pt_max,1,-999.,999.,"s");
00585           sprintf(title,"1/PtL%i - 1/PtL%i",level,level+1);         
00586           hptrespt[trig][level-1]->setAxisTitle(title, 2);
00587           hptrespt[trig][level-1]->setAxisTitle("Pt", 1);
00588           sprintf(name,"HLTMuonL%itoL%i_phiresphi",level,level+1);
00589           sprintf(title,"L%i Muon #Delta#phi vs #phi ",level);         
00590           hphiresphi[trig][level-1] =dbe_->bookProfile(name,title, NBINS, -3.15, 3.15,1,-999.,999.,"s");
00591           sprintf(title,"L%i #phi - L%i #phi",level,level+1);         
00592           hphiresphi[trig][level-1]->setAxisTitle(title, 2);
00593           hphiresphi[trig][level-1]->setAxisTitle("#phi", 1);
00594           sprintf(name,"HLTMuonL%itoL%i_etareseta",level,level+1);
00595           sprintf(title,"L%i Muon #Delta#eta vs #eta ",level);         
00596           hetareseta[trig][level-1] =dbe_->bookProfile(name,title, NBINS,-2.5, 2.5,1,-999.,999.,"s");
00597           sprintf(title,"L%i #eta - L%i #eta",level,level+1);         
00598           hetareseta[trig][level-1]->setAxisTitle(title, 2);
00599           hetareseta[trig][level-1]->setAxisTitle("#eta", 1);
00600 
00601           // relres
00602           sprintf(name,"HLTMuonL%itoL%i_ptrelres",level,level+1);
00603           sprintf(title,"(L%iMuon1/Pt - L%iMuon1/Pt)/(L%iMuon1/Pt)",level,level+1,level+1);         
00604           hptrelres[trig][level-1] = dbe_->book1D(name,title, NBINS, -1.0, 1.0);
00605           sprintf(title,"(1/PtL%i - 1/PtL%i)/(1/PtL%i)",level,level+1,level+1);         
00606           hptrelres[trig][level-1]->setAxisTitle(title, 1);
00607           sprintf(name,"HLTMuonL%itoL%i_etarelres",level,level+1);
00608           sprintf(title,"(L%iMuon#eta - L%iMuon#eta)/L%iMuon#eta",level,level+1,level+1);         
00609           hetarelres[trig][level-1] =dbe_->book1D(name,title, NBINS, -1.0, 1.0);
00610           sprintf(title,"(L%i #eta - L%i #eta)/L%i #eta",level,level+1,level+1);         
00611           hetarelres[trig][level-1]->setAxisTitle(title, 1);
00612           sprintf(name,"HLTMuonL%itoL%i_phirelres",level,level+1);
00613           sprintf(title,"(L%iMuon#phi - L%iMuon#phi)/L%iMuon#phi",level,level+1,level+1);         
00614           hphirelres[trig][level-1] =dbe_->book1D(name,title, NBINS, -1.0, 1.0);
00615           sprintf(title,"(L%i #phi - L%i #phi)/L%i #phi",level,level+1,level+1);         
00616           hphirelres[trig][level-1]->setAxisTitle(title, 1);
00617 
00618           sprintf(name,"HLTMuonL%itoL%i_ptrelrespt",level,level+1);
00619           sprintf(title,"L%i Muon #DeltaPt/Pt vs Pt ",level);         
00620           hptrelrespt[trig][level-1] =dbe_->bookProfile(name,title, NBINS, 0, pt_max,1,-999.,999.,"s");
00621           sprintf(title,"(1/PtL%i - 1/PtL%i)/(1/PtL%i)",level,level+1,level+1);         
00622           hptrelrespt[trig][level-1]->setAxisTitle(title, 2);
00623           hptrelrespt[trig][level-1]->setAxisTitle("Pt", 1);
00624           sprintf(name,"HLTMuonL%itoL%i_phirelresphi",level,level+1);
00625           sprintf(title,"L%i Muon #Delta#phi/#phi vs #phi ",level);         
00626           hphirelresphi[trig][level-1] =dbe_->bookProfile(name,title, NBINS, -3.15, 3.15,1,-999.,999.,"s");
00627           sprintf(title,"(L%i #phi - L%i #phi)/L%i #phi",level,level+1,level+1);         
00628           hphirelresphi[trig][level-1]->setAxisTitle(title, 2);
00629           hphirelresphi[trig][level-1]->setAxisTitle("#phi", 1);
00630           sprintf(name,"HLTMuonL%itoL%i_etarelreseta",level,level+1);
00631           sprintf(title,"L%i Muon #Delta#eta/#eta vs #eta ",level);         
00632           hetarelreseta[trig][level-1] =dbe_->bookProfile(name,title, NBINS,-2.5, 2.5,1,-999.,999.,"s");
00633           sprintf(title,"(L%i #eta - L%i #eta)/L%i #eta",level,level+1,level+1);         
00634           hetarelreseta[trig][level-1]->setAxisTitle(title, 2);
00635           hetarelreseta[trig][level-1]->setAxisTitle("#eta", 1);
00636           // charge conversion
00637           sprintf(name,"HLTMuonL%itoL%i_chargeconvers",level,level+1);
00638           sprintf(title,"L%i Muon charge #rightarrow L%i Muon charge",level,level+1);         
00639           hchargeconv[trig][level-1] =dbe_->book1D(name,title, 4, 0, 4);
00640           hchargeconv[trig][level-1]->setAxisTitle(title, 1);
00641           hchargeconv[trig][level-1]->setBinLabel(1, "- #rightarrow -", 1);
00642           hchargeconv[trig][level-1]->setBinLabel(2, "- #rightarrow +", 1);
00643           hchargeconv[trig][level-1]->setBinLabel(3, "+ #rightarrow -", 1);
00644           hchargeconv[trig][level-1]->setBinLabel(4, "+ #rightarrow +", 1);
00645           // reconstruction fraction with dependence
00646           sprintf(name,"HLTMuonL%itoL%i_fracpt",level,level+1);
00647           sprintf(title,"#ofL%iMuon/#ofL%iMuon",level+1,level);         
00648           hptfrac[trig][level-1] = dbe_->book1D(name,title, 40, 0, pt_max);
00649           hptfrac[trig][level-1]->setAxisTitle("Pt", 1);
00650           sprintf(name,"HLTMuonL%itoL%i_fraceta",level,level+1);
00651           sprintf(title,"#ofL%iMuon/#ofL%iMuon",level+1,level);         
00652           hetafrac[trig][level-1] = dbe_->book1D(name,title, 40, -2.5, 2.5);
00653           hetafrac[trig][level-1]->setAxisTitle("#eta", 1);
00654           sprintf(name,"HLTMuonL%itoL%i_fracphi",level,level+1);
00655           sprintf(title,"#ofL%iMuon/#ofL%iMuon",level+1,level);         
00656           hphifrac[trig][level-1] = dbe_->book1D(name,title, 40, -3.15, 3.15);
00657           hphifrac[trig][level-1]->setAxisTitle("#phi", 1);
00658           if (level  == 1 ){
00659             // res
00660             sprintf(name,"HLTMuonL%itoL3_ptres",level);
00661             sprintf(title,"L%iMuon1/Pt - L%iMuon1/Pt",level,level+2);         
00662             hptres[trig][level+1] = dbe_->book1D(name,title, NBINS, -0.1, 0.1);
00663             sprintf(title,"1/PtL%i - 1/PtL%i",level,level+2);         
00664             hptres[trig][level+1]->setAxisTitle(title, 1);
00665             sprintf(name,"HLTMuonL%itoL3_etares",level);
00666             sprintf(title,"L%iMuon#eta - L3Muon#eta",level);         
00667             hetares[trig][level+1] =dbe_->book1D(name,title, NBINS, -0.1, 0.1);
00668             sprintf(title,"L%i #eta - L3 #eta",level);         
00669             hetares[trig][level+1]->setAxisTitle(title, 1);
00670             sprintf(name,"HLTMuonL%itoL3_phires",level);
00671             sprintf(title,"L%iMuon#phi - L3Muon#phi",level);         
00672             hphires[trig][level+1] =dbe_->book1D(name,title, NBINS, -0.1, 0.1);
00673             sprintf(title,"L%i #phi - L3 #phi",level);         
00674             hphires[trig][level+1]->setAxisTitle(title, 1);
00675 
00676             sprintf(name,"HLTMuonL%itoL3_ptrespt",level);
00677             sprintf(title,"L%i Muon #Delta Pt vs Pt (wrt L3) ",level);         
00678             hptrespt[trig][level+1] =dbe_->bookProfile(name,title, NBINS, 0, pt_max,1,-999.,999.,"s");
00679             sprintf(title,"1/PtL%i - 1/PtL3",level);         
00680             hptrespt[trig][level+1]->setAxisTitle(title, 2);
00681             hptrespt[trig][level+1]->setAxisTitle("Pt", 1);
00682             sprintf(name,"HLTMuonL%itoL3_phiresphi",level);
00683             sprintf(title,"L%i Muon #Delta#phi vs #phi (wrt L3) ",level);         
00684             hphiresphi[trig][level+1] =dbe_->bookProfile(name,title, NBINS, -3.15, 3.15,1,-999.,999.,"s");
00685             sprintf(title,"L%i #phi - L3 #phi",level);         
00686             hphiresphi[trig][level+1]->setAxisTitle(title, 2);
00687             hphiresphi[trig][level+1]->setAxisTitle("#phi", 1);
00688             sprintf(name,"HLTMuonL%itoL3_etareseta",level);
00689             sprintf(title,"L%i Muon #Delta#eta vs #eta (wrt L3) ",level);         
00690             hetareseta[trig][level+1] =dbe_->bookProfile(name,title, NBINS,-2.5, 2.5,1,-999.,999.,"s");
00691             sprintf(title,"L%i #eta - L3 #eta",level);         
00692             hetareseta[trig][level+1]->setAxisTitle(title, 2);
00693             hetareseta[trig][level+1]->setAxisTitle("#eta", 1);
00694 
00695             // relres
00696             sprintf(name,"HLTMuonL%itoL3_ptrelres",level);
00697             sprintf(title,"(L%iMuon1/Pt - L%iMuon1/Pt)/(L%iMuon1/Pt)",level,level+2,level+2); 
00698             hptrelres[trig][level+1] = dbe_->book1D(name,title, NBINS, -1.0, 1.0);
00699             sprintf(title,"(1/PtL%i - 1/PtL3)/(1/PtL3)",level);         
00700             hptrelres[trig][level+1]->setAxisTitle(title, 1);
00701             sprintf(name,"HLTMuonL%itoL3_etarelres",level);
00702             sprintf(title,"(L%iMuon#eta - L3Muon#eta)/L3Muon#eta",level);         
00703             hetarelres[trig][level+1] =dbe_->book1D(name,title, NBINS, -1.0, 1.0);
00704             sprintf(title,"(L%i #eta - L3 #eta)/L3 #eta",level);         
00705             hetarelres[trig][level+1]->setAxisTitle(title, 1);
00706             sprintf(name,"HLTMuonL%itoL3_phirelres",level);
00707             sprintf(title,"(L%iMuon#phi - L3Muon#phi)/L3Muon#phi",level);         
00708             hphirelres[trig][level+1] =dbe_->book1D(name,title, NBINS, -1.0, 1.0);
00709             sprintf(title,"(L%i #phi - L3 #phi)/L3 #phi",level);         
00710             hphirelres[trig][level+1]->setAxisTitle(title, 1);
00711 
00712             sprintf(name,"HLTMuonL%itoL3_ptrelrespt",level);
00713             sprintf(title,"L%i Muon #DeltaPt/Pt vs Pt (wrt L3) ",level);         
00714             hptrelrespt[trig][level+1] =dbe_->bookProfile(name,title, NBINS, 0, pt_max,1,-999.,999.,"s");
00715             sprintf(title,"(1/PtL%i - 1/PtL3)/(1/PtL3)",level);         
00716             hptrelrespt[trig][level+1]->setAxisTitle(title, 2);
00717             hptrelrespt[trig][level+1]->setAxisTitle("Pt", 1);
00718             sprintf(name,"HLTMuonL%itoL3_phirelresphi",level);
00719             sprintf(title,"L%i Muon #Delta#phi/#phi vs #phi (wrt L3) ",level);         
00720             hphirelresphi[trig][level+1] =dbe_->bookProfile(name,title, NBINS, -3.15, 3.15,1,-999.,999.,"s");
00721             sprintf(title,"(L%i #phi - L3 #phi)/L3 #phi",level);         
00722             hphirelresphi[trig][level+1]->setAxisTitle(title, 2);
00723             hphirelresphi[trig][level+1]->setAxisTitle("#phi", 1);
00724             sprintf(name,"HLTMuonL%itoL3_etarelreseta",level);
00725             sprintf(title,"L%i Muon #Delta#eta/#eta vs #eta (wrt L3) ",level);         
00726             hetarelreseta[trig][level+1] =dbe_->bookProfile(name,title, NBINS,-2.5, 2.5,1,-999.,999.,"s");
00727             sprintf(title,"(L%i #eta - L3 #eta)/L3 #eta",level);         
00728             hetarelreseta[trig][level+1]->setAxisTitle(title, 2);
00729             hetarelreseta[trig][level+1]->setAxisTitle("#eta", 1);
00730 
00731             sprintf(name,"HLTMuonL%itoL3_chargeconvers",level);
00732             sprintf(title,"L%i Muon charge #rightarrow L3 Muon charge",level);         
00733             hchargeconv[trig][level+1] =dbe_->book1D(name,title, 4, 0, 4);
00734             hchargeconv[trig][level+1]->setAxisTitle(title, 1);
00735             hchargeconv[trig][level+1]->setBinLabel(1, "- #rightarrow -", 1);
00736             hchargeconv[trig][level+1]->setBinLabel(2, "- #rightarrow +", 1);
00737             hchargeconv[trig][level+1]->setBinLabel(3, "+ #rightarrow -", 1);
00738             hchargeconv[trig][level+1]->setBinLabel(4, "+ #rightarrow +", 1);
00739           }
00740         }
00741       }
00742       if(verbose_)dbe_->showDirStructure();
00743     }
00744     // Muon det id is 2 pushed in bits 28:31
00745     const unsigned int detector_id = 2<<28;
00746     dbe_->tagContents(monitorName_, detector_id);
00747   } 
00748   
00749   for( int trig = 0; trig < nTrigs; trig++ ) {
00750     for( int level = 1; level < 3; ++level ) {
00751       char name[512];
00752       sprintf(name, "DenominatorL%iptTrig%i", level, trig);
00753       _hpt1[trig][level-1] = new TH1D(name, name, 40, 0, 145);
00754       sprintf(name, "NumeratorL%iptTrig%i", level, trig);
00755       _hpt2[trig][level-1] = new TH1D(name, name, 40, 0, 145);
00756       sprintf(name, "DenominatorL%ietaTrig%i", level, trig);
00757       _heta1[trig][level-1] = new TH1D(name, name, 40, -2.5, 2.5);
00758       sprintf(name, "NumeratorL%ietaTrig%i", level, trig);
00759       _heta2[trig][level-1] = new TH1D(name, name, 40, -2.5, 2.5);
00760       sprintf(name, "DenominatorL%iphiTrig%i", level, trig);
00761       _hphi1[trig][level-1] = new TH1D(name, name, 40, -3.15, 3.15);
00762       sprintf(name, "NumeratorL%iphiTrig%i", level, trig);
00763       _hphi2[trig][level-1] = new TH1D(name, name, 40, -3.15, 3.15);
00764     }
00765   }
00766 }
00767 
00768 //--------------------------------------------------------
00769 void HLTMuonDQMSource::beginRun(const edm::Run& r, const edm::EventSetup& context) {
00770   
00771 }
00772 
00773 //--------------------------------------------------------
00774 void HLTMuonDQMSource::beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
00775                                             const edm::EventSetup& context) {
00776   
00777 }
00778 
00779 // ----------------------------------------------------------
00780 void HLTMuonDQMSource::analyze(const edm::Event& iEvent, 
00781                                const edm::EventSetup& iSetup )
00782 {  
00783   if ( !dbe_) return;
00784   counterEvt_++;
00785   if (prescaleEvt_ > 0 && counterEvt_%prescaleEvt_!=0) return;
00786   LogDebug("HLTMuonDQMSource") << " processing conterEvt_: " << counterEvt_ <<std::endl;
00787 
00788   bool trigFired = false;
00789   bool FiredTriggers[NTRIG] = {false};
00790   edm::Handle<edm::TriggerResults> trigResult;
00791   iEvent.getByLabel(TrigResultInput, trigResult);
00792   if( !trigResult.failedToGet() ) {
00793     int ntrigs = trigResult->size();
00794     const edm::TriggerNames & trigName = iEvent.triggerNames(*trigResult);
00795     for( int itrig = 0; itrig != ntrigs; ++itrig) {
00796       //std::cout << "trigName = " << trigName.triggerName(itrig) << " " << itrig << std::endl;
00797       for( unsigned int n = 0; n < (unsigned int)theTriggerBits.size(); n++) { 
00798         if( trigName.triggerIndex(theTriggerBits[n]) == (unsigned int)ntrigs ) continue;
00799         if( trigResult->accept(trigName.triggerIndex(theTriggerBits[n])) ) {
00800             for( unsigned int j = 0; j < (unsigned int)theDirectoryName.size(); j++ ) {
00801               if( theHLTCollectionLevel[n] == theDirectoryName[j] ) FiredTriggers[j] = true;
00802             }
00803             trigFired = true;
00804         }
00805       }
00806     }
00807   }
00808   //else std::cout << "failed to get trigResult!!" << std::endl;
00809   // trigger fired
00810   if( !trigFired ) return;
00811   nTrig_++;
00812 
00813   //get the field
00814   edm::ESHandle<MagneticField> magField;
00815   iSetup.get<IdealMagneticFieldRecord>().get(magField);
00816 
00817   //get the geometry
00818   edm::ESHandle<GlobalTrackingGeometry> glbTrackingGeometry;
00819   iSetup.get<GlobalTrackingGeometryRecord>().get(glbTrackingGeometry);
00820   
00821   edm::Handle<reco::RecoChargedCandidateCollection> l2mucands, l3mucands;
00822   edm::Handle<L2MuonTrajectorySeedCollection> l2seeds; 
00823   edm::Handle<L3MuonTrajectorySeedCollection> l3seeds; 
00824   reco::RecoChargedCandidateCollection::const_iterator cand, cand2, cand3;
00825   
00826   iEvent.getByLabel (l2seedscollectionTag_,l2seeds);
00827   iEvent.getByLabel (l3seedscollectionTag_,l3seeds);
00828   iEvent.getByLabel (l2collectionTag_,l2mucands);
00829   iEvent.getByLabel (l3collectionTag_,l3mucands);
00830 
00831   if( !l2seeds.failedToGet() && l2seeds.isValid() ) {
00832     iEvent.getByLabel (l2collectionTag_,l2mucands);
00833     if( !l2mucands.failedToGet() && l2mucands->size() != 0 ) {
00834       iEvent.getByLabel (l3seedscollectionTag_,l3seeds);
00835       if( !l3seeds.failedToGet() && l3seeds.isValid() ) iEvent.getByLabel (l3collectionTag_,l3mucands);
00836     }
00837   }
00838 
00839   for( int ntrig = 0; ntrig < nTrigs; ntrig++ ) {
00840     if( !FiredTriggers[ntrig] ) continue;
00841     //std::cout << "trigger fired!" << std::endl;
00842     if( !l2seeds.failedToGet() && l2seeds.isValid() ) {
00843       hNMu[ntrig][3]->Fill(l2seeds->size());
00844       L2MuonTrajectorySeedCollection::const_iterator l2seed;
00845       std::map<l1extra::L1MuonParticleRef, int> l1map;
00846       for (l2seed=l2seeds->begin() ; l2seed != l2seeds->end();++l2seed){
00847         PTrajectoryStateOnDet state=l2seed->startingState();
00848         // Transform Trajectory State on Det to a TSOS
00849         TrajectoryStateTransform tsTransform;
00850         DetId seedDetId(state.detId());
00851         const GeomDet* gdet = glbTrackingGeometry->idToDet( seedDetId );
00852         TrajectoryStateOnSurface tsos = tsTransform.transientState(state, &(gdet->surface()), magField.product());
00853         float pt = tsos.globalMomentum().perp();
00854         float eta = tsos.globalPosition().eta();
00855         float phi = tsos.globalPosition().phi();
00856         hcharge[ntrig][3]->Fill(tsos.charge());
00857         hpt[ntrig][3]->Fill(pt);
00858         hphi[ntrig][3]->Fill(phi);
00859         heta[ntrig][3]->Fill(eta);
00860         hetaphi[ntrig][3]->Fill(phi,eta);
00861         hptphi[ntrig][3]->Fill(pt,phi);
00862         hpteta[ntrig][3]->Fill(pt,eta);
00863         l1extra::L1MuonParticleRef l1ref = l2seed->l1Particle();
00864         l1map[l1ref]++;
00865         hseedptres[ntrig][0]->Fill(1/pt - 1/l1ref->pt());
00866         hseedetares[ntrig][0]->Fill(eta - l1ref->eta());
00867         hseedphires[ntrig][0]->Fill(phi - l1ref->phi());
00868         hseedptrelres[ntrig][0]->Fill((1/pt - 1/l1ref->pt())/(1/l1ref->pt()));
00869         hseedetarelres[ntrig][0]->Fill((eta - l1ref->eta())/l1ref->eta());
00870         hseedphirelres[ntrig][0]->Fill((phi - l1ref->phi())/l1ref->phi());
00871 
00872         hcharge[ntrig][0]->Fill(l1ref->charge());
00873         hpt[ntrig][0]->Fill(l1ref->pt());
00874         hphi[ntrig][0]->Fill(l1ref->phi());
00875 
00876         if(hphi[ntrig][0]->getEntries()){
00877           for(int ibin = 1; ibin <= hphi[ntrig][0]->getNbinsX(); ++ibin)
00878             hphi_norm[ntrig][0]->setBinContent(ibin, 
00879                                                hphi[ntrig][0]->getBinContent(ibin)/hphi[ntrig][0]->getEntries());
00880         }
00881         
00882         heta[ntrig][0]->Fill(l1ref->eta());
00883         hetaphi[ntrig][0]->Fill(l1ref->phi(),l1ref->eta());
00884         hptphi[ntrig][0]->Fill(l1ref->pt(),l1ref->phi());
00885         hpteta[ntrig][0]->Fill(l1ref->pt(),l1ref->eta());
00886         hl1quality[ntrig]->Fill(l1ref->gmtMuonCand().quality());
00887         _hpt1[ntrig][0]->Fill(l1ref->pt());
00888         _heta1[ntrig][0]->Fill(l1ref->eta());
00889         _hphi1[ntrig][0]->Fill(l1ref->phi());
00890         if ( !l2mucands.failedToGet() && l2mucands.isValid() ) {
00891           for (cand=l2mucands->begin(); cand!=l2mucands->end(); ++cand) {
00892             reco::TrackRef tk = cand->get<reco::TrackRef>();
00893             edm::RefToBase<TrajectorySeed> seed=tk->seedRef();
00894             if ( (l2seed->startingState()).detId() == (seed->startingState()).detId() ) {
00895               if(tk->pt()*l1ref->pt() != 0 ) {
00896                 hptres[ntrig][0]->Fill(1/l1ref->pt() - 1/tk->pt());
00897                 hptrespt[ntrig][0]->Fill(tk->pt(), 1/l1ref->pt() - 1/tk->pt());
00898                 hptrelres[ntrig][0]->Fill((1/l1ref->pt() - 1/tk->pt())/(1/tk->pt()));
00899                 hptrelrespt[ntrig][0]->Fill(tk->pt(), (1/l1ref->pt() - 1/tk->pt())/(1/tk->pt()));
00900               }
00901               _hpt2[ntrig][0]->Fill(l1ref->pt());
00902               _heta2[ntrig][0]->Fill(l1ref->eta());
00903               _hphi2[ntrig][0]->Fill(l1ref->phi());
00904               hetares[ntrig][0]->Fill(l1ref->eta()-tk->eta());
00905               hetareseta[ntrig][0]->Fill(tk->eta(),l1ref->eta()-tk->eta());
00906               hetarelres[ntrig][0]->Fill((l1ref->eta()-tk->eta())/tk->eta());
00907               hetarelreseta[ntrig][0]->Fill(tk->eta(),(l1ref->eta()-tk->eta())/tk->eta());
00908               hphires[ntrig][0]->Fill(l1ref->phi()-tk->phi());
00909               double dphi=l1ref->phi()-tk->phi();
00910               if (dphi>TMath::TwoPi())dphi-=2*TMath::TwoPi();
00911               else if (dphi<-TMath::TwoPi()) dphi+=TMath::TwoPi();
00912               hphiresphi[ntrig][0]->Fill(tk->phi(),dphi);
00913               hphirelres[ntrig][0]->Fill((l1ref->phi()-tk->phi())/tk->phi());
00914               hphirelresphi[ntrig][0]->Fill(tk->phi(),dphi/tk->phi());
00915               // charge conversion
00916               int chargeconv = -1;
00917               int l1charge = l1ref->charge();
00918               int l2charge = tk->charge();
00919               if( l1charge == -1 && l2charge == -1 ) chargeconv = 0;
00920               else if( l1charge == -1 && l2charge == 1 ) chargeconv = 1;
00921               else if( l1charge == 1 && l2charge == -1 ) chargeconv = 2;
00922               else if( l1charge == 1 && l2charge == 1 ) chargeconv = 3;
00923               hchargeconv[ntrig][0]->Fill(chargeconv);
00924               _hpt1[ntrig][1]->Fill(tk->pt());
00925               _heta1[ntrig][1]->Fill(tk->eta());
00926               _hphi1[ntrig][1]->Fill(tk->phi());
00927               //find the L3 build from this L2
00928               if (!l3mucands.failedToGet() && l3mucands.isValid() ) {
00929                 for (cand=l3mucands->begin(); cand!=l3mucands->end(); ++cand) {
00930                   reco::TrackRef l3tk= cand->get<reco::TrackRef>();
00931                   if( l3tk->seedRef().castTo<edm::Ref<L3MuonTrajectorySeedCollection> > ().isAvailable() ) {
00932                     if (l3tk->seedRef().castTo<edm::Ref<L3MuonTrajectorySeedCollection> >()->l2Track() == tk){
00933                       if(l1ref->pt()*l3tk->pt() != 0 ) {
00934                         hptres[ntrig][2]->Fill(1/l1ref->pt() - 1/l3tk->pt());
00935                         hptrespt[ntrig][2]->Fill(l3tk->pt(), 1/l1ref->pt() - 1/l3tk->pt());
00936                         hptrelres[ntrig][2]->Fill((1/l1ref->pt() - 1/l3tk->pt())/(1/l3tk->pt()));
00937                         hptrelrespt[ntrig][2]->Fill(l3tk->pt(), (1/l1ref->pt() - 1/l3tk->pt())/(1/l3tk->pt()));
00938                       }
00939                       hetares[ntrig][2]->Fill(l1ref->eta()-l3tk->eta());
00940                       hetareseta[ntrig][2]->Fill(l1ref->eta(),l1ref->eta()-l3tk->eta());
00941                       hetarelres[ntrig][2]->Fill((l1ref->eta()-l3tk->eta())/l3tk->eta());
00942                       hetarelreseta[ntrig][2]->Fill(l1ref->eta(),(l1ref->eta()-l3tk->eta())/l3tk->eta());
00943                       hphires[ntrig][2]->Fill(l1ref->phi()-l3tk->phi());
00944                       double dphi=l1ref->phi()-l3tk->phi();
00945                       if (dphi>TMath::TwoPi())dphi-=2*TMath::TwoPi();
00946                       else if (dphi<-TMath::TwoPi()) dphi+=TMath::TwoPi();
00947                       hphiresphi[ntrig][2]->Fill(l3tk->phi(),dphi);
00948                       hphirelres[ntrig][2]->Fill((l1ref->phi()-l3tk->phi())/l3tk->phi());
00949                       hphirelresphi[ntrig][2]->Fill(l3tk->phi(),(dphi)/l3tk->phi());
00950                       // charge conversion
00951                       int chargeconv = -1;
00952                       int l1charge = l1ref->charge();
00953                       int l3charge = l3tk->charge();
00954                       if( l1charge == -1 && l3charge == -1 ) chargeconv = 0;
00955                       else if( l1charge == -1 && l3charge == 1 ) chargeconv = 1;
00956                       else if( l1charge == 1 && l3charge == -1 ) chargeconv = 2;
00957                       else if( l1charge == 1 && l3charge == 1 ) chargeconv = 3;
00958                       hchargeconv[ntrig][2]->Fill(chargeconv);
00959                       _hpt2[ntrig][1]->Fill(tk->pt());
00960                       _heta2[ntrig][1]->Fill(tk->eta());
00961                       _hphi2[ntrig][1]->Fill(tk->phi());
00962                       //break; //plot only once per L2?
00963                     }//if
00964                   }
00965                 }//for
00966               }
00967               break;
00968             }
00969           }
00970         }
00971       }
00972       // mapping
00973       std::map<l1extra::L1MuonParticleRef, int>::iterator it;
00974       for( it = l1map.begin(); it != l1map.end(); it++ ) {
00975           hseedNMuper[ntrig][0]->Fill(it->second);
00976       }
00977       hNMu[ntrig][0]->Fill(l1map.size());
00978     }
00979     //else std::cout << "failed to get l2seed!" << std::endl;
00980 
00981     if (!l3seeds.failedToGet() && l3seeds.isValid() ) {
00982       hNMu[ntrig][4]->Fill(l3seeds->size());
00983       L3MuonTrajectorySeedCollection::const_iterator l3seed;
00984       std::map<reco::TrackRef, int> l2map;
00985       for (l3seed=l3seeds->begin() ; l3seed != l3seeds->end();++l3seed){
00986         PTrajectoryStateOnDet state=l3seed->startingState();
00987         // Transform Trajectory State on Det to a TSOS
00988         TrajectoryStateTransform tsTransform;
00989         DetId seedDetId(state.detId());
00990         const GeomDet* gdet = glbTrackingGeometry->idToDet( seedDetId );
00991         TrajectoryStateOnSurface tsos = tsTransform.transientState(state, &(gdet->surface()), magField.product());
00992 
00993         float pt = tsos.globalMomentum().perp();
00994         float eta = tsos.globalPosition().eta();
00995         float phi = tsos.globalPosition().phi();
00996         hcharge[ntrig][4]->Fill(tsos.charge());
00997         hpt[ntrig][4]->Fill(pt);
00998         hphi[ntrig][4]->Fill(phi);
00999         heta[ntrig][4]->Fill(eta);
01000         hetaphi[ntrig][4]->Fill(phi,eta);
01001         hptphi[ntrig][4]->Fill(pt,phi);
01002         hpteta[ntrig][4]->Fill(pt,eta);
01003 
01004         reco::TrackRef l2tkRef = l3seed->l2Track();
01005         l2map[l2tkRef]++;
01006         hseedptres[ntrig][1]->Fill(1/pt - 1/l2tkRef->pt());
01007         hseedetares[ntrig][1]->Fill(eta - l2tkRef->eta());
01008         hseedphires[ntrig][1]->Fill(phi - l2tkRef->phi());
01009         hseedptrelres[ntrig][1]->Fill((1/pt - 1/l2tkRef->pt())/(1/l2tkRef->pt()));
01010         hseedetarelres[ntrig][1]->Fill((eta - l2tkRef->eta())/l2tkRef->eta());
01011         hseedphirelres[ntrig][1]->Fill((phi - l2tkRef->phi())/l2tkRef->phi());
01012       }
01013       // mapping
01014       std::map<reco::TrackRef, int>::iterator it;
01015       for( it = l2map.begin(); it != l2map.end(); it++ ) {
01016           hseedNMuper[ntrig][1]->Fill(it->second);
01017       }
01018     }
01019     
01020     //else std::cout << "failed to get l3seed!" << std::endl;
01021 
01022     reco::BeamSpot beamSpot;
01023     edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
01024     iEvent.getByLabel("hltOfflineBeamSpot",recoBeamSpotHandle);
01025     if (!recoBeamSpotHandle.failedToGet())  beamSpot = *recoBeamSpotHandle;
01026     
01027     if (!l2mucands.failedToGet() && l2mucands.isValid() ) {
01028       LogDebug("HLTMuonDQMSource") << " filling L2 stuff " << std::endl;
01029       edm::Handle<reco::IsoDepositMap> l2depMap;
01030       if( l2mucands->size() != 0 ) iEvent.getByLabel (l2isolationTag_,l2depMap);
01031       hNMu[ntrig][1]->Fill(l2mucands->size());
01032       for (cand=l2mucands->begin(); cand!=l2mucands->end(); ++cand) {
01033         reco::TrackRef tk = cand->get<reco::TrackRef>();
01034         if (!l2depMap.failedToGet() && l2depMap.isValid() ) {
01035           LogDebug("HLTMuonDQMSource") << " filling L2 Iso stuff " << std::endl;
01036           if ( l2depMap->contains(tk.id()) ){
01037             reco::IsoDepositMap::value_type calDeposit = (*l2depMap)[tk];
01038             double dephlt = calDeposit.depositWithin(coneSize_);
01039             if( dephlt != 0 ) hiso[ntrig][0]->Fill(dephlt);
01040             // 2D plot: cone size vs. dep
01041             double depL2[10];
01042             for( int idep = 0; idep < 10; idep++ ) {
01043                 double conesize = (idep + 1)*coneSize_/10.0;
01044                 depL2[idep] = calDeposit.depositWithin(conesize);
01045                 if( depL2[idep] != 0 ) hL2muonIsoDR[ntrig]->Fill(conesize, depL2[idep]);
01046             }
01047           }
01048         }
01049         
01050         // eta cut
01051         hpt[ntrig][1]->Fill(tk->pt());      
01052         hcharge[ntrig][1]->Fill(tk->charge()); 
01053         if ( tk->charge() != 0 ) {
01054           heta[ntrig][1]->Fill(tk->eta());      
01055           hphi[ntrig][1]->Fill(tk->phi()); 
01056 
01057           if(hphi[ntrig][1]->getEntries()){
01058             for(int ibin = 1; ibin <= hphi[ntrig][1]->getNbinsX(); ++ibin)
01059               hphi_norm[ntrig][1]->setBinContent(ibin, 
01060                                                  hphi[ntrig][1]->getBinContent(ibin)/hphi[ntrig][1]->getEntries());
01061           }
01062           
01063           hetaphi[ntrig][1]->Fill(tk->phi(),tk->eta()); 
01064           hptphi[ntrig][1]->Fill(tk->pt(),tk->phi()); 
01065           hpteta[ntrig][1]->Fill(tk->pt(),tk->eta()); 
01066           const reco::HitPattern& hitp = tk->hitPattern();
01067           hnHits[ntrig][1]->Fill(hitp.numberOfHits()); 
01068           hnValidHits[ntrig]->Fill(hitp.numberOfValidHits()); 
01069           hd0[ntrig][0]->Fill(tk->d0()); 
01070           if (!recoBeamSpotHandle.failedToGet()){
01071             hdr[ntrig][0]->Fill(tk->dxy(beamSpot.position()));  
01072             hdrphi[ntrig][0]->Fill(tk->phi(),tk->dxy(beamSpot.position())); 
01073           } 
01074           hd0phi[ntrig][0]->Fill(tk->phi(),tk->d0()); 
01075           hdz0[ntrig][0]->Fill(tk->dz()); 
01076           hdz0eta[ntrig][0]->Fill(tk->eta(),tk->dz());
01077           hdz[ntrig][0]->Fill(tk->dz(beamSpot.position())); 
01078           hdzeta[ntrig][0]->Fill(tk->eta(),tk->dz(beamSpot.position()));
01079           herr0[ntrig][0]->Fill(tk->error(0)); 
01080           cand2=cand;
01081           ++cand2;
01082           for (; cand2!=l2mucands->end(); cand2++) {
01083             reco::TrackRef tk2=cand2->get<reco::TrackRef>();
01084             if ( tk->charge()*tk2->charge() == -1 ){
01085               double mass=(cand->p4()+cand2->p4()).M();
01086               hdimumass[ntrig][0]->Fill(mass);
01087             }
01088           }
01089         } else edm::LogWarning("HLTMonMuon")<<"stop filling candidate with update@Vtx failure";
01090       }
01091     }
01092     if (!l3mucands.failedToGet() && l3mucands.isValid() ) {
01093       LogDebug("HLTMuonDQMSource") << " filling L3 stuff " << std::endl;
01094       hNMu[ntrig][2]->Fill(l3mucands->size());
01095       edm::Handle<reco::IsoDepositMap> l3depMap;
01096       if( l3mucands->size() != 0 ) iEvent.getByLabel (l3isolationTag_,l3depMap);
01097       for (cand=l3mucands->begin(); cand!=l3mucands->end(); ++cand) {
01098         reco::TrackRef tk = cand->get<reco::TrackRef>();
01099         if (!l3depMap.failedToGet() && l3depMap.isValid() ) {
01100           if ( l3depMap->contains(tk.id()) ){
01101             reco::IsoDepositMap::value_type calDeposit= (*l3depMap)[tk];
01102             double dephlt = calDeposit.depositWithin(coneSize_);
01103             if( dephlt != 0 ) hiso[ntrig][1]->Fill(dephlt);
01104           }
01105         }
01106         // eta cut
01107         hpt[ntrig][2]->Fill(tk->pt());      
01108         heta[ntrig][2]->Fill(tk->eta());      
01109         hphi[ntrig][2]->Fill(tk->phi()); 
01110 
01111         if(hphi[ntrig][2]->getEntries()){
01112           for(int ibin = 1; ibin <= hphi[ntrig][2]->getNbinsX(); ++ibin)
01113             hphi_norm[ntrig][2]->setBinContent(ibin, 
01114                                                hphi[ntrig][2]->getBinContent(ibin)/hphi[ntrig][2]->getEntries());
01115         }
01116 
01117         hetaphi[ntrig][2]->Fill(tk->phi(),tk->eta()); 
01118         hptphi[ntrig][2]->Fill(tk->pt(),tk->phi()); 
01119         hpteta[ntrig][2]->Fill(tk->pt(),tk->eta()); 
01120         const reco::HitPattern& hitp = tk->hitPattern();
01121         hnHits[ntrig][2]->Fill(hitp.numberOfHits()); 
01122         hnTkValidHits[ntrig]->Fill(hitp.numberOfValidTrackerHits()); 
01123         hnMuValidHits[ntrig]->Fill(hitp.numberOfValidMuonHits()); 
01124         hd0[ntrig][1]->Fill(tk->d0()); 
01125         if (!recoBeamSpotHandle.failedToGet()) {
01126           hdr[ntrig][1]->Fill(tk->dxy(beamSpot.position()));
01127           hdrphi[ntrig][1]->Fill(tk->phi(),tk->dxy(beamSpot.position())); 
01128         }
01129         hd0phi[ntrig][1]->Fill(tk->phi(),tk->d0()); 
01130         hdz0[ntrig][1]->Fill(tk->dz()); 
01131         hdz0eta[ntrig][1]->Fill(tk->eta(),tk->dz());
01132         hdz[ntrig][1]->Fill(tk->dz(beamSpot.position())); 
01133         hdzeta[ntrig][1]->Fill(tk->eta(),tk->dz(beamSpot.position()));
01134         herr0[ntrig][1]->Fill(tk->error(0)); 
01135         hcharge[ntrig][2]->Fill(tk->charge()); 
01136         cand2=cand;
01137         ++cand2;
01138         
01139         for (; cand2!=l3mucands->end(); cand2++) {
01140           reco::TrackRef tk2=cand2->get<reco::TrackRef>();
01141           if ( tk->charge()*tk2->charge() == -1 ){
01142             double mass=(cand->p4()+cand2->p4()).M();
01143             hdimumass[ntrig][1]->Fill(mass);
01144           }
01145         }
01146         if( tk->seedRef().castTo<edm::Ref<L3MuonTrajectorySeedCollection> >().isAvailable() ) {
01147           reco::TrackRef l2tk = tk->seedRef().castTo<edm::Ref<L3MuonTrajectorySeedCollection> >()->l2Track();
01148           if(tk->pt()*l2tk->pt() != 0 ) {
01149             hptres[ntrig][1]->Fill(1/l2tk->pt() - 1/tk->pt());
01150             hptrespt[ntrig][1]->Fill(tk->pt(), 1/l2tk->pt() - 1/tk->pt());
01151             hptrelres[ntrig][1]->Fill((1/l2tk->pt() - 1/tk->pt())/(1/tk->pt()));
01152             hptrelrespt[ntrig][1]->Fill(tk->pt(), (1/l2tk->pt() - 1/tk->pt())/(1/tk->pt()));
01153             double pterr = (tk->ptError()/(tk->pt()*tk->pt()));
01154             hptpull[ntrig]->Fill((1/l2tk->pt() - 1/tk->pt())/pterr);
01155             hptpullpt[ntrig]->Fill(tk->pt(), (1/l2tk->pt() - 1/tk->pt())/pterr);
01156           }
01157           hphires[ntrig][1]->Fill(l2tk->phi()-tk->phi());
01158           double dphi=l2tk->phi()-tk->phi();
01159           if (dphi>TMath::TwoPi())dphi-=2*TMath::TwoPi();
01160           else if (dphi<-TMath::TwoPi()) dphi+=TMath::TwoPi();
01161           hphiresphi[ntrig][1]->Fill(tk->phi(),dphi);
01162           hphirelres[ntrig][1]->Fill((l2tk->phi()-tk->phi())/tk->phi());
01163           hphirelresphi[ntrig][1]->Fill(tk->phi(),dphi/tk->phi());
01164           hphipull[ntrig]->Fill(dphi/tk->phiError());
01165           hphipullphi[ntrig]->Fill(tk->phi(), dphi/tk->phiError());
01166           hetares[ntrig][1]->Fill(l2tk->eta()-tk->eta());
01167           hetareseta[ntrig][1]->Fill(tk->eta(),l2tk->eta()-tk->eta());
01168           hetarelres[ntrig][1]->Fill((l2tk->eta()-tk->eta())/tk->eta());
01169           hetarelreseta[ntrig][1]->Fill(tk->eta(),(l2tk->eta()-tk->eta())/tk->eta());
01170           hetapull[ntrig]->Fill((l2tk->eta()-tk->eta())/tk->etaError());
01171           hetapulleta[ntrig]->Fill(tk->eta(),(l2tk->eta()-tk->eta())/tk->etaError());
01172           // charge conversion
01173           int chargeconv = -1;
01174           int l2charge = l2tk->charge();
01175           int l3charge = tk->charge();
01176           if( l2charge == -1 && l3charge == -1 ) chargeconv = 0;
01177           else if( l2charge == -1 && l3charge == 1 ) chargeconv = 1;
01178           else if( l2charge == 1 && l3charge == -1 ) chargeconv = 2;
01179           else if( l2charge == 1 && l3charge == 1 ) chargeconv = 3;
01180           hchargeconv[ntrig][1]->Fill(chargeconv);
01181         }
01182       }
01183     }  
01184     
01185     for( int level = 0; level < 2; level++ ) {  
01186       for( int nbin = 1; nbin < _hpt1[ntrig][level]->GetNbinsX()+1; nbin++ ) {
01187         if( _hpt1[ntrig][level]->GetBinContent(nbin) != 0 ) {
01188           double frac = _hpt2[ntrig][level]->GetBinContent(nbin)/_hpt1[ntrig][level]->GetBinContent(nbin);
01189           double err = sqrt(frac*fabs(1 - frac)/_hpt1[ntrig][level]->GetBinContent(nbin));
01190           hptfrac[ntrig][level]->setBinContent(nbin, frac);
01191           hptfrac[ntrig][level]->setBinError(nbin, err);
01192         }
01193         if( _heta1[ntrig][level]->GetBinContent(nbin) != 0 ) {
01194           double frac = _heta2[ntrig][level]->GetBinContent(nbin)/_heta1[ntrig][level]->GetBinContent(nbin);
01195           double err = sqrt(frac*fabs(1 - frac)/_heta1[ntrig][level]->GetBinContent(nbin));
01196           hetafrac[ntrig][level]->setBinContent(nbin, frac);
01197           hetafrac[ntrig][level]->setBinError(nbin, err);
01198         }
01199         if( _hphi1[ntrig][level]->GetBinContent(nbin) != 0 ) {
01200           double frac = _hphi2[ntrig][level]->GetBinContent(nbin)/_hphi1[ntrig][level]->GetBinContent(nbin);
01201           double err = sqrt(frac*fabs(1 - frac)/_hphi1[ntrig][level]->GetBinContent(nbin));
01202           hphifrac[ntrig][level]->setBinContent(nbin, frac);
01203           hphifrac[ntrig][level]->setBinError(nbin, err);
01204         }
01205         else {
01206           hptfrac[ntrig][level]->setBinContent(nbin, 0.0);
01207           hetafrac[ntrig][level]->setBinContent(nbin, 0.0);
01208           hphifrac[ntrig][level]->setBinContent(nbin, 0.0);
01209           hptfrac[ntrig][level]->setBinError(nbin, 0.0);
01210           hetafrac[ntrig][level]->setBinError(nbin, 0.0);
01211           hphifrac[ntrig][level]->setBinError(nbin, 0.0);
01212         }
01213       }
01214     }
01215   }
01216 
01217 
01218   // Tower
01219   edm::Handle<CaloTowerCollection> caloTower; 
01220   if( !l2mucands.failedToGet() && l2mucands->size() != 0 )
01221     iEvent.getByLabel(edm::InputTag("hltTowerMakerForMuons"), caloTower);
01222   for( int ntrig = 0; ntrig < nTrigs; ntrig++ ) {
01223     if( !FiredTriggers[ntrig] ) continue;
01224     if( caloTower.isValid() ) {
01225       CaloTowerCollection::const_iterator itower;
01226       for( itower = caloTower->begin(); itower != caloTower->end(); ++itower ) {
01227           if( (*itower).et() == 0 ) continue;
01228 
01229           // deltaR with l2muon
01230           if (!l2mucands.failedToGet() && l2mucands.isValid() ) {
01231               for (cand=l2mucands->begin(); cand!=l2mucands->end(); ++cand) {
01232                   reco::TrackRef l2tk= cand->get<reco::TrackRef>();
01233                   double deltaR_l2 = reco::deltaR(*l2tk, (*itower));
01234                   htowerdRL2[ntrig]->Fill(deltaR_l2);
01235               }
01236           }
01237           // deltaR with l3muon
01238           if (!l3mucands.failedToGet() && l3mucands.isValid() ) {
01239               for (cand=l3mucands->begin(); cand!=l3mucands->end(); ++cand) {
01240                   reco::TrackRef l3tk= cand->get<reco::TrackRef>();
01241                   double deltaR_l3 = reco::deltaR(*l3tk, (*itower));
01242                   htowerdRL3[ntrig]->Fill(deltaR_l3);
01243               }
01244           }
01245           htowerEt[ntrig]->Fill((*itower).et());
01246           htowerPhi[ntrig]->Fill((*itower).phi());
01247           htowerEta[ntrig]->Fill((*itower).eta());
01248           
01249           // energy contributions from different detectors
01250           // energy in HO ("outerEnergy")is not included in "hadEnergy"
01251           htowerOuterEnergy[ntrig]->Fill((*itower).outerEnergy());
01252           htowerHadEnergy[ntrig]->Fill((*itower).hadEnergy());
01253           htowerEmEnergy[ntrig]->Fill((*itower).emEnergy());
01254 
01255           htowerOuterEt[ntrig]->Fill((*itower).outerEt());
01256           htowerHadEt[ntrig]->Fill((*itower).hadEt());
01257           htowerEmEt[ntrig]->Fill((*itower).emEt());
01258 
01259           // 2D plots
01260           htowerPhiOuterEt[ntrig]->Fill((*itower).phi(), (*itower).outerEt());
01261           htowerPhiHadEt[ntrig]->Fill((*itower).phi(), (*itower).hadEt());
01262           htowerPhiEmEt[ntrig]->Fill((*itower).phi(), (*itower).emEt());
01263           htowerEtaOuterEt[ntrig]->Fill((*itower).eta(), (*itower).outerEt());
01264           htowerEtaHadEt[ntrig]->Fill((*itower).eta(), (*itower).hadEt());
01265           htowerEtaEmEt[ntrig]->Fill((*itower).eta(), (*itower).emEt());
01266       }
01267     }
01268   }
01269   
01270 }
01271 
01272 
01273 
01274 
01275 //--------------------------------------------------------
01276 void HLTMuonDQMSource::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
01277                                           const edm::EventSetup& context) {
01278 }
01279 //--------------------------------------------------------
01280 void HLTMuonDQMSource::endRun(const edm::Run& r, const edm::EventSetup& context){
01281 }
01282 //--------------------------------------------------------
01283 void HLTMuonDQMSource::endJob(){
01284   edm::LogInfo("HLTMonMuon") << "analyzed " << counterEvt_ << " events";
01285   //std::cout << "analyzed = " << counterEvt_ << " , triggered = " << nTrig_ << std::endl;
01286   
01287   
01288   //if (outputFile_.size() != 0 && dbe_)
01289   //dbe_->save(outputFile_);
01290   
01291   return;
01292 }