CMS 3D CMS Logo

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

RPCCosmicSeedrecHitFinder Class Reference

#include <RPCCosmicSeedrecHitFinder.h>

List of all members.

Public Member Functions

void configure (const edm::ParameterSet &iConfig)
void fillrecHits ()
 RPCCosmicSeedrecHitFinder ()
void setEdge (const edm::EventSetup &iSetup)
void setInput (MuonRecHitContainer(&recHits)[RPCLayerNumber])
void setLayers (const std::vector< unsigned int > &Layers)
void setOutput (RPCSeedFinder *Seed)
void unsetEdge ()
void unsetInput ()
 ~RPCCosmicSeedrecHitFinder ()

Private Types

typedef
MuonTransientTrackingRecHit::ConstMuonRecHitContainer 
ConstMuonRecHitContainer
typedef
MuonTransientTrackingRecHit::ConstMuonRecHitPointer 
ConstMuonRecHitPointer
typedef
MuonTransientTrackingRecHit::MuonRecHitContainer 
MuonRecHitContainer
typedef
MuonTransientTrackingRecHit::MuonRecHitPointer 
MuonRecHitPointer

Private Member Functions

void checkandfill ()
bool complete (const GlobalVector &lastSegment, const MuonRecHitPointer &lastrecHitRef)
bool iscorssEdge (const MuonRecHitPointer &lastrecHitRef, const MuonRecHitPointer &currentrecHitRef)
bool isinsideAngleRange (const GlobalVector &lastSegment, const GlobalPoint &lastPosition, const GlobalPoint &currentPosition)
bool isouterLayer (const MuonRecHitPointer &recHitRef)
int LayerComponent ()

Private Attributes

MuonRecHitContainer AllrecHits [RPCLayerNumber]
unsigned int BxRange
std::vector< int > ClusterSet
std::vector< BoundPlaneinnerBounds
bool isConfigured
bool isEdgeset
bool isInputset
bool isLayerset
bool isLayersmixed
bool isOuterLayerfilled
bool isOutputset
std::vector< unsigned int > LayersinRPC
double MaxDeltaPhi
ConstMuonRecHitContainer therecHits
RPCSeedFindertheSeed

Detailed Description

Definition at line 30 of file RPCCosmicSeedrecHitFinder.h.


Member Typedef Documentation

Definition at line 35 of file RPCCosmicSeedrecHitFinder.h.

Definition at line 33 of file RPCCosmicSeedrecHitFinder.h.

Definition at line 34 of file RPCCosmicSeedrecHitFinder.h.

Definition at line 32 of file RPCCosmicSeedrecHitFinder.h.


Constructor & Destructor Documentation

RPCCosmicSeedrecHitFinder::RPCCosmicSeedrecHitFinder ( )

Definition at line 26 of file RPCCosmicSeedrecHitFinder.cc.

                                                     {

    // Initiate the member
    isLayerset = false;
    isConfigured = false;
    isInputset = false;
    isOutputset = false;
    isEdgeset = false;
    BxRange = 0;
    MaxDeltaPhi = 0;
    ClusterSet.clear();
    innerBounds.clear();
    isLayersmixed = false;
    LayersinRPC.clear();
    therecHits.clear();
    isOuterLayerfilled = false;
}
RPCCosmicSeedrecHitFinder::~RPCCosmicSeedrecHitFinder ( )

Definition at line 44 of file RPCCosmicSeedrecHitFinder.cc.

                                                      {

}

Member Function Documentation

void RPCCosmicSeedrecHitFinder::checkandfill ( ) [private]

Definition at line 337 of file RPCCosmicSeedrecHitFinder.cc.

References gather_cfg::cout.

                                             {

    if(therecHits.size() >= 3) {
        theSeed->setrecHits(therecHits); 
        theSeed->seed();
    }
    else
        cout << "Layer less than 3, could not fill a RPCSeedFinder" << endl;
}
bool RPCCosmicSeedrecHitFinder::complete ( const GlobalVector lastSegment,
const MuonRecHitPointer lastrecHitRef 
) [private]

Definition at line 174 of file RPCCosmicSeedrecHitFinder.cc.

References abs, begin, RPCRecHit::BunchX(), TrackingRecHit::clone(), RPCRecHit::clusterSize(), gather_cfg::cout, i, RPCLayerNumber, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

                                                                                                                {

    bool isrecHitsfound = false;

    for(unsigned int i = 0; i < RPCLayerNumber; i++)
        for(MuonRecHitContainer::const_iterator it = AllrecHits[i].begin(); it != AllrecHits[i].end(); it++) {

            cout << "Finding recHits from " << i << " th layer" << endl;
            // information for recHits
            GlobalPoint currentPosition = (*it)->globalPosition();
            int currentBX;

            // Check validation
            if(!(*it)->isValid())
                continue;

            // Check BX range, be sure there is only RPCRecHit in the MuonRecHitContainer when use the dynamic_cast
            TrackingRecHit* thisTrackingRecHit = (*it)->hit()->clone();
            // Should also delete the RPCRecHit object cast by dynamic_cast<> ?
            RPCRecHit* thisRPCRecHit = dynamic_cast<RPCRecHit*>(thisTrackingRecHit);
            currentBX = thisRPCRecHit->BunchX();
            int ClusterSize = thisRPCRecHit->clusterSize();
            delete thisTrackingRecHit;
            // Check BX
            if((unsigned int)abs(currentBX) > BxRange)
                continue;

            // Check cluster size
            bool Clustercheck = false;
            if(ClusterSet.size() == 0)
                Clustercheck = true;
            for(std::vector<int>::const_iterator CluIter = ClusterSet.begin(); CluIter != ClusterSet.end(); CluIter++)
                if(ClusterSize == (*CluIter))
                    Clustercheck = true;
            if(Clustercheck != true)
                continue;
 
            cout << "Candidate recHit's position: " << currentPosition.x() << ", " << currentPosition.y() << ", " << currentPosition.z() << ". BX : " << currentBX << endl;
            // Fill 1st recHit from outer layers and rest recHits from all layers
            if(isOuterLayerfilled == false) {
                // Pick out the recHit from outer layers and fill it
                if(!isouterLayer(*it))
                    continue;

                // If pass all, add to the seed
                GlobalVector currentSegment = GlobalVector(0, 0, 0); 
                cout << "1st recHit's global position: " << currentPosition.x() << ", " << currentPosition.y() << ", " << currentPosition.z() << ". BX: " << currentBX << endl;
                isrecHitsfound = true;
                therecHits.push_back(*it);
                isOuterLayerfilled = true;
                complete(currentSegment, *it);
                // Remember to pop the recHit before add another one from the same layer!
                therecHits.pop_back();
                isOuterLayerfilled = false;
            }
            else {
                GlobalPoint lastPosition = lastrecHitRef->globalPosition();
                TrackingRecHit* lastTrackingRecHit = lastrecHitRef->hit()->clone();
                // Should also delete the RPCRecHit object cast by dynamic_cast<> ?
                RPCRecHit* lastRPCRecHit = dynamic_cast<RPCRecHit*>(lastTrackingRecHit);
                int lastBX = lastRPCRecHit->BunchX();
                delete lastTrackingRecHit;

                // Check the Y coordinate, shoule be lower than current one
                if(currentPosition.y() >= lastPosition.y())
                    continue;

                // Check the BX, should be larger than current one
                if(currentBX < lastBX)
                    continue;

                // If be the 2nd recHit, just fill it
                bool isinsideRegion = isinsideAngleRange(lastSegment, lastPosition, currentPosition);
                cout << "Check isinsideRegion: " << isinsideRegion << endl;
                if(!isinsideRegion)
                    continue;

                // If cross the edge the recHit should belong to another seed
                bool iscrossanyEdge = iscorssEdge(lastrecHitRef, *it);
                cout << "Check iscrossanyEdge: " << iscrossanyEdge << endl;
                if(iscrossanyEdge)
                    continue;

                // If pass all, add to the seed
                unsigned int NumberinSeed = therecHits.size();
                GlobalVector currentSegment = (GlobalVector)(currentPosition - lastPosition);
                cout << (NumberinSeed + 1) << "th recHit's global position: " << currentPosition.x() << ", " << currentPosition.y() << ", " << currentPosition.z() << ". BX: " << currentBX << endl;
                isrecHitsfound = true;
                therecHits.push_back(*it);

                // if could not find next recHit in the search path, and have enough recHits already, that is the candidate
                bool findNext = complete(currentSegment, *it);
                if(findNext == false && therecHits.size() > 3) {
                    for(ConstMuonRecHitContainer::const_iterator iter = therecHits.begin(); iter != therecHits.end(); iter++)
                        cout << "Find recHit in seed candidate : " << (*iter)->globalPosition().x() << ", " << (*iter)->globalPosition().y() << ", " << (*iter)->globalPosition().z() << endl;
                    checkandfill();
                }

                // Remember to pop the recHit before add another one from the same layer!
                therecHits.pop_back();
            }
        }
    return isrecHitsfound;
}
void RPCCosmicSeedrecHitFinder::configure ( const edm::ParameterSet iConfig)

Definition at line 48 of file RPCCosmicSeedrecHitFinder.cc.

References edm::ParameterSet::getParameter().

                                                                        {

    // Set the configuration
    BxRange = iConfig.getParameter<unsigned int>("BxRange");
    MaxDeltaPhi = iConfig.getParameter<double>("MaxDeltaPhi");
    ClusterSet = iConfig.getParameter< std::vector<int> >("ClusterSet");

    // Set the signal open
    isConfigured = true;
}
void RPCCosmicSeedrecHitFinder::fillrecHits ( )

Definition at line 121 of file RPCCosmicSeedrecHitFinder.cc.

References gather_cfg::cout.

                                            {

    if(isLayerset == false || isConfigured == false || isOutputset == false || isInputset == false || isEdgeset == false) {
        cout << "Not set the IO or not configured yet" << endl;
        return;
    } 

    therecHits.clear();

    if(LayersinRPC.size() == 0) {
        cout << "Not set with any layers" << endl;
        LayersinRPC.clear();
        therecHits.clear();
        isLayerset = false;
    }

    // check the layers, 1=all barrel, 2=all endcap, 3=mix
    unsigned int Component = LayerComponent();
    if(Component == 3)
        isLayersmixed = true;
    else
        isLayersmixed = false;

    GlobalVector initVector(0, 0, 0);
    const MuonRecHitPointer recHitRef;
    isOuterLayerfilled = false;
    complete(initVector, recHitRef);

    // Unset the signal
    LayersinRPC.clear();
    therecHits.clear();
    isLayerset = false;
}
bool RPCCosmicSeedrecHitFinder::iscorssEdge ( const MuonRecHitPointer lastrecHitRef,
const MuonRecHitPointer currentrecHitRef 
) [private]

Definition at line 301 of file RPCCosmicSeedrecHitFinder.cc.

