CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/DQM/HLTEvF/plugins/HLTOniaSource.cc

Go to the documentation of this file.
00001 /*
00002  Description: [one line class summary]
00003 
00004  Implementation:
00005      [Notes on implementation]
00006 */
00007 // Original Author: Anna Cimmino
00008 
00009 #include "../interface/HLTOniaSource.h"
00010 //FWCore
00011 #include "FWCore/ServiceRegistry/interface/Service.h"
00012 //DataFormats
00013 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
00014 #include "DataFormats/MuonReco/interface/Muon.h"
00015 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00016 #include "DataFormats/Candidate/interface/Candidate.h"
00017 #include "DataFormats/Math/interface/LorentzVector.h"
00018 #include "DataFormats/HLTReco/interface/TriggerEventWithRefs.h"
00019 //#include "DataFormats/TrackReco/interface/Track.h"
00020 
00021 //HLTrigger
00022 #include "HLTrigger/HLTanalyzers/interface/JetUtil.h"
00023 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
00024 
00025 HLTOniaSource::HLTOniaSource(const edm::ParameterSet& pset){
00026 
00027   edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Constructor";
00028  
00029   //HLTrigger Path Names
00030   std::vector<std::string> myTriggerPaths;
00031   myTriggerPaths.push_back("HLT_Mu0_Track0_Jpsi");
00032   myTriggerPaths.push_back("HLT_Mu3_Track0_Jpsi");
00033   myTriggerPaths.push_back("HLT_Mu5_Track0_Jpsi");
00034   triggerPath_ = pset.getUntrackedParameter<std::vector<std::string> >("TriggerPathNames",myTriggerPaths);
00035 
00036   //Tag for Onia Muons
00037   std::vector<edm::InputTag> myOniaMuonTags;
00038                                          
00039   myOniaMuonTags.push_back(edm::InputTag("hltMu0TrackJpsiL3Filtered0", "", "HLT"));
00040   myOniaMuonTags.push_back(edm::InputTag("hltMu3TrackJpsiL3Filtered3", "", "HLT"));
00041   myOniaMuonTags.push_back(edm::InputTag("hltMu5TrackJpsiL3Filtered5", "", "HLT"));
00042   oniaMuonTag_ = pset.getUntrackedParameter<std::vector<edm::InputTag> >("OniaMuonTag",myOniaMuonTags);
00043 
00044   //Tag for Pixel tracks before Onia filter
00045   pixelTag_ = pset.getUntrackedParameter<edm::InputTag>("PixelTag",edm::InputTag("hltPixelTracks", "", "HLT"));
00046  
00047   //Tag for Tracker tracks before Onia filter
00048   trackTag_ = pset.getUntrackedParameter<edm::InputTag>("TrackTag",edm::InputTag("hltMuTrackJpsiCtfTrackCands","", "HLT"));
00049 
00050   beamSpotTag_ = pset.getUntrackedParameter<edm::InputTag>("BeamSpotTag",edm::InputTag("hltOfflineBeamSpot", "", "HLT"));
00051 
00052   //Tag Trigger Summary
00053   triggerSummaryRAWTag_ = pset.getUntrackedParameter<edm::InputTag>("TriggerSummaryTag",edm::InputTag("hltTriggerSummaryRAW", "", "HLT"));
00054   hltProcessName_  = pset.getUntrackedParameter<std::string>("TriggerProcessName","HLT");
00055   //Tag for Pixel tracks after Onia filter
00056   std::vector<edm::InputTag> pxlTagsAfterFilter;
00057   pxlTagsAfterFilter.push_back(edm::InputTag("hltMu0TrackJpsiPixelMassFiltered", "", "HLT"));
00058   pxlTagsAfterFilter.push_back(edm::InputTag("hltMu3TrackJpsiPixelMassFiltered", "", "HLT"));
00059   pxlTagsAfterFilter.push_back(edm::InputTag("hltMu5TrackJpsiPixelMassFiltered", "", "HLT"));
00060   pixelTagsAfterFilter_=  pset.getUntrackedParameter< std::vector<edm::InputTag> >("PixelTagAfterFilter",pxlTagsAfterFilter);
00061 
00062   //Tag for Tracker tracks after Onia filter
00063   std::vector<edm::InputTag> trxTagsAfterFilter;
00064   trxTagsAfterFilter.push_back(edm::InputTag("hltMu0TrackJpsiTrackMassFiltered", "", "HLT"));
00065   trxTagsAfterFilter.push_back(edm::InputTag("hltMu3TrackJpsiTrackMassFiltered", "", "HLT"));
00066   trxTagsAfterFilter.push_back(edm::InputTag("hltMu5TrackJpsiTrackMassFiltered", "", "HLT"));
00067   trackTagsAfterFilter_ = pset.getUntrackedParameter< std::vector<edm::InputTag> >("TrackTagAfterFilter",trxTagsAfterFilter);
00068 
00069   //Foldering output
00070   subsystemFolder_ = pset.getUntrackedParameter<std::string>("SubSystemFolder","HLT/HLTMonMuon/Onia");
00071 }
00072 
00073 
00074 HLTOniaSource::~HLTOniaSource(){dbe_ = 0;}
00075 
00076 void  HLTOniaSource::beginJob(){
00077 
00078   dbe_ = edm::Service<DQMStore>().operator->();
00079   if( !dbe_ ) {
00080     edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Could not access DQM Store.";
00081     return;
00082   }
00083 }
00084 
00085 void HLTOniaSource::beginRun(const edm::Run & run, const edm::EventSetup & setup) {
00086 
00087   if (!dbe_) return;
00088 
00089   // Book Pixel Histos
00090   if (pixelTag_.label()!= ""){
00091     dbe_->setCurrentFolder(subsystemFolder_+"/Pixel");
00092     this->bookOniaTriggerMEs(pixelME_,  pixelTag_.label());
00093   }
00094 
00095   // Book Track Histos
00096   if (trackTag_.label()!= ""){ 
00097     dbe_->setCurrentFolder(subsystemFolder_+"/Track");
00098     this->bookOniaTriggerMEs(trackME_, trackTag_.label());
00099   }
00100   
00101  
00102   //Book Onia Histos
00103   for (size_t i = 0 ; i<oniaMuonTag_.size() && i<pixelTagsAfterFilter_.size() && i<trackTagsAfterFilter_.size(); i++){
00104   
00105     if (oniaMuonTag_[i].label()!= "") {
00106       dbe_->setCurrentFolder(subsystemFolder_+"/MuonFilters");
00107       this->bookOniaTriggerMEs(muonME_, oniaMuonTag_[i].label()); 
00108     }
00109     if (pixelTagsAfterFilter_[i].label() != ""){ 
00110       dbe_->setCurrentFolder(subsystemFolder_+"/PixelFilters");
00111       this->bookOniaTriggerMEs(pixelAfterFilterME_, pixelTagsAfterFilter_[i].label() );
00112     }   
00113     if (trackTagsAfterFilter_[i].label() != ""){ 
00114       dbe_->setCurrentFolder(subsystemFolder_+"/TrackFilters");
00115       this->bookOniaTriggerMEs(trackAfterFilterME_, trackTagsAfterFilter_[i].label() );
00116     } 
00117     if (oniaMuonTag_[i].label()!= "" && pixelTag_.label() != ""){
00118       dbe_->setCurrentFolder(subsystemFolder_+"/Pixel");
00119       this->bookOniaTriggerInvariantMassMEs( massME_, oniaMuonTag_[i].label(),pixelTag_.label() );
00120     }
00121     if (oniaMuonTag_[i].label() != "" && trackTag_.label()!= "" ){ 
00122       dbe_->setCurrentFolder(subsystemFolder_+"/Track");
00123       this->bookOniaTriggerInvariantMassMEs( massME_, oniaMuonTag_[i].label(), trackTag_.label() );
00124     }
00125     if (oniaMuonTag_[i].label()!= "" && pixelTagsAfterFilter_[i].label()!= ""){
00126       dbe_->setCurrentFolder(subsystemFolder_+"/PixelFilters");
00127       this->bookOniaTriggerInvariantMassMEs( massME_,oniaMuonTag_[i].label(),pixelTagsAfterFilter_[i].label() );
00128     }  
00129     if (oniaMuonTag_[i].label()!= "" &&  trackTagsAfterFilter_[i].label()!= ""){ 
00130       dbe_->setCurrentFolder(subsystemFolder_+"/TrackFilters");
00131       this->bookOniaTriggerInvariantMassMEs( massME_, oniaMuonTag_[i].label(), trackTagsAfterFilter_[i].label() );
00132     }
00133   }
00134 
00135   hltConfigInit_ = this->checkHLTConfiguration(run , setup , hltProcessName_);
00136   
00137 }
00138 
00139 
00140 
00141 void HLTOniaSource::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup){
00142 
00143   if(!hltConfigInit_) return;
00144 
00145   //Get Pixel Tracks
00146   edm::Handle<reco::TrackCollection> pixelCands;
00147   iEvent.getByLabel(pixelTag_, pixelCands);
00148 
00149   reco::TrackCollection mypixelCands; //This is needed for the sort!!!!
00150   if (pixelCands.isValid()) {
00151     mypixelCands =  *  pixelCands;   
00152     sort(mypixelCands.begin(), mypixelCands.end(),PtGreater());  
00153     this->fillOniaTriggerMEs(pixelCands , pixelTag_.label(), pixelME_ );
00154   }else {
00155     edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Could not access pixel collection with tag "<<pixelTag_;
00156   }
00157    
00158   //Get Tracker Tracks
00159   edm::Handle<reco::RecoChargedCandidateCollection>  trackCands;
00160   iEvent.getByLabel(trackTag_, trackCands);
00161   reco::RecoChargedCandidateCollection mytrackCands; //This is needed for the sort!!!!
00162   if(trackCands.isValid()) {
00163     mytrackCands =  * trackCands;   
00164     sort(mytrackCands.begin(),mytrackCands.end(),PtGreater());  
00165     this->fillOniaTriggerMEs(trackCands ,  trackTag_.label(), trackME_ );   
00166    }else {
00167     edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Could not access track collection with tag "<<trackTag_;
00168    }
00169     
00170   //Get Beamspot 
00171   edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
00172   iEvent.getByLabel(beamSpotTag_, recoBeamSpotHandle);
00173   if (recoBeamSpotHandle.isValid()) {
00174     BSPosition_ = recoBeamSpotHandle->position();
00175   }else {
00176     edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Could not access beam spot info with tag "<<beamSpotTag_;
00177   }  
00178 
00179 
00180   //Get Trigger Summary RA
00181   edm::Handle<trigger::TriggerEventWithRefs> rawTriggerEvent;
00182   iEvent.getByLabel(triggerSummaryRAWTag_, rawTriggerEvent );
00183   
00184   if( rawTriggerEvent.isValid() ){
00185 
00186     for(size_t i=0; i<oniaMuonTag_.size(); i++){
00187 
00188       std::vector<reco::RecoChargedCandidateRef> myMuonFilterCands;        
00189       std::vector<reco::RecoChargedCandidateRef> myPixelFilterCands;   
00190       std::vector<reco::RecoChargedCandidateRef> myTrackFilterCands;   
00191       
00192       //Get Onia Muons
00193       size_t indexM = rawTriggerEvent->filterIndex(oniaMuonTag_[i]);
00194 
00195       if ( indexM < rawTriggerEvent->size() ){
00196         rawTriggerEvent->getObjects( indexM, trigger::TriggerMuon, myMuonFilterCands );
00197         this->fillOniaTriggerMEs( myMuonFilterCands,  oniaMuonTag_[i].label(), muonME_ );
00198       }else{
00199         edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Did not find muons with tag "<<oniaMuonTag_[i];
00200       }
00201       //Get Onia Pixel
00202       size_t indexP = rawTriggerEvent->filterIndex(pixelTagsAfterFilter_[i]);
00203       if ( indexP < rawTriggerEvent->size() ){
00204         rawTriggerEvent->getObjects( indexP, trigger::TriggerTrack , myPixelFilterCands );
00205         this->fillOniaTriggerMEs( myPixelFilterCands,pixelTagsAfterFilter_[i].label(), pixelAfterFilterME_);   
00206         sort(myPixelFilterCands.begin(), myPixelFilterCands.end(),PtGreaterRef());    
00207       }else{
00208         edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Did not find pixel with tag "<<pixelTagsAfterFilter_[i];
00209       }
00210 
00211       //Get Onia Tracker Tracks
00212       size_t indexT = rawTriggerEvent->filterIndex(trackTagsAfterFilter_[i]);
00213       if ( indexT < rawTriggerEvent->size() ){
00214         rawTriggerEvent->getObjects( indexT, trigger::TriggerTrack , myTrackFilterCands );
00215         this->fillOniaTriggerMEs( myTrackFilterCands,trackTagsAfterFilter_[i].label(), trackAfterFilterME_ );   
00216         sort(myTrackFilterCands.begin(), myTrackFilterCands.end(),PtGreaterRef());    
00217       }else{
00218         edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Did not find tracks with tag "<<trackTagsAfterFilter_[i];
00219       }
00220 
00221       if( myMuonFilterCands.size() > 0){
00222         if ( myPixelFilterCands.size() > 0 )this->fillInvariantMass( myMuonFilterCands, myPixelFilterCands ,oniaMuonTag_[i].label(),pixelTagsAfterFilter_[i].label());
00223         if ( myTrackFilterCands.size() > 0 )this->fillInvariantMass( myMuonFilterCands, myTrackFilterCands ,oniaMuonTag_[i].label(),trackTagsAfterFilter_[i].label());
00224         if (pixelCands.isValid())   this->fillInvariantMass( myMuonFilterCands, mypixelCands , oniaMuonTag_[i].label(), pixelTag_.label());
00225         if (trackCands.isValid())   this->fillInvariantMass( myMuonFilterCands, mytrackCands , oniaMuonTag_[i].label(), trackTag_.label());
00226       }
00227    
00228 
00229     }//ADD INVARIANT MASSES
00230   }else{
00231     edm::LogVerbatim ("oniatriggermonitor") << "[HLTOniaSource]: Could not access trigger collection with tag "<<triggerSummaryRAWTag_;
00232   }
00233   
00234 }
00235 
00236 
00237 void  HLTOniaSource::endJob() {}
00238 
00239 void  HLTOniaSource::bookOniaTriggerMEs( std::map<std::string, MonitorElement *>  & myMap, std::string meName){
00240 
00241     std::stringstream myMeName;
00242 
00243     //PT    
00244     myMeName.str("");
00245     myMeName<<meName<<"_Pt";
00246     myMap[meName+"pt"]=dbe_->book1D(myMeName.str(), myMeName.str(),200, 0.0, 20.0);
00247     myMap[meName+"pt"]->setAxisTitle("Pt (GeV)", 1);
00248 
00249     //P    
00250     myMeName.str("");
00251     myMeName<<meName<<"_P";
00252     myMap[meName+"p"]=dbe_->book1D(myMeName.str(), myMeName.str(),250, 0.0, 50.0);
00253     myMap[meName+"p"]->setAxisTitle("P (GeV)", 1);
00254     
00255     //Eta
00256     myMeName.str("");
00257     myMeName<<meName<<"_Eta";
00258     myMap[meName+"eta"]=dbe_->book1D(myMeName.str(), myMeName.str(), 50, -2.5, 2.5 );
00259     myMap[meName+"eta"]->setAxisTitle("Eta", 1);
00260     
00261     //Phi
00262     myMeName.str("");
00263     myMeName<<meName<<"_Phi";
00264     myMap[meName+"phi"]=dbe_->book1D(myMeName.str(), myMeName.str(), 144, -3.1416, 3.1416 );
00265     myMap[meName+"phi"]->setAxisTitle("Phi", 1);
00266 
00267     //Phi
00268     myMeName.str("");
00269     myMeName<<meName<<"_Phi";
00270     myMap[meName+"phi"]=dbe_->book1D(myMeName.str(), myMeName.str(), 144, -3.1416, 3.1416 );
00271     myMap[meName+"phi"]->setAxisTitle("Phi", 1);
00272 
00273     //Charge
00274     myMeName.str("");
00275     myMeName<<meName<<"_Charge";
00276     myMap[meName+"charge"]=dbe_->book1D(myMeName.str(), myMeName.str(), 3, -1.5, 1.5 );
00277     myMap[meName+"charge"]->setAxisTitle("charge", 1);
00278 
00279     //Dz
00280     myMeName.str("");
00281     myMeName<<meName<<"_Dz";
00282     myMap[meName+"dz"]=dbe_->book1D(myMeName.str(), myMeName.str(), 400, -20.0, 20.0 );
00283     myMap[meName+"dz"]->setAxisTitle("dz", 1);
00284 
00285     //Dxy
00286     myMeName.str("");
00287     myMeName<<meName<<"_Dxy";
00288     myMap[meName+"dxy"]=dbe_->book1D(myMeName.str(), myMeName.str(), 100, -0.5, 0.5 );
00289     myMap[meName+"dxy"]->setAxisTitle("dxy", 1);
00290 
00291     //EtaVsPhi
00292     myMeName.str("");
00293     myMeName<<meName<<"_EtaPhi";
00294     myMap[meName+"etaphi"]=dbe_->book2D(myMeName.str(), myMeName.str(), 144, -3.1416, 3.1416 ,50, -2.5, 2.5 );
00295     myMap[meName+"etaphi"]->setAxisTitle("Phi", 1);
00296     myMap[meName+"etaphi"]->setAxisTitle("Eta", 2);
00297 
00298     //EtaVsPt
00299     myMeName.str("");
00300     myMeName<<meName<<"_EtaPt";
00301     myMap[meName+"etapt"]=dbe_->book2D(myMeName.str(), myMeName.str(), 100, 0.0, 100.0, 50, -2.5, 2.5 );
00302     myMap[meName+"etapt"]->setAxisTitle("Pt (GeV)", 1);
00303     myMap[meName+"etapt"]->setAxisTitle("Eta", 2);
00304 
00305     //ValidHits
00306     myMeName.str("");
00307     myMeName<<meName<<"_ValidHits";
00308     myMap[meName+"validhits"]=dbe_->book1D(myMeName.str(), myMeName.str(), 50, 0.0, 50.0 );
00309     myMap[meName+"validhits"]->setAxisTitle("ValidHits", 1);
00310 
00311     //Norm Chi2
00312     myMeName.str("");
00313     myMeName<<meName<<"_NormChi2";
00314     myMap[meName+"normchi"]=dbe_->book1D(myMeName.str(), myMeName.str(), 300, 0.0, 30.0 );
00315     myMap[meName+"normchi"]->setAxisTitle("Normalized Chi2", 1);
00316 
00317     //Number Of Candi
00318     myMeName.str("");
00319     myMeName<<meName<<"_NrCandidates";
00320     myMap[meName+"nrcand"]=dbe_->book1D(myMeName.str(), myMeName.str(), 50, 0.0, 50.0 );
00321     myMap[meName+"nrcand"]->setAxisTitle("Nr per Event", 1);
00322     //return true;
00323 }
00324 
00325 
00326 void  HLTOniaSource::bookOniaTriggerInvariantMassMEs( std::map<std::string, MonitorElement *>  & myMap, std::string label1, std::string label2 ){
00327 
00328   std::stringstream meName;
00329   //Same charge 
00330   meName.str("");
00331   meName<<label1<<"_"<<label2<<"_SameCharge_InvariantMass";
00332   massME_[label1+label2+"same"]=dbe_->book1D(meName.str(), meName.str(),120, 0.0, 6.0);
00333   massME_[label1+label2+"same"]->setAxisTitle("mass (GeV)", 1);
00334 
00335   //Opposite charge 
00336   meName.str("");
00337   meName<<label1<<"_"<<label2<<"_OppositeCharge_InvariantMass";
00338   massME_[label1+label2+"opposite"]=dbe_->book1D(meName.str(), meName.str(),120, 0.0, 6.0);
00339   massME_[label1+label2+"opposite"]->setAxisTitle("mass (GeV)", 1);
00340       
00341   //Same charge Highest PT
00342   meName.str("");
00343   meName<<label1<<"_"<<label2<<"_SameCharge_HighestPT_InvariantMass";
00344   massME_[label1+label2+"same"+"highestpt"]=dbe_->book1D(meName.str(), meName.str(),120, 0.0, 6.0);
00345   massME_[label1+label2+"same"+"highestpt"]->setAxisTitle("mass (GeV)", 1);
00346           
00347   //Opposite charge Highest PT
00348   meName.str("");
00349   meName<<label1<<"_"<<label2<<"_OppositeCharge_HighestPT_InvariantMass";
00350   massME_[label1+label2+"opposite"+"highestpt"]=dbe_->book1D(meName.str(), meName.str(),120, 0.0, 6.0);
00351   massME_[label1+label2+"opposite"+"highestpt"]->setAxisTitle("mass (GeV)", 1);
00352 
00353  
00354  
00355   // Same Charge Deltaz Muon - Track  Highest PT
00356   meName.str("");
00357   meName<<label1<<"_"<<label2<<"_SameCharge_HighestPT_MaxDzMuonTrack";
00358   massME_[label1+label2+"same"+"highestpt"+"maxdzmuontrack"]=dbe_->book1D(meName.str(), meName.str(),50, 0.0, 5.0);
00359   massME_[label1+label2+"same"+"highestpt"+"maxdzmuontrack"]->setAxisTitle("MaxDz Muon-Track", 1);
00360   // Same Charge Deltaz Muon - Track
00361   meName.str("");
00362   meName<<label1<<"_"<<label2<<"_SameCharge_MaxDzMuonTrack";
00363   massME_[label1+label2+"same"+"maxdzmuontrack"]=dbe_->book1D(meName.str(), meName.str(),50, 0.0, 5.0);
00364   massME_[label1+label2+"same"+"maxdzmuontrack"]->setAxisTitle("MaxDz Muon-Track", 1);
00365   // Opposite charge  Deltaz Muon - Track Highest PT
00366   meName.str("");
00367   meName<<label1<<"_"<<label2<<"_OppositeCharge_HighestPT_MaxDzMuonTrack";
00368   massME_[label1+label2+"opposite"+"highestpt"+"maxdzmuontrack"]=dbe_->book1D(meName.str(), meName.str(),50, 0.0, 5.0);
00369   massME_[label1+label2+"opposite"+"highestpt"+"maxdzmuontrack"]->setAxisTitle("MaxDz Muon-Track", 1);   
00370   // Opposite charge  Deltaz Muon - Track
00371   meName.str("");
00372   meName<<label1<<"_"<<label2<<"_OppositeCharge_MaxDzMuonTrack";
00373   massME_[label1+label2+"opposite"+"maxdzmuontrack"]=dbe_->book1D(meName.str(), meName.str(),50, 0.0, 5.0);
00374   massME_[label1+label2+"opposite"+"maxdzmuontrack"]->setAxisTitle("MaxDz Muon-Track", 1);
00375 }
00376 
00377 
00378 void  HLTOniaSource::fillOniaTriggerMEs( edm::Handle<reco::TrackCollection> &  collection, std::string collectionLabel,  std::map<std::string, MonitorElement *>  & mapME ){
00379    // cout << "[HLTOniaSource]: fillOniaTriggerMEs " << collectionLabel << endl;
00380 
00381   reco::TrackCollection myCollection;
00382   if (collection.isValid()) {
00383     myCollection = * collection;
00384  
00385     // int nCollection= myCollection.size();
00386 
00387     typedef reco::TrackCollection::const_iterator cand;
00388     int num = 0;
00389     for (cand tk=myCollection.begin(); tk!=myCollection.end(); tk++) {
00390       num++;
00391       //Fill MEs  
00392       if(mapME[collectionLabel+"pt"]){  mapME[collectionLabel+"pt"]->Fill(tk->pt()); }
00393       if(mapME[collectionLabel+"p"])  { mapME[collectionLabel+"p"]->Fill(tk->p()); }
00394       if(mapME[collectionLabel+"eta"]) { mapME[collectionLabel+"eta"]->Fill(tk->eta()); }
00395       if(mapME[collectionLabel+"phi"]) { mapME[collectionLabel+"phi"]->Fill(tk->phi()); }
00396       if(mapME[collectionLabel+"etaphi"]){ mapME[collectionLabel+"etaphi"]->Fill(tk->phi(),tk->eta()); }
00397       if(mapME[collectionLabel+"etapt"]){ mapME[collectionLabel+"etapt"]->Fill(tk->pt(),tk->eta()); }
00398       if(mapME[collectionLabel+"charge"]){ mapME[collectionLabel+"charge"]->Fill(tk->charge()); }
00399 
00400      //  if(mapME[collectionLabel+"dxy"]){ mapME[collectionLabel+"dxy"]->Fill(tk->dxy(BSPosition_)); }
00401 //       if(mapME[collectionLabel+"dz"]){ mapME[collectionLabel+"dz"]->Fill(tk->dz(BSPosition_)); }
00402 
00403 //       if(mapME[collectionLabel+"validhits"]) { mapME[collectionLabel+"validhits"]->Fill(tk->numberOfValidHits()); }
00404 //       if(mapME[collectionLabel+"normchi"]){  mapME[collectionLabel+"normchi"]->Fill(tk->normalizedChi2()); }
00405     }
00406     if(mapME[collectionLabel+"nrcand"]){  mapME[collectionLabel+"nrcand"]->Fill(num);}
00407 
00408   }
00409 }
00410 
00411 
00412 void  HLTOniaSource::fillOniaTriggerMEs(std::vector<reco::RecoChargedCandidateRef>  &  candidateVector, std::string collectionLabel,  std::map<std::string, MonitorElement *>  & mapME ){
00413     
00414   for (unsigned int  i=0; i!=candidateVector.size(); i++) {
00415     reco::RecoChargedCandidate tk = (*candidateVector[i]);
00416 
00417    //Fill MEs  
00418    if(mapME[collectionLabel+"pt"]){  mapME[collectionLabel+"pt"]->Fill(tk.pt()); }
00419    if(mapME[collectionLabel+"p"])  { mapME[collectionLabel+"p"]->Fill(tk.p()); }
00420    if(mapME[collectionLabel+"eta"]) { mapME[collectionLabel+"eta"]->Fill(tk.eta()); }
00421    if(mapME[collectionLabel+"phi"]) { mapME[collectionLabel+"phi"]->Fill(tk.phi()); }
00422    if(mapME[collectionLabel+"etaphi"]){ mapME[collectionLabel+"etaphi"]->Fill(tk.phi(),tk.eta()); }
00423    if(mapME[collectionLabel+"etapt"]){ mapME[collectionLabel+"etapt"]->Fill(tk.pt(),tk.eta()); }
00424    if(mapME[collectionLabel+"charge"]){ mapME[collectionLabel+"charge"]->Fill(tk.charge()); }
00425    
00426   //  if(mapME[collectionLabel+"dxy"]){ mapME[collectionLabel+"dxy"]->Fill(tk.dxy(BSPosition_)); }
00427 //    if(mapME[collectionLabel+"dz"]){ mapME[collectionLabel+"dz"]->Fill(tk.dz(BSPosition_)); }
00428    
00429 //    if(mapME[collectionLabel+"validhits"]) { mapME[collectionLabel+"validhits"]->Fill(tk.numberOfValidHits()); }
00430 //    if(mapME[collectionLabel+"normchi"]){  mapME[collectionLabel+"normchi"]->Fill(tk.normalizedChi2()); }
00431   }
00432  
00433   if(mapME[collectionLabel+"nrcand"]){  mapME[collectionLabel+"nrcand"]->Fill( candidateVector.size());}
00434 }
00435 
00436 
00437 void  HLTOniaSource::fillOniaTriggerMEs( edm::Handle<reco::RecoChargedCandidateCollection> &  collection, std::string collectionLabel,  std::map<std::string, MonitorElement *>  & mapME ){
00438 
00439   reco::RecoChargedCandidateCollection myCollection;
00440   if (collection.isValid()) {
00441     myCollection = * collection;
00442  
00443     // int nCollection= myCollection.size();
00444     int num = 0;
00445     typedef reco::RecoChargedCandidateCollection::const_iterator cand;
00446     for (cand i=myCollection.begin(); i!=myCollection.end(); i++) {
00447       reco::RecoChargedCandidate tk = (*i);
00448 
00449       num++; 
00450      //Fill MEs  
00451       if(mapME[collectionLabel+"pt"]){  mapME[collectionLabel+"pt"]->Fill(tk.pt()); }
00452       if(mapME[collectionLabel+"p"])  { mapME[collectionLabel+"p"]->Fill(tk.p()); }
00453       if(mapME[collectionLabel+"eta"]) { mapME[collectionLabel+"eta"]->Fill(tk.eta()); }
00454       if(mapME[collectionLabel+"phi"]) { mapME[collectionLabel+"phi"]->Fill(tk.phi()); }
00455       if(mapME[collectionLabel+"etaphi"]){ mapME[collectionLabel+"etaphi"]->Fill(tk.phi(),tk.eta()); }
00456       if(mapME[collectionLabel+"etapt"]){ mapME[collectionLabel+"etapt"]->Fill(tk.pt(),tk.eta()); }
00457       if(mapME[collectionLabel+"charge"]){ mapME[collectionLabel+"charge"]->Fill(tk.charge()); }
00458 
00459    //    if(mapME[collectionLabel+"dxy"]){ mapME[collectionLabel+"dxy"]->Fill(tk.dxy(BSPosition_)); }
00460 //       if(mapME[collectionLabel+"dz"]){ mapME[collectionLabel+"dz"]->Fill(tk.dz(BSPosition_)); }
00461 
00462 //       if(mapME[collectionLabel+"validhits"]) { mapME[collectionLabel+"validhits"]->Fill(tk.numberOfValidHits()); }
00463 //       if(mapME[collectionLabel+"normchi"]){  mapME[collectionLabel+"normchi"]->Fill(tk.normalizedChi2()); }
00464     }
00465     if(mapME[collectionLabel+"nrcand"]){  mapME[collectionLabel+"nrcand"]->Fill(num);}
00466   }
00467 }
00468 
00469  
00470 void HLTOniaSource::fillInvariantMass(std::vector<reco::RecoChargedCandidateRef> & cand1,  std::vector<reco::RecoChargedCandidateRef> & cand2, std::string cand1Label, std::string  cand2Label){
00471 
00472     //Loop on collection to calculate invariate mass
00473     for(size_t i = 0 ; i< cand1.size(); i++) {
00474     
00475       //Highest PT
00476       std::string chargeLabel = "same";
00477       
00478       //Check relative charge
00479       if(cand1[i]->charge() * cand2[0]->charge() < 0) chargeLabel = "opposite";
00480       if(massME_[cand1Label+cand2Label+chargeLabel+"highestpt"]){
00481         massME_[cand1Label+cand2Label+chargeLabel+"highestpt"]->Fill((cand1[i]->p4()+cand2[0]->p4()).mass());
00482       }
00483       if(massME_[cand1Label+cand2Label+chargeLabel+"highestpt"+"maxdzmuontrack"]){
00484         reco::RecoChargedCandidate tk1 = (*cand1[i]);
00485         reco::RecoChargedCandidate tk2 = (*cand2[0]);
00486         //        TrackRef tk1 = cand1[i]->get<TrackRef>();
00487         //          massME_[cand1Label+cand2Label+chargeLabel+"highestpt"+"maxdzmuontrack"]->Fill(fabs(tk1->dz(BSPosition_) - tk2->dz(BSPosition_)));
00488       }
00489       
00490       
00491       for (size_t j= 0; j< cand2.size(); j++) {
00492         
00493         if(cand2[j]->p() < 3) continue; //Check if momentum is greater than 3GeV.
00494         std::string chargeLabel = "same";
00495         //Check relative charge
00496         if(cand1[i]->charge() * cand2[j]->charge() < 0) chargeLabel = "opposite";
00497         if(massME_[cand1Label+cand2Label+chargeLabel]){
00498           massME_[cand1Label+cand2Label+chargeLabel]->Fill((cand1[i]->p4()+cand2[j]->p4()).mass());
00499         }
00500         if(massME_[cand1Label+cand2Label+chargeLabel+"maxdzmuontrack"]){
00501           reco::RecoChargedCandidate tk1 = (*cand1[i]);
00502           reco::RecoChargedCandidate tk2 = (*cand2[j]);
00503           //      massME_[cand1Label+cand2Label+chargeLabel+"maxdzmuontrack"]->Fill(fabs(tk1->dz(BSPosition_) - tk2->dz(BSPosition_)));
00504         }
00505       }
00506     }
00507 }
00508 
00509 
00510 
00511 void HLTOniaSource::fillInvariantMass(std::vector<reco::RecoChargedCandidateRef> & cand1,  reco::RecoChargedCandidateCollection &  cand2, std::string cand1Label, std::string  cand2Label){
00512   
00513   typedef reco::RecoChargedCandidateCollection::const_iterator cand;
00514     //Loop on collection to calculate invariate mass
00515     for(size_t i = 0 ; i< cand1.size(); i++) {
00516       //Highest PT
00517       if(cand2.begin() != cand2.end()  &&  cand2.begin()->p()>3) {
00518         cand candItr = cand2.begin();
00519         std::string chargeLabel = "same";       
00520         //Check relative charge
00521         if(cand1[i]->charge() * candItr->charge() < 0) chargeLabel = "opposite";
00522         if(massME_[cand1Label+cand2Label+chargeLabel+"highestpt"]){
00523           massME_[cand1Label+cand2Label+chargeLabel+"highestpt"]->Fill((cand1[i]->p4()+candItr->p4()).mass());
00524         }
00525         
00526         if(massME_[cand1Label+cand2Label+chargeLabel+"highestpt"+"maxdzmuontrack"]){
00527           reco::RecoChargedCandidate tk1 = (*cand1[i]);
00528           reco::RecoChargedCandidate tk2 = (*candItr);
00529           //        massME_[cand1Label+cand2Label+chargeLabel+"highestpt"+"maxdzmuontrack"]->Fill(fabs(tk1->dz(BSPosition_) - tk2->dz(BSPosition_)));
00530         }
00531       }
00532 
00533       for (cand candItr2= cand2.begin(); candItr2!=cand2.end(); candItr2++) {
00534         if(candItr2->p() < 3) continue; //Check if momentum is greater than 3GeV.
00535         std::string  chargeLabel = "same";
00536         //Check relative charge
00537         if(cand1[i]->charge() * candItr2->charge() < 0) chargeLabel = "opposite";
00538         if(massME_[cand1Label+cand2Label+chargeLabel]){
00539            massME_[cand1Label+cand2Label+chargeLabel]->Fill((cand1[i]->p4()+candItr2->p4()).mass());
00540         }
00541         if(massME_[cand1Label+cand2Label+chargeLabel+"maxdzmuontrack"]){
00542           reco::RecoChargedCandidate tk1 = (*cand1[i]);
00543           reco::RecoChargedCandidate tk2 = (*candItr2);
00544           //      massME_[cand1Label+cand2Label+chargeLabel+"maxdzmuontrack"]->Fill(fabs(tk1->dz(BSPosition_) - tk2->dz(BSPosition_)));
00545         }
00546       }
00547     }
00548 }
00549 
00550 
00551 
00552 void HLTOniaSource::fillInvariantMass(std::vector<reco::RecoChargedCandidateRef> & cand1,  reco::TrackCollection &  cand2, std::string cand1Label, std::string  cand2Label){
00553   
00554   typedef reco::TrackCollection::const_iterator cand;
00555 
00556     //Loop on collection to calculate invariate mass
00557     for(size_t i = 0 ; i< cand1.size(); i++) {
00558       //Highest PT
00559       if(cand2.begin() != cand2.end()  &&  cand2.begin()->p()>3) {
00560         cand candItr = cand2.begin();
00561         math::PtEtaPhiMLorentzVector bestPtCandLVector(candItr->pt(), candItr->eta(), candItr->phi(), 1.056);
00562  
00563         std::string chargeLabel = "same";
00564         
00565         //Check relative charge
00566         if(cand1[i]->charge() * candItr->charge() < 0) chargeLabel = "opposite";
00567         if(massME_[cand1Label+cand2Label+chargeLabel+"highestpt"]){
00568           massME_[cand1Label+cand2Label+chargeLabel+"highestpt"]->Fill((cand1[i]->p4()+bestPtCandLVector).mass());
00569         }
00570         
00571         if(massME_[cand1Label+cand2Label+chargeLabel+"highestpt"+"maxdzmuontrack"]){
00572           reco::RecoChargedCandidate tk1 = (*cand1[i]);
00573           //  massME_[cand1Label+cand2Label+chargeLabel+"highestpt"+"maxdzmuontrack"]->Fill(fabs(tk->dz(BSPosition_) - candItr->dz(BSPosition_)));
00574         }
00575       }
00576 
00577       for (cand candIter= cand2.begin(); candIter!=cand2.end(); candIter++) {
00578 
00579         if(candIter->p() < 3) continue; //Check if momentum is greater than 3GeV.
00580 
00581         math::PtEtaPhiMLorentzVector candLVector(candIter->pt(), candIter->eta(), candIter->phi(), 1.056);
00582  
00583         std::string chargeLabel = "same";
00584         //Check relative charge
00585         if(cand1[i]->charge() * candIter->charge() < 0) chargeLabel = "opposite";
00586         if(massME_[cand1Label+cand2Label+chargeLabel]){
00587            massME_[cand1Label+cand2Label+chargeLabel]->Fill((cand1[i]->p4()+candLVector).mass());
00588         }
00589         if(massME_[cand1Label+cand2Label+chargeLabel+"maxdzmuontrack"]){
00590           reco::RecoChargedCandidate tk1 = (*cand1[i]);
00591           //        massME_[cand1Label+cand2Label+chargeLabel+"maxdzmuontrack"]->Fill(fabs(tk->dz(BSPosition_) - candIter->dz(BSPosition_)));
00592         }
00593       }
00594     }
00595 }
00596 
00597 bool HLTOniaSource::checkHLTConfiguration(const edm::Run & run, const edm::EventSetup & setup, std::string triggerProcessName){
00598 
00599   HLTConfigProvider hltConfig;
00600   bool changed(false);
00601   if(hltConfig.init(run , setup, triggerProcessName, changed)){
00602     edm::LogVerbatim("hltoniasource") << "Successfully initialized HLTConfigProvider with process name: "<<triggerProcessName;
00603 
00604     std::stringstream os;
00605     std::vector<std::string> triggerNames = hltConfig.triggerNames();
00606     
00607     for( size_t i = 0; i < triggerNames.size(); i++) {
00608       if (find(triggerPath_.begin(), triggerPath_.end(), triggerNames[i]) == triggerPath_.end()) continue; 
00609       edm::LogVerbatim("hltoniasource") << "[HLTOniaSource]: Trigger Path: "<<triggerNames[i];
00610       std::vector<std::string> moduleNames = hltConfig.moduleLabels( triggerNames[i] );
00611       for( size_t j = 0; j < moduleNames.size(); j++) {
00612         TString name = moduleNames[j];
00613         edm::LogVerbatim("hltoniasource") << "\t  Fliter Name: "<<moduleNames[j];
00614       }
00615     }
00616 
00617     return true;
00618 
00619   }else{
00620     edm::LogVerbatim("hltoniasource") << "Could not initialize HLTConfigProvider with process name: "<<triggerProcessName;
00621     return false;  
00622   }
00623   return true;
00624 }