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
SiStripFineDelayHit Class Reference

#include <DQM/SiStripCommissioningSources/plugins/tracking/SiStripFineDelayHit.cc>

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

Public Member Functions

 SiStripFineDelayHit (const edm::ParameterSet &)
 
virtual ~SiStripFineDelayHit ()
 
- 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 &, const edm::EventSetup &)
 
std::pair< const
SiStripCluster *, double > 
closestCluster (const TrackerGeometry &tracker, const reco::Track *tk, const uint32_t &detId, const edmNew::DetSetVector< SiStripCluster > &clusters, const edm::DetSetVector< SiStripDigi > &hits)
 
std::vector< std::pair
< uint32_t, std::pair< double,
double > > > 
detId (const TrackerGeometry &tracker, const reco::Track *tk, const std::vector< Trajectory > &trajVec, const StripSubdetector::SubDetector subdet=StripSubdetector::TIB, const int substructure=0xff)
 
std::vector< std::pair
< uint32_t, std::pair< double,
double > > > 
detId (const TrackerGeometry &tracker, const reco::Track *tk, const std::vector< Trajectory > &trajVec, const uint32_t &maskDetId, const uint32_t &rootDetId)
 
std::pair< uint32_t, uint32_t > deviceMask (const StripSubdetector::SubDetector subdet, const int substructure)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
virtual void produceNoTracking (edm::Event &, const edm::EventSetup &)
 
bool rechit (reco::Track *tk, uint32_t detId)
 

Private Attributes

SiStripFineDelayTLAanglefinder_
 
edm::InputTag clusterLabel_
 
std::map< uint32_t, uint32_t > connectionMap_
 
bool cosmic_
 
edm::InputTag digiLabel_
 
const edm::Eventevent_
 
int explorationWindow_
 
bool field_
 
bool homeMadeClusters_
 
edm::InputTag inputModuleLabel_
 
double maxAngle_
 
double maxClusterDistance_
 
double minTrackP2_
 
int mode_
 
bool noTracking_
 
edm::InputTag seedLabel_
 
edm::InputTag trackLabel_
 
bool trajInEvent_
 

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 32 of file SiStripFineDelayHit.h.

Constructor & Destructor Documentation

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

Definition at line 88 of file SiStripFineDelayHit.cc.

References anglefinder_, clusterLabel_, cosmic_, digiLabel_, explorationWindow_, field_, edm::ParameterSet::getParameter(), homeMadeClusters_, inputModuleLabel_, maxAngle_, maxClusterDistance_, minTrackP2_, mode_, noTracking_, seedLabel_, trackLabel_, and trajInEvent_.

88  :event_(0)
89 {
90  //register your products
91  produces<edm::DetSetVector<SiStripRawDigi> >("FineDelaySelection");
92  //now do what ever other initialization is needed
93  anglefinder_=new SiStripFineDelayTLA(iConfig);
94  cosmic_ = iConfig.getParameter<bool>("cosmic");
95  field_ = iConfig.getParameter<bool>("MagneticField");
96  trajInEvent_ = iConfig.getParameter<bool>("TrajInEvent");
97  maxAngle_ = iConfig.getParameter<double>("MaxTrackAngle");
98  minTrackP2_ = iConfig.getParameter<double>("MinTrackMomentum")*iConfig.getParameter<double>("MinTrackMomentum");
99  maxClusterDistance_ = iConfig.getParameter<double>("MaxClusterDistance");
100  clusterLabel_ = iConfig.getParameter<edm::InputTag>("ClustersLabel");
101  trackLabel_ = iConfig.getParameter<edm::InputTag>("TracksLabel");
102  seedLabel_ = iConfig.getParameter<edm::InputTag>("SeedsLabel");
103  inputModuleLabel_ = iConfig.getParameter<edm::InputTag>( "InputModuleLabel" ) ;
104  digiLabel_ = iConfig.getParameter<edm::InputTag>("DigiLabel");
105  homeMadeClusters_ = iConfig.getParameter<bool>("NoClustering");
106  explorationWindow_ = iConfig.getParameter<uint32_t>("ExplorationWindow");
107  noTracking_ = iConfig.getParameter<bool>("NoTracking");
108  mode_=0;
109 }
T getParameter(std::string const &) const
edm::InputTag clusterLabel_
SiStripFineDelayTLA * anglefinder_
edm::InputTag inputModuleLabel_
const edm::Event * event_
SiStripFineDelayHit::~SiStripFineDelayHit ( )
virtual

Definition at line 111 of file SiStripFineDelayHit.cc.

References anglefinder_.

112 {
113  // do anything here that needs to be done at desctruction time
114  // (e.g. close files, deallocate resources etc.)
115  delete anglefinder_;
116 }
SiStripFineDelayTLA * anglefinder_

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 567 of file SiStripFineDelayHit.cc.

References connectionMap_, edm::EventSetup::get(), and sistrip::invalid_.

