19 reRunAlgo_ (iConfig.getUntrackedParameter<bool>(
"reRunAlgo",
false)),
20 doAreaFastjet_ (iConfig.getParameter<bool> (
"doAreaFastjet")),
21 doRhoFastjet_ (iConfig.getParameter<bool> (
"doRhoFastjet")),
22 jetPtMin_(iConfig.getParameter<double> (
"jetPtMin")),
23 nSigmaPU_(iConfig.getParameter<double>(
"nSigmaPU")),
24 radiusPU_(iConfig.getParameter<double>(
"radiusPU")),
27 if (iConfig.
exists(
"puPtMin"))
31 edm::LogWarning(
"MisConfiguration")<<
"the parameter puPtMin is now necessary for PU substraction. setting it to "<<
puPtMin_;
35 double ghostEtaMax = iConfig.
getParameter<
double>(
"Ghost_EtaMax");
37 int activeAreaRepeats = iConfig.
getParameter<
int> (
"Active_Area_Repeats");
39 double ghostArea = iConfig.
getParameter<
double> (
"GhostArea");
48 std::vector<fastjet::PseudoJet>& towers,
49 std::vector<fastjet::PseudoJet>&
output){
68 LogDebug(
"PileUpSubtractor")<<
"The subtractor setting up geometry...\n";
79 for(std::vector<DetId>::const_iterator did=alldid.begin(); did != alldid.end(); did++){
82 if( (hid).
depth() == 1 ) {
85 if((hid).
ieta() != ietaold){
86 ietaold = (hid).
ieta();
109 LogDebug(
"PileUpSubtractor")<<
"The subtractor calculating pedestals...\n";
110 map<int,double> emean2;
111 map<int,int> ntowers;
113 int ietaold = -10000;
126 for (vector<fastjet::PseudoJet>::const_iterator input_object = coll.begin (),
127 fjInputsEnd = coll.end();
128 input_object != fjInputsEnd; ++input_object) {
130 ieta0 =
ieta( originalTower );
131 double Original_Et = originalTower->et();
132 if( ieta0-ietaold != 0 )
135 emean2[ieta0] = emean2[ieta0]+Original_Et*Original_Et;
142 emean2[ieta0] = emean2[ieta0]+Original_Et*Original_Et;
149 int it = (*gt).first;
151 double e1 = (*(
emean_.find(it))).second;
152 double e2 = (*emean2.find(it)).
second;
155 LogDebug(
"PileUpSubtractor")<<
" ieta : "<<it<<
" number of towers : "<<nt<<
" e1 : "<<e1<<
" e2 : "<<e2<<
"\n";
158 double eee = e2/nt - e1*e1/(nt*
nt);
178 LogDebug(
"PileUpSubtractor")<<
"The subtractor subtracting pedestals...\n";
181 for (vector<fastjet::PseudoJet>::iterator input_object = coll.begin (),
182 fjInputsEnd = coll.end();
183 input_object != fjInputsEnd; ++input_object) {
189 double etnew = itow->et() - (*(
emean_.find(it))).second - (*(
esigma_.find(it))).second;
190 float mScale = etnew/input_object->Et();
191 if(etnew < 0.) mScale = 0.;
194 input_object->pz()*mScale, input_object->e()*mScale);
196 int index = input_object->user_index();
197 input_object->reset_momentum ( towP4.px(),
201 input_object->set_user_index(index);
208 LogDebug(
"PileUpSubtractor")<<
"The subtractor calculating orphan input...\n";
212 vector<int> jettowers;
213 vector<pair<int,int> > excludedTowers;
215 vector <fastjet::PseudoJet>::iterator pseudojetTMP =
fjJets_->begin (),
217 for (; pseudojetTMP != fjJetsEnd ; ++pseudojetTMP) {
218 if(pseudojetTMP->perp() <
puPtMin_)
continue;
224 vector<pair<int,int> >::const_iterator exclude =
find(excludedTowers.begin(),excludedTowers.end(),pair<int,int>(im->ieta(),im->iphi()));
225 if( dr <
radiusPU_ && exclude == excludedTowers.end()) {
227 excludedTowers.push_back(pair<int,int>(im->ieta(),im->iphi()));
230 vector<fastjet::PseudoJet>::const_iterator it =
fjInputs_->begin(),
233 for (; it != fjInputsEnd; ++it ) {
234 int index = it->user_index();
237 vector<pair<int,int> >::const_iterator exclude =
find(excludedTowers.begin(),excludedTowers.end(),pair<int,int>(ie,ip));
238 if(exclude != excludedTowers.end()) {
239 jettowers.push_back(index);
247 for(vector<fastjet::PseudoJet>::const_iterator it =
fjInputs_->begin(),
248 fjInputsEnd =
fjInputs_->end(); it != fjInputsEnd; ++it ) {
249 int index = it->user_index();
250 vector<int>::const_iterator itjet =
find(jettowers.begin(),jettowers.end(),
index);
251 if( itjet == jettowers.end() ){
253 fastjet::PseudoJet orphan(originalTower->px(),originalTower->py(),originalTower->pz(),originalTower->energy());
254 orphan.set_user_index(index);
256 orphanInput.push_back(orphan);
264 LogDebug(
"PileUpSubtractor")<<
"The subtractor correcting jets...\n";
266 using namespace reco;
272 vector<fastjet::PseudoJet>::iterator pseudojetTMP =
fjJets_->begin (),
274 for (; pseudojetTMP != jetsEnd; ++pseudojetTMP) {
275 int ijet = pseudojetTMP -
fjJets_->begin();
278 std::vector<fastjet::PseudoJet> towers =
279 fastjet::sorted_by_pt( pseudojetTMP->constituents() );
280 double newjetet = 0.;
281 for(vector<fastjet::PseudoJet>::const_iterator ito = towers.begin(),
282 towEnd = towers.end();
287 int it =
ieta( originalTower );
288 double Original_Et = originalTower->et();
290 if(etnew < 0.) etnew = 0;
291 newjetet = newjetet + etnew;
294 double mScale = newjetet/pseudojetTMP->Et();
295 LogDebug(
"PileUpSubtractor")<<
"pseudojetTMP->Et() : "<<pseudojetTMP->Et()<<
"\n";
296 LogDebug(
"PileUpSubtractor")<<
"newjetet : "<<newjetet<<
"\n";
298 LogDebug(
"PileUpSubtractor")<<
"pseudojetTMP->Et() - jetOffset_[ijet] : "<<pseudojetTMP->Et() -
jetOffset_[ijet]<<
"\n";
299 LogDebug(
"PileUpSubtractor")<<
"Scale is : "<<mScale<<
"\n";
300 int cshist = pseudojetTMP->cluster_hist_index();
301 pseudojetTMP->reset_momentum(pseudojetTMP->px()*mScale, pseudojetTMP->py()*mScale,
302 pseudojetTMP->pz()*mScale, pseudojetTMP->e()*mScale);
303 pseudojetTMP->set_cluster_hist_index(cshist);
312 if( im->depth() != 1 )
continue;
316 pu += (*
emean_.find(im->ieta())).second+(*
esigma_.find(im->ieta())).second;
361 throw cms::Exception(
"Invalid Constituent") <<
"CaloJet constituent is not of CaloTower type";
373 throw cms::Exception(
"Invalid Constituent") <<
"CaloJet constituent is not of CaloTower type";
T getParameter(std::string const &) const
virtual void calculateOrphanInput(std::vector< fastjet::PseudoJet > &orphanInput)
std::vector< double > jetOffset_
virtual double getMeanAtTower(const reco::CandidatePtr &in) const
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
int getNwithJets(const reco::CandidatePtr &in) const
std::vector< fastjet::PseudoJet > * fjJets_
std::map< int, double > esigma_
T const * get() const
Returns C++ pointer to the item.
std::map< int, int > geomtowers_
std::vector< fastjet::PseudoJet > fjOriginalInputs_
Geom::Phi< T > phi() const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
virtual double getPileUpAtTower(const reco::CandidatePtr &in) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
static std::string const input
int ieta(const reco::CandidatePtr &in) const
U second(std::pair< T, U > const &p)
virtual void offsetCorrectJets()
std::vector< fastjet::PseudoJet > * fjInputs_
std::map< int, int > ntowersWithJets_
int iphi() const
get the tower iphi
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
boost::shared_ptr< fastjet::GhostedAreaSpec > ActiveAreaSpecPtr
virtual void subtractPedestal(std::vector< fastjet::PseudoJet > &coll)
#define EDM_REGISTER_PLUGINFACTORY(_factory_, _category_)
int iphi(const reco::CandidatePtr &in) const
CaloTowerDetId id() const
ActiveAreaSpecPtr fjActiveArea_
virtual double getSigmaAtTower(const reco::CandidatePtr &in) const
boost::shared_ptr< fastjet::RangeDefinition > RangeDefPtr
virtual void setDefinition(JetDefPtr const &jetDef)
et
define resolution functions of each parameter
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
CaloGeometry const * geo_
std::map< int, double > emean_
PileUpSubtractor(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
virtual void calculatePedestal(std::vector< fastjet::PseudoJet > const &coll)
virtual void setupGeometryMap(edm::Event &iEvent, const edm::EventSetup &iSetup)
int ieta() const
get the tower ieta
virtual double getCone(double cone, double eta, double phi, double &et, double &pu)
virtual void reset(std::vector< edm::Ptr< reco::Candidate > > &input, std::vector< fastjet::PseudoJet > &towers, std::vector< fastjet::PseudoJet > &output)
T const * product() const
std::vector< HcalDetId > allgeomid_
JetDefPtr fjJetDefinition_
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
std::vector< edm::Ptr< reco::Candidate > > * inputs_
int getN(const reco::CandidatePtr &in) const
boost::shared_ptr< fastjet::JetDefinition > JetDefPtr