CMS 3D CMS Logo

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

DeDxDiscriminatorLearner Class Reference

#include <RecoTracker/DeDxDiscriminatorLearner/src/DeDxDiscriminatorLearner.cc>

Inheritance diagram for DeDxDiscriminatorLearner:
ConditionDBWriter< PhysicsTools::Calibration::HistogramD3D > edm::EDAnalyzer

List of all members.

Classes

class  isEqual
struct  stModInfo

Public Member Functions

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

Private Member Functions

virtual void algoAnalyze (const edm::Event &, const edm::EventSetup &)
virtual void algoBeginJob (const edm::EventSetup &)
virtual void algoEndJob ()
PhysicsTools::Calibration::HistogramD3DgetNewObject ()
void Learn (const SiStripCluster *cluster, TrajectoryStateOnSurface trajState)

Private Attributes

std::string algoMode
double Charge_Max
double Charge_Min
int Charge_NBins
TH3F * Charge_Vs_Path
std::string HistoFile
const TrackerGeometrym_tracker
edm::InputTag m_tracksTag
edm::InputTag m_trajTrackAssociationTag
unsigned int MaxNrStrips
double MaxTrackChiOverNdf
double MaxTrackEta
double MaxTrackMomentum
double MeVperADCPixel
double MeVperADCStrip
double MinTrackEta
unsigned int MinTrackHits
double MinTrackMomentum
__gnu_cxx::hash_map< unsigned
int, stModInfo
*, __gnu_cxx::hash< unsigned
int >, isEqual
MODsColl
double P_Max
double P_Min
int P_NBins
double Path_Max
double Path_Min
int Path_NBins
bool usePixel
bool useStrip

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 32 of file DeDxDiscriminatorLearner.h.


Constructor & Destructor Documentation

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

Definition at line 36 of file DeDxDiscriminatorLearner.cc.

References algoMode, Charge_Max, Charge_Min, Charge_NBins, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), HistoFile, m_tracksTag, m_trajTrackAssociationTag, MaxNrStrips, MaxTrackEta, MaxTrackMomentum, MinTrackEta, MinTrackHits, MinTrackMomentum, P_Max, P_Min, P_NBins, Path_Max, Path_Min, Path_NBins, usePixel, and useStrip.

                                                                                 : ConditionDBWriter<PhysicsTools::Calibration::HistogramD3D>(iConfig)
{
   m_tracksTag                 = iConfig.getParameter<edm::InputTag>("tracks");
   m_trajTrackAssociationTag   = iConfig.getParameter<edm::InputTag>("trajectoryTrackAssociation");

   usePixel = iConfig.getParameter<bool>("UsePixel"); 
   useStrip = iConfig.getParameter<bool>("UseStrip");
   if(!usePixel && !useStrip)
   edm::LogWarning("DeDxDiscriminatorLearner") << "Pixel Hits AND Strip Hits will not be used to estimate dEdx --> BUG, Please Update the config file";

   P_Min               = iConfig.getParameter<double>  ("P_Min"  );
   P_Max               = iConfig.getParameter<double>  ("P_Max"  );
   P_NBins             = iConfig.getParameter<int>     ("P_NBins");
   Path_Min            = iConfig.getParameter<double>  ("Path_Min"  );
   Path_Max            = iConfig.getParameter<double>  ("Path_Max"  );
   Path_NBins          = iConfig.getParameter<int>     ("Path_NBins");
   Charge_Min          = iConfig.getParameter<double>  ("Charge_Min"  );
   Charge_Max          = iConfig.getParameter<double>  ("Charge_Max"  );
   Charge_NBins        = iConfig.getParameter<int>     ("Charge_NBins");

   MinTrackMomentum    = iConfig.getUntrackedParameter<double>  ("minTrackMomentum"   ,  3.0);
   MaxTrackMomentum    = iConfig.getUntrackedParameter<double>  ("maxTrackMomentum"   ,  99999.0); 
   MinTrackEta         = iConfig.getUntrackedParameter<double>  ("minTrackEta"        , -5.0);
   MaxTrackEta         = iConfig.getUntrackedParameter<double>  ("maxTrackEta"        ,  5.0);
   MaxNrStrips         = iConfig.getUntrackedParameter<unsigned>("maxNrStrips"        ,  255);
   MinTrackHits        = iConfig.getUntrackedParameter<unsigned>("MinTrackHits"       ,  4);

   algoMode            = iConfig.getUntrackedParameter<string>  ("AlgoMode"           ,  "SingleJob");
   HistoFile           = iConfig.getUntrackedParameter<string>  ("HistoFile"        ,  "out.root");
}
DeDxDiscriminatorLearner::~DeDxDiscriminatorLearner ( )