References DetId::rawId(), RPCDetId::region(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

                                                                                                                             {

    bool iscorss = false;

    
    // Check if 2 recHits corss the inner bounds
    GlobalPoint lastPosition = lastrecHitRef->globalPosition();
    GlobalPoint currentPosition = currentrecHitRef->globalPosition();
    GlobalPoint testPosition((lastPosition.x()+currentPosition.x())/2, (lastPosition.y()+currentPosition.y())/2, (lastPosition.z()+currentPosition.z())/2);
    /*
    for(std::vector<BoundPlane>::const_iterator it = innerBounds.begin(); it != innerBounds.end(); it++) {
        //SurfaceOrientation::Side TestSide0 = it->side(currentPosition, 0);
        //SurfaceOrientation::Side TestSide1 = it->side(lastPosition, 0);
        SurfaceOrientation::Side TestSide = it->side(testPosition, 0);
        //cout << "Side of currentPosition: " << TestSide0 << ", Side of lastPosition: " << TestSide1 << ", Side of middlePosition: " << TestSide << endl;
        //if(TestSide != SurfaceOrientation::positiveSide)
            //iscorss = true;
    }
    */

    // Check when mixLayer is not set
    if(isLayersmixed == false) {
        DetId lastId = lastrecHitRef->geographicalId();
        RPCDetId lastRPCId(lastId.rawId());
        int lastRegion = lastRPCId.region();
        DetId currentId = currentrecHitRef->geographicalId();
        RPCDetId currentRPCId(currentId.rawId());
        int currentRegion = currentRPCId.region();
        // Check if 2 recHits from different regions
        if((lastRegion - currentRegion) != 0)
            iscorss = true;
    }

    return iscorss;
}
bool RPCCosmicSeedrecHitFinder::isinsideAngleRange ( const GlobalVector lastSegment,
const GlobalPoint lastPosition,
const GlobalPoint currentPosition 
) [private]

Definition at line 290 of file RPCCosmicSeedrecHitFinder.cc.

References PV3DBase< T, PVType, FrameType >::mag(), PV3DBase< T, PVType, FrameType >::phi(), and relativeConstraints::value.

                                                                                                                                                       {

    bool isinsideAngle = true;
    GlobalVector SegVec = currentPosition - lastPosition;
    if(lastSegment.mag() != 0)
        if(fabs((lastSegment.phi()-SegVec.phi()).value()) > MaxDeltaPhi)
            isinsideAngle = false;
        
    return isinsideAngle;
}
bool RPCCosmicSeedrecHitFinder::isouterLayer ( const MuonRecHitPointer recHitRef) [private]

Definition at line 279 of file RPCCosmicSeedrecHitFinder.cc.

References begin, end, spr::find(), and getHLTprescales::index.

                                                                               {

    bool isinsideLayers = false;
    for(std::vector<unsigned int>::const_iterator it = LayersinRPC.begin(); it != LayersinRPC.end(); it++) {
        MuonRecHitContainer::const_iterator index = find(AllrecHits[*it].begin(), AllrecHits[*it].end(), recHitRef);
        if(index != AllrecHits[*it].end())
            isinsideLayers = true;
    }
    return isinsideLayers;
}
int RPCCosmicSeedrecHitFinder::LayerComponent ( ) [private]

Definition at line 155 of file RPCCosmicSeedrecHitFinder.cc.

References BarrelLayerNumber, and EachEndcapLayerNumber.

                                              {

    bool isBarrel = false;
    bool isEndcap = false;
    for(std::vector<unsigned int>::const_iterator it = LayersinRPC.begin(); it != LayersinRPC.end(); it++) {
        if((*it) < BarrelLayerNumber)
            isBarrel = true;
        if((*it) >= BarrelLayerNumber && (*it) < (BarrelLayerNumber+EachEndcapLayerNumber*2))
            isEndcap = true;
    }
    if(isBarrel == true && isEndcap == true)
        return 3;
    if(isEndcap == true)
        return 2;
    if(isBarrel == true)
        return 1;
    return 0;
}
void RPCCosmicSeedrecHitFinder::setEdge ( const edm::EventSetup iSetup)

Definition at line 70 of file RPCCosmicSeedrecHitFinder.cc.

References edm::EventSetup::get().

                                                                   {
  
    // Get RPCGeometry
    edm::ESHandle<RPCGeometry> rpcGeometry;
    iSetup.get<MuonGeometryRecord>().get(rpcGeometry);

    // Find all chamber in RB1in and collect their surface
    const std::vector<DetId> AllRPCId = rpcGeometry->detIds();
    for(std::vector<DetId>::const_iterator it = AllRPCId.begin(); it != AllRPCId.end(); it++) {
        RPCDetId RPCId(it->rawId());
        int Region = RPCId.region();
        int Station = RPCId.station();
        int Layer = RPCId.layer();
        if(Region == 0 && Station == 1 && Layer == 1) {
            const BoundPlane RPCChamberSurface = rpcGeometry->chamber(RPCId)->surface();
            innerBounds.push_back(RPCChamberSurface);
        }
    }

    // Set the signal open
    isEdgeset = true;
}
void RPCCosmicSeedrecHitFinder::setInput ( MuonRecHitContainer(&)  recHits[RPCLayerNumber])

Definition at line 59 of file RPCCosmicSeedrecHitFinder.cc.

References i, and RPCLayerNumber.

                                                                                       {

    for(unsigned int i = 0; i < RPCLayerNumber; i++) {
        AllrecHits[i].clear();
        AllrecHits[i] = recHits[i];
    }

    // Set the signal open
    isInputset = true;
}
void RPCCosmicSeedrecHitFinder::setLayers ( const std::vector< unsigned int > &  Layers)

Definition at line 114 of file RPCCosmicSeedrecHitFinder.cc.

                                                                               {

    LayersinRPC = Layers;
    // Set the signal open
    isLayerset = true;
}
void RPCCosmicSeedrecHitFinder::setOutput ( RPCSeedFinder Seed)

Definition at line 107 of file RPCCosmicSeedrecHitFinder.cc.

                                                             {

    theSeed = Seed;
    // Set the signal open
    isOutputset = true;
}
void RPCCosmicSeedrecHitFinder::unsetEdge ( )

Definition at line 93 of file RPCCosmicSeedrecHitFinder.cc.

                                          {

    // Clear all surfaces of chambers in RB1in
    innerBounds.clear();
    isEdgeset = false;
}
void RPCCosmicSeedrecHitFinder::unsetInput ( )

Definition at line 100 of file RPCCosmicSeedrecHitFinder.cc.

References i, and RPCLayerNumber.

                                           {

    for(unsigned int i = 0; i < RPCLayerNumber; i++)
        AllrecHits[i].clear();
    isInputset = false;
}

Member Data Documentation

Definition at line 75 of file RPCCosmicSeedrecHitFinder.h.

unsigned int RPCCosmicSeedrecHitFinder::BxRange [private]

Definition at line 59 of file RPCCosmicSeedrecHitFinder.h.

std::vector<int> RPCCosmicSeedrecHitFinder::ClusterSet [private]

Definition at line 60 of file RPCCosmicSeedrecHitFinder.h.

Definition at line 73 of file RPCCosmicSeedrecHitFinder.h.

Definition at line 64 of file RPCCosmicSeedrecHitFinder.h.

Definition at line 67 of file RPCCosmicSeedrecHitFinder.h.

Definition at line 65 of file RPCCosmicSeedrecHitFinder.h.

Definition at line 63 of file RPCCosmicSeedrecHitFinder.h.

Definition at line 74 of file RPCCosmicSeedrecHitFinder.h.

Definition at line 69 of file RPCCosmicSeedrecHitFinder.h.

Definition at line 66 of file RPCCosmicSeedrecHitFinder.h.

std::vector<unsigned int> RPCCosmicSeedrecHitFinder::LayersinRPC [private]

Definition at line 71 of file RPCCosmicSeedrecHitFinder.h.

Definition at line 61 of file RPCCosmicSeedrecHitFinder.h.

Definition at line 76 of file RPCCosmicSeedrecHitFinder.h.

Definition at line 77 of file RPCCosmicSeedrecHitFinder.h.