CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

ConversionTrackCandidateProducer Class Reference

#include <ConversionTrackCandidateProducer.h>

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

List of all members.

Public Member Functions

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

Private Member Functions

void buildCollections (const edm::Handle< edm::View< reco::CaloCluster > > &scHandle, const edm::Handle< edm::View< reco::CaloCluster > > &bcHandle, const edm::Handle< CaloTowerCollection > &hcalTowersHandle, 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 bcBarrelCollection_
edm::InputTag bcEndcapCollection_
std::vector< edm::Ptr
< reco::CaloCluster > > 
caloPtrVecInOut_
std::vector< edm::Ptr
< reco::CaloCluster > > 
caloPtrVecOutIn_
edm::ParameterSet conf_
edm::InputTag hcalTowers_
double hOverEConeSize_
std::string InOutTrackCandidateCollection_
std::string InOutTrackSuperClusterAssociationCollection_
double maxHOverE_
double minSCEt_
int nEvt_
std::string OutInTrackCandidateCollection_
std::string OutInTrackSuperClusterAssociationCollection_
edm::InputTag scHybridBarrelProducer_
edm::InputTag scIslandEndcapProducer_
edm::ESHandle< CaloGeometrytheCaloGeom_
InOutConversionSeedFindertheInOutSeedFinder_
InOutConversionTrackFindertheInOutTrackFinder_
const NavigationSchooltheNavigationSchool_
OutInConversionSeedFindertheOutInSeedFinder_
OutInConversionTrackFindertheOutInTrackFinder_
std::vector< edm::Ref
< reco::SuperClusterCollection > > 
vecOfSCRefForInOut
std::vector< edm::Ref
< reco::SuperClusterCollection > > 
vecOfSCRefForOutIn

Detailed Description

Id:
ConversionTrackCandidateProducer.h,v 1.15 2009/05/12 16:46:05 nancy Exp
Date:
2009/05/12 16:46:05
Revision:
1.15
Author:
Nancy Marinelli, U. of Notre Dame, US

Definition at line 40 of file ConversionTrackCandidateProducer.h.


Constructor & Destructor Documentation

ConversionTrackCandidateProducer::ConversionTrackCandidateProducer ( const edm::ParameterSet ps)

Definition at line 37 of file ConversionTrackCandidateProducer.cc.

References bcBarrelCollection_, bcEndcapCollection_, conf_, edm::ParameterSet::getParameter(), hcalTowers_, hOverEConeSize_, InOutTrackCandidateCollection_, InOutTrackSuperClusterAssociationCollection_, maxHOverE_, minSCEt_, nEvt_, OutInTrackCandidateCollection_, OutInTrackSuperClusterAssociationCollection_, scHybridBarrelProducer_, and scIslandEndcapProducer_.

                                                                                                : 
  conf_(config), 
  theNavigationSchool_(0), 
  theOutInSeedFinder_(0), 
  theOutInTrackFinder_(0), 
  theInOutSeedFinder_(0),
  theInOutTrackFinder_(0)
{


  
  //std::cout << "ConversionTrackCandidateProducer CTOR " << "\n";
  nEvt_=0;  
   
  // use onfiguration file to setup input/output collection names
 

  bcBarrelCollection_     = conf_.getParameter<edm::InputTag>("bcBarrelCollection");
  bcEndcapCollection_     = conf_.getParameter<edm::InputTag>("bcEndcapCollection");
  
  scHybridBarrelProducer_       = conf_.getParameter<edm::InputTag>("scHybridBarrelProducer");
  scIslandEndcapProducer_       = conf_.getParameter<edm::InputTag>("scIslandEndcapProducer");
  
  OutInTrackCandidateCollection_ = conf_.getParameter<std::string>("outInTrackCandidateCollection");
  InOutTrackCandidateCollection_ = conf_.getParameter<std::string>("inOutTrackCandidateCollection");


  OutInTrackSuperClusterAssociationCollection_ = conf_.getParameter<std::string>("outInTrackCandidateSCAssociationCollection");
  InOutTrackSuperClusterAssociationCollection_ = conf_.getParameter<std::string>("inOutTrackCandidateSCAssociationCollection");

  hcalTowers_ = conf_.getParameter<edm::InputTag>("hcalTowers");
  hOverEConeSize_   = conf_.getParameter<double>("hOverEConeSize");
  maxHOverE_        = conf_.getParameter<double>("maxHOverE");
  minSCEt_        = conf_.getParameter<double>("minSCEt");


  // Register the product
  produces< TrackCandidateCollection > (OutInTrackCandidateCollection_);
  produces< TrackCandidateCollection > (InOutTrackCandidateCollection_);

  produces< reco::TrackCandidateCaloClusterPtrAssociation > ( OutInTrackSuperClusterAssociationCollection_);
  produces< reco::TrackCandidateCaloClusterPtrAssociation > ( InOutTrackSuperClusterAssociationCollection_);
  

}
ConversionTrackCandidateProducer::~ConversionTrackCandidateProducer ( )

Definition at line 83 of file ConversionTrackCandidateProducer.cc.

{}

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 96 of file ConversionTrackCandidateProducer.cc.

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

                                                                                                 {

  edm::ESHandle<NavigationSchool> nav;
  theEventSetup.get<NavigationSchoolRecord>().get("SimpleNavigationSchool", nav);
  theNavigationSchool_ = nav.product();

  // get the Out In Seed Finder  
  theOutInSeedFinder_ = new OutInConversionSeedFinder (  conf_ );
  
  // get the Out In Track Finder
  theOutInTrackFinder_ = new OutInConversionTrackFinder ( theEventSetup, conf_  );

  
  // get the In Out Seed Finder  
  theInOutSeedFinder_ = new InOutConversionSeedFinder ( conf_ );
  
  
  // get the In Out Track Finder
  theInOutTrackFinder_ = new InOutConversionTrackFinder ( theEventSetup, conf_  );


}
void ConversionTrackCandidateProducer::buildCollections ( const edm::Handle< edm::View< reco::CaloCluster > > &  scHandle,
const edm::Handle< edm::View< reco::CaloCluster > > &  bcHandle,
const edm::Handle< CaloTowerCollection > &  hcalTowersHandle,
TrackCandidateCollection outInTracks,
TrackCandidateCollection inOutTracks,
std::vector< edm::Ptr< reco::CaloCluster > > &  vecRecOI,
std::vector< edm::Ptr< reco::CaloCluster > > &  vecRecIO 
) [private]

Definition at line 256 of file ConversionTrackCandidateProducer.cc.

References caloPtrVecInOut_, caloPtrVecOutIn_, reco::CaloCluster::energy(), EgammaTowerIsolation::getTowerESum(), hOverEConeSize_, i, InOutConversionSeedFinder::makeSeeds(), OutInConversionSeedFinder::makeSeeds(), maxHOverE_, minSCEt_, reco::CaloCluster::position(), edm::Handle< T >::product(), ConversionSeedFinder::seeds(), ConversionSeedFinder::setCandidate(), InOutConversionSeedFinder::setTracks(), theInOutSeedFinder_, theInOutTrackFinder_, theOutInSeedFinder_, theOutInTrackFinder_, InOutConversionTrackFinder::tracks(), and OutInConversionTrackFinder::tracks().

Referenced by produce().

{

  //  std::cout << "ConversionTrackCandidateProducer builcollections bc size " << bcHandle->size() <<  "\n";
  //const CaloGeometry* geometry = theCaloGeom_.product();

  //  Loop over SC in the barrel and reconstruct converted photons
  for (unsigned i = 0; i < scHandle->size(); ++i ) {

    reco::CaloClusterPtr aClus= scHandle->ptrAt(i);

    // preselection based in Et and H/E cut. 
    if (aClus->energy()/cosh(aClus->eta()) <= minSCEt_) continue;
    const reco::CaloCluster* pClus=&(*aClus);
    const reco::SuperCluster*  sc=dynamic_cast<const reco::SuperCluster*>(pClus);
    const CaloTowerCollection* hcalTowersColl = hcalTowersHandle.product();
    EgammaTowerIsolation towerIso(hOverEConeSize_,0.,0.,-1,hcalTowersColl) ;
    double HoE=towerIso.getTowerESum(sc)/sc->energy();
    if (HoE>=maxHOverE_)  continue;

    theOutInSeedFinder_->setCandidate(pClus->energy(), GlobalPoint(pClus->position().x(),pClus->position().y(),pClus->position().z() ) );
    theOutInSeedFinder_->makeSeeds( bcHandle );

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

 
    theInOutSeedFinder_->setCandidate(pClus->energy(), GlobalPoint(pClus->position().x(),pClus->position().y(),pClus->position().z() ) );  
    theInOutSeedFinder_->setTracks(  theOutInTracks );   
    theInOutSeedFinder_->makeSeeds(  bcHandle);
    
    std::vector<Trajectory> theInOutTracks= theInOutTrackFinder_->tracks(theInOutSeedFinder_->seeds(),  inOutTrackCandidates); 


    // Debug
    //   std::cout  << "ConversionTrackCandidateProducer  theOutInTracks.size() " << theOutInTracks.size() << " theInOutTracks.size() " << theInOutTracks.size() <<  " Event pointer to out in track size barrel " << outInTrackCandidates.size() << " in out track size " << inOutTrackCandidates.size() <<   "\n";


    for (std::vector<Trajectory>::const_iterator it = theOutInTracks.begin(); it !=  theOutInTracks.end(); ++it) {
      caloPtrVecOutIn_.push_back(aClus);
      //     std::cout  << "ConversionTrackCandidateProducer Barrel OutIn Tracks Number of hits " << (*it).foundHits() << "\n"; 
    }

    for (std::vector<Trajectory>::const_iterator it = theInOutTracks.begin(); it !=  theInOutTracks.end(); ++it) {
      caloPtrVecInOut_.push_back(aClus);
      //     std::cout  << "ConversionTrackCandidateProducer Barrel InOut Tracks Number of hits " << (*it).foundHits() << "\n"; 
    }




    

  }



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

Implements edm::EDProducer.

Definition at line 130 of file ConversionTrackCandidateProducer.cc.

References bcBarrelCollection_, bcEndcapCollection_, buildCollections(), caloPtrVecInOut_, caloPtrVecOutIn_, ConversionSeedFinder::clear(), edm::helper::Filler< Map >::fill(), edm::EventSetup::get(), edm::Event::getByLabel(), hcalTowers_, InOutTrackCandidateCollection_, InOutTrackSuperClusterAssociationCollection_, edm::helper::Filler< Map >::insert(), edm::InputTag::label(), nEvt_, OutInTrackCandidateCollection_, OutInTrackSuperClusterAssociationCollection_, edm::Event::put(), scHybridBarrelProducer_, scIslandEndcapProducer_, ConversionTrackFinder::setEvent(), ConversionSeedFinder::setEvent(), setEventSetup(), theCaloGeom_, theInOutSeedFinder_, theInOutTrackFinder_, theNavigationSchool_, theOutInSeedFinder_, and theOutInTrackFinder_.

                                                                                                     {
  
  using namespace edm;
  nEvt_++;
  //  std::cout << "ConversionTrackCandidateProducer 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_);  

  //
  // create empty output collections
  //
  //  Out In Track Candidates
  std::auto_ptr<TrackCandidateCollection> outInTrackCandidate_p(new TrackCandidateCollection); 
  //  In Out  Track Candidates
  std::auto_ptr<TrackCandidateCollection> inOutTrackCandidate_p(new TrackCandidateCollection); 
  //   Track Candidate  calo  Cluster Association
  std::auto_ptr<reco::TrackCandidateCaloClusterPtrAssociation> outInAssoc_p(new reco::TrackCandidateCaloClusterPtrAssociation);
  std::auto_ptr<reco::TrackCandidateCaloClusterPtrAssociation> inOutAssoc_p(new reco::TrackCandidateCaloClusterPtrAssociation);
    
  // Get the basic cluster collection in the Barrel 
  bool validBarrelBCHandle=true;
  edm::Handle<edm::View<reco::CaloCluster> > bcBarrelHandle;
  theEvent.getByLabel(bcBarrelCollection_, bcBarrelHandle);
  if (!bcBarrelHandle.isValid()) {
    edm::LogError("ConversionTrackCandidateProducer") << "Error! Can't get the product "<<bcBarrelCollection_.label();
    validBarrelBCHandle=false;
  }
  
  
  // Get the basic cluster collection in the Endcap 
  bool validEndcapBCHandle=true;
  edm::Handle<edm::View<reco::CaloCluster> > bcEndcapHandle;
  theEvent.getByLabel(bcEndcapCollection_, bcEndcapHandle);
  if (!bcEndcapHandle.isValid()) {
    edm::LogError("CoonversionTrackCandidateProducer") << "Error! Can't get the product "<<bcEndcapCollection_.label();
    validEndcapBCHandle=false; 
  }
  
  

  // Get the Super Cluster collection in the Barrel
  bool validBarrelSCHandle=true;
  edm::Handle<edm::View<reco::CaloCluster> > scBarrelHandle;
  theEvent.getByLabel(scHybridBarrelProducer_,scBarrelHandle);
  if (!scBarrelHandle.isValid()) {
    edm::LogError("CoonversionTrackCandidateProducer") << "Error! Can't get the product "<<scHybridBarrelProducer_.label();
    validBarrelSCHandle=false;
  }


  // Get the Super Cluster collection in the Endcap
  bool validEndcapSCHandle=true;
  edm::Handle<edm::View<reco::CaloCluster> > scEndcapHandle;
  theEvent.getByLabel(scIslandEndcapProducer_,scEndcapHandle);
  if (!scEndcapHandle.isValid()) {
    edm::LogError("CoonversionTrackCandidateProducer") << "Error! Can't get the product "<<scIslandEndcapProducer_.label();
    validEndcapSCHandle=false;
  }


  // get the geometry from the event setup:
  theEventSetup.get<CaloGeometryRecord>().get(theCaloGeom_);

  // get Hcal towers collection 
  Handle<CaloTowerCollection> hcalTowersHandle;
  theEvent.getByLabel(hcalTowers_, hcalTowersHandle);


  caloPtrVecOutIn_.clear();
  caloPtrVecInOut_.clear();

  if ( validBarrelBCHandle && validBarrelSCHandle ) 
    buildCollections(scBarrelHandle, bcBarrelHandle, hcalTowersHandle, *outInTrackCandidate_p,*inOutTrackCandidate_p,caloPtrVecOutIn_,caloPtrVecInOut_ );
  if ( validEndcapBCHandle && validEndcapSCHandle ) 
    buildCollections(scEndcapHandle, bcEndcapHandle, hcalTowersHandle, *outInTrackCandidate_p,*inOutTrackCandidate_p,caloPtrVecOutIn_,caloPtrVecInOut_ );




  //  std::cout  << "  ConversionTrackCandidateProducer  caloPtrVecOutIn_ size " <<  caloPtrVecOutIn_.size() << " caloPtrVecInOut_ size " << caloPtrVecInOut_.size()  << "\n"; 
  


  // put all products in the event
 // Barrel
 //std::cout  << "ConversionTrackCandidateProducer Putting in the event " << (*outInTrackCandidate_p).size() << " Out In track Candidates " << "\n";
 const edm::OrphanHandle<TrackCandidateCollection> refprodOutInTrackC = theEvent.put( outInTrackCandidate_p, OutInTrackCandidateCollection_ );
 //std::cout  << "ConversionTrackCandidateProducer  refprodOutInTrackC size  " <<  (*(refprodOutInTrackC.product())).size()  <<  "\n";
 //
 //std::cout  << "ConversionTrackCandidateProducer Putting in the event  " << (*inOutTrackCandidate_p).size() << " In Out track Candidates " <<  "\n";
 const edm::OrphanHandle<TrackCandidateCollection> refprodInOutTrackC = theEvent.put( inOutTrackCandidate_p, InOutTrackCandidateCollection_ );
 //std::cout  << "ConversionTrackCandidateProducer  refprodInOutTrackC size  " <<  (*(refprodInOutTrackC.product())).size()  <<  "\n";


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


  
 // std::cout  << "ConversionTrackCandidateProducer Putting in the event   OutIn track - SC association: size  " <<  (*outInAssoc_p).size() << "\n";  
 theEvent.put( outInAssoc_p, OutInTrackSuperClusterAssociationCollection_);
 
 // std::cout << "ConversionTrackCandidateProducer Putting in the event   InOut track - SC association: size  " <<  (*inOutAssoc_p).size() << "\n";  
 theEvent.put( inOutAssoc_p, InOutTrackSuperClusterAssociationCollection_);

 theOutInSeedFinder_->clear();
 theInOutSeedFinder_->clear();
 

  
}
void ConversionTrackCandidateProducer::setEventSetup ( const edm::EventSetup es) [private]

Member Data Documentation

Definition at line 67 of file ConversionTrackCandidateProducer.h.

Referenced by ConversionTrackCandidateProducer(), and produce().

Definition at line 68 of file ConversionTrackCandidateProducer.h.

Referenced by ConversionTrackCandidateProducer(), and produce().

Definition at line 88 of file ConversionTrackCandidateProducer.h.

Referenced by buildCollections(), and produce().

Definition at line 87 of file ConversionTrackCandidateProducer.h.

Referenced by buildCollections(), and produce().

Definition at line 72 of file ConversionTrackCandidateProducer.h.

Referenced by ConversionTrackCandidateProducer(), and produce().

Definition at line 61 of file ConversionTrackCandidateProducer.h.

Referenced by ConversionTrackCandidateProducer(), and produce().

Definition at line 65 of file ConversionTrackCandidateProducer.h.

Referenced by ConversionTrackCandidateProducer(), and produce().

Definition at line 55 of file ConversionTrackCandidateProducer.h.

Referenced by ConversionTrackCandidateProducer(), and produce().

Definition at line 60 of file ConversionTrackCandidateProducer.h.

Referenced by ConversionTrackCandidateProducer(), and produce().

Definition at line 64 of file ConversionTrackCandidateProducer.h.

Referenced by ConversionTrackCandidateProducer(), and produce().

Definition at line 69 of file ConversionTrackCandidateProducer.h.

Referenced by ConversionTrackCandidateProducer(), and produce().

Definition at line 70 of file ConversionTrackCandidateProducer.h.

Referenced by ConversionTrackCandidateProducer(), and produce().

Definition at line 78 of file ConversionTrackCandidateProducer.h.

Referenced by produce().

Definition at line 80 of file ConversionTrackCandidateProducer.h.

Referenced by beginRun(), and produce().

Definition at line 91 of file ConversionTrackCandidateProducer.h.

Definition at line 90 of file ConversionTrackCandidateProducer.h.