#include <RecoJets/JetProducers/src/BasePilupSubtractionJetProducer.h>
Definition at line 36 of file BasePilupSubtractionJetProducer.h.
BasePilupSubtractionJetProducer::BasePilupSubtractionJetProducer | ( | const edm::ParameterSet & | ps | ) |
Definition at line 72 of file BasePilupSubtractionJetProducer.cc.
References TestMuL1L2Filter_cff::cerr, lat::endl(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), makeCaloJetPU(), and mJetType.
00073 : mSrc (conf.getParameter<edm::InputTag>( "src" )), 00074 mJetType (conf.getUntrackedParameter<string>( "jetType", "CaloJet")), 00075 mVerbose (conf.getUntrackedParameter<bool>("verbose", false)), 00076 mEtInputCut (conf.getParameter<double>("inputEtMin")), 00077 mEInputCut (conf.getParameter<double>("inputEMin")), 00078 mEtJetInputCut (conf.getParameter<double>("inputEtJetMin")), 00079 nSigmaPU (conf.getParameter<double>("nSigmaPU")), 00080 radiusPU (conf.getParameter<double>("radiusPU")),geo(0) 00081 { 00082 // std::cout<<" Number of sigmas "<<nSigmaPU<<std::endl; 00083 std::string alias = conf.getUntrackedParameter<string>( "alias", conf.getParameter<std::string>("@module_label")); 00084 if (!makeCaloJetPU (mJetType)) { 00085 std::cerr << "BasePilupSubtractionJetProducer-> ERROR: wrong jetType '" << mJetType 00086 << "'. The only supported jetType is 'CaloJetPileupSubtraction'" << std::endl; 00087 } 00088 produces<CaloJetCollection>().setBranchAlias (alias); 00089 }
BasePilupSubtractionJetProducer::~BasePilupSubtractionJetProducer | ( | ) | [virtual] |
void BasePilupSubtractionJetProducer::beginJob | ( | const edm::EventSetup & | iSetup | ) | [virtual] |
Reimplemented from edm::EDProducer.
Definition at line 94 of file BasePilupSubtractionJetProducer.cc.
void BasePilupSubtractionJetProducer::calculate_pedestal | ( | const JetReco::InputCollection & | fInputs | ) |
Definition at line 430 of file BasePilupSubtractionJetProducer.cc.
References e1, e2, i, it, edm::second(), and funct::sqrt().
00431 { 00432 // std::cout<<"========== Start BasePilupSubtractionJetProducer::calculate_pedestal"<<std::endl; 00433 // std::cout<<" BasePilupSubtractionJetProducer::calculate_pedestal::ietamax="<<ietamax<<" ietamin="<<ietamin<<std::endl; 00434 00435 map<int,double> emean2; 00436 map<int,int> ntowers; 00437 00438 int ietaold = -10000; 00439 int ieta0 = -100; 00440 00441 // Initial values for emean, emean2, esigma, ntowers 00442 00443 for(int i = ietamin; i < ietamax+1; i++) 00444 { 00445 emean[i] = 0.; 00446 emean2[i] = 0.; 00447 esigma[i] = 0.; 00448 ntowers[i] = 0; 00449 } 00450 00451 //=> 00452 00453 for (JetReco::InputCollection::const_iterator input_object = fInputs.begin (); input_object != fInputs.end (); input_object++) { 00454 00455 ieta0 = ieta(&(**input_object)); 00456 00457 // std::cout<<"+++calculate pedestal, Et_tower="<<(**input_object).et() 00458 // <<" ieta0 ="<<ieta(&(**input_object)) 00459 // <<" iphi0 ="<<iphi(&(**input_object))<<"ietaold="<<ietaold<<std::endl; 00460 00461 //=> 00462 if( ieta0-ietaold != 0 ) 00463 { 00464 00465 emean[ieta0] = emean[ieta0]+(**input_object).et(); 00466 emean2[ieta0] = emean2[ieta0]+((**input_object).et())*((**input_object).et()); 00467 ntowers[ieta0] = 1; 00468 00469 ietaold = ieta0; 00470 00471 // std::cout<<"--NEW ETA, emean[ieta0]="<<emean[ieta0] 00472 // <<" ntowers[ieta0]="<<ntowers[ieta0]<<" ieta0="<<ieta0<<std::endl; 00473 } 00474 else 00475 { 00476 emean[ieta0] = emean[ieta0]+(**input_object).et(); 00477 emean2[ieta0] = emean2[ieta0]+((**input_object).et())*((**input_object).et()); 00478 ntowers[ieta0]++; 00479 00480 // std::cout<<"--OLD ETA, emean[ieta0]="<<emean[ieta0] 00481 // <<" ntowers[ieta0]="<<ntowers[ieta0]<<" ieta0="<<ieta0<<std::endl; 00482 } 00483 00484 //=> 00485 00486 00487 } 00488 00489 //======================> 00490 // std::cout<<" Geom towers begin "<<geomtowers.size()<<std::endl; 00491 00492 for(map<int,int>::const_iterator gt = geomtowers.begin(); gt != geomtowers.end(); gt++) 00493 { 00494 00495 int it = (*gt).first; 00496 00497 double e1 = (*emean.find(it)).second; 00498 double e2 = (*emean2.find(it)).second; 00499 int nt = (*gt).second - (*ntowers_with_jets.find(it)).second; 00500 00501 if(nt > 0) { 00502 emean[it] = e1/nt; 00503 double eee = e2/nt - e1*e1/(nt*nt); 00504 00505 // std::cout<<" Pedestal "<<it<<" "<<emean[it]<<" "<<eee<<" "<<e2<<" "<<e1<<" "<<nt<<std::endl; 00506 00507 if(eee<0.) eee = 0.; 00508 esigma[it] = nSigmaPU*sqrt(eee); 00509 } 00510 else 00511 { 00512 emean[it] = 0.; 00513 esigma[it] = 0.; 00514 } 00515 00516 // std::cout<<"---calculate_pedestal, emean[it]= " 00517 // <<(*emean.find(it)).second<<"esigma[it]="<<(*esigma.find(it)).second 00518 // <<" ntowers_without_jets{it]="<<nt<<" it="<<it 00519 // <<" ntowers_map(it)="<<(*ntowers.find(it)).second 00520 // <<" geomtowers(it)="<<(*geomtowers.find(it)).second<<" gt.second "<<(*gt).second<< 00521 // " ntow_with_jets "<<(*ntowers_with_jets.find(it)).second<<std::endl; 00522 00523 } 00524 00525 }
int BasePilupSubtractionJetProducer::ieta | ( | const reco::Candidate * | in | ) |
Definition at line 621 of file BasePilupSubtractionJetProducer.cc.
References Exception, CaloTower::id(), CaloTowerDetId::ieta(), it, and makeCaloJetPU().
00622 { 00623 // std::cout<<" Start BasePilupSubtractionJetProducer::ieta "<<std::endl; 00624 int it = 0; 00625 if (makeCaloJetPU (mJetType)) { 00626 // std::cout<<" BasePilupSubtractionJetProducer::ieta::PU type "<<std::endl; 00627 // updated from RecoCaloTowerCandidate (MBT 10 July 2008) 00628 const CaloTower* ctc = dynamic_cast<const CaloTower*>(in); 00629 00630 if(ctc) 00631 { 00632 it = ctc->id().ieta(); 00633 } else 00634 { 00635 throw cms::Exception("Invalid Constituent") << "CaloJet constituent is not of CaloTower type"; 00636 } 00637 } 00638 // std::cout<<" End BasePilupSubtractionJetProducer::ieta "<<it<<std::endl; 00639 return it; 00640 }
int BasePilupSubtractionJetProducer::iphi | ( | const reco::Candidate * | in | ) |
Definition at line 642 of file BasePilupSubtractionJetProducer.cc.
References Exception, CaloTower::id(), CaloTowerDetId::iphi(), it, and makeCaloJetPU().
00643 { 00644 // std::cout<<" Start BasePilupSubtractionJetProducer::iphi "<<std::endl; 00645 int it = 0; 00646 if (makeCaloJetPU (mJetType)) { 00647 // std::cout<<"BasePilupSubtractionJetProducer::iphi::PU type "<<std::endl; 00648 // updated from RecoCaloTowerCandidate (MBT 10 July 2008) 00649 const CaloTower* ctc = dynamic_cast<const CaloTower*>(in); 00650 if(ctc) 00651 { 00652 it = ctc->id().iphi(); 00653 } else 00654 { 00655 throw cms::Exception("Invalid Constituent") << "CaloJet constituent is not of CaloTower type"; 00656 } 00657 } 00658 // std::cout<<" End BasePilupSubtractionJetProducer::iphi "<<it<<std::endl; 00659 return it; 00660 }
std::string cms::BasePilupSubtractionJetProducer::jetType | ( | ) | const [inline] |
jet type
Definition at line 47 of file BasePilupSubtractionJetProducer.h.
References mJetType.
00047 {return mJetType;}
void BasePilupSubtractionJetProducer::produce | ( | edm::Event & | e, | |
const edm::EventSetup & | c | |||
) | [virtual] |
Produces the EDM products.
!! Change towers to rescaled towers///
Implements edm::EDProducer.
Definition at line 99 of file BasePilupSubtractionJetProducer.cc.
References reco::CompositePtrCandidate::addDaughter(), DetId::Calo, dumpJets(), find(), edm::EventSetup::get(), edm::Event::getByLabel(), ProtoJet::getTowerList(), CaloGeometry::getValidDetIds(), DetId::Hcal, i, iggi_31X_cfg::input, it, ProtoJet::jetArea(), pfTauBenchmarkGeneric_cfi::jets, kk, JetMaker::makeSpecific(), ProtoJet::nPasses(), offset, output(), ProtoJet::p4(), ProtoJet::pileup(), edm::ESHandle< T >::product(), edm::Event::put(), edm::second(), reco::Jet::setJetArea(), reco::Jet::setNPasses(), reco::Jet::setPileup(), sortByPt(), funct::sqrt(), and CaloTowerDetId::SubdetId.
00100 { 00101 // std::cout<<"========================BasePilupSubtractionJetProducer::produce::start"<<std::endl; 00102 00103 // Provenance 00104 /* 00105 std::vector<edm::Provenance const*> theProvenance; 00106 e.getAllProvenance(theProvenance); 00107 for( std::vector<edm::Provenance const*>::const_iterator ip = theProvenance.begin(); 00108 ip != theProvenance.end(); ip++) 00109 { 00110 00111 std::cout<<" Print all module/label names "<<(**ip).moduleName()<<" "<<(**ip).moduleLabel()<< 00112 " "<<(**ip).productInstanceName()<<std::endl; 00113 edm::ParameterSetID pset = (**ip).psetID(); 00114 std::cout<<" Try to print "<<pset<<std::endl; 00115 } 00116 */ 00117 00118 if(geo == 0) 00119 { 00120 edm::ESHandle<CaloGeometry> pG; 00121 fSetup.get<CaloGeometryRecord>().get(pG); 00122 geo = pG.product(); 00123 std::vector<DetId> alldid = geo->getValidDetIds(); 00124 00125 int ietaold = -10000; 00126 ietamax = -10000; 00127 ietamin = 10000; 00128 for(std::vector<DetId>::const_iterator did=alldid.begin(); did != alldid.end(); did++) 00129 { 00130 if( (*did).det() == DetId::Hcal ) 00131 { 00132 HcalDetId hid = HcalDetId(*did); 00133 if( (hid).depth() == 1 ) 00134 { 00135 // std::cout<<" Hcal detector eta,phi,depth "<<(hid).ieta()<<" "<<(hid).iphi()<<" "<<(hid).depth()<<std::endl; 00136 allgeomid.push_back(*did); 00137 00138 if((hid).ieta() != ietaold) 00139 { 00140 ietaold = (hid).ieta(); 00141 geomtowers[(hid).ieta()] = 1; 00142 if((hid).ieta() > ietamax) ietamax = (hid).ieta(); 00143 if((hid).ieta() < ietamin) ietamin = (hid).ieta(); 00144 } 00145 else 00146 { 00147 geomtowers[(hid).ieta()]++; 00148 } 00149 } 00150 } 00151 } 00152 } 00153 // Clear ntowers_with_jets ==================================================== 00154 for (int i = ietamin; i<ietamax+1; i++) 00155 { 00156 ntowers_with_jets[i] = 0; 00157 } 00158 //============================================================================== 00159 // get input 00160 edm::Handle<edm::View <Candidate> > inputHandle; 00161 e.getByLabel( mSrc, inputHandle); 00162 // convert to input collection 00163 JetReco::InputCollection input; 00164 input.reserve (inputHandle->size()); 00165 for (unsigned i = 0; i < inputHandle->size(); ++i) { 00166 if ((mEtInputCut <= 0 || (*inputHandle)[i].et() > mEtInputCut) && 00167 (mEInputCut <= 0 || (*inputHandle)[i].energy() > mEInputCut)) { 00168 input.push_back (JetReco::InputItem (&((*inputHandle)[i]), i)); 00169 } 00170 } 00171 // 00172 // Create the initial vector for Candidates 00173 // 00174 // std::cout<<"============================================= Before first calculate pedestal "<<std::endl; 00175 00176 calculate_pedestal(input); 00177 std::vector<ProtoJet> output; 00178 00179 // std::cout<<"============================================= After first calculate pedestal "<<std::endl; 00180 00181 InputCollection inputTMPN = subtract_pedestal(input); 00182 00183 // std::cout<<"============================================= After pedestal subtraction "<<inputTMPN.size()<<std::endl; 00184 00185 00186 // run algorithm 00187 vector <ProtoJet> firstoutput; 00188 00189 // std::cout<<" We are here at Point 0 "<<std::endl; 00190 00191 // runAlgorithm (input, &firstoutput); 00192 00193 runAlgorithm (inputTMPN, &firstoutput); 00194 00195 00196 // std::cout<<" We are here at Point 1 with firstoutput size (Njets) "<<firstoutput.size()<<std::endl; 00197 // 00198 // Now we find jets and need to recalculate their energy, 00199 // mark towers participated in jet, 00200 // remove occupied towers from the list and recalculate mean and sigma 00201 // put the initial towers collection to the jet, 00202 // and subtract from initial towers in jet recalculated mean and sigma of towers 00203 00204 InputCollection jettowers; 00205 vector <ProtoJet>::iterator protojetTMP = firstoutput.begin (); 00206 00207 for (; protojetTMP != firstoutput.end (); protojetTMP++) { 00208 00209 // std::cout<<" Before mEtJetInputCut, firstoutput.size()="<<firstoutput.size() 00210 // <<" (*protojetTMP).et()="<<(*protojetTMP).et()<<std::endl; 00211 00212 if( (*protojetTMP).et() < mEtJetInputCut) continue; 00213 00214 ProtoJet::Constituents newtowers; 00215 00216 // std::cout<<" First passed cut, (*protojetTMP).et()= "<<(*protojetTMP).et() 00217 // <<" Eta_jet= "<< (*protojetTMP).eta()<<" Phi_jet="<<(*protojetTMP).phi()<<std::endl; 00218 00219 double eta2 = (*protojetTMP).eta(); 00220 double phi2 = (*protojetTMP).phi(); 00221 for(vector<HcalDetId>::const_iterator im = allgeomid.begin(); im != allgeomid.end(); im++) 00222 { 00223 double eta1 = geo->getPosition((DetId)(*im)).eta(); 00224 double phi1 = geo->getPosition((DetId)(*im)).phi(); 00225 00226 double dphi = fabs(phi1-phi2); 00227 double deta = eta1-eta2; 00228 if (dphi > 4.*atan(1.)) dphi = 8.*atan(1.) - dphi; 00229 double dr = sqrt(dphi*dphi+deta*deta); 00230 00231 // std::cout<<" dr="<<dr<<std::endl; 00232 00233 if( dr < radiusPU) { 00234 ntowers_with_jets[(*im).ieta()]++; 00235 00236 // std::cout<<"Towers WITH jets, eta1="<<eta1<<" phi1="<<phi1 00237 // <<" ntowers_with_jets="<<ntowers_with_jets[(*im).ieta()] 00238 // <<"(DetId)(*im)="<<(*im)<<std::endl; 00239 00240 } 00241 00242 } 00243 00244 // std::cout<<" Number of towers in input collection "<<inputs.size()<<std::endl; 00245 00246 for (InputCollection::const_iterator it = input.begin(); it != input.end(); it++ ) { 00247 00248 double eta1 = (**it).eta(); 00249 double phi1 = (**it).phi(); 00250 00251 double dphi = fabs(phi1-phi2); 00252 double deta = eta1-eta2; 00253 if (dphi > 4.*atan(1.)) dphi = 8.*atan(1.) - dphi; 00254 double dr = sqrt(dphi*dphi+deta*deta); 00255 00256 if( dr < radiusPU) { 00257 newtowers.push_back(*it); 00258 jettowers.push_back(*it); 00259 00260 int ieta1 = ieta(&(**it)); 00261 int iphi1 = iphi(&(**it)); 00262 // std::cout<<" Take Et of tower inputs, (dr < 0.5), (**it).et()= "<<(**it).et()<<" eta= "<<(**it).eta() 00263 // <<" phi= "<<(**it).phi()<<" ieta1= "<<ieta1<<" iphi1= "<<iphi1<<std::endl; 00264 00265 } //dr < 0.5 00266 00267 } // initial input collection 00268 00269 // std::cout<<" Jet with new towers before putTowers (after background subtraction) "<<(*protojetTMP).et()<<std::endl; 00270 00271 (*protojetTMP).putTowers(newtowers); // put the reference of the towers from initial map 00272 00273 // std::cout<<" Jet with new towers (Initial tower energy)"<<(*protojetTMP).et()<<std::endl; 00274 00275 00276 //========> PRINT Tower after Subtraction 00277 if (0) { // bypass 00278 for (InputCollection::const_iterator itt = input.begin(); itt != input.end(); itt++ ) { 00279 00280 double eta_pu1 = (**itt).eta(); 00281 double phi_pu1 = (**itt).phi(); 00282 00283 double dphi = fabs(phi_pu1-phi2); 00284 double deta = eta_pu1-eta2; 00285 if (dphi > 4.*atan(1.)) dphi = 8.*atan(1.) - dphi; 00286 double dr = sqrt(dphi*dphi+deta*deta); 00287 00288 if( dr < radiusPU) { 00289 int ieta_pu1 = ieta(&(**itt)); 00290 int iphi_pu1 = iphi(&(**itt)); 00291 00292 // std::cout<<" Take Et of tower after Subtraction, (**itt).et()= "<<(**itt).et() 00293 // <<" eta= "<<(**itt).eta()<<" phi= "<<(**itt).phi() 00294 // <<" ieta_pu1= "<<ieta_pu1<<" iphi_pu1= "<<iphi_pu1<<std::endl; 00295 00296 } //dr < 0.5 00297 00298 } // input collection after Subtraction 00299 } 00300 00301 //=====================> 00302 00303 00304 } // protojets 00305 00306 // std::cout<<" We are at Point 2 with "<<firstoutput.size()<<std::endl; 00307 // 00308 // Create a new collections from the towers not included in jets 00309 // 00310 InputCollection orphanInput; 00311 for(InputCollection::const_iterator it = input.begin(); it != input.end(); it++ ) { 00312 InputCollection::const_iterator itjet = find(jettowers.begin(),jettowers.end(),*it); 00313 if( itjet == jettowers.end() ) orphanInput.push_back(*it); 00314 } 00315 // std::cout<<" We are at Point 3, Number of tower not included in jets= "<<orphanInput.size()<<std::endl; 00316 00317 /* 00318 //======================> PRINT NEW InputCollection without jets 00319 00320 for (InputCollection::const_iterator it = input.begin(); it != input.end(); it++ ) { 00321 00322 int ieta1 = ieta(&(**it)); 00323 int iphi1 = iphi(&(**it)); 00324 00325 std::cout<<" Take Et of tower WITHOUT jet, (**it).et()= "<<(**it).et() 00326 <<" eta= "<<(**it).eta()<<" phi= "<<(**it).phi() 00327 <<" ieta1= "<<ieta1<<" iphi1="<<iphi1<<std::endl; 00328 } 00329 //======================> 00330 */ 00331 00332 // 00333 // Recalculate pedestal 00334 // 00335 00336 // std::cout<<" We are at Point 4, Before Recalculation of pedestal"<<std::endl; 00337 00338 calculate_pedestal(orphanInput); 00339 00340 // std::cout<<" We are at Point 4, After Recalculation of pedestal"<<std::endl; 00341 // 00342 // Reestimate energy of jet (energy of jet with initial map) 00343 // 00344 protojetTMP = firstoutput.begin (); 00345 int kk = 0; 00346 for (; protojetTMP != firstoutput.end (); protojetTMP++) { 00347 00348 // std::cout<<" ++++++++++++++Jet with initial map energy "<<kk<<" "<<(*protojetTMP).et() 00349 // <<" mEtJetInputCut="<<mEtJetInputCut<<std::endl; 00350 00351 if( (*protojetTMP).et() < mEtJetInputCut) continue; 00352 00353 // std::cout<<" Jet with energyi passed condition "<<kk<<" "<<(*protojetTMP).et()<<std::endl; 00354 00355 const ProtoJet::Constituents towers = (*protojetTMP).getTowerList(); 00356 00357 // std::cout<<" List of candidates "<<towers.size()<<std::endl; 00358 00359 double offset = 0.; 00360 00361 for(ProtoJet::Constituents::const_iterator ito = towers.begin(); ito != towers.end(); ito++) 00362 { 00363 // std::cout<<" start towers list "<<std::endl; 00364 00365 int it = ieta(&(**ito)); 00366 00367 // offset = offset + (*emean.find(it)).second + (*esigma.find(it)).second; 00368 // Temporarily for test 00369 00370 double etnew = (**ito).et() - (*emean.find(it)).second - (*esigma.find(it)).second; 00371 00372 // std::cout<<" Reference to tower : "<<it<<" etold "<<(**ito).et()<<" etnew "<<etnew<<std::endl; 00373 00374 if( etnew <0.) etnew = 0.; 00375 00376 offset = offset + etnew; 00377 // std::cout<<" it = "<<it<<", etnew = "<<etnew<<", offset = "<<offset<<endl; 00378 00379 } 00380 // double mScale = ((*protojetTMP).et()-offset)/(*protojetTMP).et(); 00381 // Temporarily for test only 00382 00383 double mScale = offset/(*protojetTMP).et(); 00384 00385 // std::cout<<"offset = "<<offset<<" , protojetTMP.et() = "<<(*protojetTMP).et()<<" , mScale = "<<mScale<<endl; 00387 Jet::LorentzVector fP4((*protojetTMP).px()*mScale, (*protojetTMP).py()*mScale, 00388 (*protojetTMP).pz()*mScale, (*protojetTMP).energy()*mScale); 00389 00390 // std::cout<<" Final energy of jet, fP4.pt()= "<<fP4.pt()<<" Eta "<<fP4.eta()<<" Phi "<<fP4.phi()<<std::endl; 00394 ProtoJet pj(fP4, towers); 00395 kk++; 00396 output.push_back(pj); 00397 } 00398 00399 // std::cout<<" Size of final collection "<<output.size()<<std::endl; 00400 00401 reco::Jet::Point vertex (0,0,0); // do not have true vertex yet, use default 00402 // make sure protojets are sorted 00403 sortByPt (&output); 00404 // produce output collection Only CaloJets at the moment 00405 edm::ESHandle<CaloGeometry> geometry; 00406 fSetup.get<CaloGeometryRecord>().get(geometry); 00407 const CaloSubdetectorGeometry* towerGeometry = 00408 geometry->getSubdetectorGeometry(DetId::Calo, CaloTowerDetId::SubdetId); 00409 auto_ptr<CaloJetCollection> jets (new CaloJetCollection); 00410 for (unsigned iJet = 0; iJet < output.size (); ++iJet) { 00411 ProtoJet* protojet = &(output [iJet]); 00412 const JetReco::InputCollection& constituents = protojet->getTowerList(); 00413 CaloJet::Specific specific; 00414 JetMaker::makeSpecific (constituents, *towerGeometry, &specific); 00415 jets->push_back (CaloJet (protojet->p4(), vertex, specific)); 00416 Jet* newJet = &(jets->back()); 00417 // put constituents 00418 for (unsigned iConstituent = 0; iConstituent < constituents.size (); ++iConstituent) { 00419 newJet->addDaughter (inputHandle->ptrAt (constituents[iConstituent].index ())); 00420 } 00421 newJet->setJetArea (protojet->jetArea ()); 00422 newJet->setPileup (protojet->pileup ()); 00423 newJet->setNPasses (protojet->nPasses ()); 00424 } 00425 if (mVerbose) dumpJets (*jets); 00426 e.put(jets); 00427 // std::cout<<" Done with BasePilupSubtractionJetProducer"<<endl; 00428 }
virtual bool cms::BasePilupSubtractionJetProducer::runAlgorithm | ( | const JetReco::InputCollection & | fInput, | |
JetReco::OutputCollection * | fOutput | |||
) | [pure virtual] |
run algorithm itself
Implemented in cms::ExtKtPilupSubtractionJetProducer, cms::IterativeConePilupSubtractionJetProducer, cms::KtPilupSubtractionJetProducer, and cms::MidpointPilupSubtractionJetProducer.
JetReco::InputCollection BasePilupSubtractionJetProducer::subtract_pedestal | ( | const JetReco::InputCollection & | fInputs | ) |
Definition at line 528 of file BasePilupSubtractionJetProducer.cc.
References ct, Exception, it, makeCaloJetPU(), p4, edm::second(), and reco::Particle::setP4().
00529 { 00530 // 00531 // Subtract mean and sigma and prepare collection for jet finder 00532 // 00533 // CandidateCollection inputCache; 00534 00535 JetReco::InputCollection inputCache; 00536 00537 Candidate * mycand; 00538 00539 JetReco::InputCollection inputTMP; 00540 int it = -100; 00541 int ip = -100; 00542 int icand = 0; 00543 00544 // std::cout<<" BasePilupSubtractionJetProducer::subtract_pedestal::Number of candidates "<<fInputs.size()<<std::endl; 00545 00546 for (JetReco::InputCollection::const_iterator input_object = fInputs.begin (); input_object != fInputs.end (); input_object++) { 00547 00548 it = ieta(&(**input_object)); 00549 ip = iphi(&(**input_object)); 00550 00551 double etnew = (**input_object).et() - (*emean.find(it)).second - (*esigma.find(it)).second; 00552 float mScale = etnew/(**input_object).et(); 00553 00554 // Temporarily ////// 00555 if(etnew < 0.) mScale = 0.; 00556 00557 // std::cout<<" subtract_pedestal::Subtraction from tower with ieta "<<icand<<" "<<it<<" iphi "<<ip<< 00558 // " OLD energy "<< 00559 // (**input_object).et()<<" NEW energy "<<etnew<<" mScale "<<mScale<< 00560 // " Mean energy "<<(*emean.find(it)).second<<" Sigma " 00561 // <<(*esigma.find(it)).second<<std::endl; 00562 00563 00565 math::XYZTLorentzVectorD p4((**input_object).px()*mScale, (**input_object).py()*mScale, 00566 (**input_object).pz()*mScale, (**input_object).energy()*mScale); 00567 00568 // std::cout<<"subtract_pedestal::NEW energy from p4 "<<p4.pt()<<std::endl; 00569 // std::cout<<" subtract_pedestal::CaloJet "<<makeCaloJetPU (mJetType)<<" "<<mJetType<<std::endl; 00570 00571 if (makeCaloJetPU (mJetType)) { 00572 // mycand = new CaloTower( 0, Candidate::LorentzVector( p4 ) ); 00573 00574 const CaloTower* ct = dynamic_cast<const CaloTower*>(&(**input_object)); 00575 00576 // std::cout<<" subtract_pedestal::dynamic_cast<const CaloTower*> "<<ct<<std::endl; 00577 00578 if(ct) 00579 { 00580 // 00581 // std::cout<<" subtract_pedestal::before Candidate* mycand = new CaloTower (*ct); "<<std::endl; 00582 // Candidate* mycand = new CaloTower (*ct); 00583 mycand = new CaloTower (*ct); 00584 // std::cout<<" subtract_pedestal::after Candidate* mycand = new CaloTower (*ct); "<<std::endl; 00585 00586 mycand->setP4(p4); 00587 // old method: dynamic_cast<RecoCaloTowerCandidate*>(mycand)->setCaloTower(ct->caloTower()); 00588 // std::cout<<" subtract_pedestal::after mycand->setP4(p4); "<<std::endl; 00589 } 00590 else 00591 { 00592 throw cms::Exception("Invalid Constituent") << "CaloJet constituent is not of CaloTower type"; 00593 } 00594 } 00595 inputCache.push_back (JetReco::InputItem(mycand,icand)); 00596 icand++; 00597 } 00598 00599 // std::cout<<" OLD size "<<fInputs.size()<<" NEW size "<<inputCache.size()<<std::endl; 00600 00601 /* 00602 //===> Print NEW tower energy after background Subtraction 00603 for (CandidateCollection::const_iterator itt = inputCache.begin(); itt != inputCache.end(); itt++ ) { 00604 00605 double et_pu = (*itt).et(); 00606 double eta_pu = (*itt).eta(); 00607 double phi_pu = (*itt).phi(); 00608 00609 int ieta_pu = ieta(&(*itt)); 00610 int iphi_pu = iphi(&(*itt)); 00611 00612 std::cout<<"---inputCache, Subtraction from tower with eta= "<<ieta_pu 00613 <<" phi="<<iphi_pu<<" NEW et="<<et_pu<<std::endl; 00614 00615 } 00616 //===> 00617 */ 00618 return inputCache; 00619 }
std::vector<HcalDetId> cms::BasePilupSubtractionJetProducer::allgeomid [private] |
Definition at line 75 of file BasePilupSubtractionJetProducer.h.
std::map<int,double> cms::BasePilupSubtractionJetProducer::emean [private] |
Definition at line 72 of file BasePilupSubtractionJetProducer.h.
std::map<int,double> cms::BasePilupSubtractionJetProducer::esigma [private] |
Definition at line 71 of file BasePilupSubtractionJetProducer.h.
const CaloGeometry* cms::BasePilupSubtractionJetProducer::geo [private] |
Definition at line 76 of file BasePilupSubtractionJetProducer.h.
std::map<int,int> cms::BasePilupSubtractionJetProducer::geomtowers [private] |
Definition at line 73 of file BasePilupSubtractionJetProducer.h.
Definition at line 77 of file BasePilupSubtractionJetProducer.h.
Definition at line 78 of file BasePilupSubtractionJetProducer.h.
double cms::BasePilupSubtractionJetProducer::mEInputCut [private] |
Definition at line 67 of file BasePilupSubtractionJetProducer.h.
double cms::BasePilupSubtractionJetProducer::mEtInputCut [private] |
Definition at line 66 of file BasePilupSubtractionJetProducer.h.
double cms::BasePilupSubtractionJetProducer::mEtJetInputCut [private] |
Definition at line 68 of file BasePilupSubtractionJetProducer.h.
std::string cms::BasePilupSubtractionJetProducer::mJetType [private] |
Definition at line 64 of file BasePilupSubtractionJetProducer.h.
Referenced by BasePilupSubtractionJetProducer(), and jetType().
Definition at line 63 of file BasePilupSubtractionJetProducer.h.
Definition at line 65 of file BasePilupSubtractionJetProducer.h.
double cms::BasePilupSubtractionJetProducer::nSigmaPU [private] |
Definition at line 69 of file BasePilupSubtractionJetProducer.h.
std::map<int,int> cms::BasePilupSubtractionJetProducer::ntowers_with_jets [private] |
Definition at line 74 of file BasePilupSubtractionJetProducer.h.
double cms::BasePilupSubtractionJetProducer::radiusPU [private] |
Definition at line 70 of file BasePilupSubtractionJetProducer.h.