CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

MuonReSeeder Class Reference

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

List of all members.

Public Member Functions

 MuonReSeeder (const edm::ParameterSet &iConfig)
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
virtual ~MuonReSeeder ()

Private Member Functions

int layer (DetId detid) const

Private Attributes

bool debug_
 Dump deug information.
bool insideOut_
 Do inside-out.
int layersToKeep_
 How many hits to keep from the muon trajectory.
TrackTransformer refitter_
 Track Transformer.
StringCutObjectSelector
< reco::Muon
selector_
 Muon selection.
edm::InputTag src_
 Labels for input collections.

Detailed Description

Definition at line 38 of file MuonReSeeder.cc.


Constructor & Destructor Documentation

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

Definition at line 68 of file MuonReSeeder.cc.

                                                          :
    src_(iConfig.getParameter<edm::InputTag>("src")),
    selector_(iConfig.existsAs<std::string>("cut") ? iConfig.getParameter<std::string>("cut") : "", true),
    layersToKeep_(iConfig.getParameter<int32_t>("layersToKeep")),
    insideOut_(iConfig.getParameter<bool>("insideOut")),
    debug_(iConfig.getUntrackedParameter<bool>("debug",false)),
    refitter_(iConfig)
{
    produces<std::vector<TrajectorySeed> >(); 
}
virtual MuonReSeeder::~MuonReSeeder ( ) [inline, virtual]

Definition at line 41 of file MuonReSeeder.cc.

{ }

Member Function Documentation

int MuonReSeeder::layer ( DetId  detid) const [private]
void MuonReSeeder::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 80 of file MuonReSeeder.cc.

