CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

MCAcceptanceAnalyzer Class Reference

Inheritance diagram for MCAcceptanceAnalyzer:
edm::EDAnalyzer

List of all members.

Public Member Functions

 MCAcceptanceAnalyzer (const ParameterSet &cfg)

Private Member Functions

void analyze (const Event &, const EventSetup &)
void endJob ()

Private Attributes

long nZToMuMu_
long nZToMuMuMC_
long nZToMuMuMCDen_
long nZToMuMuMCMatched_
ZSelector select_
ZSelector select_OnlyMassCut_
long selZToMuMu_
long selZToMuMuMC_
long selZToMuMuMCMatched_
InputTag zToMuMu_
InputTag zToMuMuMatched_
InputTag zToMuMuMC_

Detailed Description

Definition at line 54 of file MCAcceptanceAnalyzer.cc.


Constructor & Destructor Documentation

MCAcceptanceAnalyzer::MCAcceptanceAnalyzer ( const ParameterSet cfg)

Definition at line 65 of file MCAcceptanceAnalyzer.cc.

                                                                  :
  zToMuMu_(cfg.getParameter<InputTag>("zToMuMu")),
  zToMuMuMC_(cfg.getParameter<InputTag>("zToMuMuMC")),
  zToMuMuMatched_(cfg.getParameter<InputTag>("zToMuMuMatched")),
  nZToMuMu_(0), selZToMuMu_(0), 
  nZToMuMuMC_(0), selZToMuMuMC_(0),
  nZToMuMuMCMatched_(0), selZToMuMuMCMatched_(0), nZToMuMuMCDen_(0),
  select_(cfg.getParameter<double>("ptMin"), cfg.getParameter<double>("etaDau0Min"), cfg.getParameter<double>("etaDau0Max"), cfg.getParameter<double>("etaDau1Min"), cfg.getParameter<double>("etaDau1Max"),cfg.getParameter<double>("massMin"), cfg.getParameter<double>("massMax"), cfg.getParameter<double>("massMinZMC"), cfg.getParameter<double>("massMaxZMC")  ),
  select_OnlyMassCut_(-1, -9999,9999 , -9999, 9999,0, 0, cfg.getParameter<double>("massMinZMC"), cfg.getParameter<double>("massMaxZMC")  )
{
}

Member Function Documentation

