CMS 3D CMS Logo

Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes

MuonIdProducer Class Reference

#include <MuonIdProducer.h>

Inheritance diagram for MuonIdProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Types

typedef reco::Muon::MuonTrackType TrackType

Public Member Functions

virtual void beginRun (edm::Run &, const edm::EventSetup &)
 MuonIdProducer (const edm::ParameterSet &)
virtual void produce (edm::Event &, const edm::EventSetup &)
virtual ~MuonIdProducer ()

Static Public Member Functions

static double sectorPhi (const DetId &id)

Private Member Functions

unsigned int chamberId (const DetId &)
bool checkLinks (const reco::MuonTrackLinks *) const
void fillArbitrationInfo (reco::MuonCollection *)
void fillGlbQuality (edm::Event &, const edm::EventSetup &, reco::Muon &aMuon)
void fillMuonId (edm::Event &, const edm::EventSetup &, reco::Muon &, TrackDetectorAssociator::Direction direction=TrackDetectorAssociator::InsideOut)
void fillMuonIsolation (edm::Event &, const edm::EventSetup &, reco::Muon &aMuon, reco::IsoDeposit &trackDep, reco::IsoDeposit &ecalDep, reco::IsoDeposit &hcalDep, reco::IsoDeposit &hoDep, reco::IsoDeposit &jetDep)
void fillTrackerKink (reco::Muon &aMuon)
void init (edm::Event &, const edm::EventSetup &)
bool isGoodTrack (const reco::Track &track)
bool isGoodTrackerMuon (const reco::Muon &muon)
reco::CaloMuon makeCaloMuon (const reco::Muon &)
reco::Muon makeMuon (const reco::MuonTrackLinks &links)
reco::Muon makeMuon (const reco::Track &track)
reco::Muon makeMuon (edm::Event &iEvent, const edm::EventSetup &iSetup, const reco::TrackRef &track, TrackType type)
int overlap (const reco::Muon &muon, const reco::Track &track)
double phiOfMuonIneteractionRegion (const reco::Muon &muon) const

Private Attributes

bool addExtraSoftMuons_
bool arbClean_
double caloCut_
bool debugWithTruthMatching_
edm::Handle
< reco::TrackToTrackMap
dytCollectionHandle_
std::string ecalDepositName_
bool fillCaloCompatibility_
bool fillEnergy_
bool fillGlobalTrackQuality_
bool fillGlobalTrackRefits_
bool fillIsolation_
bool fillMatching_
bool fillTrackerKink_
edm::InputTag globalTrackQualityInputTag_
std::string hcalDepositName_
std::string hoDepositName_
edm::Handle
< reco::TrackCollection
innerTrackCollectionHandle_
std::vector< edm::InputTaginputCollectionLabels_
std::vector< std::string > inputCollectionTypes_
std::string jetDepositName_
edm::Handle
< reco::MuonTrackLinksCollection
linkCollectionHandle_
double maxAbsDx_
double maxAbsDy_
double maxAbsEta_
double maxAbsPullX_
double maxAbsPullY_
MuonMeshmeshAlgo_
int minNumberOfMatches_
double minP_
double minPCaloMuon_
double minPt_
reco::isodeposit::IsoDepositExtractormuIsoExtractorCalo_
reco::isodeposit::IsoDepositExtractormuIsoExtractorJet_
reco::isodeposit::IsoDepositExtractormuIsoExtractorTrack_
MuonCaloCompatibility muonCaloCompatibility_
edm::Handle< reco::MuonCollectionmuonCollectionHandle_
edm::Handle
< reco::TrackCollection
outerTrackCollectionHandle_
TrackAssociatorParameters parameters_
edm::Handle
< reco::TrackToTrackMap
pickyCollectionHandle_
double ptThresholdToFillCandidateP4WithGlobalFit_
double sigmaThresholdToFillCandidateP4WithGlobalFit_
MuonTimingFillertheTimingFiller_
edm::Handle
< reco::TrackToTrackMap
tpfmsCollectionHandle_
TrackDetectorAssociator trackAssociator_
std::string trackDepositName_
std::auto_ptr< MuonKinkFindertrackerKinkFinder_
bool writeIsoDeposits_

Detailed Description

Definition at line 55 of file MuonIdProducer.h.


Member Typedef Documentation

Definition at line 57 of file MuonIdProducer.h.


Constructor & Destructor Documentation

MuonIdProducer::MuonIdProducer ( const edm::ParameterSet iConfig) [explicit]

Definition at line 59 of file MuonIdProducer.cc.

References addExtraSoftMuons_, arbClean_, caloCut_, MuonCaloCompatibility::configure(), debugWithTruthMatching_, ecalDepositName_, fillCaloCompatibility_, fillEnergy_, fillGlobalTrackQuality_, fillGlobalTrackRefits_, fillIsolation_, fillMatching_, fillTrackerKink_, reco::get(), edm::ParameterSet::getParameter(), globalTrackQualityInputTag_, hcalDepositName_, hoDepositName_, inputCollectionLabels_, inputCollectionTypes_, jetDepositName_, TrackAssociatorParameters::loadParameters(), maxAbsDx_, maxAbsDy_, maxAbsEta_, maxAbsPullX_, maxAbsPullY_, meshAlgo_, minNumberOfMatches_, minP_, minPCaloMuon_, minPt_, muIsoExtractorCalo_, muIsoExtractorJet_, muIsoExtractorTrack_, muonCaloCompatibility_, Parameters::parameters, parameters_, ptThresholdToFillCandidateP4WithGlobalFit_, sigmaThresholdToFillCandidateP4WithGlobalFit_, theTimingFiller_, trackDepositName_, trackerKinkFinder_, and writeIsoDeposits_.

                                                            :
muIsoExtractorCalo_(0),muIsoExtractorTrack_(0),muIsoExtractorJet_(0)
{
   produces<reco::MuonCollection>();
   produces<reco::CaloMuonCollection>();
   produces<reco::MuonTimeExtraMap>("combined");
   produces<reco::MuonTimeExtraMap>("dt");
   produces<reco::MuonTimeExtraMap>("csc");
   
   minPt_                   = iConfig.getParameter<double>("minPt");
   minP_                    = iConfig.getParameter<double>("minP");
   minPCaloMuon_            = iConfig.getParameter<double>("minPCaloMuon");
   minNumberOfMatches_      = iConfig.getParameter<int>("minNumberOfMatches");
   addExtraSoftMuons_       = iConfig.getParameter<bool>("addExtraSoftMuons");
   maxAbsEta_               = iConfig.getParameter<double>("maxAbsEta");
   maxAbsDx_                = iConfig.getParameter<double>("maxAbsDx");
   maxAbsPullX_             = iConfig.getParameter<double>("maxAbsPullX");
   maxAbsDy_                = iConfig.getParameter<double>("maxAbsDy");
   maxAbsPullY_             = iConfig.getParameter<double>("maxAbsPullY");
   fillCaloCompatibility_   = iConfig.getParameter<bool>("fillCaloCompatibility");
   fillEnergy_              = iConfig.getParameter<bool>("fillEnergy");
   fillMatching_            = iConfig.getParameter<bool>("fillMatching");
   fillIsolation_           = iConfig.getParameter<bool>("fillIsolation");
   writeIsoDeposits_        = iConfig.getParameter<bool>("writeIsoDeposits");
   fillGlobalTrackQuality_  = iConfig.getParameter<bool>("fillGlobalTrackQuality");
   fillGlobalTrackRefits_   = iConfig.getParameter<bool>("fillGlobalTrackRefits");
   //SK: (maybe temporary) run it only if the global is also run
   fillTrackerKink_         = false;
   if (fillGlobalTrackQuality_)  fillTrackerKink_ =  iConfig.getParameter<bool>("fillTrackerKink");

   ptThresholdToFillCandidateP4WithGlobalFit_    = iConfig.getParameter<double>("ptThresholdToFillCandidateP4WithGlobalFit");
   sigmaThresholdToFillCandidateP4WithGlobalFit_ = iConfig.getParameter<double>("sigmaThresholdToFillCandidateP4WithGlobalFit");
   caloCut_ = iConfig.getParameter<double>("minCaloCompatibility"); //CaloMuons
   arbClean_ = iConfig.getParameter<bool>("runArbitrationCleaner"); // muon mesh 
   
   // Load TrackDetectorAssociator parameters
   edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
   parameters_.loadParameters( parameters );

   // Load parameters for the TimingFiller
   edm::ParameterSet timingParameters = iConfig.getParameter<edm::ParameterSet>("TimingFillerParameters");
   theTimingFiller_ = new MuonTimingFiller(timingParameters);
   
   if (fillCaloCompatibility_){
      // Load MuonCaloCompatibility parameters
      parameters = iConfig.getParameter<edm::ParameterSet>("MuonCaloCompatibility");
      muonCaloCompatibility_.configure( parameters );
   }

   if (fillIsolation_){
      // Load MuIsoExtractor parameters
      edm::ParameterSet caloExtractorPSet = iConfig.getParameter<edm::ParameterSet>("CaloExtractorPSet");
      std::string caloExtractorName = caloExtractorPSet.getParameter<std::string>("ComponentName");
      muIsoExtractorCalo_ = IsoDepositExtractorFactory::get()->create( caloExtractorName, caloExtractorPSet);

      edm::ParameterSet trackExtractorPSet = iConfig.getParameter<edm::ParameterSet>("TrackExtractorPSet");
      std::string trackExtractorName = trackExtractorPSet.getParameter<std::string>("ComponentName");
      muIsoExtractorTrack_ = IsoDepositExtractorFactory::get()->create( trackExtractorName, trackExtractorPSet);

      edm::ParameterSet jetExtractorPSet = iConfig.getParameter<edm::ParameterSet>("JetExtractorPSet");
      std::string jetExtractorName = jetExtractorPSet.getParameter<std::string>("ComponentName");
      muIsoExtractorJet_ = IsoDepositExtractorFactory::get()->create( jetExtractorName, jetExtractorPSet);
   }
   if (fillIsolation_ && writeIsoDeposits_){
     trackDepositName_ = iConfig.getParameter<std::string>("trackDepositName");
     produces<reco::IsoDepositMap>(trackDepositName_);
     ecalDepositName_ = iConfig.getParameter<std::string>("ecalDepositName");
     produces<reco::IsoDepositMap>(ecalDepositName_);
     hcalDepositName_ = iConfig.getParameter<std::string>("hcalDepositName");
     produces<reco::IsoDepositMap>(hcalDepositName_);
     hoDepositName_ = iConfig.getParameter<std::string>("hoDepositName");
     produces<reco::IsoDepositMap>(hoDepositName_);
     jetDepositName_ = iConfig.getParameter<std::string>("jetDepositName");
     produces<reco::IsoDepositMap>(jetDepositName_);
   }
   
   inputCollectionLabels_ = iConfig.getParameter<std::vector<edm::InputTag> >("inputCollectionLabels");
   inputCollectionTypes_  = iConfig.getParameter<std::vector<std::string> >("inputCollectionTypes");
   if (inputCollectionLabels_.size() != inputCollectionTypes_.size()) 
     throw cms::Exception("ConfigurationError") << "Number of input collection labels is different from number of types. " <<
     "For each collection label there should be exactly one collection type specified.";
   if (inputCollectionLabels_.size()>7 ||inputCollectionLabels_.empty()) 
     throw cms::Exception("ConfigurationError") << "Number of input collections should be from 1 to 7.";
   
   debugWithTruthMatching_    = iConfig.getParameter<bool>("debugWithTruthMatching");
   if (debugWithTruthMatching_) edm::LogWarning("MuonIdentification") 
     << "========================================================================\n" 
     << "Debugging mode with truth matching is turned on!!! Make sure you understand what you are doing!\n"
     << "========================================================================\n";
   if (fillGlobalTrackQuality_){
     globalTrackQualityInputTag_ = iConfig.getParameter<edm::InputTag>("globalTrackQualityInputTag");
   }

   if (fillTrackerKink_) {
     trackerKinkFinder_.reset(new MuonKinkFinder(iConfig.getParameter<edm::ParameterSet>("TrackerKinkFinderParameters")));
   }
   
   //create mesh holder
   meshAlgo_ = new MuonMesh(iConfig.getParameter<edm::ParameterSet>("arbitrationCleanerOptions"));
}
MuonIdProducer::~MuonIdProducer ( ) [virtual]

