CMS 3D CMS Logo

List of all members | 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 edm::EDConsumerBase

Public Member Functions

 DeDxDiscriminatorLearner (const edm::ParameterSet &)
 
 ~DeDxDiscriminatorLearner () override
 
- Public Member Functions inherited from ConditionDBWriter< PhysicsTools::Calibration::HistogramD3D >
 ConditionDBWriter (const edm::ParameterSet &iConfig)
 
 ~ConditionDBWriter () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void algoAnalyze (const edm::Event &, const edm::EventSetup &) override
 
void algoAnalyzeTheTree (const edm::EventSetup &iSetup)
 
void algoBeginJob (const edm::EventSetup &) override
 
void algoEndJob () override
 
std::unique_ptr< PhysicsTools::Calibration::HistogramD3DgetNewObject () override
 
void processHit (const TrackingRecHit *recHit, float trackMomentum, float &cosine, const TrajectoryStateOnSurface &trajState)
 

Private Attributes

std::string algoMode
 
std::vector< std::vector< float > > calibGains
 
float Charge_Max
 
float Charge_Min
 
int Charge_NBins
 
TH3F * Charge_Vs_Path
 
std::string HistoFile
 
std::string m_calibrationPath
 
unsigned int m_off
 
edm::EDGetTokenT< reco::TrackCollectionm_tracksTag
 
edm::EDGetTokenT< TrajTrackAssociationCollectionm_trajTrackAssociationTag
 
unsigned int MaxNrStrips
 
float MaxTrackChiOverNdf
 
float MaxTrackEta
 
float MaxTrackMomentum
 
float MinTrackEta
 
unsigned int MinTrackHits
 
float MinTrackMomentum
 
float P_Max
 
float P_Min
 
int P_NBins
 
float Path_Max
 
float Path_Min
 
int Path_NBins
 
bool shapetest
 
bool useCalibration
 
std::vector< std::string > VInputFiles
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from ConditionDBWriter< PhysicsTools::Calibration::HistogramD3D >
void setDoStore (const bool doStore)
 When set to false the payload will not be written to the db. More...
 
void storeOnDbNow ()
 
cond::Time_t timeOfLastIOV ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

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

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

Definition at line 23 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_calibrationPath, m_tracksTag, m_trajTrackAssociationTag, MaxNrStrips, MaxTrackEta, MaxTrackMomentum, MinTrackEta, MinTrackHits, MinTrackMomentum, P_Max, P_Min, P_NBins, Path_Max, Path_Min, Path_NBins, shapetest, useCalibration, and VInputFiles.

37 {
38  m_tracksTag = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"));
39  m_trajTrackAssociationTag = consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("trajectoryTrackAssociation"));
40 
41  P_Min = iConfig.getParameter<double> ("P_Min" );
42  P_Max = iConfig.getParameter<double> ("P_Max" );
43  P_NBins = iConfig.getParameter<int> ("P_NBins");
44  Path_Min = iConfig.getParameter<double> ("Path_Min" );
45  Path_Max = iConfig.getParameter<double> ("Path_Max" );
46  Path_NBins = iConfig.getParameter<int> ("Path_NBins");
47  Charge_Min = iConfig.getParameter<double> ("Charge_Min" );
48  Charge_Max = iConfig.getParameter<double> ("Charge_Max" );
49  Charge_NBins = iConfig.getParameter<int> ("Charge_NBins");
50 
51  MinTrackMomentum = iConfig.getUntrackedParameter<double> ("minTrackMomentum" , 5.0);
52  MaxTrackMomentum = iConfig.getUntrackedParameter<double> ("maxTrackMomentum" , 99999.0);
53  MinTrackEta = iConfig.getUntrackedParameter<double> ("minTrackEta" , -5.0);
54  MaxTrackEta = iConfig.getUntrackedParameter<double> ("maxTrackEta" , 5.0);
55  MaxNrStrips = iConfig.getUntrackedParameter<unsigned>("maxNrStrips" , 255);
56  MinTrackHits = iConfig.getUntrackedParameter<unsigned>("MinTrackHits" , 4);
57 
58  algoMode = iConfig.getUntrackedParameter<string> ("AlgoMode" , "SingleJob");
59  HistoFile = iConfig.getUntrackedParameter<string> ("HistoFile" , "out.root");
60  VInputFiles = iConfig.getUntrackedParameter<vector<string> > ("InputFiles");
61 
62  shapetest = iConfig.getParameter<bool>("ShapeTest");
63  useCalibration = iConfig.getUntrackedParameter<bool>("UseCalibration");
64  m_calibrationPath = iConfig.getUntrackedParameter<string>("calibrationPath");
65 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > VInputFiles
edm::EDGetTokenT< TrajTrackAssociationCollection > m_trajTrackAssociationTag
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
DeDxDiscriminatorLearner::~DeDxDiscriminatorLearner ( )
override

