CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

HLTTrackClusterRemover Class Reference

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

List of all members.

Classes

struct  ParamBlock

Public Member Functions

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

Private Member Functions

template<typename T >
std::auto_ptr
< edmNew::DetSetVector< T > > 
cleanup (const edmNew::DetSetVector< T > &oldClusters, const std::vector< uint8_t > &isGood, reco::ClusterRemovalInfo::Indices &refs, const reco::ClusterRemovalInfo::Indices *oldRefs)
void mergeOld (reco::ClusterRemovalInfo::Indices &refs, const reco::ClusterRemovalInfo::Indices &oldRefs)
void process (const TrackingRecHit *hit, float chi2)
void process (const OmniClusterRef &cluRef, uint32_t subdet)
void readPSet (const edm::ParameterSet &iConfig, const std::string &name, int id1=-1, int id2=-1, int id3=-1, int id4=-1, int id5=-1, int id6=-1)

Private Attributes

std::vector< bool > collectedPixels_
std::vector< bool > collectedRegStrips_
bool doPixel_
bool doStrip_
bool makeProducts_
bool mergeOld_
edm::InputTag oldRemovalInfo_
ParamBlock pblocks_ [NumberOfParamBlocks]
edm::InputTag pixelClusters_
std::vector< uint8_t > pixels
edm::ProductID pixelSourceProdID
edm::InputTag stripClusters_
std::vector< uint8_t > strips
edm::ProductID stripSourceProdID
edm::InputTag trajectories_

Static Private Attributes

static const unsigned int NumberOfParamBlocks = 6

Detailed Description

Definition at line 34 of file HLTTrackClusterRemover.cc.


Constructor & Destructor Documentation

HLTTrackClusterRemover::HLTTrackClusterRemover ( const edm::ParameterSet iConfig)

Definition at line 108 of file HLTTrackClusterRemover.cc.

References doPixel_, doStrip_, Exception, edm::ParameterSet::exists(), lumiContext::fill, edm::ParameterSet::getParameter(), i, mergeOld_, NumberOfParamBlocks, oldRemovalInfo_, pblocks_, and readPSet().

                                                                         :
    trajectories_(iConfig.getParameter<InputTag>("trajectories")),
    doStrip_(iConfig.existsAs<bool>("doStrip") ? iConfig.getParameter<bool>("doStrip") : true),
    doPixel_(iConfig.existsAs<bool>("doPixel") ? iConfig.getParameter<bool>("doPixel") : true),
    stripClusters_(doStrip_ ? iConfig.getParameter<InputTag>("stripClusters") : InputTag("NONE")),
    pixelClusters_(doPixel_ ? iConfig.getParameter<InputTag>("pixelClusters") : InputTag("NONE")),
    mergeOld_(false),
    oldRemovalInfo_(edm::InputTag()),
    makeProducts_(true)
{

  if (iConfig.exists("oldClusterRemovalInfo"))
    {
      oldRemovalInfo_=iConfig.getParameter<InputTag>("oldClusterRemovalInfo");
      if (not (oldRemovalInfo_== edm::InputTag())) mergeOld_=true;
    }

    fill(pblocks_, pblocks_+NumberOfParamBlocks, ParamBlock());
    readPSet(iConfig, "Common",-1);
    if (doPixel_) {
        readPSet(iConfig, "Pixel" ,0,1);
        readPSet(iConfig, "PXB" ,0);
        readPSet(iConfig, "PXE" ,1);
    }
    if (doStrip_) {
        readPSet(iConfig, "Strip" ,2,3,4,5);
        readPSet(iConfig, "StripInner" ,2,3);
        readPSet(iConfig, "StripOuter" ,4,5);
        readPSet(iConfig, "TIB" ,2);
        readPSet(iConfig, "TID" ,3);
        readPSet(iConfig, "TOB" ,4);
        readPSet(iConfig, "TEC" ,5);
    }

    bool usingCharge = false;
    for (size_t i = 0; i < NumberOfParamBlocks; ++i) {
        if (!pblocks_[i].isSet_) throw cms::Exception("Configuration Error") << "HLTTrackClusterRemover: Missing configuration for detector with subDetID = " << (i+1);
        if (pblocks_[i].usesCharge_ && !usingCharge) {
            throw cms::Exception("Configuration Error") << "HLTTrackClusterRemover: Configuration for subDetID = " << (i+1) << " uses cluster charge, which is not enabled.";
        }
    }

    //produces<edmNew::DetSetVector<SiPixelClusterRefNew> >();
    //produces<edmNew::DetSetVector<SiStripRecHit1D::ClusterRegionalRef> >();
    
    produces< edm::ContainerMask<edmNew::DetSetVector<SiPixelCluster> > >();
    produces< edm::ContainerMask<edm::LazyGetter<SiStripCluster> > >();

}
HLTTrackClusterRemover::~HLTTrackClusterRemover ( )

