CMS 3D CMS Logo

CompositeKit.cc

Go to the documentation of this file.
00001 #include "PhysicsTools/StarterKit/interface/CompositeKit.h"
00002 
00003 #include "PhysicsTools/CandUtils/interface/AddFourMomenta.h"
00004 #include "DataFormats/Math/interface/LorentzVector.h"
00005 
00006 using namespace std;
00007 using namespace reco;
00008 //
00009 // constructors and destructor
00010 //
00011 CompositeKit::CompositeKit(const edm::ParameterSet& iConfig)
00012   :
00013   src_              ( iConfig.getParameter<edm::InputTag> ("src") ),
00014   description_      ( iConfig.getParameter<std::string>   ("description") ),
00015   helper_           ( iConfig )
00016 {
00017 
00018   verboseLevel_ = 0;
00019 
00020 
00021   // First book standard histograms
00022   helper_.bookHistos(this);
00023 
00024   PhysicsHistograms::KinAxisLimits compositeAxisLimits;
00025 
00026   compositeAxisLimits = helper_.getAxisLimits("compositeAxis");
00027 
00028   double pt1 = compositeAxisLimits.pt1;
00029   double pt2 = compositeAxisLimits.pt2;
00030   double m1  = compositeAxisLimits.m1;
00031   double m2  = compositeAxisLimits.m2;
00032 
00033   // Now book composite histograms
00034   compositeCandHist_ = new pat::HistoComposite(src_.label(), 
00035                                                description_,
00036                                                src_.label(),
00037                                                pt1,pt2,m1,m2 );
00038 
00039 
00040 }
00041 
00042 
00043 CompositeKit::~CompositeKit()
00044 {
00045   // clean up
00046   if ( compositeCandHist_ ) delete compositeCandHist_;
00047 }
00048 
00049 
00050 //
00051 // member functions
00052 //
00053 
00054 // ------------ method called to for each event  ------------
00055 void CompositeKit::produce( edm::Event& iEvent, const edm::EventSetup& iSetup)
00056 {
00057   using namespace edm;
00058   using namespace std;
00059 
00060   // --------------------------------------------------
00061   //    Step 1: Retrieve objects from data stream
00062   // --------------------------------------------------
00063   helper_.getHandles( iEvent,
00064                       muonHandle_,
00065                       electronHandle_,
00066                       tauHandle_,
00067                       jetHandle_,
00068                       METHandle_,
00069                       photonHandle_);
00070 
00071   // --------------------------------------------------
00072   //    Step 2: invoke PhysicsHistograms to deal with all this.
00073   //
00074   //    Note that each handle will dereference into a vector<>,
00075   //    however the fillCollection() method takes a reference,
00076   //    so the collections are not copied...
00077   // --------------------------------------------------
00078 
00079   if ( verboseLevel_ > 10 )
00080     std::cout << "PatAnalyzerKit::analyze: calling fillCollection()." << std::endl;
00081   helper_.fillHistograms( iEvent,
00082                           muonHandle_,
00083                           electronHandle_,
00084                           tauHandle_,
00085                           jetHandle_,
00086                           METHandle_,
00087                           photonHandle_);
00088 
00089 
00090   // BEGIN YOUR CODE HERE
00091 
00092   // --------------------------------------------------
00093   //    Step 3: Plot some composite objects
00094   // --------------------------------------------------
00095 
00096   // Get the composite candidates from upstream
00097   iEvent.getByLabel(src_,   compositeCandHandle_ );
00098 
00099   if ( compositeCandHandle_->size() > 0 ) {
00100 
00101     // Get the vector of masses... when expression histograms come along, this 
00102     // will disappear
00103     vector<double> compositeCandMassVector;
00104 
00105     // Loop over the composite candidates
00106     vector<reco::CompositeCandidate>::const_iterator i = compositeCandHandle_->begin(),
00107       iend = compositeCandHandle_->end();
00108     for ( ; i != iend; ++i ) {
00109       compositeCandHist_->fill( *i );
00110     }
00111     
00112     // Save the ntuple variables... in this case just the mass
00113 //     saveNtuple( compositeNtVars_, iEvent );
00114 
00115   }
00116 }
00117 
00118 
00119 // ------------ method called once each job just before starting event loop  ------------
00120 void
00121 CompositeKit::beginJob(const edm::EventSetup& iSetup)
00122 {
00123 }
00124 
00125 
00126 
00127 // ------------ method called once each job just after ending the event loop  ------------
00128 void
00129 CompositeKit::endJob() {
00130 }
00131 
00132 //define this as a plug-in
00133 DEFINE_FWK_MODULE(CompositeKit);

Generated on Tue Jun 9 17:41:52 2009 for CMSSW by  doxygen 1.5.4