CMS 3D CMS Logo

L1ExtraParticlesProd.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    L1ExtraParticlesProd
00004 // Class:      L1ExtraParticlesProd
00005 // 
00008 //
00009 // Original Author:  Werner Sun
00010 //         Created:  Mon Oct  2 22:45:32 EDT 2006
00011 // $Id: L1ExtraParticlesProd.cc,v 1.21 2008/04/21 17:36:12 wsun Exp $
00012 //
00013 //
00014 
00015 
00016 // system include files
00017 #include <memory>
00018 
00019 // user include files
00020 #include "L1Trigger/L1ExtraFromDigis/interface/L1ExtraParticlesProd.h"
00021 
00022 #include "FWCore/Framework/interface/Frameworkfwd.h"
00023 //#include "FWCore/Framework/interface/MakerMacros.h"
00024 
00025 #include "DataFormats/Common/interface/Handle.h"
00026 #include "FWCore/Framework/interface/ESHandle.h"
00027 #include "DataFormats/Common/interface/OrphanHandle.h"
00028 
00029 #include "CondFormats/L1TObjects/interface/L1CaloGeometry.h"
00030 #include "CondFormats/DataRecord/interface/L1CaloGeometryRecord.h"
00031 
00032 #include "CondFormats/L1TObjects/interface/L1CaloEtScale.h"
00033 #include "CondFormats/DataRecord/interface/L1EmEtScaleRcd.h"
00034 #include "CondFormats/DataRecord/interface/L1JetEtScaleRcd.h"
00035 #include "CondFormats/L1TObjects/interface/L1GctJetEtCalibrationFunction.h"
00036 #include "CondFormats/DataRecord/interface/L1GctJetCalibFunRcd.h"
00037 
00038 #include "CondFormats/L1TObjects/interface/L1MuTriggerScales.h"
00039 #include "CondFormats/DataRecord/interface/L1MuTriggerScalesRcd.h"
00040 #include "CondFormats/L1TObjects/interface/L1MuTriggerPtScale.h"
00041 #include "CondFormats/DataRecord/interface/L1MuTriggerPtScaleRcd.h"
00042 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
00043 
00044 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00045 
00046 // #include "FWCore/Utilities/interface/EDMException.h"
00047 
00048 //
00049 // class decleration
00050 //
00051 
00052 
00053 //
00054 // constants, enums and typedefs
00055 //
00056 
00057 //
00058 // static data member definitions
00059 //
00060 
00061 double L1ExtraParticlesProd::muonMassGeV_ = 0.105658369 ; // PDG06
00062 
00063 //
00064 // constructors and destructor
00065 //
00066 L1ExtraParticlesProd::L1ExtraParticlesProd(const edm::ParameterSet& iConfig)
00067    : produceMuonParticles_( iConfig.getParameter< bool >(
00068       "produceMuonParticles" ) ),
00069      muonSource_( iConfig.getParameter< edm::InputTag >(
00070         "muonSource" ) ),
00071      produceCaloParticles_( iConfig.getParameter< bool >(
00072         "produceCaloParticles" ) ),
00073      isoEmSource_( iConfig.getParameter< edm::InputTag >(
00074         "isolatedEmSource" ) ),
00075      nonIsoEmSource_( iConfig.getParameter< edm::InputTag >(
00076         "nonIsolatedEmSource" ) ),
00077      cenJetSource_( iConfig.getParameter< edm::InputTag >(
00078         "centralJetSource" ) ),
00079      forJetSource_( iConfig.getParameter< edm::InputTag >(
00080         "forwardJetSource" ) ),
00081      tauJetSource_( iConfig.getParameter< edm::InputTag >(
00082         "tauJetSource" ) ),
00083      etTotSource_( iConfig.getParameter< edm::InputTag >(
00084         "etTotalSource" ) ),
00085      etHadSource_( iConfig.getParameter< edm::InputTag >(
00086         "etHadSource" ) ),
00087      etMissSource_( iConfig.getParameter< edm::InputTag >(
00088         "etMissSource" ) ),
00089      centralBxOnly_( iConfig.getParameter< bool >(
00090         "centralBxOnly" ) )
00091 {
00092    using namespace l1extra ;
00093 
00094    //register your products
00095    produces< L1EmParticleCollection >( "Isolated" ) ;
00096    produces< L1EmParticleCollection >( "NonIsolated" ) ;
00097    produces< L1JetParticleCollection >( "Central" ) ;
00098    produces< L1JetParticleCollection >( "Forward" ) ;
00099    produces< L1JetParticleCollection >( "Tau" ) ;
00100    produces< L1MuonParticleCollection >() ;
00101    //   produces< L1EtMissParticle >() ;
00102    produces< L1EtMissParticleCollection >() ;
00103 
00104    //now do what ever other initialization is needed
00105 }
00106 
00107 
00108 L1ExtraParticlesProd::~L1ExtraParticlesProd()
00109 {
00110  
00111    // do anything here that needs to be done at desctruction time
00112    // (e.g. close files, deallocate resources etc.)
00113 
00114 }
00115 
00116 
00117 //
00118 // member functions
00119 //
00120 
00121 // ------------ method called to produce the data  ------------
00122 void
00123 L1ExtraParticlesProd::produce( edm::Event& iEvent,
00124                                const edm::EventSetup& iSetup)
00125 {
00126    using namespace edm ;
00127    using namespace l1extra ;
00128    using namespace std ;
00129 
00130    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00131    // ~~~~~~~~~~~~~~~~~~~~ Muons ~~~~~~~~~~~~~~~~~~~~
00132    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00133 
00134    if( produceMuonParticles_ )
00135    {
00136       ESHandle< L1MuTriggerScales > muScales ;
00137       iSetup.get< L1MuTriggerScalesRcd >().get( muScales ) ;
00138 
00139       ESHandle< L1MuTriggerPtScale > muPtScale ;
00140       iSetup.get< L1MuTriggerPtScaleRcd >().get( muPtScale ) ;
00141 
00142       Handle< L1MuGMTReadoutCollection > hwMuCollection ;
00143       iEvent.getByLabel( muonSource_, hwMuCollection ) ;
00144 
00145       vector< L1MuGMTExtendedCand > hwMuCands ;
00146 
00147       if( centralBxOnly_ )
00148       {
00149          // Get GMT candidates from central bunch crossing only
00150          hwMuCands = hwMuCollection->getRecord().getGMTCands() ;
00151       }
00152       else
00153       {
00154          // Get GMT candidates from all bunch crossings
00155          vector< L1MuGMTReadoutRecord > records = hwMuCollection->getRecords();
00156          vector< L1MuGMTReadoutRecord >::const_iterator rItr = records.begin();
00157          vector< L1MuGMTReadoutRecord >::const_iterator rEnd = records.end();
00158 
00159          for( ; rItr != rEnd ; ++rItr )
00160          {
00161             vector< L1MuGMTExtendedCand > tmpCands = rItr->getGMTCands() ;
00162 
00163             hwMuCands.insert( hwMuCands.end(),
00164                               tmpCands.begin(),
00165                               tmpCands.end() ) ;
00166          }
00167       }
00168 
00169       auto_ptr< L1MuonParticleCollection > muColl(
00170          new L1MuonParticleCollection );
00171 
00172 //       cout << "HW muons" << endl ;
00173       vector< L1MuGMTExtendedCand >::const_iterator muItr = hwMuCands.begin() ;
00174       vector< L1MuGMTExtendedCand >::const_iterator muEnd = hwMuCands.end() ;
00175       for( int i = 0 ; muItr != muEnd ; ++muItr, ++i )
00176       {
00177 //       cout << "#" << i
00178 //            << " name " << muItr->name()
00179 //            << " empty " << muItr->empty()
00180 //            << " pt " << muItr->ptIndex()
00181 //            << " eta " << muItr->etaIndex()
00182 //            << " phi " << muItr->phiIndex()
00183 //            << " iso " << muItr->isol()
00184 //            << " mip " << muItr->mip()
00185 //            << " bx " << muItr->bx()
00186 //            << endl ;
00187 
00188          if( !muItr->empty() )
00189          {
00190             // keep x and y components non-zero and protect against roundoff.
00191             double pt =
00192               muPtScale->getPtScale()->getLowEdge( muItr->ptIndex() ) + 1.e-6 ;
00193             // muScales->getPtScale()->getLowEdge( muItr->ptIndex() ) + 1.e-6 ;
00194 
00195 //          cout << "L1Extra pt " << pt << endl ;
00196 
00197             double eta =
00198                muScales->getGMTEtaScale()->getCenter( muItr->etaIndex() ) ;
00199 
00200             double phi =
00201                muScales->getPhiScale()->getLowEdge( muItr->phiIndex() ) ;
00202 
00203             math::PtEtaPhiMLorentzVector p4( pt,
00204                                              eta,
00205                                              phi,
00206                                              muonMassGeV_ ) ;
00207 
00208             muColl->push_back(
00209                L1MuonParticle( muItr->charge(),
00210                                p4,
00211                                *muItr,
00212                                muItr->bx() )
00213                ) ;
00214          }
00215       }
00216 
00217       OrphanHandle< L1MuonParticleCollection > muHandle =
00218          iEvent.put( muColl );
00219    }
00220    
00221 
00222    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00223    // ~~~~~~~~~~~~~~~~~~~~ Calorimeter ~~~~~~~~~~~~~~~~~~~~
00224    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00225 
00226    if( produceCaloParticles_ )
00227    {
00228       // ~~~~~~~~~~~~~~~~~~~~ Geometry ~~~~~~~~~~~~~~~~~~~~
00229 
00230       ESHandle< L1CaloGeometry > caloGeomESH ;
00231       iSetup.get< L1CaloGeometryRecord >().get( caloGeomESH ) ;
00232       const L1CaloGeometry* caloGeom = &( *caloGeomESH ) ;
00233 
00234       // ~~~~~~~~~~~~~~~~~~~~ EM ~~~~~~~~~~~~~~~~~~~~
00235 
00236       ESHandle< L1CaloEtScale > emScale ;
00237       iSetup.get< L1EmEtScaleRcd >().get( emScale ) ;
00238 
00239       // Isolated EM
00240       Handle< L1GctEmCandCollection > hwIsoEmCands ;
00241       iEvent.getByLabel( isoEmSource_, hwIsoEmCands ) ;
00242 
00243       auto_ptr< L1EmParticleCollection > isoEmColl(
00244          new L1EmParticleCollection );
00245 
00246 //       cout << "HW iso EM" << endl ;
00247 
00248       L1GctEmCandCollection::const_iterator emItr = hwIsoEmCands->begin() ;
00249       L1GctEmCandCollection::const_iterator emEnd = hwIsoEmCands->end() ;
00250       for( int i = 0 ; emItr != emEnd ; ++emItr, ++i )
00251       {
00252 //       cout << "#" << i
00253 //            << " name " << emItr->name()
00254 //            << " empty " << emItr->empty()
00255 //            << " rank " << emItr->rank()
00256 //            << " eta " << emItr->etaIndex()
00257 //            << " sign " << emItr->etaSign()
00258 //            << " phi " << emItr->phiIndex()
00259 //            << " iso " << emItr->isolated()
00260 //            << " bx " << emItr->bx()
00261 //            << endl ;
00262 
00263          if( !emItr->empty() &&
00264              ( !centralBxOnly_ || emItr->bx() == 0 ) )
00265          {
00266             double et = emScale->et( emItr->rank() ) ;
00267 
00268 //          cout << "L1Extra et " << et << endl ;
00269 
00270             isoEmColl->push_back(
00271                L1EmParticle( gctLorentzVector( et, *emItr, caloGeom, true ),
00272                              Ref< L1GctEmCandCollection >( hwIsoEmCands,
00273                                                            i ),
00274                              emItr->bx() ) ) ;
00275          }
00276       }
00277 
00278       OrphanHandle< L1EmParticleCollection > isoEmHandle =
00279          iEvent.put( isoEmColl, "Isolated" ) ;
00280 
00281 
00282       // Non-isolated EM
00283       Handle< L1GctEmCandCollection > hwNonIsoEmCands ;
00284       iEvent.getByLabel( nonIsoEmSource_, hwNonIsoEmCands ) ;
00285 
00286       auto_ptr< L1EmParticleCollection > nonIsoEmColl(
00287          new L1EmParticleCollection );
00288 
00289 //       cout << "HW non-iso EM" << endl ;
00290       emItr = hwNonIsoEmCands->begin() ;
00291       emEnd = hwNonIsoEmCands->end() ;
00292       for( int i = 0 ; emItr != emEnd ; ++emItr, ++i )
00293       {
00294 //       cout << "#" << i
00295 //            << " name " << emItr->name()
00296 //            << " empty " << emItr->empty()
00297 //            << " rank " << emItr->rank()
00298 //            << " eta " << emItr->etaIndex()
00299 //            << " sign " << emItr->etaSign()
00300 //            << " phi " << emItr->phiIndex()
00301 //            << " iso " << emItr->isolated()
00302 //            << " bx " << emItr->bx()
00303 //            << endl ;
00304 
00305          if( !emItr->empty() &&
00306              ( !centralBxOnly_ || emItr->bx() == 0 ) )
00307          {
00308             double et = emScale->et( emItr->rank() ) ;
00309 
00310 //          cout << "L1Extra et " << et << endl ;
00311 
00312             nonIsoEmColl->push_back(
00313                L1EmParticle( gctLorentzVector( et, *emItr, caloGeom, true ),
00314                              Ref< L1GctEmCandCollection >( hwNonIsoEmCands,
00315                                                            i ),
00316                              emItr->bx() ) );
00317          }
00318       }
00319 
00320       OrphanHandle< L1EmParticleCollection > nonIsoEmHandle =
00321          iEvent.put( nonIsoEmColl, "NonIsolated" ) ;
00322 
00323 
00324       // ~~~~~~~~~~~~~~~~~~~~ Jets ~~~~~~~~~~~~~~~~~~~~
00325 
00326       ESHandle< L1CaloEtScale > jetScale ;
00327       iSetup.get< L1JetEtScaleRcd >().get( jetScale ) ;
00328 
00329       // Central jets.
00330       Handle< L1GctJetCandCollection > hwCenJetCands ;
00331       iEvent.getByLabel( cenJetSource_, hwCenJetCands ) ;
00332 
00333       auto_ptr< L1JetParticleCollection > cenJetColl(
00334          new L1JetParticleCollection );
00335 
00336 //       cout << "HW central jets" << endl ;
00337       L1GctJetCandCollection::const_iterator jetItr = hwCenJetCands->begin() ;
00338       L1GctJetCandCollection::const_iterator jetEnd = hwCenJetCands->end() ;
00339       for( int i = 0 ; jetItr != jetEnd ; ++jetItr, ++i )
00340       {
00341 //       cout << "#" << i
00342 //            << " name " << jetItr->name()
00343 //            << " empty " << jetItr->empty()
00344 //            << " rank " << jetItr->rank()
00345 //            << " eta " << jetItr->etaIndex()
00346 //            << " sign " << jetItr->etaSign()
00347 //            << " phi " << jetItr->phiIndex()
00348 //            << " cen " << jetItr->isCentral()
00349 //            << " for " << jetItr->isForward()
00350 //            << " tau " << jetItr->isTau()
00351 //            << " bx " << jetItr->bx()
00352 //            << endl ;
00353 
00354          if( !jetItr->empty() &&
00355              ( !centralBxOnly_ || jetItr->bx() == 0 ) )
00356          {
00357             double et = jetScale->et( jetItr->rank() ) ;
00358 
00359 //          cout << "L1Extra et " << et << endl ;
00360 
00361             cenJetColl->push_back(
00362                L1JetParticle( gctLorentzVector( et, *jetItr, caloGeom, true ),
00363                               Ref< L1GctJetCandCollection >( hwCenJetCands,
00364                                                              i ),
00365                               jetItr->bx() ) ) ;
00366          }
00367       }
00368 
00369       OrphanHandle< L1JetParticleCollection > cenJetHandle =
00370          iEvent.put( cenJetColl, "Central" ) ;
00371 
00372 
00373       // Forward jets.
00374       Handle< L1GctJetCandCollection > hwForJetCands ;
00375       iEvent.getByLabel( forJetSource_, hwForJetCands ) ;
00376 
00377       auto_ptr< L1JetParticleCollection > forJetColl(
00378          new L1JetParticleCollection );
00379 
00380 //       cout << "HW forward jets" << endl ;
00381       jetItr = hwForJetCands->begin() ;
00382       jetEnd = hwForJetCands->end() ;
00383       for( int i = 0 ; jetItr != jetEnd ; ++jetItr, ++i )
00384       {
00385 //       cout << "#" << i
00386 //            << " name " << jetItr->name()
00387 //            << " empty " << jetItr->empty()
00388 //            << " rank " << jetItr->rank()
00389 //            << " eta " << jetItr->etaIndex()
00390 //            << " sign " << jetItr->etaSign()
00391 //            << " phi " << jetItr->phiIndex()
00392 //            << " cen " << jetItr->isCentral()
00393 //            << " for " << jetItr->isForward()
00394 //            << " tau " << jetItr->isTau()
00395 //            << " bx " << jetItr->bx()
00396 //            << endl ;
00397 
00398          if( !jetItr->empty() &&
00399              ( !centralBxOnly_ || jetItr->bx() == 0 ) )
00400          {
00401             double et = jetScale->et( jetItr->rank() ) ;
00402 
00403 //          cout << "L1Extra et " << et << endl ;
00404 
00405             forJetColl->push_back(
00406                L1JetParticle( gctLorentzVector( et, *jetItr, caloGeom, false ),
00407                               Ref< L1GctJetCandCollection >( hwForJetCands,
00408                                                              i ),
00409                               jetItr->bx() ) ) ;
00410          }
00411       }
00412 
00413       OrphanHandle< L1JetParticleCollection > forJetHandle =
00414          iEvent.put( forJetColl, "Forward" ) ;
00415 
00416 
00417       // Tau jets.
00418 //       cout << "HW tau jets" << endl ;
00419       Handle< L1GctJetCandCollection > hwTauJetCands ;
00420       iEvent.getByLabel( tauJetSource_, hwTauJetCands ) ;
00421 
00422       auto_ptr< L1JetParticleCollection > tauJetColl(
00423          new L1JetParticleCollection );
00424 
00425       jetItr = hwTauJetCands->begin() ;
00426       jetEnd = hwTauJetCands->end() ;
00427       for( int i = 0 ; jetItr != jetEnd ; ++jetItr, ++i )
00428       {
00429 //       cout << "#" << i
00430 //            << " name " << jetItr->name()
00431 //            << " empty " << jetItr->empty()
00432 //            << " rank " << jetItr->rank()
00433 //            << " eta " << jetItr->etaIndex()
00434 //            << " sign " << jetItr->etaSign()
00435 //            << " phi " << jetItr->phiIndex()
00436 //            << " cen " << jetItr->isCentral()
00437 //            << " for " << jetItr->isForward()
00438 //            << " tau " << jetItr->isTau()
00439 //            << " bx " << jetItr->bx()
00440 //            << endl ;
00441 
00442          if( !jetItr->empty() &&
00443              ( !centralBxOnly_ || jetItr->bx() == 0 ) )
00444          {
00445             double et = jetScale->et( jetItr->rank() ) ;
00446 
00447 //          cout << "L1Extra et " << et << endl ;
00448 
00449             tauJetColl->push_back(
00450                L1JetParticle( gctLorentzVector( et, *jetItr, caloGeom, true ),
00451                               Ref< L1GctJetCandCollection >( hwTauJetCands,
00452                                                              i ),
00453                               jetItr->bx() ) ) ;
00454          }
00455       }
00456 
00457       OrphanHandle< L1JetParticleCollection > tauJetHandle =
00458          iEvent.put( tauJetColl, "Tau" ) ;
00459 
00460       // ~~~~~~~~~~~~~~~~~~~~ Energy Sums ~~~~~~~~~~~~~~~~~~~~
00461 
00462       ESHandle< L1GctJetEtCalibrationFunction > jetCalibFn ;
00463       iSetup.get< L1GctJetCalibFunRcd >().get( jetCalibFn ) ;
00464 
00465       double etSumLSB = jetScale->linearLsb() ;
00466       double htSumLSB = jetCalibFn->getHtScaleLSB();
00467 
00468       Handle< L1GctEtTotalCollection > hwEtTotColl ;
00469       iEvent.getByLabel( etTotSource_, hwEtTotColl ) ;
00470 
00471       Handle< L1GctEtHadCollection > hwEtHadColl ;
00472       iEvent.getByLabel( etHadSource_, hwEtHadColl ) ;
00473 
00474       Handle< L1GctEtMissCollection > hwEtMissColl ;
00475       iEvent.getByLabel( etMissSource_, hwEtMissColl ) ;
00476 
00477 //       try
00478 //       {
00479 //          iEvent.getByLabel( etTotSource_, hwEtTotColl ) ;
00480 //          iEvent.getByLabel( etHadSource_, hwEtHadColl ) ;
00481 //          iEvent.getByLabel( etMissSource_, hwEtMissColl ) ;
00482 //       }
00483 //       catch( const edm::Exception& ex )
00484 
00485       if( !( hwEtTotColl.isValid() && hwEtHadColl.isValid() &&
00486              hwEtMissColl.isValid() ) )
00487       {
00488 //       // Check for only one particular exception.
00489 //       if( ex.categoryCode() != edm::errors::ProductNotFound )
00490 //       {
00491 //          throw ex ;
00492 //       }
00493 
00494          // For backwards compatibility with 20X and earlier.
00495          // If energy sum collections are not present, get the objects
00496          // themselves.
00497 
00498          Handle< L1GctEtTotal > hwEtTot ;
00499          iEvent.getByLabel( etTotSource_, hwEtTot ) ;
00500 
00501          Handle< L1GctEtHad > hwEtHad ;
00502          iEvent.getByLabel( etHadSource_, hwEtHad ) ;
00503 
00504          Handle< L1GctEtMiss > hwEtMiss ;
00505          iEvent.getByLabel( etMissSource_, hwEtMiss ) ;
00506 
00507 //       cout << "AAAA HW ET Sums " << endl
00508 //            << "MET: phi " << hwEtMiss->phi()
00509 //            << " et " << hwEtMiss->et()
00510 //            << " EtTot " << hwEtTot->et()
00511 //            << " EtHad " << hwEtHad->et()
00512 //            << " bx 0"
00513 //            << endl ;
00514 
00515          // ET bin low edge
00516          double etTot = ( hwEtTot->overFlow() ?
00517                           ( double ) L1GctEtTotal::kEtTotalMaxValue :
00518                           ( double ) hwEtTot->et() ) * etSumLSB + 1.e-6 ;
00519          double etHad = ( hwEtHad->overFlow() ?
00520                           ( double ) L1GctEtHad::kEtHadMaxValue :
00521                           ( double ) hwEtHad->et() ) * htSumLSB + 1.e-6 ;
00522          double etMiss = ( hwEtMiss->overFlow() ?
00523                            ( double ) L1GctEtMiss::kEtMissMaxValue :
00524                            ( double ) hwEtMiss->et() ) * etSumLSB + 1.e-6 ;
00525          // keep x and y components non-zero and protect against roundoff.
00526 
00527          double phi = caloGeom->etSumPhiBinCenter( hwEtMiss->phi() ) ;
00528 
00529          math::PtEtaPhiMLorentzVector p4( etMiss,
00530                                           0.,
00531                                           phi,
00532                                           0. ) ;
00533 
00534          auto_ptr< L1EtMissParticleCollection > etMissColl(
00535             new L1EtMissParticleCollection );
00536 
00537          etMissColl->push_back(
00538             L1EtMissParticle( p4,
00539                               etTot,
00540                               etHad ) ) ;
00541 
00542          iEvent.put( etMissColl ) ;
00543          return ; // don't put any other processing after energy sums block!!!
00544       }
00545 
00546       auto_ptr< L1EtMissParticleCollection > etMissColl(
00547          new L1EtMissParticleCollection );
00548 
00549       // Collate energy sums by bx
00550       L1GctEtTotalCollection::const_iterator hwEtTotItr =
00551          hwEtTotColl->begin() ;
00552       L1GctEtTotalCollection::const_iterator hwEtTotEnd =
00553          hwEtTotColl->end() ;
00554 
00555       int iTot = 0 ;
00556       for( ; hwEtTotItr != hwEtTotEnd ; ++hwEtTotItr, ++iTot )
00557       {
00558          int bx = hwEtTotItr->bx() ;
00559 
00560          if( !centralBxOnly_ || bx == 0 )
00561          {
00562             L1GctEtHadCollection::const_iterator hwEtHadItr =
00563                hwEtHadColl->begin() ;
00564             L1GctEtHadCollection::const_iterator hwEtHadEnd =
00565                hwEtHadColl->end() ;
00566 
00567             int iHad = 0 ;
00568             for( ; hwEtHadItr != hwEtHadEnd ; ++hwEtHadItr, ++iHad )
00569             {
00570                if( hwEtHadItr->bx() == bx )
00571                {
00572                   break ;
00573                }
00574             }
00575 
00576             // If a L1GctEtHad with the right bx is not found, itr == end.
00577             if( hwEtHadItr != hwEtHadEnd )
00578             {
00579                L1GctEtMissCollection::const_iterator hwEtMissItr =
00580                   hwEtMissColl->begin() ;
00581                L1GctEtMissCollection::const_iterator hwEtMissEnd =
00582                   hwEtMissColl->end() ;
00583 
00584                int iMiss = 0 ;
00585                for( ; hwEtMissItr != hwEtMissEnd ; ++hwEtMissItr, ++iMiss )
00586                {
00587                   if( hwEtMissItr->bx() == bx )
00588                   {
00589                      break ;
00590                   }
00591                }
00592 
00593                // If a L1GctEtMiss with the right bx is not found, itr == end.
00594                if( hwEtMissItr != hwEtMissEnd )
00595                {
00596                   // Construct L1EtMissParticle only if all three energy
00597                   // sums are present.
00598 
00599 //                cout << "HW ET Sums " << endl
00600 //                     << "MET: phi " << hwEtMissItr->phi()
00601 //                     << " et " << hwEtMissItr->et()
00602 //                     << " EtTot " << hwEtTotItr->et()
00603 //                     << " EtHad " << hwEtHadItr->et()
00604 //                     << " bx " << bx
00605 //                     << endl ;
00606 
00607                   // ET bin low edge
00608                   double etTot =
00609                      ( hwEtTotItr->overFlow() ?
00610                        ( double ) L1GctEtTotal::kEtTotalMaxValue :
00611                        ( double ) hwEtTotItr->et() ) * etSumLSB + 1.e-6 ;
00612                   double etHad =
00613                      ( hwEtHadItr->overFlow() ?
00614                        ( double ) L1GctEtHad::kEtHadMaxValue :
00615                        ( double ) hwEtHadItr->et() ) * htSumLSB + 1.e-6 ;
00616                   double etMiss =
00617                      ( hwEtMissItr->overFlow() ?
00618                        ( double ) L1GctEtMiss::kEtMissMaxValue :
00619                        ( double ) hwEtMissItr->et() ) * etSumLSB + 1.e-6 ;
00620                   // keep x and y components non-zero and
00621                   // protect against roundoff.
00622 
00623                   double phi =
00624                      caloGeom->etSumPhiBinCenter( hwEtMissItr->phi() ) ;
00625 
00626                   math::PtEtaPhiMLorentzVector p4( etMiss,
00627                                                    0.,
00628                                                    phi,
00629                                                    0. ) ;
00630 
00631                   etMissColl->push_back(
00632                      L1EtMissParticle(
00633                         p4,
00634                         etTot,
00635                         etHad,
00636                         Ref< L1GctEtMissCollection >( hwEtMissColl, iMiss ),
00637                         Ref< L1GctEtTotalCollection >( hwEtTotColl, iTot ),
00638                         Ref< L1GctEtHadCollection >( hwEtHadColl, iHad ),
00639                         bx
00640                         ) ) ;
00641                }
00642             }
00643          }
00644       }
00645 
00646       OrphanHandle< L1EtMissParticleCollection > etMissCollHandle =
00647          iEvent.put( etMissColl ) ;
00648    }
00649 }
00650 
00651 //math::XYZTLorentzVector
00652 math::PtEtaPhiMLorentzVector
00653 L1ExtraParticlesProd::gctLorentzVector( const double& et,
00654                                         const L1GctCand& cand,
00655                                         const L1CaloGeometry* geom,
00656                                         bool central )
00657 {
00658    // To keep x and y components non-zero.
00659    double etCorr = et + 1.e-6 ; // protect against roundoff, not only for et=0
00660 
00661    double eta = geom->etaBinCenter( cand.etaIndex(), central ) ;
00662 
00663 //    double tanThOver2 = exp( -eta ) ;
00664 //    double ez = etCorr * ( 1. - tanThOver2 * tanThOver2 ) / ( 2. * tanThOver2 );
00665 //    double e  = etCorr * ( 1. + tanThOver2 * tanThOver2 ) / ( 2. * tanThOver2 );
00666 
00667    double phi = geom->emJetPhiBinCenter( cand.phiIndex() ) ;
00668 
00669 //    return math::XYZTLorentzVector( etCorr * cos( phi ),
00670 //                                 etCorr * sin( phi ),
00671 //                                 ez,
00672 //                                 e ) ;
00673    return math::PtEtaPhiMLorentzVector( etCorr,
00674                                         eta,
00675                                         phi,
00676                                         0. ) ;
00677 }     
00678 
00679 // ------------ method called once each job just before starting event loop  ------------
00680 void 
00681 L1ExtraParticlesProd::beginJob(const edm::EventSetup&)
00682 {
00683 }
00684 
00685 // ------------ method called once each job just after ending the event loop  ------------
00686 void 
00687 L1ExtraParticlesProd::endJob() {
00688 }
00689 
00690 //define this as a plug-in
00691 //DEFINE_FWK_MODULE(L1ExtraParticlesProd);

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