예제 #1
0
StatusCode TrackTune::execute()
{

  // output tuple
  Tuple myTuple = nTuple("Candidates");

  const LHCb::Track::Range tracks = get<LHCb::Track::Range>(m_trackLocation);
  const LHCb::Particle::Range particles = get<LHCb::Particle::Range>(m_particleLocation);

  std::vector<const LHCb::Particle* > tVec; 
  if (select(tVec,particles) == false) return StatusCode::SUCCESS ;

  for (std::vector<const LHCb::Particle* >::const_iterator iterP = tVec.begin(); iterP != tVec.end(); ++iterP ){

    bool rec = isFound(tracks,**iterP);
    myTuple <<  Tuples::Column("M", (*iterP)->measuredMass()) 
            <<  Tuples::Column("found",rec) 
	    <<  Tuples::Column("PT", (*iterP)->pt())
            <<  Tuples::Column("Candidates", particles.size());

    myTuple->write();
  }

  return StatusCode::SUCCESS ;
  //
} // the end of the Algorihtm
예제 #2
0
//=============================================================================
// Main execution
//=============================================================================
StatusCode VertexCompare::execute() {
  if(msgLevel(MSG::DEBUG)) debug() << "==> Execute" << endmsg;

  std::vector<LHCb::RecVertex*> vecOfVertices1;
  std::vector<LHCb::RecVertex*> vecOfVertices2;

  bool vertices_ok = getInputVertices(vecOfVertices1, vecOfVertices2);

  std::vector<LHCb::RecVertex> fullVrt1, fullVrt2;

  if (!vertices_ok) {
    return StatusCode::SUCCESS; // return SUCCESS anyway
  }
  if (debugLevel()) debug() << 
     "  Vtx Properities       x       y       z      chi2/ndof     ntracks" 
                            << endmsg;
  // Fill reconstructed PV info
  std::vector<LHCb::RecVertex*>::iterator itRecV1;
  for(itRecV1 = vecOfVertices1.begin(); vecOfVertices1.end() != itRecV1;
               itRecV1++) {
    LHCb::RecVertex* pv;
    pv = *itRecV1;
    fullVrt1.push_back(*pv);
//     int nTracks      = pv->tracks().size();
    if (debugLevel()) debug() << m_inputVerticesName1 << endmsg;
    if (debugLevel()) debug() << "              " << pv->position().x() << "   " 
                              << pv->position().y() << "   " << pv->position().z()  
                              << "   " << pv->chi2PerDoF()  << "   " << pv->tracks().size() << endmsg;
  } // end of loop over vertices1

  std::vector<LHCb::RecVertex*>::iterator itRecV2;
  for(itRecV2 = vecOfVertices2.begin(); vecOfVertices2.end() != itRecV2;
               itRecV2++) {
    LHCb::RecVertex* pv;
    pv = *itRecV2;
    fullVrt2.push_back(*pv);
//     int nTracks      = pv->tracks().size();
    if (debugLevel()) debug() << m_inputVerticesName2 << endmsg;
    if (debugLevel()) debug() << "              " 
                              << pv->position().x() << "   " 
                              << pv->position().y() << "   " 
                              << pv->position().z()  << "   " 
                              << pv->chi2PerDoF()  << "   " 
                              << pv->tracks().size() << endmsg;
  } // end of loop over vertices2
  if (debugLevel()) debug() << "fullVrt1 size   " << fullVrt1.size() << endmsg;
  if (debugLevel()) debug() << "fullVrt2 size   " << fullVrt2.size() << endmsg;
  int size_diff = fullVrt1.size() - fullVrt2.size();
  if(m_produceHistogram) {
    plot(double(size_diff), 1001, "size_diff", -5.5, 5.5, 11);
  }
  if(m_produceNtuple) {
    Tuple myTuple_evt = nTuple(101, "PV_nTuple_evt", CLID_ColumnWiseTuple);
    myTuple_evt->column("size_diff",  double(size_diff));
    myTuple_evt->column("size_1",  double(fullVrt1.size()));
    myTuple_evt->column("size_2",  double(fullVrt2.size()));
    myTuple_evt->write();
  }
  double dx          = -99999.;
  double dy          = -99999.;
  double dz          = -99999.;
  double errx        = -99999.;
  double erry        = -99999.;
  double errz        = -99999.;
  double covxx1      = -99999.;
  double covyy1      = -99999.;
  double covzz1      = -99999.;
  double covxy1      = -99999.;
  double covxz1      = -99999.;  
  double covyz1      = -99999.;

  double covxx2      = -99999.;
  double covyy2      = -99999.;
  double covzz2      = -99999.;
  double covxy2      = -99999.;
  double covxz2      = -99999.;  
  double covyz2      = -99999.;

  int ntracks_part  = 0;
  int ntracks_part2 = 0;
  int dtracks = 0;

  std::vector<LHCb::RecVertex>::iterator fullIter;
  int oIt=0;
  std::vector<int> link;
  if (fullVrt1.size()!=0 && fullVrt2.size()!=0) matchByDistance(fullVrt1, fullVrt2, link);
  else return StatusCode::SUCCESS;
  for (fullIter=fullVrt1.begin(); fullIter!=fullVrt1.end(); fullIter++){
    LHCb::RecVertex vrtf = *fullIter;
    m_nVtx++;
    if (link.at(oIt)==-1) continue;
    Gaudi::SymMatrix3x3 covPV_part1 = vrtf.covMatrix();
    double sigx_part1 = (covPV_part1(0,0));
    double sigy_part1 = (covPV_part1(1,1));
    double sigz_part1 = (covPV_part1(2,2));
    covxx1 = sigx_part1;
    covyy1 = sigy_part1;
    covzz1 = sigz_part1;
    covxy1 = (covPV_part1(0,1));
    covxz1 = (covPV_part1(0,2));
    covyz1 = (covPV_part1(1,2));
    

    Gaudi::SymMatrix3x3 covPV_part2 = fullVrt2.at(link.at(oIt)).covMatrix();
    double sigx_part2 = (covPV_part2(0,0));
    double sigy_part2 = (covPV_part2(1,1));
    double sigz_part2 = (covPV_part2(2,2));

    covxx2 = sigx_part2;
    covyy2 = sigy_part2;
    covzz2 = sigz_part2;
    covxy2 = (covPV_part2(0,1));
    covxz2 = (covPV_part2(0,2));
    covyz2 = (covPV_part2(1,2));
    
    double x1 = vrtf.position().x();
    double y1 = vrtf.position().y();
    double z1 = vrtf.position().z();
    
    double x2 = fullVrt2.at(link.at(oIt)).position().x();
    double y2 = fullVrt2.at(link.at(oIt)).position().y();
    double z2 = fullVrt2.at(link.at(oIt)).position().z();
                
    dx = vrtf.position().x()-fullVrt2.at(link.at(oIt)).position().x();
    dy = vrtf.position().y()-fullVrt2.at(link.at(oIt)).position().y();
    dz = vrtf.position().z()-fullVrt2.at(link.at(oIt)).position().z();

    errx = sqrt(sigx_part1 + sigx_part2);
    erry = sqrt(sigy_part1 + sigy_part2);
    errz = sqrt(sigz_part1 + sigz_part2);
    ntracks_part  = vrtf.tracks().size();
    ntracks_part2 = fullVrt2.at(link.at(oIt)).tracks().size();
    dtracks = ntracks_part - ntracks_part2;

    if(m_produceHistogram) {
      plot(dx, 1021, "dx", -0.25, 0.25, 50);
      plot(dy, 1022, "dy", -0.25, 0.25, 50);
      plot(dz, 1023, "dz", -1.5, 1.5, 60);
      plot(x1, 2021, "x1", -0.25, 0.25, 50);
      plot(y1, 2022, "y1", -0.25, 0.25, 50);
      plot(z1, 2023, "z1", -100., 100., 50);
      plot(x2, 3021, "x2", -0.25, 0.25, 50);
      plot(y2, 3022, "y2", -0.25, 0.25, 50);
      plot(z2, 3023, "z2", -100., 100., 50);
      plot(std::sqrt(sigx_part1), 4011, "x err 1",0., .1, 50);
      plot(std::sqrt(sigy_part1), 4012, "y err 1",0., .1, 50);
      plot(std::sqrt(sigz_part1), 4013, "z err 1",0., .5, 50);
      plot(std::sqrt(sigx_part2), 4021, "x err 2",0., .1, 50);
      plot(std::sqrt(sigy_part2), 4022, "y err 2",0., .1, 50);
      plot(std::sqrt(sigz_part2), 4023, "z err 2",0., .5, 50);
      plot(dx/errx, 1031, "pullx", -5., 5., 50);
      plot(dy/erry, 1032, "pully", -5., 5., 50);
      plot(dz/errz, 1033, "pullz", -5., 5., 50);
      plot(double(ntracks_part) , 1041, "ntracks_part1", 0., 150., 50);
      plot(double(ntracks_part2), 1042, "ntracks_part2", 0., 150., 50);
      plot(double(dtracks), 1043, "dtracks", 0., 150., 50);
      // dz to get false vertex rate from data
      if ( vecOfVertices1.size() > 1 ) {
        for ( unsigned int i1 = 0; i1 < vecOfVertices1.size(); i1++ ) {
          for ( unsigned int i2 = 0; i2 < vecOfVertices1.size(); i2++ ) {
            if (i2 != i1) {  
              double vdz = vecOfVertices1[i1]->position().z() - vecOfVertices1[i2]->position().z();
                plot(vdz,1201,"dz vertices 1", -150.,150.,100);
            }
          }
        }        
      }
      if ( vecOfVertices2.size() > 1 ) {
        for ( unsigned int i1 = 0; i1 < vecOfVertices2.size(); i1++ ) {
          for ( unsigned int i2 = 0; i2 < vecOfVertices2.size(); i2++ ) {
            if (i2 != i1) {  
              double vdz = vecOfVertices2[i1]->position().z() - vecOfVertices2[i2]->position().z();
              plot(vdz, 1202, "dz vertices 2", -150.,150.,100);
            }
          }
        }        
      }

    }
    if(m_produceNtuple) {
      Tuple myTuple = nTuple(102, "PV_nTuple", CLID_ColumnWiseTuple);
      myTuple->column("ntracks_part",  double(ntracks_part));
      myTuple->column("ntracks_part2",  double(ntracks_part2));
      myTuple->column("dtracks", double(dtracks));
      myTuple->column("dx",       dx);
      myTuple->column("dy",       dy);
      myTuple->column("dz",       dz);
      myTuple->column("x1",       x1);
      myTuple->column("y1",       y1);
      myTuple->column("z1",       z1);
      myTuple->column("x2",       x2);
      myTuple->column("y2",       y2);
      myTuple->column("z2",       z2);
      myTuple->column("errx",     errx);
      myTuple->column("erry",     erry);
      myTuple->column("errz",     errz);
      myTuple->column("covxx1",   covxx1);
      myTuple->column("covyy1",   covyy1);
      myTuple->column("covzz1",   covzz1);
      myTuple->column("covxy1",   covxy1);
      myTuple->column("covxz1",   covxz1);
      myTuple->column("covyz1",   covyz1);
      myTuple->column("covxx2",   covxx2);
      myTuple->column("covyy2",   covyy2);
      myTuple->column("covzz2",   covzz2);
      myTuple->column("covxy2",   covxy2);
      myTuple->column("covxz2",   covxz2);
      myTuple->column("covyz2",   covyz2);

      myTuple->write();
    }
    oIt++;
  }

  return StatusCode::SUCCESS;
}
예제 #3
0
파일: B2DMuNu.cpp 프로젝트: hustons/CERN
//============================================================================= 
// Look at MC data                                                             
//=============================================================================
StatusCode B2DMuNu::loopOnMC()
{
  StatusCode sc = StatusCode::SUCCESS;
  
  //### Declare vectors used later to store relevant particles, filtered by charge ###//
  LHCb::MCParticle::Vector MuPlus, MuMinus;
 
  //### Obtain MCParticles from the default location and store in MCParticle vector ###//
  m_mcparts.clear();
  LHCb::MCParticles* kmcparts;
  
  if (exist<LHCb::MCParticles>(LHCb::MCParticleLocation::Default))
  {
    kmcparts = get<LHCb::MCParticles>(LHCb::MCParticleLocation::Default);
    LHCb::MCParticles::iterator j;
    for (j = kmcparts->begin(); j != kmcparts->end(); ++j) m_mcparts.push_back(*j);
  }
  else debug() << "There are no MC particles in the default location" << endmsg;
  debug() << "There are " << m_mcparts.size() << " MC particles" << endmsg;
  
  if (m_mcparts.size()==0)
  {
    m_passEvent = 1; // Automatically run event if MC data is unavailable
    m_runMC     = 0; // No need to try looking at MC data any more if it is unavailable
  }
  else
  {
    //### Declare Tuple to store data ###//
    Tuple mcTuple = nTuple("mcTuple");
    
    //### Test ###//
    int loop = 0; // Is this really needed anymore?? 
    
    //### Loop over MCParticle vector ###//
    for ( unsigned int k = 0; k<m_mcparts.size(); k++)
    {
      LHCb::MCParticle *part = m_mcparts[k];
      int pid = part->particleID().pid();
      verbose() << "MC Particle is a " << pid << endmsg;
      
      if ( abs(pid) == 13 )
      {
        //### Identify the mother of the MCParticle ###//
        const LHCb::MCParticle *mcMother = part->mother();
                    
      //### TEST ###//
      //if ( abs(pid) == 513 || abs(pid) == 525 || abs(pid) == 515 || abs(pid) == 533 || abs(pid) == 535 || abs(pid) == 10531
      //     || abs(pid) == 10511 || abs(pid) == 10521 || abs(pid) == 20513 || abs(pid) == 20523 || abs(pid) == 20533 ) 
      /*
        if (abs(pid == 511) || abs(pid == 521) )
        {
        //info() << "Found mother B (" << pid << ")" <<  endmsg;
        if (mcMother != NULL)
        {
        info() << "Found B (" << pid << ")" <<  endmsg;
        info() << "B Mother:" << mcMother->particleID().pid() << endmsg;
        const LHCb::MCParticle *gMother = mcMother->mother();
        if ( gMother == NULL ) info() << "B has no GrandMother" << endmsg;
        else info() << "B GrandMother: " << gMother->particleID().pid() << endmsg;
        }
        //else info() << "B has no mother." << endmsg;
        loop++;
        }
      */
      /*
        if (mcMother==NULL)
        {
        info() << "Found particle with NULL mother: " << pid << endmsg;
        loop++;
        }
      */
      
      /*    if (mcMother!=NULL)
            {
            if ( abs(pid) == 13 && (abs(mcMother->particleID().pid()) == 511 || abs(mcMother->particleID().pid()) == 521 ) )
            {
            loop++;
            }
            }*/
      
      
        //### Filter particles into vector of mu+ and mu- ###//
        if ( abs( mcMother->particleID().pid() ) == 511 || abs( mcMother->particleID().pid() ) == 521 )
        {
          //info() << "MCParticle reconstructible..." << m_recoTool->text(m_recoTool->reconstructible(part)) << endmsg;
          sc = filterMC(part, mcMother, MuMinus, MuPlus);
          if (!sc) return sc;
          loop++;
        }
      }
    }
  
    //### There should be one of each particle from the correct mother per event ###//
    if ( loop <= 1 || MuMinus.size() != 1 || MuPlus.size() != 1 ) 
    {
      debug() << "There are too many / few daughters in this event." << endmsg;
      debug() << "There are " << MuMinus.size() << " MC muons" << endmsg;
      debug() << "There are " << MuPlus.size() << " MC anti-muons" << endmsg;
      counter("TooManyMCDaughters")++;
    }
    else
    {
      //### Accep Event ###//
      m_passEvent = 1;
      
      //### Find DiMuon Invariant Masses, plot along with other quantites ###//
      const std::string& strMC = "mc";
      MC* mc = new MC(strMC, m_local);
      sc = mc->invMassMC(MuPlus, MuMinus, m_mcparts, mcTuple, "Mu");
      if (!sc) return sc;
      mcTuple->write();
      delete mc;
    }
  }
  
  return StatusCode::SUCCESS;
}