30 const std::string PositionCalcType__EGPositionCalc(
"EGPositionCalc");
31 const std::string PositionCalcType__EGPositionFormula(
"EGPositionFormula");
32 const std::string PositionCalcType__PFPositionCalc(
"PFPositionCalc");
34 bool sortByKey(
const EEPSPair&
a,
const EEPSPair&
b) {
35 return a.first < b.first;
39 if( psclus.
isNull() )
return -1.0;
54 if( eeclus->z()*psclus->z() < 0 )
return -1.0;
57 if( dphi > 0.6 )
return -1.0;
58 const double deta=
std::abs(eepos.eta() - pspos.eta());
59 if( deta > 0.3 )
return -1.0;
70 pfEnergyCalibration_ =
77 double threshSeedBarrel =
80 double threshPtBarrel =
82 double threshPtSeedBarrel =
85 double threshCleanBarrel =
87 std::vector<double> minS4S1CleanBarrel =
88 iConfig.
getParameter< std::vector<double> >(
"minS4S1_Clean_Barrel");
92 double threshSeedEndcap =
95 double threshPtEndcap =
97 double threshPtSeedEndcap =
100 double threshCleanEndcap =
102 std::vector<double> minS4S1CleanEndcap =
103 iConfig.
getParameter< std::vector<double> >(
"minS4S1_Clean_Endcap");
105 double threshDoubleSpikeBarrel =
106 iConfig.
getParameter<
double>(
"thresh_DoubleSpike_Barrel");
107 double minS6S2DoubleSpikeBarrel =
108 iConfig.
getParameter<
double>(
"minS6S2_DoubleSpike_Barrel");
109 double threshDoubleSpikeEndcap =
110 iConfig.
getParameter<
double>(
"thresh_DoubleSpike_Endcap");
111 double minS6S2DoubleSpikeEndcap =
112 iConfig.
getParameter<
double>(
"minS6S2_DoubleSpike_Endcap");
120 int posCalcNCrystal =
126 bool useCornerCells =
129 bool cleanRBXandHPDs =
133 clusterAlgo_.setThreshBarrel( threshBarrel );
134 clusterAlgo_.setThreshSeedBarrel( threshSeedBarrel );
136 clusterAlgo_.setThreshPtBarrel( threshPtBarrel );
137 clusterAlgo_.setThreshPtSeedBarrel( threshPtSeedBarrel );
139 clusterAlgo_.setThreshCleanBarrel(threshCleanBarrel);
140 clusterAlgo_.setS4S1CleanBarrel(minS4S1CleanBarrel);
142 clusterAlgo_.setThreshDoubleSpikeBarrel( threshDoubleSpikeBarrel );
143 clusterAlgo_.setS6S2DoubleSpikeBarrel( minS6S2DoubleSpikeBarrel );
145 clusterAlgo_.setThreshEndcap( threshEndcap );
146 clusterAlgo_.setThreshSeedEndcap( threshSeedEndcap );
148 clusterAlgo_.setThreshPtEndcap( threshPtEndcap );
149 clusterAlgo_.setThreshPtSeedEndcap( threshPtSeedEndcap );
151 clusterAlgo_.setThreshCleanEndcap(threshCleanEndcap);
152 clusterAlgo_.setS4S1CleanEndcap(minS4S1CleanEndcap);
154 clusterAlgo_.setThreshDoubleSpikeEndcap( threshDoubleSpikeEndcap );
155 clusterAlgo_.setS6S2DoubleSpikeEndcap( minS6S2DoubleSpikeEndcap );
157 clusterAlgo_.setNNeighbours( nNeighbours );
160 std::string poscalctype = PositionCalcType__PFPositionCalc;
164 if( poscalctype == PositionCalcType__EGPositionCalc ) {
168 clusterAlgo_.setEGammaPosCalc(pc_config);
169 }
else if( poscalctype == PositionCalcType__EGPositionFormula) {
174 clusterAlgo_.setPosCalcW0(w0);
175 }
else if( poscalctype == PositionCalcType__PFPositionCalc) {
179 <<
"You have not chosen a valid position calculation type,"
180 <<
" please choose from \""
181 << PositionCalcType__EGPositionCalc <<
"\", \""
182 << PositionCalcType__EGPositionFormula <<
"\", or \""
183 << PositionCalcType__PFPositionCalc <<
"\"!";
187 double posCalcP1 = threshBarrel<threshEndcap ? threshBarrel:threshEndcap;
188 clusterAlgo_.setPosCalcP1( posCalcP1 );
189 clusterAlgo_.setPosCalcNCrystal( posCalcNCrystal );
190 clusterAlgo_.setShowerSigma( showerSigma );
192 clusterAlgo_.setUseCornerCells( useCornerCells );
193 clusterAlgo_.setCleanRBXandHPDs( cleanRBXandHPDs);
221 if( produces_eeps ) {
222 inputTagPFClustersPS_ =
224 threshPFClusterES_ = iConfig.
getParameter<
double>(
"thresh_Preshower");
225 applyCrackCorrections_ =
227 if (inputTagPFClustersPS_.label().empty()) {
228 produces_eeps =
false;
230 produces<reco::PFCluster::EEtoPSAssociation>();
237 produces<reco::PFClusterCollection>();
238 produces<reco::PFRecHitCollection>(
"Cleaned");
255 clusterAlgo_.setEBGeom(cgeom->getSubdetectorGeometry(
DetId::Ecal,
257 clusterAlgo_.setEEGeom(cgeom->getSubdetectorGeometry(
DetId::Ecal,
259 clusterAlgo_.setPreshowerGeom(cgeom->getSubdetectorGeometry(
DetId::Ecal,
277 err<<
"cannot find rechits: "<<inputTagPFRecHits_;
278 LogError(
"PFClusterProducer")<<err.str()<<endl;
284 clusterAlgo_.doClustering( rechitsHandle );
288 <<
" clusters --------------------------------- "<<endl
289 <<clusterAlgo_<<endl;
292 std::auto_ptr< std::vector<reco::PFCluster> > clusters =
293 clusterAlgo_.clusters();
295 if( produces_eeps ) {
296 iEvent.
getByLabel( inputTagPFClustersPS_, psclustersHandle );
298 std::auto_ptr<reco::PFCluster::EEtoPSAssociation>
302 psclustersHandle->ptrVector();
303 double dist = -1.0, min_dist = -1.0;
306 for(
const auto& psclus : clusterPtrsPS ) {
307 if( psclus->energy() < threshPFClusterES_ )
continue;
308 switch( psclus->layer() ) {
316 dist = min_dist = -1.0;
317 for(
size_t ic = 0; ic < clusters->size(); ++ic ) {
320 dist = testPreshowerDistance(eeclus,psclus);
321 if( dist == -1.0 || (min_dist != -1.0 && dist > min_dist) )
continue;
322 if( dist < min_dist || min_dist == -1.0 ) {
328 outEEPS->push_back(std::make_pair(eematch.
key(),psclus));
332 std::sort(outEEPS->begin(),outEEPS->end(),sortByKey);
334 std::vector<double> ps1_energies,ps2_energies;
336 for(
size_t ic = 0 ; ic < clusters->size(); ++ic ) {
337 ps1_energies.clear();
338 ps2_energies.clear();
341 const auto clustops = std::equal_range(outEEPS->begin(),
345 for(
auto i_ps = clustops.first; i_ps != clustops.second; ++i_ps) {
347 switch( psclus->layer() ) {
349 ps1_energies.push_back(psclus->energy());
352 ps2_energies.push_back(psclus->energy());
359 pfEnergyCalibration_->energyEm(clusters->at(ic),
360 ps1_energies,ps2_energies,
362 applyCrackCorrections_);
363 clusters->at(ic).setCorrectedEnergy(eCorr);
372 auto_ptr< vector<reco::PFRecHit> > recHitsCleaned ( clusterAlgo_.rechitsCleaned() );
374 iEvent.
put( clusters );
375 iEvent.
put( recHitsCleaned,
"Cleaned" );
T getParameter(std::string const &) const
unsigned long long cacheIdentifier() const
T getUntrackedParameter(std::string const &, T const &) const
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
static void setDepthCorParameters(int mode, double a, double b, double ap, double bp)
static double testECALAndPSByRecHit(const reco::PFCluster &clusterECAL, const reco::PFCluster &clusterPS, bool debug=false)
ROOT::Math::PositionVector3D< ROOT::Math::CylindricalEta3D< Double32_t > > REPPoint
double Phi_mpi_pi(double x)
virtual void produce(edm::Event &, const edm::EventSetup &)
bool isNonnull() const
Checks for non-null.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
std::vector< std::pair< CaloClusterPtr::key_type, edm::Ptr< PFCluster > > > EEtoPSAssociation
Abs< T >::type abs(const T &t)
Container::value_type value_type
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
virtual void beginLuminosityBlock(edm::LuminosityBlock const &iL, edm::EventSetup const &iE)
ParameterSet const & getParameterSet(std::string const &) const
bool isNull() const
Checks for null.
PFClusterProducer(const edm::ParameterSet &)
static float eCorr(int ieta, int iphi, double ampl, int runnum)
Ugly hack to apply energy corrections to some HB- cells.