Definition at line 68 of file DeDxDiscriminatorLearner.cc.

{}

Member Function Documentation

void DeDxDiscriminatorLearner::algoAnalyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Reimplemented from ConditionDBWriter< PhysicsTools::Calibration::HistogramD3D >.

Definition at line 131 of file DeDxDiscriminatorLearner.cc.

References edm::AssociationMap< Tag >::begin(), SiStripRecHit1D::cluster(), SiStripRecHit2D::cluster(), edm::AssociationMap< Tag >::end(), reco::TrackBase::eta(), reco::Track::found(), edm::EventSetup::get(), edm::Event::getByLabel(), TrajectoryStateOnSurface::isValid(), Learn(), m_tracker, m_tracksTag, m_trajTrackAssociationTag, MaxTrackEta, MaxTrackMomentum, Trajectory::measurements(), MinTrackEta, MinTrackHits, MinTrackMomentum, SiStripMatchedRecHit2D::monoHit(), reco::TrackBase::p(), edm::ESHandle< T >::product(), edm::Handle< T >::product(), and SiStripMatchedRecHit2D::stereoHit().

{
   edm::ESHandle<TrackerGeometry> tkGeom;
   iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
   m_tracker = tkGeom.product();



  Handle<TrajTrackAssociationCollection> trajTrackAssociationHandle;
  iEvent.getByLabel(m_trajTrackAssociationTag, trajTrackAssociationHandle);
  const TrajTrackAssociationCollection TrajToTrackMap = *trajTrackAssociationHandle.product();

  edm::Handle<reco::TrackCollection> trackCollectionHandle;
  iEvent.getByLabel(m_tracksTag,trackCollectionHandle);

  unsigned track_index = 0;
  for(TrajTrackAssociationCollection::const_iterator it = TrajToTrackMap.begin(); it!=TrajToTrackMap.end(); ++it, track_index++) {

      const Track      track = *it->val;
      const Trajectory traj  = *it->key;

      if(track.eta()  <MinTrackEta      || track.eta()>MaxTrackEta     ){continue;}
      if(track.p()    <MinTrackMomentum || track.p()  >MaxTrackMomentum){continue;}
      if(track.found()<MinTrackHits                                    ){continue;}

      vector<TrajectoryMeasurement> measurements = traj.measurements();
      for(vector<TrajectoryMeasurement>::const_iterator measurement_it = measurements.begin(); measurement_it!=measurements.end(); measurement_it++)
      {
         TrajectoryStateOnSurface trajState = measurement_it->updatedState();
         if( !trajState.isValid() ) continue;

         const TrackingRecHit*         hit               = (*measurement_it->recHit()).hit();
         const SiStripRecHit2D*        sistripsimplehit  = dynamic_cast<const SiStripRecHit2D*>(hit);
         const SiStripMatchedRecHit2D* sistripmatchedhit = dynamic_cast<const SiStripMatchedRecHit2D*>(hit);
         const SiStripRecHit1D*        sistripsimple1dhit  = dynamic_cast<const SiStripRecHit1D*>(hit);

         if(sistripsimplehit){
             Learn((sistripsimplehit->cluster()).get(), trajState);
         }else if(sistripmatchedhit){
             Learn((sistripmatchedhit->monoHit()  ->cluster()).get(),trajState);
             Learn((sistripmatchedhit->stereoHit()->cluster()).get(),trajState);
         }else if(sistripsimple1dhit){
             Learn((sistripsimple1dhit->cluster()).get(), trajState);
         }else{
         }

      }
   }

}
void DeDxDiscriminatorLearner::algoBeginJob ( const edm::EventSetup iSetup) [private, virtual]

Reimplemented from ConditionDBWriter< PhysicsTools::Calibration::HistogramD3D >.

Definition at line 72 of file DeDxDiscriminatorLearner.cc.

References PV3DBase< T, PVType, FrameType >::basicVector(), BoundSurface::bounds(), Charge_Max, Charge_Min, Charge_NBins, Charge_Vs_Path, DeDxDiscriminatorLearner::stModInfo::DetId, DeDxDiscriminatorLearner::stModInfo::Eta, reco::tau::disc::Eta(), edm::EventSetup::get(), i, m_tracker, MODsColl, DeDxDiscriminatorLearner::stModInfo::NAPV, StripTopology::nstrips(), P_Max, P_Min, P_NBins, Path_Max, Path_Min, Path_NBins, GeomDet::position(), edm::ESHandle< T >::product(), dttmaxenums::R, DeDxDiscriminatorLearner::stModInfo::R, DetId::rawId(), StripGeomDetUnit::specificTopology(), DeDxDiscriminatorLearner::stModInfo::SubDet, DetId::subdetId(), GeomDet::surface(), StripSubdetector::TEC, Bounds::thickness(), DeDxDiscriminatorLearner::stModInfo::Thickness, StripSubdetector::TIB, StripSubdetector::TID, and StripSubdetector::TOB.

