9 for ( std::map<int, double>::iterator
iter = esigma_.begin();
19 LogDebug(
"PileUpSubtractor")<<
"The subtractor correcting jets...\n";
24 (*fjInputs_) = fjOriginalInputs_;
25 rescaleRMS(nSigmaPU_);
26 subtractPedestal(*fjInputs_);
27 const fastjet::JetDefinition&
def = *fjJetDefinition_;
28 if ( !doAreaFastjet_ && !doRhoFastjet_) {
31 fjClusterSeq_ =
ClusterSequencePtr(
new fastjet::ClusterSequenceArea( *fjInputs_,
def, *fjActiveArea_ ) );
34 (*fjJets_) = fastjet::sorted_by_pt(fjClusterSeq_->inclusive_jets(jetPtMin_));
36 jetOffset_.reserve(fjJets_->size());
38 vector<fastjet::PseudoJet>::iterator pseudojetTMP = fjJets_->begin (),
39 jetsEnd = fjJets_->end();
40 for (; pseudojetTMP != jetsEnd; ++pseudojetTMP) {
42 int ijet = pseudojetTMP - fjJets_->begin();
45 std::vector<fastjet::PseudoJet>
towers =
46 sorted_by_pt(pseudojetTMP->constituents());
49 for(vector<fastjet::PseudoJet>::const_iterator ito = towers.begin(),
50 towEnd = towers.end();
55 int it = ieta( originalTower );
56 double Original_Et = originalTower->et();
57 double etnew = Original_Et - (*emean_.find(it)).
second - (*esigma_.find(it)).
second;
58 if(etnew < 0.) etnew = 0;
59 newjetet = newjetet + etnew;
60 jetOffset_[ijet] += Original_Et - etnew;
68 LogDebug(
"PileUpSubtractor")<<
"The subtractor subtracting pedestals...\n";
72 vector<fastjet::PseudoJet> newcoll;
74 for (vector<fastjet::PseudoJet>::iterator input_object = coll.begin (),
75 fjInputsEnd = coll.end();
76 input_object != fjInputsEnd; ++input_object) {
83 double Original_Et = itow->et();
85 Original_Et = getEt(itow);
88 double etnew = Original_Et - (*(emean_.find(it))).second - (*(esigma_.find(it))).second;
89 float mScale = etnew/input_object->Et();
90 if(etnew < 0.) mScale = 0.;
93 input_object->pz()*mScale, input_object->e()*mScale);
95 int index = input_object->user_index();
96 input_object->reset_momentum ( towP4.px(),
100 input_object->set_user_index(index);
102 if(etnew > 0. && dropZeroTowers_) newcoll.push_back(*input_object);
105 if(dropZeroTowers_) coll = newcoll;
111 LogDebug(
"PileUpSubtractor")<<
"The subtractor calculating pedestals...\n";
113 map<int,double> emean2;
114 map<int,int> ntowers;
116 int ietaold = -10000;
121 for(
int i = ietamin_;
i < ietamax_+1;
i++)
129 for (vector<fastjet::PseudoJet>::const_iterator input_object = coll.begin (),
130 fjInputsEnd = coll.end();
131 input_object != fjInputsEnd; ++input_object) {
134 ieta0 = ieta( originalTower );
135 double Original_Et = originalTower->et();
137 Original_Et = getEt(originalTower);
140 if( ieta0-ietaold != 0 )
142 emean_[ieta0] = emean_[ieta0]+Original_Et;
143 emean2[ieta0] = emean2[ieta0]+Original_Et*Original_Et;
149 emean_[ieta0] = emean_[ieta0]+Original_Et;
150 emean2[ieta0] = emean2[ieta0]+Original_Et*Original_Et;
156 for(map<int,int>::const_iterator
gt = geomtowers_.begin();
gt != geomtowers_.end();
gt++)
159 int it = (*gt).first;
161 double e1 = (*(emean_.find(it))).second;
162 double e2 = (*emean2.find(it)).
second;
163 int nt = (*gt).second - (*(ntowersWithJets_.find(it))).second;
165 LogDebug(
"PileUpSubtractor")<<
" ieta : "<<it<<
" number of towers : "<<nt<<
" e1 : "<<e1<<
" e2 : "<<e2<<
"\n";
169 double eee = e2/nt - e1*e1/(nt*
nt);
171 esigma_[it] = nSigmaPU_*
sqrt(eee);
178 LogDebug(
"PileUpSubtractor")<<
" ieta : "<<it<<
" Pedestals : "<<emean_[it]<<
" "<<esigma_[it]<<
"\n";
190 double et = energy*
sin(pos.
theta());
double getEt(const reco::CandidatePtr &in) const
virtual void calculatePedestal(std::vector< fastjet::PseudoJet > const &coll)
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
boost::shared_ptr< fastjet::ClusterSequence > ClusterSequencePtr
T const * get() const
Returns C++ pointer to the item.
Sin< T >::type sin(const T &t)
double getEta(const reco::CandidatePtr &in) const
virtual void subtractPedestal(std::vector< fastjet::PseudoJet > &coll)
Geom::Theta< T > theta() const
U second(std::pair< T, U > const &p)
virtual void offsetCorrectJets()
void rescaleRMS(double s)
CaloTowerDetId id() const