Definition at line 159 of file HLTTrackClusterRemover.cc.

{
}

Member Function Documentation

template<typename T >
auto_ptr< edmNew::DetSetVector< T > > HLTTrackClusterRemover::cleanup ( const edmNew::DetSetVector< T > &  oldClusters,
const std::vector< uint8_t > &  isGood,
reco::ClusterRemovalInfo::Indices refs,
const reco::ClusterRemovalInfo::Indices oldRefs 
) [private]

Definition at line 174 of file HLTTrackClusterRemover.cc.

References edmNew::DetSetVector< T >::begin(), edmNew::DetSetVector< T >::data(), edmNew::DetSetVector< T >::dataSize(), edmNew::DetSetVector< T >::end(), getHLTprescales::index, mergeOld(), convertSQLitetoXML_cfg::output, and edmNew::DetSetVector< T >::size().

                                                                                                               {
    typedef typename edmNew::DetSetVector<T>             DSV;
    typedef typename edmNew::DetSetVector<T>::FastFiller DSF;
    typedef typename edmNew::DetSet<T>                   DS;
    auto_ptr<DSV> output(new DSV());
    output->reserve(oldClusters.size(), oldClusters.dataSize());

    unsigned int countOld=0;
    unsigned int countNew=0;

    // cluster removal loop
    const T * firstOffset = & oldClusters.data().front();
    for (typename DSV::const_iterator itdet = oldClusters.begin(), enddet = oldClusters.end(); itdet != enddet; ++itdet) {
        DS oldDS = *itdet;

        if (oldDS.empty()) continue; // skip empty detsets

        uint32_t id = oldDS.detId();
        DSF outds(*output, id);

        for (typename DS::const_iterator it = oldDS.begin(), ed = oldDS.end(); it != ed; ++it) {
            uint32_t index = ((&*it) - firstOffset);
            countOld++;
            if (isGood[index]) { 
                outds.push_back(*it);
                countNew++;
                refs.push_back(index); 
                //std::cout << "HLTTrackClusterRemover::cleanup " << typeid(T).name() << " reference " << index << " to " << (refs.size() - 1) << std::endl;
            }

        }
        if (outds.empty()) outds.abort(); // not write in an empty DSV
    }
    //    double fraction = countNew  / (double) countOld;
    //    std::cout<<"fraction: "<<fraction<<std::endl;
    if (oldRefs != 0) mergeOld(refs, *oldRefs);
    return output;
}
void HLTTrackClusterRemover::mergeOld ( reco::ClusterRemovalInfo::Indices refs,
const reco::ClusterRemovalInfo::Indices oldRefs 
) [private]

Definition at line 163 of file HLTTrackClusterRemover.cc.

References i, and n.

Referenced by cleanup().

{
        for (size_t i = 0, n = refs.size(); i < n; ++i) {
            refs[i] = oldRefs[refs[i]];
       }
}
void HLTTrackClusterRemover::process ( const OmniClusterRef cluRef,
uint32_t  subdet 
) [inline, private]

Definition at line 214 of file HLTTrackClusterRemover.cc.

