00001 #include "RecoParticleFlow/PFClusterProducer/interface/PFClusterProducer.h" 00002 00003 #include <memory> 00004 00005 #include "RecoParticleFlow/PFClusterAlgo/interface/PFClusterAlgo.h" 00006 00007 #include "DataFormats/ParticleFlowReco/interface/PFRecHit.h" 00008 #include "DataFormats/ParticleFlowReco/interface/PFCluster.h" 00009 00010 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00011 #include "FWCore/Framework/interface/ESHandle.h" 00012 #include "FWCore/Framework/interface/EventSetup.h" 00013 00014 00015 00016 using namespace std; 00017 using namespace edm; 00018 00019 PFClusterProducer::PFClusterProducer(const edm::ParameterSet& iConfig) 00020 { 00021 00022 verbose_ = 00023 iConfig.getUntrackedParameter<bool>("verbose",false); 00024 00025 00026 00027 // parameters for clustering 00028 00029 double threshBarrel = 00030 iConfig.getParameter<double>("thresh_Barrel"); 00031 double threshSeedBarrel = 00032 iConfig.getParameter<double>("thresh_Seed_Barrel"); 00033 00034 double threshEndcap = 00035 iConfig.getParameter<double>("thresh_Endcap"); 00036 double threshSeedEndcap = 00037 iConfig.getParameter<double>("thresh_Seed_Endcap"); 00038 00039 00040 int nNeighbours = 00041 iConfig.getParameter<int>("nNeighbours"); 00042 00043 double posCalcP1 = 00044 iConfig.getParameter<double>("posCalcP1"); 00045 00046 int posCalcNCrystal = 00047 iConfig.getParameter<int>("posCalcNCrystal"); 00048 00049 double showerSigma = 00050 iConfig.getParameter<double>("showerSigma"); 00051 00052 00053 clusterAlgo_.setThreshBarrel( threshBarrel ); 00054 clusterAlgo_.setThreshSeedBarrel( threshSeedBarrel ); 00055 00056 clusterAlgo_.setThreshEndcap( threshEndcap ); 00057 clusterAlgo_.setThreshSeedEndcap( threshSeedEndcap ); 00058 00059 clusterAlgo_.setNNeighbours( nNeighbours ); 00060 clusterAlgo_.setPosCalcP1( posCalcP1 ); 00061 clusterAlgo_.setPosCalcNCrystal( posCalcNCrystal ); 00062 clusterAlgo_.setShowerSigma( showerSigma ); 00063 00064 00065 00066 int dcormode = 00067 iConfig.getParameter<int>("depthCor_Mode"); 00068 00069 double dcora = 00070 iConfig.getParameter<double>("depthCor_A"); 00071 double dcorb = 00072 iConfig.getParameter<double>("depthCor_B"); 00073 double dcorap = 00074 iConfig.getParameter<double>("depthCor_A_preshower"); 00075 double dcorbp = 00076 iConfig.getParameter<double>("depthCor_B_preshower"); 00077 00078 if( dcormode !=0 ) 00079 reco::PFCluster::setDepthCorParameters( dcormode, 00080 dcora, dcorb, 00081 dcorap, dcorbp ); 00082 00083 00084 00085 00086 00087 00088 // access to the collections of rechits from the various detectors: 00089 00090 00091 inputTagPFRecHits_ = 00092 iConfig.getParameter<InputTag>("PFRecHits"); 00093 00094 00095 00096 produces<reco::PFClusterCollection>(); 00097 } 00098 00099 00100 00101 PFClusterProducer::~PFClusterProducer() {} 00102 00103 00104 00105 00106 void PFClusterProducer::produce(edm::Event& iEvent, 00107 const edm::EventSetup& iSetup) { 00108 00109 00110 edm::Handle< reco::PFRecHitCollection > rechitsHandle; 00111 00112 // access the rechits in the event 00113 bool found = iEvent.getByLabel( inputTagPFRecHits_, rechitsHandle ); 00114 00115 if(!found ) { 00116 00117 ostringstream err; 00118 err<<"cannot find rechits: "<<inputTagPFRecHits_; 00119 LogError("PFClusterProducer")<<err.str()<<endl; 00120 00121 throw cms::Exception( "MissingProduct", err.str()); 00122 } 00123 00124 00125 // do clustering 00126 clusterAlgo_.doClustering( rechitsHandle ); 00127 00128 if( verbose_ ) { 00129 LogInfo("PFClusterProducer") 00130 <<" clusters --------------------------------- "<<endl 00131 <<clusterAlgo_<<endl; 00132 } 00133 00134 // get clusters out of the clustering algorithm 00135 // and put them in the event. There is no copy. 00136 auto_ptr< vector<reco::PFCluster> > 00137 outClusters( clusterAlgo_.clusters() ); 00138 iEvent.put( outClusters ); 00139 00140 } 00141 00142 00143