CMS 3D CMS Logo

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

#include <ShallowGainCalibration.h>

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

Public Member Functions

 ShallowGainCalibration (const edm::ParameterSet &)
 
- 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

bool IsFarFromBorder (TrajectoryStateOnSurface *trajState, const uint32_t detid, const edm::EventSetup *iSetup)
 
void produce (edm::Event &, const edm::EventSetup &)
 
double thickness (DetId id)
 

Private Attributes

std::map< DetId, double > m_thicknessMap
 
const TrackerGeometrym_tracker
 
std::string Prefix
 
std::string Suffix
 
edm::InputTag theTracksLabel
 

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

Definition at line 63 of file ShallowGainCalibration.h.

Constructor & Destructor Documentation

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

Definition at line 12 of file ShallowGainCalibration.cc.

References Prefix, and Suffix.

13  : theTracksLabel( iConfig.getParameter<edm::InputTag>("Tracks") ),
14  Suffix ( iConfig.getParameter<std::string>("Suffix") ),
15  Prefix ( iConfig.getParameter<std::string>("Prefix") )
16 {
17  produces <std::vector<int> > ( Prefix + "trackindex" + Suffix );
18  produces <std::vector<unsigned int> > ( Prefix + "rawid" + Suffix );
19  produces <std::vector<float> > ( Prefix + "localdirx" + Suffix );
20  produces <std::vector<float> > ( Prefix + "localdiry" + Suffix );
21  produces <std::vector<float> > ( Prefix + "localdirz" + Suffix );
22  produces <std::vector<unsigned short> > ( Prefix + "firststrip" + Suffix );
23  produces <std::vector<unsigned short> > ( Prefix + "nstrips" + Suffix );
24  produces <std::vector<bool> > ( Prefix + "saturation" + Suffix );
25  produces <std::vector<bool> > ( Prefix + "overlapping" + Suffix );
26  produces <std::vector<bool> > ( Prefix + "farfromedge" + Suffix );
27  produces <std::vector<unsigned int> > ( Prefix + "charge" + Suffix );
28  produces <std::vector<float> > ( Prefix + "path" + Suffix );
29  produces <std::vector<float> > ( Prefix + "chargeoverpath" + Suffix );
30  produces <std::vector<unsigned char> > ( Prefix + "amplitude" + Suffix );
31  produces <std::vector<double> > ( Prefix + "gainused" + Suffix );
32 }
T getParameter(std::string const &) const

Member Function Documentation

bool ShallowGainCalibration::IsFarFromBorder ( TrajectoryStateOnSurface trajState,
const uint32_t  detid,
const edm::EventSetup iSetup 
)
private

Definition at line 224 of file ShallowGainCalibration.cc.

