CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/DataFormats/L1Trigger/src/L1ParticleMap.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     L1Trigger
00004 // Class  :     L1ParticleMap
00005 // 
00008 //
00009 // Original Author:  Werner Sun
00010 //         Created:  Wed Jul 26 14:42:56 EDT 2006
00011 // $Id: L1ParticleMap.cc,v 1.27 2007/09/27 22:31:21 ratnik Exp $
00012 //
00013 
00014 // system include files
00015 
00016 // user include files
00017 #include "DataFormats/L1Trigger/interface/L1ParticleMap.h"
00018 #include "DataFormats/L1Trigger/interface/L1EmParticle.h"  
00019 #include "DataFormats/L1Trigger/interface/L1JetParticle.h"  
00020 #include "DataFormats/L1Trigger/interface/L1MuonParticle.h"  
00021 
00022 using namespace l1extra ;
00023 
00024 //
00025 // constants, enums and typedefs
00026 //
00027 
00028 //
00029 // static data member definitions
00030 //
00031 
00032 // EG = isolated OR non-isolated
00033 // Jet = central OR forward OR tau
00034 std::string
00035 L1ParticleMap::triggerNames_[ kNumOfL1TriggerTypes ] = {
00036    "L1_SingleMu3",
00037    "L1_SingleMu5",
00038    "L1_SingleMu7",
00039    "L1_SingleMu10",
00040    "L1_SingleMu14",
00041    "L1_SingleMu20",
00042    "L1_SingleMu25",
00043    "L1_SingleIsoEG5",
00044    "L1_SingleIsoEG8",
00045    "L1_SingleIsoEG10",
00046    "L1_SingleIsoEG12",
00047    "L1_SingleIsoEG15",
00048    "L1_SingleIsoEG20",
00049    "L1_SingleIsoEG25",
00050    "L1_SingleEG5",
00051    "L1_SingleEG8",
00052    "L1_SingleEG10",
00053    "L1_SingleEG12",
00054    "L1_SingleEG15",
00055    "L1_SingleEG20",
00056    "L1_SingleEG25",
00057    "L1_SingleJet15",
00058    "L1_SingleJet20",
00059    "L1_SingleJet30",
00060    "L1_SingleJet50",
00061    "L1_SingleJet70",
00062    "L1_SingleJet100",
00063    "L1_SingleJet150",
00064    "L1_SingleJet200",
00065    "L1_SingleTauJet10",
00066    "L1_SingleTauJet20",
00067    "L1_SingleTauJet30",
00068    "L1_SingleTauJet35",
00069    "L1_SingleTauJet40",
00070    "L1_SingleTauJet60",
00071    "L1_SingleTauJet80",
00072    "L1_SingleTauJet100",
00073    "L1_HTT100",
00074    "L1_HTT200",
00075    "L1_HTT250",
00076    "L1_HTT300",
00077    "L1_HTT400",
00078    "L1_HTT500",
00079    "L1_ETM10",
00080    "L1_ETM15",
00081    "L1_ETM20",
00082    "L1_ETM30",
00083    "L1_ETM40",
00084    "L1_ETM50",
00085    "L1_ETM60",
00086    "L1_ETT60",
00087    "L1_DoubleMu3",
00088    "L1_DoubleIsoEG8",
00089    "L1_DoubleIsoEG10",
00090    "L1_DoubleEG5",
00091    "L1_DoubleEG10",
00092    "L1_DoubleEG15",
00093    "L1_DoubleJet70",
00094    "L1_DoubleJet100",
00095    "L1_DoubleTauJet20",
00096    "L1_DoubleTauJet30",
00097    "L1_DoubleTauJet35",
00098    "L1_DoubleTauJet40",
00099    "L1_Mu3_IsoEG5",
00100    "L1_Mu5_IsoEG10",
00101    "L1_Mu3_EG12",
00102    "L1_Mu3_Jet15",
00103    "L1_Mu5_Jet15",
00104    "L1_Mu3_Jet70",
00105    "L1_Mu5_Jet20",
00106    "L1_Mu5_TauJet20",
00107    "L1_Mu5_TauJet30",
00108    "L1_IsoEG10_EG10",
00109    "L1_IsoEG10_Jet15",
00110    "L1_IsoEG10_Jet20",
00111    "L1_IsoEG10_Jet30",
00112    "L1_IsoEG10_Jet70",
00113    "L1_IsoEG10_TauJet20",
00114    "L1_IsoEG10_TauJet30",
00115    "L1_EG10_Jet15",
00116    "L1_EG12_Jet20",
00117    "L1_EG12_Jet70",
00118    "L1_EG12_TauJet40",
00119    "L1_Jet70_TauJet40",
00120    "L1_Mu3_HTT200",
00121    "L1_IsoEG10_HTT200",
00122    "L1_EG12_HTT200",
00123    "L1_Jet70_HTT200",
00124    "L1_TauJet40_HTT200",
00125    "L1_Mu3_ETM30",
00126    "L1_IsoEG10_ETM30",
00127    "L1_EG12_ETM30",
00128    "L1_Jet70_ETM40",
00129    "L1_TauJet20_ETM20",
00130    "L1_TauJet30_ETM30",
00131    "L1_TauJet30_ETM40",
00132    "L1_HTT100_ETM30",
00133    "L1_TripleMu3",
00134    "L1_TripleIsoEG5",
00135    "L1_TripleEG10",
00136    "L1_TripleJet50",
00137    "L1_TripleTauJet40",
00138    "L1_DoubleMu3_IsoEG5",
00139    "L1_DoubleMu3_EG10",
00140    "L1_DoubleIsoEG5_Mu3",
00141    "L1_DoubleEG10_Mu3",
00142    "L1_DoubleMu3_HTT200",
00143    "L1_DoubleIsoEG5_HTT200",
00144    "L1_DoubleEG10_HTT200",
00145    "L1_DoubleJet50_HTT200",
00146    "L1_DoubleTauJet40_HTT200",
00147    "L1_DoubleMu3_ETM20",
00148    "L1_DoubleIsoEG5_ETM20",
00149    "L1_DoubleEG10_ETM20",
00150    "L1_DoubleJet50_ETM20",
00151    "L1_DoubleTauJet40_ETM20",
00152    "L1_QuadJet30",
00153    "L1_ExclusiveDoubleIsoEG4", 
00154    "L1_ExclusiveDoubleJet60", 
00155    "L1_ExclusiveJet25_Gap_Jet25", 
00156    "L1_IsoEG10_Jet20_ForJet10",
00157    "L1_MinBias_HTT10",
00158    "L1_ZeroBias"
00159 } ;
00160 
00161 //
00162 // constructors and destructor
00163 //
00164 L1ParticleMap::L1ParticleMap()
00165 {
00166 }
00167 
00168 L1ParticleMap::L1ParticleMap(
00169    L1TriggerType triggerType,
00170    bool triggerDecision,
00171    const L1ObjectTypeVector& objectTypes,
00172    const L1EmParticleVectorRef& emParticles,
00173    const L1JetParticleVectorRef& jetParticles,
00174    const L1MuonParticleVectorRef& muonParticles,
00175    const L1EtMissParticleRefProd& etMissParticle,
00176    const L1IndexComboVector& indexCombos )
00177    : triggerType_( triggerType ),
00178      triggerDecision_( triggerDecision ),
00179      objectTypes_( objectTypes ),
00180      emParticles_( emParticles ),
00181      jetParticles_( jetParticles ),
00182      muonParticles_( muonParticles ),
00183      etMissParticle_( etMissParticle ),
00184      indexCombos_( indexCombos )
00185 {
00186 }
00187 
00188 // L1ParticleMap::L1ParticleMap(const L1ParticleMap& rhs)
00189 // {
00190 //    // do actual copying here;
00191 // }
00192 
00193 L1ParticleMap::~L1ParticleMap()
00194 {
00195 }
00196 
00197 //
00198 // assignment operators
00199 //
00200 // const L1ParticleMap& L1ParticleMap::operator=(const L1ParticleMap& rhs)
00201 // {
00202 //   //An exception safe implementation is
00203 //   L1ParticleMap temp(rhs);
00204 //   swap(rhs);
00205 //
00206 //   return *this;
00207 // }
00208 
00209 //
00210 // member functions
00211 //
00212 
00213 //
00214 // const member functions
00215 //
00216 
00217 const L1ParticleMap::L1IndexComboVector&
00218 L1ParticleMap::indexCombos() const
00219 {
00220    if( indexCombos_.size() == 0 )
00221    {
00222       // Determine the number of non-global objects.  There should be 0 or 1.
00223       int numNonGlobal = 0 ;
00224       L1ObjectType nonGlobalType = kNumOfL1ObjectTypes ;
00225       int nonGlobalIndex = -1 ;
00226       for( int i = 0 ; i < numOfObjects() ; ++i )
00227       {
00228          if( !objectTypeIsGlobal( objectTypes_[ i ] ) )
00229          {
00230             ++numNonGlobal ;
00231             nonGlobalType = objectTypes_[ i ] ;
00232             nonGlobalIndex = i ;
00233          }
00234       }
00235 
00236       if( numNonGlobal == 0 )
00237       {
00238          // Dummy entry for each object type.
00239          L1IndexCombo tmpCombo ;
00240 
00241          for( int i = 0 ; i < numOfObjects() ; ++i )
00242          {
00243             tmpCombo.push_back( 0 ) ;
00244          }
00245 
00246          indexCombos_.push_back( tmpCombo ) ;
00247       }
00248       else if( numNonGlobal == 1 )
00249       {
00250          int nParticles = 0 ;
00251 
00252          if( nonGlobalType == kEM )
00253          {
00254             nParticles = emParticles_.size() ;
00255          }
00256          else if( nonGlobalType == kJet )
00257          {
00258             nParticles = jetParticles_.size() ;
00259          }
00260          else if( nonGlobalType == kMuon )
00261          {
00262             nParticles = muonParticles_.size() ;
00263          }
00264 
00265          for( int i = 0 ; i < nParticles ; ++i )
00266          {
00267             L1IndexCombo tmpCombo ;
00268 
00269             for( int j = 0 ; j < numOfObjects() ; ++j )
00270             {
00271                if( j == nonGlobalIndex )
00272                {                  
00273                   tmpCombo.push_back( i ) ;
00274                }
00275                else
00276                {
00277                   tmpCombo.push_back( 0 ) ;
00278                }
00279             }
00280 
00281             indexCombos_.push_back( tmpCombo ) ;
00282          }
00283       }
00284    }
00285 
00286    return indexCombos_ ;
00287 }
00288 
00289 const reco::LeafCandidate*
00290 L1ParticleMap::candidateInCombo( int aIndexInCombo,
00291                                  const L1IndexCombo& aCombo ) const
00292 {
00293    L1ObjectType type = objectTypes_[ aIndexInCombo ] ;
00294    int particleInList = aCombo[ aIndexInCombo ] ;
00295 
00296    if( type == kEM )
00297    {
00298       return dynamic_cast< const reco::LeafCandidate* >(
00299          emParticles_[ particleInList ].get() ) ;
00300    }
00301    else if( type == kJet )
00302    {
00303       return dynamic_cast< const reco::LeafCandidate* >(
00304          jetParticles_[ particleInList ].get() ) ;
00305    }
00306    else if( type == kMuon )
00307    {
00308       return dynamic_cast< const reco::LeafCandidate* >(
00309          muonParticles_[ particleInList ].get() ) ;
00310    }
00311    else if( type == kEtMiss || type == kEtTotal || type == kEtHad )
00312    {
00313       return dynamic_cast< const reco::LeafCandidate* >(
00314          etMissParticle_.get() ) ;
00315    }
00316    else
00317    {
00318       return 0 ;
00319    }
00320 }
00321 
00322 const L1EmParticle*
00323 L1ParticleMap::emParticleInCombo( int aIndexInCombo,
00324                                  const L1IndexCombo& aCombo ) const
00325 {
00326    L1ObjectType type = objectTypes_[ aIndexInCombo ] ;
00327    int particleInList = aCombo[ aIndexInCombo ] ;
00328 
00329    if( type == kEM )
00330    {
00331       return emParticles_[ particleInList ].get() ;
00332    }
00333    else
00334    {
00335       return 0 ;
00336    }
00337 }
00338 
00339 const L1JetParticle*
00340 L1ParticleMap::jetParticleInCombo( int aIndexInCombo,
00341                                    const L1IndexCombo& aCombo ) const
00342 {
00343    L1ObjectType type = objectTypes_[ aIndexInCombo ] ;
00344    int particleInList = aCombo[ aIndexInCombo ] ;
00345 
00346    if( type == kJet )
00347    {
00348       return jetParticles_[ particleInList ].get() ;
00349    }
00350    else
00351    {
00352       return 0 ;
00353    }
00354 }
00355 
00356 const L1MuonParticle*
00357 L1ParticleMap::muonParticleInCombo( int aIndexInCombo,
00358                                     const L1IndexCombo& aCombo ) const
00359 {
00360    L1ObjectType type = objectTypes_[ aIndexInCombo ] ;
00361    int particleInList = aCombo[ aIndexInCombo ] ;
00362 
00363    if( type == kMuon )
00364    {
00365       return muonParticles_[ particleInList ].get() ;
00366    }
00367    else
00368    {
00369       return 0 ;
00370    }
00371 }
00372 
00373 const L1EtMissParticle*
00374 L1ParticleMap::etMissParticleInCombo( int aIndexInCombo,
00375                                       const L1IndexCombo& aCombo ) const
00376 {
00377    L1ObjectType type = objectTypes_[ aIndexInCombo ] ;
00378 
00379    if( type == kEtMiss || type == kEtTotal || type == kEtHad )
00380    {
00381       return etMissParticle_.get() ;
00382    }
00383    else
00384    {
00385       return 0 ;
00386    }
00387 }
00388 
00389 std::vector< const reco::LeafCandidate* >
00390 L1ParticleMap::candidateCombo( const L1IndexCombo& aCombo ) const
00391 {
00392    std::vector< const reco::LeafCandidate* > tmp ;
00393 
00394    for( int i = 0 ; i < numOfObjects() ; ++i )
00395    {
00396       tmp.push_back( candidateInCombo( i, aCombo ) ) ;
00397    }
00398 
00399    return tmp ;
00400 }
00401 
00402 //
00403 // static member functions
00404 //
00405 const std::string&
00406 L1ParticleMap::triggerName( L1TriggerType type )
00407 {
00408    return triggerNames_[ type ] ;
00409 }
00410 
00411 L1ParticleMap::L1TriggerType
00412 L1ParticleMap::triggerType( const std::string& name )
00413 {
00414    for( int i = 0 ; i < kNumOfL1TriggerTypes ; ++i )
00415    {
00416       if( triggerNames_[ i ] == name )
00417       {
00418          return ( L1TriggerType ) i ;
00419       }
00420    }
00421 
00422    return kNumOfL1TriggerTypes ;
00423 }
00424 
00425 bool
00426 L1ParticleMap::objectTypeIsGlobal( L1ObjectType type )
00427 {
00428    return type == kEtMiss || type == kEtTotal || type == kEtHad ;
00429 }