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::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ShallowGainCalibration (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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

Definition at line 59 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 227 of file ShallowGainCalibration.cc.

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

Referenced by produce().

228 {
229  edm::ESHandle<TrackerGeometry> tkGeom; iSetup->get<TrackerDigiGeometryRecord>().get( tkGeom );
230 
231  LocalPoint HitLocalPos = trajState->localPosition();
232  LocalError HitLocalError = trajState->localError().positionError() ;
233 
234  const GeomDetUnit* it = tkGeom->idToDetUnit(DetId(detid));
235  if (dynamic_cast<const StripGeomDetUnit*>(it)==0 && dynamic_cast<const PixelGeomDetUnit*>(it)==0) {
236  std::cout << "this detID doesn't seem to belong to the Tracker" << std::endl;
237  return false;
238  }
239 
240  const BoundPlane plane = it->surface();
241  const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
242  const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
243 
244  double DistFromBorder = 1.0;
245  double HalfLength = it->surface().bounds().length() /2.0;
246 
247  if(trapezoidalBounds)
248  {
249  std::array<const float, 4> const & parameters = (*trapezoidalBounds).parameters();
250  HalfLength = parameters[3];
251  }else if(rectangularBounds){
252  HalfLength = it->surface().bounds().length() /2.0;
253  }else{return false;}
254 
255  if (fabs(HitLocalPos.y())+HitLocalError.yy() >= (HalfLength - DistFromBorder) ) return false;
256 
257  return true;
258 }
dictionary parameters
Definition: Parameters.py:2
virtual float length() const =0
T y() const
Definition: PV3DBase.h:63
const Bounds & bounds() const
Definition: Surface.h:128
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
LocalError positionError() const
float yy() const
Definition: LocalError.h:26
const LocalTrajectoryError & localError() const
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:55
tuple cout
Definition: gather_cfg.py:121
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(), SiStripRecHit1D::cluster(), SiStripRecHit2D::cluster(), edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >::const_iterator, shallow::findTrackIndex(), SiStripCluster::firstStrip(), TrackingRecHit::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::monoCluster(), SiStripMatchedRecHit2D::monoId(), NULL, cmsHarvester::path, Prefix, edm::Event::put(), DetId::rawId(), SiStripMatchedRecHit2D::stereoCluster(), SiStripMatchedRecHit2D::stereoId(), Suffix, theTracksLabel, thickness(), testEve_cfg::tracks, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::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  uint32_t DetId = 0;
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->monoCluster();
80  DetId = sistripmatchedhit->monoId();
81  }else if(sistripmatchedhit && h==1){
82  Cluster = &sistripmatchedhit->stereoCluster();;
83  DetId = sistripmatchedhit->stereoId();
84  }else if(sistripsimplehit){
85  Cluster = (sistripsimplehit->cluster()).get();
86  DetId = sistripsimplehit->geographicalId().rawId();
87  }else if(sistripsimple1dhit){
88  Cluster = (sistripsimple1dhit->cluster()).get();
89  DetId = sistripsimple1dhit->geographicalId().rawId();
90  }else{
91  continue;
92  }
93 
94  LocalVector trackDirection = trajState.localDirection();
95  double cosine = trackDirection.z()/trackDirection.mag();
96  const auto & Ampls = Cluster->amplitudes();
97  int FirstStrip = Cluster->firstStrip();
98  int APVId = FirstStrip/128;
99  bool Saturation = false;
100  bool Overlapping = false;
101  unsigned int Charge = 0;
102  double Path = (10.0*thickness(DetId))/fabs(cosine);
103  double PrevGain = -1;
104 
105  if(gainHandle.isValid()){
106  SiStripApvGain::Range detGainRange = gainHandle->getRange(DetId);
107  PrevGain = *(detGainRange.first + APVId);
108  }
109 
110  for(unsigned int a=0;a<Ampls.size();a++){
111  Charge+=Ampls[a];
112  if(Ampls[a] >=254)Saturation =true;
113  amplitude->push_back( Ampls[a] );
114  }
115  double ChargeOverPath = (double)Charge / Path ;
116 
117  if(FirstStrip==0 )Overlapping=true;
118  if(FirstStrip==128 )Overlapping=true;
119  if(FirstStrip==256 )Overlapping=true;
120  if(FirstStrip==384 )Overlapping=true;
121  if(FirstStrip==512 )Overlapping=true;
122  if(FirstStrip==640 )Overlapping=true;
123 
124  if(FirstStrip<=127 && FirstStrip+Ampls.size()>127)Overlapping=true;
125  if(FirstStrip<=255 && FirstStrip+Ampls.size()>255)Overlapping=true;
126  if(FirstStrip<=383 && FirstStrip+Ampls.size()>383)Overlapping=true;
127  if(FirstStrip<=511 && FirstStrip+Ampls.size()>511)Overlapping=true;
128  if(FirstStrip<=639 && FirstStrip+Ampls.size()>639)Overlapping=true;
129 
130  if(FirstStrip+Ampls.size()==127 )Overlapping=true;
131  if(FirstStrip+Ampls.size()==255 )Overlapping=true;
132  if(FirstStrip+Ampls.size()==383 )Overlapping=true;
133  if(FirstStrip+Ampls.size()==511 )Overlapping=true;
134  if(FirstStrip+Ampls.size()==639 )Overlapping=true;
135  if(FirstStrip+Ampls.size()==767 )Overlapping=true;
136 
137  trackindex ->push_back( shallow::findTrackIndex(tracks, track) );
138  rawid ->push_back( DetId );
139  localdirx ->push_back( trackDirection.x() );
140  localdiry ->push_back( trackDirection.y() );
141  localdirz ->push_back( trackDirection.z() );
142  firststrip ->push_back( FirstStrip );
143  nstrips ->push_back( Ampls.size() );
144  saturation ->push_back( Saturation );
145  overlapping ->push_back( Overlapping );
146  farfromedge ->push_back( IsFarFromBorder(&trajState,DetId, &iSetup) );
147  charge ->push_back( Charge );
148  path ->push_back( Path );
149  chargeoverpath->push_back( ChargeOverPath );
150  gainused ->push_back( PrevGain );
151  }
152  }
153  }
154 
155  iEvent.put(trackindex, Prefix + "trackindex" + Suffix );
156  iEvent.put(rawid , Prefix + "rawid" + Suffix );
157  iEvent.put(localdirx , Prefix + "localdirx" + Suffix );
158  iEvent.put(localdiry , Prefix + "localdiry" + Suffix );
159  iEvent.put(localdirz , Prefix + "localdirz" + Suffix );
160  iEvent.put(firststrip, Prefix + "firststrip" + Suffix );
161  iEvent.put(nstrips, Prefix + "nstrips" + Suffix );
162  iEvent.put(saturation, Prefix + "saturation" + Suffix );
163  iEvent.put(overlapping, Prefix + "overlapping" + Suffix );
164  iEvent.put(farfromedge, Prefix + "farfromedge" + Suffix );
165  iEvent.put(charge, Prefix + "charge" + Suffix );
166  iEvent.put(path, Prefix + "path" + Suffix );
167  iEvent.put(chargeoverpath,Prefix + "chargeoverpath"+ Suffix );
168  iEvent.put(amplitude, Prefix + "amplitude" + Suffix );
169  iEvent.put(gainused, Prefix + "gainused" + Suffix );
170 }
ClusterRef cluster() const
unsigned int stereoId() const
int findTrackIndex(const edm::Handle< edm::View< reco::Track > > &h, const reco::Track *t)
Definition: ShallowTools.cc:29
SiStripCluster const & monoCluster() const
LocalVector localDirection() const
T y() const
Definition: PV3DBase.h:63
#define NULL
Definition: scimark2.h:8
uint16_t firstStrip() const
bool IsFarFromBorder(TrajectoryStateOnSurface *trajState, const uint32_t detid, const edm::EventSetup *iSetup)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
DataContainer const & measurements() const
Definition: Trajectory.h:203
T mag() const
Definition: PV3DBase.h:67
tuple path
else: Piece not in the list, fine.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
Definition: Path.h:40
T z() const
Definition: PV3DBase.h:64
std::pair< ContainerIterator, ContainerIterator > Range
ClusterRef cluster() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:413
Definition: DetId.h:18
const TrackerGeometry * m_tracker
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:55
SiStripCluster const & stereoCluster() const
double a
Definition: hdecay.h:121
unsigned int monoId() const
DetId geographicalId() const
bool isValid() const
Definition: ESHandle.h:47
T x() const
Definition: PV3DBase.h:62
const std::vector< uint8_t > & amplitudes() const
double ShallowGainCalibration::thickness ( DetId  id)
private

Definition at line 261 of file ShallowGainCalibration.cc.

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

Referenced by produce().

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

Member Data Documentation

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

Definition at line 74 of file ShallowGainCalibration.h.

Referenced by thickness().

const TrackerGeometry* ShallowGainCalibration::m_tracker
private

Definition at line 73 of file ShallowGainCalibration.h.

Referenced by produce(), and thickness().

std::string ShallowGainCalibration::Prefix
private

Definition at line 65 of file ShallowGainCalibration.h.

Referenced by produce(), and ShallowGainCalibration().

std::string ShallowGainCalibration::Suffix
private

Definition at line 64 of file ShallowGainCalibration.h.

Referenced by produce(), and ShallowGainCalibration().

edm::InputTag ShallowGainCalibration::theTracksLabel
private

Definition at line 63 of file ShallowGainCalibration.h.

Referenced by produce().