Ntupler para la Escuela de Particulas

  • Datos de entrada: /MET/Run2011A-EXOHSCP-PromptSkim-v6/USER
  • Creation time: 08/Aug/2011 12:44:11 GMT, Dataset size: 31.7GB, Number of blocks: 32, Number of events: 1437549, Number of files: 113, Type: data

  • Analyzer en CMSSW_4_4_4

DoubleMuon.h

// ----------member data ---------------------------

  TH1F * h_nMuons;
  TH1F * h_MuonsInv;

  edm::InputTag m_trackLabel;
  edm::InputTag m_muonLabel; 

  bool m_debug;

  TTree * m_tree;
  
  TFile * m_outfile;
  
  int nmuons;
  float muons_fPx[5];     //[muons_]
  float muons_fPy[5];     //[muons_]
  float muons_fPz[5];     //[muons_]
  float muons_fE[5];      //[muons_]
  float muons_fC[5];      //[muons_]
  float muons_fEta[5];    //[muons_]

DoubleMuon.cc

void
DoubleMuons::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
{
  
  unsigned int ieventX = iEvent.id().event();
  if(m_debug)   std::cout << " @Evento: " << ieventX << std::endl;
  
  edm::Handle<reco::MuonCollection> muonCollectionHandle;
  iEvent.getByLabel(m_muonLabel, muonCollectionHandle);
  
  if ( muonCollectionHandle.isValid() ) {
    
    reco::MuonCollection::const_iterator recoMuItr;
    
    int iMu = 0;
    
    for (recoMuItr = muonCollectionHandle->begin(); recoMuItr != muonCollectionHandle->end(); recoMuItr++) {
      
      //Only study the GlobalMuons from this collection
      
      if( ! (*recoMuItr).isGlobalMuon() ) continue; 
      
      muons_fPx[iMu]  = (*recoMuItr).px();
      muons_fPy[iMu]  = (*recoMuItr).py();
      muons_fPz[iMu]  = (*recoMuItr).pz();
      muons_fE[iMu]   = (*recoMuItr).energy();
      muons_fC[iMu]   = (*recoMuItr).charge();
      muons_fEta[iMu] = (*recoMuItr).eta();

      ++iMu;
      
    }
    
    h_nMuons->Fill(iMu);
    
    nmuons = iMu;
    
    if ( nmuons >= 2 && nmuons < 5)
      m_tree->Fill();
    
  } else {
    
    std::cout << "Cannot find collection with name " << m_muonLabel << std::endl;
        
  }
 
}

Otras definiciones en DoubleMuon.cc

void 
DoubleMuons::beginJob()
{

  edm::Service<TFileService> fs;
  
  h_nMuons = fs->make<TH1F>("nMuons" , "GL Muons per event" , 5 , 0.0 , 5.0 );
  h_MuonsInv = fs->make<TH1F>("muonsInv" , "Dimuons invariant mass" , 40 , 60 , 100 ); 


  m_outfile = new TFile("ntupler_output.root","RECREATE");
  
  m_outfile->cd();
  
  m_tree = new TTree("t1","Real data root-tuple");

  //adicionar una rama por variable  
  m_tree->Branch("nMuons", &nmuons ,"nMuons/I");
  m_tree->Branch("muons_fPx"  , muons_fPx  ,"muons_fPx[5]/F");
  m_tree->Branch("muons_fPy"  , muons_fPy  ,"muons_fPy[5]/F");
  m_tree->Branch("muons_fPz"  , muons_fPz  ,"muons_fPz[5]/F");
  m_tree->Branch("muons_fE"   , muons_fE   ,"muons_fE[5]/F");
  m_tree->Branch("muons_fC"   , muons_fC   ,"muons_fC[5]/F");
  m_tree->Branch("muons_fEta" , muons_fEta ,"muons_fEta[5]/F");

}

DoubleMuons::~DoubleMuons()
{
 
  // do anything here that needs to be done at desctruction time
  // (e.g. close files, deallocate resources etc.)
  
  m_outfile->Write();
  m_outfile->Close();


}

-- AndresOsorio - 29-May-2012

Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2012-05-29 - AndresOsorio
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback