CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DQM/Physics/src/QcdUeDQM.cc

Go to the documentation of this file.
00001 
00002 /*
00003     This is the DQM code for UE physics plots
00004     11/12/2009 Sunil Bansal
00005 */
00006 #include "DQM/Physics/src/QcdUeDQM.h"
00007 #include "DataFormats/Common/interface/TriggerResults.h"
00008 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00009 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00010 #include "DataFormats/SiPixelDetId/interface/PXBDetId.h"
00011 #include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
00012 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"
00013 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00014 #include "DataFormats/VertexReco/interface/Vertex.h"
00015 #include "DQMServices/Core/interface/DQMStore.h"
00016 #include "DQMServices/Core/interface/MonitorElement.h"
00017 #include "FWCore/Framework/interface/Event.h"
00018 #include "FWCore/Framework/interface/EventSetup.h"
00019 #include "FWCore/Framework/interface/ESHandle.h"
00020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022 #include "FWCore/ServiceRegistry/interface/Service.h"
00023 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00024 #include "CommonTools/RecoAlgos/src/TrackToRefCandidate.h"
00025 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00026 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetType.h"
00027 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
00028 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00029 #include "Geometry/TrackerGeometryBuilder/interface/RectangularPixelTopology.h" 
00030 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
00031 #include "AnalysisDataFormats/TrackInfo/interface/TrackInfo.h"
00032 #include "AnalysisDataFormats/TrackInfo/interface/TrackInfoTrackAssociation.h"
00033 #include "DataFormats/TrackReco/interface/Track.h"
00034 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00035 #include "DataFormats/Candidate/interface/CandMatchMap.h"
00036 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00037 #include "DataFormats/Math/interface/deltaPhi.h"
00038 #include <TString.h>
00039 #include <TMath.h>
00040 #include <TH1F.h>
00041 #include <TH2F.h>
00042 #include <TH3F.h>
00043 #include <TProfile.h>
00044 using namespace std;
00045 using namespace edm;
00046 
00047 #define CP(level) \
00048   if (level>=verbose_)
00049 
00050 struct deleter {
00051   void operator()(TH3F *&h) { delete h; h=0;}
00052 };
00053 
00054 
00055 //--------------------------------------------------------------------------------------------------
00056 QcdUeDQM::QcdUeDQM(const ParameterSet &parameters) :
00057   hltResName_(parameters.getUntrackedParameter<string>("hltTrgResults")),
00058   verbose_(parameters.getUntrackedParameter<int>("verbose",3)),
00059   tgeo_(0),
00060   theDbe_(0),
00061   repSumMap_(0),
00062   repSummary_(0),
00063   h2TrigCorr_(0),
00064   ptMin_(parameters.getParameter<double>("ptMin")),
00065   minRapidity_(parameters.getParameter<double>("minRapidity")),
00066   maxRapidity_(parameters.getParameter<double>("maxRapidity")),
00067   tip_(parameters.getParameter<double>("tip")),
00068   lip_(parameters.getParameter<double>("lip")),
00069   diffvtxbs_(parameters.getParameter<double>("diffvtxbs")),
00070   ptErr_pt_(parameters.getParameter<double>("ptErr_pt")),
00071   vtxntk_(parameters.getParameter<double>("vtxntk")),
00072   minHit_(parameters.getParameter<int>("minHit")),
00073   pxlLayerMinCut_(parameters.getParameter<double>("pxlLayerMinCut")),
00074   requirePIX1_(parameters.getParameter<bool>("requirePIX1")),
00075   min3DHit_(parameters.getParameter<int>("min3DHit")),
00076   maxChi2_(parameters.getParameter<double>("maxChi2")),
00077   bsuse_(parameters.getParameter<bool>("bsuse")),
00078   allowTriplets_(parameters.getParameter<bool>("allowTriplets")),
00079   bsPos_(parameters.getParameter<double>("bsPos")),
00080   caloJetLabel_(parameters.getUntrackedParameter<edm::InputTag>("caloJetTag")),
00081   chargedJetLabel_(parameters.getUntrackedParameter<edm::InputTag>("chargedJetTag")),
00082   trackLabel_(parameters.getUntrackedParameter<edm::InputTag>("trackTag")),
00083   vtxLabel_(parameters.getUntrackedParameter<edm::InputTag>("vtxTag")),
00084   bsLabel_(parameters.getParameter<edm::InputTag>("beamSpotTag")) 
00085 {
00086   // Constructor.
00087   std::vector<std::string> quality = parameters.getParameter<std::vector<std::string> >("quality");
00088   for (unsigned int j=0;j<quality.size();j++) quality_.push_back(reco::TrackBase::qualityByName(quality[j])); 
00089   std::vector<std::string> algorithm = parameters.getParameter<std::vector<std::string> >("algorithm");
00090   for (unsigned int j=0;j<algorithm.size();j++) algorithm_.push_back(reco::TrackBase::algoByName(algorithm[j])); 
00091 
00092   if (parameters.exists("hltTrgNames"))
00093     hltTrgNames_ = parameters.getUntrackedParameter<vector<string> >("hltTrgNames");
00094 
00095   if (parameters.exists("hltProcNames"))
00096      hltProcNames_ = parameters.getUntrackedParameter<vector<string> >("hltProcNames");
00097   else {
00098     //     hltProcNames_.push_back("FU");
00099      hltProcNames_.push_back("HLT");
00100   }
00101 
00102  
00103 }
00104 
00105 //--------------------------------------------------------------------------------------------------
00106 QcdUeDQM::~QcdUeDQM()
00107 {
00108   // Destructor.
00109 
00110 
00111 }
00112 
00113 //--------------------------------------------------------------------------------------------------
00114 void QcdUeDQM::analyze(const Event &iEvent, const EventSetup &iSetup) 
00115 {
00116   if( ! isHltConfigSuccessful_ ) return;
00117 
00118   // Analyze the given event.
00119    
00120    edm::Handle<reco::BeamSpot> beamSpot;
00121    bool ValidBS_ = iEvent.getByLabel(bsLabel_,beamSpot);
00122    if(!ValidBS_)return;
00123 
00124    edm::Handle<reco::TrackCollection>tracks ;
00125    bool ValidTrack_ = iEvent.getByLabel(trackLabel_,tracks);
00126    if(!ValidTrack_)return;
00127 
00128    edm::Handle<reco::CandidateView> trkJets;
00129    bool ValidTrackJet_ = iEvent.getByLabel (chargedJetLabel_,trkJets);
00130    if(!ValidTrackJet_)return;
00131    
00132    edm::Handle<reco::CaloJetCollection> calJets;
00133    bool ValidCaloJet_ = iEvent.getByLabel (caloJetLabel_,calJets);
00134    if(!ValidCaloJet_)return;
00135  
00136    edm::Handle< reco::VertexCollection > vertexColl;
00137    bool ValidVtxColl_ = iEvent.getByLabel (vtxLabel_, vertexColl);
00138    if(!ValidVtxColl_)return;
00139 
00140    reco::TrackCollection tracks_sort = *tracks;
00141    std::sort(tracks_sort.begin(), tracks_sort.end(), PtSorter()); 
00142 
00143   // get tracker geometry
00144   ESHandle<TrackerGeometry> trackerHandle;
00145   iSetup.get<TrackerDigiGeometryRecord>().get(trackerHandle);
00146   tgeo_ = trackerHandle.product();
00147   if (!tgeo_)return;
00148   selected_.clear(); 
00149   fillHltBits(iEvent);
00150   // select good tracks
00151   if(fillVtxPlots(vertexColl))
00152   {
00153   fill1D(hNevts_,1);
00154   for(reco::TrackCollection::const_iterator Trk = tracks_sort.begin(); Trk != tracks_sort.end(); ++Trk)
00155    {
00156     
00157    if ( trackSelection(*Trk,beamSpot.product(),vtx1,vertexColl->size()) ) selected_.push_back( & * Trk );   
00158    }
00159  
00160       
00161     fillpTMaxRelated(selected_);
00162     fillChargedJetSpectra(trkJets);  
00163     fillCaloJetSpectra(calJets);
00164     fillUE_with_MaxpTtrack(selected_);
00165     if(trkJets->size() > 0)fillUE_with_ChargedJets(selected_,trkJets); 
00166     if(calJets->size()>0)fillUE_with_CaloJets(selected_,calJets);
00167   
00168  }
00169 
00170 }
00171 
00172 //--------------------------------------------------------------------------------------------------
00173 void QcdUeDQM::beginJob() 
00174 {
00175   // Begin job and setup the DQM store.
00176 
00177   theDbe_ = Service<DQMStore>().operator->();
00178   if (!theDbe_)return;
00179   
00180   //  theDbe_->setCurrentFolder("Physics/QcdUe");
00181   
00182 }
00183 
00184 //--------------------------------------------------------------------------------------------------
00185 void QcdUeDQM::beginLuminosityBlock(const LuminosityBlock &l, 
00186                                        const EventSetup &iSetup)
00187 {
00188   if( ! isHltConfigSuccessful_ ) return;
00189 
00190   // At the moment, nothing needed to be done.
00191 }
00192 
00193 //--------------------------------------------------------------------------------------------------
00194 void QcdUeDQM::beginRun(const Run &run, const EventSetup &iSetup)
00195 {
00196 
00197  // indicating change of HLT cfg at run boundries
00198  // for HLTConfigProvider::init()
00199  bool isHltCfgChange = false;
00200  isHltConfigSuccessful_ = false; // init
00201 
00202  string teststr;
00203  for(size_t i=0; i<hltProcNames_.size(); ++i) {
00204    if (i>0) 
00205      teststr += ", ";
00206    teststr += hltProcNames_.at(i);
00207    if ( hltConfig.init( run, iSetup, hltProcNames_.at(i), isHltCfgChange ) ) {
00208      isHltConfigSuccessful_ = true;
00209      hltUsedResName_ = hltResName_;
00210      if (hltResName_.find(':')==string::npos)
00211        hltUsedResName_ += "::";
00212      else 
00213        hltUsedResName_ += ":";
00214      hltUsedResName_ += hltProcNames_.at(i);
00215      break;
00216    }
00217  }
00218  
00219  if ( ! isHltConfigSuccessful_ )return;
00220 
00221   // setup "Any" bit
00222   hltTrgBits_.clear();
00223   hltTrgBits_.push_back(-1);
00224   hltTrgDeci_.clear();
00225   hltTrgDeci_.push_back(true);
00226   hltTrgUsedNames_.clear();
00227   hltTrgUsedNames_.push_back("Any");
00228 
00229   // figure out relation of trigger name to trigger bit and store used trigger names/bits
00230   for(size_t i=0;i<hltTrgNames_.size();++i) {
00231     const string &n1(hltTrgNames_.at(i));
00232     bool found = 0;
00233     for(size_t j=0;j<hltConfig.size();++j) {
00234       const string &n2(hltConfig.triggerName(j));
00235       if (n2==n1) {
00236         hltTrgBits_.push_back(j);
00237         hltTrgUsedNames_.push_back(n1);
00238         hltTrgDeci_.push_back(false);
00239         found = 1;
00240         break;
00241       }
00242     }      
00243     if (!found) {
00244       CP(2) cout<<"Could not find trigger bit"<<endl ;
00245     }
00246   }
00247  
00248   // book monitoring histograms
00249   createHistos();
00250   isHltConfigSuccessful_ = true;
00251 
00252 }
00253 
00254 //--------------------------------------------------------------------------------------------------
00255 void QcdUeDQM::book1D(std::vector<MonitorElement*> &mes, 
00256                          const std::string &name, const std::string &title, 
00257                          int nx, double x1, double x2, bool sumw2, bool sbox)
00258 {
00259   // Book 1D histos.
00260 
00261   for(size_t i=0;i<hltTrgUsedNames_.size();++i) {
00262     std::string folderName = "Physics/QcdUe/" + hltTrgUsedNames_.at(i);
00263     theDbe_->setCurrentFolder(folderName);
00264     MonitorElement *e = theDbe_->book1D(Form("%s_%s",name.c_str(),hltTrgUsedNames_.at(i).c_str()),
00265                                         Form("%s: %s",hltTrgUsedNames_.at(i).c_str(), title.c_str()), 
00266                                         nx, x1, x2);
00267     TH1 *h1 = e->getTH1();
00268     if (sumw2) {
00269       if( 0 == h1->GetSumw2N() ) { // protect against re-summing (would cause exception)
00270         h1->Sumw2();
00271       }
00272     }
00273     h1->SetStats(sbox);
00274     mes.push_back(e);
00275   }
00276 }
00277 
00278 //--------------------------------------------------------------------------------------------------
00279 void QcdUeDQM::book2D(std::vector<MonitorElement*> &mes, 
00280                          const std::string &name, const std::string &title, 
00281                          int nx, double x1, double x2, int ny, double y1, double y2, 
00282                          bool sumw2, bool sbox)
00283 {
00284   // Book 2D histos.
00285 
00286   for(size_t i=0;i<hltTrgUsedNames_.size();++i) {
00287     std::string folderName = "Physics/QcdUe/" + hltTrgUsedNames_.at(i);
00288     theDbe_->setCurrentFolder(folderName);
00289     MonitorElement *e = theDbe_->book2D(Form("%s_%s",name.c_str(),hltTrgUsedNames_.at(i).c_str()),
00290                                         Form("%s: %s",hltTrgUsedNames_.at(i).c_str(), title.c_str()), 
00291                                         nx, x1, x2, ny, y1, y2);
00292     TH1 *h1 = e->getTH1();
00293     if (sumw2) {
00294       if( 0 == h1->GetSumw2N() ) { // protect against re-summing (would cause exception)
00295         h1->Sumw2();
00296       }
00297     }
00298     h1->SetStats(sbox);
00299     mes.push_back(e);
00300   }
00301 }
00302 
00303 //--------------------------------------------------------------------------------------------------
00304 void QcdUeDQM::bookProfile(std::vector<MonitorElement*> &mes, 
00305                          const std::string &name, const std::string &title, 
00306                          int nx, double x1, double x2,  double y1, double y2, 
00307                          bool sumw2, bool sbox)
00308 {
00309   // Book Profile histos.
00310 
00311   for(size_t i=0;i<hltTrgUsedNames_.size();++i) {
00312     std::string folderName = "Physics/QcdUe/" + hltTrgUsedNames_.at(i);
00313     theDbe_->setCurrentFolder(folderName);
00314     MonitorElement *e = theDbe_->bookProfile(Form("%s_%s",name.c_str(),hltTrgUsedNames_.at(i).c_str()),
00315                                         Form("%s: %s",hltTrgUsedNames_.at(i).c_str(), title.c_str()), 
00316                                         nx, x1, x2, y1, y2," ");
00317     mes.push_back(e);
00318   }
00319 }
00320 //--------------------------------------------------------------------------------------------------
00321 void QcdUeDQM::createHistos()
00322 {
00323   // Book histograms if needed.
00324 
00325 
00326   if (1) {
00327     theDbe_->setCurrentFolder("Physics/EventInfo/");
00328     repSumMap_  = theDbe_->book2D("reportSummaryMap","reportSummaryMap",1,0,1,1,0,1);
00329     repSummary_ = theDbe_->bookFloat("reportSummary");
00330   }
00331    
00332    theDbe_->setCurrentFolder("Physics/QcdUe");
00333 
00334   if (1) {
00335     const int Nx = hltTrgUsedNames_.size();
00336     const double x1 = -0.5;
00337     const double x2 = Nx-0.5;
00338     h2TrigCorr_ = theDbe_->book2D("h2TriCorr","Trigger bit x vs y;y&&!x;x&&y",Nx,x1,x2,Nx,x1,x2);
00339     for(size_t i=1;i<=hltTrgUsedNames_.size();++i) {
00340       h2TrigCorr_->setBinLabel(i,hltTrgUsedNames_.at(i-1),1);
00341       h2TrigCorr_->setBinLabel(i,hltTrgUsedNames_.at(i-1),2);
00342     }
00343     TH1 *h = h2TrigCorr_->getTH1();
00344     if (h)
00345       h->SetStats(0);
00346   }
00347   book1D(hNevts_,"hNevts","number of events",2,0,2);
00348   book1D(hNtrackerLayer_,"hNtrackerLayer","number of tracker layers;multiplicity",20,-0.5,19.5 );
00349   book1D(hNtrackerPixelLayer_,"hNtrackerPixelLayer","number of pixel layers;multiplicity",10,-0.5,9.5 );
00350   book1D(hNtrackerStripPixelLayer_,"hNtrackerStripPixelLayer","number of strip + pixel layers;multiplicity",30,-0.5,39.5 );
00351   book1D(hRatioPtErrorPt_,"hRatioPtErrorPt","ratio of pT error and track pT",25,0.,5.);
00352   book1D(hTrkPt_,"hTrkPt","pT of all tracks",50,0.,50.);
00353   book1D(hTrkEta_,"hTrkEta","eta of all tracks",40,-4.,4.);
00354   book1D(hTrkPhi_,"hTrkPhi","phi of all tracks",40,-4.,4.);
00355   book1D(hRatioDxySigmaDxyBS_,"hRatioDxySigmaDxyBS","ratio of transverse impact parameter and its significance wrt beam spot",60,-10.,10);
00356   book1D(hRatioDxySigmaDxyPV_,"hRatioDxySigmaDxyPV","ratio of transverse impact parameter and its significance wrt PV",60,-10.,10);
00357   book1D(hRatioDzSigmaDzBS_,"hRatioDzSigmaDzBS","ratio of longitudinal impact parameter and its significance wrt beam spot",80,-20.,20);
00358   book1D(hRatioDzSigmaDzPV_,"hRatioDzSigmaDzPV","ratio of longitudinal impact parameter and its significance wrt PV",80,-20.,20);
00359   book1D(hTrkChi2_,"hTrkChi2","track chi2",30,0.,30);
00360   book1D(hTrkNdof_,"hTrkNdof","track NDOF",100,0,100);
00361 
00362   book1D(hNgoodTrk_,"hNgoodTrk","number of good tracks",50,-0.5,49.5);
00363 
00364   book1D(hGoodTrkPt500_,"hGoodTrkPt500","pT of all good tracks with pT > 500 MeV",50,0.,50.);
00365   book1D(hGoodTrkEta500_,"hGoodTrkEta500","eta of all good tracks pT > 500 MeV",40,-4.,4.);
00366   book1D(hGoodTrkPhi500_,"hGoodTrkPhi500","phi of all good tracks pT > 500 MeV",40,-4.,4.);
00367 
00368   book1D(hGoodTrkPt900_,"hGoodTrkPt900","pT of all good tracks with pT > 900 MeV",50,0.,50.);
00369   book1D(hGoodTrkEta900_,"hGoodTrkEta900","eta of all good tracks pT > 900 MeV",40,-4.,4.);
00370   book1D(hGoodTrkPhi900_,"hGoodTrkPhi900","phi of all good tracks pT > 900 MeV",40,-4.,4.);
00371 
00372   book1D(hNvertices_,"hNvertices","number of vertices",5,-0.5,4.5);
00373   book1D(hVertex_z_,"hVertex_z","z position of vertex; z[cm]",100,-20,20);
00374   book1D(hVertex_y_,"hVertex_y","y position of vertex; y[cm]",100,-5,5);
00375   book1D(hVertex_x_,"hVertex_x","x position of vertex; x[cm]",100,-5,5);
00376 
00377   book1D(hBeamSpot_z_,"hBeamSpot_z","z position of beamspot; z[cm]",100,-20,20);
00378   book1D(hBeamSpot_y_,"hBeamSpot_y","y position of beamspot; y[cm]",50,-10,10);
00379   book1D(hBeamSpot_x_,"hBeamSpot_x","x position of beamspot; x[cm]",50,-10,10);
00380 
00381 
00382   if (1) {
00383     const int Nx = 25;
00384     const double x1 = 0.0;
00385     const double x2 = 50.0;
00386     book1D(hLeadingTrack_pTSpectrum_,"hLeadingTrack_pTSpectrum","pT spectrum of leading track;pT(GeV/c)",Nx,x1,x2);
00387     book1D(hLeadingCaloJet_pTSpectrum_,"hLeadingCalo_pTSpectrum","pT spectrum of leading calo jet;pT(GeV/c)",Nx,x1,x2);
00388     book1D(hLeadingChargedJet_pTSpectrum_,"hLeadingChargedJet_pTSpectrum","pT spectrum of leading track jet;pT(GeV/c)",Nx,x1,x2);
00389     
00390   }
00391   
00392   if (1) {
00393     const int Nx = 24;
00394     const double x1 = -4.;
00395     const double x2 =  4.;
00396     book1D(hLeadingTrack_phiSpectrum_,"hLeadingTrack_phiSpectrum","#phi spectrum of leading track;#phi",Nx,x1,x2);
00397     book1D(hLeadingCaloJet_phiSpectrum_,"hLeadingCaloJet_phiSpectrum","#phi spectrum of leading calo jet;#phi",Nx,x1,x2);
00398     book1D(hLeadingChargedJet_phiSpectrum_,"hLeadingChargedJet_phiSpectrum","#phi spectrum of leading track jet;#phi",Nx,x1,x2);
00399 
00400   }
00401   
00402   if (1) {
00403     const int Nx = 24;
00404     const double x1 = -4.;
00405     const double x2 =  4.;
00406     book1D(hLeadingTrack_etaSpectrum_,"hLeadingTrack_etaSpectrum","#eta spectrum of leading track;#eta",Nx,x1,x2);
00407     book1D(hLeadingCaloJet_etaSpectrum_,"hLeadingCaloJet_etaSpectrum","#eta spectrum of leading calo jet;#eta",Nx,x1,x2);
00408     book1D(hLeadingChargedJet_etaSpectrum_,"hLeadingChargedJet_etaSpectrum","#eta spectrum of leading track jet;#eta",Nx,x1,x2);
00409 
00410   }
00411 
00412 
00413 if (1) {
00414     const int Nx = 75;
00415     const double x1 = 0.0;
00416     const double x2 = 75.0;
00417     const double y1 = 0.;
00418     const double y2 = 10.;
00419     bookProfile(hdNdEtadPhi_pTMax_Toward500_,"hdNdEtadPhi_pTMax_Toward500", 
00420                  "Average number of tracks (pT > 500 MeV) in toward region vs leading track pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00421     bookProfile(hdNdEtadPhi_pTMax_Transverse500_,"hdNdEtadPhi_pTMax_Transverse500", 
00422                  "Average number of tracks (pT > 500 MeV) in transverse region vs leading track pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00423     bookProfile(hdNdEtadPhi_pTMax_Away500_,"hdNdEtadPhi_pTMax_Away500", 
00424                  "Average number of tracks (pT > 500 MeV) in away region vs leading track pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00425  
00426     bookProfile(hdNdEtadPhi_caloJet_Toward500_,"hdNdEtadPhi_caloJet_Toward500", 
00427                  "Average number of tracks (pT > 500 MeV) in toward region vs leading calo jet pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00428     bookProfile(hdNdEtadPhi_caloJet_Transverse500_,"hdNdEtadPhi_caloJet_Transverse500", 
00429                  "Average number of tracks (pT > 500 MeV) in transverse region vs leading calo jet pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00430     bookProfile(hdNdEtadPhi_caloJet_Away500_,"hdNdEtadPhi_caloJet_Away500", 
00431                  "Average number of tracks (pT > 500 MeV) in away region vs leading calo jet pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);   
00432   
00433     bookProfile(hdNdEtadPhi_trackJet_Toward500_,"hdNdEtadPhi_trackJet_Toward500", 
00434                  "Average number of tracks (pT > 500 MeV) in toward region vs leading track jet pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2);
00435     bookProfile(hdNdEtadPhi_trackJet_Transverse500_,"hdNdEtadPhi_trackJet_Transverse500", 
00436                  "Average number of tracks (pT > 500 MeV) in transverse region vs leading track jet pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00437     bookProfile(hdNdEtadPhi_trackJet_Away500_,"hdNdEtadPhi_trackJet_Away500", 
00438                  "Average number of tracks (pT > 500 MeV) in away region vs leading track jet pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00439 
00440 
00441  
00442     bookProfile(hpTSumdEtadPhi_pTMax_Toward500_,"hpTSumdEtadPhi_pTMax_Toward500", 
00443                  "Average number of tracks (pT > 500 MeV) in toward region vs leading track pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00444     bookProfile(hpTSumdEtadPhi_pTMax_Transverse500_,"hpTSumdEtadPhi_pTMax_Transverse500", 
00445                  "Average number of tracks (pT > 500 MeV) in transverse region vs leading track pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00446     bookProfile(hpTSumdEtadPhi_pTMax_Away500_,"hpTSumdEtadPhi_pTMax_Away500", 
00447                  "Average number of tracks (pT > 500 MeV) in away region vs leading track pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00448  
00449     bookProfile(hpTSumdEtadPhi_caloJet_Toward500_,"hpTSumdEtadPhi_caloJet_Toward500", 
00450                  "Average number of tracks (pT > 500 MeV) in toward region vs leading calo jet pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00451     bookProfile(hpTSumdEtadPhi_caloJet_Transverse500_,"hpTSumdEtadPhi_caloJet_Transverse500", 
00452                  "Average number of tracks (pT > 500 MeV) in transverse region vs leading calo jet pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00453     bookProfile(hpTSumdEtadPhi_caloJet_Away500_,"hpTSumdEtadPhi_caloJet_Away500", 
00454                  "Average number of tracks (pT > 500 MeV) in away region vs leading calo jet pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);   
00455   
00456     bookProfile(hpTSumdEtadPhi_trackJet_Toward500_,"hpTSumdEtadPhi_trackJet_Toward500", 
00457                  "Average number of tracks (pT > 500 MeV) in toward region vs leading track jet pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00458     bookProfile(hpTSumdEtadPhi_trackJet_Transverse500_,"hpTSumdEtadPhi_trackJet_Transverse500", 
00459                  "Average number of tracks (pT > 500 MeV) in transverse region vs leading track jet pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00460     bookProfile(hpTSumdEtadPhi_trackJet_Away500_,"hpTSumdEtadPhi_trackJet_Away500", 
00461                  "Average number of tracks (pT > 500 MeV) in away region vs leading track jet pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00462 
00463    
00464    bookProfile(hdNdEtadPhi_pTMax_Toward900_,"hdNdEtadPhi_pTMax_Toward900",
00465                  "Average number of tracks (pT > 900 MeV) in toward region vs leading track pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00466     bookProfile(hdNdEtadPhi_pTMax_Transverse900_,"hdNdEtadPhi_pTMax_Transverse900",
00467                  "Average number of tracks (pT > 900 MeV) in transverse region vs leading track pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00468     bookProfile(hdNdEtadPhi_pTMax_Away900_,"hdNdEtadPhi_pTMax_Away900",
00469                  "Average number of tracks (pT > 900 MeV) in away region vs leading track pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00470 
00471     bookProfile(hdNdEtadPhi_caloJet_Toward900_,"hdNdEtadPhi_caloJet_Toward900",
00472                  "Average number of tracks (pT > 900 MeV) in toward region vs leading calo jet pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00473     bookProfile(hdNdEtadPhi_caloJet_Transverse900_,"hdNdEtadPhi_caloJet_Transverse900",
00474                  "Average number of tracks (pT > 900 MeV) in transverse region vs leading calo jet pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00475     bookProfile(hdNdEtadPhi_caloJet_Away900_,"hdNdEtadPhi_caloJet_Away900",
00476                  "Average number of tracks (pT > 900 MeV) in away region vs leading calo jet pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00477 
00478     bookProfile(hdNdEtadPhi_trackJet_Toward900_,"hdNdEtadPhi_trackJet_Toward900",
00479                  "Average number of tracks (pT > 900 MeV) in toward region vs leading track jet pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2);
00480     bookProfile(hdNdEtadPhi_trackJet_Transverse900_,"hdNdEtadPhi_trackJet_Transverse900",
00481                  "Average number of tracks (pT > 900 MeV) in transverse region vs leading track jet pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00482     bookProfile(hdNdEtadPhi_trackJet_Away900_,"hdNdEtadPhi_trackJet_Away900",
00483                  "Average number of tracks (pT > 900 MeV) in away region vs leading track jet pT;pT(GeV/c);dN/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00484 
00485 
00486 
00487     bookProfile(hpTSumdEtadPhi_pTMax_Toward900_,"hpTSumdEtadPhi_pTMax_Toward900",
00488                  "Average number of tracks (pT > 900 MeV) in toward region vs leading track pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00489     bookProfile(hpTSumdEtadPhi_pTMax_Transverse900_,"hpTSumdEtadPhi_pTMax_Transverse900",
00490                  "Average number of tracks (pT > 900 MeV) in transverse region vs leading track pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00491     bookProfile(hpTSumdEtadPhi_pTMax_Away900_,"hpTSumdEtadPhi_pTMax_Away900",
00492                  "Average number of tracks (pT > 900 MeV) in away region vs leading track pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00493 
00494     bookProfile(hpTSumdEtadPhi_caloJet_Toward900_,"hpTSumdEtadPhi_caloJet_Toward900",
00495                  "Average number of tracks (pT > 900 MeV) in toward region vs leading calo jet pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00496     bookProfile(hpTSumdEtadPhi_caloJet_Transverse900_,"hpTSumdEtadPhi_caloJet_Transverse900",
00497                  "Average number of tracks (pT > 900 MeV) in transverse region vs leading calo jet pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00498     bookProfile(hpTSumdEtadPhi_caloJet_Away900_,"hpTSumdEtadPhi_caloJet_Away900",
00499                  "Average number of tracks (pT > 900 MeV) in away region vs leading calo jet pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00500 
00501     bookProfile(hpTSumdEtadPhi_trackJet_Toward900_,"hpTSumdEtadPhi_trackJet_Toward900",
00502                  "Average number of tracks (pT > 900 MeV) in toward region vs leading track jet pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00503     bookProfile(hpTSumdEtadPhi_trackJet_Transverse900_,"hpTSumdEtadPhi_trackJet_Transverse900",
00504                  "Average number of tracks (pT > 900 MeV) in transverse region vs leading track jet pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00505     bookProfile(hpTSumdEtadPhi_trackJet_Away900_,"hpTSumdEtadPhi_trackJet_Away900",
00506                  "Average number of tracks (pT > 900 MeV) in away region vs leading track jet pT;pT(GeV/c);dpTSum/d#eta d#phi",Nx,x1,x2,y1,y2,0,0);
00507  
00508    
00509   }
00510 
00511 if (1) {
00512     const int Nx = 20;
00513     const double x1 = 0.0;
00514     const double x2 = 20.0;
00515 
00516         book1D(hChargedJetMulti_,"hChargedJetMulti","Charged jet multiplicity;multiplicities",Nx,x1,x2);
00517         book1D(hCaloJetMulti_,"hCaloJetMulti","Calo jet multiplicity;multiplicities",Nx,x1,x2);
00518 
00519   }
00520 
00521 
00522 if (1) {
00523     const int Nx = 60;
00524     const double x1 = -180.0;
00525     const double x2 = 180.0;
00526 
00527         book1D(hdPhi_maxpTTrack_tracks_,"hdPhi_maxpTTrack_tracks","delta phi between leading tracks and other tracks;#Delta#phi(leading track-track)",Nx,x1,x2);
00528         book1D(hdPhi_caloJet_tracks_,"hdPhi_caloJet_tracks","delta phi between leading calo jet  and tracks;#Delta#phi(leading calo jet-track)",Nx,x1,x2);
00529         book1D(hdPhi_chargedJet_tracks_,"hdPhi_chargedJet_tracks","delta phi between leading charged jet  and tracks;#Delta#phi(leading charged jet-track)",Nx,x1,x2);
00530 
00531 }
00532             
00533 
00534 }
00535 
00536 //--------------------------------------------------------------------------------------------------
00537 void QcdUeDQM::endJob(void) 
00538 {
00539 }
00540 
00541 //--------------------------------------------------------------------------------------------------
00542 
00543 void QcdUeDQM::endLuminosityBlock(const LuminosityBlock &l, 
00544                                      const EventSetup &iSetup)
00545 {
00546   if( ! isHltConfigSuccessful_ ) return;
00547 
00548   // Update various histograms.
00549 
00550   repSummary_->Fill(1.);
00551   repSumMap_->Fill(0.5,0.5,1.);
00552 
00553 }
00554 
00555 //--------------------------------------------------------------------------------------------------
00556 
00557 void QcdUeDQM::endRun(const Run &, const EventSetup &)
00558 {
00559   if( ! isHltConfigSuccessful_ ) return;
00560 
00561   // End run, cleanup. TODO: can this be called several times in DQM???
00562 
00563 }
00564 
00565 //--------------------------------------------------------------------------------------------------
00566 void QcdUeDQM::fill1D(std::vector<TH1F*> &hs, double val, double w)
00567 {
00568   // Loop over histograms and fill if trigger has fired.
00569 
00570   for(size_t i=0;i<hs.size();++i) {
00571     if (!hltTrgDeci_.at(i))
00572       continue;
00573     hs.at(i)->Fill(val,w);
00574   }
00575 }
00576 
00577 //--------------------------------------------------------------------------------------------------
00578 void QcdUeDQM::fill1D(std::vector<MonitorElement*> &mes, double val, double w)
00579 {
00580   // Loop over histograms and fill if trigger has fired.
00581 
00582   for(size_t i=0;i<mes.size();++i) {
00583     if (!hltTrgDeci_.at(i))
00584       continue;
00585     mes.at(i)->Fill(val,w);
00586   }
00587 }
00588 
00589 //--------------------------------------------------------------------------------------------------
00590 void QcdUeDQM::setLabel1D(std::vector<MonitorElement*> &mes)
00591 {
00592   // Loop over histograms and fill if trigger has fired.
00593   string cut[5] = {"Nevt","vtx!=bmspt","Zvtx<10cm","pT>1GeV","trackFromVtx"};
00594   for(size_t i=0;i<mes.size();++i) {
00595     if (!hltTrgDeci_.at(i))
00596       continue;
00597     for(size_t j = 1;j < 6;j++)mes.at(i)->setBinLabel(j,cut[j-1],1);
00598   }
00599 }
00600 
00601 //--------------------------------------------------------------------------------------------------
00602 void QcdUeDQM::fill2D(std::vector<TH2F*> &hs, double valx, double valy, double w)
00603 {
00604   // Loop over histograms and fill if trigger has fired.
00605 
00606   for(size_t i=0;i<hs.size();++i) {
00607     if (!hltTrgDeci_.at(i))
00608       continue;
00609     hs.at(i)->Fill(valx, valy ,w);
00610   }
00611 }
00612 
00613 //--------------------------------------------------------------------------------------------------
00614 void QcdUeDQM::fill2D(std::vector<MonitorElement*> &mes, double valx, double valy, double w)
00615 {
00616   // Loop over histograms and fill if trigger has fired.
00617 
00618   for(size_t i=0;i<mes.size();++i) {
00619     if (!hltTrgDeci_.at(i))
00620       continue;
00621     mes.at(i)->Fill(valx, valy ,w);
00622   }
00623 }
00624 //--------------------------------------------------------------------------------------------------
00625 void QcdUeDQM::fillProfile(std::vector<TProfile*> &hs, double valx, double valy, double w)
00626 {
00627   // Loop over histograms and fill if trigger has fired.
00628 
00629   for(size_t i=0;i<hs.size();++i) {
00630     if (!hltTrgDeci_.at(i))
00631       continue;
00632     hs.at(i)->Fill(valx, valy ,w);
00633   }
00634 }
00635 
00636 //--------------------------------------------------------------------------------------------------
00637 void QcdUeDQM::fillProfile(std::vector<MonitorElement*> &mes, double valx, double valy, double w)
00638 {
00639   // Loop over histograms and fill if trigger has fired.
00640 
00641   for(size_t i=0;i<mes.size();++i) {
00642     if (!hltTrgDeci_.at(i))
00643       continue;
00644    const double y = valy*w; 
00645     mes.at(i)->Fill(valx, y);
00646   }
00647 }
00648 
00649 //--------------------------------------------------------------------------------------------------
00650 bool QcdUeDQM::trackSelection(const reco::Track &trk, const reco::BeamSpot* bs, const reco::Vertex vtx, int sizevtx )
00651 {
00652 //-------------Fill basic histograms---------
00653 
00654 
00655 //-------------------------------------------
00656 
00657  bool goodTrk = false;
00658 
00659  if(sizevtx!=1) return 0;    //selection events with only a vertex
00660  if(vtx.z()-bs->z0()==0) return 0;   //selection events with good vertex
00661  vtxntk_=vtxntk_-1;
00662     if(vtx.tracksSize()<= vtxntk_) return 0;    //selection evets with vertex recostructed with at least vtxntk  tracks
00663 
00664  //Fill basic information of all the tracks
00665   fill1D(hNtrackerLayer_,trk.hitPattern().trackerLayersWithMeasurement());
00666   fill1D(hNtrackerPixelLayer_,trk.hitPattern().pixelLayersWithMeasurement());
00667   fill1D(hNtrackerStripPixelLayer_,(trk.hitPattern().pixelLayersWithMeasurement() +  trk.hitPattern().numberOfValidStripLayersWithMonoAndStereo()));
00668   fill1D(hRatioPtErrorPt_,(trk.ptError()/trk.pt()));
00669   fill1D(hTrkPt_,trk.pt());
00670   fill1D(hTrkEta_,trk.eta());  
00671   fill1D(hTrkPhi_,trk.phi());
00672   fill1D(hRatioDxySigmaDxyBS_,(trk.dxy(bs->position())/trk.dxyError()));
00673   fill1D(hRatioDxySigmaDxyPV_,(trk.dxy(vtx.position())/trk.dxyError()));
00674   fill1D(hRatioDzSigmaDzBS_,(trk.dz(bs->position())/trk.dzError()));
00675   fill1D(hRatioDzSigmaDzPV_,(trk.dz(vtx.position())/trk.dzError()));
00676   fill1D(hTrkChi2_,trk.normalizedChi2());
00677   fill1D(hTrkNdof_,trk.ndof());   
00678 
00679   fill1D(hBeamSpot_x_,bs->x0());
00680   fill1D(hBeamSpot_y_,bs->y0()); 
00681   fill1D(hBeamSpot_z_,bs->z0());
00682  
00683  //number of layers
00684  bool layerMinCutbool=false;
00685     if (trk.hitPattern().trackerLayersWithMeasurement() >= minHit_ ||
00686                 (trk.hitPattern().trackerLayersWithMeasurement()==3 && trk.hitPattern().pixelLayersWithMeasurement()==3 && allowTriplets_))
00687       layerMinCutbool=true;
00688 
00689 
00690   //number of pixel layers
00691  bool pxlLayerMinCutbool=false;
00692     if (trk.hitPattern().pixelLayersWithMeasurement() >=pxlLayerMinCut_) pxlLayerMinCutbool=true;
00693 
00694 
00695  // cut on the hits in pixel layers
00696  bool hasPIX1 = false;
00697     if (requirePIX1_) {
00698       const reco::HitPattern& p = trk.hitPattern();
00699       for (int i=0; i<p.numberOfHits(); i++) {
00700         uint32_t hit = p.getHitPattern(i);
00701         if (p.validHitFilter(hit) && p.pixelHitFilter(hit) && p.getLayer(hit)==1) hasPIX1 = true;
00702       }
00703     }else hasPIX1 = true;
00704  
00705  // cut on the pT error
00706  bool ptErrorbool=false; 
00707     if (trk.ptError()/trk.pt() < ptErr_pt_ || 
00708         (trk.hitPattern().trackerLayersWithMeasurement()==3 && trk.hitPattern().pixelLayersWithMeasurement()==3 && allowTriplets_)) ptErrorbool=true; 
00709  // quality cut
00710  bool quality_ok = true;  
00711  if (quality_.size()!=0) {
00712       quality_ok = false;
00713       for (unsigned int i = 0; i<quality_.size();++i) {
00714         if (trk.quality(quality_[i])){
00715           quality_ok = true;
00716           break;
00717         }
00718       }
00719     }
00720  //-----
00721  bool algo_ok = true;
00722     if (algorithm_.size()!=0) {
00723       if (std::find(algorithm_.begin(),algorithm_.end(),trk.algo())==algorithm_.end()) algo_ok = false;
00724     }
00725  
00726 
00727  if(bsuse_==1)
00728       {
00729     if(hasPIX1 &&  pxlLayerMinCutbool && layerMinCutbool &&  (trk.hitPattern().pixelLayersWithMeasurement() +  trk.hitPattern().numberOfValidStripLayersWithMonoAndStereo()) >= min3DHit_ && ptErrorbool && fabs(trk.pt()) >= ptMin_ &&  trk.eta() >= minRapidity_ && trk.eta() <= maxRapidity_ &&  fabs(trk.dxy(bs->position())/trk.dxyError()) < tip_ &&  fabs(trk.dz(bs->position())/trk.dzError()) < lip_  &&  trk.normalizedChi2()<=maxChi2_ &&  quality_ok &&  algo_ok)goodTrk=true ;
00730       }
00731 
00732     if(bsuse_==0)
00733      {
00734        if(hasPIX1 &&  pxlLayerMinCutbool &&  layerMinCutbool &&  (trk.hitPattern().pixelLayersWithMeasurement() +  trk.hitPattern().numberOfValidStripLayersWithMonoAndStereo())  >= min3DHit_ && ptErrorbool && fabs(trk.pt()) >= ptMin_ && trk.eta() >= minRapidity_ && trk.eta() <= maxRapidity_ && fabs(trk.dxy(vtx.position())/trk.dxyError()) < tip_ && fabs(trk.dz(vtx.position())/trk.dzError()) < lip_  && trk.normalizedChi2()<=maxChi2_ && quality_ok &&  algo_ok)goodTrk=true;
00735      
00736      }
00737 
00738   return goodTrk;
00739 
00740  }
00741 //--------------------------------------------------------------------------------------------------
00742 bool  QcdUeDQM::fillVtxPlots( const edm::Handle< reco::VertexCollection > vtxColl)
00743 {
00744   const reco::VertexCollection theVertices = *(vtxColl.product());
00745   bool goodVtx = false;
00746   fill1D(hNvertices_,theVertices.size()); 
00747     for (reco::VertexCollection::const_iterator vertexIt = theVertices.begin(); vertexIt != theVertices.end(); ++vertexIt) 
00748       {
00749         fill1D(hVertex_z_,vertexIt->z());
00750         fill1D(hVertex_y_,vertexIt->y());
00751         fill1D(hVertex_x_,vertexIt->x());
00752 
00753         if(fabs(vertexIt->z()) < diffvtxbs_)
00754          {
00755          goodVtx = true;
00756          vtx1=(*vertexIt);
00757          
00758          break;
00759          }
00760       } // Loop over vertcies
00761    return goodVtx;
00762 }
00763 //--------------------------------------------------------------------------------------------------
00764 void QcdUeDQM::fillpTMaxRelated(const std::vector<const reco::Track *> &track)
00765  {
00766    fill1D(hNgoodTrk_,track.size());
00767    if(track.size()>0)
00768    {
00769    fill1D(hLeadingTrack_pTSpectrum_,track[0]->pt());
00770    fill1D(hLeadingTrack_phiSpectrum_,track[0]->phi());
00771    fill1D(hLeadingTrack_etaSpectrum_,track[0]->eta());
00772    }
00773      for(size_t i = 0; i < track.size(); i++)
00774        {
00775         fill1D(hGoodTrkPt500_,track[i]->pt());
00776         fill1D(hGoodTrkEta500_,track[i]->eta());
00777         fill1D(hGoodTrkPhi500_,track[i]->phi());
00778         if(track[i]->pt() > 0.9)
00779         {
00780         fill1D(hGoodTrkPt900_,track[i]->pt());
00781         fill1D(hGoodTrkEta900_,track[i]->eta());
00782         fill1D(hGoodTrkPhi900_,track[i]->phi());
00783         }
00784         }
00785                      
00786  }
00787 
00788 
00789 void QcdUeDQM::fillChargedJetSpectra(const edm::Handle<reco::CandidateView> trackJets)
00790 {
00791   fill1D(hChargedJetMulti_,trackJets->size());
00792   for( reco::CandidateView::const_iterator f  = trackJets->begin();  f != trackJets->end(); f++) 
00793     {
00794       if(f != trackJets->begin())continue;
00795       fill1D(hLeadingChargedJet_pTSpectrum_,f->pt());
00796       fill1D(hLeadingChargedJet_etaSpectrum_,f->eta());
00797       fill1D(hLeadingChargedJet_phiSpectrum_,f->phi());
00798     } 
00799         
00800 }
00801 
00802 void QcdUeDQM::fillCaloJetSpectra(const edm::Handle<reco::CaloJetCollection> caloJets)
00803 {
00804   fill1D(hCaloJetMulti_,caloJets->size());
00805    for( reco::CaloJetCollection::const_iterator f  = caloJets->begin();  f != caloJets->end(); f++)
00806      {
00807        if(f != caloJets->begin())continue;
00808        fill1D(hLeadingCaloJet_pTSpectrum_,f->pt()); 
00809        fill1D(hLeadingCaloJet_etaSpectrum_,f->eta());
00810        fill1D(hLeadingCaloJet_phiSpectrum_,f->phi());
00811      }
00812    
00813 }
00814 
00815 /*
00816  weight for transverse/toward/away region = 0.12
00817  
00818 
00819 */
00820 
00821 void QcdUeDQM::fillUE_with_MaxpTtrack(const std::vector<const reco::Track*>  &track)
00822 {
00823 double w = 0.119;          
00824 //double w = 1.;
00825 double nTrk500_TransReg = 0;
00826 double nTrk500_AwayReg = 0;
00827 double nTrk500_TowardReg = 0;
00828  
00829 double pTSum500_TransReg = 0;
00830 double pTSum500_AwayReg = 0;
00831 double pTSum500_TowardReg = 0;
00832 
00833 
00834 double nTrk900_TransReg = 0;
00835 double nTrk900_AwayReg = 0;
00836 double nTrk900_TowardReg = 0;
00837 
00838 double pTSum900_TransReg = 0;
00839 double pTSum900_AwayReg = 0;
00840 double pTSum900_TowardReg = 0;
00841    if(track.size() > 0) 
00842     {
00843      if(track[0]->pt() > 1.)
00844          {
00845             for(size_t i = 1; i < track.size();i++)
00846                  {
00847                         
00848                        double dphi = (180./PI)*(deltaPhi(track[0]->phi(),track[i]->phi()));
00849                        fill1D(hdPhi_maxpTTrack_tracks_,dphi);
00850                        if(fabs(dphi)>60. && fabs(dphi)<120.)
00851                          {
00852                                pTSum500_TransReg =  pTSum500_TransReg + track[i]->pt();     
00853                                nTrk500_TransReg++;
00854                                if(track[i]->pt() > 0.9)
00855                                {
00856                                pTSum900_TransReg =  pTSum900_TransReg + track[i]->pt();
00857                                nTrk900_TransReg++;
00858                                }
00859                          }            
00860                         
00861                        if(fabs(dphi)>120. && fabs(dphi)<180.)
00862                          {
00863                                pTSum500_AwayReg =  pTSum500_AwayReg + track[i]->pt();   
00864                                nTrk500_AwayReg++;
00865                                 if(track[i]->pt() > 0.9)
00866                                 {
00867                                 pTSum900_AwayReg =  pTSum900_AwayReg + track[i]->pt();
00868                                 nTrk900_AwayReg++;
00869 
00870                                 } 
00871                          } 
00872                        
00873                        if(fabs(dphi)<60.)
00874                          {
00875                                pTSum500_TowardReg =  pTSum500_TowardReg + track[i]->pt();
00876                                nTrk500_TowardReg++;
00877                                if(track[i]->pt() > 0.9)
00878                                {
00879                                pTSum900_TowardReg =  pTSum900_TowardReg + track[i]->pt();
00880                                nTrk900_TowardReg++;
00881                                } 
00882                          }           
00883                      } // track loop 
00884                  }// leading track
00885              // non empty collection
00886                fillProfile(hdNdEtadPhi_pTMax_Toward500_, track[0]->pt(),nTrk500_TowardReg,w);
00887                fillProfile(hdNdEtadPhi_pTMax_Transverse500_, track[0]->pt(),nTrk500_TransReg,w);
00888                fillProfile(hdNdEtadPhi_pTMax_Away500_, track[0]->pt(),nTrk500_AwayReg,w);
00889 
00890                fillProfile(hpTSumdEtadPhi_pTMax_Toward500_,track[0]->pt() ,pTSum500_TowardReg,w);
00891                fillProfile(hpTSumdEtadPhi_pTMax_Transverse500_,track[0]->pt(),pTSum500_TransReg,w);
00892                fillProfile(hpTSumdEtadPhi_pTMax_Away500_, track[0]->pt(),pTSum500_AwayReg,w);
00893 
00894                fillProfile(hdNdEtadPhi_pTMax_Toward900_, track[0]->pt(),nTrk900_TowardReg,w);
00895                fillProfile(hdNdEtadPhi_pTMax_Transverse900_, track[0]->pt(),nTrk900_TransReg,w);
00896                fillProfile(hdNdEtadPhi_pTMax_Away900_, track[0]->pt(),nTrk900_AwayReg,w);
00897 
00898                fillProfile(hpTSumdEtadPhi_pTMax_Toward900_,track[0]->pt() ,pTSum900_TowardReg,w);
00899                fillProfile(hpTSumdEtadPhi_pTMax_Transverse900_,track[0]->pt(),pTSum900_TransReg,w);
00900                fillProfile(hpTSumdEtadPhi_pTMax_Away900_, track[0]->pt(),pTSum900_AwayReg,w);
00901      }
00902 }
00903 
00904 void QcdUeDQM::fillUE_with_ChargedJets(const std::vector<const reco::Track *>  &track, const edm::Handle<reco::CandidateView> &trackJets)
00905 {
00906 double w = 0.119;
00907 double nTrk500_TransReg = 0;
00908 double nTrk500_AwayReg = 0;
00909 double nTrk500_TowardReg = 0;
00910   
00911 double pTSum500_TransReg = 0;
00912 double pTSum500_AwayReg = 0;
00913 double pTSum500_TowardReg = 0;
00914 
00915 
00916 double nTrk900_TransReg = 0;
00917 double nTrk900_AwayReg = 0;
00918 double nTrk900_TowardReg = 0;
00919 
00920 double pTSum900_TransReg = 0;
00921 double pTSum900_AwayReg = 0;
00922 double pTSum900_TowardReg = 0;
00923 
00924    if(!(trackJets->empty()) && (trackJets->begin())->pt() > 1.)
00925          {
00926          double jetPhi = (trackJets->begin())->phi();
00927            for(size_t i = 0; i < track.size();i++)
00928                    {
00929                          double dphi = (180./PI)*(deltaPhi(jetPhi,track[i]->phi()));
00930                          fill1D(hdPhi_chargedJet_tracks_,dphi);
00931                          if(fabs(dphi)>60. && fabs(dphi)<120.)
00932                            {
00933                                  pTSum500_TransReg =  pTSum500_TransReg + track[i]->pt();
00934                                  nTrk500_TransReg++;
00935                                  if(track[i]->pt() > 0.9)
00936                                  {
00937                                  pTSum900_TransReg =  pTSum900_TransReg + track[i]->pt();
00938                                  nTrk900_TransReg++;
00939                                  }
00940                            }
00941                         
00942                          if(fabs(dphi)>120. && fabs(dphi)<180.)
00943                            {
00944                                  pTSum500_AwayReg =  pTSum500_AwayReg + track[i]->pt();
00945                                  nTrk500_AwayReg++;
00946                                   if(track[i]->pt() > 0.9)
00947                                  {
00948                                  pTSum900_AwayReg =  pTSum900_AwayReg + track[i]->pt();
00949                                  nTrk900_AwayReg++;
00950                                  }
00951                            }
00952                          if(fabs(dphi)<60.)
00953                            {
00954                                  pTSum500_TowardReg =  pTSum500_TowardReg + track[i]->pt();
00955                                  nTrk500_TowardReg++;
00956                                   if(track[i]->pt() > 0.9)
00957                                  {
00958                                  pTSum900_TowardReg =  pTSum900_TowardReg + track[i]->pt();
00959                                  nTrk900_TowardReg++;
00960                                  } 
00961                            }
00962                        }// tracks loop 
00963 
00964                    }// leading track jet
00965                  
00966                  fillProfile(hdNdEtadPhi_trackJet_Toward500_, (trackJets->begin())->pt(),nTrk500_TowardReg,w);
00967                  fillProfile(hdNdEtadPhi_trackJet_Transverse500_, (trackJets->begin())->pt(),nTrk500_TransReg,w);
00968                  fillProfile(hdNdEtadPhi_trackJet_Away500_, (trackJets->begin())->pt(),nTrk500_AwayReg,w);
00969                  
00970                  fillProfile(hpTSumdEtadPhi_trackJet_Toward500_, (trackJets->begin())->pt(),pTSum500_TowardReg,w);
00971                  fillProfile(hpTSumdEtadPhi_trackJet_Transverse500_, (trackJets->begin())->pt(),pTSum500_TransReg,w);
00972                  fillProfile(hpTSumdEtadPhi_trackJet_Away500_, (trackJets->begin())->pt(),pTSum500_AwayReg,w);
00973 
00974                  fillProfile(hdNdEtadPhi_trackJet_Toward900_, (trackJets->begin())->pt(),nTrk900_TowardReg,w);
00975                  fillProfile(hdNdEtadPhi_trackJet_Transverse900_, (trackJets->begin())->pt(),nTrk900_TransReg,w);
00976                  fillProfile(hdNdEtadPhi_trackJet_Away900_, (trackJets->begin())->pt(),nTrk900_AwayReg,w);
00977 
00978                  fillProfile(hpTSumdEtadPhi_trackJet_Toward900_, (trackJets->begin())->pt(),pTSum900_TowardReg,w);
00979                  fillProfile(hpTSumdEtadPhi_trackJet_Transverse900_, (trackJets->begin())->pt(),pTSum900_TransReg,w);
00980                  fillProfile(hpTSumdEtadPhi_trackJet_Away900_, (trackJets->begin())->pt(),pTSum900_AwayReg,w);  
00981 }
00982 
00983 void QcdUeDQM:: fillUE_with_CaloJets(const std::vector<const reco::Track *>  &track, const edm::Handle<reco::CaloJetCollection> &caloJets)
00984 {
00985 double w = 0.119;
00986 double nTrk500_TransReg = 0;
00987 double nTrk500_AwayReg = 0;
00988 double nTrk500_TowardReg = 0;
00989                  
00990 double pTSum500_TransReg = 0;
00991 double pTSum500_AwayReg = 0;
00992 double pTSum500_TowardReg = 0;
00993 
00994 double nTrk900_TransReg = 0;
00995 double nTrk900_AwayReg = 0;
00996 double nTrk900_TowardReg = 0;
00997 
00998 double pTSum900_TransReg = 0;
00999 double pTSum900_AwayReg = 0;
01000 double pTSum900_TowardReg = 0;
01001     if(!(caloJets->empty()) && (caloJets->begin())->pt() > 1.)
01002           {
01003             double jetPhi = (caloJets->begin())->phi();
01004              for(size_t i = 0; i < track.size();i++)
01005                    {
01006                          double dphi = (180./PI)*(deltaPhi(jetPhi,track[i]->phi()));
01007                          fill1D(hdPhi_caloJet_tracks_,dphi);
01008                          if(fabs(dphi)>60. && fabs(dphi)<120.)
01009                            {
01010                                  pTSum500_TransReg =  pTSum500_TransReg + track[i]->pt();
01011                                  nTrk500_TransReg++;
01012                                  if(track[i]->pt() > 0.9)
01013                                  {
01014                                  pTSum900_TransReg =  pTSum900_TransReg + track[i]->pt();
01015                                  nTrk900_TransReg++;
01016                                  }
01017                            }
01018                          if(fabs(dphi)>120. && fabs(dphi)<180.)
01019                            {
01020                                  pTSum500_AwayReg =  pTSum500_AwayReg + track[i]->pt();
01021                                  nTrk500_AwayReg++;
01022                                  if(track[i]->pt() > 0.9)
01023                                  {
01024                                  pTSum900_AwayReg =  pTSum900_AwayReg + track[i]->pt();
01025                                  nTrk900_AwayReg++;
01026                                  }
01027                            }
01028                          if(fabs(dphi)<60.)
01029                            {
01030                                  pTSum500_TowardReg =  pTSum500_TowardReg + track[i]->pt();
01031                                  nTrk500_TowardReg++;
01032                                  if(track[i]->pt() > 0.9)
01033                                  {
01034                                  pTSum900_TowardReg =  pTSum900_TowardReg + track[i]->pt();
01035                                  nTrk900_TowardReg++; 
01036                                  }
01037                            }
01038                        }// tracks loop 
01039 
01040                    }// leading calo jet
01041                  fillProfile(hdNdEtadPhi_caloJet_Toward500_, (caloJets->begin())->pt(),nTrk500_TowardReg,w);
01042                  fillProfile(hdNdEtadPhi_caloJet_Transverse500_, (caloJets->begin())->pt(),nTrk500_TransReg,w);
01043                  fillProfile(hdNdEtadPhi_caloJet_Away500_, (caloJets->begin())->pt(),nTrk500_AwayReg,w);
01044                    
01045                  fillProfile(hpTSumdEtadPhi_caloJet_Toward500_, (caloJets->begin())->pt(),pTSum500_TowardReg,w);
01046                  fillProfile(hpTSumdEtadPhi_caloJet_Transverse500_, (caloJets->begin())->pt(),pTSum500_TransReg,w);
01047                  fillProfile(hpTSumdEtadPhi_caloJet_Away500_, (caloJets->begin())->pt(),pTSum500_AwayReg,w);
01048 
01049                  fillProfile(hdNdEtadPhi_caloJet_Toward900_, (caloJets->begin())->pt(),nTrk900_TowardReg,w);
01050                  fillProfile(hdNdEtadPhi_caloJet_Transverse900_, (caloJets->begin())->pt(),nTrk900_TransReg,w);
01051                  fillProfile(hdNdEtadPhi_caloJet_Away900_, (caloJets->begin())->pt(),nTrk900_AwayReg,w);
01052 
01053                  fillProfile(hpTSumdEtadPhi_caloJet_Toward900_, (caloJets->begin())->pt(),pTSum900_TowardReg,w);
01054                  fillProfile(hpTSumdEtadPhi_caloJet_Transverse900_, (caloJets->begin())->pt(),pTSum900_TransReg,w);
01055                  fillProfile(hpTSumdEtadPhi_caloJet_Away900_, (caloJets->begin())->pt(),pTSum900_AwayReg,w);
01056 
01057                  
01058 }
01059 
01060 void QcdUeDQM::fillHltBits(const Event &iEvent)
01061 {
01062   // Fill HLT trigger bits.
01063 
01064   Handle<TriggerResults> triggerResultsHLT;
01065   getProduct(hltUsedResName_, triggerResultsHLT, iEvent);
01066 
01067   for(size_t i=0;i<hltTrgBits_.size();++i) {
01068     if (hltTrgBits_.at(i)<0) 
01069       continue; //ignore unknown trigger 
01070     size_t tbit = hltTrgBits_.at(i);
01071     if (tbit<triggerResultsHLT->size()) {
01072       hltTrgDeci_[i] = triggerResultsHLT->accept(tbit);
01073   }
01074  }
01075   // fill correlation histogram
01076   for(size_t i=0;i<hltTrgBits_.size();++i) {
01077     if (hltTrgDeci_.at(i))
01078       h2TrigCorr_->Fill(i,i);
01079     for(size_t j=i+1;j<hltTrgBits_.size();++j) {
01080       if (hltTrgDeci_.at(i) && hltTrgDeci_.at(j))
01081         h2TrigCorr_->Fill(i,j);
01082       if (hltTrgDeci_.at(i) && !hltTrgDeci_.at(j))
01083         h2TrigCorr_->Fill(j,i);
01084     }
01085   }
01086 }
01087 
01088 
01089 
01090 //--------------------------------------------------------------------------------------------------
01091