CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
DeDxEstimatorProducerPixelTripplet Class Reference

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

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

Classes

class  isEqual
 
struct  stModInfo
 

Public Member Functions

 DeDxEstimatorProducerPixelTripplet (const edm::ParameterSet &)
 
 ~DeDxEstimatorProducerPixelTripplet ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void beginRun (edm::Run &run, const edm::EventSetup &)
 
virtual void endJob ()
 
void MakeCalibrationMap ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

std::string m_calibrationPath
 
BaseDeDxEstimatorm_estimator
 
edm::InputTag m_tracksTag
 
edm::InputTag m_trajTrackAssociationTag
 
unsigned int MaxNrStrips
 
double MeVperADCPixel
 
double MeVperADCStrip
 
unsigned int MinTrackHits
 
__gnu_cxx::hash_map< unsigned
int, stModInfo
*, __gnu_cxx::hash< unsigned
int >, isEqual
MODsColl
 
bool shapetest
 
bool useCalibration
 
bool usePixel
 
bool useStrip
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

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

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

Definition at line 33 of file DeDxEstimatorProducerPixelTripplet.h.

Constructor & Destructor Documentation

DeDxEstimatorProducerPixelTripplet::DeDxEstimatorProducerPixelTripplet ( const edm::ParameterSet iConfig)
explicit

Definition at line 47 of file DeDxEstimatorProducerPixelTripplet.cc.

References edm::ParameterSet::getParameter(), and edm::ParameterSet::getUntrackedParameter().

