CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

SoftConversionTrackCandidateProducer Class Reference

#include <SoftConversionTrackCandidateProducer.h>

Inheritance diagram for SoftConversionTrackCandidateProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

virtual void beginRun (edm::Run &r, edm::EventSetup const &es)
virtual void endRun (edm::Run &r, edm::EventSetup const &es)
virtual void produce (edm::Event &evt, const edm::EventSetup &es)
 SoftConversionTrackCandidateProducer (const edm::ParameterSet &ps)
 ~SoftConversionTrackCandidateProducer ()

Private Member Functions

void buildCollections (const edm::Handle< edm::View< reco::CaloCluster > > &clusterHandle, TrackCandidateCollection &outInTracks, TrackCandidateCollection &inOutTracks, std::vector< edm::Ptr< reco::CaloCluster > > &vecRecOI, std::vector< edm::Ptr< reco::CaloCluster > > &vecRecIO)
void setEventSetup (const edm::EventSetup &es)
 Initialize EventSetup objects at each event.

Private Attributes

edm::InputTag clusterBarrelCollection_
edm::InputTag clusterEndcapCollection_
std::string clusterType_
edm::ParameterSet conf_
std::string InOutTrackCandidateCollection_
std::string InOutTrackClusterAssociationCollection_
int nEvt_
std::string OutInTrackCandidateCollection_
std::string OutInTrackClusterAssociationCollection_
edm::ESHandle< CaloGeometrytheCaloGeom_
InOutConversionSeedFindertheInOutSeedFinder_
InOutConversionTrackFindertheInOutTrackFinder_
const NavigationSchooltheNavigationSchool_
OutInConversionSeedFindertheOutInSeedFinder_
OutInConversionTrackFindertheOutInTrackFinder_

Detailed Description

Id:
SoftConversionTrackCandidateProducer.h,v 1.5 2009/03/04 21:20:18 nancy Exp
Date:
2009/03/04 21:20:18
Revision:
1.5
Author:
Dongwook Jang, Carnegie Mellon University Modified version of original ConversionTrackCandidateProducer

Definition at line 39 of file SoftConversionTrackCandidateProducer.h.


Constructor & Destructor Documentation

SoftConversionTrackCandidateProducer::SoftConversionTrackCandidateProducer ( const edm::ParameterSet ps)

Definition at line 57 of file SoftConversionTrackCandidateProducer.cc.

References clusterBarrelCollection_, clusterEndcapCollection_, clusterType_, conf_, edm::ParameterSet::getParameter(), InOutTrackCandidateCollection_, InOutTrackClusterAssociationCollection_, LogDebug, OutInTrackCandidateCollection_, and OutInTrackClusterAssociationCollection_.

                                                                                                        : 
  conf_(config), 
  theNavigationSchool_(0), 
  theOutInSeedFinder_(0), 
  theOutInTrackFinder_(0), 
  theInOutSeedFinder_(0),
  theInOutTrackFinder_(0)
{
  LogDebug("SoftConversionTrackCandidateProducer") << "SoftConversionTrackCandidateProducer CTOR " << "\n";
  
  clusterType_                 = conf_.getParameter<std::string>("clusterType");
  clusterBarrelCollection_     = conf_.getParameter<edm::InputTag>("clusterBarrelCollection");
  clusterEndcapCollection_     = conf_.getParameter<edm::InputTag>("clusterEndcapCollection");
  
  OutInTrackCandidateCollection_ = conf_.getParameter<std::string>("outInTrackCandidateCollection");
  InOutTrackCandidateCollection_ = conf_.getParameter<std::string>("inOutTrackCandidateCollection");

  OutInTrackClusterAssociationCollection_ = conf_.getParameter<std::string>("outInTrackCandidateClusterAssociationCollection");
  InOutTrackClusterAssociationCollection_ = conf_.getParameter<std::string>("inOutTrackCandidateClusterAssociationCollection");

  // Register the product
  produces< TrackCandidateCollection > (OutInTrackCandidateCollection_);
  produces< TrackCandidateCollection > (InOutTrackCandidateCollection_);
  produces< reco::TrackCandidateCaloClusterPtrAssociation > ( OutInTrackClusterAssociationCollection_);
  produces< reco::TrackCandidateCaloClusterPtrAssociation > ( InOutTrackClusterAssociationCollection_);

}
SoftConversionTrackCandidateProducer::~SoftConversionTrackCandidateProducer ( )