568 {
569  // Retrieve FED cabling object
571  iSetup.get<SiStripFedCablingRcd>().get( cabling );
572  const std::vector< uint16_t > & feds = cabling->feds() ;
573  for(std::vector< uint16_t >::const_iterator fedid = feds.begin();fedid<feds.end();++fedid) {
574  const std::vector< FedChannelConnection > & connections = cabling->connections(*fedid);
575  for(std::vector< FedChannelConnection >::const_iterator conn=connections.begin();conn<connections.end();++conn) {
576  /*
577  SiStripFedKey key(conn->fedId(),
578  SiStripFedKey::feUnit(conn->fedCh()),
579  SiStripFedKey::feChan(conn->fedCh()));
580  connectionMap_[conn->detId()] = key.key();
581  */
582  // the key is computed using an alternate formula for performance reasons.
583  connectionMap_[conn->detId()] = ( ( conn->fedId() & sistrip::invalid_ ) << 16 ) | ( conn->fedCh() & sistrip::invalid_ );
584  }
585  }
586 }
std::map< uint32_t, uint32_t > connectionMap_
const T & get() const
Definition: EventSetup.h:55
static const uint16_t invalid_
Definition: Constants.h:17
std::pair< const SiStripCluster *, double > SiStripFineDelayHit::closestCluster ( const TrackerGeometry tracker,
const reco::Track tk,
const uint32_t &  detId,
const edmNew::DetSetVector< SiStripCluster > &  clusters,
const edm::DetSetVector< SiStripDigi > &  hits 
)
private

Definition at line 258 of file SiStripFineDelayHit.cc.

References SiStripCluster::barycenter(), begin, edm::DetSetVector< T >::begin(), edmNew::DetSetVector< T >::begin(), end, edm::DetSet< T >::end(), edm::DetSetVector< T >::end(), edmNew::DetSetVector< T >::end(), explorationWindow_, TrackingRecHit::geographicalId(), homeMadeClusters_, TrackerGeometry::idToDet(), TrackingRecHit::isValid(), BaseSiTrackerRecHit2DLocalPos::localPosition(), LogDebug, Topology::measurementPosition(), SiStripMatchedRecHit2D::monoHit(), NULL, L1TEmulatorMonitor_cff::p, reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), query::result, SiStripMatchedRecHit2D::stereoHit(), GeomDetUnit::topology(), and PV2DBase< T, PVType, FrameType >::x().

Referenced by produce().