Definition at line 161 of file MuonIdProducer.cc.

References meshAlgo_, muIsoExtractorCalo_, muIsoExtractorJet_, muIsoExtractorTrack_, and theTimingFiller_.

{
   if (muIsoExtractorCalo_) delete muIsoExtractorCalo_;
   if (muIsoExtractorTrack_) delete muIsoExtractorTrack_;
   if (muIsoExtractorJet_) delete muIsoExtractorJet_;
   if (theTimingFiller_) delete theTimingFiller_;
   if (meshAlgo_) delete meshAlgo_;
   // TimingReport::current()->dump(std::cout);
}

Member Function Documentation

void MuonIdProducer::beginRun ( edm::Run iRun,
const edm::EventSetup iSetup 
) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 391 of file MuonIdProducer.cc.

References edm::EventSetup::get(), meshAlgo_, edm::ESHandle< T >::product(), and MuonMesh::setCSCGeometry().

{
  edm::ESHandle<CSCGeometry> geomHandle;
  iSetup.get<MuonGeometryRecord>().get(geomHandle);

  meshAlgo_->setCSCGeometry(geomHandle.product());
  
}
unsigned int MuonIdProducer::chamberId ( const DetId id) [private]

Definition at line 331 of file MuonIdProducer.cc.

References CSCDetId::chamberId(), MuonSubdetId::CSC, MuonSubdetId::DT, DetId::Muon, and DetId::rawId().

Referenced by overlap().

{
   switch ( id.det() ) {
    case DetId::Muon:
      switch ( id.subdetId() ) {
       case MuonSubdetId::DT:
           { 
              DTChamberId detId(id.rawId());
              return detId.rawId();
           }
         break;
       case MuonSubdetId::CSC:
           {
              CSCDetId detId(id.rawId());
              return detId.chamberId().rawId();
           }
         break;
       default:
         return 0;
      }
    default:
      return 0;
   }
   return 0;
}
bool MuonIdProducer::checkLinks ( const reco::MuonTrackLinks links) const [private]

Definition at line 1177 of file MuonIdProducer.cc.

References reco::MuonTrackLinks::globalTrack(), edm::Ref< C, T, F >::isNull(), reco::MuonTrackLinks::standAloneTrack(), and reco::MuonTrackLinks::trackerTrack().

Referenced by produce().

                                                                     {
  bool trackBAD = links->trackerTrack().isNull();
  bool staBAD = links->standAloneTrack().isNull();
  bool glbBAD = links->globalTrack().isNull();
  if (trackBAD || staBAD || glbBAD ) 
    {
      edm::LogWarning("muonIDbadLinks") << "Global muon links to constituent tracks are invalid: trkBad "
                                        <<trackBAD <<" standaloneBad "<<staBAD<<" globalBad "<<glbBAD
                                        <<". There should be no such object. Muon is skipped.";
      return false;
    }
  return true;
}
void MuonIdProducer::fillArbitrationInfo ( reco::MuonCollection pOutputMuons) [private]

Definition at line 882 of file MuonIdProducer.cc.

References arbClean_, reco::MuonSegmentMatch::Arbitrated, reco::MuonSegmentMatch::BelongsToTrackByDR, reco::MuonSegmentMatch::BelongsToTrackByDRSlope, reco::MuonSegmentMatch::BelongsToTrackByDX, reco::MuonSegmentMatch::BelongsToTrackByDXSlope, reco::MuonSegmentMatch::BelongsToTrackByME1aClean, reco::MuonSegmentMatch::BestInChamberByDR, reco::MuonSegmentMatch::BestInChamberByDRSlope, reco::MuonSegmentMatch::BestInChamberByDX, reco::MuonSegmentMatch::BestInChamberByDXSlope, reco::MuonSegmentMatch::BestInStationByDR, reco::MuonSegmentMatch::BestInStationByDRSlope, reco::MuonSegmentMatch::BestInStationByDX, reco::MuonSegmentMatch::BestInStationByDXSlope, MuonMesh::clearMesh(), MuonSubdetId::CSC, MuonMesh::isDuplicateOf(), meshAlgo_, CSCDetId::ring(), MuonMesh::runMesh(), python::multivaluedict::sort(), and plotscripts::stationIndex().

Referenced by produce().

{
   //
   // apply segment flags
   //
   std::vector<std::pair<reco::MuonChamberMatch*,reco::MuonSegmentMatch*> > chamberPairs;     // for chamber segment sorting
   std::vector<std::pair<reco::MuonChamberMatch*,reco::MuonSegmentMatch*> > stationPairs;     // for station segment sorting
   std::vector<std::pair<reco::MuonChamberMatch*,reco::MuonSegmentMatch*> > arbitrationPairs; // for muon segment arbitration

   // muonIndex1
   for( unsigned int muonIndex1 = 0; muonIndex1 < pOutputMuons->size(); ++muonIndex1 )
   {
      // chamberIter1
      for( std::vector<reco::MuonChamberMatch>::iterator chamberIter1 = pOutputMuons->at(muonIndex1).matches().begin();
            chamberIter1 != pOutputMuons->at(muonIndex1).matches().end(); ++chamberIter1 )
      {
         if(chamberIter1->segmentMatches.empty()) continue;
         chamberPairs.clear();

         // segmentIter1
         for( std::vector<reco::MuonSegmentMatch>::iterator segmentIter1 = chamberIter1->segmentMatches.begin();
               segmentIter1 != chamberIter1->segmentMatches.end(); ++segmentIter1 )
         {
            chamberPairs.push_back(std::make_pair(&(*chamberIter1), &(*segmentIter1)));
            if(!segmentIter1->isMask()) // has not yet been arbitrated
            {
               arbitrationPairs.clear();
               arbitrationPairs.push_back(std::make_pair(&(*chamberIter1), &(*segmentIter1)));

               

               // find identical segments with which to arbitrate
               // tracker muons only
               if (pOutputMuons->at(muonIndex1).isTrackerMuon()) {
                  // muonIndex2
                  for( unsigned int muonIndex2 = muonIndex1+1; muonIndex2 < pOutputMuons->size(); ++muonIndex2 )
                  {
                     // tracker muons only
                     if (! pOutputMuons->at(muonIndex2).isTrackerMuon()) continue;
                     // chamberIter2
                     for( std::vector<reco::MuonChamberMatch>::iterator chamberIter2 = pOutputMuons->at(muonIndex2).matches().begin();
                           chamberIter2 != pOutputMuons->at(muonIndex2).matches().end(); ++chamberIter2 )
                     {
                        // segmentIter2
                        for( std::vector<reco::MuonSegmentMatch>::iterator segmentIter2 = chamberIter2->segmentMatches.begin();
                              segmentIter2 != chamberIter2->segmentMatches.end(); ++segmentIter2 )
                        {
                           if(segmentIter2->isMask()) continue; // has already been arbitrated
                           if(fabs(segmentIter2->x       - segmentIter1->x      ) < 1E-3 &&
                                 fabs(segmentIter2->y       - segmentIter1->y      ) < 1E-3 &&
                                 fabs(segmentIter2->dXdZ    - segmentIter1->dXdZ   ) < 1E-3 &&
                                 fabs(segmentIter2->dYdZ    - segmentIter1->dYdZ   ) < 1E-3 &&
                                 fabs(segmentIter2->xErr    - segmentIter1->xErr   ) < 1E-3 &&
                                 fabs(segmentIter2->yErr    - segmentIter1->yErr   ) < 1E-3 &&
                                 fabs(segmentIter2->dXdZErr - segmentIter1->dXdZErr) < 1E-3 &&
                                 fabs(segmentIter2->dYdZErr - segmentIter1->dYdZErr) < 1E-3)
                              arbitrationPairs.push_back(std::make_pair(&(*chamberIter2), &(*segmentIter2)));
                        } // segmentIter2
                     } // chamberIter2
                  } // muonIndex2
               }

               // arbitration segment sort
               if(arbitrationPairs.empty()) continue; // this should never happen
               if(arbitrationPairs.size()==1) {
                  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::BelongsToTrackByDRSlope);
                  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::BelongsToTrackByDXSlope);
                  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::BelongsToTrackByDR);
                  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::BelongsToTrackByDX);
                  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::Arbitrated);
               } else {
                  sort(arbitrationPairs.begin(), arbitrationPairs.end(), SortMuonSegmentMatches(reco::MuonSegmentMatch::BelongsToTrackByDRSlope));
                  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::BelongsToTrackByDRSlope);
                  sort(arbitrationPairs.begin(), arbitrationPairs.end(), SortMuonSegmentMatches(reco::MuonSegmentMatch::BelongsToTrackByDXSlope));
                  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::BelongsToTrackByDXSlope);
                  sort(arbitrationPairs.begin(), arbitrationPairs.end(), SortMuonSegmentMatches(reco::MuonSegmentMatch::BelongsToTrackByDR));
                  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::BelongsToTrackByDR);
                  sort(arbitrationPairs.begin(), arbitrationPairs.end(), SortMuonSegmentMatches(reco::MuonSegmentMatch::BelongsToTrackByDX));
                  arbitrationPairs.front().second->setMask(reco::MuonSegmentMatch::BelongsToTrackByDX);
                  for( unsigned int it = 0; it < arbitrationPairs.size(); ++it )
                     arbitrationPairs.at(it).second->setMask(reco::MuonSegmentMatch::Arbitrated);
               }
            }
            
            // setup me1a cleaning for later
            if( chamberIter1->id.subdetId() == MuonSubdetId::CSC && arbClean_ ) {
              CSCDetId cscid(chamberIter1->id);
              if(cscid.ring() == 4)
                for( std::vector<reco::MuonSegmentMatch>::iterator segmentIter2 = chamberIter1->segmentMatches.begin();
                     segmentIter2 != chamberIter1->segmentMatches.end(); ++segmentIter2 ) {
                  if( segmentIter1->cscSegmentRef.isNonnull() && segmentIter2->cscSegmentRef.isNonnull() ) 
                    if( meshAlgo_->isDuplicateOf(segmentIter1->cscSegmentRef,segmentIter2->cscSegmentRef) && 
                        (segmentIter2->mask & 0x1e0000) && 
                        (segmentIter1->mask & 0x1e0000) ) 
                      segmentIter2->setMask(reco::MuonSegmentMatch::BelongsToTrackByME1aClean);
                  //if the track has lost the segment already through normal arbitration no need to do it again.
                }
            }// mark all ME1/a duplicates that this track owns

         } // segmentIter1

         // chamber segment sort
         if(chamberPairs.empty()) continue; // this should never happen
         if(chamberPairs.size()==1) {
            chamberPairs.front().second->setMask(reco::MuonSegmentMatch::BestInChamberByDRSlope);
            chamberPairs.front().second->setMask(reco::MuonSegmentMatch::BestInChamberByDXSlope);
            chamberPairs.front().second->setMask(reco::MuonSegmentMatch::BestInChamberByDR);
            chamberPairs.front().second->setMask(reco::MuonSegmentMatch::BestInChamberByDX);
         } else {
            sort(chamberPairs.begin(), chamberPairs.end(), SortMuonSegmentMatches(reco::MuonSegmentMatch::BestInChamberByDRSlope));
            chamberPairs.front().second->setMask(reco::MuonSegmentMatch::BestInChamberByDRSlope);
            sort(chamberPairs.begin(), chamberPairs.end(), SortMuonSegmentMatches(reco::MuonSegmentMatch::BestInChamberByDXSlope));
            chamberPairs.front().second->setMask(reco::MuonSegmentMatch::BestInChamberByDXSlope);
            sort(chamberPairs.begin(), chamberPairs.end(), SortMuonSegmentMatches(reco::MuonSegmentMatch::BestInChamberByDR));
            chamberPairs.front().second->setMask(reco::MuonSegmentMatch::BestInChamberByDR);
            sort(chamberPairs.begin(), chamberPairs.end(), SortMuonSegmentMatches(reco::MuonSegmentMatch::BestInChamberByDX));
            chamberPairs.front().second->setMask(reco::MuonSegmentMatch::BestInChamberByDX);
         }
      } // chamberIter1

      // station segment sort
      for( int stationIndex = 1; stationIndex < 5; ++stationIndex )
         for( int detectorIndex = 1; detectorIndex < 4; ++detectorIndex )
         {
            stationPairs.clear();

            // chamberIter
            for( std::vector<reco::MuonChamberMatch>::iterator chamberIter = pOutputMuons->at(muonIndex1).matches().begin();
                  chamberIter != pOutputMuons->at(muonIndex1).matches().end(); ++chamberIter )
            {
               if(!(chamberIter->station()==stationIndex && chamberIter->detector()==detectorIndex)) continue;
               if(chamberIter->segmentMatches.empty()) continue;

               for( std::vector<reco::MuonSegmentMatch>::iterator segmentIter = chamberIter->segmentMatches.begin();
                     segmentIter != chamberIter->segmentMatches.end(); ++segmentIter )
                  stationPairs.push_back(std::make_pair(&(*chamberIter), &(*segmentIter)));
            } // chamberIter

            if(stationPairs.empty()) continue; // this may very well happen
            if(stationPairs.size()==1) {
               stationPairs.front().second->setMask(reco::MuonSegmentMatch::BestInStationByDRSlope);
               stationPairs.front().second->setMask(reco::MuonSegmentMatch::BestInStationByDXSlope);
               stationPairs.front().second->setMask(reco::MuonSegmentMatch::BestInStationByDR);
               stationPairs.front().second->setMask(reco::MuonSegmentMatch::BestInStationByDX);
            } else {
               sort(stationPairs.begin(), stationPairs.end(), SortMuonSegmentMatches(reco::MuonSegmentMatch::BestInStationByDRSlope));
               stationPairs.front().second->setMask(reco::MuonSegmentMatch::BestInStationByDRSlope);
               sort(stationPairs.begin(), stationPairs.end(), SortMuonSegmentMatches(reco::MuonSegmentMatch::BestInStationByDXSlope));
               stationPairs.front().second->setMask(reco::MuonSegmentMatch::BestInStationByDXSlope);
               sort(stationPairs.begin(), stationPairs.end(), SortMuonSegmentMatches(reco::MuonSegmentMatch::BestInStationByDR));
               stationPairs.front().second->setMask(reco::MuonSegmentMatch::BestInStationByDR);
               sort(stationPairs.begin(), stationPairs.end(), SortMuonSegmentMatches(reco::MuonSegmentMatch::BestInStationByDX));
               stationPairs.front().second->setMask(reco::MuonSegmentMatch::BestInStationByDX);
            }
         }

   } // muonIndex1

   if(arbClean_) {
     // clear old mesh, create and prune new mesh!
     meshAlgo_->clearMesh();
     meshAlgo_->runMesh(pOutputMuons);
   }
}
void MuonIdProducer::fillGlbQuality ( edm::Event iEvent,
const edm::EventSetup iSetup,
reco::Muon aMuon 
) [private]
void MuonIdProducer::fillMuonId ( edm::Event iEvent,
const edm::EventSetup iSetup,
reco::Muon aMuon,
TrackDetectorAssociator::Direction  direction = TrackDetectorAssociator::InsideOut 
) [private]

Definition at line 749 of file MuonIdProducer.cc.

References TrackDetectorAssociator::associate(), TrackDetMatchInfo::chambers, TrackDetMatchInfo::crossedEcalIds, TrackDetMatchInfo::crossedEnergy(), TrackDetMatchInfo::crossedHcalIds, reco::MuonSegmentMatch::cscSegmentRef, reco::MuonSegmentMatch::dtSegmentRef, reco::MuonSegmentMatch::dXdZ, reco::MuonChamberMatch::dXdZ, reco::MuonChamberMatch::dXdZErr, reco::MuonSegmentMatch::dXdZErr, reco::MuonSegmentMatch::dYdZ, reco::MuonChamberMatch::dYdZ, reco::MuonChamberMatch::dYdZErr, reco::MuonSegmentMatch::dYdZErr, reco::MuonEnergy::ecal_id, reco::MuonEnergy::ecal_position, reco::MuonEnergy::ecal_time, TrackDetMatchInfo::ecalRecHits, TrackDetMatchInfo::EcalRecHits, reco::MuonChamberMatch::edgeX, reco::MuonChamberMatch::edgeY, reco::MuonEnergy::em, reco::MuonEnergy::emMax, reco::MuonEnergy::emS25, reco::MuonEnergy::emS9, Exception, fillEnergy_, fillMatching_, TrackDetMatchInfo::findMaxDeposition(), reco::MuonEnergy::had, reco::MuonEnergy::hadMax, reco::MuonEnergy::hadS9, reco::MuonSegmentMatch::hasPhi_, reco::MuonSegmentMatch::hasZed_, reco::MuonEnergy::hcal_id, reco::MuonEnergy::hcal_position, reco::MuonEnergy::hcal_time, TrackDetMatchInfo::HcalRecHits, TrackDetMatchInfo::hcalRecHits, reco::MuonEnergy::ho, TrackDetMatchInfo::HORecHits, reco::MuonEnergy::hoS9, reco::MuonChamberMatch::id, info, reco::Muon::isTrackerMuon(), LogTrace, reco::MuonSegmentMatch::mask, reco::Muon::matches(), maxAbsDx_, maxAbsDy_, maxAbsPullX_, maxAbsPullY_, reco::Muon::NoArbitration, reco::Muon::numberOfMatches(), TrackDetMatchInfo::nXnEnergy(), parameters_, funct::pow(), reco::MuonChamberMatch::segmentMatches, reco::Muon::setCalEnergy(), reco::Muon::setMatches(), mathSSE::sqrt(), reco::Muon::standAloneMuon(), reco::MuonSegmentMatch::t0, reco::MuonEnergy::tower, reco::MuonEnergy::towerS9, TrackDetMatchInfo::TowerTotal, reco::Muon::track(), trackAssociator_, TrackDetMatchInfo::trkGlobPosAtEcal, TrackDetMatchInfo::trkGlobPosAtHcal, reco::MuonSegmentMatch::x, reco::MuonChamberMatch::x, reco::MuonChamberMatch::xErr, reco::MuonSegmentMatch::xErr, LocalError::xx(), reco::MuonSegmentMatch::y, reco::MuonChamberMatch::y, reco::MuonChamberMatch::yErr, reco::MuonSegmentMatch::yErr, and LocalError::yy().

Referenced by produce().

{
   // perform track - detector association
   const reco::Track* track = 0;
   if ( ! aMuon.track().isNull() )
     track = aMuon.track().get();
   else 
     {
        if ( ! aMuon.standAloneMuon().isNull() )
          track = aMuon.standAloneMuon().get();
        else
          throw cms::Exception("FatalError") << "Failed to fill muon id information for a muon with undefined references to tracks"; 
     }
   
   TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup, *track, parameters_, direction);
   
   if ( fillEnergy_ ) {
      reco::MuonEnergy muonEnergy;
      muonEnergy.em      = info.crossedEnergy(TrackDetMatchInfo::EcalRecHits);
      muonEnergy.had     = info.crossedEnergy(TrackDetMatchInfo::HcalRecHits);
      muonEnergy.ho      = info.crossedEnergy(TrackDetMatchInfo::HORecHits);
      muonEnergy.tower   = info.crossedEnergy(TrackDetMatchInfo::TowerTotal);
      muonEnergy.emS9    = info.nXnEnergy(TrackDetMatchInfo::EcalRecHits,1); // 3x3 energy
      muonEnergy.emS25   = info.nXnEnergy(TrackDetMatchInfo::EcalRecHits,2); // 5x5 energy
      muonEnergy.hadS9   = info.nXnEnergy(TrackDetMatchInfo::HcalRecHits,1); // 3x3 energy
      muonEnergy.hoS9    = info.nXnEnergy(TrackDetMatchInfo::HORecHits,1);   // 3x3 energy
      muonEnergy.towerS9 = info.nXnEnergy(TrackDetMatchInfo::TowerTotal,1);  // 3x3 energy
      muonEnergy.ecal_position = info.trkGlobPosAtEcal;
      muonEnergy.hcal_position = info.trkGlobPosAtHcal;
      if (! info.crossedEcalIds.empty() ) muonEnergy.ecal_id = info.crossedEcalIds.front();
      if (! info.crossedHcalIds.empty() ) muonEnergy.hcal_id = info.crossedHcalIds.front();
      // find maximal energy depositions and their time
      DetId emMaxId      = info.findMaxDeposition(TrackDetMatchInfo::EcalRecHits,2); // max energy deposit in 5x5 shape
      for(std::vector<const EcalRecHit*>::const_iterator hit=info.ecalRecHits.begin(); 
          hit!=info.ecalRecHits.end(); ++hit) {
         if ((*hit)->id() != emMaxId) continue;
         muonEnergy.emMax   = (*hit)->energy();
         muonEnergy.ecal_time = (*hit)->time();
      }
      DetId hadMaxId     = info.findMaxDeposition(TrackDetMatchInfo::HcalRecHits,1); // max energy deposit in 3x3 shape
      for(std::vector<const HBHERecHit*>::const_iterator hit=info.hcalRecHits.begin(); 
          hit!=info.hcalRecHits.end(); ++hit) {
         if ((*hit)->id() != hadMaxId) continue;
         muonEnergy.hadMax   = (*hit)->energy();
         muonEnergy.hcal_time = (*hit)->time();
      }
      aMuon.setCalEnergy( muonEnergy );
   }
   if ( ! fillMatching_ && ! aMuon.isTrackerMuon() ) return;
   
   // fill muon match info
   std::vector<reco::MuonChamberMatch> muonChamberMatches;
   unsigned int nubmerOfMatchesAccordingToTrackAssociator = 0;
   for( std::vector<TAMuonChamberMatch>::const_iterator chamber=info.chambers.begin();
        chamber!=info.chambers.end(); chamber++ )
     {
        reco::MuonChamberMatch matchedChamber;
        
        LocalError localError = chamber->tState.localError().positionError();
        matchedChamber.x = chamber->tState.localPosition().x();
        matchedChamber.y = chamber->tState.localPosition().y();
        matchedChamber.xErr = sqrt( localError.xx() );
        matchedChamber.yErr = sqrt( localError.yy() );
                                                                                                                                                            
        matchedChamber.dXdZ = chamber->tState.localDirection().z()!=0?chamber->tState.localDirection().x()/chamber->tState.localDirection().z():9999;
        matchedChamber.dYdZ = chamber->tState.localDirection().z()!=0?chamber->tState.localDirection().y()/chamber->tState.localDirection().z():9999;
        // DANGEROUS - compiler cannot guaranty parameters ordering
        AlgebraicSymMatrix55 trajectoryCovMatrix = chamber->tState.localError().matrix();
        matchedChamber.dXdZErr = trajectoryCovMatrix(1,1)>0?sqrt(trajectoryCovMatrix(1,1)):0;
        matchedChamber.dYdZErr = trajectoryCovMatrix(2,2)>0?sqrt(trajectoryCovMatrix(2,2)):0;
        
        matchedChamber.edgeX = chamber->localDistanceX;
        matchedChamber.edgeY = chamber->localDistanceY;
        
        matchedChamber.id = chamber->id;
        if ( ! chamber->segments.empty() ) ++nubmerOfMatchesAccordingToTrackAssociator;
        
        // fill segments
        for( std::vector<TAMuonSegmentMatch>::const_iterator segment = chamber->segments.begin();
             segment != chamber->segments.end(); segment++ ) 
          {
             reco::MuonSegmentMatch matchedSegment;
             matchedSegment.x = segment->segmentLocalPosition.x();
             matchedSegment.y = segment->segmentLocalPosition.y();
             matchedSegment.dXdZ = segment->segmentLocalDirection.z()?segment->segmentLocalDirection.x()/segment->segmentLocalDirection.z():0;
             matchedSegment.dYdZ = segment->segmentLocalDirection.z()?segment->segmentLocalDirection.y()/segment->segmentLocalDirection.z():0;
             matchedSegment.xErr = segment->segmentLocalErrorXX>0?sqrt(segment->segmentLocalErrorXX):0;
             matchedSegment.yErr = segment->segmentLocalErrorYY>0?sqrt(segment->segmentLocalErrorYY):0;
             matchedSegment.dXdZErr = segment->segmentLocalErrorDxDz>0?sqrt(segment->segmentLocalErrorDxDz):0;
             matchedSegment.dYdZErr = segment->segmentLocalErrorDyDz>0?sqrt(segment->segmentLocalErrorDyDz):0;
             matchedSegment.t0 = segment->t0;
             matchedSegment.mask = 0;
             matchedSegment.dtSegmentRef  = segment->dtSegmentRef;
             matchedSegment.cscSegmentRef = segment->cscSegmentRef;
        matchedSegment.hasZed_ = segment->hasZed;
        matchedSegment.hasPhi_ = segment->hasPhi;
             // test segment
             bool matchedX = false;
             bool matchedY = false;
             LogTrace("MuonIdentification") << " matching local x, segment x: " << matchedSegment.x << 
               ", chamber x: " << matchedChamber.x << ", max: " << maxAbsDx_;
             LogTrace("MuonIdentification") << " matching local y, segment y: " << matchedSegment.y <<
               ", chamber y: " << matchedChamber.y << ", max: " << maxAbsDy_;
             if (matchedSegment.xErr>0 && matchedChamber.xErr>0 )
               LogTrace("MuonIdentification") << " xpull: " << 
               fabs(matchedSegment.x - matchedChamber.x)/sqrt(pow(matchedSegment.xErr,2) + pow(matchedChamber.xErr,2));
             if (matchedSegment.yErr>0 && matchedChamber.yErr>0 )
               LogTrace("MuonIdentification") << " ypull: " << 
               fabs(matchedSegment.y - matchedChamber.y)/sqrt(pow(matchedSegment.yErr,2) + pow(matchedChamber.yErr,2));
             
             if (fabs(matchedSegment.x - matchedChamber.x) < maxAbsDx_) matchedX = true;
             if (fabs(matchedSegment.y - matchedChamber.y) < maxAbsDy_) matchedY = true;
             if (matchedSegment.xErr>0 && matchedChamber.xErr>0 && 
                 fabs(matchedSegment.x - matchedChamber.x)/sqrt(pow(matchedSegment.xErr,2) + pow(matchedChamber.xErr,2)) < maxAbsPullX_) matchedX = true;
             if (matchedSegment.yErr>0 && matchedChamber.yErr>0 && 
                 fabs(matchedSegment.y - matchedChamber.y)/sqrt(pow(matchedSegment.yErr,2) + pow(matchedChamber.yErr,2)) < maxAbsPullY_) matchedY = true;
             if (matchedX && matchedY) matchedChamber.segmentMatches.push_back(matchedSegment);
          }
        muonChamberMatches.push_back(matchedChamber);
     }
   aMuon.setMatches(muonChamberMatches);

   LogTrace("MuonIdentification") << "number of muon chambers: " << aMuon.matches().size() << "\n" 
     << "number of chambers with segments according to the associator requirements: " << 
     nubmerOfMatchesAccordingToTrackAssociator;
   LogTrace("MuonIdentification") << "number of segment matches with the producer requirements: " << 
     aMuon.numberOfMatches( reco::Muon::NoArbitration );
   
   // fillTime( iEvent, iSetup, aMuon );
}
void MuonIdProducer::fillMuonIsolation ( edm::Event iEvent,
const edm::EventSetup iSetup,
reco::Muon aMuon,
reco::IsoDeposit trackDep,
reco::IsoDeposit ecalDep,
reco::IsoDeposit hcalDep,
reco::IsoDeposit hoDep,
reco::IsoDeposit jetDep 
) [private]

Definition at line 1047 of file MuonIdProducer.cc.

References reco::IsoDeposit::candEnergy(), reco::isodeposit::IsoDepositExtractor::deposit(), reco::IsoDeposit::depositAndCountWithin(), reco::isodeposit::IsoDepositExtractor::deposits(), reco::IsoDeposit::depositWithin(), reco::MuonIsolation::emEt, reco::MuonIsolation::emVetoEt, Exception, reco::MuonIsolation::hadEt, reco::MuonIsolation::hadVetoEt, reco::MuonIsolation::hoEt, reco::MuonIsolation::hoVetoEt, LogTrace, muIsoExtractorCalo_, muIsoExtractorJet_, muIsoExtractorTrack_, reco::MuonIsolation::nJets, reco::MuonIsolation::nTracks, reco::Muon::setIsolation(), reco::Muon::standAloneMuon(), reco::MuonIsolation::sumPt, reco::Muon::track(), and reco::MuonIsolation::trackerVetoPt.

Referenced by produce().