Definition at line 85 of file SoftConversionTrackCandidateProducer.cc.

{}

Member Function Documentation

void SoftConversionTrackCandidateProducer::beginRun ( edm::Run r,
edm::EventSetup const &  es 
) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 96 of file SoftConversionTrackCandidateProducer.cc.

References conf_, edm::EventSetup::get(), nEvt_, edm::ESHandle< T >::product(), theInOutSeedFinder_, theInOutTrackFinder_, theNavigationSchool_, theOutInSeedFinder_, and theOutInTrackFinder_.

                                                                                                    {
  nEvt_=0;
  //get magnetic field
  edm::LogInfo("SoftConversionTrackCandidateProducer") << " get magnetic field" << "\n";
  
  edm::ESHandle<NavigationSchool> nav;
  theEventSetup.get<NavigationSchoolRecord>().get("SimpleNavigationSchool", nav);
  theNavigationSchool_ = nav.product();
  
  // get the Out In Seed Finder  
  edm::LogInfo("SoftConversionTrackCandidateProducer") << " get the OutInSeedFinder" << "\n";
  theOutInSeedFinder_ = new OutInConversionSeedFinder (  conf_ );
  
  // get the Out In Track Finder
  edm::LogInfo("SoftConversionTrackCandidateProducer") << " get the OutInTrackFinder" << "\n";
  theOutInTrackFinder_ = new OutInConversionTrackFinder ( theEventSetup, conf_  );
  
  // get the In Out Seed Finder  
  edm::LogInfo("SoftConversionTrackCandidateProducer") << " get the InOutSeedFinder" << "\n";
  theInOutSeedFinder_ = new InOutConversionSeedFinder ( conf_ );
  
  // get the In Out Track Finder
  edm::LogInfo("SoftConversionTrackCandidateProducer") << " get the InOutTrackFinder" << "\n";
  theInOutTrackFinder_ = new InOutConversionTrackFinder ( theEventSetup, conf_  );
}
void SoftConversionTrackCandidateProducer::buildCollections ( const edm::Handle< edm::View< reco::CaloCluster > > &  clusterHandle,
TrackCandidateCollection outInTracks,
TrackCandidateCollection inOutTracks,
std::vector< edm::Ptr< reco::CaloCluster > > &  vecRecOI,
std::vector< edm::Ptr< reco::CaloCluster > > &  vecRecIO 
) [private]

Definition at line 197 of file SoftConversionTrackCandidateProducer.cc.

References abs, dPhi(), IsGoodSeed(), InOutConversionSeedFinder::makeSeeds(), OutInConversionSeedFinder::makeSeeds(), position, ConversionSeedFinder::seeds(), ConversionSeedFinder::setCandidate(), InOutConversionSeedFinder::setTracks(), theInOutSeedFinder_, theInOutTrackFinder_, theOutInSeedFinder_, theOutInTrackFinder_, OutInConversionTrackFinder::tracks(), and InOutConversionTrackFinder::tracks().