259 {
260  std::pair<const SiStripCluster*,double> result(NULL,0.);
261  double hitStrip = -1;
262  int nstrips = -1;
263  // localize the crossing point of the track on the module
264  for(trackingRecHit_iterator it = tk->recHitsBegin(); it != tk->recHitsEnd(); it++) {
265  LogDebug("closestCluster") << "(*it)->geographicalId().rawId() vs det_id" << (*it)->geographicalId().rawId() << " " << det_id;
266  //handle the mono rechits
267  if((*it)->geographicalId().rawId() == det_id) {
268  if(!(*it)->isValid()) continue;
269  LogDebug("closestCluster") << " using the single mono hit";
270  LocalPoint lp = (*it)->localPosition();
271  const GeomDetUnit* gdu = static_cast<const GeomDetUnit*>(tracker.idToDet((*it)->geographicalId()));
273  hitStrip = p.x();
274  nstrips = (dynamic_cast<const StripTopology*>(&(gdu->topology())))->nstrips();
275  break;
276  }
277  //handle stereo part of matched hits
278  //one could try to cast to SiStripMatchedRecHit2D but it is faster to look at the detid
279  else if((det_id - (*it)->geographicalId().rawId())==1) {
280  const SiStripMatchedRecHit2D* hit2D = dynamic_cast<const SiStripMatchedRecHit2D*>(&(**it));
281  if(!hit2D) continue; // this is a security that should never trigger
282  const SiStripRecHit2D* stereo = hit2D->stereoHit();
283  if(!stereo) continue; // this is a security that should never trigger
284  if(!stereo->isValid()) continue;
285  LogDebug("closestCluster") << " using the stereo hit";
286  LocalPoint lp = stereo->localPosition();
287  const GeomDetUnit* gdu = static_cast<const GeomDetUnit*>(tracker.idToDet(stereo->geographicalId()));
289  hitStrip = p.x();
290  nstrips = (dynamic_cast<const StripTopology*>(&(gdu->topology())))->nstrips();
291  break;
292  }
293  //handle mono part of matched hits
294  //one could try to cast to SiStripMatchedRecHit2D but it is faster to look at the detid
295  else if((det_id - (*it)->geographicalId().rawId())==2) {
296  const SiStripMatchedRecHit2D* hit2D = dynamic_cast<const SiStripMatchedRecHit2D*>(&(**it));
297  if(!hit2D) continue; // this is a security that should never trigger
298  const SiStripRecHit2D* mono = hit2D->monoHit();
299  if(!mono) continue; // this is a security that should never trigger
300  if(!mono->isValid()) continue;
301  LogDebug("closestCluster") << " using the mono hit";
302  LocalPoint lp = mono->localPosition();
303  const GeomDetUnit* gdu = static_cast<const GeomDetUnit*>(tracker.idToDet(mono->geographicalId()));
305  hitStrip = p.x();
306  nstrips = (dynamic_cast<const StripTopology*>(&(gdu->topology())))->nstrips();
307  break;
308  }
309  }
310  LogDebug("closestCluster") << " hit strip = " << hitStrip;
311  if(hitStrip<0) return result;
312  if(homeMadeClusters_) {
313  // take the list of digis on the module
314  for (edm::DetSetVector<SiStripDigi>::const_iterator DSViter=hits.begin(); DSViter!=hits.end();DSViter++){
315  if(DSViter->id==det_id) {
316  // loop from hitstrip-n to hitstrip+n (explorationWindow_) and select the highest strip
317  int minStrip = int(round(hitStrip))- explorationWindow_;
318  minStrip = minStrip<0 ? 0 : minStrip;
319  int maxStrip = int(round(hitStrip)) + explorationWindow_ + 1;
320  maxStrip = maxStrip>=nstrips ? nstrips-1 : maxStrip;
321  edm::DetSet<SiStripDigi>::const_iterator rangeStart = DSViter->end();
322  edm::DetSet<SiStripDigi>::const_iterator rangeStop = DSViter->end();
323  for(edm::DetSet<SiStripDigi>::const_iterator digiIt = DSViter->begin(); digiIt!=DSViter->end(); ++digiIt) {
324  if(digiIt->strip()>=minStrip && rangeStart == DSViter->end()) rangeStart = digiIt;
325  if(digiIt->strip()<=maxStrip) rangeStop = digiIt;
326  }
327  if(rangeStart != DSViter->end()) {
328  if(rangeStop !=DSViter->end()) ++rangeStop;
329  // build a fake cluster
330  LogDebug("closestCluster") << "build a fake cluster ";
331  SiStripCluster* newCluster = new SiStripCluster(det_id,SiStripCluster::SiStripDigiRange(rangeStart,rangeStop)); // /!\ ownership transfered
332  result.first = newCluster;
333  result.second = fabs(newCluster->barycenter()-hitStrip);
334  }
335  break;
336  }
337  }
338  } else {
339  // loop on the detsetvector<cluster> to find the right one
340  for (edmNew::DetSetVector<SiStripCluster>::const_iterator DSViter=clusters.begin(); DSViter!=clusters.end();DSViter++ )
341  if(DSViter->id()==det_id) {
342  LogDebug("closestCluster") << " detset with the right detid. ";
345  //find the cluster close to the hitStrip
346  result.second = 1000.;
347  for(edmNew::DetSet<SiStripCluster>::const_iterator iter=begin;iter!=end;++iter) {
348  double dist = fabs(iter->barycenter()-hitStrip);
349  if(dist<result.second) { result.second = dist; result.first = &(*iter); }
350  }
351  break;
352  }
353  }
354  return result;
355 }
#define LogDebug(id)
iterator end()
Definition: DetSet.h:50
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator begin() const
std::pair< SiStripDigiIter, SiStripDigiIter > SiStripDigiRange
const SiStripRecHit2D * stereoHit() const
#define NULL
Definition: scimark2.h:8
data_type const * const_iterator
Definition: DetSetNew.h:25
virtual LocalPoint localPosition() const
virtual const Topology & topology() const =0
tuple result
Definition: query.py:137
float barycenter() const
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
#define end
Definition: vmac.h:38
const_iterator end() const
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:63
virtual const GeomDet * idToDet(DetId) const
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:352
bool isValid() const
#define begin
Definition: vmac.h:31
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:337
DetId geographicalId() const
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:105
const SiStripRecHit2D * monoHit() const
T x() const
Definition: PV2DBase.h:39
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:65
std::vector< std::pair< uint32_t, std::pair< double, double > > > SiStripFineDelayHit::detId ( const TrackerGeometry tracker,
const reco::Track tk,
const std::vector< Trajectory > &  trajVec,
const StripSubdetector::SubDetector  subdet = StripSubdetector::TIB,
const int  substructure = 0xff 
)
private

Definition at line 154 of file SiStripFineDelayHit.cc.

References deviceMask().

Referenced by produce().

155 {
156  if(substructure==0xff) return detId(tracker,tk,trajVec,0,0);
157  // first determine the root detId we are looking for
158  std::pair<uint32_t, uint32_t> mask = deviceMask(subdet,substructure);
159  // then call the method that loops on recHits
160  return detId(tracker,tk,trajVec,mask.first,mask.second);
161 }
std::vector< std::pair< uint32_t, std::pair< double, double > > > detId(const TrackerGeometry &tracker, const reco::Track *tk, const std::vector< Trajectory > &trajVec, const StripSubdetector::SubDetector subdet=StripSubdetector::TIB, const int substructure=0xff)
std::pair< uint32_t, uint32_t > deviceMask(const StripSubdetector::SubDetector subdet, const int substructure)
std::vector< std::pair< uint32_t, std::pair< double, double > > > SiStripFineDelayHit::detId ( const TrackerGeometry tracker,
const reco::Track tk,
const std::vector< Trajectory > &  trajVec,
const uint32_t &  maskDetId,
const uint32_t &  rootDetId 
)
private

Definition at line 163 of file SiStripFineDelayHit.cc.