References abs, alongMomentum, gather_cfg::cout, debug_, end, reco::LeafCandidate::eta(), edm::OwnVector< T, P >::front(), TrackingRecHit::geographicalId(), edm::Event::getByLabel(), TrajectoryStateOnSurface::globalPosition(), i, insideOut_, TrackingRecHit::isValid(), TrajectoryStateOnSurface::isValid(), layer(), layersToKeep_, RPCpg::mu, oppositeToMomentum, dbtoconf::out, PV3DBase< T, PVType, FrameType >::perp(), trajectoryStateTransform::persistentState(), reco::LeafCandidate::phi(), reco::LeafCandidate::pt(), edm::OwnVector< T, P >::push_back(), edm::Event::put(), DetId::rawId(), TrajectoryMeasurement::recHit(), refitter_, selector_, TrackTransformer::setServices(), alcazmumu_cfi::src, src_, relval_parameters_module::step, DetId::subdetId(), reco::Muon::track(), TrackTransformer::transform(), TrajectoryMeasurement::updatedState(), and PV3DBase< T, PVType, FrameType >::z().

                                                                     {
    using namespace edm;
    using namespace std;

    refitter_.setServices(iSetup);

    Handle<View<reco::Muon> > src;
    iEvent.getByLabel(src_, src);


    auto_ptr<vector<TrajectorySeed> > out(new vector<TrajectorySeed>());
    unsigned int nsrc = src->size();
    out->reserve(nsrc);

    for (View<reco::Muon>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
        const reco::Muon &mu = *it;
        if (mu.track().isNull() || !selector_(mu)) continue;
        std::vector<Trajectory> traj  = refitter_.transform(*mu.track());
        if (traj.size() != 1) continue;
        edm::OwnVector<TrackingRecHit> seedHits;
        const std::vector<TrajectoryMeasurement> & tms = traj.front().measurements();
        TrajectoryStateOnSurface tsos; const TrackingRecHit *hit  = 0;
        bool fromInside = (insideOut_ == (traj.front().direction() == alongMomentum));
        if (debug_) {
            std::cout << "Considering muon of pt " << mu.pt() << ", eta = " << mu.eta() << ", phi = " << mu.phi() << std::endl;
            std::cout << "Trajectory is " << (traj.front().direction() == alongMomentum ? "along" : "opposite") << " to momentum, so will start from " << (fromInside ? "inside" : "outside") << std::endl;
        }
        const TrajectoryMeasurement & tin = (fromInside ? tms.front() : tms.back());
        const TrajectoryMeasurement & tou = (fromInside ? tms.front() : tms.back());
        if (debug_) {
            std::cout << "IN state: subdetector   = " << tin.recHit()->geographicalId().subdetId() << std::endl;
            std::cout << "          global pos Rho  " << tin.updatedState().globalPosition().perp() << ", Z   " << tin.updatedState().globalPosition().z() << std::endl;
            std::cout << "OU state: subdetector   = " << tou.recHit()->geographicalId().subdetId() << std::endl;
            std::cout << "          global pos Rho  " << tou.updatedState().globalPosition().perp() << ", Z   " << tou.updatedState().globalPosition().z() << std::endl;
        }
        int lastSubdet = 0, lastLayer = -1;
        for (int i    = (fromInside ? 0 : tms.size()-1),
                 end  = (fromInside ? tms.size() : -1),
                 step = (fromInside ? +1 : -1),
                 taken = 0; (end-i)*step > 0; i += step) {
            const TrackingRecHit *lastHit = hit;
            hit = tms[i].recHit()->hit();
            if (debug_) std::cout << "  considering hit " << i << ": rechit on " << (hit ? hit->geographicalId().rawId() : -1) << std::endl;
            if (!hit) continue;
            int subdet = hit->geographicalId().subdetId(), lay = layer(hit->geographicalId());
            if (subdet != lastSubdet || lay != lastLayer) {
                // I'm on a new layer
                if (lastHit != 0 && taken == layersToKeep_) {
                    // I've had enough layers, I can stop here
                    hit = lastHit;
                    break;
                } 
                lastSubdet = subdet; lastLayer = lay;
                taken++;
            }
            seedHits.push_back(*hit); 
            tsos = tms[i].updatedState().isValid() ? tms[i].updatedState() :
                          (abs(i-end) < abs(i) ? tms[i].forwardPredictedState() : tms[i].backwardPredictedState());
            if (debug_) {
                std::cout << "     hit  : subdetector   = " << tms[i].recHit()->geographicalId().subdetId() << std::endl;
                if (hit->isValid()) {
                    std::cout << "            global pos Rho  " << tms[i].recHit()->globalPosition().perp() << ", Z   " << tms[i].recHit()->globalPosition().z() << std::endl;
                } else {
                    std::cout << "            invalid tracking rec hit, so no global position" << std::endl;
                }
                std::cout << "     state: global pos Rho  " << tsos.globalPosition().perp() << ", Z   " << tsos.globalPosition().z() << std::endl;
            }
        }
        if (!tsos.isValid()) continue;
        PTrajectoryStateOnDet const & PTraj = trajectoryStateTransform::persistentState(tsos, hit->geographicalId().rawId());
        TrajectorySeed seed(PTraj,std::move(seedHits),insideOut_ ? alongMomentum : oppositeToMomentum); 
        out->push_back(seed);
    }

    iEvent.put(out);
}

Member Data Documentation

bool MuonReSeeder::debug_ [private]

Dump deug information.

Definition at line 59 of file MuonReSeeder.cc.

Referenced by produce().

bool MuonReSeeder::insideOut_ [private]

Do inside-out.

Definition at line 56 of file MuonReSeeder.cc.

Referenced by produce().

How many hits to keep from the muon trajectory.

Definition at line 53 of file MuonReSeeder.cc.

Referenced by produce().

Track Transformer.

Definition at line 62 of file MuonReSeeder.cc.

Referenced by produce().

Muon selection.

Definition at line 50 of file MuonReSeeder.cc.

Referenced by produce().

Labels for input collections.

Definition at line 47 of file MuonReSeeder.cc.

Referenced by produce().