CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

SiStripQualityHotStripIdentifier Class Reference

#include <SiStripQualityHotStripIdentifier.h>

Inheritance diagram for SiStripQualityHotStripIdentifier:
ConditionDBWriter< SiStripBadStrip > edm::EDAnalyzer

List of all members.

Public Member Functions

 SiStripQualityHotStripIdentifier (const edm::ParameterSet &)
 ~SiStripQualityHotStripIdentifier ()

Private Member Functions

void algoAnalyze (const edm::Event &, const edm::EventSetup &)
void algoBeginJob (const edm::EventSetup &)
void algoBeginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &)
void algoBeginRun (const edm::Run &, const edm::EventSetup &)
void algoEndJob ()
void bookHistos ()
void fillHisto (uint32_t detid, float value)
SiStripBadStripgetNewObject ()
void resetHistos ()

Private Attributes

edm::InputTag Cluster_src_
SiStrip::QualityHistosMap ClusterPositionHistoMap
const edm::ParameterSet conf_
std::string dataLabel_
edm::FileInPath fp_
unsigned long long m_cacheID_
unsigned short MaxClusterWidth_
unsigned short MinClusterWidth_
SiStripDetInfoFileReaderreader
edm::ESHandle< SiStripQualitySiStripQuality_
edm::InputTag Track_src_
bool tracksCollection_in_EventTree

Detailed Description

Definition at line 20 of file SiStripQualityHotStripIdentifier.h.


Constructor & Destructor Documentation

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

Definition at line 20 of file SiStripQualityHotStripIdentifier.cc.