References anglefinder_, funct::cos(), cosmic_, event_, field_, spr::find(), SiStripFineDelayTLA::findtrackangle(), edm::Event::getByLabel(), i, TrackerGeometry::idToDetUnit(), LogDebug, maxAngle_, reco::TrackBase::momentum(), reco::TrackBase::parameters(), Pi, DetId::rawId(), reco::Track::recHitsEnd(), query::result, seedLabel_, SiStripFineDelayTOF::timeOfFlight(), SiStripFineDelayTOF::trackParameters(), trajInEvent_, and PV3DBase< T, PVType, FrameType >::x().

164 {
165  bool onDisk = ((maskDetId==TIDDetId(3,15,0,0,0,0).rawId())||(maskDetId==TECDetId(3,15,0,0,0,0,0).rawId())) ;
166  std::vector< std::pair<uint32_t,std::pair<double, double> > > result;
167  std::vector<uint32_t> usedDetids;
168  // now loop on recHits to find the right detId plus the track local angle
169  std::vector<std::pair< std::pair<DetId, LocalPoint> ,float> > hitangle;
170  if(!cosmic_) {
171  if(!trajInEvent_) {
172  //use the track. It will be refitted by the angleFinder
173  hitangle = anglefinder_->findtrackangle(*tk);
174  }
175  else {
176  // use trajectories in event.
177  // we have first to find the right trajectory for the considered track.
178  for(std::vector<Trajectory>::const_iterator traj = trajVec.begin(); traj< trajVec.end(); ++traj) {
179  if(
180  ((traj->lastMeasurement().recHit()->geographicalId().rawId() == (*(tk->recHitsEnd()-1))->geographicalId().rawId()) &&
181  ( traj->lastMeasurement().recHit()->localPosition().x() == (*(tk->recHitsEnd()-1))->localPosition().x()) ) ||
182  ((traj->firstMeasurement().recHit()->geographicalId().rawId() == (*(tk->recHitsEnd()-1))->geographicalId().rawId()) &&
183  ( traj->firstMeasurement().recHit()->localPosition().x() == (*(tk->recHitsEnd()-1))->localPosition().x()) ) ) {
184  hitangle = anglefinder_->findtrackangle(*traj);
185  break;
186  }
187  }
188  }
189  } else {
191  event_->getByLabel(seedLabel_,seedcoll);
192  if(!trajInEvent_) {
193  //use the track. It will be refitted by the angleFinder
194  hitangle = anglefinder_->findtrackangle((*(*seedcoll).begin()),*tk);
195  }
196  else {
197  // use trajectories in event.
198  hitangle = anglefinder_->findtrackangle(trajVec);
199  }
200  }
201  LogDebug("DetId") << "number of hits for the track: " << hitangle.size();
202  std::vector<std::pair< std::pair<DetId, LocalPoint> ,float> >::iterator iter;
203  // select the interesting DetIds, based on the ID and TLA
204  for(iter=hitangle.begin();iter!=hitangle.end();iter++){
205  // check the detId.
206  // if substructure was 0xff, then maskDetId and rootDetId == 0
207  // this implies all detids are accepted. (also if maskDetId=rootDetId=0 explicitely).
208  // That "unusual" mode of operation allows to analyze also Latency scans
209  LogDebug("DetId") << "check the detid: " << std::hex << (iter->first.first.rawId()) << " vs " << rootDetId
210  << " with a mask of " << maskDetId << std::dec << std::endl;
211 
212  if(((iter->first.first.rawId() & maskDetId) != rootDetId)) continue;
213  if(std::find(usedDetids.begin(),usedDetids.end(),iter->first.first.rawId())!=usedDetids.end()) continue;
214  // check the local angle (extended to the equivalent angle correction)
215  LogDebug("DetId") << "check the angle: " << fabs((iter->second));
216  if(1-fabs(fabs(iter->second)-1)<cos(maxAngle_/180.*TMath::Pi())) continue;
217  // returns the detid + the time of flight to there
218  std::pair<uint32_t,std::pair<double, double> > el;
219  std::pair<double, double> subel;
220  el.first = iter->first.first.rawId();
221  // here, we compute the TOF.
222  // For cosmics, some track parameters are missing. Parameters are recomputed.
223  // for our calculation, the track momemtum at any point is enough:
224  // only used without B field or for the sign of Pz.
225  double trackParameters[5];
226  for(int i=0;i<5;i++) trackParameters[i] = tk->parameters()[i];
227  if(cosmic_) SiStripFineDelayTOF::trackParameters(*tk,trackParameters);
228  double hit[3];
229  const GeomDetUnit* det(tracker.idToDetUnit(iter->first.first));
230  Surface::GlobalPoint gp = det->surface().toGlobal(iter->first.second);
231  hit[0]=gp.x();
232  hit[1]=gp.y();
233  hit[2]=gp.z();
234  double phit[3];
235  phit[0] = tk->momentum().x();
236  phit[1] = tk->momentum().y();
237  phit[2] = tk->momentum().z();
238  subel.first = SiStripFineDelayTOF::timeOfFlight(cosmic_,field_,trackParameters,hit,phit,onDisk);
239  subel.second = iter->second;
240  el.second = subel;
241  // returns the detid + TOF
242  result.push_back(el);
243  usedDetids.push_back(el.first);
244  }
245  return result;
246 }
#define LogDebug(id)
const double Pi
int i
Definition: DBlmapReader.cc:9
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:149
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
ParameterVector parameters() const
Track parameters with one-to-one correspondence to the covariance matrix.
Definition: TrackBase.h:171
static double timeOfFlight(bool cosmics, bool field, double *trackParameters, double *hit, double *phit, bool onDisk)
SiStripFineDelayTLA * anglefinder_
tuple result
Definition: query.py:137
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static void trackParameters(const reco::Track &tk, double *trackParameters)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
const edm::Event * event_
std::vector< std::pair< std::pair< DetId, LocalPoint >,float > > findtrackangle(const TrajectorySeed &seed, const reco::Track &theT)
T x() const
Definition: PV3DBase.h:56
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:65
std::pair< uint32_t, uint32_t > SiStripFineDelayHit::deviceMask ( const StripSubdetector::SubDetector  subdet,
const int  substructure 
)
private