Definition at line 68 of file DeDxDiscriminatorLearner.cc.

68 {}

Member Function Documentation

void DeDxDiscriminatorLearner::algoAnalyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

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

Definition at line 112 of file DeDxDiscriminatorLearner.cc.

References edm::AssociationMap< Tag >::begin(), edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, edm::AssociationMap< Tag >::end(), reco::TrackBase::eta(), reco::Track::found(), edm::Event::getByToken(), TrajectoryStateOnSurface::isValid(), TrackingRecHit::isValid(), TrajectoryStateOnSurface::localDirection(), TrajectoryStateOnSurface::localMomentum(), m_tracksTag, m_trajTrackAssociationTag, PV3DBase< T, PVType, FrameType >::mag(), MaxTrackEta, MaxTrackMomentum, Trajectory::measurements(), MinTrackEta, MinTrackHits, MinTrackMomentum, processHit(), reco::TrackBase::pt(), rpcPointValidation_cfi::recHit, HiIsolationCommonParameters_cff::track, and PV3DBase< T, PVType, FrameType >::z().

113 {
114  Handle<TrajTrackAssociationCollection> trajTrackAssociationHandle;
115  iEvent.getByToken(m_trajTrackAssociationTag, trajTrackAssociationHandle);
116 
117  edm::Handle<reco::TrackCollection> trackCollectionHandle;
118  iEvent.getByToken(m_tracksTag,trackCollectionHandle);
119 
120  unsigned track_index = 0;
121  for(TrajTrackAssociationCollection::const_iterator it = trajTrackAssociationHandle->begin(); it!=trajTrackAssociationHandle->end(); ++it, track_index++) {
122  const Track& track = *it->val;
123  const Trajectory& traj = *it->key;
124 
125  if(track.eta() <MinTrackEta || track.eta()>MaxTrackEta ){continue;}
126  if(track.pt() <MinTrackMomentum || track.pt() >MaxTrackMomentum){continue;}
127  if(track.found()<MinTrackHits ){continue;}
128 
129  const vector<TrajectoryMeasurement> & measurements = traj.measurements();
130  for(vector<TrajectoryMeasurement>::const_iterator it = measurements.begin(); it!=measurements.end(); it++){
131  TrajectoryStateOnSurface trajState=it->updatedState();
132  if( !trajState.isValid()) continue;
133 
134 
135  const TrackingRecHit * recHit=(*it->recHit()).hit();
136  if(!recHit || !recHit->isValid())continue;
137  LocalVector trackDirection = trajState.localDirection();
138  float cosine = trackDirection.z()/trackDirection.mag();
139 
140  processHit(recHit, trajState.localMomentum().mag(), cosine, trajState);
141  }
142  }
143 
144 }
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
LocalVector localDirection() const
LocalVector localMomentum() const
DataContainer const & measurements() const
Definition: Trajectory.h:196
T mag() const
Definition: PV3DBase.h:67
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:651
double pt() const
track transverse momentum
Definition: TrackBase.h:621
T z() const
Definition: PV3DBase.h:64
void processHit(const TrackingRecHit *recHit, float trackMomentum, float &cosine, const TrajectoryStateOnSurface &trajState)
bool isValid() const
unsigned short found() const
Number of valid hits on track.
Definition: Track.h:194
edm::EDGetTokenT< TrajTrackAssociationCollection > m_trajTrackAssociationTag
const_iterator begin() const
first iterator over the map (read only)
edm::EDGetTokenT< reco::TrackCollection > m_tracksTag
void DeDxDiscriminatorLearner::algoAnalyzeTheTree ( const edm::EventSetup iSetup)
private