{
   reco::MuonIsolation isoR03, isoR05;
   const reco::Track* track = 0;
   if ( ! aMuon.track().isNull() )
     track = aMuon.track().get();
   else 
     {
        if ( ! aMuon.standAloneMuon().isNull() )
          track = aMuon.standAloneMuon().get();
        else
          throw cms::Exception("FatalError") << "Failed to compute muon isolation information for a muon with undefined references to tracks"; 
     }

   // get deposits
   reco::IsoDeposit depTrk = muIsoExtractorTrack_->deposit(iEvent, iSetup, *track );
   std::vector<reco::IsoDeposit> caloDeps = muIsoExtractorCalo_->deposits(iEvent, iSetup, *track);
   reco::IsoDeposit depJet = muIsoExtractorJet_->deposit(iEvent, iSetup, *track );

   if(caloDeps.size()!=3) {
      LogTrace("MuonIdentification") << "Failed to fill vector of calorimeter isolation deposits!";
      return;
   }

   reco::IsoDeposit depEcal = caloDeps.at(0);
   reco::IsoDeposit depHcal = caloDeps.at(1);
   reco::IsoDeposit depHo   = caloDeps.at(2);

   trackDep = depTrk;
   ecalDep = depEcal;
   hcalDep = depHcal;
   hoDep = depHo;
   jetDep = depJet;

   isoR03.sumPt     = depTrk.depositWithin(0.3);
   isoR03.emEt      = depEcal.depositWithin(0.3);
   isoR03.hadEt     = depHcal.depositWithin(0.3);
   isoR03.hoEt      = depHo.depositWithin(0.3);
   isoR03.nTracks   = depTrk.depositAndCountWithin(0.3).second;
   isoR03.nJets     = depJet.depositAndCountWithin(0.3).second;
   isoR03.trackerVetoPt  = depTrk.candEnergy();
   isoR03.emVetoEt       = depEcal.candEnergy();
   isoR03.hadVetoEt      = depHcal.candEnergy();
   isoR03.hoVetoEt       = depHo.candEnergy();

   isoR05.sumPt     = depTrk.depositWithin(0.5);
   isoR05.emEt      = depEcal.depositWithin(0.5);
   isoR05.hadEt     = depHcal.depositWithin(0.5);
   isoR05.hoEt      = depHo.depositWithin(0.5);
   isoR05.nTracks   = depTrk.depositAndCountWithin(0.5).second;
   isoR05.nJets     = depJet.depositAndCountWithin(0.5).second;
   isoR05.trackerVetoPt  = depTrk.candEnergy();
   isoR05.emVetoEt       = depEcal.candEnergy();
   isoR05.hadVetoEt      = depHcal.candEnergy();
   isoR05.hoVetoEt       = depHo.candEnergy();


   aMuon.setIsolation(isoR03, isoR05);

}
void MuonIdProducer::fillTrackerKink ( reco::Muon aMuon) [private]

Definition at line 1166 of file MuonIdProducer.cc.

References reco::Muon::combinedQuality(), reco::Muon::innerTrack(), reco::Muon::isQualityValid(), reco::Muon::setCombinedQuality(), and trackerKinkFinder_.

Referenced by produce().

                                                      {
    // skip muons with no tracks
    if (aMuon.innerTrack().isNull()) return;
    // get quality from muon if already there, otherwise make empty one
    reco::MuonQuality quality = (aMuon.isQualityValid() ? aMuon.combinedQuality() : reco::MuonQuality());
    // fill it
    bool filled = trackerKinkFinder_->fillTrkKink(quality, *aMuon.innerTrack());
    // if quality was there, or if we filled it, commit to the muon 
    if (filled || aMuon.isQualityValid()) aMuon.setCombinedQuality(quality);
}
void MuonIdProducer::init ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private]

Definition at line 171 of file MuonIdProducer.cc.

References edm::HandleBase::clear(), dytCollectionHandle_, Exception, fillGlobalTrackRefits_, fillTrackerKink_, edm::EventSetup::get(), edm::Event::getByLabel(), i, innerTrackCollectionHandle_, inputCollectionLabels_, inputCollectionTypes_, edm::HandleBase::isValid(), linkCollectionHandle_, LogTrace, muonCollectionHandle_, outerTrackCollectionHandle_, pickyCollectionHandle_, edm::ESHandle< T >::product(), LargeD0_PixelPairStep_cff::propagator, TrackDetectorAssociator::setPropagator(), tpfmsCollectionHandle_, trackAssociator_, and trackerKinkFinder_.

Referenced by produce().

{
   // TimerStack timers;
   // timers.push("MuonIdProducer::produce::init");
   
   innerTrackCollectionHandle_.clear();
   outerTrackCollectionHandle_.clear();
   linkCollectionHandle_.clear();
   muonCollectionHandle_.clear();
   
   tpfmsCollectionHandle_.clear();
   pickyCollectionHandle_.clear();
   dytCollectionHandle_.clear();
   

   // timers.push("MuonIdProducer::produce::init::getPropagator");
   edm::ESHandle<Propagator> propagator;
   iSetup.get<TrackingComponentsRecord>().get("SteppingHelixPropagatorAny", propagator);
   trackAssociator_.setPropagator(propagator.product());

   if (fillTrackerKink_) trackerKinkFinder_->init(iSetup);
   
   // timers.pop_and_push("MuonIdProducer::produce::init::getInputCollections");
   for ( unsigned int i = 0; i < inputCollectionLabels_.size(); ++i ) {
      if ( inputCollectionTypes_[i] == "inner tracks" ) {
         iEvent.getByLabel(inputCollectionLabels_[i], innerTrackCollectionHandle_);
         if (! innerTrackCollectionHandle_.isValid()) 
           throw cms::Exception("FatalError") << "Failed to get input track collection with label: " << inputCollectionLabels_[i];
         LogTrace("MuonIdentification") << "Number of input inner tracks: " << innerTrackCollectionHandle_->size();
         continue;
      }
      if ( inputCollectionTypes_[i] == "outer tracks" ) {
         iEvent.getByLabel(inputCollectionLabels_[i], outerTrackCollectionHandle_);
         if (! outerTrackCollectionHandle_.isValid()) 
           throw cms::Exception("FatalError") << "Failed to get input track collection with label: " << inputCollectionLabels_[i];
         LogTrace("MuonIdentification") << "Number of input outer tracks: " << outerTrackCollectionHandle_->size();
         continue;
      }
      if ( inputCollectionTypes_[i] == "links" ) {
         iEvent.getByLabel(inputCollectionLabels_[i], linkCollectionHandle_);
         if (! linkCollectionHandle_.isValid()) 
           throw cms::Exception("FatalError") << "Failed to get input link collection with label: " << inputCollectionLabels_[i];
         LogTrace("MuonIdentification") << "Number of input links: " << linkCollectionHandle_->size();
         continue;
      }
      if ( inputCollectionTypes_[i] == "muons" ) {
         iEvent.getByLabel(inputCollectionLabels_[i], muonCollectionHandle_);
         if (! muonCollectionHandle_.isValid()) 
           throw cms::Exception("FatalError") << "Failed to get input muon collection with label: " << inputCollectionLabels_[i];
         LogTrace("MuonIdentification") << "Number of input muons: " << muonCollectionHandle_->size();
         continue;
      }
      if ( fillGlobalTrackRefits_  && inputCollectionTypes_[i] == "tev firstHit" ) {
         iEvent.getByLabel(inputCollectionLabels_[i], tpfmsCollectionHandle_);
         if (! tpfmsCollectionHandle_.isValid()) 
           throw cms::Exception("FatalError") << "Failed to get input muon collection with label: " << inputCollectionLabels_[i];
         LogTrace("MuonIdentification") << "Number of input muons: " << tpfmsCollectionHandle_->size();
         continue;
      }

      if ( fillGlobalTrackRefits_  && inputCollectionTypes_[i] == "tev picky" ) {
         iEvent.getByLabel(inputCollectionLabels_[i], pickyCollectionHandle_);
         if (! pickyCollectionHandle_.isValid()) 
           throw cms::Exception("FatalError") << "Failed to get input muon collection with label: " << inputCollectionLabels_[i];
         LogTrace("MuonIdentification") << "Number of input muons: " << pickyCollectionHandle_->size();
         continue;
      }

      if ( fillGlobalTrackRefits_  && inputCollectionTypes_[i] == "tev dyt" ) {
         iEvent.getByLabel(inputCollectionLabels_[i], dytCollectionHandle_);
         if (! dytCollectionHandle_.isValid()) 
           throw cms::Exception("FatalError") << "Failed to get input muon collection with label: " << inputCollectionLabels_[i];
         LogTrace("MuonIdentification") << "Number of input muons: " << dytCollectionHandle_->size();
         continue;
      }
      throw cms::Exception("FatalError") << "Unknown input collection type: " << inputCollectionTypes_[i];
   }
}
bool MuonIdProducer::isGoodTrack ( const reco::Track track) [private]

Definition at line 314 of file MuonIdProducer.cc.

References reco::TrackBase::eta(), LogTrace, maxAbsEta_, minP_, minPCaloMuon_, minPt_, reco::TrackBase::p(), and reco::TrackBase::pt().

Referenced by produce().

{
   // Pt and absolute momentum requirement
   if (track.pt() < minPt_ || (track.p() < minP_ && track.p() < minPCaloMuon_)){ 
      LogTrace("MuonIdentification") << "Skipped low momentum track (Pt,P): " << track.pt() <<
        ", " << track.p() << " GeV";
      return false;
   }
        
   // Eta requirement
   if ( fabs(track.eta()) > maxAbsEta_ ){
      LogTrace("MuonIdentification") << "Skipped track with large pseudo rapidity (Eta: " << track.eta() << " )";
      return false;
   }
   return true;
}
bool MuonIdProducer::isGoodTrackerMuon ( const reco::Muon muon) [private]

Definition at line 740 of file MuonIdProducer.cc.

References addExtraSoftMuons_, reco::LeafCandidate::eta(), minNumberOfMatches_, minP_, minPt_, reco::Muon::NoArbitration, reco::Muon::numberOfMatches(), reco::LeafCandidate::pt(), and reco::Muon::track().

Referenced by produce().

{
  if(muon.track()->pt() < minPt_ || muon.track()->p() < minP_) return false;
   if ( addExtraSoftMuons_ && 
        muon.pt()<5 && fabs(muon.eta())<1.5 && 
        muon.numberOfMatches( reco::Muon::NoArbitration ) >= 1 ) return true;
   return ( muon.numberOfMatches( reco::Muon::NoArbitration ) >= minNumberOfMatches_ );
}
reco::CaloMuon MuonIdProducer::makeCaloMuon ( const reco::Muon muon) [private]
reco::Muon MuonIdProducer::makeMuon ( const reco::Track track) [private]

Definition at line 1110 of file MuonIdProducer.cc.

References reco::TrackBase::charge(), relval_parameters_module::energy, reco::TrackBase::p(), p4, reco::TrackBase::px(), reco::TrackBase::py(), reco::TrackBase::pz(), mathSSE::sqrt(), and reco::TrackBase::vertex().

{
   //FIXME: E = sqrt(p^2 + m^2), where m == 0.105658369(9)GeV 
   double energy = sqrt(track.p() * track.p() + 0.011163691);
   math::XYZTLorentzVector p4(track.px(),
                              track.py(),
                              track.pz(),
                              energy);
   return reco::Muon( track.charge(), p4, track.vertex() );
}
reco::Muon MuonIdProducer::makeMuon ( edm::Event iEvent,
const edm::EventSetup iSetup,
const reco::TrackRef track,
MuonIdProducer::TrackType  type 
) [private]

Definition at line 250 of file MuonIdProducer.cc.

References edm::Ref< C, T, F >::get(), LogTrace, and reco::Muon::setMuonTrack().

Referenced by makeMuon(), and produce().