Definition at line 121 of file SiStripFineDelayHit.cc.

References abs, DetId::rawId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, and StripSubdetector::TOB.

Referenced by detId(), and produceNoTracking().

122 {
123  uint32_t rootDetId = 0;
124  uint32_t maskDetId = 0;
125  switch(subdet){
126  case (int)StripSubdetector::TIB :
127  {
128  rootDetId = TIBDetId(substructure,0,0,0,0,0).rawId();
129  maskDetId = TIBDetId(15,0,0,0,0,0).rawId();
130  break;
131  }
132  case (int)StripSubdetector::TID :
133  {
134  rootDetId = TIDDetId(substructure>0 ? 2 : 1,abs(substructure),0,0,0,0).rawId();
135  maskDetId = TIDDetId(3,15,0,0,0,0).rawId();
136  break;
137  }
138  case (int)StripSubdetector::TOB :
139  {
140  rootDetId = TOBDetId(substructure,0,0,0,0).rawId();
141  maskDetId = TOBDetId(15,0,0,0,0).rawId();
142  break;
143  }
144  case (int)StripSubdetector::TEC :
145  {
146  rootDetId = TECDetId(substructure>0 ? 2 : 1,abs(substructure),0,0,0,0,0).rawId();
147  maskDetId = TECDetId(3,15,0,0,0,0,0).rawId();
148  break;
149  }
150  }
151  return std::make_pair(maskDetId,rootDetId);
152 }
#define abs(x)
Definition: mlp_lapack.h:159
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
void SiStripFineDelayHit::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 359 of file SiStripFineDelayHit.cc.

References abs, anglefinder_, sistrip::APV_LATENCY, closestCluster(), clusterLabel_, connectionMap_, detId(), digiLabel_, event_, sistrip::FINE_DELAY, edm::EventSetup::get(), edm::Event::getByLabel(), homeMadeClusters_, iEvent, SiStripFineDelayTLA::init(), inputModuleLabel_, LogDebug, maxClusterDistance_, minTrackP2_, mode_, noTracking_, NULL, convertSQLitetoXML_cfg::output, produceNoTracking(), edm::Handle< T >::product(), edm::Event::put(), dataDML::runsummary(), edmLumisInFiles::summary, StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, ExpressReco_HICollisions_FallBack::trackCollection, patCandidatesForDimuonsSequences_cff::tracker, trackLabel_, testEve_cfg::tracks, and trajInEvent_.

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

