CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRemoveDuplicatedSC.cc

Go to the documentation of this file.
00001 #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTRemoveDuplicatedSC.h"
00002 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00003 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00004 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00005 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
00006 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00007 
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 #include "FWCore/Utilities/interface/Exception.h"
00010 #include "DataFormats/Common/interface/Handle.h"
00011 
00012 #include <string>
00013 
00014 EgammaHLTRemoveDuplicatedSC::EgammaHLTRemoveDuplicatedSC(const edm::ParameterSet& ps)
00015 {
00016  
00017  
00018   // the input producers
00019 
00020   sCInputProducer_ = ps.getParameter<edm::InputTag>("L1NonIsoUskimmedSC");
00021   alreadyExistingSC_= ps.getParameter<edm::InputTag>("L1IsoSC");
00022   // set the producer parameters
00023   outputCollection_ = ps.getParameter<std::string>("L1NonIsoSkimmedCollection");
00024   produces<reco::SuperClusterCollection>(outputCollection_);
00025 
00026   
00027 }
00028 
00029 EgammaHLTRemoveDuplicatedSC::~EgammaHLTRemoveDuplicatedSC()
00030 {
00031   ;
00032 }
00033 
00034 void
00035 EgammaHLTRemoveDuplicatedSC::produce(edm::Event& evt, const edm::EventSetup& es)
00036 {
00037   using namespace edm;
00038 
00039  
00040   // Get raw SuperClusters from the event    
00041   Handle<reco::SuperClusterCollection> UnskimmedSuperCluster;
00042   evt.getByLabel(sCInputProducer_, UnskimmedSuperCluster);
00043   Handle<reco::SuperClusterCollection> L1IsoSuperCluster;
00044   evt.getByLabel(alreadyExistingSC_, L1IsoSuperCluster);
00045   /*
00046     edm::LogError("EgammaHLTRemoveDuplicatedSCError") 
00047       << "Error! can't get the rawSuperClusters " 
00048       << sCInputProducer_.label() ;
00049   */
00050   
00051 
00052   // Create a pointer to the existing SuperClusters
00053     const reco::SuperClusterCollection *UnskimmedL1NonIsoSC = UnskimmedSuperCluster.product();
00054     const reco::SuperClusterCollection *L1IsoSC = L1IsoSuperCluster.product();
00055 
00056     /*
00057     for(reco::SuperClusterCollection::const_iterator it = L1IsoSC->begin(); it != L1IsoSC->end(); it++){
00058       std::cout<<"L1 iso  E, eta, phi: "<<it->energy()<<" "<<it->eta()<<" "<<it->phi()<<std::endl;
00059     }
00060     std::cout<<std::endl;
00061     for(reco::SuperClusterCollection::const_iterator it = UnskimmedL1NonIsoSC->begin(); it != UnskimmedL1NonIsoSC->end(); it++){
00062       std::cout<<"L1 Non iso (not skimmed) E, eta, phi: "<<it->energy()<<" "<<it->eta()<<" "<<it->phi()<<std::endl;
00063     }
00064     std::cout<<std::endl;
00065     */
00066 
00067   // Define a collection of corrected SuperClusters to put back into the event
00068   std::auto_ptr<reco::SuperClusterCollection> corrClusters(new reco::SuperClusterCollection);
00069   
00070   //  Loop over raw clusters and make corrected ones
00071   reco::SuperClusterCollection::const_iterator aClus;
00072   reco::SuperClusterCollection::const_iterator cit;
00073   for(aClus = UnskimmedL1NonIsoSC->begin(); aClus != UnskimmedL1NonIsoSC->end(); aClus++)
00074     {
00075       bool AlreadyThere = false;
00076       //reco::SuperCluster newClus;
00077       for(cit = L1IsoSC->begin(); cit != L1IsoSC->end(); cit++){
00078         if( fabs(aClus->energy()- cit->energy()) < 0.5 && fabs(aClus->eta()- cit->eta()) < 0.0175 ){
00079           float deltaphi=fabs( aClus->phi() - cit->phi() );
00080           if(deltaphi>6.283185308) deltaphi -= 6.283185308;
00081           if(deltaphi>3.141592654) deltaphi = 6.283185308-deltaphi;
00082 
00083           if( deltaphi < 0.035 ){AlreadyThere = true; break;}
00084         }
00085       }
00086       // if(AlreadyThere){std::cout<<"AAAA: SC removed: "<<aClus->energy()<<" "<<aClus->eta()<<" "<<aClus->phi()<<std::endl;}
00087       if(!AlreadyThere){corrClusters->push_back(*aClus);}
00088     }
00089 
00090   // Put collection of corrected SuperClusters into the event
00091   evt.put(corrClusters, outputCollection_);   
00092   
00093 }
00094 
00095 
00096