References collectedRegStrips_, OmniClusterRef::id(), OmniClusterRef::key(), and stripSourceProdID.

                                                                                       {
   if (clusterReg.id() != stripSourceProdID) throw cms::Exception("Inconsistent Data") <<
    "HLTTrackClusterRemover: strip cluster ref from Product ID = " << clusterReg.id() <<
    " does not match with source cluster collection (ID = " << stripSourceProdID << ")\n.";
  if (collectedRegStrips_.size()<=clusterReg.key()){
    edm::LogError("BadCollectionSize")<<collectedRegStrips_.size()<<" is smaller than "<<clusterReg.key();
    assert(collectedRegStrips_.size()>clusterReg.key());
  }
  collectedRegStrips_[clusterReg.key()]=true;
}
void HLTTrackClusterRemover::process ( const TrackingRecHit hit,
float  chi2 
) [inline, private]

Definition at line 227 of file HLTTrackClusterRemover.cc.

References collectedPixels_, cond::rpcobgas::detid, doPixel_, doStrip_, Exception, TrackingRecHit::geographicalId(), HLTTrackClusterRemover::ParamBlock::maxSize_, NumberOfParamBlocks, ProjectedSiStripRecHit2D::originalHit(), pblocks_, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, pixelSourceProdID, DetId::rawId(), and DetId::subdetId().

Referenced by produce().

                                                                          {
    DetId detid = hit->geographicalId(); 
    uint32_t subdet = detid.subdetId();

    assert ((subdet > 0) && (subdet <= NumberOfParamBlocks));

    // chi2 cut
    if (chi2 > pblocks_[subdet-1].maxChi2_) return;

    if ((subdet == PixelSubdetector::PixelBarrel) || (subdet == PixelSubdetector::PixelEndcap)) {
      //      std::cout<<"process pxl hit"<<std::endl;
        if (!doPixel_) return;
        // this is a pixel, and i *know* it is
        const SiPixelRecHit *pixelHit = static_cast<const SiPixelRecHit *>(hit);

        SiPixelRecHit::ClusterRef cluster = pixelHit->cluster();

        if (cluster.id() != pixelSourceProdID) throw cms::Exception("Inconsistent Data") << 
                "HLTTrackClusterRemover: pixel cluster ref from Product ID = " << cluster.id() << 
                " does not match with source cluster collection (ID = " << pixelSourceProdID << ")\n.";

        assert(cluster.id() == pixelSourceProdID);
//DBG// cout << "HIT NEW PIXEL DETID = " << detid.rawId() << ", Cluster [ " << cluster.key().first << " / " <<  cluster.key().second << " ] " << endl;

        // if requested, cut on cluster size
        if (pblocks_[subdet-1].usesSize_ && (cluster->pixels().size() > pblocks_[subdet-1].maxSize_)) return;

        // mark as used
        //pixels[cluster.key()] = false;
        assert(collectedPixels_.size() > cluster.key());
        collectedPixels_[cluster.key()]=true;
    } else { // aka Strip
        if (!doStrip_) return;
        const type_info &hitType = typeid(*hit);
        if (hitType == typeid(SiStripRecHit2D)) {
            const SiStripRecHit2D *stripHit = static_cast<const SiStripRecHit2D *>(hit);
//DBG//     cout << "Plain RecHit 2D: " << endl;
            process(stripHit->omniClusterRef(),subdet);}
        else if (hitType == typeid(SiStripRecHit1D)) {
          const SiStripRecHit1D *hit1D = static_cast<const SiStripRecHit1D *>(hit);
          process(hit1D->omniClusterRef(),subdet);
        } else if (hitType == typeid(SiStripMatchedRecHit2D)) {
            const SiStripMatchedRecHit2D *matchHit = static_cast<const SiStripMatchedRecHit2D *>(hit);
//DBG//     cout << "Matched RecHit 2D: " << endl;
            process(matchHit->monoClusterRef(),subdet);
            process(matchHit->stereoClusterRef(),subdet);
        } else if (hitType == typeid(ProjectedSiStripRecHit2D)) {
            const ProjectedSiStripRecHit2D *projHit = static_cast<const ProjectedSiStripRecHit2D *>(hit);
//DBG//     cout << "Projected RecHit 2D: " << endl;
            process(projHit->originalHit().omniClusterRef(),subdet);
        } else throw cms::Exception("NOT IMPLEMENTED") << "Don't know how to handle " << hitType.name() << " on detid " << detid.rawId() << "\n";
    }
}
void HLTTrackClusterRemover::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 293 of file HLTTrackClusterRemover.cc.

References collectedPixels_, collectedRegStrips_, prof2calltree::count, doPixel_, doStrip_, lumiContext::fill, edm::Event::getByLabel(), edm::HandleBase::id(), TrackingRecHit::isValid(), LogDebug, Trajectory::measurements(), mergeOld_, oldRemovalInfo_, clustersummaryproducer_cfg::pixelClusters, pixelClusters_, pixelSourceProdID, process(), edm::Event::put(), clustersummaryproducer_cfg::stripClusters, stripClusters_, stripSourceProdID, and trajectories_.

{
    ProductID pixelOldProdID, stripOldProdID;

    Handle<edmNew::DetSetVector<SiPixelCluster> > pixelClusters;
    if (doPixel_) {
        iEvent.getByLabel(pixelClusters_, pixelClusters);
        pixelSourceProdID = pixelClusters.id();
    }

    Handle<edm::LazyGetter<SiStripCluster> > stripClusters;
    if (doStrip_) {
        iEvent.getByLabel(stripClusters_, stripClusters);
        stripSourceProdID = stripClusters.id();
    }

    //Handle<TrajTrackAssociationCollection> trajectories; 
    Handle<vector<Trajectory> > trajectories; 
    iEvent.getByLabel(trajectories_, trajectories);

    typedef edm::ContainerMask<edmNew::DetSetVector<SiPixelCluster> > PixelMaskContainer;
    typedef edm::ContainerMask<edm::LazyGetter<SiStripCluster> > StripMaskContainer;
    if(mergeOld_) {
      edm::Handle<PixelMaskContainer> oldPxlMask;
      edm::Handle<StripMaskContainer> oldStrMask;
      iEvent.getByLabel(oldRemovalInfo_,oldPxlMask);
      iEvent.getByLabel(oldRemovalInfo_,oldStrMask);
      LogDebug("TrackClusterRemover")<<"to merge in, "<<oldStrMask->size()<<" strp and "<<oldPxlMask->size()<<" pxl";
      oldStrMask->copyMaskTo(collectedRegStrips_);
      oldPxlMask->copyMaskTo(collectedPixels_);
      collectedRegStrips_.resize(stripClusters->size());
    }else {
      collectedRegStrips_.resize(stripClusters->size()); fill(collectedRegStrips_.begin(), collectedRegStrips_.end(), false);
      collectedPixels_.resize(pixelClusters->dataSize()); fill(collectedPixels_.begin(), collectedPixels_.end(), false);
    } 


    //for (TrajTrackAssociationCollection::const_iterator it = trajectories->begin(), ed = trajectories->end(); it != ed; ++it)  {
    //    const Trajectory &tj = * it->key;
    for (vector<Trajectory>::const_iterator it = trajectories->begin(), ed = trajectories->end(); it != ed; ++it)  {
        const Trajectory &tj = * it;
        const vector<TrajectoryMeasurement> &tms = tj.measurements();
        vector<TrajectoryMeasurement>::const_iterator itm, endtm;
        for (itm = tms.begin(), endtm = tms.end(); itm != endtm; ++itm) {
            const TrackingRecHit *hit = itm->recHit()->hit();
            if (!hit->isValid()) continue; 
            //      std::cout<<"process hit"<<std::endl;
            process( hit, itm->estimate() );
        }
    }
    
    std::auto_ptr<StripMaskContainer> removedStripClusterMask(
       new StripMaskContainer(edm::RefProd<edm::LazyGetter<SiStripCluster> >(stripClusters),collectedRegStrips_));
    LogDebug("TrackClusterRemover")<<"total strip to skip: "<<std::count(collectedRegStrips_.begin(),collectedRegStrips_.end(),true);
    iEvent.put( removedStripClusterMask );

    std::auto_ptr<PixelMaskContainer> removedPixelClusterMask(
       new PixelMaskContainer(edm::RefProd<edmNew::DetSetVector<SiPixelCluster> >(pixelClusters),collectedPixels_));      
    LogDebug("TrackClusterRemover")<<"total pxl to skip: "<<std::count(collectedPixels_.begin(),collectedPixels_.end(),true);
    iEvent.put( removedPixelClusterMask );
    
}
void HLTTrackClusterRemover::readPSet ( const edm::ParameterSet iConfig,
const std::string &  name,
int  id1 = -1,
int  id2 = -1,
int  id3 = -1,
int  id4 = -1,
int  id5 = -1,
int  id6 = -1 
) [private]