360 {
361  using namespace edm;
362  // Retrieve commissioning information from "event summary"
365  if(runsummary->runType()==sistrip::APV_LATENCY) mode_ = 2; // LatencyScan
366  else if(runsummary->runType()==sistrip::FINE_DELAY) mode_ = 1; // DelayScan
367  else {
368  mode_ = 0; //unknown
369  return;
370  }
371 
372  if(noTracking_) {
373  produceNoTracking(iEvent,iSetup);
374  return;
375  }
376  event_ = &iEvent;
377  // container for the selected hits
378  std::vector< edm::DetSet<SiStripRawDigi> > output;
379  output.reserve(100);
380  // access the tracks
385  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
386  if (tracks->size()) {
387  anglefinder_->init(iEvent,iSetup);
388  LogDebug("produce") << "Found " << tracks->size() << " tracks.";
389  // look at the hits if one needs them
391  const edm::DetSetVector<SiStripDigi>* hitSet = NULL;
392  if(homeMadeClusters_) {
393  iEvent.getByLabel(digiLabel_,hits);
394  hitSet = hits.product();
395  }
396  // look at the clusters
398  iEvent.getByLabel(clusterLabel_, clusters);
399  const edmNew::DetSetVector<SiStripCluster>* clusterSet = clusters.product();
400  // look at the trajectories if they are in the event
401  std::vector<Trajectory> trajVec;
402  if(trajInEvent_) {
404  iEvent.getByLabel(trackLabel_,TrajectoryCollection);
405  trajVec = *(TrajectoryCollection.product());
406  }
407  // loop on tracks
408  for(reco::TrackCollection::const_iterator itrack = tracks->begin(); itrack<tracks->end(); itrack++) {
409  // first check the track Pt
410  if((itrack->px()*itrack->px()+itrack->py()*itrack->py()+itrack->pz()*itrack->pz())<minTrackP2_) continue;
411  // check that we have something in the layer we are interested in
412  std::vector< std::pair<uint32_t,std::pair<double,double> > > intersections;
413  if(mode_==1) {
414  // Retrieve and decode commissioning information from "event summary"
416  iEvent.getByLabel( inputModuleLabel_, summary );
417  uint32_t layerCode = (const_cast<SiStripEventSummary*>(summary.product())->layerScanned())>>16;
419  if(((layerCode>>6)&0x3)==0) subdet = StripSubdetector::TIB;
420  else if(((layerCode>>6)&0x3)==1) subdet = StripSubdetector::TOB;
421  else if(((layerCode>>6)&0x3)==2) subdet = StripSubdetector::TID;
422  else if(((layerCode>>6)&0x3)==3) subdet = StripSubdetector::TEC;
423  int32_t layerIdx = (layerCode&0xF)*(((layerCode>>4)&0x3) ? -1 : 1);
424  intersections = detId(*tracker,&(*itrack),trajVec,subdet,layerIdx);
425  } else {
426  // for latency scans, no layer is specified -> no cut on detid
427  intersections = detId(*tracker,&(*itrack),trajVec);
428  }
429  LogDebug("produce") << " Found " << intersections.size() << " interesting intersections." << std::endl;
430  for(std::vector< std::pair<uint32_t,std::pair<double,double> > >::iterator it = intersections.begin();it<intersections.end();it++) {
431  std::pair<const SiStripCluster*,double> candidateCluster = closestCluster(*tracker,&(*itrack),it->first,*clusterSet,*hitSet);
432  if(candidateCluster.first) {
433  LogDebug("produce") << " Found a cluster."<< std::endl;
434  // cut on the distance
435  if(candidateCluster.second>maxClusterDistance_) continue;
436  LogDebug("produce") << " The cluster is close enough."<< std::endl;
437  // build the rawdigi corresponding to the leading strip and save it
438  // here, only the leading strip is retained. All other rawdigis in the module are set to 0.
439  const std::vector< uint8_t >& amplitudes = candidateCluster.first->amplitudes();
440  uint8_t leadingCharge = 0;
441  uint8_t leadingStrip = candidateCluster.first->firstStrip();
442  uint8_t leadingPosition = 0;
443  for(std::vector< uint8_t >::const_iterator amplit = amplitudes.begin();amplit<amplitudes.end();amplit++,leadingStrip++) {
444  if(leadingCharge<*amplit) {
445  leadingCharge = *amplit;
446  leadingPosition = leadingStrip;
447  }
448  }
449 
450  // look for an existing detset
451  std::vector< edm::DetSet<SiStripRawDigi> >::iterator newdsit = output.begin();
452  for(;newdsit!=output.end()&&newdsit->detId()!=connectionMap_[it->first];++newdsit) {}
453  // if there is no detset yet, create it.
454  if(newdsit==output.end()) {
456  output.push_back(newds);
457  newdsit = output.end()-1;
458  }
459 
460  LogDebug("produce") << " New Hit... TOF:" << it->second.first << ", charge: " << int(leadingCharge)
461  << " at " << int(leadingPosition) << "." << std::endl
462  << "Angular correction: " << it->second.second
463  << " giving a final value of " << int(leadingCharge*fabs(it->second.second))
464  << " for fed key = " << connectionMap_[it->first] << " (detid=" << it->first << ")" ;
465  // apply corrections to the leading charge, but only if it has not saturated.
466  if(leadingCharge<255) {
467  // correct the leading charge for the crossing angle
468  leadingCharge = uint8_t(leadingCharge*fabs(it->second.second));
469  // correct for module thickness for TEC and TOB
470  if((((it->first>>25)&0x7f)==0xd) ||
471  ((((it->first>>25)&0x7f)==0xe) && (((it->first>>5)&0x7)>4)))
472  leadingCharge = uint8_t((leadingCharge*0.64));
473  }
474  //code the time of flight in the digi
475  unsigned int tof = abs(int(round(it->second.first*10)));
476  tof = tof>255 ? 255 : tof;
477  SiStripRawDigi newSiStrip(leadingCharge + (tof<<8));
478  newdsit->push_back(newSiStrip);
479  LogDebug("produce") << "New edm::DetSet<SiStripRawDigi> added.";
480  }
481  if(homeMadeClusters_) delete candidateCluster.first; // we are owner of home-made clusters
482  }
483  }
484  }
485  // add the selected hits to the event.
486  LogDebug("produce") << "Putting " << output.size() << " new hits in the event.";
487  std::auto_ptr< edm::DetSetVector<SiStripRawDigi> > formatedOutput(new edm::DetSetVector<SiStripRawDigi>(output) );
488  iEvent.put(formatedOutput,"FineDelaySelection");
489 }
#define LogDebug(id)
std::vector< std::pair< uint32_t, std::pair< double, double > > > detId(const TrackerGeometry &tracker, const reco::Track *tk, const std::vector< Trajectory > &trajVec, const StripSubdetector::SubDetector subdet=StripSubdetector::TIB, const int substructure=0xff)
virtual void produceNoTracking(edm::Event &, const edm::EventSetup &)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
void init(const edm::Event &e, const edm::EventSetup &c)
#define abs(x)
Definition: mlp_lapack.h:159
#define NULL
Definition: scimark2.h:8
edm::InputTag clusterLabel_
std::map< uint32_t, uint32_t > connectionMap_
std::pair< const SiStripCluster *, double > closestCluster(const TrackerGeometry &tracker, const reco::Track *tk, const uint32_t &detId, const edmNew::DetSetVector< SiStripCluster > &clusters, const edm::DetSetVector< SiStripDigi > &hits)
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
SiStripFineDelayTLA * anglefinder_
def runsummary
Definition: dataDML.py:85
edm::InputTag inputModuleLabel_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: Handle.h:74
std::vector< Trajectory > TrajectoryCollection
const edm::Event * event_
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
void SiStripFineDelayHit::produceNoTracking ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Definition at line 493 of file SiStripFineDelayHit.cc.