{
   LogTrace("MuonIdentification") << "Creating a muon from a track " << track.get()->pt() << 
     " Pt (GeV), eta: " << track.get()->eta();
   reco::Muon aMuon( makeMuon( *(track.get()) ) );

   aMuon.setMuonTrack(type,track);
   return aMuon;
}
reco::Muon MuonIdProducer::makeMuon ( const reco::MuonTrackLinks links) [private]

Definition at line 274 of file MuonIdProducer.cc.

References reco::Muon::DYT, dytCollectionHandle_, edm::HandleBase::failedToGet(), fillGlobalTrackRefits_, muon::getTevRefitTrack(), reco::MuonTrackLinks::globalTrack(), edm::HandleBase::isValid(), LogTrace, makeMuon(), reco::Muon::Picky, pickyCollectionHandle_, ptThresholdToFillCandidateP4WithGlobalFit_, sigmaSwitch(), sigmaThresholdToFillCandidateP4WithGlobalFit_, reco::MuonTrackLinks::standAloneTrack(), muon::tevOptimized(), reco::Muon::TPFMS, tpfmsCollectionHandle_, and reco::MuonTrackLinks::trackerTrack().

{
   LogTrace("MuonIdentification") << "Creating a muon from a link to tracks object";

   reco::Muon aMuon;
   reco::Muon::MuonTrackTypePair chosenTrack;
   
   if (tpfmsCollectionHandle_.isValid() && !tpfmsCollectionHandle_.failedToGet() && 
       pickyCollectionHandle_.isValid() && !pickyCollectionHandle_.failedToGet()) 
       chosenTrack = muon::tevOptimized( links.globalTrack(), links.trackerTrack(), 
                                         muon::getTevRefitTrack(links.globalTrack(), *tpfmsCollectionHandle_),
                                         muon::getTevRefitTrack(links.globalTrack(), *pickyCollectionHandle_),
                                         ptThresholdToFillCandidateP4WithGlobalFit_);
     else chosenTrack = muon::sigmaSwitch( links.globalTrack(), links.trackerTrack(), 
                                           sigmaThresholdToFillCandidateP4WithGlobalFit_,
                                           ptThresholdToFillCandidateP4WithGlobalFit_);
   aMuon = makeMuon(*chosenTrack.first);
   aMuon.setInnerTrack( links.trackerTrack() );
   aMuon.setOuterTrack( links.standAloneTrack() );
   aMuon.setGlobalTrack( links.globalTrack() );
   aMuon.setBestTrack(chosenTrack.second);

   if(fillGlobalTrackRefits_){
     if (tpfmsCollectionHandle_.isValid() && !tpfmsCollectionHandle_.failedToGet()) {
       reco::TrackToTrackMap::const_iterator it = tpfmsCollectionHandle_->find(links.globalTrack());
       if (it != tpfmsCollectionHandle_->end()) aMuon.setMuonTrack(reco::Muon::TPFMS, (it->val));
     }
     if (pickyCollectionHandle_.isValid() && !pickyCollectionHandle_.failedToGet()) {
       reco::TrackToTrackMap::const_iterator it = pickyCollectionHandle_->find(links.globalTrack());
       if (it != pickyCollectionHandle_->end()) aMuon.setMuonTrack(reco::Muon::Picky, (it->val));
     }
     if (dytCollectionHandle_.isValid() && !dytCollectionHandle_.failedToGet()) {
       reco::TrackToTrackMap::const_iterator it = dytCollectionHandle_->find(links.globalTrack());
       if (it != dytCollectionHandle_->end()) aMuon.setMuonTrack(reco::Muon::DYT, (it->val));
     }
   }
   return aMuon;
}
int MuonIdProducer::overlap ( const reco::Muon muon,
const reco::Track track 
) [private]

Definition at line 358 of file MuonIdProducer.cc.

References chamberId(), reco::Track::extra(), reco::Muon::isMatchesValid(), match(), and reco::Muon::matches().

Referenced by produce().

{
   int numberOfCommonDetIds = 0;
   if ( ! muon.isMatchesValid() || 
        track.extra().isNull() ||
        track.extra()->recHits().isNull() ) return numberOfCommonDetIds;
   const std::vector<reco::MuonChamberMatch>& matches( muon.matches() );
   for ( std::vector<reco::MuonChamberMatch>::const_iterator match = matches.begin();
         match != matches.end(); ++match ) 
     {
        if ( match->segmentMatches.empty() ) continue;
        bool foundCommonDetId = false;
        
        for ( TrackingRecHitRefVector::const_iterator hit = track.extra()->recHitsBegin();
              hit != track.extra()->recHitsEnd(); ++hit )
          {
             // LogTrace("MuonIdentification") << "hit DetId: " << std::hex << hit->get()->geographicalId().rawId() <<
             //  "\t hit chamber DetId: " << getChamberId(hit->get()->geographicalId()) <<
             //  "\t segment DetId: " << match->id.rawId() << std::dec;
             
             if ( chamberId(hit->get()->geographicalId()) == match->id.rawId() ) {
                foundCommonDetId = true;
                break;
             }
          }
        if ( foundCommonDetId ) {
           numberOfCommonDetIds++;
           break;
        }
     }
   return numberOfCommonDetIds;
}
double MuonIdProducer::phiOfMuonIneteractionRegion ( const reco::Muon muon) const [private]

Definition at line 1139 of file MuonIdProducer.cc.

References reco::Muon::innerTrack(), reco::Muon::isStandAloneMuon(), reco::Muon::matches(), reco::LeafCandidate::phi(), sectorPhi(), and reco::Muon::standAloneMuon().

Referenced by produce().

{
   if ( muon.isStandAloneMuon() ) return muon.standAloneMuon()->innerPosition().phi();
   // the rest is tracker muon only
   if ( muon.matches().empty() ){
      if ( muon.innerTrack().isAvailable() &&
           muon.innerTrack()->extra().isAvailable() )
        return muon.innerTrack()->outerPosition().phi();
      else
        return muon.phi(); // makes little sense, but what else can I use
   }
   return sectorPhi(muon.matches().at(0).id);
}
void MuonIdProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 416 of file MuonIdProducer.cc.

References TrackDetectorAssociator::Any, reco::Muon::calEnergy(), reco::CaloMuon::caloCompatibility(), caloCut_, checkLinks(), funct::cos(), TrackDetectorAssociator::crossedIP(), debugWithTruthMatching_, ecalDepositName_, MuonCaloCompatibility::evaluate(), reco::Track::extra(), edm::helper::Filler< Map >::fill(), fillArbitrationInfo(), fillCaloCompatibility_, fillEnergy_, fillGlbQuality(), fillGlobalTrackQuality_, fillIsolation_, fillMatching_, fillMuonId(), fillMuonIsolation(), MuonTimingFiller::fillTiming(), fillTrackerKink(), fillTrackerKink_, reco::Muon::GlobalMuon, reco::MuonTrackLinks::globalTrack(), hcalDepositName_, hoDepositName_, i, init(), reco::Muon::innerTrack(), reco::Muon::InnerTrack, innerTrackCollectionHandle_, edm::helper::Filler< Map >::insert(), TrackDetectorAssociator::InsideOut, reco::CaloMuon::isCaloCompatibilityValid(), reco::Muon::isEnergyValid(), isGoodTrack(), isGoodTrackerMuon(), reco::Muon::isTimeValid(), edm::HandleBase::isValid(), j, jetDepositName_, linkCollectionHandle_, LogDebug, LogTrace, makeCaloMuon(), makeMuon(), reco::Muon::matches(), minPCaloMuon_, metsig::muon, muonCaloCompatibility_, muonCollectionHandle_, reco::MuonTimeExtra::nDof(), reco::MuonTime::nDof, reco::Muon::OuterTrack, outerTrackCollectionHandle_, TrackDetectorAssociator::OutsideIn, overlap(), reco::CaloMuon::p(), phiOfMuonIneteractionRegion(), edm::Event::put(), reco::Muon::setType(), reco::Muon::StandAloneMuon, reco::MuonTrackLinks::standAloneTrack(), theTimingFiller_, reco::Muon::time(), reco::MuonTimeExtra::timeAtIpInOut(), reco::MuonTime::timeAtIpInOut, reco::MuonTimeExtra::timeAtIpInOutErr(), reco::MuonTime::timeAtIpInOutErr, reco::MuonTime::timeAtIpOutIn, reco::MuonTimeExtra::timeAtIpOutIn(), reco::MuonTime::timeAtIpOutInErr, reco::MuonTimeExtra::timeAtIpOutInErr(), trackDepositName_, susybsm::HSCParticleType::trackerMuon, reco::Muon::TrackerMuon, reco::MuonTrackLinks::trackerTrack(), MuonIdTruthInfo::truthMatchMuon(), validateGlobalMuonPair(), and writeIsoDeposits_.