{
//   Charge_Vs_Path = new TH2F ("Charge_Vs_Path"     , "Charge_Vs_Path" , 24, 0.2, 1.4, 250, 0, 5000);
   Charge_Vs_Path = new TH3F ("Charge_Vs_Path"     , "Charge_Vs_Path" , P_NBins, P_Min, P_Max, Path_NBins, Path_Min, Path_Max, Charge_NBins, Charge_Min, Charge_Max);


   edm::ESHandle<TrackerGeometry> tkGeom;
   iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
   m_tracker = tkGeom.product();

   vector<GeomDet*> Det = tkGeom->dets();
   for(unsigned int i=0;i<Det.size();i++){
      DetId  Detid  = Det[i]->geographicalId();
      int    SubDet = Detid.subdetId();

      if( SubDet == StripSubdetector::TIB ||  SubDet == StripSubdetector::TID ||
          SubDet == StripSubdetector::TOB ||  SubDet == StripSubdetector::TEC  ){

          StripGeomDetUnit* DetUnit     = dynamic_cast<StripGeomDetUnit*> (Det[i]);
          if(!DetUnit)continue;

          const StripTopology& Topo     = DetUnit->specificTopology();
          unsigned int         NAPV     = Topo.nstrips()/128;

          double Eta           = DetUnit->position().basicVector().eta();
          double R             = DetUnit->position().basicVector().transverse();
          double Thick         = DetUnit->surface().bounds().thickness();

          stModInfo* MOD       = new stModInfo;
          MOD->DetId           = Detid.rawId();
          MOD->SubDet          = SubDet;
          MOD->Eta             = Eta;
          MOD->R               = R;
          MOD->Thickness       = Thick;
          MOD->NAPV            = NAPV;
          MODsColl[MOD->DetId] = MOD;
      }
   }

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

Reimplemented from ConditionDBWriter< PhysicsTools::Calibration::HistogramD3D >.

Definition at line 115 of file DeDxDiscriminatorLearner.cc.

References algoMode, Charge_Vs_Path, HistoFile, Input, and Output.

{

   if( strcmp(algoMode.c_str(),"MultiJob")==0){
        TFile* Output = new TFile(HistoFile.c_str(), "RECREATE");
        Charge_Vs_Path->Write();
        Output->Write();
        Output->Close();
   }else if( strcmp(algoMode.c_str(),"WriteOnDB")==0){
        TFile* Input = new TFile(HistoFile.c_str() );
        Charge_Vs_Path = (TH3F*)(Input->FindObjectAny("Charge_Vs_Path"))->Clone();  
        Input->Close();
   }

}
PhysicsTools::Calibration::HistogramD3D * DeDxDiscriminatorLearner::getNewObject ( ) [private, virtual]

Implements ConditionDBWriter< PhysicsTools::Calibration::HistogramD3D >.

Definition at line 204 of file DeDxDiscriminatorLearner.cc.

References Charge_Vs_Path, VarParsing::obj, and PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >::setBinContent().

{
//   if( strcmp(algoMode.c_str(),"MultiJob")==0)return NULL;

   PhysicsTools::Calibration::HistogramD3D* obj;
   obj = new PhysicsTools::Calibration::HistogramD3D(
                Charge_Vs_Path->GetNbinsX(), Charge_Vs_Path->GetXaxis()->GetXmin(),  Charge_Vs_Path->GetXaxis()->GetXmax(),
                Charge_Vs_Path->GetNbinsY(), Charge_Vs_Path->GetYaxis()->GetXmin(),  Charge_Vs_Path->GetYaxis()->GetXmax(),
                Charge_Vs_Path->GetNbinsZ(), Charge_Vs_Path->GetZaxis()->GetXmin(),  Charge_Vs_Path->GetZaxis()->GetXmax());

   for(int ix=0; ix<=Charge_Vs_Path->GetNbinsX()+1; ix++){
      for(int iy=0; iy<=Charge_Vs_Path->GetNbinsY()+1; iy++){
         for(int iz=0; iz<=Charge_Vs_Path->GetNbinsZ()+1; iz++){
            obj->setBinContent(ix, iy, iz, Charge_Vs_Path->GetBinContent(ix,iy, iz) );       
//          if(Charge_Vs_Path->GetBinContent(ix,iy)!=0)printf("%i %i %i --> %f\n",ix,iy, iz, Charge_Vs_Path->GetBinContent(ix,iy,iz)); 
         }
      }
   }

   return obj;
}
void DeDxDiscriminatorLearner::Learn ( const SiStripCluster cluster,
TrajectoryStateOnSurface  trajState 
) [private]

Definition at line 183 of file DeDxDiscriminatorLearner.cc.

References SiStripCluster::amplitudes(), DeDxDiscriminatorTools::charge(), Charge_Vs_Path, SiStripCluster::firstStrip(), SiStripCluster::geographicalId(), TrackerGeometry::idToDetUnit(), DeDxDiscriminatorTools::IsFarFromBorder(), DeDxDiscriminatorTools::IsSpanningOver2APV(), TrajectoryStateOnSurface::localDirection(), TrajectoryStateOnSurface::localMomentum(), m_tracker, PV3DBase< T, PVType, FrameType >::mag(), MaxNrStrips, MODsColl, path(), DeDxDiscriminatorLearner::stModInfo::Thickness, and PV3DBase< T, PVType, FrameType >::z().

Referenced by algoAnalyze().

{
   // Get All needed variables
   LocalVector             trackDirection = trajState.localDirection();
   double                  cosine         = trackDirection.z()/trackDirection.mag();
   const vector<uint8_t>&  ampls          = cluster->amplitudes();
   uint32_t                detId          = cluster->geographicalId();
   int                     firstStrip     = cluster->firstStrip();
   stModInfo* MOD                         = MODsColl[detId];
   // Sanity Checks
   if( ampls.size()>MaxNrStrips)                                                                      { return; }
// if( DeDxDiscriminatorTools::IsSaturatingStrip  (ampls))                                            { return; }
   if( DeDxDiscriminatorTools::IsSpanningOver2APV (firstStrip, ampls.size()))                         { return; }
   if(!DeDxDiscriminatorTools::IsFarFromBorder    (trajState, m_tracker->idToDetUnit(DetId(detId)) )) { return; }
   // Fill Histo Path Vs Charge/Path
   double charge = DeDxDiscriminatorTools::charge(ampls);
   double path   = DeDxDiscriminatorTools::path(cosine,MOD->Thickness);
   Charge_Vs_Path->Fill(trajState.localMomentum().mag(),path,charge/path);
}

Member Data Documentation

std::string DeDxDiscriminatorLearner::algoMode [private]

Definition at line 80 of file DeDxDiscriminatorLearner.h.

Referenced by algoEndJob(), and DeDxDiscriminatorLearner().

Definition at line 76 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

Definition at line 75 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

Definition at line 77 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

Definition at line 83 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), algoEndJob(), getNewObject(), and Learn().

