ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/CmsHi/JetAnalysis/src/MyVirtualJetProducer.cc
Revision: 1.4
Committed: Mon Jul 26 15:51:12 2010 UTC (14 years, 9 months ago) by yilmaz
Content type: text/plain
Branch: MAIN
Changes since 1.3: +50 -11 lines
Log Message:
update Fastjet

File Contents

# User Rev Content
1 yilmaz 1.1 ////////////////////////////////////////////////////////////////////////////////
2     //
3     // MyVirtualJetProducer
4     // ------------------
5     //
6     // 04/21/2009 Philipp Schieferdecker <philipp.schieferdecker@cern.ch>
7     ////////////////////////////////////////////////////////////////////////////////
8    
9     #include "MyVirtualJetProducer.h"
10     #include "RecoJets/JetProducers/interface/JetSpecific.h"
11    
12     #include "FWCore/Framework/interface/Event.h"
13     #include "FWCore/Framework/interface/EventSetup.h"
14     #include "FWCore/Framework/interface/ESHandle.h"
15     #include "FWCore/Utilities/interface/CodedException.h"
16     #include "FWCore/MessageLogger/interface/MessageLogger.h"
17     #include "FWCore/Framework/interface/MakerMacros.h"
18    
19     #include "DataFormats/Common/interface/View.h"
20     #include "DataFormats/Common/interface/Handle.h"
21     #include "DataFormats/VertexReco/interface/Vertex.h"
22     #include "DataFormats/VertexReco/interface/VertexFwd.h"
23     #include "DataFormats/JetReco/interface/CaloJetCollection.h"
24     #include "DataFormats/JetReco/interface/GenJetCollection.h"
25     #include "DataFormats/JetReco/interface/PFJetCollection.h"
26     #include "DataFormats/JetReco/interface/BasicJetCollection.h"
27     #include "DataFormats/JetReco/interface/TrackJetCollection.h"
28     #include "DataFormats/Candidate/interface/CandidateFwd.h"
29     #include "DataFormats/Candidate/interface/LeafCandidate.h"
30 yilmaz 1.2 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
31     #include "Geometry/Records/interface/CaloGeometryRecord.h"
32    
33     #include "DataFormats/Math/interface/Vector3D.h"
34 yilmaz 1.1
35     #include "fastjet/SISConePlugin.hh"
36     #include "fastjet/CMSIterativeConePlugin.hh"
37     #include "fastjet/ATLASConePlugin.hh"
38     #include "fastjet/CDFMidPointPlugin.hh"
39    
40     #include <iostream>
41     #include <memory>
42     #include <algorithm>
43     #include <limits>
44     #include <cmath>
45    
46     using namespace std;
47    
48    
49     namespace reco {
50     namespace helper {
51     struct GreaterByPtPseudoJet {
52     bool operator()( const fastjet::PseudoJet & t1, const fastjet::PseudoJet & t2 ) const {
53     return t1.perp() > t2.perp();
54     }
55     };
56    
57     }
58     }
59    
60     //______________________________________________________________________________
61     const char *MyVirtualJetProducer::JetType::names[] = {
62     "BasicJet","GenJet","CaloJet","PFJet","TrackJet"
63     };
64    
65    
66     //______________________________________________________________________________
67     MyVirtualJetProducer::JetType::Type
68     MyVirtualJetProducer::JetType::byName(const string &name)
69     {
70     const char **pos = std::find(names, names + LastJetType, name);
71     if (pos == names + LastJetType) {
72     std::string errorMessage="Requested jetType not supported: "+name+"\n";
73     throw cms::Exception("Configuration",errorMessage);
74     }
75     return (Type)(pos-names);
76     }
77    
78    
79     void MyVirtualJetProducer::makeProduces( std::string alias, std::string tag )
80     {
81     if (makeCaloJet(jetTypeE)) {
82     produces<reco::CaloJetCollection>(tag).setBranchAlias(alias);
83     }
84     else if (makePFJet(jetTypeE)) {
85     produces<reco::PFJetCollection>(tag).setBranchAlias(alias);
86     }
87     else if (makeGenJet(jetTypeE)) {
88     produces<reco::GenJetCollection>(tag).setBranchAlias(alias);
89     }
90     else if (makeTrackJet(jetTypeE)) {
91     produces<reco::TrackJetCollection>(tag).setBranchAlias(alias);
92     }
93     else if (makeBasicJet(jetTypeE)) {
94     produces<reco::BasicJetCollection>(tag).setBranchAlias(alias);
95     }
96     }
97    
98     ////////////////////////////////////////////////////////////////////////////////
99     // construction / destruction
100     ////////////////////////////////////////////////////////////////////////////////
101    
102     //______________________________________________________________________________
103     MyVirtualJetProducer::MyVirtualJetProducer(const edm::ParameterSet& iConfig)
104     : moduleLabel_ (iConfig.getParameter<string> ("@module_label"))
105     , src_ (iConfig.getParameter<edm::InputTag>("src"))
106     , srcPVs_ (iConfig.getParameter<edm::InputTag>("srcPVs"))
107     , jetType_ (iConfig.getParameter<string> ("jetType"))
108     , jetAlgorithm_ (iConfig.getParameter<string> ("jetAlgorithm"))
109     , rParam_ (iConfig.getParameter<double> ("rParam"))
110     , inputEtMin_ (iConfig.getParameter<double> ("inputEtMin"))
111     , inputEMin_ (iConfig.getParameter<double> ("inputEMin"))
112     , jetPtMin_ (iConfig.getParameter<double> ("jetPtMin"))
113     , doPVCorrection_(iConfig.getParameter<bool> ("doPVCorrection"))
114     , restrictInputs_(false)
115     , maxInputs_(99999999)
116     , doAreaFastjet_ (iConfig.getParameter<bool> ("doAreaFastjet"))
117     , doRhoFastjet_ (iConfig.getParameter<bool> ("doRhoFastjet"))
118     , doPUOffsetCorr_(iConfig.getParameter<bool> ("doPUOffsetCorr"))
119     , maxBadEcalCells_ (iConfig.getParameter<unsigned>("maxBadEcalCells"))
120     , maxRecoveredEcalCells_ (iConfig.getParameter<unsigned>("maxRecoveredEcalCells"))
121     , maxProblematicEcalCells_(iConfig.getParameter<unsigned>("maxProblematicEcalCells"))
122     , maxBadHcalCells_ (iConfig.getParameter<unsigned>("maxBadHcalCells"))
123     , maxRecoveredHcalCells_ (iConfig.getParameter<unsigned>("maxRecoveredHcalCells"))
124     , maxProblematicHcalCells_(iConfig.getParameter<unsigned>("maxProblematicHcalCells"))
125     , jetCollInstanceName_ ("")
126     {
127    
128 yilmaz 1.2 // ntuple = new TNtuple("nt","debug","ieta:eta:iphi:phi");
129    
130 yilmaz 1.1 //
131     // additional parameters to think about:
132     // - overlap threshold (set to 0.75 for the time being)
133     // - p parameter for generalized kT (set to -2 for the time being)
134     // - fastjet PU subtraction parameters (not yet considered)
135     //
136     if (jetAlgorithm_=="SISCone") {
137     fjPlugin_ = PluginPtr( new fastjet::SISConePlugin(rParam_,0.75,0,0.0,false,
138     fastjet::SISConePlugin::SM_pttilde) );
139     fjJetDefinition_= JetDefPtr( new fastjet::JetDefinition(&*fjPlugin_) );
140     }
141     else if (jetAlgorithm_=="IterativeCone") {
142     fjPlugin_ = PluginPtr(new fastjet::CMSIterativeConePlugin(rParam_,1.0));
143     fjJetDefinition_= JetDefPtr(new fastjet::JetDefinition(&*fjPlugin_));
144     }
145     else if (jetAlgorithm_=="CDFMidPoint") {
146     fjPlugin_ = PluginPtr(new fastjet::CDFMidPointPlugin(rParam_,0.75));
147     fjJetDefinition_= JetDefPtr(new fastjet::JetDefinition(&*fjPlugin_));
148     }
149     else if (jetAlgorithm_=="ATLASCone") {
150     fjPlugin_ = PluginPtr(new fastjet::ATLASConePlugin(rParam_));
151     fjJetDefinition_= JetDefPtr(new fastjet::JetDefinition(&*fjPlugin_));
152     }
153     else if (jetAlgorithm_=="Kt")
154     fjJetDefinition_= JetDefPtr(new fastjet::JetDefinition(fastjet::kt_algorithm,rParam_));
155     else if (jetAlgorithm_=="CambridgeAachen")
156     fjJetDefinition_= JetDefPtr(new fastjet::JetDefinition(fastjet::cambridge_algorithm,
157     rParam_) );
158     else if (jetAlgorithm_=="AntiKt")
159     fjJetDefinition_= JetDefPtr( new fastjet::JetDefinition(fastjet::antikt_algorithm,rParam_) );
160     else if (jetAlgorithm_=="GeneralizedKt")
161     fjJetDefinition_= JetDefPtr( new fastjet::JetDefinition(fastjet::genkt_algorithm,
162     rParam_,-2) );
163     else
164     throw cms::Exception("Invalid jetAlgorithm")
165     <<"Jet algorithm for MyVirtualJetProducer is invalid, Abort!\n";
166    
167     jetTypeE=JetType::byName(jetType_);
168    
169     if ( iConfig.exists("jetCollInstanceName") ) {
170     jetCollInstanceName_ = iConfig.getParameter<string>("jetCollInstanceName");
171     }
172    
173     if ( doPUOffsetCorr_ ) {
174 yilmaz 1.3 if ( jetTypeE != JetType::CaloJet ) {
175     throw cms::Exception("InvalidInput") << "Can only offset correct jets of type CaloJet";
176     }
177 yilmaz 1.4
178 yilmaz 1.3 puSubtractorName_ = iConfig.getParameter<string> ("subtractorName");
179     if(puSubtractorName_.empty()){
180     edm::LogWarning("VirtualJetProducer") << "Pile Up correction on; however, pile up type is not specified. Using default... \n";
181     subtractor_ = boost::shared_ptr<PileUpSubtractor>(new PileUpSubtractor(iConfig));
182     }else{
183     subtractor_ = boost::shared_ptr<PileUpSubtractor>(PileUpSubtractorFactory::get()->create( puSubtractorName_, iConfig));
184     }
185 yilmaz 1.1 }
186    
187     // do fasjet area / rho calcluation? => accept corresponding parameters
188     if ( doAreaFastjet_ || doRhoFastjet_ ) {
189     // default Ghost_EtaMax should be 5
190     double ghostEtaMax = iConfig.getParameter<double>("Ghost_EtaMax");
191     // default Active_Area_Repeats 1
192     int activeAreaRepeats = iConfig.getParameter<int> ("Active_Area_Repeats");
193     // default GhostArea 0.01
194     double ghostArea = iConfig.getParameter<double> ("GhostArea");
195     fjActiveArea_ = ActiveAreaSpecPtr(new fastjet::ActiveAreaSpec(ghostEtaMax,
196     activeAreaRepeats,
197     ghostArea));
198     fjRangeDef_ = RangeDefPtr( new fastjet::RangeDefinition(ghostEtaMax) );
199 yilmaz 1.4
200     }
201    
202     if ( doRhoFastjet_ ) {
203     doFastJetNonUniform_ = iConfig.getParameter<bool> ("doFastJetNonUniform");
204     if(doFastJetNonUniform_){
205     puCenters_ = iConfig.getParameter<std::vector<double> >("puCenters");
206     puWidth_ = iConfig.getParameter<double>("puWidth");
207     produces<std::vector<double> >("rhos");
208     produces<std::vector<double> >("sigmas");
209     }else{
210     produces<double>("rho");
211     produces<double>("sigma");
212     }
213    
214     }
215 yilmaz 1.1
216     // restrict inputs to first "maxInputs" towers?
217     if ( iConfig.exists("restrictInputs") ) {
218     restrictInputs_ = iConfig.getParameter<bool>("restrictInputs");
219     maxInputs_ = iConfig.getParameter<unsigned int>("maxInputs");
220     }
221    
222    
223     string alias=iConfig.getUntrackedParameter<string>("alias",moduleLabel_);
224    
225     // make the "produces" statements
226     makeProduces( alias, jetCollInstanceName_ );
227    
228     if(doRhoFastjet_){
229     produces<double>("rho");
230     produces<double>("sigma");
231     }
232     }
233    
234    
235     //______________________________________________________________________________
236     MyVirtualJetProducer::~MyVirtualJetProducer()
237     {
238     }
239    
240    
241     ////////////////////////////////////////////////////////////////////////////////
242     // implementation of member functions
243     ////////////////////////////////////////////////////////////////////////////////
244    
245     //______________________________________________________________________________
246     void MyVirtualJetProducer::produce(edm::Event& iEvent,const edm::EventSetup& iSetup)
247     {
248 yilmaz 1.2
249     if(!geo){
250     edm::ESHandle<CaloGeometry> pGeo;
251     iSetup.get<CaloGeometryRecord>().get(pGeo);
252     geo = pGeo.product();
253     }
254    
255 yilmaz 1.1 LogDebug("MyVirtualJetProducer") << "Entered produce\n";
256     //determine signal vertex
257     vertex_=reco::Jet::Point(0,0,0);
258     if (makeCaloJet(jetTypeE)&&doPVCorrection_) {
259     LogDebug("MyVirtualJetProducer") << "Adding PV info\n";
260     edm::Handle<reco::VertexCollection> pvCollection;
261     iEvent.getByLabel(srcPVs_,pvCollection);
262     if (pvCollection->size()>0) vertex_=pvCollection->begin()->position();
263     }
264    
265     // For Pileup subtraction using offset correction:
266     // set up geometry map
267     if ( doPUOffsetCorr_ ) {
268     subtractor_->setupGeometryMap(iEvent, iSetup);
269     }
270    
271     // clear data
272     LogDebug("MyVirtualJetProducer") << "Clear data\n";
273     fjInputs_.clear();
274     fjJets_.clear();
275     inputs_.clear();
276    
277     // get inputs and convert them to the fastjet format (fastjet::PeudoJet)
278     edm::Handle<reco::CandidateView> inputsHandle;
279     iEvent.getByLabel(src_,inputsHandle);
280     for (size_t i = 0; i < inputsHandle->size(); ++i) {
281     inputs_.push_back(inputsHandle->ptrAt(i));
282     }
283     LogDebug("MyVirtualJetProducer") << "Got inputs\n";
284    
285     // Convert candidates to fastjet::PseudoJets.
286     // Also correct to Primary Vertex. Will modify fjInputs_
287     // and use inputs_
288     fjInputs_.reserve(inputs_.size());
289     inputTowers();
290     LogDebug("MyVirtualJetProducer") << "Inputted towers\n";
291    
292     // For Pileup subtraction using offset correction:
293     // Subtract pedestal.
294     if ( doPUOffsetCorr_ ) {
295 yilmaz 1.4 subtractor_->reset(inputs_,fjInputs_,fjJets_);
296 yilmaz 1.1 subtractor_->calculatePedestal(fjInputs_);
297     subtractor_->subtractPedestal(fjInputs_);
298     LogDebug("MyVirtualJetProducer") << "Subtracted pedestal\n";
299     }
300    
301     // Run algorithm. Will modify fjJets_ and allocate fjClusterSeq_.
302     // This will use fjInputs_
303     runAlgorithm( iEvent, iSetup );
304     if ( doPUOffsetCorr_ ) {
305     subtractor_->setAlgorithm(fjClusterSeq_);
306     }
307    
308     LogDebug("MyVirtualJetProducer") << "Ran algorithm\n";
309    
310     // For Pileup subtraction using offset correction:
311     // Now we find jets and need to recalculate their energy,
312     // mark towers participated in jet,
313     // remove occupied towers from the list and recalculate mean and sigma
314     // put the initial towers collection to the jet,
315     // and subtract from initial towers in jet recalculated mean and sigma of towers
316     if ( doPUOffsetCorr_ ) {
317     vector<fastjet::PseudoJet> orphanInput;
318     subtractor_->calculateOrphanInput(orphanInput);
319     subtractor_->calculatePedestal(orphanInput);
320     subtractor_->offsetCorrectJets();
321     }
322    
323     // Write the output jets.
324     // This will (by default) call the member function template
325     // "writeJets", but can be overridden.
326     // this will use inputs_
327     output( iEvent, iSetup );
328     LogDebug("MyVirtualJetProducer") << "Wrote jets\n";
329    
330     return;
331     }
332    
333     //______________________________________________________________________________
334    
335     void MyVirtualJetProducer::inputTowers( )
336     {
337     std::vector<edm::Ptr<reco::Candidate> >::const_iterator inBegin = inputs_.begin(),
338     inEnd = inputs_.end(), i = inBegin;
339     for (; i != inEnd; ++i ) {
340     reco::CandidatePtr input = *i;
341     if (isnan(input->pt())) continue;
342     if (input->et() <inputEtMin_) continue;
343     if (input->energy()<inputEMin_) continue;
344     if (isAnomalousTower(input)) continue;
345 yilmaz 1.2
346     //Check consistency of kinematics
347    
348     const CaloTower* ctc = dynamic_cast<const CaloTower*>(input.get());
349     if(ctc){
350     int ieta = ctc->id().ieta();
351     int iphi = ctc->id().iphi();
352    
353     ntuple->Fill(ieta, input->eta(), iphi, input->phi(),input->et(),ctc->emEt(),ctc->hadEt());
354    
355     if(abs(ieta) < 5){
356    
357     if(0){
358     math::RhoEtaPhiVector v(1.4,input->eta(),input->phi());
359     GlobalPoint point(v.x(),v.y(),v.z());
360     // const DetId d = geo->getClosestCell(point);
361     // HcalDetId hd(d);
362     HcalDetId hd(0);
363     if(hd.ieta() != ieta || hd.iphi() != iphi){
364     cout<<"Inconsistent kinematics!!! ET = "<<input->pt()<<endl;
365     cout<<"ieta candidate : "<<ieta<<" ieta detid : "<<hd.ieta()<<endl;
366     cout<<"iphi candidate : "<<iphi<<" iphi detid : "<<hd.iphi()<<endl;
367     }
368    
369     }
370    
371     if(0){
372     HcalDetId det(HcalBarrel,ieta,iphi,1);
373    
374     if(geo->present(det)){
375     double eta = geo->getPosition(det).eta();
376     double phi = geo->getPosition(det).phi();
377    
378     if(input->eta() != eta || input->phi() != phi){
379     cout<<"Inconsistent kinematics!!! ET = "<<input->pt()<<endl;
380     cout<<"eta candidate : "<<input->eta()<<" eta detid : "<<eta<<endl;
381     cout<<"phi candidate : "<<input->phi()<<" phi detid : "<<phi<<endl;
382     }
383     }else{
384     cout<<"DetId not present in the Calo Geometry : ieta = "<<ieta<<" iphi = "<<iphi<<endl;
385     }
386     }
387     }
388    
389     }
390    
391 yilmaz 1.1 if (makeCaloJet(jetTypeE)&&doPVCorrection_) {
392     const CaloTower* tower=dynamic_cast<const CaloTower*>(input.get());
393     math::PtEtaPhiMLorentzVector ct(tower->p4(vertex_));
394     fjInputs_.push_back(fastjet::PseudoJet(ct.px(),ct.py(),ct.pz(),ct.energy()));
395     }
396     else {
397     fjInputs_.push_back(fastjet::PseudoJet(input->px(),input->py(),input->pz(),
398     input->energy()));
399     }
400     fjInputs_.back().set_user_index(i - inBegin);
401     }
402    
403     if ( restrictInputs_ && fjInputs_.size() > maxInputs_ ) {
404     reco::helper::GreaterByPtPseudoJet pTComparator;
405     std::sort(fjInputs_.begin(), fjInputs_.end(), pTComparator);
406     fjInputs_.resize(maxInputs_);
407     edm::LogWarning("JetRecoTooManyEntries") << "Too many inputs in the event, limiting to first " << maxInputs_ << ". Output is suspect.";
408     }
409     }
410    
411     //______________________________________________________________________________
412     bool MyVirtualJetProducer::isAnomalousTower(reco::CandidatePtr input)
413     {
414     if (!makeCaloJet(jetTypeE)) return false;
415     const CaloTower* tower=dynamic_cast<const CaloTower*>(input.get());
416     if (0==tower) return false;
417     if (tower->numBadEcalCells() >maxBadEcalCells_ ||
418     tower->numRecoveredEcalCells() >maxRecoveredEcalCells_ ||
419     tower->numProblematicEcalCells()>maxProblematicEcalCells_||
420     tower->numBadHcalCells() >maxBadHcalCells_ ||
421     tower->numRecoveredHcalCells() >maxRecoveredHcalCells_ ||
422     tower->numProblematicHcalCells()>maxProblematicHcalCells_) return true;
423     return false;
424     }
425    
426    
427     //------------------------------------------------------------------------------
428     // This is pure virtual.
429     //______________________________________________________________________________
430     // void MyVirtualJetProducer::runAlgorithm( edm::Event & iEvent, edm::EventSetup const& iSetup,
431     // std::vector<edm::Ptr<reco::Candidate> > const & inputs_);
432    
433     //______________________________________________________________________________
434     void MyVirtualJetProducer::copyConstituents(const vector<fastjet::PseudoJet>& fjConstituents,
435     reco::Jet* jet)
436     {
437     for (unsigned int i=0;i<fjConstituents.size();++i)
438     jet->addDaughter(inputs_[fjConstituents[i].user_index()]);
439     }
440    
441    
442     //______________________________________________________________________________
443     vector<reco::CandidatePtr>
444     MyVirtualJetProducer::getConstituents(const vector<fastjet::PseudoJet>&fjConstituents)
445     {
446     vector<reco::CandidatePtr> result;
447     for (unsigned int i=0;i<fjConstituents.size();i++) {
448     int index = fjConstituents[i].user_index();
449     reco::CandidatePtr candidate = inputs_[index];
450     result.push_back(candidate);
451     }
452     return result;
453     }
454    
455     void MyVirtualJetProducer::output(edm::Event & iEvent, edm::EventSetup const& iSetup)
456     {
457     // Write jets and constitutents. Will use fjJets_, inputs_
458     // and fjClusterSeq_
459     switch( jetTypeE ) {
460     case JetType::CaloJet :
461     writeJets<reco::CaloJet>( iEvent, iSetup);
462     break;
463     case JetType::PFJet :
464     writeJets<reco::PFJet>( iEvent, iSetup);
465     break;
466     case JetType::GenJet :
467     writeJets<reco::GenJet>( iEvent, iSetup);
468     break;
469     case JetType::TrackJet :
470     writeJets<reco::TrackJet>( iEvent, iSetup);
471     break;
472     case JetType::BasicJet :
473     writeJets<reco::BasicJet>( iEvent, iSetup);
474     break;
475     default:
476     throw cms::Exception("InvalidInput") << "invalid jet type in MyVirtualJetProducer\n";
477     break;
478     };
479    
480     }
481    
482     template< typename T >
483     void MyVirtualJetProducer::writeJets( edm::Event & iEvent, edm::EventSetup const& iSetup )
484     {
485     // produce output jet collection
486    
487     using namespace reco;
488    
489     std::auto_ptr<std::vector<T> > jets(new std::vector<T>() );
490     jets->reserve(fjJets_.size());
491    
492     for (unsigned int ijet=0;ijet<fjJets_.size();++ijet) {
493     // allocate this jet
494     T jet;
495     // get the fastjet jet
496     const fastjet::PseudoJet& fjJet = fjJets_[ijet];
497     // get the constituents from fastjet
498     std::vector<fastjet::PseudoJet> fjConstituents =
499     sorted_by_pt(fjClusterSeq_->constituents(fjJet));
500     // convert them to CandidatePtr vector
501     std::vector<CandidatePtr> constituents =
502     getConstituents(fjConstituents);
503    
504     // calcuate the jet area
505     double jetArea=0.0;
506     if ( doAreaFastjet_ ) {
507     fastjet::ClusterSequenceArea const * clusterSequenceWithArea =
508     dynamic_cast<fastjet::ClusterSequenceArea const *>(&*fjClusterSeq_);
509     jetArea = clusterSequenceWithArea->area(fjJet);
510     }
511    
512     // write the specifics to the jet (simultaneously sets 4-vector, vertex).
513     // These are overridden functions that will call the appropriate
514     // specific allocator.
515     writeSpecific(jet,
516     Particle::LorentzVector(fjJet.px(),
517     fjJet.py(),
518     fjJet.pz(),
519     fjJet.E()),
520     vertex_,
521     constituents, iSetup);
522    
523     jet.setJetArea (jetArea);
524    
525     if(doPUOffsetCorr_){
526     jet.setPileup(subtractor_->getPileUpEnergy(ijet));
527     }else{
528     jet.setPileup (0.0);
529     }
530    
531     // add to the list
532     jets->push_back(jet);
533     }
534    
535     // put the jets in the collection
536     iEvent.put(jets);
537    
538     // calculate rho (median pT per unit area, for PU&UE subtraction down the line
539     if (doRhoFastjet_) {
540 yilmaz 1.4 if(doFastJetNonUniform_){
541     std::auto_ptr<std::vector<double> > rhos(new std::vector<double>);
542     std::auto_ptr<std::vector<double> > sigmas(new std::vector<double>);
543     int nEta = puCenters_.size();
544     rhos->reserve(nEta);
545     sigmas->reserve(nEta);
546     fastjet::ClusterSequenceArea const * clusterSequenceWithArea =
547     dynamic_cast<fastjet::ClusterSequenceArea const *> ( &*fjClusterSeq_ );
548     for(int ie = 0; ie < nEta; ++ie){
549     double eta = puCenters_[ie];
550     double rho = 0;
551     double sigma = 0;
552     double etamin=eta-puWidth_;
553     double etamax=eta+puWidth_;
554     fastjet::RangeDefinition range_rho(etamin,etamax);
555     clusterSequenceWithArea->get_median_rho_and_sigma(range_rho, true, rho, sigma);
556     rhos->push_back(rho);
557     sigmas->push_back(sigma);
558     }
559     iEvent.put(rhos,"rhos");
560     iEvent.put(sigmas,"sigmas");
561     }else{
562     std::auto_ptr<double> rho(new double(0.0));
563     std::auto_ptr<double> sigma(new double(0.0));
564     double mean_area = 0;
565     fastjet::ClusterSequenceArea const * clusterSequenceWithArea =
566     dynamic_cast<fastjet::ClusterSequenceArea const *> ( &*fjClusterSeq_ );
567     clusterSequenceWithArea->get_median_rho_and_sigma(*fjRangeDef_,false,*rho,*sigma,mean_area);
568     iEvent.put(rho,"rho");
569     iEvent.put(sigma,"sigma");
570     }
571 yilmaz 1.1 }
572     }
573    
574 yilmaz 1.4