References BoundSurface::bounds(), gather_cfg::cout, edm::EventSetup::get(), Bounds::length(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localPosition(), Parameters::parameters, LocalTrajectoryError::positionError(), GeomDet::surface(), matplotRender::t, Bounds::width(), PV3DBase< T, PVType, FrameType >::y(), and LocalError::yy().

Referenced by produce().

225 {
226  edm::ESHandle<TrackerGeometry> tkGeom; iSetup->get<TrackerDigiGeometryRecord>().get( tkGeom );
227 
228  LocalPoint HitLocalPos = trajState->localPosition();
229  LocalError HitLocalError = trajState->localError().positionError() ;
230 
231  const GeomDetUnit* it = tkGeom->idToDetUnit(DetId(detid));
232  if (dynamic_cast<const StripGeomDetUnit*>(it)==0 && dynamic_cast<const PixelGeomDetUnit*>(it)==0) {
233  std::cout << "this detID doesn't seem to belong to the Tracker" << std::endl;
234  return false;
235  }
236 
237  const BoundPlane plane = it->surface();
238  const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
239  const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
240 
241  double DistFromBorder = 1.0;
242  double HalfWidth = it->surface().bounds().width() /2.0;
243  double HalfLength = it->surface().bounds().length() /2.0;
244 
245  if(trapezoidalBounds)
246  {
247  std::vector<float> const & parameters = (*trapezoidalBounds).parameters();
248  HalfLength = parameters[3];
249  double t = (HalfLength + HitLocalPos.y()) / (2*HalfLength) ;
250  HalfWidth = parameters[0] + (parameters[1]-parameters[0]) * t;
251  }else if(rectangularBounds){
252  HalfWidth = it->surface().bounds().width() /2.0;
253  HalfLength = it->surface().bounds().length() /2.0;
254  }else{return false;}
255 
256 // if (fabs(HitLocalPos.x())+HitLocalError.xx() >= (HalfWidth - DistFromBorder) ) return false;//Don't think is really necessary
257  if (fabs(HitLocalPos.y())+HitLocalError.yy() >= (HalfLength - DistFromBorder) ) return false;
258 
259  return true;
260 }
dictionary parameters
Definition: Parameters.py:2
virtual float length() const =0
T y() const
Definition: PV3DBase.h:57
LocalError positionError() const
float yy() const
Definition: LocalError.h:21
const LocalTrajectoryError & localError() const
Definition: DetId.h:20
const Bounds & bounds() const
Definition: BoundSurface.h:89
const T & get() const
Definition: EventSetup.h:55
tuple cout
Definition: gather_cfg.py:41
virtual float width() const =0
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
void ShallowGainCalibration::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 35 of file ShallowGainCalibration.cc.

References a, SiStripCluster::amplitudes(), DeDxDiscriminatorTools::charge(), SiStripRecHit2D::cluster(), SiStripRecHit1D::cluster(), shallow::findTrackIndex(), SiStripCluster::firstStrip(), SiStripCluster::geographicalId(), edm::EventSetup::get(), edm::Event::getByLabel(), h, IsFarFromBorder(), edm::ESHandleBase::isValid(), TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localDirection(), m_tracker, PV3DBase< T, PVType, FrameType >::mag(), Trajectory::measurements(), SiStripMatchedRecHit2D::monoHit(), NULL, path(), Prefix, edm::Event::put(), SiStripMatchedRecHit2D::stereoHit(), Suffix, theTracksLabel, thickness(), testEve_cfg::tracks, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by python.JSONExport.JsonExport::export(), and python.HTMLExport.HTMLExport::export().

35  {
36  std::auto_ptr<std::vector<int> > trackindex ( new std::vector<int> );
37  std::auto_ptr<std::vector<unsigned int> > rawid ( new std::vector<unsigned int> );
38  std::auto_ptr<std::vector<float> > localdirx ( new std::vector<float> );
39  std::auto_ptr<std::vector<float> > localdiry ( new std::vector<float> );
40  std::auto_ptr<std::vector<float> > localdirz ( new std::vector<float> );
41  std::auto_ptr<std::vector<unsigned short> > firststrip ( new std::vector<unsigned short> );
42  std::auto_ptr<std::vector<unsigned short> > nstrips ( new std::vector<unsigned short> );
43  std::auto_ptr<std::vector<bool> > saturation ( new std::vector<bool> );
44  std::auto_ptr<std::vector<bool> > overlapping ( new std::vector<bool> );
45  std::auto_ptr<std::vector<bool> > farfromedge ( new std::vector<bool> );
46  std::auto_ptr<std::vector<unsigned int> > charge ( new std::vector<unsigned int> );
47  std::auto_ptr<std::vector<float> > path ( new std::vector<float> );
48  std::auto_ptr<std::vector<float> > chargeoverpath( new std::vector<float> );
49  std::auto_ptr<std::vector<unsigned char> > amplitude ( new std::vector<unsigned char> );
50  std::auto_ptr<std::vector<double> > gainused ( new std::vector<double> );
51 
52  edm::ESHandle<TrackerGeometry> theTrackerGeometry; iSetup.get<TrackerDigiGeometryRecord>().get( theTrackerGeometry );
53  m_tracker=&(* theTrackerGeometry );
54  edm::ESHandle<SiStripGain> gainHandle; iSetup.get<SiStripGainRcd>().get(gainHandle);
56  edm::Handle<TrajTrackAssociationCollection> associations; iEvent.getByLabel(theTracksLabel, associations);
57 
58  for( TrajTrackAssociationCollection::const_iterator association = associations->begin(); association != associations->end(); association++) {
59  const Trajectory* traj = association->key.get();
60  const reco::Track* track = association->val.get();
61 
62  vector<TrajectoryMeasurement> measurements = traj->measurements();
63  for(vector<TrajectoryMeasurement>::const_iterator measurement_it = measurements.begin(); measurement_it!=measurements.end(); measurement_it++){
64  TrajectoryStateOnSurface trajState = measurement_it->updatedState();
65  if( !trajState.isValid() ) continue;
66 
67  const TrackingRecHit* hit = (*measurement_it->recHit()).hit();
68  const SiStripRecHit1D* sistripsimple1dhit = dynamic_cast<const SiStripRecHit1D*>(hit);
69  const SiStripRecHit2D* sistripsimplehit = dynamic_cast<const SiStripRecHit2D*>(hit);
70  const SiStripMatchedRecHit2D* sistripmatchedhit = dynamic_cast<const SiStripMatchedRecHit2D*>(hit);
71 
72  const SiStripCluster* Cluster = NULL;
73 
74 
75  for(unsigned int h=0;h<2;h++){
76  if(!sistripmatchedhit && h==1){
77  continue;
78  }else if(sistripmatchedhit && h==0){
79  Cluster = (sistripmatchedhit->monoHit() ->cluster()).get();
80  }else if(sistripmatchedhit && h==1){
81  Cluster = (sistripmatchedhit->stereoHit()->cluster()).get();
82  }else if(sistripsimplehit){
83  Cluster = (sistripsimplehit->cluster()).get();
84  }else if(sistripsimple1dhit){
85  Cluster = (sistripsimple1dhit->cluster()).get();
86  }else{
87  continue;
88  }
89 
90  LocalVector trackDirection = trajState.localDirection();
91  double cosine = trackDirection.z()/trackDirection.mag();
92  const vector<uint8_t>& Ampls = Cluster->amplitudes();
93  uint32_t DetId = Cluster->geographicalId();
94  int FirstStrip = Cluster->firstStrip();
95  int APVId = FirstStrip/128;
96  bool Saturation = false;
97  bool Overlapping = false;
98  unsigned int Charge = 0;
99  double Path = (10.0*thickness(DetId))/fabs(cosine);
100  double PrevGain = -1;
101 
102  if(gainHandle.isValid()){
103  SiStripApvGain::Range detGainRange = gainHandle->getRange(DetId);
104  PrevGain = *(detGainRange.first + APVId);
105  }
106 
107  for(unsigned int a=0;a<Ampls.size();a++){
108  Charge+=Ampls[a];
109  if(Ampls[a] >=254)Saturation =true;
110  amplitude->push_back( Ampls[a] );
111  }
112  double ChargeOverPath = (double)Charge / Path ;
113 
114  if(FirstStrip==0 )Overlapping=true;
115  if(FirstStrip==128 )Overlapping=true;
116  if(FirstStrip==256 )Overlapping=true;
117  if(FirstStrip==384 )Overlapping=true;
118  if(FirstStrip==512 )Overlapping=true;
119  if(FirstStrip==640 )Overlapping=true;
120 
121  if(FirstStrip<=127 && FirstStrip+Ampls.size()>127)Overlapping=true;
122  if(FirstStrip<=255 && FirstStrip+Ampls.size()>255)Overlapping=true;
123  if(FirstStrip<=383 && FirstStrip+Ampls.size()>383)Overlapping=true;
124  if(FirstStrip<=511 && FirstStrip+Ampls.size()>511)Overlapping=true;
125  if(FirstStrip<=639 && FirstStrip+Ampls.size()>639)Overlapping=true;
126 
127  if(FirstStrip+Ampls.size()==127 )Overlapping=true;
128  if(FirstStrip+Ampls.size()==255 )Overlapping=true;
129  if(FirstStrip+Ampls.size()==383 )Overlapping=true;
130  if(FirstStrip+Ampls.size()==511 )Overlapping=true;
131  if(FirstStrip+Ampls.size()==639 )Overlapping=true;
132  if(FirstStrip+Ampls.size()==767 )Overlapping=true;
133 
134  trackindex ->push_back( shallow::findTrackIndex(tracks, track) );
135  rawid ->push_back( DetId );
136  localdirx ->push_back( trackDirection.x() );
137  localdiry ->push_back( trackDirection.y() );
138  localdirz ->push_back( trackDirection.z() );
139  firststrip ->push_back( FirstStrip );
140  nstrips ->push_back( Ampls.size() );
141  saturation ->push_back( Saturation );
142  overlapping ->push_back( Overlapping );
143  farfromedge ->push_back( IsFarFromBorder(&trajState,DetId, &iSetup) );
144  charge ->push_back( Charge );
145  path ->push_back( Path );
146  chargeoverpath->push_back( ChargeOverPath );
147  gainused ->push_back( PrevGain );
148  }
149  }
150  }
151 
152  iEvent.put(trackindex, Prefix + "trackindex" + Suffix );
153  iEvent.put(rawid , Prefix + "rawid" + Suffix );
154  iEvent.put(localdirx , Prefix + "localdirx" + Suffix );
155  iEvent.put(localdiry , Prefix + "localdiry" + Suffix );
156  iEvent.put(localdirz , Prefix + "localdirz" + Suffix );
157  iEvent.put(firststrip, Prefix + "firststrip" + Suffix );
158  iEvent.put(nstrips, Prefix + "nstrips" + Suffix );
159  iEvent.put(saturation, Prefix + "saturation" + Suffix );
160  iEvent.put(overlapping, Prefix + "overlapping" + Suffix );
161  iEvent.put(farfromedge, Prefix + "farfromedge" + Suffix );
162  iEvent.put(charge, Prefix + "charge" + Suffix );
163  iEvent.put(path, Prefix + "path" + Suffix );
164  iEvent.put(chargeoverpath,Prefix + "chargeoverpath"+ Suffix );
165  iEvent.put(amplitude, Prefix + "amplitude" + Suffix );
166  iEvent.put(gainused, Prefix + "gainused" + Suffix );
167 }
int findTrackIndex(const edm::Handle< edm::View< reco::Track > > &h, const reco::Track *t)
Definition: ShallowTools.cc:29
const SiStripRecHit2D * stereoHit() const
LocalVector localDirection() const
T y() const
Definition: PV3DBase.h:57
#define NULL
Definition: scimark2.h:8
uint16_t firstStrip() const
double charge(const std::vector< uint8_t > &Ampls)
bool IsFarFromBorder(TrajectoryStateOnSurface *trajState, const uint32_t detid, const edm::EventSetup *iSetup)
int path() const
Definition: HLTadd.h:3
uint32_t geographicalId() const
DataContainer const & measurements() const
Definition: Trajectory.h:169
T mag() const
Definition: PV3DBase.h:61
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
Definition: Path.h:29
T z() const
Definition: PV3DBase.h:58
std::pair< ContainerIterator, ContainerIterator > Range
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
Definition: DetId.h:20
const TrackerGeometry * m_tracker
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:55
ClusterRef const & cluster() const
double a
Definition: hdecay.h:121
ClusterRef const & cluster() const
bool isValid() const
Definition: ESHandle.h:37
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
const SiStripRecHit2D * monoHit() const
T x() const
Definition: PV3DBase.h:56
const std::vector< uint8_t > & amplitudes() const
double ShallowGainCalibration::thickness ( DetId  id)
private

Definition at line 263 of file ShallowGainCalibration.cc.

References TrackerGeometry::idToDetUnit(), m_thicknessMap, and m_tracker.

Referenced by produce().

264 {
265  map<DetId,double>::iterator th=m_thicknessMap.find(id);
266  if(th!=m_thicknessMap.end())
267  return (*th).second;
268  else {
269  double detThickness=1.;
270  //compute thickness normalization
271  const GeomDetUnit* it = m_tracker->idToDetUnit(DetId(id));
272  bool isPixel = dynamic_cast<const PixelGeomDetUnit*>(it)!=0;
273  bool isStrip = dynamic_cast<const StripGeomDetUnit*>(it)!=0;
274  if (!isPixel && ! isStrip) {
275  //FIXME throw exception
276  edm::LogWarning("DeDxHitsProducer") << "\t\t this detID doesn't seem to belong to the Tracker";
277  detThickness = 1.;
278  }else{
279  detThickness = it->surface().bounds().thickness();
280  }
281 
282  m_thicknessMap[id]=detThickness;//computed value
283  return detThickness;
284  }
285 
286 }
std::map< DetId, double > m_thicknessMap
Definition: DetId.h:20
const TrackerGeometry * m_tracker
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.

Member Data Documentation

std::map<DetId,double> ShallowGainCalibration::m_thicknessMap
private

Definition at line 78 of file ShallowGainCalibration.h.

Referenced by thickness().

const TrackerGeometry* ShallowGainCalibration::m_tracker
private

Definition at line 77 of file ShallowGainCalibration.h.

Referenced by produce(), and thickness().

std::string ShallowGainCalibration::Prefix
private

Definition at line 69 of file ShallowGainCalibration.h.

Referenced by produce(), and ShallowGainCalibration().

std::string ShallowGainCalibration::Suffix
private

Definition at line 68 of file ShallowGainCalibration.h.

Referenced by produce(), and ShallowGainCalibration().

edm::InputTag ShallowGainCalibration::theTracksLabel
private

Definition at line 67 of file ShallowGainCalibration.h.

Referenced by produce().