Definition at line 38 of file SeedClusterRemover.cc.
SeedClusterRemover::SeedClusterRemover | ( | const edm::ParameterSet & | iConfig | ) |
Definition at line 116 of file SeedClusterRemover.cc.
References clusterWasteSolution_, doPixel_, doStrip_, Exception, edm::ParameterSet::exists(), lumiContext::fill, filterTracks_, edm::ParameterSet::getParameter(), i, NumberOfParamBlocks, overrideTrkQuals_, pblocks_, reco::TrackBase::qualityByName(), readPSet(), AlCaHLTBitMon_QueryRunRegistry::string, trackQuality_, and reco::TrackBase::undefQuality.
: 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_(iConfig.exists("oldClusterRemovalInfo")), oldRemovalInfo_(mergeOld_ ? iConfig.getParameter<InputTag>("oldClusterRemovalInfo") : InputTag("NONE")), clusterWasteSolution_(true) { if (iConfig.exists("overrideTrkQuals")) overrideTrkQuals_.push_back(iConfig.getParameter<edm::InputTag>("overrideTrkQuals")); if (iConfig.exists("clusterLessSolution")) clusterWasteSolution_=!iConfig.getParameter<bool>("clusterLessSolution"); if (doPixel_ && clusterWasteSolution_) produces< edmNew::DetSetVector<SiPixelCluster> >(); if (doStrip_ && clusterWasteSolution_) produces< edmNew::DetSetVector<SiStripCluster> >(); if (clusterWasteSolution_) produces< ClusterRemovalInfo >(); 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") << "SeedClusterRemover: Missing configuration for detector with subDetID = " << (i+1); if (pblocks_[i].usesCharge_ && !usingCharge) { throw cms::Exception("Configuration Error") << "SeedClusterRemover: Configuration for subDetID = " << (i+1) << " uses cluster charge, which is not enabled."; } } if (!clusterWasteSolution_){ produces<edm::ContainerMask<edmNew::DetSetVector<SiPixelCluster> > >(); produces<edm::ContainerMask<edmNew::DetSetVector<SiStripCluster> > >(); } trackQuality_=reco::TrackBase::undefQuality; filterTracks_=false; if (iConfig.exists("TrackQuality")){ filterTracks_=true; trackQuality_=reco::TrackBase::qualityByName(iConfig.getParameter<std::string>("TrackQuality")); } }
SeedClusterRemover::~SeedClusterRemover | ( | ) |
Definition at line 173 of file SeedClusterRemover.cc.
{ }
auto_ptr< edmNew::DetSetVector< T > > SeedClusterRemover::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 188 of file SeedClusterRemover.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().
Referenced by produce().
{ 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 << "SeedClusterRemover::cleanup " << typeid(T).name() << " reference " << index << " to " << (refs.size() - 1) << std::endl; } } if (outds.empty()) outds.abort(); // not write in an empty DSV } if (oldRefs != 0) mergeOld(refs, *oldRefs); return output; }
void SeedClusterRemover::mergeOld | ( | reco::ClusterRemovalInfo::Indices & | refs, |
const reco::ClusterRemovalInfo::Indices & | oldRefs | ||
) | [private] |
void SeedClusterRemover::process | ( | const OmniClusterRef & | cluRef, |
uint32_t | subdet | ||
) | [inline, private] |
Definition at line 228 of file SeedClusterRemover.cc.
References OmniClusterRef::cluster_strip(), clusterWasteSolution_, collectedStrips_, SeedClusterRemover::ParamBlock::maxSize_, pblocks_, strips, and stripSourceProdID.
{ SiStripRecHit2D::ClusterRef cluster = ocluster.cluster_strip(); if (cluster.id() != stripSourceProdID) throw cms::Exception("Inconsistent Data") << "SeedClusterRemover: strip cluster ref from Product ID = " << cluster.id() << " does not match with source cluster collection (ID = " << stripSourceProdID << ")\n."; assert(cluster.id() == stripSourceProdID); if (pblocks_[subdet-1].usesSize_ && (cluster->amplitudes().size() > pblocks_[subdet-1].maxSize_)) return; strips[cluster.key()] = false; //if (!clusterWasteSolution_) collectedStrip[hit->geographicalId()].insert(cluster); assert(collectedStrips_.size() > cluster.key()); //assert(hit->geographicalId() == cluster->geographicalId()); //This condition fails if (!clusterWasteSolution_) collectedStrips_[cluster.key()]=true; }
void SeedClusterRemover::process | ( | const TrackingRecHit * | hit, |
float | chi2 | ||
) | [inline, private] |
Definition at line 245 of file SeedClusterRemover.cc.
References clusterWasteSolution_, collectedPixels_, cond::rpcobgas::detid, doPixel_, doStrip_, Exception, TrackingRecHit::geographicalId(), SeedClusterRemover::ParamBlock::maxSize_, NumberOfParamBlocks, ProjectedSiStripRecHit2D::originalHit(), pblocks_, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, pixels, 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)) { 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") << "SeedClusterRemover: 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; //if(!clusterWasteSolution_) collectedPixel[detid.rawId()].insert(cluster); assert(collectedPixels_.size() > cluster.key()); //assert(detid.rawId() == cluster->geographicalId()); //This condition fails if(!clusterWasteSolution_) 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 SeedClusterRemover::produce | ( | edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [virtual] |
Implements edm::EDProducer.
Definition at line 314 of file SeedClusterRemover.cc.
References cleanup(), clusterWasteSolution_, collectedPixels_, collectedStrips_, prof2calltree::count, doPixel_, doStrip_, edm::InputTag::encode(), Exception, lumiContext::fill, edm::Event::getByLabel(), edm::HandleBase::id(), LogDebug, mergeOld_, oldRemovalInfo_, clustersummaryproducer_cfg::pixelClusters, pixelClusters_, pixels, pixelSourceProdID, process(), edm::Event::put(), edm::ProductID::reset(), clustersummaryproducer_cfg::stripClusters, stripClusters_, strips, stripSourceProdID, and trajectories_.
{ ProductID pixelOldProdID, stripOldProdID; Handle<edmNew::DetSetVector<SiPixelCluster> > pixelClusters; if (doPixel_) { iEvent.getByLabel(pixelClusters_, pixelClusters); pixelSourceProdID = pixelClusters.id(); } //DBG// std::cout << "SeedClusterRemover: Read pixel " << pixelClusters_.encode() << " = ID " << pixelSourceProdID << std::endl; Handle<edmNew::DetSetVector<SiStripCluster> > stripClusters; if (doStrip_) { iEvent.getByLabel(stripClusters_, stripClusters); stripSourceProdID = stripClusters.id(); } //DBG// std::cout << "SeedClusterRemover: Read strip " << stripClusters_.encode() << " = ID " << stripSourceProdID << std::endl; auto_ptr<ClusterRemovalInfo> cri; if (clusterWasteSolution_){ if (doStrip_ && doPixel_) cri.reset(new ClusterRemovalInfo(pixelClusters, stripClusters)); else if (doStrip_) cri.reset(new ClusterRemovalInfo(stripClusters)); else if (doPixel_) cri.reset(new ClusterRemovalInfo(pixelClusters)); } Handle<ClusterRemovalInfo> oldRemovalInfo; if (mergeOld_ && clusterWasteSolution_) { iEvent.getByLabel(oldRemovalInfo_, oldRemovalInfo); // Check ProductIDs if ( (oldRemovalInfo->stripNewRefProd().id() == stripClusters.id()) && (oldRemovalInfo->pixelNewRefProd().id() == pixelClusters.id()) ) { cri->getOldClustersFrom(*oldRemovalInfo); pixelOldProdID = oldRemovalInfo->pixelRefProd().id(); stripOldProdID = oldRemovalInfo->stripRefProd().id(); } else { throw cms::Exception("Inconsistent Data") << "SeedClusterRemover: " << "Input collection product IDs are [pixel: " << pixelClusters.id() << ", strip: " << stripClusters.id() << "] \n" << "\t but the *old* ClusterRemovalInfo " << oldRemovalInfo_.encode() << " refers as 'new product ids' to " << "[pixel: " << oldRemovalInfo->pixelNewRefProd().id() << ", strip: " << oldRemovalInfo->stripNewRefProd().id() << "]\n" << "NOTA BENE: when running SeedClusterRemover with an old ClusterRemovalInfo the hits in the trajectory MUST be already re-keyed.\n"; } } else { // then Old == Source pixelOldProdID = pixelSourceProdID; stripOldProdID = stripSourceProdID; } if (doStrip_) { strips.resize(stripClusters->dataSize()); fill(strips.begin(), strips.end(), true); } if (doPixel_) { pixels.resize(pixelClusters->dataSize()); fill(pixels.begin(), pixels.end(), true); } typedef edm::ContainerMask<edmNew::DetSetVector<SiPixelCluster> > PixelMaskContainer; typedef edm::ContainerMask<edmNew::DetSetVector<SiStripCluster> > StripMaskContainer; if(mergeOld_) { edm::Handle<PixelMaskContainer> oldPxlMask; edm::Handle<StripMaskContainer> oldStrMask; iEvent.getByLabel(oldRemovalInfo_,oldPxlMask); iEvent.getByLabel(oldRemovalInfo_,oldStrMask); LogDebug("SeedClusterRemover")<<"to merge in, "<<oldStrMask->size()<<" strp and "<<oldPxlMask->size()<<" pxl"; oldStrMask->copyMaskTo(collectedStrips_); oldPxlMask->copyMaskTo(collectedPixels_); }else { collectedStrips_.resize(stripClusters->dataSize()); fill(collectedStrips_.begin(), collectedStrips_.end(), false); collectedPixels_.resize(pixelClusters->dataSize()); fill(collectedPixels_.begin(), collectedPixels_.end(), false); } edm::Handle<TrajectorySeedCollection> seeds; iEvent.getByLabel(trajectories_,seeds); TrajectorySeedCollection::const_iterator seed=seeds->begin(); for (;seed!=seeds->end();++seed){ TrajectorySeed::range hits=seed->recHits(); TrajectorySeed::const_iterator hit=hits.first; for (;hit!=hits.second;++hit){ if (!hit->isValid()) continue; process( &(*hit), 0. ); } } if (doPixel_ && clusterWasteSolution_) { auto_ptr<edmNew::DetSetVector<SiPixelCluster> > newPixelClusters = cleanup(*pixelClusters, pixels, cri->pixelIndices(), mergeOld_ ? &oldRemovalInfo->pixelIndices() : 0); OrphanHandle<edmNew::DetSetVector<SiPixelCluster> > newPixels = iEvent.put(newPixelClusters); //DBG// std::cout << "SeedClusterRemover: Wrote pixel " << newPixels.id() << " from " << pixelSourceProdID << std::endl; cri->setNewPixelClusters(newPixels); } if (doStrip_ && clusterWasteSolution_) { auto_ptr<edmNew::DetSetVector<SiStripCluster> > newStripClusters = cleanup(*stripClusters, strips, cri->stripIndices(), mergeOld_ ? &oldRemovalInfo->stripIndices() : 0); OrphanHandle<edmNew::DetSetVector<SiStripCluster> > newStrips = iEvent.put(newStripClusters); //DBG// std::cout << "SeedClusterRemover: Wrote strip " << newStrips.id() << " from " << stripSourceProdID << std::endl; cri->setNewStripClusters(newStrips); } if (clusterWasteSolution_) { // double fraction_pxl= cri->pixelIndices().size() / (double) pixels.size(); // double fraction_strp= cri->stripIndices().size() / (double) strips.size(); // edm::LogWarning("SeedClusterRemover")<<" fraction: " << fraction_pxl <<" "<<fraction_strp; iEvent.put(cri); } pixels.clear(); strips.clear(); if (!clusterWasteSolution_){ //auto_ptr<edmNew::DetSetVector<SiPixelClusterRefNew> > removedPixelClsuterRefs(new edmNew::DetSetVector<SiPixelClusterRefNew>()); //auto_ptr<edmNew::DetSetVector<SiStripRecHit1D::ClusterRef> > removedStripClsuterRefs(new edmNew::DetSetVector<SiStripRecHit1D::ClusterRef>()); std::auto_ptr<StripMaskContainer> removedStripClusterMask( new StripMaskContainer(edm::RefProd<edmNew::DetSetVector<SiStripCluster> >(stripClusters),collectedStrips_)); LogDebug("SeedClusterRemover")<<"total strip to skip: "<<std::count(collectedStrips_.begin(),collectedStrips_.end(),true); iEvent.put( removedStripClusterMask ); std::auto_ptr<PixelMaskContainer> removedPixelClusterMask( new PixelMaskContainer(edm::RefProd<edmNew::DetSetVector<SiPixelCluster> >(pixelClusters),collectedPixels_)); LogDebug("SeedClusterRemover")<<"total pxl to skip: "<<std::count(collectedPixels_.begin(),collectedPixels_.end(),true); iEvent.put( removedPixelClusterMask ); } }
void SeedClusterRemover::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 98 of file SeedClusterRemover.cc.
References edm::ParameterSet::exists(), lumiContext::fill, and edm::ParameterSet::getParameter().
Referenced by SeedClusterRemover().
{ 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; } } }
bool SeedClusterRemover::clusterWasteSolution_ [private] |
Definition at line 85 of file SeedClusterRemover.cc.
Referenced by process(), produce(), and SeedClusterRemover().
std::vector<bool> SeedClusterRemover::collectedPixels_ [private] |
Definition at line 89 of file SeedClusterRemover.cc.
std::vector<bool> SeedClusterRemover::collectedStrips_ [private] |
Definition at line 88 of file SeedClusterRemover.cc.
bool SeedClusterRemover::doPixel_ [private] |
Definition at line 61 of file SeedClusterRemover.cc.
Referenced by process(), produce(), and SeedClusterRemover().
bool SeedClusterRemover::doStrip_ [private] |
Definition at line 61 of file SeedClusterRemover.cc.
Referenced by process(), produce(), and SeedClusterRemover().
bool SeedClusterRemover::filterTracks_ [private] |
Definition at line 86 of file SeedClusterRemover.cc.
Referenced by SeedClusterRemover().
bool SeedClusterRemover::mergeOld_ [private] |
Definition at line 63 of file SeedClusterRemover.cc.
Referenced by produce().
const unsigned int SeedClusterRemover::NumberOfParamBlocks = 6 [static, private] |
Definition at line 57 of file SeedClusterRemover.cc.
Referenced by process(), and SeedClusterRemover().
Definition at line 64 of file SeedClusterRemover.cc.
Referenced by produce().
std::vector<edm::InputTag> SeedClusterRemover::overrideTrkQuals_ [private] |
Definition at line 60 of file SeedClusterRemover.cc.
Referenced by SeedClusterRemover().
Definition at line 66 of file SeedClusterRemover.cc.
Referenced by process(), and SeedClusterRemover().
Definition at line 62 of file SeedClusterRemover.cc.
Referenced by produce().
std::vector<uint8_t> SeedClusterRemover::pixels [private] |
Definition at line 70 of file SeedClusterRemover.cc.
Definition at line 71 of file SeedClusterRemover.cc.
Definition at line 62 of file SeedClusterRemover.cc.
Referenced by produce().
std::vector<uint8_t> SeedClusterRemover::strips [private] |
Definition at line 70 of file SeedClusterRemover.cc.
Definition at line 71 of file SeedClusterRemover.cc.
Definition at line 87 of file SeedClusterRemover.cc.
Referenced by SeedClusterRemover().
Definition at line 59 of file SeedClusterRemover.cc.
Referenced by produce().