void MCAcceptanceAnalyzer::analyze ( const Event evt,
const EventSetup  
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 77 of file MCAcceptanceAnalyzer.cc.

References gather_cfg::cout, reco::Candidate::daughter(), reco::Candidate::eta(), edm::Event::getByLabel(), i, edm::Ref< C, T, F >::isNonnull(), m, reco::Candidate::mass(), mcMuDaughter(), reco::Candidate::numberOfDaughters(), nZToMuMu_, nZToMuMuMC_, nZToMuMuMCDen_, nZToMuMuMCMatched_, reco::Candidate::p4(), reco::Candidate::pt(), select_, select_OnlyMassCut_, selZToMuMu_, selZToMuMuMC_, selZToMuMuMCMatched_, z, zToMuMu_, zToMuMuMatched_, and zToMuMuMC_.

                                                                      {
  Handle<CandidateView> zToMuMu;
  evt.getByLabel(zToMuMu_, zToMuMu);
  Handle<CandidateView> zToMuMuMC;
  evt.getByLabel(zToMuMuMC_, zToMuMuMC);
  Handle<GenParticleMatch > zToMuMuMatched;
  evt.getByLabel(zToMuMuMatched_, zToMuMuMatched);
  //  long nZToMuMu = zToMuMu->size();
  long nZToMuMuMC = zToMuMuMC->size();
  long nZToMuMuMatched = zToMuMuMatched->size();
  
 
  // cout << ">>> " << zToMuMu_ << " has " << nZToMuMu << " entries" << endl;   
  //cout << ">>> " << zToMuMuMC_ << " has " << nZToMuMuMC << " entries" << endl;   
  //cout << ">>> " << zToMuMuMatched_ << " has " << nZToMuMuMatched << " entries" << endl;
  


  nZToMuMuMC_ += nZToMuMuMC;
  for(long i = 0; i < nZToMuMuMC; ++i) { 
    const Candidate & z = (*zToMuMuMC)[i]; 
    if(select_(z)==4) ++selZToMuMuMC_;
    if(select_OnlyMassCut_(z)==4) ++nZToMuMuMCDen_;

  }

  
  for(long i = 0; i < nZToMuMuMatched; ++i) { 

    const Candidate & z = (*zToMuMu)[i];
    CandidateBaseRef zRef = zToMuMu->refAt(i);
    GenParticleRef mcRef = (*zToMuMuMatched)[zRef];


    if(mcRef.isNonnull()) {   // z candidate matched to Z MC
    ++nZToMuMu_;
    ++nZToMuMuMCMatched_;

    int selectZ = select_(z);
    if(selectZ==4) ++selZToMuMu_;



      int selectMC = select_(*mcRef);
     
      if(selectMC==4) ++selZToMuMuMCMatched_;

      if(selectZ != selectMC) {
        cout << ">>> select reco: " << selectZ << ", select mc: " << selectMC << endl;
        if ((selectZ * selectMC) ==0 ) break; 
        if (z.numberOfDaughters()> 1){
        const Candidate * d0 = z.daughter(0), * d1 = z.daughter(1);
        if (mcRef->numberOfDaughters()>1){
          const Candidate * mcd0 = mcMuDaughter(mcRef->daughter(0)),
            * mcd1 = mcMuDaughter(mcRef->daughter(1));
          double m = z.mass(), mcm = (mcd0->p4()+mcd1->p4()).mass();
          cout << ">>> reco pt1, eta1: " << d0->pt() <<", " << d0->eta() 
               << ", 2: " << d1->pt() << ", " << d1->eta()
               << ", mass = " << m << endl; 
          cout << ">>> mc   pt1, eta1: " << mcd0->pt() <<", " << mcd0->eta()
               << ", 2: " << mcd1->pt() << ", " << mcd1->eta()
               << ", mass = " << mcm << endl; 
        }
        }
        
      }
      // to avoid double counting 
      if ((selectZ==3) && (selectMC==3)) break;
    }
   }

}
void MCAcceptanceAnalyzer::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 150 of file MCAcceptanceAnalyzer.cc.

References gather_cfg::cout, nZToMuMu_, nZToMuMuMC_, nZToMuMuMCDen_, nZToMuMuMCMatched_, selZToMuMu_, selZToMuMuMC_, selZToMuMuMCMatched_, mathSSE::sqrt(), zToMuMu_, and zToMuMuMC_.

                                  {
  double effZToMuMu = double(selZToMuMu_)/double(nZToMuMu_);
  double errZToMuMu = sqrt(effZToMuMu*(1. - effZToMuMu)/nZToMuMu_);
  double effZToMuMuMC = double(selZToMuMuMC_)/double(nZToMuMuMC_);
  double errZToMuMuMC = sqrt(effZToMuMuMC*(1. - effZToMuMuMC)/nZToMuMuMC_);
  double effZToMuMuMCDen = double(selZToMuMuMC_)/double(nZToMuMuMCDen_);
  double errZToMuMuMCDen = sqrt(effZToMuMuMCDen*(1. - effZToMuMuMCDen)/nZToMuMuMCDen_);
  double effZToMuMuMCMatched = double(selZToMuMuMCMatched_)/double(nZToMuMuMCMatched_);
  double errZToMuMuMCMatched = sqrt(effZToMuMuMCMatched*(1. - effZToMuMuMCMatched)/nZToMuMuMCMatched_);
  cout << ">>> " << zToMuMu_ << ": " << selZToMuMu_ << "/" << nZToMuMu_ 
       << " = " << effZToMuMu << " +/- " << errZToMuMu << endl;
  cout << ">>> " << zToMuMuMC_ << " - matched: " << selZToMuMuMCMatched_ << "/" << nZToMuMuMCMatched_ 
       << " = " << effZToMuMuMCMatched << " +/- " << errZToMuMuMCMatched << endl;
  cout << " if the two numbers above are the same we can neglete resolution effect and quote the acceptance as the number below.... " << endl; 
  cout << "********* acceptance m>sampleMCMassCut (usually 20 or 40) ********  " << endl;
  cout << ">>> " << zToMuMuMC_ << ": " << selZToMuMuMC_ << "/" << nZToMuMuMC_ 
       << " = " << effZToMuMuMC << " +/- " << errZToMuMuMC << endl;
  cout << "********* acceptance in the given mass range ********  " << endl;
  cout << ">>> " << zToMuMuMC_ << ": " << selZToMuMuMC_ << "/" << nZToMuMuMCDen_ 
       << " = " << effZToMuMuMCDen << " +/- " << errZToMuMuMCDen << endl;

}

Member Data Documentation

Definition at line 61 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

Definition at line 61 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

Definition at line 61 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

Definition at line 61 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

Definition at line 62 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

Definition at line 62 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

Definition at line 61 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

Definition at line 61 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

Definition at line 61 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

Definition at line 60 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().

Definition at line 60 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze().

Definition at line 60 of file MCAcceptanceAnalyzer.cc.

Referenced by analyze(), and endJob().