48 {
49 
50  produces<ValueMap<DeDxData> >();
51 
52 
53  string estimatorName = iConfig.getParameter<string>("estimator");
54  if(estimatorName == "median") m_estimator = new MedianDeDxEstimator(-2.);
55  if(estimatorName == "generic") m_estimator = new GenericAverageDeDxEstimator (iConfig.getParameter<double>("exponent"));
56  if(estimatorName == "truncated") m_estimator = new TruncatedAverageDeDxEstimator(iConfig.getParameter<double>("fraction"));
57  if(estimatorName == "unbinnedFit") m_estimator = new UnbinnedFitDeDxEstimator();
58 
59  MaxNrStrips = iConfig.getUntrackedParameter<unsigned>("maxNrStrips" , 255);
60  MinTrackHits = iConfig.getUntrackedParameter<unsigned>("MinTrackHits" , 4);
61 
62  m_tracksTag = iConfig.getParameter<edm::InputTag>("tracks");
63  m_trajTrackAssociationTag = iConfig.getParameter<edm::InputTag>("trajectoryTrackAssociation");
64 
65  usePixel = iConfig.getParameter<bool>("UsePixel");
66  useStrip = iConfig.getParameter<bool>("UseStrip");
67  MeVperADCPixel = iConfig.getParameter<double>("MeVperADCPixel");
68  MeVperADCStrip = iConfig.getParameter<double>("MeVperADCStrip");
69 
70  shapetest = iConfig.getParameter<bool>("ShapeTest");
71  useCalibration = iConfig.getParameter<bool>("UseCalibration");
72  m_calibrationPath = iConfig.getParameter<string>("calibrationPath");
73 
74  if(!usePixel && !useStrip)
75  edm::LogWarning("DeDxHitsProducer") << "Pixel Hits AND Strip Hits will not be used to estimate dEdx --> BUG, Please Update the config file";
76 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
DeDxEstimatorProducerPixelTripplet::~DeDxEstimatorProducerPixelTripplet ( )

Definition at line 79 of file DeDxEstimatorProducerPixelTripplet.cc.

80 {
81  delete m_estimator;
82 }

Member Function Documentation

void DeDxEstimatorProducerPixelTripplet::beginRun ( edm::Run run,
const edm::EventSetup iSetup 
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 87 of file DeDxEstimatorProducerPixelTripplet.cc.

References BoundSurface::bounds(), DeDxEstimatorProducerPixelTripplet::stModInfo::DetId, DeDxEstimatorProducerPixelTripplet::stModInfo::Distance, DeDxEstimatorProducerPixelTripplet::stModInfo::Gain, edm::EventSetup::get(), i, PV3DBase< T, PVType, FrameType >::mag(), DeDxEstimatorProducerPixelTripplet::stModInfo::Normal, DeDxEstimatorProducerPixelTripplet::stModInfo::Normalization, Plane::normalVector(), GeomDet::position(), DetId::rawId(), GeomDet::surface(), Bounds::thickness(), and DeDxEstimatorProducerPixelTripplet::stModInfo::Thickness.

88 {
89  if(MODsColl.size()!=0)return;
90 
91 
93  iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
94 
95  vector<GeomDet*> Det = tkGeom->dets();
96  for(unsigned int i=0;i<Det.size();i++){
97  DetId Detid = Det[i]->geographicalId();
98 
99  StripGeomDetUnit* StripDetUnit = dynamic_cast<StripGeomDetUnit*> (Det[i]);
100  PixelGeomDetUnit* PixelDetUnit = dynamic_cast<PixelGeomDetUnit*> (Det[i]);
101 
102  stModInfo* MOD = new stModInfo;
103  double Thick=-1, Dist=-1, Norma=-1;
104  if(StripDetUnit){
105  Dist = StripDetUnit->position().mag();
106  Thick = StripDetUnit->surface().bounds().thickness();
107  Norma = MeVperADCStrip/Thick;
108  MOD->Normal = StripDetUnit->surface().normalVector();
109  }else if(PixelDetUnit){
110  Dist = PixelDetUnit->position().mag();
111  Thick = PixelDetUnit->surface().bounds().thickness();
112  Norma = MeVperADCPixel/Thick;
113  MOD->Normal = PixelDetUnit->surface().normalVector();
114  }
115 
116  MOD->DetId = Detid.rawId();
117  MOD->Thickness = Thick;
118  MOD->Distance = Dist;
119  MOD->Normalization = Norma;
120  MOD->Gain = 1;
121  MODsColl[MOD->DetId] = MOD;
122  }
123 
125 }
int i
Definition: DBlmapReader.cc:9
GlobalVector normalVector() const
Definition: Plane.h:47
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
virtual float thickness() const =0
T mag() const
Definition: PV3DBase.h:61
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
__gnu_cxx::hash_map< unsigned int, stModInfo *, __gnu_cxx::hash< unsigned int >, isEqual > MODsColl
Definition: DetId.h:20
const Bounds & bounds() const
Definition: BoundSurface.h:89
const T & get() const
Definition: EventSetup.h:55
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
void DeDxEstimatorProducerPixelTripplet::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 128 of file DeDxEstimatorProducerPixelTripplet.cc.

128  {
129  MODsColl.clear();
130 }
__gnu_cxx::hash_map< unsigned int, stModInfo *, __gnu_cxx::hash< unsigned int >, isEqual > MODsColl
void DeDxEstimatorProducerPixelTripplet::MakeCalibrationMap ( )
private

Definition at line 199 of file DeDxEstimatorProducerPixelTripplet.cc.

References DeDxEstimatorProducerPixelTripplet::stModInfo::Gain.

200 {
201  if(!useCalibration)return;
202 
203  TChain* t1 = new TChain("SiStripCalib/APVGain");
204  t1->Add(m_calibrationPath.c_str());
205 
206  unsigned int tree_DetId;
207  unsigned char tree_APVId;
208  double tree_Gain;
209 
210  t1->SetBranchAddress("DetId" ,&tree_DetId );
211  t1->SetBranchAddress("APVId" ,&tree_APVId );
212  t1->SetBranchAddress("Gain" ,&tree_Gain );
213 
214 
215 
216  for (unsigned int ientry = 0; ientry < t1->GetEntries(); ientry++) {
217  t1->GetEntry(ientry);
218  stModInfo* MOD = MODsColl[tree_DetId];
219  MOD->Gain = tree_Gain;
220  }
221 
222  delete t1;
223 
224 }
__gnu_cxx::hash_map< unsigned int, stModInfo *, __gnu_cxx::hash< unsigned int >, isEqual > MODsColl
void DeDxEstimatorProducerPixelTripplet::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 135 of file DeDxEstimatorProducerPixelTripplet.cc.

References abs, DeDxDiscriminatorTools::charge(), clone(), cond::rpcobgas::detid, DeDxEstimatorProducerPixelTripplet::stModInfo::Distance, edm::helper::Filler< Map >::fill(), edm::Event::getByLabel(), h, edm::helper::Filler< Map >::insert(), j, n, DeDxEstimatorProducerPixelTripplet::stModInfo::Normal, DeDxEstimatorProducerPixelTripplet::stModInfo::Normalization, edm::Handle< T >::product(), edm::Event::put(), python.multivaluedict::sort(), DeDxEstimatorProducerPixelTripplet::stModInfo::Thickness, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

136 {
137  auto_ptr<ValueMap<DeDxData> > trackDeDxEstimateAssociation(new ValueMap<DeDxData> );
138  ValueMap<DeDxData>::Filler filler(*trackDeDxEstimateAssociation);
139 
140  Handle<TrackCollection> trackCollHandle;
141  iEvent.getByLabel(m_trajTrackAssociationTag, trackCollHandle);
142  const TrackCollection trackColl = *trackCollHandle.product();
143 
144  size_t n = trackColl.size();
145  std::vector<DeDxData> dedxEstimate(n);
146 
147  //assume trajectory collection size is equal to track collection size and that order is kept
148  for(unsigned int j=0;j<trackColl.size();j++){
149  const reco::TrackRef track = reco::TrackRef( trackCollHandle.product(), j );
150 
151  DeDxHitCollection dedxHits;
152  vector<DeDxTools::RawHits> hits;
153 // DeDxTools::trajectoryRawHits(traj, hits, usePixel, useStrip);
154 
155 
156  int NClusterSaturating = 0;
157  for(unsigned int h=0;h<track->recHitsSize();h++){
158  //SiStripDetId detid = SiStripDetId((track->recHit(h))->geographicalId());
159  //TrackingRecHit* recHit = (track->recHit(h))->clone();
160 
161  TrackingRecHit* recHit= (track->recHit(h))->clone();
162 
163  if(const SiPixelRecHit* pixelHit=dynamic_cast<const SiPixelRecHit*>(recHit)){
164  if(!usePixel) continue;
165 
166  unsigned int detid = pixelHit->geographicalId();
167  stModInfo* MOD = MODsColl[detid];
168 
169  double cosine = (track->px()*MOD->Normal.x()+track->py()*MOD->Normal.y()+track->pz()*MOD->Normal.z())/track->p();
170  float pathLen = MOD->Thickness/std::abs(cosine);
171  float charge = MOD->Normalization*pixelHit->cluster()->charge()*std::abs(cosine);
172  dedxHits.push_back( DeDxHit( charge, MOD->Distance, pathLen, detid) );
173 
174  }
175  delete recHit;
176  }
178 
179 
180  sort(dedxHits.begin(),dedxHits.end(),less<DeDxHit>());
181  std::pair<float,float> val_and_error = m_estimator->dedx(dedxHits);
182 
183  //WARNING: Since the dEdX Error is not properly computed for the moment
184  //It was decided to store the number of saturating cluster in that dataformat
185  val_and_error.second = NClusterSaturating;
186 
187  dedxEstimate[j] = DeDxData(val_and_error.first, val_and_error.second, dedxHits.size() );
188  }
189  filler.insert(trackCollHandle, dedxEstimate.begin(), dedxEstimate.end());
190 
191  // really fill the association map
192  filler.fill();
193  // put into the event
194  iEvent.put(trackDeDxEstimateAssociation);
195 }
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
std::vector< DeDxHit > DeDxHitCollection
Definition: DeDxHit.h:49
#define abs(x)
Definition: mlp_lapack.h:159
double charge(const std::vector< uint8_t > &Ampls)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
int j
Definition: DBlmapReader.cc:9
__gnu_cxx::hash_map< unsigned int, stModInfo *, __gnu_cxx::hash< unsigned int >, isEqual > MODsColl
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
virtual std::pair< float, float > dedx(const reco::DeDxHitCollection &Hits)=0
T * clone(const T *tp)
Definition: Ptr.h:42
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
T const * product() const
Definition: Handle.h:74
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
Our base class.
Definition: SiPixelRecHit.h:27

Member Data Documentation

std::string DeDxEstimatorProducerPixelTripplet::m_calibrationPath
private

Definition at line 62 of file DeDxEstimatorProducerPixelTripplet.h.

BaseDeDxEstimator* DeDxEstimatorProducerPixelTripplet::m_estimator
private

Definition at line 49 of file DeDxEstimatorProducerPixelTripplet.h.

edm::InputTag DeDxEstimatorProducerPixelTripplet::m_tracksTag
private

Definition at line 52 of file DeDxEstimatorProducerPixelTripplet.h.

edm::InputTag DeDxEstimatorProducerPixelTripplet::m_trajTrackAssociationTag
private

Definition at line 51 of file DeDxEstimatorProducerPixelTripplet.h.

unsigned int DeDxEstimatorProducerPixelTripplet::MaxNrStrips
private

Definition at line 59 of file DeDxEstimatorProducerPixelTripplet.h.

double DeDxEstimatorProducerPixelTripplet::MeVperADCPixel
private

Definition at line 56 of file DeDxEstimatorProducerPixelTripplet.h.

double DeDxEstimatorProducerPixelTripplet::MeVperADCStrip
private

Definition at line 57 of file DeDxEstimatorProducerPixelTripplet.h.

unsigned int DeDxEstimatorProducerPixelTripplet::MinTrackHits
private

Definition at line 60 of file DeDxEstimatorProducerPixelTripplet.h.

__gnu_cxx::hash_map<unsigned int, stModInfo*, __gnu_cxx::hash<unsigned int>, isEqual > DeDxEstimatorProducerPixelTripplet::MODsColl
private

Definition at line 74 of file DeDxEstimatorProducerPixelTripplet.h.

bool DeDxEstimatorProducerPixelTripplet::shapetest
private

Definition at line 64 of file DeDxEstimatorProducerPixelTripplet.h.

bool DeDxEstimatorProducerPixelTripplet::useCalibration
private

Definition at line 63 of file DeDxEstimatorProducerPixelTripplet.h.

bool DeDxEstimatorProducerPixelTripplet::usePixel
private

Definition at line 54 of file DeDxEstimatorProducerPixelTripplet.h.

bool DeDxEstimatorProducerPixelTripplet::useStrip
private

Definition at line 55 of file DeDxEstimatorProducerPixelTripplet.h.