CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

ElectronSeedMerger Class Reference

#include <ElectronSeedMerger.h>

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

List of all members.

Public Member Functions

 ElectronSeedMerger (const edm::ParameterSet &)
 ~ElectronSeedMerger ()

Private Member Functions

virtual void beginJob ()
virtual void endJob ()
virtual void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

edm::ParameterSet conf_
edm::InputTag ecalBasedSeeds_
 SEED COLLECTIONS.
edm::InputTag tkBasedSeeds_

Detailed Description

Definition at line 13 of file ElectronSeedMerger.h.


Constructor & Destructor Documentation

ElectronSeedMerger::ElectronSeedMerger ( const edm::ParameterSet iConfig) [explicit]

Definition at line 22 of file ElectronSeedMerger.cc.

References ecalBasedSeeds_, edm::ParameterSet::getParameter(), and tkBasedSeeds_.

                                                                 :
 conf_(iConfig)
{
  LogInfo("ElectronSeedMerger")<<"Electron SeedMerger  started  ";
  
  
  ecalBasedSeeds_=iConfig.getParameter<InputTag>("EcalBasedSeeds");
  tkBasedSeeds_=iConfig.getParameter<InputTag>("TkBasedSeeds");
 
  produces<ElectronSeedCollection>();

}
ElectronSeedMerger::~ElectronSeedMerger ( )

Definition at line 36 of file ElectronSeedMerger.cc.

{
  
  // do anything here that needs to be done at desctruction time
  // (e.g. close files, deallocate resources etc.) 

}

Member Function Documentation

virtual void ElectronSeedMerger::beginJob ( void  ) [inline, private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 19 of file ElectronSeedMerger.h.

{} ;
virtual void ElectronSeedMerger::endJob ( void  ) [inline, private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 21 of file ElectronSeedMerger.h.

{}
void ElectronSeedMerger::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 51 of file ElectronSeedMerger.cc.

References TrackingRecHit::all, ecalBasedSeeds_, edm::Event::getByLabel(), convertSQLitetoXML_cfg::output, edm::Handle< T >::product(), edm::Event::put(), TrajectorySeed::recHits(), reco::ElectronSeed::setCtfTrack(), and tkBasedSeeds_.

{
  //CREATE OUTPUT COLLECTION
  auto_ptr<ElectronSeedCollection> output(new ElectronSeedCollection);

  //HANDLE THE INPUT SEED COLLECTIONS
  Handle<ElectronSeedCollection> EcalBasedSeeds;
  iEvent.getByLabel(ecalBasedSeeds_,EcalBasedSeeds);
  ElectronSeedCollection ESeed = *(EcalBasedSeeds.product());

  Handle<ElectronSeedCollection> TkBasedSeeds;
  iEvent.getByLabel(tkBasedSeeds_,TkBasedSeeds);
  ElectronSeedCollection TSeed = *(TkBasedSeeds.product());


  //VECTOR FOR MATCHED SEEDS
  vector<bool> TSeedMatched;
  for (unsigned int it=0;it<TSeed.size();it++){
    TSeedMatched.push_back(false);
  } 


  //LOOP OVER THE ECAL SEED COLLECTION
  ElectronSeedCollection::const_iterator e_beg= ESeed.begin();
  ElectronSeedCollection::const_iterator e_end= ESeed.end();
  for (;e_beg!=e_end;++e_beg){

    ElectronSeed NewSeed=*(e_beg);
    bool AlreadyMatched =false;
    
    //LOOP OVER THE TK SEED COLLECTION
    for (unsigned int it=0;it<TSeed.size();it++){
      if (AlreadyMatched) continue;

      //HITS FOR ECAL SEED 
      TrajectorySeed::const_iterator eh = e_beg->recHits().first;
      TrajectorySeed::const_iterator eh_end = e_beg->recHits().second;

      //HITS FOR TK SEED 
      unsigned int hitShared=0;
      unsigned int hitSeed=0;
      for (;eh!=eh_end;++eh){

        if (!eh->isValid()) continue;
        hitSeed++;
        bool Shared=false;
        TrajectorySeed::const_iterator th = TSeed[it].recHits().first;
        TrajectorySeed::const_iterator th_end = TSeed[it].recHits().second;
        for (;th!=th_end;++th){
          if (!th->isValid()) continue;
          //CHECK THE HIT COMPATIBILITY: put back sharesInput 
          // as soon Egamma solves the bug on the seed collection
          if (eh->sharesInput(&(*th),TrackingRecHit::all)) Shared = true;
        //   if(eh->geographicalId() == th->geographicalId() &&
//           (eh->localPosition() - th->localPosition()).mag() < 0.001) Shared=true;
        }
        if (Shared) hitShared++;
      }     
      if (hitShared==hitSeed){
        AlreadyMatched=true;
        TSeedMatched[it]=true;
        NewSeed.setCtfTrack(TSeed[it].ctfTrack());
      }
      if ( hitShared == (hitSeed-1)){
        NewSeed.setCtfTrack(TSeed[it].ctfTrack());
      }
    }

    output->push_back(NewSeed);
  }
  
  //FILL THE COLLECTION WITH UNMATCHED TK-BASED SEED
  for (unsigned int it=0;it<TSeed.size();it++){
    if (!TSeedMatched[it])  output->push_back(TSeed[it]);
  }
  
  //PUT THE MERGED COLLECTION IN THE EVENT
  iEvent.put(output);
  
}

Member Data Documentation

Definition at line 24 of file ElectronSeedMerger.h.

SEED COLLECTIONS.

Definition at line 27 of file ElectronSeedMerger.h.

Referenced by ElectronSeedMerger(), and produce().

Definition at line 28 of file ElectronSeedMerger.h.

Referenced by ElectronSeedMerger(), and produce().