Definition at line 202 of file DeDxDiscriminatorLearner.cc.

References CustomPhysics_cfi::amplitude, EnergyCorrector::c, calibGains, ALCARECOTkAlJpsiMuMu_cff::charge, Charge_Vs_Path, muonCSCDigis_cfi::gain, edm::EventSetup::get(), mps_fire::i, TrackerGeometry::idToDetUnit(), GeomDet::index(), createfilelist::int, m_off, callgraph::path, cond::runnumber, alignCSCRings::s, mps_setup::stdout, lumiQTWidget::t, useCalibration, and VInputFiles.

Referenced by algoBeginJob().

203 {
205  iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
206 
207  unsigned int NEvent = 0;
208  for(unsigned int i=0;i<VInputFiles.size();i++){
209  printf("Openning file %3i/%3i --> %s\n",i+1, (int)VInputFiles.size(), (char*)(VInputFiles[i].c_str())); fflush(stdout);
210  TChain* tree = new TChain("gainCalibrationTree/tree");
211  tree->Add(VInputFiles[i].c_str());
212 
213  TString EventPrefix("");
214  TString EventSuffix("");
215 
216  TString TrackPrefix("track");
217  TString TrackSuffix("");
218 
219  TString CalibPrefix("GainCalibration");
220  TString CalibSuffix("");
221 
222  unsigned int eventnumber = 0; tree->SetBranchAddress(EventPrefix + "event" + EventSuffix, &eventnumber , nullptr);
223  unsigned int runnumber = 0; tree->SetBranchAddress(EventPrefix + "run" + EventSuffix, &runnumber , nullptr);
224  std::vector<bool>* TrigTech = nullptr; tree->SetBranchAddress(EventPrefix + "TrigTech" + EventSuffix, &TrigTech , nullptr);
225 
226  std::vector<double>* trackchi2ndof = nullptr; tree->SetBranchAddress(TrackPrefix + "chi2ndof" + TrackSuffix, &trackchi2ndof , nullptr);
227  std::vector<float>* trackp = nullptr; tree->SetBranchAddress(TrackPrefix + "momentum" + TrackSuffix, &trackp , nullptr);
228  std::vector<float>* trackpt = nullptr; tree->SetBranchAddress(TrackPrefix + "pt" + TrackSuffix, &trackpt , nullptr);
229  std::vector<double>* tracketa = nullptr; tree->SetBranchAddress(TrackPrefix + "eta" + TrackSuffix, &tracketa , nullptr);
230  std::vector<double>* trackphi = nullptr; tree->SetBranchAddress(TrackPrefix + "phi" + TrackSuffix, &trackphi , nullptr);
231  std::vector<unsigned int>* trackhitsvalid = nullptr; tree->SetBranchAddress(TrackPrefix + "hitsvalid" + TrackSuffix, &trackhitsvalid, nullptr);
232 
233  std::vector<int>* trackindex = nullptr; tree->SetBranchAddress(CalibPrefix + "trackindex" + CalibSuffix, &trackindex , nullptr);
234  std::vector<unsigned int>* rawid = nullptr; tree->SetBranchAddress(CalibPrefix + "rawid" + CalibSuffix, &rawid , nullptr);
235  std::vector<unsigned short>* firststrip = nullptr; tree->SetBranchAddress(CalibPrefix + "firststrip" + CalibSuffix, &firststrip , nullptr);
236  std::vector<unsigned short>* nstrips = nullptr; tree->SetBranchAddress(CalibPrefix + "nstrips" + CalibSuffix, &nstrips , nullptr);
237  std::vector<unsigned int>* charge = nullptr; tree->SetBranchAddress(CalibPrefix + "charge" + CalibSuffix, &charge , nullptr);
238  std::vector<float>* path = nullptr; tree->SetBranchAddress(CalibPrefix + "path" + CalibSuffix, &path , nullptr);
239  std::vector<unsigned char>* amplitude = nullptr; tree->SetBranchAddress(CalibPrefix + "amplitude" + CalibSuffix, &amplitude , nullptr);
240  std::vector<double>* gainused = nullptr; tree->SetBranchAddress(CalibPrefix + "gainused" + CalibSuffix, &gainused , nullptr);
241 
242  printf("Number of Events = %i + %i = %i\n",NEvent,(unsigned int)tree->GetEntries(),(unsigned int)(NEvent+tree->GetEntries()));NEvent+=tree->GetEntries();
243  printf("Progressing Bar :0%% 20%% 40%% 60%% 80%% 100%%\n");
244  printf("Looping on the Tree :");
245  int TreeStep = tree->GetEntries()/50;if(TreeStep<=1)TreeStep=1;
246  for (unsigned int ientry = 0; ientry < tree->GetEntries(); ientry++) {
247  if(ientry%TreeStep==0){printf(".");fflush(stdout);}
248  tree->GetEntry(ientry);
249 
250  int FirstAmplitude = 0;
251  for(unsigned int c=0;c<(*path).size();c++){
252  FirstAmplitude+=(*nstrips)[c];
253  int t = (*trackindex)[c];
254  if((*trackpt)[t]<5)continue;
255  if((*trackhitsvalid)[t]<5)continue;
256 
257  int Charge = 0;
258  if(useCalibration){
259  auto & gains = calibGains[tkGeom->idToDetUnit(DetId((*rawid)[c]))->index()-m_off];
260  auto & gain = gains[(*firststrip)[c]/128];
261  for(unsigned int s=0;s<(*nstrips)[c];s++){
262  int StripCharge = (*amplitude)[FirstAmplitude-(*nstrips)[c]+s];
263  if(StripCharge<254){
264  StripCharge=(int)(StripCharge/gain);
265  if(StripCharge>=1024){
266  StripCharge = 255;
267  }else if(StripCharge>=254){
268  StripCharge = 254;
269  }
270  }
271  Charge += StripCharge;
272  }
273  }else{
274  Charge = (*charge)[c];
275  }
276 
277 // printf("ChargeDifference = %i Vs %i with Gain = %f\n",(*charge)[c],Charge,Gains[(*rawid)[c]]);
278  double ClusterChargeOverPath = ( (double) Charge )/(*path)[c] ;
279  Charge_Vs_Path->Fill((*trackp)[t],(*path)[c],ClusterChargeOverPath);
280  }
281  }printf("\n");
282  }
283 }
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
int index() const
Definition: GeomDet.h:99
std::vector< std::string > VInputFiles
Definition: DetId.h:18
T get() const
Definition: EventSetup.h:62
Definition: tree.py:1
std::vector< std::vector< float > > calibGains
void DeDxDiscriminatorLearner::algoBeginJob ( const edm::EventSetup iSetup)
overrideprivatevirtual

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

