CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/SLHCUpgradeSimulations/L1CaloTrigger/plugins/L1TowerJetPUSubtractedProducer.cc

Go to the documentation of this file.
00001 //This producer creates a PU subtracted collection of upgrade jets in both slhc::L1TowerJet format
00002 //and l1extra::L1JetParticle format
00003 //
00004 //It takes rho produced by L1TowerJetPUSubtraction producer and applies PU subtraction to input collection which
00005 //is filtered, uncalibrated jet collection
00006 //
00007 //Calibration should be done after this step is completed
00008 
00009 // system include files
00010 #include <memory>
00011 #include "FWCore/Framework/interface/Frameworkfwd.h"
00012 #include "FWCore/Framework/interface/EDProducer.h"
00013 #include "FWCore/Framework/interface/Event.h"
00014 #include "FWCore/Framework/interface/MakerMacros.h"
00015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00016 #include "FWCore/ServiceRegistry/interface/Service.h"
00017 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00018 
00019 #include "TLorentzVector.h"
00020 #include "DataFormats/VertexReco/interface/Vertex.h"
00021 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00022 #include "DataFormats/L1Trigger/interface/L1JetParticle.h"
00023 #include "DataFormats/L1Trigger/interface/L1JetParticleFwd.h"
00024 #include "DataFormats/L1Trigger/interface/L1EtMissParticle.h"
00025 #include "DataFormats/L1Trigger/interface/L1EtMissParticleFwd.h"
00026 #include "SimDataFormats/SLHC/interface/L1TowerJet.h"
00027 #include "SimDataFormats/SLHC/interface/L1TowerJetFwd.h"
00028 #include "FWCore/Framework/interface/LuminosityBlock.h"
00029 #include <iostream>
00030 #include <fstream>
00031 
00032 //
00033 // class declaration
00034 //
00035 
00036 
00037 using namespace l1slhc;
00038 using namespace edm;
00039 using namespace std;
00040 using namespace reco;
00041 using namespace l1extra;
00042 
00043 
00044 class L1TowerJetPUSubtractedProducer : public edm::EDProducer {
00045    public:
00046       explicit L1TowerJetPUSubtractedProducer(const edm::ParameterSet&);
00047       ~L1TowerJetPUSubtractedProducer();
00048 
00049       static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
00050 
00051    private:
00052       virtual void beginJob() ;
00053       virtual void produce(edm::Event&, const edm::EventSetup&);
00054       virtual void endJob() ;
00055       
00056       virtual void beginRun(edm::Run&, edm::EventSetup const&);
00057       virtual void endRun(edm::Run&, edm::EventSetup const&);
00058       virtual void beginLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&);
00059       virtual void endLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&);
00060     
00061     
00062       // ----------member data ---------------------------
00063  
00064         ParameterSet conf_;
00065 };
00066 
00067 L1TowerJetPUSubtractedProducer::L1TowerJetPUSubtractedProducer(const edm::ParameterSet& iConfig):
00068 conf_(iConfig)
00069 {
00070     produces<L1TowerJetCollection>("PUSubCenJets");
00071     produces< L1JetParticleCollection >( "PUSubCen8x8" ) ;
00072 }
00073 
00074 
00075 L1TowerJetPUSubtractedProducer::~L1TowerJetPUSubtractedProducer()
00076 {
00077 }
00078 
00079 
00080 
00081 
00082 // ------------ method called to produce the data  ------------
00083 void
00084 L1TowerJetPUSubtractedProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00085 {
00086     
00087     bool evValid =true;
00088     auto_ptr< L1TowerJetCollection > outputCollCen(new L1TowerJetCollection());
00089     produces<L1TowerJetCollection>("CalibFwdJets");
00090     auto_ptr< L1JetParticleCollection > outputExtraCen(new L1JetParticleCollection());
00091 
00092 
00093     edm::Handle< double > calRho;
00094     iEvent.getByLabel(conf_.getParameter<edm::InputTag>("CalibratedL1Rho"), calRho);
00095     if(!calRho.isValid()){
00096       evValid=false;
00097       edm::LogWarning("MissingProduct") << conf_.getParameter<edm::InputTag>("CalibratedL1Rho") << std::endl; 
00098     }
00099 
00100     edm::Handle<L1TowerJetCollection > UnCalibCen;
00101     iEvent.getByLabel(conf_.getParameter<edm::InputTag>("FilteredCircle8"), UnCalibCen);
00102     if(!UnCalibCen.isValid()){
00103       edm::LogWarning("MissingProduct") << conf_.getParameter<edm::InputTag>("FilteredCircle8") << std::endl; 
00104       evValid=false;
00105     }
00106 
00107     if( evValid ) {
00108 
00109       //get rho from the producer L1TowerJetPUSubtraction
00110       //This value is calibrated to offline calo rho
00111       double cal_rhoL1 = *calRho;
00112 
00114       //              JET VALUES 
00116       
00117       math::PtEtaPhiMLorentzVector upgrade_jet;
00118     
00119       //Produce calibrated pt collection: central jets
00120       for (L1TowerJetCollection::const_iterator il1 = UnCalibCen->begin();
00121            il1!= UnCalibCen->end() ;
00122            ++il1 ){
00123 
00124           L1TowerJet h=(*il1);
00125 
00126     //      float l1Eta_ = il1->p4().eta();
00127     //      float l1Phi_ = il1->p4().phi();
00128           float l1Pt_  = il1->p4().Pt();
00129 
00130           //weighted eta is still not correct
00131           //change the contents out p4, upgrade_jet when it is corrected
00132           float l1wEta_ = il1->WeightedEta();
00133           float l1wPhi_ = il1->WeightedPhi() ;
00134 
00135 
00136           //This is just for 8x8 circular jets: change if using different jets
00137           double areaPerJet = 52 * (0.087 * 0.087) ;
00138           //PU subtraction
00139           float l1Pt_PUsub_ = l1Pt_ - (cal_rhoL1 * areaPerJet);
00140           
00141           //only keep jet if pt > 0 after PU sub 
00142           if(l1Pt_PUsub_>0.1){
00143 
00144             math::PtEtaPhiMLorentzVector p4;
00145 
00146             //use weighted eta and phi: these are energy weighted 
00147             p4.SetCoordinates(l1Pt_PUsub_ , l1wEta_ , l1wPhi_ , il1->p4().M() );
00148 
00149             h.setP4(p4);
00150             outputCollCen->insert( l1wEta_ , l1wPhi_ , h );
00151             upgrade_jet.SetCoordinates( l1Pt_PUsub_ , l1wEta_ , l1wPhi_ , il1->p4().M() );
00152 
00153             // add jet to L1Extra list
00154             outputExtraCen->push_back( L1JetParticle( math::PtEtaPhiMLorentzVector( 
00155                                                         l1Pt_PUsub_,
00156                                                                                             l1wEta_,
00157                                                                                             l1wPhi_,
00158                                                                                             0. ),
00159                                                                 Ref< L1GctJetCandCollection >(), 0 )
00160                                                        );
00161           }
00162         }
00163       }
00164 
00165     //this is the slhc collection containing extra information
00166     iEvent.put(outputCollCen,"PUSubCenJets");
00167     //this is the l1extra collection containing the same jet vector as in slhc collection
00168     iEvent.put(outputExtraCen,"PUSubCen8x8");
00169 
00170 }
00171 
00172 
00173 // ------------ method called once each job just before starting event loop  ------------
00174 void 
00175 L1TowerJetPUSubtractedProducer::beginJob()
00176 {
00177 
00178 }
00179 
00180 // ------------ method called once each job just after ending the event loop  ------------
00181 void 
00182 L1TowerJetPUSubtractedProducer::endJob() {
00183 }
00184 
00185 // ------------ method called when starting to processes a run  ------------
00186 void 
00187 L1TowerJetPUSubtractedProducer::beginRun(edm::Run&, edm::EventSetup const&)
00188 {    
00189 
00190 }
00191 
00192 // ------------ method called when ending the processing of a run  ------------
00193 void 
00194 L1TowerJetPUSubtractedProducer::endRun(edm::Run&, edm::EventSetup const&)
00195 {
00196 }
00197 
00198 // ------------ method called when starting to processes a luminosity block  ------------
00199 void 
00200 L1TowerJetPUSubtractedProducer::beginLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&)
00201 {
00202 }
00203 
00204 // ------------ method called when ending the processing of a luminosity block  ------------
00205 void 
00206 L1TowerJetPUSubtractedProducer::endLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&)
00207 {
00208 }
00209 
00210 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
00211 void
00212 L1TowerJetPUSubtractedProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
00213   //The following says we do not know what parameters are allowed so do no validation
00214   // Please change this to state exactly what you do use, even if it is no parameters
00215   edm::ParameterSetDescription desc;
00216   desc.setUnknown();
00217   descriptions.addDefault(desc);
00218 }
00219 
00220 //
00221 // member functions
00222 //
00223 
00224 //define this as a plug-in
00225 DEFINE_FWK_MODULE(L1TowerJetPUSubtractedProducer);