CMS 3D CMS Logo

L1ExtraTestAnalyzer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    L1ExtraTestAnalyzer
00004 // Class:      L1ExtraTestAnalyzer
00005 // 
00010 //
00011 // Original Author:  Werner Sun
00012 //         Created:  Fri Jul 28 14:22:31 EDT 2006
00013 // $Id: L1ExtraTestAnalyzer.cc,v 1.5 2007/12/18 03:32:44 wsun Exp $
00014 //
00015 //
00016 
00017 
00018 // system include files
00019 #include <memory>
00020 #include <string>
00021 
00022 // user include files
00023 #include "FWCore/Framework/interface/Frameworkfwd.h"
00024 #include "FWCore/Framework/interface/EDAnalyzer.h"
00025 
00026 #include "FWCore/Framework/interface/Event.h"
00027 #include "FWCore/Framework/interface/MakerMacros.h"
00028 
00029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00030 #include "FWCore/ParameterSet/interface/InputTag.h"
00031 
00032 #include "DataFormats/Common/interface/Handle.h"
00033 #include "DataFormats/L1Trigger/interface/L1EmParticle.h"
00034 #include "DataFormats/L1Trigger/interface/L1JetParticle.h"
00035 #include "DataFormats/L1Trigger/interface/L1MuonParticle.h"
00036 #include "DataFormats/L1Trigger/interface/L1EtMissParticle.h"
00037 #include "DataFormats/L1Trigger/interface/L1ParticleMap.h"
00038 #include "DataFormats/L1Trigger/interface/L1ParticleMapFwd.h"
00039 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00040 
00041 #include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h"
00042 
00043 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00044 
00045 #include "TH1.h"
00046 #include "TFile.h"
00047 
00048 using namespace std ;
00049 
00050 //
00051 // class decleration
00052 //
00053 
00054 class L1ExtraTestAnalyzer : public edm::EDAnalyzer {
00055    public:
00056       explicit L1ExtraTestAnalyzer(const edm::ParameterSet&);
00057       ~L1ExtraTestAnalyzer();
00058 
00059 
00060       virtual void analyze(const edm::Event&, const edm::EventSetup&);
00061    private:
00062       // ----------member data ---------------------------
00063 
00064       edm::InputTag isoEmSource_ ;
00065       edm::InputTag nonIsoEmSource_ ;
00066       edm::InputTag cenJetSource_ ;
00067       edm::InputTag forJetSource_ ;
00068       edm::InputTag tauJetSource_ ;
00069       edm::InputTag muonSource_ ;
00070       edm::InputTag etMissSource_ ;
00071       edm::InputTag gtReadoutSource_ ;
00072       edm::InputTag particleMapSource_ ;
00073 
00074       TFile file_ ;
00075       TH1F hist_ ;
00076 };
00077 
00078 //
00079 // constants, enums and typedefs
00080 //
00081 
00082 //
00083 // static data member definitions
00084 //
00085 
00086 //
00087 // constructors and destructor
00088 //
00089 L1ExtraTestAnalyzer::L1ExtraTestAnalyzer(const edm::ParameterSet& iConfig)
00090    : isoEmSource_( iConfig.getParameter< edm::InputTag >(
00091       "isolatedEmSource" ) ),
00092      nonIsoEmSource_( iConfig.getParameter< edm::InputTag >(
00093       "nonIsolatedEmSource" ) ),
00094      cenJetSource_( iConfig.getParameter< edm::InputTag >(
00095       "centralJetSource" ) ),
00096      forJetSource_( iConfig.getParameter< edm::InputTag >(
00097       "forwardJetSource" ) ),
00098      tauJetSource_( iConfig.getParameter< edm::InputTag >(
00099       "tauJetSource" ) ),
00100      muonSource_( iConfig.getParameter< edm::InputTag >(
00101       "muonSource" ) ),
00102      etMissSource_( iConfig.getParameter< edm::InputTag >(
00103       "etMissSource" ) ),
00104      gtReadoutSource_( iConfig.getParameter< edm::InputTag >(
00105       "gtReadoutSource" ) ),
00106      particleMapSource_( iConfig.getParameter< edm::InputTag >(
00107       "particleMapSource" ) ),
00108      file_( "l1extra.root", "RECREATE" ),
00109      hist_( "triggers", "Triggers",
00110             2*l1extra::L1ParticleMap::kNumOfL1TriggerTypes + 1,
00111             -0.75,
00112             l1extra::L1ParticleMap::kNumOfL1TriggerTypes + 0.5 - 0.75 )
00113 {
00114    //now do what ever initialization is needed
00115 
00116 }
00117 
00118 
00119 L1ExtraTestAnalyzer::~L1ExtraTestAnalyzer()
00120 {
00121    // do anything here that needs to be done at desctruction time
00122    // (e.g. close files, deallocate resources etc.)
00123 
00124    file_.cd() ;
00125    hist_.Write() ;
00126 }
00127 
00128 
00129 //
00130 // member functions
00131 //
00132 
00133 // ------------ method called to produce the data  ------------
00134 void
00135 L1ExtraTestAnalyzer::analyze(const edm::Event& iEvent,
00136                              const edm::EventSetup& iSetup)
00137 {
00138    using namespace edm ;
00139    using namespace l1extra ;
00140 
00141    static int iev = 0 ;
00142    cout << "EVENT " << ++iev << endl ;
00143 
00144 //    // Generated particles
00145 //    edm::Handle< edm::HepMCProduct > hepmc ;
00146 //    iEvent.getByLabel( "VtxSmeared", hepmc ) ;
00147 
00148 //    const HepMC::GenEvent* evt = hepmc->GetEvent() ;
00149 //    for( HepMC::GenEvent::particle_const_iterator pitr =
00150 //            evt->particles_begin() ;
00151 //         pitr != evt->particles_end() ;
00152 //         ++pitr )
00153 //    {
00154 //      if( ( *pitr )->status() == 1 )
00155 //        {
00156 //       HepMC::FourVector p = ( *pitr )->momentum() ;
00157 //       //math::XYZTLorentzVector p4( p.x(), p.y(), p.z(), p.t() ) ;      
00158 
00159 //       cout << "PDG " << ( *pitr )->pdg_id() << " p4 = " << p << endl
00160 //            << "    et = " << p.e() * p.perp() / p.mag()
00161 //            << " eta = " << p.eta() << " phi = " << p.phi() << endl ;
00162 //        }
00163 //    }
00164 
00165    cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl ;
00166 
00167    // Isolated EM particles
00168    Handle< L1EmParticleCollection > isoEmColl ;
00169    iEvent.getByLabel( isoEmSource_, isoEmColl ) ;
00170    cout << "Number of isolated EM " << isoEmColl->size() << endl ;
00171 
00172    for( L1EmParticleCollection::const_iterator emItr = isoEmColl->begin() ;
00173         emItr != isoEmColl->end() ;
00174         ++emItr )
00175    {
00176       cout << "  p4 (" << emItr->px()
00177            << ", " << emItr->py()
00178            << ", " << emItr->pz()
00179            << ", " << emItr->energy()
00180            << ") et " << emItr->et()
00181            << " eta " << emItr->eta()
00182            << " phi " << emItr->phi()
00183            << endl ;
00184    }
00185 
00186    // Non-isolated EM particles
00187    Handle< L1EmParticleCollection > nonIsoEmColl ;
00188    iEvent.getByLabel( nonIsoEmSource_, nonIsoEmColl ) ;
00189    cout << "Number of non-isolated EM " << nonIsoEmColl->size() << endl ;
00190 
00191    for( L1EmParticleCollection::const_iterator emItr = nonIsoEmColl->begin() ;
00192         emItr != nonIsoEmColl->end() ;
00193         ++emItr )
00194    {
00195       cout << "  p4 (" << emItr->px()
00196            << ", " << emItr->py()
00197            << ", " << emItr->pz()
00198            << ", " << emItr->energy()
00199            << ") et " << emItr->et()
00200            << " eta " << emItr->eta()
00201            << " phi " << emItr->phi()
00202            << endl ;
00203    }
00204 
00205    // Jet particles
00206    Handle< L1JetParticleCollection > cenJetColl ;
00207    iEvent.getByLabel( cenJetSource_, cenJetColl ) ;
00208    cout << "Number of central jets " << cenJetColl->size() << endl ;
00209 
00210    for( L1JetParticleCollection::const_iterator jetItr = cenJetColl->begin() ;
00211         jetItr != cenJetColl->end() ;
00212         ++jetItr )
00213    {
00214       cout << "  p4 (" << jetItr->px()
00215            << ", " << jetItr->py()
00216            << ", " << jetItr->pz()
00217            << ", " << jetItr->energy()
00218            << ") et " << jetItr->et()
00219            << " eta " << jetItr->eta()
00220            << " phi " << jetItr->phi()
00221            << endl ;
00222    }
00223 
00224    Handle< L1JetParticleCollection > forJetColl ;
00225    iEvent.getByLabel( forJetSource_, forJetColl ) ;
00226    cout << "Number of forward jets " << forJetColl->size() << endl ;
00227 
00228    for( L1JetParticleCollection::const_iterator jetItr = forJetColl->begin() ;
00229         jetItr != forJetColl->end() ;
00230         ++jetItr )
00231    {
00232       cout << "  p4 (" << jetItr->px()
00233            << ", " << jetItr->py()
00234            << ", " << jetItr->pz()
00235            << ", " << jetItr->energy()
00236            << ") et " << jetItr->et()
00237            << " eta " << jetItr->eta()
00238            << " phi " << jetItr->phi()
00239            << endl ;
00240    }
00241 
00242    Handle< L1JetParticleCollection > tauColl ;
00243    iEvent.getByLabel( tauJetSource_, tauColl ) ;
00244    cout << "Number of tau jets " << tauColl->size() << endl ;
00245 
00246    for( L1JetParticleCollection::const_iterator tauItr = tauColl->begin() ;
00247         tauItr != tauColl->end() ;
00248         ++tauItr )
00249    {
00250       cout << "  p4 (" << tauItr->px()
00251            << ", " << tauItr->py()
00252            << ", " << tauItr->pz()
00253            << ", " << tauItr->energy()
00254            << ") et " << tauItr->et()
00255            << " eta " << tauItr->eta()
00256            << " phi " << tauItr->phi()
00257            << endl ;
00258    }
00259 
00260    // Muon particles
00261    Handle< L1MuonParticleCollection > muColl ;
00262    iEvent.getByLabel( muonSource_, muColl ) ;
00263    cout << "Number of muons " << muColl->size() << endl ;
00264 
00265    for( L1MuonParticleCollection::const_iterator muItr = muColl->begin() ;
00266         muItr != muColl->end() ;
00267         ++muItr )
00268    {
00269       cout << "  q " << muItr->charge()
00270            << " p4 (" << muItr->px()
00271            << ", " << muItr->py()
00272            << ", " << muItr->pz()
00273            << ", " << muItr->energy()
00274            << ") et " << muItr->et()
00275            << " eta " << muItr->eta() << endl
00276            << "    phi " << muItr->phi()
00277            << " iso " << muItr->isIsolated()
00278            << " mip " << muItr->isMip()
00279            << " fwd " << muItr->isForward()
00280            << " rpc " << muItr->isRPC()
00281            << endl ;
00282    }
00283 
00284    // MET particle
00285 //    Handle< L1EtMissParticle > etMiss ;
00286 //    iEvent.getByLabel( etMissSource_, etMiss ) ;
00287 //    cout << "MET (" << etMiss->px()
00288 //      << ", " << etMiss->py()
00289 //      << ", " << etMiss->pz()
00290 //      << ", " << etMiss->energy()
00291 //         << ") phi " << etMiss->phi()
00292 //         << " EtTot " << etMiss->etTotal()
00293 //      << " EtHad " << etMiss->etHad()
00294 //      << endl ;
00295 
00296    Handle< L1EtMissParticleCollection > etMissColl ;
00297    iEvent.getByLabel( etMissSource_, etMissColl ) ;
00298    cout << "MET Coll (" << etMissColl->begin()->px()
00299         << ", " << etMissColl->begin()->py()
00300         << ", " << etMissColl->begin()->pz()
00301         << ", " << etMissColl->begin()->energy()
00302         << ") phi " << etMissColl->begin()->phi()
00303         << " EtTot " << etMissColl->begin()->etTotal()
00304         << " EtHad " << etMissColl->begin()->etHad()
00305         << endl ;
00306 
00307 
00308 //    // L1GlobalTriggerReadoutRecord
00309 //    Handle< L1GlobalTriggerReadoutRecord > gtRecord ;
00310 //    iEvent.getByLabel( gtReadoutSource_, gtRecord ) ;
00311 //    cout << "Global trigger decision " << gtRecord->decision() << endl ;
00312 
00313 
00314 //    // L1ParticleMaps
00315 //    Handle< L1ParticleMapCollection > mapColl ;
00316 //    iEvent.getByLabel( particleMapSource_, mapColl ) ;
00317 //    cout << "Number of particle maps " << mapColl->size() << endl ;
00318 
00319 //    for( int imap = 0 ; imap < L1ParticleMap::kNumOfL1TriggerTypes ; ++imap )
00320 //    {
00321 //       const L1ParticleMap& map = ( *mapColl )[ imap ] ;
00322 
00323 //       cout << "Trig #" << map.triggerType()
00324 //         << " name " << map.triggerName()
00325 //         << " decision " << map.triggerDecision()
00326 //         << " #objs " << map.numOfObjects() ;
00327 //       cout << " types" ;
00328 //       for( int i = 0 ; i < map.numOfObjects() ; ++i )
00329 //       {
00330 //       cout << " " << map.objectTypes()[ i ] ;
00331 //       }
00332 //       cout << endl ;
00333 
00334 //       hist_.Fill( imap, ( map.triggerDecision() ? 1. : 0. ) ) ;
00335 
00336 //       if( map.triggerDecision() )
00337 //       {
00338 //       const L1EmParticleVectorRef& ems = map.emParticles() ;
00339 //       cout << "  EM particles ET" ;
00340 //       for( L1EmParticleVectorRef::const_iterator emItr = ems.begin() ;
00341 //            emItr != ems.end() ; ++emItr )
00342 //       {
00343 //          cout << " " << ( *emItr )->et() ;
00344 //       }
00345 //       cout << endl ;
00346 
00347 //       const L1JetParticleVectorRef& jets = map.jetParticles() ;
00348 //       cout << "  Jet particles ET" ;
00349 //       for( L1JetParticleVectorRef::const_iterator jetItr = jets.begin() ;
00350 //            jetItr != jets.end() ; ++jetItr )
00351 //       {
00352 //          cout << " " << ( *jetItr )->et() ;
00353 //       }
00354 //       cout << endl ;
00355 
00356 //       const L1MuonParticleVectorRef& muons = map.muonParticles() ;
00357 //       cout << "  Muon particles ET" ;
00358 //       for( L1MuonParticleVectorRef::const_iterator muonItr = muons.begin() ;
00359 //            muonItr != muons.end() ; ++muonItr )
00360 //       {
00361 //          cout << " " << ( *muonItr )->et() ;
00362 //       }
00363 //       cout << endl ;
00364 
00365 //       cout << "  Particle combinations" ;
00366 //       const L1ParticleMap::L1IndexComboVector& combos = map.indexCombos() ;
00367 //       for( L1ParticleMap::L1IndexComboVector::const_iterator comboItr =
00368 //               combos.begin() ; comboItr != combos.end() ; ++comboItr )
00369 //       {
00370 //          cout << " {" ;
00371 //          for( L1ParticleMap::L1IndexCombo::const_iterator indexItr =
00372 //                  comboItr->begin() ;
00373 //               indexItr != comboItr->end() ; ++indexItr )
00374 //          {
00375 //             cout << *indexItr ;
00376 //          }
00377 //          cout << "}" ;
00378 //       }
00379 
00380 //       cout << endl ;
00381 //       }
00382 //    }
00383 
00384    cout << endl ;
00385 }
00386 
00387 //define this as a plug-in
00388 DEFINE_FWK_MODULE(L1ExtraTestAnalyzer);

Generated on Tue Jun 9 17:40:30 2009 for CMSSW by  doxygen 1.5.4