Referenced by produce().

                                                                                                           {

  // temporary collection
  TrackCandidateCollection tempTCC;
  TrajectorySeedCollection totalOISeeds; // total number of out-in trajectory seeds through entire cluster collection loop
  TrajectorySeedCollection totalIOSeeds; // total number of in-out trajectory seeds through entire cluster collection loop

  int nClusters = (int) clusterHandle->size();

  // first loop to fill totalOISeeds and totalIOSeeds

  for(int iCluster=0; iCluster<nClusters; iCluster++){
    reco::CaloClusterPtr clusterRefOutIn = clusterHandle->ptrAt(iCluster);
    math::XYZPoint position = clusterRefOutIn->position();
    GlobalPoint gp(position.x(),position.y(),position.z());
    theOutInSeedFinder_->setCandidate(clusterRefOutIn->energy(),gp);
    theOutInSeedFinder_->makeSeeds(clusterRefOutIn);


    TrajectorySeedCollection oISeeds = theOutInSeedFinder_->seeds();
    for(TrajectorySeedCollection::const_iterator it = oISeeds.begin(); it != oISeeds.end(); it++){
      totalOISeeds.push_back(*it);
    }

    std::vector<Trajectory> theOutInTracks= theOutInTrackFinder_->tracks(oISeeds, tempTCC);
    tempTCC.clear();

    for(int jCluster=iCluster; jCluster<nClusters; jCluster++){
      reco::CaloClusterPtr clusterRefInOut = clusterHandle->ptrAt(jCluster);

      math::XYZPoint position2 = clusterRefInOut->position();
      GlobalPoint gp2(position2.x(),position2.y(),position2.z());
      double dEta = std::abs(position.Eta() - position2.Eta());
      if(dEta > 0.1) continue;

      double dPhi = std::abs(ROOT::Math::VectorUtil::DeltaPhi(position, position2));
      if(dPhi > 0.5) continue;

      theInOutSeedFinder_->setCandidate(clusterRefInOut->energy(),gp2);
      theInOutSeedFinder_->setTracks(theOutInTracks);   
      theInOutSeedFinder_->makeSeeds(clusterHandle);

      TrajectorySeedCollection iOSeeds = theInOutSeedFinder_->seeds();

      for(TrajectorySeedCollection::const_iterator it = iOSeeds.begin(); it != iOSeeds.end(); it++){
        totalIOSeeds.push_back(*it);
      }
    
    }// for jCluster
  }// for iCluster


  // Now we have total OI/IO seeds. Let's clean them up and save them with only giving good trajectories
  TrajectorySeedCollection oIFilteredSeeds;
  TrajectorySeedCollection iOFilteredSeeds;

  tempTCC.clear();
  std::vector<Trajectory> tempTrj = theOutInTrackFinder_->tracks(totalOISeeds,tempTCC);
  for(std::vector<Trajectory>::iterator it = tempTrj.begin(); it!= tempTrj.end(); it++){
    oIFilteredSeeds.push_back(it->seed());
  }

  tempTrj.clear();
  tempTCC.clear();
  tempTrj = theInOutTrackFinder_->tracks(totalIOSeeds,tempTCC);
  for(std::vector<Trajectory>::iterator it = tempTrj.begin(); it!= tempTrj.end(); it++){
    iOFilteredSeeds.push_back(it->seed());
  }

  tempTCC.clear();
  tempTrj.clear();
  totalOISeeds.clear();
  totalIOSeeds.clear();


  // Now start normal procedure and consider seeds that belong to filtered ones.

  for(int iCluster=0; iCluster<nClusters; iCluster++){
    reco::CaloClusterPtr clusterRefOutIn = clusterHandle->ptrAt(iCluster);
    math::XYZPoint position = clusterRefOutIn->position();
    GlobalPoint gp(position.x(),position.y(),position.z());
    theOutInSeedFinder_->setCandidate(clusterRefOutIn->energy(),gp);
    theOutInSeedFinder_->makeSeeds(clusterRefOutIn);

    TrajectorySeedCollection oISeeds_all = theOutInSeedFinder_->seeds();
    TrajectorySeedCollection oISeeds;
    for(TrajectorySeedCollection::iterator it = oISeeds_all.begin(); it != oISeeds_all.end(); it++){
      if(IsGoodSeed(oIFilteredSeeds,*it)) oISeeds.push_back(*it);
    }

    if(oISeeds.size() == 0) continue;

    std::vector<Trajectory> theOutInTracks= theOutInTrackFinder_->tracks(oISeeds, outInTrackCandidates);

    int nOITrj = (int) theOutInTracks.size();
    for(int itrj=0; itrj < nOITrj; itrj++) vecRecOI.push_back( clusterRefOutIn );

    for(int jCluster=iCluster; jCluster<nClusters; jCluster++){
      reco::CaloClusterPtr clusterRefInOut = clusterHandle->ptrAt(jCluster);

      math::XYZPoint position2 = clusterRefInOut->position();
      GlobalPoint gp2(position2.x(),position2.y(),position2.z());
      double dEta = std::abs(position.Eta() - position2.Eta());
      if(dEta > 0.1) continue;

      double dPhi = std::abs(ROOT::Math::VectorUtil::DeltaPhi(position, position2));
      if(dPhi > 0.5) continue;

      theInOutSeedFinder_->setCandidate(clusterRefInOut->energy(),gp2);
      theInOutSeedFinder_->setTracks(theOutInTracks);   
      theInOutSeedFinder_->makeSeeds(clusterHandle);
    
      TrajectorySeedCollection iOSeeds_all = theInOutSeedFinder_->seeds();
      TrajectorySeedCollection iOSeeds;
      for(TrajectorySeedCollection::iterator it = iOSeeds_all.begin(); it != iOSeeds_all.end(); it++){
        if(IsGoodSeed(iOFilteredSeeds,*it)) iOSeeds.push_back(*it);
      }

      if(iOSeeds.size() == 0) continue;

      std::vector<Trajectory> theInOutTracks= theInOutTrackFinder_->tracks(iOSeeds, inOutTrackCandidates); 

      int nIOTrj = (int) theInOutTracks.size();
      for(int itrj=0; itrj < nIOTrj; itrj++) vecRecIO.push_back( clusterRefInOut );

    }// for jCluster
  }// for iCluster


}
void SoftConversionTrackCandidateProducer::endRun ( edm::Run r,
edm::EventSetup const &  es 
) [virtual]
void SoftConversionTrackCandidateProducer::produce ( edm::Event evt,
const edm::EventSetup es 
) [virtual]