Definition at line 72 of file DeDxDiscriminatorLearner.cc.

References algoAnalyzeTheTree(), algoMode, calibGains, Charge_Max, Charge_Min, Charge_NBins, Charge_Vs_Path, edm::EventSetup::get(), m_calibrationPath, m_off, DeDxTools::makeCalibrationMap(), TrackerGeometry::offsetDU(), P_Max, P_Min, P_NBins, Path_Max, Path_Min, Path_NBins, GeomDetEnumerators::PixelBarrel, and useCalibration.

73 {
74  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);
75 
76  if(useCalibration && calibGains.empty()){
78  iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
79  m_off = tkGeom->offsetDU(GeomDetEnumerators::PixelBarrel); //index start at the first pixel
80 
82  }
83 
84  //Read the calibTree if in calibTree mode
85  if(strcmp(algoMode.c_str(),"CalibTree")==0)algoAnalyzeTheTree(iSetup);
86 }
void makeCalibrationMap(const std::string &m_calibrationPath, const TrackerGeometry &tkGeom, std::vector< std::vector< float > > &calibGains, const unsigned int &m_off)
Definition: DeDxTools.cc:196
void algoAnalyzeTheTree(const edm::EventSetup &iSetup)
unsigned int offsetDU(SubDetector sid) const
T get() const
Definition: EventSetup.h:62
std::vector< std::vector< float > > calibGains
void DeDxDiscriminatorLearner::algoEndJob ( )
overrideprivatevirtual

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