References begin, clusterLabel_, connectionMap_, deviceMask(), end, event_, edm::EventSetup::get(), edm::Event::getByLabel(), iEvent, inputModuleLabel_, LogDebug, mode_, convertSQLitetoXML_cfg::output, edm::Handle< T >::product(), edm::Event::put(), edmLumisInFiles::summary, StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, and StripSubdetector::TOB.

Referenced by produce().

494 {
495  event_ = &iEvent;
496  // container for the selected hits
497  std::vector< edm::DetSet<SiStripRawDigi> > output;
498  output.reserve(100);
499  // Retrieve and decode commissioning information from "event summary"
501  iEvent.getByLabel( inputModuleLabel_, summary );
502  uint32_t layerCode = (const_cast<SiStripEventSummary*>(summary.product())->layerScanned())>>16;
504  if(((layerCode>>6)&0x3)==0) subdet = StripSubdetector::TIB;
505  else if(((layerCode>>6)&0x3)==1) subdet = StripSubdetector::TOB;
506  else if(((layerCode>>6)&0x3)==2) subdet = StripSubdetector::TID;
507  else if(((layerCode>>6)&0x3)==3) subdet = StripSubdetector::TEC;
508  int32_t layerIdx = (layerCode&0xF)*(((layerCode>>4)&0x3) ? -1 : 1);
509  std::pair<uint32_t, uint32_t> mask = deviceMask(subdet,layerIdx);
510  // look at the clusters
512  iEvent.getByLabel(clusterLabel_,clusters);
513  for (edmNew::DetSetVector<SiStripCluster>::const_iterator DSViter=clusters->begin(); DSViter!=clusters->end();DSViter++ ) {
514  // check that we are in the layer of interest
515  if(mode_==1 && ((DSViter->id() & mask.first) != mask.second) ) continue;
516  // iterate over clusters
519  edm::DetSet<SiStripRawDigi> newds(connectionMap_[DSViter->id()]);
520  for(edmNew::DetSet<SiStripCluster>::const_iterator iter=begin;iter!=end;++iter) {
521  // build the rawdigi corresponding to the leading strip and save it
522  // here, only the leading strip is retained. All other rawdigis in the module are set to 0.
523  const std::vector< uint8_t >& amplitudes = iter->amplitudes();
524  uint8_t leadingCharge = 0;
525  uint8_t leadingStrip = iter->firstStrip();
526  uint8_t leadingPosition = 0;
527  for(std::vector< uint8_t >::const_iterator amplit = amplitudes.begin();amplit<amplitudes.end();amplit++,leadingStrip++) {
528  if(leadingCharge<*amplit) {
529  leadingCharge = *amplit;
530  leadingPosition = leadingStrip;
531  }
532  }
533  // apply some sanity cuts. This is needed since we don't use tracking to clean clusters
534  // 1.5< noise <8
535  // charge<250
536  // 50 > s/n > 10
537  edm::ESHandle<SiStripNoises> noiseHandle_;
538  iSetup.get<SiStripNoisesRcd>().get(noiseHandle_);
539  SiStripNoises::Range detNoiseRange = noiseHandle_->getRange(DSViter->id());
540  float noise=noiseHandle_->getNoise(leadingPosition, detNoiseRange);
541  if( noise<1.5 ) continue;
542  if( leadingCharge>=250 || noise>=8 || leadingCharge/noise>50 || leadingCharge/noise<10 ) continue;
543  // apply some correction to the leading charge, but only if it has not saturated.
544  if(leadingCharge<255) {
545  // correct for modulethickness for TEC and TOB
546  if((((((DSViter->id())>>25)&0x7f)==0xd)||((((DSViter->id())>>25)&0x7f)==0xe))&&((((DSViter->id())>>5)&0x7)>4))
547  leadingCharge = uint8_t((leadingCharge*0.64));
548  }
549  //code the time of flight == 0 in the digi
550  SiStripRawDigi newSiStrip(leadingCharge);
551  newds.push_back(newSiStrip);
552  }
553  //store into the detsetvector
554  output.push_back(newds);
555  LogDebug("produce") << "New edm::DetSet<SiStripRawDigi> added with fedkey = "
556  << std::hex << std::setfill('0') << std::setw(8)
557  << connectionMap_[DSViter->id()] << std::dec;
558  }
559  // add the selected hits to the event.
560  LogDebug("produce") << "Putting " << output.size() << " new hits in the event.";
561  std::auto_ptr< edm::DetSetVector<SiStripRawDigi> > formatedOutput(new edm::DetSetVector<SiStripRawDigi>(output) );
562  iEvent.put(formatedOutput,"FineDelaySelection");
563 }
#define LogDebug(id)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
data_type const * const_iterator
Definition: DetSetNew.h:25
edm::InputTag clusterLabel_
std::pair< uint32_t, uint32_t > deviceMask(const StripSubdetector::SubDetector subdet, const int substructure)
std::map< uint32_t, uint32_t > connectionMap_
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
edm::InputTag inputModuleLabel_
#define end
Definition: vmac.h:38
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: Handle.h:74
#define begin
Definition: vmac.h:31
const edm::Event * event_
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:41
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
bool SiStripFineDelayHit::rechit ( reco::Track tk,
uint32_t  detId 
)
private