std::string DeDxDiscriminatorLearner::HistoFile [private]

Definition at line 81 of file DeDxDiscriminatorLearner.h.

Referenced by algoEndJob(), and DeDxDiscriminatorLearner().

Definition at line 58 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyze(), algoBeginJob(), and Learn().

Definition at line 51 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyze(), and DeDxDiscriminatorLearner().

Definition at line 50 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyze(), and DeDxDiscriminatorLearner().

unsigned int DeDxDiscriminatorLearner::MaxNrStrips [private]

Definition at line 64 of file DeDxDiscriminatorLearner.h.

Referenced by DeDxDiscriminatorLearner(), and Learn().

Definition at line 66 of file DeDxDiscriminatorLearner.h.

Definition at line 63 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyze(), and DeDxDiscriminatorLearner().

Definition at line 61 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyze(), and DeDxDiscriminatorLearner().

Definition at line 55 of file DeDxDiscriminatorLearner.h.

Definition at line 56 of file DeDxDiscriminatorLearner.h.

Definition at line 62 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyze(), and DeDxDiscriminatorLearner().

Definition at line 65 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyze(), and DeDxDiscriminatorLearner().

Definition at line 60 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyze(), and DeDxDiscriminatorLearner().

__gnu_cxx::hash_map<unsigned int, stModInfo*, __gnu_cxx::hash<unsigned int>, isEqual > DeDxDiscriminatorLearner::MODsColl [private]

Definition at line 93 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and Learn().

Definition at line 70 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

Definition at line 69 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

Definition at line 71 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

Definition at line 73 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

Definition at line 72 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

Definition at line 74 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

Definition at line 53 of file DeDxDiscriminatorLearner.h.

Referenced by DeDxDiscriminatorLearner().

Definition at line 54 of file DeDxDiscriminatorLearner.h.

Referenced by DeDxDiscriminatorLearner().