{
   // TimerStack timers;
   // timers.push("MuonIdProducer::produce");
   
   std::auto_ptr<reco::MuonCollection> outputMuons(new reco::MuonCollection);
   std::auto_ptr<reco::CaloMuonCollection> caloMuons( new reco::CaloMuonCollection );

   init(iEvent, iSetup);

   std::auto_ptr<reco::MuonTimeExtraMap> muonTimeMap(new reco::MuonTimeExtraMap());
   reco::MuonTimeExtraMap::Filler filler(*muonTimeMap);
   std::auto_ptr<reco::MuonTimeExtraMap> muonTimeMapDT(new reco::MuonTimeExtraMap());
   reco::MuonTimeExtraMap::Filler fillerDT(*muonTimeMapDT);
   std::auto_ptr<reco::MuonTimeExtraMap> muonTimeMapCSC(new reco::MuonTimeExtraMap());
   reco::MuonTimeExtraMap::Filler fillerCSC(*muonTimeMapCSC);

   std::auto_ptr<reco::IsoDepositMap> trackDepMap(new reco::IsoDepositMap());
   reco::IsoDepositMap::Filler trackDepFiller(*trackDepMap);
   std::auto_ptr<reco::IsoDepositMap> ecalDepMap(new reco::IsoDepositMap());
   reco::IsoDepositMap::Filler ecalDepFiller(*ecalDepMap);
   std::auto_ptr<reco::IsoDepositMap> hcalDepMap(new reco::IsoDepositMap());
   reco::IsoDepositMap::Filler hcalDepFiller(*hcalDepMap);
   std::auto_ptr<reco::IsoDepositMap> hoDepMap(new reco::IsoDepositMap());
   reco::IsoDepositMap::Filler hoDepFiller(*hoDepMap);
   std::auto_ptr<reco::IsoDepositMap> jetDepMap(new reco::IsoDepositMap());
   reco::IsoDepositMap::Filler jetDepFiller(*jetDepMap);

   // loop over input collections
   
   // muons first - no cleaning, take as is.
   if ( muonCollectionHandle_.isValid() )
     for ( reco::MuonCollection::const_iterator muon = muonCollectionHandle_->begin();
           muon !=  muonCollectionHandle_->end(); ++muon )
       outputMuons->push_back(*muon);
   
   // links second ( assume global muon type )
   if ( linkCollectionHandle_.isValid() ){
     std::vector<bool> goodmuons(linkCollectionHandle_->size(),true);
     if ( goodmuons.size()>1 ){
       // check for shared tracker tracks
       for ( unsigned int i=0; i<linkCollectionHandle_->size()-1; ++i ){
         if (!checkLinks(&linkCollectionHandle_->at(i))) continue;
         for ( unsigned int j=i+1; j<linkCollectionHandle_->size(); ++j ){
           if (!checkLinks(&linkCollectionHandle_->at(j))) continue; 
           if ( linkCollectionHandle_->at(i).trackerTrack().isNonnull() &&
                linkCollectionHandle_->at(i).trackerTrack() == 
                linkCollectionHandle_->at(j).trackerTrack() )
             {
               // Tracker track is the essential part that dominates muon resolution
               // so taking either muon is fine. All that is important is to preserve
               // the muon identification information. If number of hits is small,
               // keep the one with large number of hits, otherwise take the smalest chi2/ndof
               if ( validateGlobalMuonPair(linkCollectionHandle_->at(i),linkCollectionHandle_->at(j)) )
                 goodmuons[j] = false;
               else
                 goodmuons[i] = false;
             }
         }
       }
       // check for shared stand-alone muons.
       for ( unsigned int i=0; i<linkCollectionHandle_->size()-1; ++i ){
         if ( !goodmuons[i] ) continue;
         if (!checkLinks(&linkCollectionHandle_->at(i))) continue;
         for ( unsigned int j=i+1; j<linkCollectionHandle_->size(); ++j ){
           if ( !goodmuons[j] ) continue;
           if (!checkLinks(&linkCollectionHandle_->at(j))) continue;
           if ( linkCollectionHandle_->at(i).standAloneTrack().isNonnull() &&
                linkCollectionHandle_->at(i).standAloneTrack() == 
                linkCollectionHandle_->at(j).standAloneTrack() )
             {
               if ( validateGlobalMuonPair(linkCollectionHandle_->at(i),linkCollectionHandle_->at(j)) )
                 goodmuons[j] = false;
               else
                 goodmuons[i] = false;
             }
         }
       }
     }
     for ( unsigned int i=0; i<linkCollectionHandle_->size(); ++i ){
       if ( !goodmuons[i] ) continue;
       const reco::MuonTrackLinks* links = &linkCollectionHandle_->at(i);
       if ( ! checkLinks(links))   continue;
       // check if this muon is already in the list
       bool newMuon = true;
       for ( reco::MuonCollection::const_iterator muon = outputMuons->begin();
             muon !=  outputMuons->end(); ++muon )
         if ( muon->track() == links->trackerTrack() &&
              muon->standAloneMuon() == links->standAloneTrack() &&
              muon->combinedMuon() == links->globalTrack() )
           newMuon = false;
       if ( newMuon ) {
         outputMuons->push_back( makeMuon( *links ) );
         outputMuons->back().setType(reco::Muon::GlobalMuon | reco::Muon::StandAloneMuon);
       }
     }
   }

   // tracker and calo muons are next
   if ( innerTrackCollectionHandle_.isValid() ) {
      LogTrace("MuonIdentification") << "Creating tracker muons";
      for ( unsigned int i = 0; i < innerTrackCollectionHandle_->size(); ++i )
        {
           const reco::Track& track = innerTrackCollectionHandle_->at(i);
           if ( ! isGoodTrack( track ) ) continue;
           bool splitTrack = false;
           if ( track.extra().isAvailable() && 
                TrackDetectorAssociator::crossedIP( track ) ) splitTrack = true;
           std::vector<TrackDetectorAssociator::Direction> directions;
           if ( splitTrack ) {
              directions.push_back(TrackDetectorAssociator::InsideOut);
              directions.push_back(TrackDetectorAssociator::OutsideIn);
           } else {
              directions.push_back(TrackDetectorAssociator::Any);
           }
           for ( std::vector<TrackDetectorAssociator::Direction>::const_iterator direction = directions.begin();
                 direction != directions.end(); ++direction )
             {
                // make muon
                // timers.push("MuonIdProducer::produce::fillMuonId");
               reco::Muon trackerMuon( makeMuon(iEvent, iSetup, reco::TrackRef( innerTrackCollectionHandle_, i ), reco::Muon::InnerTrack ) );
                trackerMuon.setType( reco::Muon::TrackerMuon );
                fillMuonId(iEvent, iSetup, trackerMuon, *direction);
                // timers.pop();
          
                if ( debugWithTruthMatching_ ) {
                   // add MC hits to a list of matched segments. 
                   // Since it's debugging mode - code is slow
                   MuonIdTruthInfo::truthMatchMuon(iEvent, iSetup, trackerMuon);
                }
          
                // check if this muon is already in the list
                // have to check where muon hits are really located
                // to match properly
                bool newMuon = true;
                bool goodTrackerMuon = isGoodTrackerMuon( trackerMuon );
                for ( reco::MuonCollection::iterator muon = outputMuons->begin();
                      muon !=  outputMuons->end(); ++muon )
                  {
                     if ( muon->innerTrack().get() == trackerMuon.innerTrack().get() &&
                          cos(phiOfMuonIneteractionRegion(*muon) - 
                              phiOfMuonIneteractionRegion(trackerMuon)) > 0 )
                       {
                          newMuon = false;
                          muon->setMatches( trackerMuon.matches() );
                          if (trackerMuon.isTimeValid()) muon->setTime( trackerMuon.time() );
                          if (trackerMuon.isEnergyValid()) muon->setCalEnergy( trackerMuon.calEnergy() );
                          if (goodTrackerMuon) muon->setType( muon->type() | reco::Muon::TrackerMuon );
                          LogTrace("MuonIdentification") << "Found a corresponding global muon. Set energy, matches and move on";
                          break;
                       }
                  }
                if ( newMuon ) {
                   if ( goodTrackerMuon ){
                      outputMuons->push_back( trackerMuon );
                   } else {
                      LogTrace("MuonIdentification") << "track failed minimal number of muon matches requirement";
                      const reco::CaloMuon& caloMuon = makeCaloMuon(trackerMuon);
                      if ( ! caloMuon.isCaloCompatibilityValid() || caloMuon.caloCompatibility() < caloCut_ || caloMuon.p() < minPCaloMuon_) continue;
                      caloMuons->push_back( caloMuon );
                   }
                }
             }
        }
   }
   
   // and at last the stand alone muons
   if ( outerTrackCollectionHandle_.isValid() ) {
      LogTrace("MuonIdentification") << "Looking for new muons among stand alone muon tracks";
      for ( unsigned int i = 0; i < outerTrackCollectionHandle_->size(); ++i )
        {
           // check if this muon is already in the list of global muons
           bool newMuon = true;
           for ( reco::MuonCollection::iterator muon = outputMuons->begin();
                 muon !=  outputMuons->end(); ++muon ) 
             {
                if ( ! muon->standAloneMuon().isNull() ) {
                   // global muon
                   if ( muon->standAloneMuon().get() ==  &(outerTrackCollectionHandle_->at(i)) ) {
                      newMuon = false;
                      break;
                   }
                } else {
                   // tracker muon - no direct links to the standalone muon
                   // since we have only a few real muons in an event, matching 
                   // the stand alone muon to the tracker muon by DetIds should 
                   // be good enough for association. At the end it's up to a 
                   // user to redefine the association and what it means. Here 
                   // we would like to avoid obvious double counting and we 
                   // tolerate a potential miss association
                   if ( overlap(*muon,outerTrackCollectionHandle_->at(i))>0 ) {
                      LogTrace("MuonIdentification") << "Found associated tracker muon. Set a reference and move on";
                      newMuon = false;
                      muon->setOuterTrack( reco::TrackRef( outerTrackCollectionHandle_, i ) );
                      muon->setType( muon->type() | reco::Muon::StandAloneMuon );
                      break;
                   }
                }
             }
           if ( newMuon ) {
              LogTrace("MuonIdentification") << "No associated stand alone track is found. Making a muon";
              outputMuons->push_back( makeMuon(iEvent, iSetup, 
                                               reco::TrackRef( outerTrackCollectionHandle_, i ), reco::Muon::OuterTrack ) );
              outputMuons->back().setType( reco::Muon::StandAloneMuon );
           }
        }
   }
   
   LogTrace("MuonIdentification") << "Dress up muons if it's necessary";

   int nMuons=outputMuons->size();

   std::vector<reco::MuonTimeExtra> dtTimeColl(nMuons);
   std::vector<reco::MuonTimeExtra> cscTimeColl(nMuons);
   std::vector<reco::MuonTimeExtra> combinedTimeColl(nMuons);
   std::vector<reco::IsoDeposit> trackDepColl(nMuons);
   std::vector<reco::IsoDeposit> ecalDepColl(nMuons);
   std::vector<reco::IsoDeposit> hcalDepColl(nMuons);
   std::vector<reco::IsoDeposit> hoDepColl(nMuons);
   std::vector<reco::IsoDeposit> jetDepColl(nMuons);

   // Fill various information
   unsigned int i=0;
   for ( reco::MuonCollection::iterator muon = outputMuons->begin(); muon != outputMuons->end(); ++muon )
     {
        // Fill muonID
        // timers.push("MuonIdProducer::produce::fillMuonId");
        if ( ( fillMatching_ && ! muon->isMatchesValid() ) || 
             ( fillEnergy_ && !muon->isEnergyValid() ) )
          {
             // predict direction based on the muon interaction region location 
             // if it's available
             if ( muon->isStandAloneMuon() ) {
                if ( cos(phiOfMuonIneteractionRegion(*muon) - muon->phi()) > 0 )
                  fillMuonId(iEvent, iSetup, *muon, TrackDetectorAssociator::InsideOut);
                else
                  fillMuonId(iEvent, iSetup, *muon, TrackDetectorAssociator::OutsideIn);
             } else {
                LogTrace("MuonIdentification") << "THIS SHOULD NEVER HAPPEN";
                fillMuonId(iEvent, iSetup, *muon);
             }
          }

        if (fillGlobalTrackQuality_){
          // Fill global quality information
          fillGlbQuality(iEvent, iSetup, *muon);
        }
        LogDebug("MuonIdentification");

        if (fillTrackerKink_) {
            fillTrackerKink(*muon);
        }

        // timers.push("MuonIdProducer::produce::fillCaloCompatibility");
        if ( fillCaloCompatibility_ ) muon->setCaloCompatibility( muonCaloCompatibility_.evaluate(*muon) );
        // timers.pop();
        
        // timers.push("MuonIdProducer::produce::fillIsolation");
        if ( fillIsolation_ ) fillMuonIsolation(iEvent, iSetup, *muon,
                                                trackDepColl[i], ecalDepColl[i], hcalDepColl[i], hoDepColl[i], jetDepColl[i]);
        // timers.pop();

        // fill timing information
        reco::MuonTime muonTime;
        reco::MuonTimeExtra dtTime;
        reco::MuonTimeExtra cscTime;
        reco::MuonTimeExtra combinedTime;

        theTimingFiller_->fillTiming(*muon, dtTime, cscTime, combinedTime, iEvent, iSetup);

        muonTime.nDof=combinedTime.nDof();
        muonTime.timeAtIpInOut=combinedTime.timeAtIpInOut();
        muonTime.timeAtIpInOutErr=combinedTime.timeAtIpInOutErr();
        muonTime.timeAtIpOutIn=combinedTime.timeAtIpOutIn();
        muonTime.timeAtIpOutInErr=combinedTime.timeAtIpOutInErr();

        muon->setTime(  muonTime);
        dtTimeColl[i] = dtTime;
        cscTimeColl[i] = cscTime;
        combinedTimeColl[i] = combinedTime;
        
        i++;
     
     }
        
   LogTrace("MuonIdentification") << "number of muons produced: " << outputMuons->size();
   // timers.push("MuonIdProducer::produce::fillArbitration");
   if ( fillMatching_ ) fillArbitrationInfo( outputMuons.get() );
   // timers.pop();
   edm::OrphanHandle<reco::MuonCollection> muonHandle = iEvent.put(outputMuons);

   filler.insert(muonHandle, combinedTimeColl.begin(), combinedTimeColl.end());
   filler.fill();
   fillerDT.insert(muonHandle, dtTimeColl.begin(), dtTimeColl.end());
   fillerDT.fill();
   fillerCSC.insert(muonHandle, cscTimeColl.begin(), cscTimeColl.end());
   fillerCSC.fill();

   iEvent.put(muonTimeMap,"combined");
   iEvent.put(muonTimeMapDT,"dt");
   iEvent.put(muonTimeMapCSC,"csc");

   if (writeIsoDeposits_ && fillIsolation_){
     trackDepFiller.insert(muonHandle, trackDepColl.begin(), trackDepColl.end());
     trackDepFiller.fill();
     iEvent.put(trackDepMap, trackDepositName_);
     ecalDepFiller.insert(muonHandle, ecalDepColl.begin(), ecalDepColl.end());
     ecalDepFiller.fill();
     iEvent.put(ecalDepMap,  ecalDepositName_);
     hcalDepFiller.insert(muonHandle, hcalDepColl.begin(), hcalDepColl.end());
     hcalDepFiller.fill();
     iEvent.put(hcalDepMap,  hcalDepositName_);
     hoDepFiller.insert(muonHandle, hoDepColl.begin(), hoDepColl.end());
     hoDepFiller.fill();
     iEvent.put(hoDepMap,    hoDepositName_);
     jetDepFiller.insert(muonHandle, jetDepColl.begin(), jetDepColl.end());
     jetDepFiller.fill();
     iEvent.put(jetDepMap,  jetDepositName_);
   }

   iEvent.put(caloMuons);
}
double MuonIdProducer::sectorPhi ( const DetId id) [static]

Definition at line 1121 of file MuonIdProducer.cc.

References CSC(), MuonSubdetId::DT, M_PI, phi, DTChamberId::sector(), and CSCDetId::triggerSector().

Referenced by phiOfMuonIneteractionRegion().

{
   double phi = 0;
   if( id.subdetId() ==  MuonSubdetId::DT ) {    // DT
      DTChamberId muonId(id.rawId());
      if ( muonId.sector() <= 12 )
        phi = (muonId.sector()-1)/6.*M_PI;
      if ( muonId.sector() == 13 ) phi = 3/6.*M_PI;
      if ( muonId.sector() == 14 ) phi = 9/6.*M_PI;
   }
   if( id.subdetId() == MuonSubdetId::CSC ) {    // CSC
      CSCDetId muonId(id.rawId());
      phi = M_PI/4+(muonId.triggerSector()-1)/3.*M_PI;
   }
   if ( phi > M_PI ) phi -= 2*M_PI; 
   return phi; 
}

Member Data Documentation

Definition at line 119 of file MuonIdProducer.h.

Referenced by isGoodTrackerMuon(), and MuonIdProducer().

bool MuonIdProducer::arbClean_ [private]

Definition at line 165 of file MuonIdProducer.h.

Referenced by fillArbitrationInfo(), and MuonIdProducer().

double MuonIdProducer::caloCut_ [private]

Definition at line 163 of file MuonIdProducer.h.

Referenced by MuonIdProducer(), and produce().

Definition at line 136 of file MuonIdProducer.h.

Referenced by MuonIdProducer(), and produce().

Definition at line 144 of file MuonIdProducer.h.

Referenced by init(), and makeMuon().

std::string MuonIdProducer::ecalDepositName_ [private]

Definition at line 151 of file MuonIdProducer.h.

Referenced by MuonIdProducer(), and produce().

Definition at line 128 of file MuonIdProducer.h.

Referenced by makeCaloMuon(), MuonIdProducer(), and produce().

Definition at line 129 of file MuonIdProducer.h.

Referenced by fillMuonId(), MuonIdProducer(), and produce().

Definition at line 156 of file MuonIdProducer.h.

Referenced by MuonIdProducer(), and produce().

Definition at line 157 of file MuonIdProducer.h.

Referenced by init(), makeMuon(), and MuonIdProducer().

Definition at line 131 of file MuonIdProducer.h.

Referenced by MuonIdProducer(), and produce().

Definition at line 130 of file MuonIdProducer.h.

Referenced by fillMuonId(), MuonIdProducer(), and produce().

Definition at line 160 of file MuonIdProducer.h.

Referenced by init(), MuonIdProducer(), and produce().

Definition at line 158 of file MuonIdProducer.h.

Referenced by fillGlbQuality(), and MuonIdProducer().

std::string MuonIdProducer::hcalDepositName_ [private]

Definition at line 152 of file MuonIdProducer.h.

Referenced by MuonIdProducer(), and produce().

std::string MuonIdProducer::hoDepositName_ [private]

Definition at line 153 of file MuonIdProducer.h.

Referenced by MuonIdProducer(), and produce().

Definition at line 138 of file MuonIdProducer.h.

Referenced by init(), and produce().

Definition at line 108 of file MuonIdProducer.h.

Referenced by init(), and MuonIdProducer().

std::vector<std::string> MuonIdProducer::inputCollectionTypes_ [private]

Definition at line 109 of file MuonIdProducer.h.

Referenced by init(), and MuonIdProducer().

std::string MuonIdProducer::jetDepositName_ [private]

Definition at line 154 of file MuonIdProducer.h.

Referenced by MuonIdProducer(), and produce().

Definition at line 141 of file MuonIdProducer.h.

Referenced by init(), and produce().

double MuonIdProducer::maxAbsDx_ [private]

Definition at line 122 of file MuonIdProducer.h.

Referenced by fillMuonId(), and MuonIdProducer().

double MuonIdProducer::maxAbsDy_ [private]

Definition at line 124 of file MuonIdProducer.h.

Referenced by fillMuonId(), and MuonIdProducer().

double MuonIdProducer::maxAbsEta_ [private]

Definition at line 118 of file MuonIdProducer.h.

Referenced by isGoodTrack(), and MuonIdProducer().

double MuonIdProducer::maxAbsPullX_ [private]

Definition at line 123 of file MuonIdProducer.h.

Referenced by fillMuonId(), and MuonIdProducer().

double MuonIdProducer::maxAbsPullY_ [private]

Definition at line 125 of file MuonIdProducer.h.

Referenced by fillMuonId(), and MuonIdProducer().

Definition at line 166 of file MuonIdProducer.h.

Referenced by beginRun(), fillArbitrationInfo(), MuonIdProducer(), and ~MuonIdProducer().

Definition at line 117 of file MuonIdProducer.h.

Referenced by isGoodTrackerMuon(), and MuonIdProducer().

double MuonIdProducer::minP_ [private]

Definition at line 115 of file MuonIdProducer.h.

Referenced by isGoodTrack(), isGoodTrackerMuon(), and MuonIdProducer().

Definition at line 116 of file MuonIdProducer.h.

Referenced by isGoodTrack(), MuonIdProducer(), and produce().

double MuonIdProducer::minPt_ [private]

Definition at line 114 of file MuonIdProducer.h.

Referenced by isGoodTrack(), isGoodTrackerMuon(), and MuonIdProducer().

Definition at line 147 of file MuonIdProducer.h.

Referenced by fillMuonIsolation(), MuonIdProducer(), and ~MuonIdProducer().

Definition at line 149 of file MuonIdProducer.h.

Referenced by fillMuonIsolation(), MuonIdProducer(), and ~MuonIdProducer().

Definition at line 148 of file MuonIdProducer.h.

Referenced by fillMuonIsolation(), MuonIdProducer(), and ~MuonIdProducer().

Definition at line 146 of file MuonIdProducer.h.

Referenced by makeCaloMuon(), MuonIdProducer(), and produce().

Definition at line 140 of file MuonIdProducer.h.

Referenced by init(), and produce().

Definition at line 139 of file MuonIdProducer.h.

Referenced by init(), and produce().

Definition at line 106 of file MuonIdProducer.h.

Referenced by fillMuonId(), and MuonIdProducer().

Definition at line 143 of file MuonIdProducer.h.

Referenced by init(), and makeMuon().

Definition at line 133 of file MuonIdProducer.h.

Referenced by makeMuon(), and MuonIdProducer().

Definition at line 134 of file MuonIdProducer.h.

Referenced by makeMuon(), and MuonIdProducer().

Definition at line 111 of file MuonIdProducer.h.

Referenced by MuonIdProducer(), produce(), and ~MuonIdProducer().

Definition at line 142 of file MuonIdProducer.h.

Referenced by init(), and makeMuon().

Definition at line 105 of file MuonIdProducer.h.

Referenced by fillMuonId(), and init().

std::string MuonIdProducer::trackDepositName_ [private]

Definition at line 150 of file MuonIdProducer.h.

Referenced by MuonIdProducer(), and produce().

Definition at line 161 of file MuonIdProducer.h.

Referenced by fillTrackerKink(), init(), and MuonIdProducer().

Definition at line 132 of file MuonIdProducer.h.

Referenced by MuonIdProducer(), and produce().