Definition at line 90 of file DeDxDiscriminatorLearner.cc.

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

91 {
92  if( strcmp(algoMode.c_str(),"MultiJob")==0){
93  TFile* Output = new TFile(HistoFile.c_str(), "RECREATE");
94  Charge_Vs_Path->Write();
95  Output->Write();
96  Output->Close();
97  }else if( strcmp(algoMode.c_str(),"WriteOnDB")==0){
98  TFile* Input = new TFile(HistoFile.c_str() );
99  Charge_Vs_Path = (TH3F*)(Input->FindObjectAny("Charge_Vs_Path"))->Clone();
100  Input->Close();
101  }else if(strcmp(algoMode.c_str(),"CalibTree")==0){
102  TFile* Output = new TFile(HistoFile.c_str(), "RECREATE");
103  Charge_Vs_Path->Write();
104  Output->Write();
105  Output->Close();
106  TFile* Input = new TFile(HistoFile.c_str() );
107  Charge_Vs_Path = (TH3F*)(Input->FindObjectAny("Charge_Vs_Path"))->Clone();
108  Input->Close();
109  }
110 }
#define Input(cl)
Definition: vmac.h:190
#define Output(cl)
Definition: vmac.h:194
std::unique_ptr< PhysicsTools::Calibration::HistogramD3D > DeDxDiscriminatorLearner::getNewObject ( )
overrideprivatevirtual

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

Definition at line 286 of file DeDxDiscriminatorLearner.cc.

References Charge_Vs_Path, DEFINE_FWK_MODULE, and GetRecoTauVFromDQM_MC_cff::obj.

287 {
288  auto obj = std::make_unique<PhysicsTools::Calibration::HistogramD3D>(
289  Charge_Vs_Path->GetNbinsX(), Charge_Vs_Path->GetXaxis()->GetXmin(), Charge_Vs_Path->GetXaxis()->GetXmax(),
290  Charge_Vs_Path->GetNbinsY(), Charge_Vs_Path->GetYaxis()->GetXmin(), Charge_Vs_Path->GetYaxis()->GetXmax(),
291  Charge_Vs_Path->GetNbinsZ(), Charge_Vs_Path->GetZaxis()->GetXmin(), Charge_Vs_Path->GetZaxis()->GetXmax());
292 
293  for(int ix=0; ix<=Charge_Vs_Path->GetNbinsX()+1; ix++){
294  for(int iy=0; iy<=Charge_Vs_Path->GetNbinsY()+1; iy++){
295  for(int iz=0; iz<=Charge_Vs_Path->GetNbinsZ()+1; iz++){
296  obj->setBinContent(ix, iy, iz, Charge_Vs_Path->GetBinContent(ix,iy, iz) );
297 // if(Charge_Vs_Path->GetBinContent(ix,iy)!=0)printf("%i %i %i --> %f\n",ix,iy, iz, Charge_Vs_Path->GetBinContent(ix,iy,iz));
298  }
299  }
300  }
301 
302  return obj;
303 }
void DeDxDiscriminatorLearner::processHit ( const TrackingRecHit recHit,
float  trackMomentum,
float &  cosine,
const TrajectoryStateOnSurface trajState 
)
private

Definition at line 147 of file DeDxDiscriminatorLearner.cc.

References calibGains, ALCARECOTkAlJpsiMuMu_cff::charge, Charge_Vs_Path, TrackingRecHit::det(), TrackingRecHit::detUnit(), BaseTrackerRecHit::firstClusterRef(), DeDxTools::getCharge(), DeDxTools::IsFarFromBorder(), DeDxTools::IsSpanningOver2APV(), m_off, MaxNrStrips, SiStripMatchedRecHit2D::monoCluster(), GluedGeomDet::monoDet(), rpcPointValidation_cfi::recHit, DeDxTools::shapeSelection(), shapetest, SiStripMatchedRecHit2D::stereoCluster(), GluedGeomDet::stereoDet(), and OmniClusterRef::stripCluster().

Referenced by algoAnalyze().