Definition at line 90 of file HLTTrackClusterRemover.cc.

References edm::ParameterSet::exists(), lumiContext::fill, and edm::ParameterSet::getParameter().

Referenced by HLTTrackClusterRemover().

{
    if (iConfig.exists(name)) {
        ParamBlock pblock(iConfig.getParameter<ParameterSet>(name));
        if (id1 == -1) {
            fill(pblocks_, pblocks_+NumberOfParamBlocks, pblock);
        } else {
            pblocks_[id1] = pblock;
            if (id2 != -1) pblocks_[id2] = pblock;
            if (id3 != -1) pblocks_[id3] = pblock;
            if (id4 != -1) pblocks_[id4] = pblock;
            if (id5 != -1) pblocks_[id5] = pblock;
            if (id6 != -1) pblocks_[id6] = pblock;
        }
    }
}

Member Data Documentation

std::vector<bool> HLTTrackClusterRemover::collectedPixels_ [private]

Definition at line 81 of file HLTTrackClusterRemover.cc.

Referenced by process(), and produce().

std::vector<bool> HLTTrackClusterRemover::collectedRegStrips_ [private]

Definition at line 80 of file HLTTrackClusterRemover.cc.

Referenced by process(), and produce().

Definition at line 56 of file HLTTrackClusterRemover.cc.

Referenced by HLTTrackClusterRemover(), process(), and produce().

Definition at line 56 of file HLTTrackClusterRemover.cc.

Referenced by HLTTrackClusterRemover(), process(), and produce().

Definition at line 79 of file HLTTrackClusterRemover.cc.

Definition at line 58 of file HLTTrackClusterRemover.cc.

Referenced by HLTTrackClusterRemover(), and produce().

const unsigned int HLTTrackClusterRemover::NumberOfParamBlocks = 6 [static, private]

Definition at line 53 of file HLTTrackClusterRemover.cc.

Referenced by HLTTrackClusterRemover(), and process().

Definition at line 59 of file HLTTrackClusterRemover.cc.

Referenced by HLTTrackClusterRemover(), and produce().

Definition at line 61 of file HLTTrackClusterRemover.cc.

Referenced by HLTTrackClusterRemover(), and process().

Definition at line 57 of file HLTTrackClusterRemover.cc.

Referenced by produce().

std::vector<uint8_t> HLTTrackClusterRemover::pixels [private]

Definition at line 65 of file HLTTrackClusterRemover.cc.

Definition at line 66 of file HLTTrackClusterRemover.cc.

Referenced by process(), and produce().

Definition at line 57 of file HLTTrackClusterRemover.cc.

Referenced by produce().

std::vector<uint8_t> HLTTrackClusterRemover::strips [private]

Definition at line 65 of file HLTTrackClusterRemover.cc.

Definition at line 66 of file HLTTrackClusterRemover.cc.

Referenced by process(), and produce().

Definition at line 55 of file HLTTrackClusterRemover.cc.

Referenced by produce().