Definition at line 248 of file SiStripFineDelayHit.cc.

References reco::Track::recHitsBegin(), and reco::Track::recHitsEnd().

249 {
250  for(trackingRecHit_iterator it = tk->recHitsBegin(); it != tk->recHitsEnd(); it++)
251  if((*it)->geographicalId().rawId() == det_id) {
252  return (*it)->isValid();
253  break;
254  }
255  return false;
256 }
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:63
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:65

Member Data Documentation

SiStripFineDelayTLA* SiStripFineDelayHit::anglefinder_
private

Definition at line 52 of file SiStripFineDelayHit.h.

Referenced by detId(), produce(), SiStripFineDelayHit(), and ~SiStripFineDelayHit().

edm::InputTag SiStripFineDelayHit::clusterLabel_
private

Definition at line 58 of file SiStripFineDelayHit.h.

Referenced by produce(), produceNoTracking(), and SiStripFineDelayHit().

std::map<uint32_t,uint32_t> SiStripFineDelayHit::connectionMap_
private

Definition at line 59 of file SiStripFineDelayHit.h.

Referenced by beginRun(), produce(), and produceNoTracking().

bool SiStripFineDelayHit::cosmic_
private

Definition at line 54 of file SiStripFineDelayHit.h.

Referenced by detId(), and SiStripFineDelayHit().

edm::InputTag SiStripFineDelayHit::digiLabel_
private

Definition at line 58 of file SiStripFineDelayHit.h.

Referenced by produce(), and SiStripFineDelayHit().

const edm::Event* SiStripFineDelayHit::event_
private

Definition at line 53 of file SiStripFineDelayHit.h.

Referenced by detId(), produce(), and produceNoTracking().

int SiStripFineDelayHit::explorationWindow_
private

Definition at line 57 of file SiStripFineDelayHit.h.

Referenced by closestCluster(), and SiStripFineDelayHit().

bool SiStripFineDelayHit::field_
private

Definition at line 54 of file SiStripFineDelayHit.h.

Referenced by detId(), and SiStripFineDelayHit().

bool SiStripFineDelayHit::homeMadeClusters_
private

Definition at line 54 of file SiStripFineDelayHit.h.

Referenced by closestCluster(), produce(), and SiStripFineDelayHit().

edm::InputTag SiStripFineDelayHit::inputModuleLabel_
private

Definition at line 58 of file SiStripFineDelayHit.h.

Referenced by produce(), produceNoTracking(), and SiStripFineDelayHit().

double SiStripFineDelayHit::maxAngle_
private

Definition at line 55 of file SiStripFineDelayHit.h.

Referenced by detId(), and SiStripFineDelayHit().

double SiStripFineDelayHit::maxClusterDistance_
private

Definition at line 55 of file SiStripFineDelayHit.h.

Referenced by produce(), and SiStripFineDelayHit().

double SiStripFineDelayHit::minTrackP2_
private

Definition at line 55 of file SiStripFineDelayHit.h.

Referenced by produce(), and SiStripFineDelayHit().

int SiStripFineDelayHit::mode_
private

Definition at line 56 of file SiStripFineDelayHit.h.

Referenced by produce(), produceNoTracking(), and SiStripFineDelayHit().

bool SiStripFineDelayHit::noTracking_
private

Definition at line 54 of file SiStripFineDelayHit.h.

Referenced by produce(), and SiStripFineDelayHit().

edm::InputTag SiStripFineDelayHit::seedLabel_
private

Definition at line 58 of file SiStripFineDelayHit.h.

Referenced by detId(), and SiStripFineDelayHit().

edm::InputTag SiStripFineDelayHit::trackLabel_
private

Definition at line 58 of file SiStripFineDelayHit.h.

Referenced by produce(), and SiStripFineDelayHit().

bool SiStripFineDelayHit::trajInEvent_
private

Definition at line 54 of file SiStripFineDelayHit.h.

Referenced by detId(), produce(), and SiStripFineDelayHit().