147  {
148  auto const & thit = static_cast<BaseTrackerRecHit const&>(*recHit);
149  if(!thit.isValid())return;
150 
151  auto const & clus = thit.firstClusterRef();
152  if(!clus.isValid())return;
153 
154  int NSaturating = 0;
155  if(clus.isPixel()){
156  return;
157  }else if(clus.isStrip() && !thit.isMatched()){
158  auto& detUnit = *(recHit->detUnit());
159  auto& cluster = clus.stripCluster();
160  if( cluster.amplitudes().size()>MaxNrStrips) { return; }
161  if( DeDxTools::IsSpanningOver2APV (cluster.firstStrip(), cluster.amplitudes().size())) { return; }
162  if(!DeDxTools::IsFarFromBorder (trajState, &detUnit )) { return; }
163  float pathLen = 10.0*detUnit.surface().bounds().thickness()/fabs(cosine);
164  float chargeAbs = DeDxTools::getCharge(&cluster,NSaturating, detUnit, calibGains, m_off);
165  float charge = chargeAbs/pathLen;
166  if(!shapetest || (shapetest && DeDxTools::shapeSelection(cluster))){
167  Charge_Vs_Path->Fill(trackMomentum, pathLen, charge);
168  }
169  }else if(clus.isStrip() && thit.isMatched()){
170  const SiStripMatchedRecHit2D* matchedHit=dynamic_cast<const SiStripMatchedRecHit2D*>(recHit);
171  if(!matchedHit)return;
172  const GluedGeomDet* gdet = static_cast<const GluedGeomDet*>(matchedHit->det());
173 
174  auto& detUnitM = *(gdet->monoDet());
175  auto& clusterM = matchedHit->monoCluster();
176  if( clusterM.amplitudes().size()>MaxNrStrips) { return; }
177  if( DeDxTools::IsSpanningOver2APV (clusterM.firstStrip(), clusterM.amplitudes().size())) { return; }
178  if(!DeDxTools::IsFarFromBorder (trajState, &detUnitM )) { return; }
179  float pathLen = 10.0*detUnitM.surface().bounds().thickness()/fabs(cosine);
180  float chargeAbs = DeDxTools::getCharge(&clusterM,NSaturating, detUnitM, calibGains, m_off);
181  float charge = chargeAbs/pathLen;
182  if(!shapetest || (shapetest && DeDxTools::shapeSelection(clusterM))){
183  Charge_Vs_Path->Fill(trackMomentum, pathLen, charge);
184  }
185 
186  auto& detUnitS = *(gdet->stereoDet());
187  auto& clusterS = matchedHit->stereoCluster();
188  if( clusterS.amplitudes().size()>MaxNrStrips) { return; }
189  if( DeDxTools::IsSpanningOver2APV (clusterS.firstStrip(), clusterS.amplitudes().size())) { return; }
190  if(!DeDxTools::IsFarFromBorder (trajState, &detUnitS )) { return; }
191  pathLen = 10.0*detUnitS.surface().bounds().thickness()/fabs(cosine);
192  chargeAbs = DeDxTools::getCharge(&clusterS,NSaturating, detUnitS, calibGains, m_off);
193  charge = chargeAbs/pathLen;
194  if(!shapetest || (shapetest && DeDxTools::shapeSelection(clusterS))){
195  Charge_Vs_Path->Fill(trackMomentum, pathLen, charge);
196  }
197  }
198 }
bool IsFarFromBorder(const TrajectoryStateOnSurface &trajState, const GeomDetUnit *it)
Definition: DeDxTools.cc:311
int getCharge(const SiStripCluster *cluster, int &nSatStrip, const GeomDetUnit &detUnit, const std::vector< std::vector< float > > &calibGains, const unsigned int &m_off)
Definition: DeDxTools.cc:161
const GeomDetUnit * monoDet() const
Definition: GluedGeomDet.h:20
SiStripCluster const & monoCluster() const
SiStripCluster const & stripCluster() const
const GeomDet * det() const
bool shapeSelection(const SiStripCluster &ampls)
Definition: DeDxTools.cc:10
SiStripCluster const & stereoCluster() const
virtual const GeomDetUnit * detUnit() const
virtual OmniClusterRef const & firstClusterRef() const =0
bool IsSpanningOver2APV(unsigned int FirstStrip, unsigned int ClusterSize)
Definition: DeDxTools.cc:286
const GeomDetUnit * stereoDet() const
Definition: GluedGeomDet.h:21
std::vector< std::vector< float > > calibGains