References bookHistos(), fp_, edm::FileInPath::fullPath(), edm::ParameterSet::getUntrackedParameter(), MaxClusterWidth_, MinClusterWidth_, MultipleCompare::pset, reader, and python::OfflineSiStripConfigDb_cff::SiStripDetInfoFileReader.

                                                                                                 : ConditionDBWriter<SiStripBadStrip>(iConfig),
  m_cacheID_(0), 
  dataLabel_(iConfig.getUntrackedParameter<std::string>("dataLabel","")),
  conf_(iConfig), 
  fp_(iConfig.getUntrackedParameter<edm::FileInPath>("file",edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"))),
  Cluster_src_(iConfig.getParameter<edm::InputTag>( "Cluster_src" )),
  Track_src_(iConfig.getUntrackedParameter<edm::InputTag>( "Track_src" )),
  tracksCollection_in_EventTree(iConfig.getUntrackedParameter<bool>("RemoveTrackClusters",false))
{
  reader = new SiStripDetInfoFileReader(fp_.fullPath());  

  edm::ParameterSet pset=iConfig.getUntrackedParameter< edm::ParameterSet > ("ClusterSelection",edm::ParameterSet());
  MinClusterWidth_=pset.getUntrackedParameter<uint32_t>("minWidth",1);
  MaxClusterWidth_=pset.getUntrackedParameter<uint32_t>("maxWidth",1000);

  bookHistos();
}
SiStripQualityHotStripIdentifier::~SiStripQualityHotStripIdentifier ( )

Definition at line 38 of file SiStripQualityHotStripIdentifier.cc.

                                                                   {
}

Member Function Documentation

void SiStripQualityHotStripIdentifier::algoAnalyze ( const edm::Event e,
const edm::EventSetup eSetup 
) [private, virtual]

Reimplemented from ConditionDBWriter< SiStripBadStrip >.

Definition at line 137 of file SiStripQualityHotStripIdentifier.cc.

References edm::DetSetVector< T >::begin(), SiStripRecHit2D::cluster(), Cluster_src_, edm::DetSetVector< T >::end(), fillHisto(), spr::find(), edm::Event::getByLabel(), i, edm::isDebugEnabled(), TrackingRecHit::isValid(), edm::HandleBase::isValid(), LogTrace, MaxClusterWidth_, SiStripMatchedRecHit2D::monoHit(), ProjectedSiStripRecHit2D::originalHit(), edm::Handle< T >::product(), findQualityFiles::size, edm::DetSet< T >::size(), SiStripMatchedRecHit2D::stereoHit(), Track_src_, and tracksCollection_in_EventTree.

                                                                                                {
  edm::Handle< edm::DetSetVector<SiStripCluster> >  dsv_SiStripCluster;
  e.getByLabel( Cluster_src_, dsv_SiStripCluster);    
      
  edm::Handle<reco::TrackCollection> trackCollection;
  if(tracksCollection_in_EventTree){
    e.getByLabel(Track_src_, trackCollection);
    if(!trackCollection.isValid()){
      edm::LogError("SiStripQualityHotStripIdentifier")<<" [SiStripQualityHotStripIdentifier::algoAnalyze] missing trackCollection with label " << Track_src_ <<std::endl;
    }
  }

  std::set<const void*> vPSiStripCluster;    
  //Perform track study
  if (tracksCollection_in_EventTree){
   
    const reco::TrackCollection tC = *(trackCollection.product());
    int i=0;
    for (reco::TrackCollection::const_iterator track=tC.begin(); track!=tC.end(); track++){
      LogTrace("SiStripQualityHotStripIdentifier")
        << "Track number "<< i+1 
        << "\n\tmomentum: " << track->momentum()
        << "\n\tPT: " << track->pt()
        << "\n\tvertex: " << track->vertex()
        << "\n\timpact parameter: " << track->d0()
        << "\n\tcharge: " << track->charge()
        << "\n\tnormalizedChi2: " << track->normalizedChi2() 
        <<"\n\tFrom EXTRA : "
        <<"\n\t\touter PT "<< track->outerPt()<<std::endl;

      //Loop on rechits
      for (trackingRecHit_iterator it = track->recHitsBegin();  it != track->recHitsEnd(); ++it){
        const TrackingRecHit* recHit = &(**it);
        
        if (!recHit->isValid()){
          LogTrace("SiStripQualityHotStripIdentifier") <<"\t\t Invalid Hit "<<std::endl;
          continue;
        }
        
        const SiStripRecHit2D* singleHit=dynamic_cast<const SiStripRecHit2D*>(recHit);
        const SiStripMatchedRecHit2D* matchedHit=dynamic_cast<const SiStripMatchedRecHit2D*>(recHit);
        const ProjectedSiStripRecHit2D* projectedHit=dynamic_cast<const ProjectedSiStripRecHit2D*>(recHit);

        if(matchedHit){
          vPSiStripCluster.insert((void *)&*(matchedHit->monoHit()->cluster())); 
          vPSiStripCluster.insert((void *)&*(matchedHit->stereoHit()->cluster()));         
        } else if(projectedHit){
          vPSiStripCluster.insert((void *)&*(projectedHit->originalHit().cluster())); 
        } else if(singleHit){
          vPSiStripCluster.insert((void*)&*(singleHit->cluster())); 
        }else{
          LogTrace("SiStripQualityHotStripIdentifier") << "NULL hit" << std::endl;
        }
      }
    }
  }
        
  std::stringstream ss;   
  //Loop on Det Clusters
  edm::DetSetVector<SiStripCluster>::const_iterator DSViter=dsv_SiStripCluster->begin();
  for (; DSViter!=dsv_SiStripCluster->end();DSViter++){
    edm::DetSet<SiStripCluster>::const_iterator ClusIter = DSViter->data.begin();
    edm::DetSet<SiStripCluster>::const_iterator ClusIterEnd = DSViter->data.end();
    for(; ClusIter!=ClusIterEnd; ++ClusIter) {    
      if (MinClusterWidth_<=ClusIter->amplitudes().size() && ClusIter->amplitudes().size()<=MaxClusterWidth_) {
        if (std::find(vPSiStripCluster.begin(),vPSiStripCluster.end(),(void*) &*ClusIter) == vPSiStripCluster.end()){
          if ( edm::isDebugEnabled() ) 
            ss << " adding cluster to histo for detid " << DSViter->id << " with barycenter "<< ClusIter->barycenter() << std::endl;
          fillHisto(DSViter->id,ClusIter->barycenter());
        }
      }
    }
  }
  LogTrace("SiStripQualityHotStripIdentifier") << ss.str();
}
void SiStripQualityHotStripIdentifier::algoBeginJob ( const edm::EventSetup ) [inline, private, virtual]

Reimplemented from ConditionDBWriter< SiStripBadStrip >.

Definition at line 30 of file SiStripQualityHotStripIdentifier.h.

{}
void SiStripQualityHotStripIdentifier::algoBeginLuminosityBlock ( const edm::LuminosityBlock ,
const edm::EventSetup  
) [inline, private, virtual]

Reimplemented from ConditionDBWriter< SiStripBadStrip >.

Definition at line 34 of file SiStripQualityHotStripIdentifier.h.

References resetHistos().

{ resetHistos(); }
void SiStripQualityHotStripIdentifier::algoBeginRun ( const edm::Run run,
const edm::EventSetup iSetup 
) [private, virtual]

Reimplemented from ConditionDBWriter< SiStripBadStrip >.

Definition at line 84 of file SiStripQualityHotStripIdentifier.cc.

References dataLabel_, edm::EventSetup::get(), m_cacheID_, resetHistos(), and SiStripQuality_.

                                                                                                 {
  resetHistos(); 
  unsigned long long cacheID = iSetup.get<SiStripQualityRcd>().cacheIdentifier();

  if (m_cacheID_ == cacheID) 
    return;

  m_cacheID_ = cacheID; 

  iSetup.get<SiStripQualityRcd>().get(dataLabel_,SiStripQuality_);

}
void SiStripQualityHotStripIdentifier::algoEndJob ( ) [private, virtual]

Reimplemented from ConditionDBWriter< SiStripBadStrip >.

Definition at line 97 of file SiStripQualityHotStripIdentifier.cc.

References ClusterPositionHistoMap.

                                                 {
  //Clear map
  ClusterPositionHistoMap.clear();
}
void SiStripQualityHotStripIdentifier::bookHistos ( ) [private]

Definition at line 111 of file SiStripQualityHotStripIdentifier.cc.

References ClusterPositionHistoMap, SiStripDetInfoFileReader::getAllData(), and reader.

Referenced by SiStripQualityHotStripIdentifier().

                                                 {
  edm::LogInfo("SiStripQualityHotStripIdentifier") <<" [SiStripQualityHotStripIdentifier::bookHistos] " << std::endl;
  char hname[1024];
  std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator it =reader->getAllData().begin();
  std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator iEnd =reader->getAllData().end();
  for(; it!=iEnd; ++it){    
    sprintf(hname,"h_%d",it->first);
    SiStrip::QualityHistosMap::iterator ref=ClusterPositionHistoMap.find(it->first);
    if (ref==ClusterPositionHistoMap.end()){
      ClusterPositionHistoMap[it->first]=boost::shared_ptr<TH1F>(new TH1F(hname,hname,it->second.nApvs*128,-0.5,it->second.nApvs*128-0.5));
    }
    else 
      edm::LogError("SiStripQualityHotStripIdentifier") <<" [SiStripQualityHotStripIdentifier::bookHistos] DetId " << it->first << " already found in map. Ignoring new data"<<std::endl;
  }
}
void SiStripQualityHotStripIdentifier::fillHisto ( uint32_t  detid,
float  value 
) [private]

Definition at line 127 of file SiStripQualityHotStripIdentifier.cc.

References ClusterPositionHistoMap.

Referenced by algoAnalyze().

                                                                          {
  
  SiStrip::QualityHistosMap::iterator ref=ClusterPositionHistoMap.find(detid);
  if (ref!=ClusterPositionHistoMap.end())
    ref->second->Fill(value);
  else
    edm::LogError("SiStripQualityHotStripIdentifier") <<" [SiStripQualityHotStripIdentifier::fillHisto] Histogram not found in the list for DetId " << detid << " Ignoring data value "<< value <<std::endl;
}
SiStripBadStrip * SiStripQualityHotStripIdentifier::getNewObject ( ) [private, virtual]

Implements ConditionDBWriter< SiStripBadStrip >.

Definition at line 41 of file SiStripQualityHotStripIdentifier.cc.

References a, ClusterPositionHistoMap, conf_, SiStripHotStripAlgorithmFromClusterOccupancy::extractBadStrips(), SiStripBadStrip::getDataVectorBegin(), edm::ParameterSet::getParameter(), SiStripBadStrip::getRegistryVectorBegin(), SiStripBadStrip::getRegistryVectorEnd(), edm::ParameterSet::getUntrackedParameter(), VarParsing::obj, Parameters::parameters, SiStripBadStrip::put(), SiStripHotStripAlgorithmFromClusterOccupancy::setMinNumEntries(), SiStripHotStripAlgorithmFromClusterOccupancy::setMinNumEntriesPerStrip(), SiStripHotStripAlgorithmFromClusterOccupancy::setProbabilityThreshold(), AlCaHarvesting_cff::SiStripQuality, and SiStripQuality_.

                                                               {

  SiStripBadStrip* obj=new SiStripBadStrip();
  
  edm::ParameterSet parameters=conf_.getParameter<edm::ParameterSet>("AlgoParameters");
  std::string AlgoName = parameters.getParameter<std::string>("AlgoName");
  if (AlgoName=="SiStripHotStripAlgorithmFromClusterOccupancy"){
    
    edm::LogInfo("SiStripQualityHotStripIdentifier") <<" [SiStripQualityHotStripIdentifier::getNewObject] call to SiStripHotStripAlgorithmFromClusterOccupancy"<<std::endl;

    SiStripHotStripAlgorithmFromClusterOccupancy theIdentifier(conf_);
    theIdentifier.setProbabilityThreshold(parameters.getUntrackedParameter<double>("ProbabilityThreshold",1.E-7));
    theIdentifier.setMinNumEntries(parameters.getUntrackedParameter<uint32_t>("MinNumEntries",100));
    theIdentifier.setMinNumEntriesPerStrip(parameters.getUntrackedParameter<uint32_t>("MinNumEntriesPerStrip",5));

    SiStripQuality* qobj = new SiStripQuality();
    theIdentifier.extractBadStrips(qobj,ClusterPositionHistoMap,SiStripQuality_);

    edm::LogInfo("SiStripQualityHotStripIdentifier") <<" [SiStripQualityHotStripIdentifier::getNewObject] copy SiStripObject in SiStripBadStrip"<<std::endl;

    std::stringstream ss;  
  
    SiStripBadStrip::RegistryIterator rIter=qobj->getRegistryVectorBegin();
    SiStripBadStrip::RegistryIterator rIterEnd=qobj->getRegistryVectorEnd();
    for(;rIter!=rIterEnd;++rIter){
      SiStripBadStrip::Range range(qobj->getDataVectorBegin()+rIter->ibegin,qobj->getDataVectorBegin()+rIter->iend);
      if ( ! obj->put(rIter->detid,range) )
        edm::LogError("SiStripQualityHotStripIdentifier")<<"[SiStripQualityHotStripIdentifier::getNewObject] detid already exists"<<std::endl;
    }
    edm::LogInfo("SiStripQualityHotStripIdentifier") <<" [SiStripQualityHotStripIdentifier::getNewObject] " << ss.str() << std::endl;

  } else {
    edm::LogError("SiStripQualityHotStripIdentifier") <<" [SiStripQualityHotStripIdentifier::getNewObject] call for a unknow HotStrip identification algoritm"<<std::endl;

    std::vector<uint32_t> a;
    SiStripBadStrip::Range range(a.begin(),a.end());
    if ( ! obj->put(0xFFFFFFFF,range) )
      edm::LogError("SiStripQualityHotStripIdentifier")<<"[SiStripQualityHotStripIdentifier::getNewObject] detid already exists"<<std::endl;
  }
  
  return obj;
}
void SiStripQualityHotStripIdentifier::resetHistos ( ) [private]

Definition at line 102 of file SiStripQualityHotStripIdentifier.cc.

References ClusterPositionHistoMap.

Referenced by algoBeginLuminosityBlock(), and algoBeginRun().

                                                  {
  edm::LogInfo("SiStripQualityHotStripIdentifier") <<" [SiStripQualityHotStripIdentifier::resetHistos] " << std::endl;
  SiStrip::QualityHistosMap::iterator it=ClusterPositionHistoMap.begin();
  SiStrip::QualityHistosMap::iterator iEnd=ClusterPositionHistoMap.end();
  for (;it!=iEnd;++it){
    it->second->Reset();
  }
}

Member Data Documentation

Definition at line 56 of file SiStripQualityHotStripIdentifier.h.

Referenced by algoAnalyze().

Definition at line 53 of file SiStripQualityHotStripIdentifier.h.

Referenced by getNewObject().

Definition at line 51 of file SiStripQualityHotStripIdentifier.h.

Referenced by algoBeginRun().

Definition at line 54 of file SiStripQualityHotStripIdentifier.h.

Referenced by SiStripQualityHotStripIdentifier().

unsigned long long SiStripQualityHotStripIdentifier::m_cacheID_ [private]

Definition at line 50 of file SiStripQualityHotStripIdentifier.h.

Referenced by algoBeginRun().

Definition at line 60 of file SiStripQualityHotStripIdentifier.h.

Referenced by SiStripQualityHotStripIdentifier().

Definition at line 52 of file SiStripQualityHotStripIdentifier.h.

Referenced by algoBeginRun(), and getNewObject().

Definition at line 57 of file SiStripQualityHotStripIdentifier.h.

Referenced by algoAnalyze().

Definition at line 58 of file SiStripQualityHotStripIdentifier.h.

Referenced by algoAnalyze().