Implements edm::EDProducer.

Definition at line 130 of file SoftConversionTrackCandidateProducer.cc.

References buildCollections(), clusterBarrelCollection_, clusterEndcapCollection_, clusterType_, gather_cfg::cout, edm::helper::Filler< Map >::fill(), edm::Event::getByLabel(), edm::EventBase::id(), InOutTrackCandidateCollection_, InOutTrackClusterAssociationCollection_, edm::helper::Filler< Map >::insert(), edm::HandleBase::isValid(), edm::InputTag::label(), nEvt_, OutInTrackCandidateCollection_, OutInTrackClusterAssociationCollection_, edm::Event::put(), ConversionTrackFinder::setEvent(), ConversionSeedFinder::setEvent(), setEventSetup(), theInOutSeedFinder_, theInOutTrackFinder_, theNavigationSchool_, theOutInSeedFinder_, and theOutInTrackFinder_.

                                                                                                         {
  
  using namespace edm;
  nEvt_++;
  edm::LogInfo("SoftConversionTrackCandidateProducer") << "SoftConversionTrackCandidateProducer Analyzing event number: " << theEvent.id() << " Global Counter " << nEvt_ << "\n";

  std::cout << "SoftConversionTrackCandidateProducer Analyzing event number: " << theEvent.id() << " Global Counter " << nEvt_ << "\n";
  
  setEventSetup( theEventSetup );
  theOutInSeedFinder_->setEvent(theEvent);
  theInOutSeedFinder_->setEvent(theEvent);
  theOutInTrackFinder_->setEvent(theEvent);
  theInOutTrackFinder_->setEvent(theEvent);

  // Set the navigation school  
  NavigationSetter setter(*theNavigationSchool_);  

  // collections to be stored in events
  std::auto_ptr<TrackCandidateCollection> outInTrackCandidate_p(new TrackCandidateCollection); 
  std::auto_ptr<TrackCandidateCollection> inOutTrackCandidate_p(new TrackCandidateCollection); 
  std::auto_ptr<reco::TrackCandidateCaloClusterPtrAssociation> outInAssoc_p(new reco::TrackCandidateCaloClusterPtrAssociation);
  std::auto_ptr<reco::TrackCandidateCaloClusterPtrAssociation> inOutAssoc_p(new reco::TrackCandidateCaloClusterPtrAssociation);
   
  std::vector<edm::Ptr<reco::CaloCluster> > vecOfClusterRefForOutIn;
  std::vector<edm::Ptr<reco::CaloCluster> > vecOfClusterRefForInOut;

  // Get the basic cluster collection in the Barrel 
  edm::Handle<edm::View<reco::CaloCluster> > clusterBarrelHandle;
  theEvent.getByLabel(clusterBarrelCollection_, clusterBarrelHandle);

  if (!clusterBarrelHandle.isValid()) {
    edm::LogError("SoftConverionTrackCandidateProducer") << "Error! Can't get the product "<<clusterBarrelCollection_.label();
    return;
  }
  
  buildCollections(clusterBarrelHandle, *outInTrackCandidate_p, *inOutTrackCandidate_p, vecOfClusterRefForOutIn, vecOfClusterRefForInOut);

  if(clusterType_ == "BasicCluster" ) {
    // Get the basic cluster collection in the Endcap 
    edm::Handle<edm::View<reco::CaloCluster> > clusterEndcapHandle;
    theEvent.getByLabel(clusterEndcapCollection_, clusterEndcapHandle);

    if (!clusterEndcapHandle.isValid()) {
      edm::LogError("SoftConversionTrackCandidateProducer") << "Error! Can't get the product "<<clusterEndcapCollection_.label();
      return;
    }

    buildCollections(clusterEndcapHandle, *outInTrackCandidate_p, *inOutTrackCandidate_p, vecOfClusterRefForOutIn, vecOfClusterRefForInOut);

  }

  // put all products in the event
  const edm::OrphanHandle<TrackCandidateCollection> refprodOutInTrackC = theEvent.put( outInTrackCandidate_p, OutInTrackCandidateCollection_ );
  const edm::OrphanHandle<TrackCandidateCollection> refprodInOutTrackC = theEvent.put( inOutTrackCandidate_p, InOutTrackCandidateCollection_ );

  edm::ValueMap<reco::CaloClusterPtr>::Filler fillerOI(*outInAssoc_p);
  fillerOI.insert(refprodOutInTrackC, vecOfClusterRefForOutIn.begin(), vecOfClusterRefForOutIn.end());
  fillerOI.fill();
  edm::ValueMap<reco::CaloClusterPtr>::Filler fillerIO(*inOutAssoc_p);
  fillerIO.insert(refprodInOutTrackC, vecOfClusterRefForInOut.begin(), vecOfClusterRefForInOut.end());
  fillerIO.fill();

  theEvent.put( outInAssoc_p, OutInTrackClusterAssociationCollection_);
  theEvent.put( inOutAssoc_p, InOutTrackClusterAssociationCollection_);
}
void SoftConversionTrackCandidateProducer::setEventSetup ( const edm::EventSetup es) [private]

Member Data Documentation

Definition at line 53 of file SoftConversionTrackCandidateProducer.h.

Referenced by beginRun(), and produce().

Definition at line 68 of file SoftConversionTrackCandidateProducer.h.

Definition at line 70 of file SoftConversionTrackCandidateProducer.h.

Referenced by beginRun(), and produce().