Member Data Documentation

std::string DeDxDiscriminatorLearner::algoMode
private

Definition at line 63 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), algoEndJob(), and DeDxDiscriminatorLearner().

std::vector< std::vector<float> > DeDxDiscriminatorLearner::calibGains
private

Definition at line 73 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyzeTheTree(), algoBeginJob(), and processHit().

float DeDxDiscriminatorLearner::Charge_Max
private

Definition at line 59 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

float DeDxDiscriminatorLearner::Charge_Min
private

Definition at line 58 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

int DeDxDiscriminatorLearner::Charge_NBins
private

Definition at line 60 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

TH3F* DeDxDiscriminatorLearner::Charge_Vs_Path
private
std::string DeDxDiscriminatorLearner::HistoFile
private

Definition at line 64 of file DeDxDiscriminatorLearner.h.

Referenced by algoEndJob(), and DeDxDiscriminatorLearner().

std::string DeDxDiscriminatorLearner::m_calibrationPath
private

Definition at line 69 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

unsigned int DeDxDiscriminatorLearner::m_off
private

Definition at line 74 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyzeTheTree(), algoBeginJob(), and processHit().

edm::EDGetTokenT<reco::TrackCollection> DeDxDiscriminatorLearner::m_tracksTag
private

Definition at line 42 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyze(), and DeDxDiscriminatorLearner().

edm::EDGetTokenT<TrajTrackAssociationCollection> DeDxDiscriminatorLearner::m_trajTrackAssociationTag
private

Definition at line 41 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyze(), and DeDxDiscriminatorLearner().

unsigned int DeDxDiscriminatorLearner::MaxNrStrips
private

Definition at line 48 of file DeDxDiscriminatorLearner.h.

Referenced by DeDxDiscriminatorLearner(), and processHit().

float DeDxDiscriminatorLearner::MaxTrackChiOverNdf
private

Definition at line 50 of file DeDxDiscriminatorLearner.h.

float DeDxDiscriminatorLearner::MaxTrackEta
private

Definition at line 47 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyze(), and DeDxDiscriminatorLearner().

float DeDxDiscriminatorLearner::MaxTrackMomentum
private

Definition at line 45 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyze(), and DeDxDiscriminatorLearner().

float DeDxDiscriminatorLearner::MinTrackEta
private

Definition at line 46 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyze(), and DeDxDiscriminatorLearner().

unsigned int DeDxDiscriminatorLearner::MinTrackHits
private

Definition at line 49 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyze(), and DeDxDiscriminatorLearner().

float DeDxDiscriminatorLearner::MinTrackMomentum
private

Definition at line 44 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyze(), and DeDxDiscriminatorLearner().

float DeDxDiscriminatorLearner::P_Max
private

Definition at line 53 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

float DeDxDiscriminatorLearner::P_Min
private

Definition at line 52 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

int DeDxDiscriminatorLearner::P_NBins
private

Definition at line 54 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

float DeDxDiscriminatorLearner::Path_Max
private

Definition at line 56 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

float DeDxDiscriminatorLearner::Path_Min
private

Definition at line 55 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

int DeDxDiscriminatorLearner::Path_NBins
private

Definition at line 57 of file DeDxDiscriminatorLearner.h.

Referenced by algoBeginJob(), and DeDxDiscriminatorLearner().

bool DeDxDiscriminatorLearner::shapetest
private

Definition at line 71 of file DeDxDiscriminatorLearner.h.

Referenced by DeDxDiscriminatorLearner(), and processHit().

bool DeDxDiscriminatorLearner::useCalibration
private
std::vector<std::string> DeDxDiscriminatorLearner::VInputFiles
private

Definition at line 62 of file DeDxDiscriminatorLearner.h.

Referenced by algoAnalyzeTheTree(), and DeDxDiscriminatorLearner().