Exemplo n.º 1
0
int NeroAll::analyze(const edm::Event&iEvent)
{
    if(isMc_ <0 )
    {
        isMc_ = ( iEvent.isRealData() ) ? 0 : 1;
        isRealData = ( iEvent.isRealData() ) ? 1 : 0;
    }
    if( isSkim() == 0) 
    {
        //TODO FILL all_
        isRealData = ( iEvent.isRealData() ) ? 1 : 0;	
        runNum = iEvent.id().run();
        lumiNum = iEvent.luminosityBlock(); 	
        eventNum = iEvent.id().event();  
        iEvent.getByLabel(edm::InputTag("generator"), info_handle); // USE TOKEN AND INPUT TAG ?
        iEvent.getByLabel(edm::InputTag("addPileupInfo"), pu_handle);
        mcWeight = info_handle->weight();
        //PU
        puTrueInt = 0;
        for(const auto & pu : *pu_handle)
        {
            //Intime
            if (pu.getBunchCrossing() == 0)
                puTrueInt += pu.getTrueNumInteractions();
            //Out-of-time
        }
    }
    return 0;
}
Exemplo n.º 2
0
void UAHiggsTree::GetGenMET(const edm::Event& iEvent , const edm::EventSetup& iSetup,
                            const string GenMETCollection_ , vector<MyGenMET>& METVector )
{
   using namespace std;
   using namespace edm;
   using namespace reco;

   METVector.clear();
  
   Handle<GenMETCollection> met;
   iEvent.getByLabel(GenMETCollection_, met);

   for(reco::GenMETCollection::const_iterator met_iter=met->begin(); 
      met_iter != met->end(); met_iter++)
    {
      
      MyGenMET mymet;
     
      mymet.pt=met_iter->pt();
      mymet.phi=met_iter->phi();
      mymet.eta=met_iter->eta();
      
      
      METVector.push_back(mymet);
         

    } 

}
Exemplo n.º 3
0
void ChPartTree::GetL1Trig(const edm::Event& iEvent, const edm::EventSetup& iSetup)
{
   using namespace std;

  // Tests
/*
  if (L1TrigDebug)
  {  
   edm::ESHandle<L1GtTriggerMenu> menuRcd;
   iSetup.get<L1GtTriggerMenuRcd>().get(menuRcd) ;
   const L1GtTriggerMenu* menu = menuRcd.product();

   for (CItAlgo algo = menu->gtAlgorithmMap().begin(); 
                algo!=menu->gtAlgorithmMap().end(); 
                ++algo) 
   {
     cout << "Name: " << (algo->second).algoName() 
          << " Alias: " << (algo->second).algoAlias() 
          << " Bit: " << (algo->second).algoBitNumber()
           << " Result: " << l1AlgorithmResult(iEvent, iSetup, (algo->second).algoName() )
          << std::endl;
   }
  }
*/

   edm::Handle<L1GlobalTriggerReadoutRecord> L1GTRR;
   iEvent.getByLabel("gtDigis",L1GTRR);
   for (int i=0 ; i <128 ; i++) 
   {
     if (L1TrigDebug) cout << "PhysicsTriggerWord :" << i << " " << L1GTRR->decisionWord()[i] << endl;
     L1Trig.PhysTrigWord[i] = L1GTRR->decisionWord()[i];
   }
   for (int i=0 ; i <64  ; i++)
   {
    if (L1TrigDebug) cout << "technicalTriggerWord :" << i << " " << L1GTRR->technicalTriggerWord()[i] << endl;
     L1Trig.TechTrigWord[i] = L1GTRR->technicalTriggerWord()[i]; 
   }
}
Exemplo n.º 4
0
void UAHiggsTree::GetGenPart(const edm::Event& iEvent, const edm::EventSetup& iSetup)
{
   using namespace std;
   using namespace edm;
   using namespace reco;

   // Clear GenPart List
   // (evt->GenPart).clear();
   GenPart.clear();
   GenElec.clear();
   GenMu.clear();
   GenNu.clear();

   // Handle to access PDG data from iSetup
   ESHandle <ParticleDataTable> pdt;
   iSetup.getData( pdt );

   // Handle to access GenParticleCollection
   Handle<GenParticleCollection> genParticles;
   iEvent.getByLabel(genPartColl_, genParticles);
   if (!genParticles.isValid()) {
     cerr << "[UAHiggsTree::GetGenPart] Error: non valid GenParticleCollection " << endl;
     return;
   }

   // List for Daugther/Mother Search
   vector<const reco::Candidate *> cands;
   vector<const Candidate *>::const_iterator found = cands.begin();
   for(GenParticleCollection::const_iterator p = genParticles->begin();
     p != genParticles->end(); ++ p) {
     cands.push_back(&*p);
   }

   // Loop on generated particle and store if status=3
   if ( GenPartDebug )
     cout << "GenPart # : " << genParticles->size() << endl;
   
   for(GenParticleCollection::const_iterator p = genParticles->begin();
     p != genParticles->end(); ++ p) {
     int st = p->status();

       MyGenPart genpart;

      if ( GenPartDebug )
      {
       if(( fabs(p->pdgId())==11 || fabs(p->pdgId())== 13) && st==1) 
         cout    << p-genParticles->begin()
                 << " " << st  
                 << " " << p->pdgId()
                 << " " << (pdt->particle(p->pdgId()))->name()
                 << " " << p->pt()
                 << " " << p->eta()
                 << " " << p->phi()
                 << " " << p->charge()
                 << endl ;

       if(( fabs(p->pdgId())==11 || fabs(p->pdgId())== 13) && st==3)
         cout    << p-genParticles->begin()
                 << " " << st
                 << " " << p->pdgId()
                 << " " << (pdt->particle(p->pdgId()))->name()
                 << " " << p->pt()
                 << " " << p->eta()
                 << " " << p->phi()
                 << " " << p->charge()
                 << endl ;
       }

       // Four vector

       genpart.pt   = p->pt();
       genpart.eta  = p->eta();
       genpart.phi  = p->phi();
       genpart.e    = p->energy();
       genpart.px   = p->px();
       genpart.py   = p->py();
       genpart.pz   = p->pz();
       genpart.m    = p->mass();

       //genpart.v.SetPxPyPzE( p->px() , p->py() , p->pz() , p->energy() );
       genpart.Part.v.SetPxPyPzE( p->px() , p->py() , p->pz() , p->energy() );

       // Extra properties

       genpart.Part.charge  = p->charge();
       genpart.charge  = p->charge();
       genpart.pdgId   = p->pdgId();
       genpart.name    = (pdt->particle(p->pdgId()))->name();
       genpart.status  = p->status();

       // Mother Daughter relations

       int nMo = p->numberOfMothers();
       int nDa = p->numberOfDaughters();
       int iMo1 = -1 , iMo2 = -1 ; 
       int iDa1 = -1 , iDa2 = -1 ; 

       found = find(cands.begin(), cands.end(), p->mother(0));
       if(found != cands.end()) iMo1 = found - cands.begin() ;
 
       found = find(cands.begin(), cands.end(), p->mother(nMo-1));
       if(found != cands.end()) iMo2 = found - cands.begin() ;

       found = find(cands.begin(), cands.end(), p->daughter(0));
       if(found != cands.end()) iDa1 = found - cands.begin() ;
 
       found = find(cands.begin(), cands.end(), p->daughter(nDa-1));
       if(found != cands.end()) iDa2 = found - cands.begin() ;

       if ( GenPartDebug )
       {
         cout << "Mother : " << iMo1 << " " << iMo2 << endl;
         cout << "Daugther: " << iDa1 << " " << iDa2 << endl;
       }

       genpart.mo1     = iMo1 ;
       genpart.mo2     = iMo2 ;
       genpart.da1     = iDa1 ;
       genpart.da2     = iDa2 ;

       // Store




       if(st==3)
       GenPart.push_back(genpart);

       if(fabs(genpart.pdgId)==11 && st==1)
	 GenElec.push_back(genpart);

       if(fabs(genpart.pdgId)==13 && st==1)
	 GenMu.push_back(genpart);
     
       if((fabs(genpart.pdgId)==12 && st==1)||(fabs(genpart.pdgId)==14 && st==1))
	 GenNu.push_back(genpart);
   }

}
// ------------ method called for each event  ------------
void
ThreePointCorrelatorEtaTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
{
  using namespace edm;
  using namespace std;

  edm::Handle<reco::VertexCollection> vertices;
  iEvent.getByLabel(vertexSrc_,vertices);
  double bestvz=-999.9, bestvx=-999.9, bestvy=-999.9;
  double bestvzError=-999.9, bestvxError=-999.9, bestvyError=-999.9;
  const reco::Vertex & vtx = (*vertices)[0];
  bestvz = vtx.z(); bestvx = vtx.x(); bestvy = vtx.y();
  bestvzError = vtx.zError(); bestvxError = vtx.xError(); bestvyError = vtx.yError();
  
  //first selection; vertices
  if(bestvz < vzLow_ || bestvz > vzHigh_ ) return;
  
  Handle<CaloTowerCollection> towers;
  iEvent.getByLabel(towerSrc_, towers);

  Handle<reco::TrackCollection> tracks;
  iEvent.getByLabel(trackSrc_, tracks);
  
  if( useCentrality_ ){

    CentralityProvider * centProvider = 0;
    if (!centProvider) centProvider = new CentralityProvider(iSetup);
    centProvider->newEvent(iEvent,iSetup);
    int hiBin = centProvider->getBin();
    cbinHist->Fill( hiBin );
    if( hiBin < Nmin_ || hiBin >= Nmax_ ) return;

  }

  const int NetaBins = etaBins_.size() - 1 ;

// initialize Qcos and Qsin

  double QcosTRK = 0.;
  double QsinTRK = 0.;
  double QcountsTrk = 0;

  double Q1[NetaBins][2][2];
  double Q1_count[NetaBins][2];

  double Q2[NetaBins][2][2];
  double Q2_count[NetaBins][2];

  for(int i = 0; i < NetaBins; i++){
    for(int j = 0; j < 2; j++){
      Q1_count[i][j] = 0.0;
      Q2_count[i][j] = 0.0;
      for(int k = 0; k < 2; k++){
        Q1[i][j][k] = 0.0;
        Q2[i][j][k] = 0.0;
      }
    }
  }

  int nTracks = 0;
  for(unsigned it = 0; it < tracks->size(); it++){

     const reco::Track & trk = (*tracks)[it];

     math::XYZPoint bestvtx(bestvx,bestvy,bestvz);
        
        double dzvtx = trk.dz(bestvtx);
        double dxyvtx = trk.dxy(bestvtx);
        double dzerror = sqrt(trk.dzError()*trk.dzError()+bestvzError*bestvzError);
        double dxyerror = sqrt(trk.d0Error()*trk.d0Error()+bestvxError*bestvyError);
        double nhits = trk.numberOfValidHits();
        double chi2n = trk.normalizedChi2();
        double nlayers = trk.hitPattern().trackerLayersWithMeasurement();
        chi2n = chi2n/nlayers;

        double weight = 1.0;

        if(!trk.quality(reco::TrackBase::highPurity)) continue;
        if(fabs(trk.ptError())/trk.pt() > offlineptErr_ ) continue;
        if(fabs(dzvtx/dzerror) > offlineDCA_) continue;
        if(fabs(dxyvtx/dxyerror) > offlineDCA_) continue;
        if(fabs(trk.eta()) < 2.4 && trk.pt() > 0.4 ){nTracks++;}// NtrkOffline        
        if(fabs(trk.eta()) > 2.4 || trk.pt() < ptLow_ || trk.pt() > ptHigh_) continue;
        if(chi2n > offlineChi2_) continue;
        if(nhits < offlinenhits_) continue;
        if( messAcceptance_ ) { if( trk.phi() < holeRight_ && trk.phi() > holeLeft_ ) continue;}
        if( doEffCorrection_ ){ weight = 1.0/effTable->GetBinContent( effTable->FindBin(trk.eta(), trk.pt()) );}
        else{ weight = 1.0; }
       
        trkPhi->Fill( trk.phi() );//make sure if messAcceptance is on or off

        QcosTRK += weight*cos( 2*trk.phi() );
        QsinTRK += weight*sin( 2*trk.phi() );
        QcountsTrk += weight;

        for(int eta = 0; eta < NetaBins; eta++){
          if( trk.eta() > etaBins_[eta] && trk.eta() < etaBins_[eta+1] ){

            if( trk.charge() == 1){
              Q1[eta][0][0] += weight*cos( trk.phi() );
              Q1[eta][0][1] += weight*sin( trk.phi() );
              Q1_count[eta][0] += weight;

              Q2[eta][0][0] += weight*weight*cos( 2*trk.phi() );
              Q2[eta][0][1] += weight*weight*sin( 2*trk.phi() );
              Q2_count[eta][0] += weight*weight;

            }
            else if( trk.charge() == -1){
              Q1[eta][1][0] += weight*cos( trk.phi() );
              Q1[eta][1][1] += weight*sin( trk.phi() );
              Q1_count[eta][1] += weight;

              Q2[eta][1][0] += weight*weight*cos( 2*trk.phi() );
              Q2[eta][1][1] += weight*weight*sin( 2*trk.phi() );
              Q2_count[eta][1] += weight*weight;

            }
          }
        }    


  } 

  if( !useCentrality_ ) if( nTracks < Nmin_ || nTracks >= Nmax_ ) return;
  
  Ntrk->Fill(nTracks);

//loop over calo towers (HF)

  double Q3[2][2];
  double ETT[2];

  for(int i = 0; i < 2; i++){
    ETT[i] = 0.;
    for(int j = 0; j < 2; j++){
      Q3[i][j] = 0.;
    }
  }

  int HFside = 2;
  if( useBothSide_ ) HFside = 1;

  for(unsigned i = 0; i < towers->size(); ++i){

        const CaloTower & hit= (*towers)[i];

        double caloEta = hit.eta();
        double caloPhi = hit.phi();
        double w = hit.hadEt( vtx.z() ) + hit.emEt( vtx.z() );
        
        if( reverseBeam_ ) caloEta = -hit.eta();
        if( messAcceptance_ ){if( caloPhi < holeRight_ && caloPhi > holeLeft_ ) continue;} hfPhi->Fill( caloPhi );//make sure if messAcceptance is on or off
        
        if( caloEta < etaHighHF_ && caloEta > etaLowHF_ ){
          
            Q3[0][0] += w*cos( -2*caloPhi );
            Q3[0][1] += w*sin( -2*caloPhi );
            ETT[0] += w;
        }
        else if( caloEta < -etaLowHF_ && caloEta > -etaHighHF_ ){

            Q3[1][0] += w*cos( -2*caloPhi );
            Q3[1][1] += w*sin( -2*caloPhi );
            ETT[1] += w;

        }
        else{continue;}
  }

  for(int ieta = 0; ieta < NetaBins; ieta++){
    for(int HF = 0; HF < HFside; HF++){
      for(int sign = 0; sign < 2; sign++){
        
        if( Q1_count[ieta][sign] == 0.0 || ETT[HF] == 0.0 ) continue;

          double Q_real = get3RealOverlap(Q1[ieta][sign][0], Q2[ieta][sign][0], Q3[HF][0], Q1[ieta][sign][1], Q2[ieta][sign][1], Q3[HF][1], Q1_count[ieta][sign], Q2_count[ieta][sign], ETT[HF] );
          QvsdEta[ieta][sign][HF]->Fill( Q_real, (Q1_count[ieta][sign]*Q1_count[ieta][sign] - Q2_count[ieta][sign])*ETT[HF] );

        } 
      if( Q1_count[ieta][0] == 0.0 || Q1_count[ieta][1] == 0.0 || ETT[HF] == 0.0 ) continue;

      double Q_real = get3Real(Q1[ieta][0][0]/Q1_count[ieta][0],Q1[ieta][1][0]/Q1_count[ieta][1],Q3[HF][0]/ETT[HF], Q1[ieta][0][1]/Q1_count[ieta][0], Q1[ieta][1][1]/Q1_count[ieta][1], Q3[HF][1]/ETT[HF]);
      QvsdEta[ieta][2][HF]->Fill( Q_real, Q1_count[ieta][0]*Q1_count[ieta][1]*ETT[HF] );  

    } 
  }

/*
calculate v2 using 3 sub-events method:
 */

  aveQ3[0][0]->Fill( Q3[0][0]/ETT[0], ETT[0] );//HF+ cos
  aveQ3[0][1]->Fill( Q3[0][1]/ETT[0], ETT[0] );//HF+ sin
  
  aveQ3[1][0]->Fill( Q3[1][0]/ETT[1], ETT[1] );//HF- cos
  aveQ3[1][1]->Fill( Q3[1][1]/ETT[1], ETT[1] );//HF- sin

  QcosTRK = QcosTRK/QcountsTrk;
  QsinTRK = QsinTRK/QcountsTrk;

  double QaQc = get2Real(Q3[1][0]/ETT[1], QcosTRK/QcountsTrk, Q3[1][1]/ETT[1], QsinTRK/QcountsTrk );
  double QaQb = get2Real(Q3[1][0]/ETT[1], Q3[0][0]/ETT[0], Q3[1][1]/ETT[1], -Q3[0][1]/ETT[0]);//an extra minus sign 
  double QcQb = get2Real(QcosTRK/QcountsTrk, Q3[0][0]/ETT[0], QsinTRK/QcountsTrk, Q3[0][1]/ETT[0]);

  c2_ac->Fill( QaQc, ETT[1]*QcountsTrk );
  c2_cb->Fill( QcQb, ETT[1]*ETT[0]  );
  c2_ab->Fill( QaQb, ETT[0]*QcountsTrk );

}
// ------------ method called to skim the data  ------------
bool MCBarrelEndcapFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
{
    using namespace edm;
    bool accepted = false;
    Handle<HepMCProduct> evt;
    iEvent.getByLabel(label_, evt);

    vector<HepMC::GenParticle*> barrel_passed;
    vector<HepMC::GenParticle*> endcap_passed;


    const HepMC::GenEvent * myGenEvent = evt->GetEvent();

    if(verbose) cout << "Start Event\n";

    for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
            p != myGenEvent->particles_end(); ++p ) {


        if(verbose) cout << abs((*p)->pdg_id()) << ' ' 
            << (*p)->momentum().perp() << ' ' 
            << (*p)->momentum().eta() << ' ' 
            << (*p)->status() << endl;
        // check for barrel conditions
        if ((abs((*p)->pdg_id()) == abs(barrelID) || barrelID == 0) &&
                (*p)->momentum().perp() > ptMinBarrel && (*p)->momentum().eta() > etaMinBarrel 
                && (*p)->momentum().eta() < etaMaxBarrel && ((*p)->status() == statusBarrel || statusBarrel == 0))
        { 
            if(verbose) cout << "Found Barrel\n";
            // passed barrel conditions ...
            // ... now check pair-conditions with endcap passed particles
            //
            unsigned int i=0;
            double invmass =0.;
            while(!accepted && i<endcap_passed.size()) {
                invmass = ( math::PtEtaPhiMLorentzVector((*p)->momentum()) + math::PtEtaPhiMLorentzVector(endcap_passed[i]->momentum())).mass();
                if(verbose) cout << "Invariant Mass is" << invmass << endl;
                if(invmass > minInvMass && invmass < maxInvMass) {
                    accepted = true;
                }
                i++;
            }    
            // if we found a matching pair quit the loop
            if(accepted) break;
            else{
                barrel_passed.push_back(*p);   // else remember the particle to have passed barrel conditions
            }
        }

        // check for endcap conditions

        if ((abs((*p)->pdg_id()) == abs(endcapID) || endcapID == 0) && 
                (*p)->momentum().perp() > ptMinEndcap && (*p)->momentum().eta() > etaMinEndcap
                && (*p)->momentum().eta() < etaMaxEndcap && ((*p)->status() == statusEndcap || statusEndcap == 0)) { 
            if(verbose) cout << "Found Endcap\n";
            // passed endcap conditions ...
            // ... now check pair-conditions with barrel passed particles vector
            unsigned int i=0;
            double invmass =0.;
            while(!accepted && i<barrel_passed.size()) {
                if((*p) != barrel_passed[i]) {
                    if(verbose) cout << "Checking to match Barrel\n";
                    invmass = ( math::PtEtaPhiMLorentzVector((*p)->momentum()) + math::PtEtaPhiMLorentzVector(barrel_passed[i]->momentum())).mass();
                    if(verbose) cout << "Invariant Mass is" << invmass << endl;
                    if(invmass > minInvMass && invmass < maxInvMass) {
                        accepted = true;
                    }
                    i++;
                }
            }    
            // if we found a matching pair quit the loop
            if(accepted) break;
            else {
                endcap_passed.push_back(*p);   // else remember the particle to have passed endcap conditions
            }
        }
    }

    if(verbose)
    {
        cout << "This event ";
        if (accepted){ cout <<  "passed "; } else {cout << "failed ";}
        cout << "the filter\n";
    }

    return accepted;

}
Exemplo n.º 7
0
void UAHiggsTree::GetGenKin(const edm::Event& iEvent)
{
   using namespace std;
   using namespace edm;
   using namespace reco;

/* 
   // MC Process Id and PtHat for AOD

   Handle< int > genProcessID;
   iEvent.getByLabel( "genEventProcID", genProcessID );
   int processId = *genProcessID;
   cout<<"Process ID : "<<processId<<endl;

*/

   //K Factor For Signal
   edm::Handle<double> KFactor;
   try {
    iEvent.getByLabel("KFactorProducer",KFactor);
    double kfactor = *KFactor;
    GenKin.kfactor=kfactor;
   }
   catch (...){;}

   /*
   // MC Process Id and PtHat for RECO
   Handle<HepMCProduct> hepMCHandle;
   iEvent.getByLabel(hepMCColl_, hepMCHandle ) ;
   const HepMC::GenEvent* GenEvt = hepMCHandle->GetEvent() ;
   int processId = GenEvt->signal_process_id();
   if (GenKinDebug) cout<<"Process ID2: "<<processId<<endl; 
   double ptHat  = GenEvt->event_scale();
   if (GenKinDebug) cout<<"PtHat MC : "<<ptHat<<endl; 

   GenKin.MCProcId  = processId ; 
   GenKin.Scale     = ptHat ;

   // PDF Info -> x,Q, parton id's -> see HepMC manual
   const HepMC::PdfInfo* PdfInfo = GenEvt->pdf_info();
   double x1 = PdfInfo->x1();
   double x2 = PdfInfo->x2();
   double Q  = PdfInfo->scalePDF(); 

   int id1 = PdfInfo->id1();
   int id2 = PdfInfo->id2();

   GenKin.x1 = x1 ;
   GenKin.x2 = x2 ;
   GenKin.Q  = Q  ;
   GenKin.Part1Id = id1 ; 
   GenKin.Part2Id = id2 ; */

   // Gen MET: From GenMETCollection  

   Handle<GenMETCollection> genmet;
//   iEvent.getByLabel(GenMetColl_ , genmet);
   iEvent.getByLabel("genMetTrue" , genmet);

   if (GenKinDebug) 
   { 
     cout << "GenMET et()  = " << (genmet->front()).et() << endl ;
     cout << "GenMET px()  = " << (genmet->front()).px() << endl ;
     cout << "GenMET py()  = " << (genmet->front()).py() << endl ;
     cout << "GenMET phi() = " << (genmet->front()).phi() << endl;
   }

   GenKin.Met    = (genmet->front()).et() ; 
   GenKin.MetX   = (genmet->front()).px() ; 
   GenKin.MetY   = (genmet->front()).py() ; 
   GenKin.MetPhi = (genmet->front()).phi() ; 

   // Gen MET: From GenPart Neutrinos ( no SUSY !!! )

   // ... Handle to access GenParticleCollection
   Handle<GenParticleCollection> genParticles;
   iEvent.getByLabel(genPartColl_, genParticles);
   if (!genParticles.isValid()) {
     cerr << "[UAHiggsTree::GetGenKin] Error: non valid GenParticleCollection " << endl;
     return;
   }
 
   double met1Px = 0 ;
   double met1Py = 0 ;
   double met1Pz = 0 ;
   double met1E  = 0 ;

   double met3Px = 0 ;
   double met3Py = 0 ;
   double met3Pz = 0 ;
   double met3E  = 0 ;

   // ... Loop on stable (final) particles
   for(GenParticleCollection::const_iterator p = genParticles->begin(); p != genParticles->end(); ++ p) 
   {
     int st  = p->status();
     int pid = p->pdgId();
     if ( st == 1 && ( abs(pid)==12 || abs(pid)==14 || abs(pid)==16 ) )
     {
       met1Px += p->px();
       met1Py += p->py();
       met1Pz += p->pz();
       met1E  += p->energy();
     } 
     else if ( st == 3 && ( abs(pid)==12 || abs(pid)==14 || abs(pid)==16 ) )
     {
       met3Px += p->px();
       met3Py += p->py();
       met3Pz += p->pz();
       met3E  += p->energy();
     }
   }

   // ... Set Missing Et 4-Vector
   GenKin.MetGP1.SetPxPyPzE( met1Px , met1Py , met1Pz , met1E ) ;
   GenKin.MetGP3.SetPxPyPzE( met3Px , met3Py , met3Pz , met3E ) ;

}
Exemplo n.º 8
0
void UAHiggsTree::GetRecoMuon(const edm::Event& iEvent, const edm::EventSetup& iSetup,
                                                       const string globalMuonCollection_, vector<MyMuon>& MuonVector )
{
   using namespace std;
   using namespace edm;
   using namespace reco;

   // BORIS 3D IP stuff: Declaration
   ESHandle<TransientTrackBuilder> theTTBuilder;
   iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theTTBuilder);


   MuonVector.clear();

   Handle<MuonCollection> muonsHandle;
   try {
     iEvent.getByLabel(globalMuonCollection_,muonsHandle);
   } catch ( cms::Exception& ex ) {
    printf("Error! can't get globalMuon collection\n");
   }
   const MuonCollection & muons = *(muonsHandle.product());

   for (reco::MuonCollection::const_iterator iMuon = muons.begin(); 
        iMuon != muons.end(); iMuon++) {

     MyMuon muon;     
     
     // Global Muon
   
     muon.pt  = iMuon->pt(); 
     muon.px  = iMuon->px(); 
     muon.py  = iMuon->py(); 
     muon.pz  = iMuon->pz(); 
     muon.e   = sqrt(iMuon->momentum().mag2()+MASS_MU*MASS_MU); 
     muon.eta = iMuon->eta(); 
     muon.phi = iMuon->phi(); 
     
     
     muon.Part.v.SetPxPyPzE(iMuon->px(),
                            iMuon->py(),
                            iMuon->pz(), 
                            sqrt(iMuon->momentum().mag2()+MASS_MU*MASS_MU));
     muon.Part.charge = iMuon->charge();

     // Global Properties

     muon.nChambers             = iMuon -> numberOfChambers();
     muon.nChambersMatched      = iMuon -> numberOfMatches();
     
     muon.AllGlobalMuons                          =  muon::isGoodMuon(*iMuon,muon::AllGlobalMuons);
     muon.AllStandAloneMuons                      =  muon::isGoodMuon(*iMuon,muon::AllStandAloneMuons);
     muon.AllTrackerMuons                         =  muon::isGoodMuon(*iMuon,muon::AllTrackerMuons);
     muon.TrackerMuonArbitrated                   =  muon::isGoodMuon(*iMuon,muon::TrackerMuonArbitrated);
     muon.AllArbitrated                           =  muon::isGoodMuon(*iMuon,muon::AllArbitrated);
     muon.GlobalMuonPromptTight                   =  muon::isGoodMuon(*iMuon,muon::GlobalMuonPromptTight);
     muon.TMLastStationLoose                      =  muon::isGoodMuon(*iMuon,muon::TMLastStationLoose);
     muon.TMLastStationTight                      =  muon::isGoodMuon(*iMuon,muon::TMLastStationTight);
     muon.TM2DCompatibilityLoose                  =  muon::isGoodMuon(*iMuon,muon::TM2DCompatibilityLoose);
     muon.TM2DCompatibilityTight                  =  muon::isGoodMuon(*iMuon,muon::TM2DCompatibilityTight);
     muon.TMOneStationLoose                       =  muon::isGoodMuon(*iMuon,muon::TMOneStationLoose);
     muon.TMOneStationTight                       =  muon::isGoodMuon(*iMuon,muon::TMOneStationTight);
     muon.TMLastStationOptimizedLowPtLoose        =  muon::isGoodMuon(*iMuon,muon::TMLastStationOptimizedLowPtLoose);
     muon.TMLastStationOptimizedLowPtTight        =  muon::isGoodMuon(*iMuon,muon::TMLastStationOptimizedLowPtTight);
     muon.GMTkChiCompatibility                    =  muon::isGoodMuon(*iMuon,muon::GMTkChiCompatibility);
     muon.GMStaChiCompatibility                   =  muon::isGoodMuon(*iMuon,muon::GMStaChiCompatibility);
     muon.GMTkKinkTight                           =  muon::isGoodMuon(*iMuon,muon::GMTkKinkTight);
     muon.TMLastStationAngLoose                   =  muon::isGoodMuon(*iMuon,muon::TMLastStationAngLoose);
     muon.TMLastStationAngTight                   =  muon::isGoodMuon(*iMuon,muon::TMLastStationAngTight);
     muon.TMOneStationAngLoose                    =  muon::isGoodMuon(*iMuon,muon::TMOneStationAngLoose);
     muon.TMOneStationAngTight                    =  muon::isGoodMuon(*iMuon,muon::TMOneStationAngTight);
     muon.TMLastStationOptimizedBarrelLowPtLoose  =  muon::isGoodMuon(*iMuon,muon::TMLastStationOptimizedBarrelLowPtLoose);
     muon.TMLastStationOptimizedBarrelLowPtTight  =  muon::isGoodMuon(*iMuon,muon::TMLastStationOptimizedBarrelLowPtTight);
     
 
     muon.isoR03sumPt   = iMuon->isolationR03().sumPt   ;
     muon.isoR03emEt    = iMuon->isolationR03().emEt    ;
     muon.isoR03hadEt   = iMuon->isolationR03().hadEt   ;
     muon.isoR03hoEt    = iMuon->isolationR03().hoEt    ;
     muon.isoR03nTracks = iMuon->isolationR03().nTracks ;
     muon.isoR03nJets   = iMuon->isolationR03().nJets   ;

     muon.isoR05sumPt   = iMuon->isolationR05().sumPt   ;
     muon.isoR05emEt    = iMuon->isolationR05().emEt    ;
     muon.isoR05hadEt   = iMuon->isolationR05().hadEt   ;
     muon.isoR05hoEt    = iMuon->isolationR05().hoEt    ;
     muon.isoR05nTracks = iMuon->isolationR05().nTracks ;
     muon.isoR05nJets   = iMuon->isolationR05().nJets   ;

     muon.calEnergyEm   = iMuon->calEnergy().em   ; 
     muon.calEnergyHad  = iMuon->calEnergy().had  ;
     muon.calEnergyHo   = iMuon->calEnergy().ho   ;
     muon.calEnergyEmS9 = iMuon->calEnergy().emS9 ;
     muon.calEnergyHadS9= iMuon->calEnergy().hadS9;
     muon.calEnergyHoS9 = iMuon->calEnergy().hoS9 ;

     muon.IsGlobalMuon      = iMuon->isGlobalMuon()     ;
     muon.IsTrackerMuon     = iMuon->isTrackerMuon()    ;
     muon.IsStandaloneMuon  = iMuon->isStandAloneMuon() ;
     muon.IsCaloMuon        = iMuon->isCaloMuon()       ;

     
     
 

     // Global Muon Track
   
   if(iMuon->globalTrack().isAvailable()){
    
    reco::TrackRef glTrack = iMuon->globalTrack();
   
    muon.globalTrack.Part.v.SetPxPyPzE(glTrack->momentum().x(),
                                         glTrack->momentum().y(),
                                         glTrack->momentum().z(),
                                         sqrt(glTrack->momentum().mag2()+MASS_MU*MASS_MU));

     muon.globalTrack.Part.charge = glTrack->charge();
     muon.globalTrack.numberOfValidTkHits    =  glTrack->hitPattern().numberOfValidTrackerHits();
     muon.globalTrack.numberOfValidMuonHits  =  glTrack->hitPattern().numberOfValidMuonHits();
     
   //  cout<<glTrack->hitPattern().numberOfValidTrackerHits()<<endl;
   //  cout<<glTrack->hitPattern().numberOfValidMuonHits()<<endl;
     
     
     muon.globalTrack.numberOfValidStripHits    =  glTrack->hitPattern().numberOfValidStripHits();
     muon.globalTrack.numberOfValidPixelHits    =  glTrack->hitPattern().numberOfValidPixelHits();
     muon.globalTrack.numberOfValidMuonRPCHits  =  glTrack->hitPattern().numberOfValidMuonRPCHits();
     muon.globalTrack.numberOfValidMuonCSCHits  =  glTrack->hitPattern().numberOfValidMuonCSCHits();
     muon.globalTrack.numberOfValidMuonDTHits   =  glTrack->hitPattern().numberOfValidMuonDTHits();
     
    
    
     muon.globalTrack.nhit  =  glTrack->hitPattern().numberOfValidHits();
     muon.globalTrack.chi2n =  glTrack->normalizedChi2();
     muon.globalTrack.dz    =  glTrack->dz();

     muon.globalTrack.d0    =  glTrack->d0();

     muon.globalTrack.edz   =  glTrack->dzError();
     muon.globalTrack.ed0   =  glTrack->d0Error();
     muon.globalTrack.ept   =  glTrack->ptError();

     muon.globalTrack.vx    =  glTrack->vertex().x();
     muon.globalTrack.vy    =  glTrack->vertex().y();
     muon.globalTrack.vz    =  glTrack->vertex().z();

     muon.globalTrack.quality[0] = glTrack->quality(reco::TrackBase::qualityByName("loose"));
     muon.globalTrack.quality[1] = glTrack->quality(reco::TrackBase::qualityByName("tight"));
     muon.globalTrack.quality[2] = glTrack->quality(reco::TrackBase::qualityByName("highPurity"));

     muon.globalTrack.vtxid.clear();
     muon.globalTrack.vtxdxy.clear();
     muon.globalTrack.vtxdz.clear();

     for ( int i = 0 ; i != vtxid ; i++ )
     {
        muon.globalTrack.vtxid.push_back( i );
        muon.globalTrack.vtxdxy.push_back( glTrack->dxy( vtxid_xyz[i] ) );
        muon.globalTrack.vtxdz.push_back(  glTrack->dz( vtxid_xyz[i] )  );
     }

    }
    
    else {
     
      muon.globalTrack.d0 = -999;
      for ( int i = 0 ; i != vtxid ; i++ )
       {
         
	  muon.globalTrack.vtxid.push_back( i );
          muon.globalTrack.vtxdxy.push_back( -999 );
          muon.globalTrack.vtxdz.push_back( -999 );
       }
     
    }
    
    
   
    
     // Inner Muon Track
     
   if(iMuon->innerTrack().isAvailable()){
     
     reco::TrackRef inTrack = iMuon->innerTrack();
     muon.innerTrack.Part.v.SetPxPyPzE(inTrack->momentum().x(),
                                         inTrack->momentum().y(),
                                         inTrack->momentum().z(),
                                         sqrt(inTrack->momentum().mag2()+MASS_MU*MASS_MU));
     muon.innerTrack.Part.charge = inTrack->charge();
     
     muon.innerTrack.numberOfValidTkHits    =  inTrack->hitPattern().numberOfValidTrackerHits();
     muon.innerTrack.numberOfValidMuonHits  =  inTrack->hitPattern().numberOfValidMuonHits();
    
     muon.innerTrack.numberOfValidStripHits    =  inTrack->hitPattern().numberOfValidStripHits();
     muon.innerTrack.numberOfValidPixelHits    =  inTrack->hitPattern().numberOfValidPixelHits();
     muon.innerTrack.numberOfValidMuonRPCHits  =  inTrack->hitPattern().numberOfValidMuonRPCHits();
     muon.innerTrack.numberOfValidMuonCSCHits  =  inTrack->hitPattern().numberOfValidMuonCSCHits();
     muon.innerTrack.numberOfValidMuonDTHits   =  inTrack->hitPattern().numberOfValidMuonDTHits();
     
     muon.innerTrack.nhit  =  inTrack->hitPattern().numberOfValidHits();
     muon.innerTrack.chi2n =  inTrack->normalizedChi2();
     muon.innerTrack.dz    =  inTrack->dz();
     muon.innerTrack.d0    =  inTrack->d0();
     muon.innerTrack.edz   =  inTrack->dzError();
     muon.innerTrack.ed0   =  inTrack->d0Error();
     muon.innerTrack.ept   =  inTrack->ptError();

     muon.innerTrack.vx    =  inTrack->vertex().x();
     muon.innerTrack.vy    =  inTrack->vertex().y();
     muon.innerTrack.vz    =  inTrack->vertex().z();

     muon.innerTrack.quality[0] = inTrack->quality(reco::TrackBase::qualityByName("loose"));
     muon.innerTrack.quality[1] = inTrack->quality(reco::TrackBase::qualityByName("tight"));
     muon.innerTrack.quality[2] = inTrack->quality(reco::TrackBase::qualityByName("highPurity"));

     muon.innerTrack.vtxid.clear();
     muon.innerTrack.vtxdxy.clear();
     muon.innerTrack.vtxdz.clear();

     for ( int i = 0 ; i != vtxid ; i++ )
     {
        muon.innerTrack.vtxid.push_back( i );
        muon.innerTrack.vtxdxy.push_back( inTrack->dxy( vtxid_xyz[i] ) );
        muon.innerTrack.vtxdz.push_back(  inTrack->dz( vtxid_xyz[i] )  );
     }

     // Boris 3D IP Stuff
     int iVtx = 0;
     muon.vtxid.clear();
     muon.tip.clear();
     muon.tipErr.clear();
     muon.ip.clear();
     muon.ipErr.clear();
     muon.tip2.clear();
     muon.tip2Err.clear();
     muon.ip2.clear();
     muon.ip2Err.clear();

     // ... redo muon trajectory
     reco::TransientTrack tt = theTTBuilder->build(iMuon->innerTrack());
     // ... get beamspot + first entry in IP respecting BS
     edm::Handle<reco::BeamSpot> bs;
     iEvent.getByLabel(edm::InputTag("offlineBeamSpot"),bs);
     reco::Vertex bsvtx = reco::Vertex(reco::Vertex::Point(bs->position().x(),bs->position().y(),bs->position().z()),reco::Vertex::Error());
          Measurement1D ip     = IPTools::absoluteTransverseImpactParameter(tt,bsvtx).second;
          Measurement1D ip3D   = IPTools::absoluteImpactParameter3D(tt,bsvtx).second;
          muon.vtxid.push_back( iVtx );
          ++iVtx;
          muon.tip.push_back(    ip.value()  );
          muon.tipErr.push_back( ip.error() );
          muon.ip.push_back(     ip3D.value() );
          muon.ipErr.push_back(  ip3D.error() );
          muon.tip2.push_back(    ip.value()  );
          muon.tip2Err.push_back( ip.error() );
          muon.ip2.push_back(     ip3D.value() );
          muon.ip2Err.push_back(  ip3D.error() );


     // ... Loop on vtx collections
     for (unsigned int ivc=0; ivc!= vertexs.size(); ivc++){

       // ... get vertex collection
       edm::Handle<reco::VertexCollection> vertices;
       iEvent.getByLabel(vertexs.at(ivc),vertices);
       //cout << vertexs.at(ivc) << " -> size = " << vertices->end()-vertices->begin() <<  endl;  

       // ... prepare refitting
       VertexReProducer revertex(vertices, iEvent); 
       Handle<reco::BeamSpot>        pvbeamspot; 
       iEvent.getByLabel(revertex.inputBeamSpot(), pvbeamspot);
   
         // ... Loop on vtx in curent collection
         for(VertexCollection::const_iterator pvtx=vertices->begin(); pvtx!= vertices->end() ; ++pvtx)
         {

           reco::Vertex vertexYesB;
           reco::Vertex vertexNoB;
           reco::TrackCollection newTkCollection;

           vertexYesB = *pvtx ;   

           // ... Remove lepton track
           bool foundMatch(false);
           for (reco::Vertex::trackRef_iterator itk = pvtx->tracks_begin(); itk!=pvtx->tracks_end(); ++itk) 
           {
              bool refMatching = (itk->get() == &*(iMuon->innerTrack()) );
              if(refMatching){
                foundMatch = true;
              }else{
                newTkCollection.push_back(*itk->get());
              }     
           }//track collection for vertexNoB is set

          //cout << "checking mu matching" << endl;
          if(!foundMatch) {
	    //cout << "WARNING: no muon matching found" << endl;
	    vertexNoB = vertexYesB;
          }else{      
            vector<TransientVertex> pvs = revertex.makeVertices(newTkCollection, *pvbeamspot, iSetup) ;
            //cout << pvs.size() << endl;
            if(pvs.empty()) {
                vertexNoB = reco::Vertex(reco::Vertex::Point(bs->position().x(),bs->position().y(),bs->position().z()),
                        reco::Vertex::Error());
            } else {
	      //vertexNoB = findClosestVertex<TransientVertex>(zPos,pvs);
	      vertexNoB = pvs.front(); //take the first in the list
            }
          }

          // ... Compute 3D IP
 
          Measurement1D ip     = IPTools::absoluteTransverseImpactParameter(tt,vertexYesB).second;
          Measurement1D ip3D   = IPTools::absoluteImpactParameter3D(tt,vertexYesB).second;
          Measurement1D ip_2   = IPTools::absoluteTransverseImpactParameter(tt,vertexNoB).second;
          Measurement1D ip3D_2 = IPTools::absoluteImpactParameter3D(tt,vertexNoB).second;

          muon.vtxid.push_back( iVtx );
          ++iVtx;
          muon.tip.push_back(    ip.value()  );
          muon.tipErr.push_back( ip.error() );
          muon.ip.push_back(     ip3D.value() );
          muon.ipErr.push_back(  ip3D.error() );
          muon.tip2.push_back(    ip_2.value()  );
          muon.tip2Err.push_back( ip_2.error() );
          muon.ip2.push_back(     ip3D_2.value() );
          muon.ip2Err.push_back(  ip3D_2.error() );
/*
          if (foundMatch){
            cout << ip3D.value() << " " << ip3D_2.value() << endl;
          } 
*/
         } // END ... Loop on vtx in curent collection

       } // END ... Loop on vtx collections

     } else {
     
      muon.innerTrack.d0 = -999;
      for ( int i = 0 ; i != vtxid ; i++ )
       {
          muon.innerTrack.vtxid.push_back( i );
          muon.innerTrack.vtxdxy.push_back( -999 ) ;
          muon.innerTrack.vtxdz.push_back( -999 );
          muon.vtxid.push_back( i ) ;
          muon.tip.push_back(    -999 ) ;
          muon.tipErr.push_back( -999 ) ;
          muon.ip.push_back(     -999 ) ;
          muon.ipErr.push_back(  -999 ) ;
          muon.tip2.push_back(   -999 ) ; 
          muon.tip2Err.push_back(-999 ) ; 
          muon.ip2.push_back(    -999 ) ; 
          muon.ip2Err.push_back( -999 ) ; 


       }
     
    }
     
     // Outer Muon Track
     
   if(iMuon->outerTrack().isAvailable()){
     
     reco::TrackRef outTrack = iMuon->outerTrack();
     muon.outerTrack.Part.v.SetPxPyPzE(outTrack->momentum().x(),
                                         outTrack->momentum().y(),
                                         outTrack->momentum().z(),
                                         sqrt(outTrack->momentum().mag2()+MASS_MU*MASS_MU));
     muon.outerTrack.Part.charge = outTrack->charge();
     muon.outerTrack.numberOfValidTkHits    =  outTrack->hitPattern().numberOfValidTrackerHits();
     muon.outerTrack.numberOfValidMuonHits  =  outTrack->hitPattern().numberOfValidMuonHits();
     
     muon.outerTrack.numberOfValidStripHits    =  outTrack->hitPattern().numberOfValidStripHits();
     muon.outerTrack.numberOfValidPixelHits    =  outTrack->hitPattern().numberOfValidPixelHits();
     muon.outerTrack.numberOfValidMuonRPCHits  =  outTrack->hitPattern().numberOfValidMuonRPCHits();
     muon.outerTrack.numberOfValidMuonCSCHits  =  outTrack->hitPattern().numberOfValidMuonCSCHits();
     muon.outerTrack.numberOfValidMuonDTHits   =  outTrack->hitPattern().numberOfValidMuonDTHits();
     
     
     
     muon.outerTrack.nhit  =  outTrack->hitPattern().numberOfValidHits();
     muon.outerTrack.chi2n =  outTrack->normalizedChi2();
     muon.outerTrack.dz    =  outTrack->dz();
     muon.outerTrack.d0    =  outTrack->d0();
     muon.outerTrack.edz   =  outTrack->dzError();
     muon.outerTrack.ed0   =  outTrack->d0Error();
     muon.outerTrack.ept   =  outTrack->ptError();

     muon.outerTrack.vx    =  outTrack->vertex().x();
     muon.outerTrack.vy    =  outTrack->vertex().y();
     muon.outerTrack.vz    =  outTrack->vertex().z();

     muon.outerTrack.quality[0] = outTrack->quality(reco::TrackBase::qualityByName("loose"));
     muon.outerTrack.quality[1] = outTrack->quality(reco::TrackBase::qualityByName("tight"));
     muon.outerTrack.quality[2] = outTrack->quality(reco::TrackBase::qualityByName("highPurity"));

     muon.outerTrack.vtxid.clear();
     muon.outerTrack.vtxdxy.clear();
     muon.outerTrack.vtxdz.clear();

     for ( int i = 0 ; i != vtxid ; i++ )
     {
        muon.outerTrack.vtxid.push_back( i );
        muon.outerTrack.vtxdxy.push_back( outTrack->dxy( vtxid_xyz[i] ) );
        muon.outerTrack.vtxdz.push_back(  outTrack->dz( vtxid_xyz[i] )  );
     }
    }

    else {
      
      muon.outerTrack.d0 = -999;
      for ( int i = 0 ; i != vtxid ; i++ )
       {
          muon.outerTrack.vtxid.push_back( i );
          muon.outerTrack.vtxdxy.push_back( -999 );
          muon.outerTrack.vtxdz.push_back( -999 );
       }
     
    }
     
     
     
     MuonVector.push_back(muon);

   } // end for MuonCollection 

}
Exemplo n.º 9
0
void ChPartTree::GetFwdGap(const edm::Event& iEvent , const edm::EventSetup& iSetup )
{
   using namespace std;


  int nTowersHF_plus = 0;
  int nTowersHF_minus = 0;
  int nTowersHE_plus = 0;
  int nTowersHE_minus = 0;
  int nTowersHB_plus = 0;
  int nTowersHB_minus = 0;
  int nTowersEE_plus = 0;
  int nTowersEE_minus = 0;
  int nTowersEB_plus = 0;
  int nTowersEB_minus = 0; 
  //Sum(E)
  double sumEHF_plus = 0.;
  double sumEHF_minus = 0.;
  double sumEHE_plus = 0.;
  double sumEHE_minus = 0.;
  double sumEHB_plus = 0.;
  double sumEHB_minus = 0.;
  double sumEEE_plus = 0.;
  double sumEEE_minus = 0.;
  double sumEEB_plus = 0.;
  double sumEEB_minus = 0.;
  // Sum(ET)
  double sumETHF_plus = 0.;
  double sumETHF_minus = 0.;
  double sumETHE_plus = 0.;
  double sumETHE_minus = 0.;
  double sumETHB_plus = 0.;
  double sumETHB_minus = 0.;
  double sumETEE_plus = 0.;
  double sumETEE_minus = 0.;
  double sumETEB_plus = 0.;
  double sumETEB_minus = 0.;

  FwdGap.Reset();

  // Calo tower collection from event
  edm::Handle<CaloTowerCollection> towerCollectionH;
  iEvent.getByLabel(caloTowerTag_,towerCollectionH);
  const CaloTowerCollection& towerCollection = *towerCollectionH;

  // Loop over calo towers
  CaloTowerCollection::const_iterator calotower = towerCollection.begin();
  CaloTowerCollection::const_iterator calotowers_end = towerCollection.end();
  for(; calotower != calotowers_end; ++calotower) {
     bool hasHCAL = false;
     bool hasHF = false;
     bool hasHE = false;
     bool hasHB = false;
     bool hasHO = false;
     bool hasECAL = false;
     bool hasEE = false;
     bool hasEB = false;     
     for(size_t iconst = 0; iconst < calotower->constituentsSize(); iconst++){
        DetId detId = calotower->constituent(iconst);
        if(detId.det()==DetId::Hcal){
           hasHCAL = true;
           HcalDetId hcalDetId(detId);
           if(hcalDetId.subdet()==HcalForward) hasHF = true;
           else if(hcalDetId.subdet()==HcalEndcap) hasHE = true;
           else if(hcalDetId.subdet()==HcalBarrel) hasHB = true;
           else if(hcalDetId.subdet()==HcalOuter) hasHO = true;  
        } else if(detId.det()==DetId::Ecal){
           hasECAL = true;
           EcalSubdetector ecalSubDet = (EcalSubdetector)detId.subdetId();
           if(ecalSubDet == EcalEndcap) hasEE = true;
           else if(ecalSubDet == EcalBarrel) hasEB = true;
        }
     }

     int zside = calotower->zside();
     double caloTowerEnergy = calotower->energy();
     // FIXME
     //double caloTowerET = calotower->et(primVtx.position());
     //double caloTowerET = calotower->et(primVtx.z());
     double caloTowerET = calotower->et();

     // HCAL: Towers made of at least one component from HB,HE,HF
     if( hasHF && !hasHE ){
        if( caloTowerEnergy >= energyThresholdHF_ ){
           if(zside >= 0){
              ++nTowersHF_plus;
              sumEHF_plus += caloTowerEnergy; 
              sumETHF_plus += caloTowerET;
           } else{
              ++nTowersHF_minus;
              sumEHF_minus += caloTowerEnergy;
              sumETHF_minus += caloTowerET;
           } 
        }
     } else if( hasHE && !hasHF && !hasHB ){
        if( caloTowerEnergy >= energyThresholdHE_ ){
           if(zside >= 0){
              ++nTowersHE_plus;
              sumEHE_plus += caloTowerEnergy;
              sumETHE_plus += caloTowerET;
           } else{
              ++nTowersHE_minus;
              sumEHE_minus += caloTowerEnergy;
              sumETHE_minus += caloTowerET;
           }
        }
     } else if( hasHB && !hasHE ){
        if( caloTowerEnergy >= energyThresholdHB_ ){
           if(zside >= 0){
              ++nTowersHB_plus;
              sumEHB_plus += caloTowerEnergy;
              sumETHB_plus += caloTowerET;
           } else{
              ++nTowersHB_minus;
              sumEHB_minus += caloTowerEnergy;
              sumETHB_minus += caloTowerET;
           }
        }
     }

     // ECAL: Towers made of at least one component from EB,EE
     if( hasEE && !hasEB ){
        if( caloTowerEnergy >= energyThresholdEE_ ){
           if(zside >= 0){
              ++nTowersEE_plus;
              sumEEE_plus += caloTowerEnergy;
              sumETEE_plus += caloTowerET;
           } else{
              ++nTowersEE_minus;
              sumEEE_minus += caloTowerEnergy;
              sumETEE_minus += caloTowerET;
           }
        }
     } else if( hasEB && !hasEE ){
        if( caloTowerEnergy >= energyThresholdEB_ ){
           if(zside >= 0){
              ++nTowersEB_plus;
              sumEEB_plus += caloTowerEnergy;
              sumETEB_plus += caloTowerET;
           } else{
              ++nTowersEB_minus;
              sumEEB_minus += caloTowerEnergy;
              sumETEB_minus += caloTowerET;
           }
        }
     }
  }

   FwdGap.nTowersHF_plus = nTowersHF_plus ;
   FwdGap.nTowersHF_minus = nTowersHF_minus ;
   FwdGap.nTowersHE_plus = nTowersHE_plus ;
   FwdGap.nTowersHE_minus = nTowersHE_minus ;
   FwdGap.nTowersHB_plus = nTowersHB_plus ;
   FwdGap.nTowersHB_minus = nTowersHB_minus ;
   FwdGap.nTowersEE_plus = nTowersEE_plus ;
   FwdGap.nTowersEE_minus = nTowersEE_minus ;
   FwdGap.nTowersEB_plus = nTowersEB_plus ;
   FwdGap.nTowersEB_minus = nTowersEB_minus ;
   FwdGap.sumEHF_plus = sumEHF_plus ;
   FwdGap.sumEHF_minus = sumEHF_minus ;
   FwdGap.sumEHE_plus = sumEHE_plus ;
   FwdGap.sumEHE_minus = sumEHE_minus ;
   FwdGap.sumEHB_plus = sumEHB_plus ;
   FwdGap.sumEHB_minus = sumEHB_minus ;
   FwdGap.sumEEE_plus = sumEEE_plus ;
   FwdGap.sumEEE_minus = sumEEE_minus ;
   FwdGap.sumEEB_plus = sumEEB_plus ;
   FwdGap.sumEEB_minus = sumEEB_minus ;
   FwdGap.sumETHF_plus = sumETHF_plus ;
   FwdGap.sumETHF_minus = sumETHF_minus ;
   FwdGap.sumETHE_plus = sumETHE_plus ;
   FwdGap.sumETHE_minus = sumETHE_minus ;
   FwdGap.sumETHB_plus = sumETHB_plus ;
   FwdGap.sumETHB_minus = sumETHB_minus ;
   FwdGap.sumETEE_plus = sumETEE_plus ;
   FwdGap.sumETEE_minus = sumETEE_minus ;
   FwdGap.sumETEB_plus = sumETEB_plus ;
   FwdGap.sumETEB_minus = sumETEB_minus ;


/*
   cout << "[FwdGap]: " << sumEHF_plus << " " << sumEHF_minus << " " 
                        << sumEHE_plus << " " << sumEHE_minus << " "
                        << sumEHB_plus << " " << sumEHB_minus << " "
                        << sumEEE_plus << " " << sumEEE_minus << " "
                        << sumEEB_plus << " " << sumEEB_minus << " " << endl ;
*/
}
Exemplo n.º 10
0
void UAHiggsTree::GetGenJet(const edm::Event& iEvent , const edm::EventSetup& iSetup,
                            const string GenJetCollection_ , vector<MyGenJet>& JetVector )
{
   using namespace std;
   using namespace edm;
   using namespace reco;

   // Clear

   JetVector.clear();
   

   // Handle to access PDG data from iSetup
   ESHandle <ParticleDataTable> pdt;
   iSetup.getData( pdt );


   // get gen jet collection
   Handle<GenJetCollection> genjets;
   iEvent.getByLabel(GenJetCollection_, genjets);
   
   for(GenJetCollection::const_iterator genjet=genjets->begin();genjet!=genjets->end();genjet++){ 
     
      MyGenJet Jet;
      
      Jet.et  = genjet->et();
      Jet.pt  = genjet->pt();
      Jet.eta = genjet->eta();
      Jet.phi = genjet->phi();
      Jet.e   = genjet->energy();
      Jet.px  = genjet->px();
      Jet.py  = genjet->py();
      Jet.pz  = genjet->pz();
      Jet.npart = genjet->nConstituents();

      Jet.JetPart.clear();

      if (GenJetDebug) cout << genjet->nConstituents() << endl;    
      std::vector <const reco::GenParticle*> mcparts = genjet->getGenConstituents();
      for (unsigned i = 0; i < mcparts.size (); i++) {
        const reco::GenParticle* p = mcparts[i]; 
        if (GenJetDebug) 
          cout    << i
                  << " " <<  p->pdgId()
                  << " " << (pdt->particle(p->pdgId()))->name()
                  << " " << p->pt()
                  << " " << p->eta()
                  << " " << p->phi()
                  << " " << p->charge()
                  << endl ;

         MyGenPart genpart;

         // Four vector

         genpart.pt   = p->pt();
         genpart.eta  = p->eta();
         genpart.phi  = p->phi();
         genpart.e    = p->energy();
         genpart.px   = p->px();
         genpart.py   = p->py();
         genpart.pz   = p->pz();
         genpart.m    = p->mass();
         genpart.Part.v.SetPxPyPzE( p->px() , p->py() , p->pz() , p->energy() );

         // Extra properties

         genpart.Part.charge  = p->charge();
         genpart.charge  = p->charge();
         genpart.pdgId   = p->pdgId();
         genpart.name    = (pdt->particle(p->pdgId()))->name();
         genpart.status  = p->status();

         Jet.JetPart.push_back(genpart);

      }
      vector<int> i;

      JetVector.push_back(Jet);

   }

}