CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripFineDelayHit.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripFineDelayHit
4 // Class: SiStripFineDelayHit
5 //
13 //
14 // Original Author: Christophe DELAERE
15 // Created: Fri Nov 17 10:52:42 CET 2006
16 // $Id: SiStripFineDelayHit.cc,v 1.17 2012/01/17 10:04:37 innocent Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 #include <utility>
24 #include <vector>
25 #include <algorithm>
26 
27 // user include files
35 
64 
65 
75 
77 
81 
82 #include "TMath.h"
83 
84 //
85 // constructors and destructor
86 //
88 {
89  //register your products
90  produces<edm::DetSetVector<SiStripRawDigi> >("FineDelaySelection");
91  //now do what ever other initialization is needed
92  anglefinder_=new SiStripFineDelayTLA(iConfig);
93  cosmic_ = iConfig.getParameter<bool>("cosmic");
94  field_ = iConfig.getParameter<bool>("MagneticField");
95  maxAngle_ = iConfig.getParameter<double>("MaxTrackAngle");
96  minTrackP2_ = iConfig.getParameter<double>("MinTrackMomentum")*iConfig.getParameter<double>("MinTrackMomentum");
97  maxClusterDistance_ = iConfig.getParameter<double>("MaxClusterDistance");
98  clusterLabel_ = iConfig.getParameter<edm::InputTag>("ClustersLabel");
99  trackLabel_ = iConfig.getParameter<edm::InputTag>("TracksLabel");
100  seedLabel_ = iConfig.getParameter<edm::InputTag>("SeedsLabel");
101  inputModuleLabel_ = iConfig.getParameter<edm::InputTag>( "InputModuleLabel" ) ;
102  digiLabel_ = iConfig.getParameter<edm::InputTag>("DigiLabel");
103  homeMadeClusters_ = iConfig.getParameter<bool>("NoClustering");
104  explorationWindow_ = iConfig.getParameter<uint32_t>("ExplorationWindow");
105  noTracking_ = iConfig.getParameter<bool>("NoTracking");
106  mode_=0;
107 }
108 
110 {
111  // do anything here that needs to be done at desctruction time
112  // (e.g. close files, deallocate resources etc.)
113  delete anglefinder_;
114 }
115 
116 //
117 // member functions
118 //
119 std::pair<uint32_t, uint32_t> SiStripFineDelayHit::deviceMask(const StripSubdetector::SubDetector subdet,const int substructure)
120 {
121  uint32_t rootDetId = 0;
122  uint32_t maskDetId = 0;
123  switch(subdet){
124  case (int)StripSubdetector::TIB :
125  {
126  rootDetId = TIBDetId(substructure,0,0,0,0,0).rawId();
127  maskDetId = TIBDetId(15,0,0,0,0,0).rawId();
128  break;
129  }
130  case (int)StripSubdetector::TID :
131  {
132  rootDetId = TIDDetId(substructure>0 ? 2 : 1,abs(substructure),0,0,0,0).rawId();
133  maskDetId = TIDDetId(3,15,0,0,0,0).rawId();
134  break;
135  }
136  case (int)StripSubdetector::TOB :
137  {
138  rootDetId = TOBDetId(substructure,0,0,0,0).rawId();
139  maskDetId = TOBDetId(15,0,0,0,0).rawId();
140  break;
141  }
142  case (int)StripSubdetector::TEC :
143  {
144  rootDetId = TECDetId(substructure>0 ? 2 : 1,abs(substructure),0,0,0,0,0).rawId();
145  maskDetId = TECDetId(3,15,0,0,0,0,0).rawId();
146  break;
147  }
148  }
149  return std::make_pair(maskDetId,rootDetId);
150 }
151 
152 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,const int substructure)
153 {
154  if(substructure==0xff) return detId(tracker,tk,trajVec,0,0);
155  // first determine the root detId we are looking for
156  std::pair<uint32_t, uint32_t> mask = deviceMask(subdet,substructure);
157  // then call the method that loops on recHits
158  return detId(tracker,tk,trajVec,mask.first,mask.second);
159 }
160 
161 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)
162 {
163  bool onDisk = ((maskDetId==TIDDetId(3,15,0,0,0,0).rawId())||(maskDetId==TECDetId(3,15,0,0,0,0,0).rawId())) ;
164  std::vector< std::pair<uint32_t,std::pair<double, double> > > result;
165  std::vector<uint32_t> usedDetids;
166  // now loop on recHits to find the right detId plus the track local angle
167  std::vector<std::pair< std::pair<DetId, LocalPoint> ,float> > hitangle;
168  if(!cosmic_) {
169  // use trajectories in event.
170  // we have first to find the right trajectory for the considered track.
171  for(std::vector<Trajectory>::const_iterator traj = trajVec.begin(); traj< trajVec.end(); ++traj) {
172  if(
173  ((traj->lastMeasurement().recHit()->geographicalId().rawId() == (*(tk->recHitsEnd()-1))->geographicalId().rawId()) &&
174  ( traj->lastMeasurement().recHit()->localPosition().x() == (*(tk->recHitsEnd()-1))->localPosition().x()) ) ||
175  ((traj->firstMeasurement().recHit()->geographicalId().rawId() == (*(tk->recHitsEnd()-1))->geographicalId().rawId()) &&
176  ( traj->firstMeasurement().recHit()->localPosition().x() == (*(tk->recHitsEnd()-1))->localPosition().x()) ) ) {
177  hitangle = anglefinder_->findtrackangle(*traj);
178  break;
179  }
180  }
181  } else {
183  event_->getByLabel(seedLabel_,seedcoll);
184  // use trajectories in event.
185  hitangle = anglefinder_->findtrackangle(trajVec);
186  }
187  LogDebug("DetId") << "number of hits for the track: " << hitangle.size();
188  std::vector<std::pair< std::pair<DetId, LocalPoint> ,float> >::iterator iter;
189  // select the interesting DetIds, based on the ID and TLA
190  for(iter=hitangle.begin();iter!=hitangle.end();iter++){
191  // check the detId.
192  // if substructure was 0xff, then maskDetId and rootDetId == 0
193  // this implies all detids are accepted. (also if maskDetId=rootDetId=0 explicitely).
194  // That "unusual" mode of operation allows to analyze also Latency scans
195  LogDebug("DetId") << "check the detid: " << std::hex << (iter->first.first.rawId()) << " vs " << rootDetId
196  << " with a mask of " << maskDetId << std::dec << std::endl;
197 
198  if(((iter->first.first.rawId() & maskDetId) != rootDetId)) continue;
199  if(std::find(usedDetids.begin(),usedDetids.end(),iter->first.first.rawId())!=usedDetids.end()) continue;
200  // check the local angle (extended to the equivalent angle correction)
201  LogDebug("DetId") << "check the angle: " << fabs((iter->second));
202  if(1-fabs(fabs(iter->second)-1)<cos(maxAngle_/180.*TMath::Pi())) continue;
203  // returns the detid + the time of flight to there
204  std::pair<uint32_t,std::pair<double, double> > el;
205  std::pair<double, double> subel;
206  el.first = iter->first.first.rawId();
207  // here, we compute the TOF.
208  // For cosmics, some track parameters are missing. Parameters are recomputed.
209  // for our calculation, the track momemtum at any point is enough:
210  // only used without B field or for the sign of Pz.
211  double trackParameters[5];
212  for(int i=0;i<5;i++) trackParameters[i] = tk->parameters()[i];
213  if(cosmic_) SiStripFineDelayTOF::trackParameters(*tk,trackParameters);
214  double hit[3];
215  const GeomDetUnit* det(tracker.idToDetUnit(iter->first.first));
216  Surface::GlobalPoint gp = det->surface().toGlobal(iter->first.second);
217  hit[0]=gp.x();
218  hit[1]=gp.y();
219  hit[2]=gp.z();
220  double phit[3];
221  phit[0] = tk->momentum().x();
222  phit[1] = tk->momentum().y();
223  phit[2] = tk->momentum().z();
224  subel.first = SiStripFineDelayTOF::timeOfFlight(cosmic_,field_,trackParameters,hit,phit,onDisk);
225  subel.second = iter->second;
226  el.second = subel;
227  // returns the detid + TOF
228  result.push_back(el);
229  usedDetids.push_back(el.first);
230  }
231  return result;
232 }
233 
234 bool SiStripFineDelayHit::rechit(reco::Track* tk,uint32_t det_id)
235 {
236  for(trackingRecHit_iterator it = tk->recHitsBegin(); it != tk->recHitsEnd(); it++)
237  if((*it)->geographicalId().rawId() == det_id) {
238  return (*it)->isValid();
239  break;
240  }
241  return false;
242 }
243 
244 // VI January 2012: FIXME
245 // do not understand what is going on here: each hit has a cluster: by definition will be the closest!
246 std::pair<const SiStripCluster*,double> SiStripFineDelayHit::closestCluster(const TrackerGeometry& tracker,const reco::Track* tk,const uint32_t& det_id ,const edmNew::DetSetVector<SiStripCluster>& clusters, const edm::DetSetVector<SiStripDigi>& hits)
247 {
248  std::pair<const SiStripCluster*,double> result(NULL,0.);
249  double hitStrip = -1;
250  int nstrips = -1;
251  // localize the crossing point of the track on the module
252  for(trackingRecHit_iterator it = tk->recHitsBegin(); it != tk->recHitsEnd(); it++) {
253  LogDebug("closestCluster") << "(*it)->geographicalId().rawId() vs det_id" << (*it)->geographicalId().rawId() << " " << det_id;
254  //handle the mono rechits
255  if((*it)->geographicalId().rawId() == det_id) {
256  if(!(*it)->isValid()) continue;
257  LogDebug("closestCluster") << " using the single mono hit";
258  LocalPoint lp = (*it)->localPosition();
259  const GeomDetUnit* gdu = static_cast<const GeomDetUnit*>(tracker.idToDet((*it)->geographicalId()));
261  hitStrip = p.x();
262  nstrips = (dynamic_cast<const StripTopology*>(&(gdu->topology())))->nstrips();
263  break;
264  }
265  /* FIXME: local position is not there anymore...
266  //handle stereo part of matched hits
267  //one could try to cast to SiStripMatchedRecHit2D but it is faster to look at the detid
268  else if((det_id - (*it)->geographicalId().rawId())==1) {
269  const SiStripMatchedRecHit2D* hit2D = dynamic_cast<const SiStripMatchedRecHit2D*>(&(**it));
270  if(!hit2D) continue; // this is a security that should never trigger
271  const SiStripRecHit2D* stereo = hit2D->stereoHit();
272  if(!stereo) continue; // this is a security that should never trigger
273  if(!stereo->isValid()) continue;
274  LogDebug("closestCluster") << " using the stereo hit";
275  LocalPoint lp = stereo->localPosition();
276  const GeomDetUnit* gdu = static_cast<const GeomDetUnit*>(tracker.idToDet(stereo->geographicalId()));
277  MeasurementPoint p = gdu->topology().measurementPosition(lp);
278  hitStrip = p.x();
279  nstrips = (dynamic_cast<const StripTopology*>(&(gdu->topology())))->nstrips();
280  break;
281  }
282  //handle mono part of matched hits
283  //one could try to cast to SiStripMatchedRecHit2D but it is faster to look at the detid
284  else if((det_id - (*it)->geographicalId().rawId())==2) {
285  const SiStripMatchedRecHit2D* hit2D = dynamic_cast<const SiStripMatchedRecHit2D*>(&(**it));
286  if(!hit2D) continue; // this is a security that should never trigger
287  const SiStripRecHit2D* mono = hit2D->monoHit();
288  if(!mono) continue; // this is a security that should never trigger
289  if(!mono->isValid()) continue;
290  LogDebug("closestCluster") << " using the mono hit";
291  LocalPoint lp = mono->localPosition();
292  const GeomDetUnit* gdu = static_cast<const GeomDetUnit*>(tracker.idToDet(mono->geographicalId()));
293  MeasurementPoint p = gdu->topology().measurementPosition(lp);
294  hitStrip = p.x();
295  nstrips = (dynamic_cast<const StripTopology*>(&(gdu->topology())))->nstrips();
296  break;
297  }
298  */
299  }
300  LogDebug("closestCluster") << " hit strip = " << hitStrip;
301  if(hitStrip<0) return result;
302  if(homeMadeClusters_) {
303  // take the list of digis on the module
304  for (edm::DetSetVector<SiStripDigi>::const_iterator DSViter=hits.begin(); DSViter!=hits.end();DSViter++){
305  if(DSViter->id==det_id) {
306  // loop from hitstrip-n to hitstrip+n (explorationWindow_) and select the highest strip
307  int minStrip = int(round(hitStrip))- explorationWindow_;
308  minStrip = minStrip<0 ? 0 : minStrip;
309  int maxStrip = int(round(hitStrip)) + explorationWindow_ + 1;
310  maxStrip = maxStrip>=nstrips ? nstrips-1 : maxStrip;
311  edm::DetSet<SiStripDigi>::const_iterator rangeStart = DSViter->end();
312  edm::DetSet<SiStripDigi>::const_iterator rangeStop = DSViter->end();
313  for(edm::DetSet<SiStripDigi>::const_iterator digiIt = DSViter->begin(); digiIt!=DSViter->end(); ++digiIt) {
314  if(digiIt->strip()>=minStrip && rangeStart == DSViter->end()) rangeStart = digiIt;
315  if(digiIt->strip()<=maxStrip) rangeStop = digiIt;
316  }
317  if(rangeStart != DSViter->end()) {
318  if(rangeStop !=DSViter->end()) ++rangeStop;
319  // build a fake cluster
320  LogDebug("closestCluster") << "build a fake cluster ";
321  SiStripCluster* newCluster = new SiStripCluster(det_id,SiStripCluster::SiStripDigiRange(rangeStart,rangeStop)); // /!\ ownership transfered
322  result.first = newCluster;
323  result.second = fabs(newCluster->barycenter()-hitStrip);
324  }
325  break;
326  }
327  }
328  } else {
329  // loop on the detsetvector<cluster> to find the right one
330  for (edmNew::DetSetVector<SiStripCluster>::const_iterator DSViter=clusters.begin(); DSViter!=clusters.end();DSViter++ )
331  if(DSViter->id()==det_id) {
332  LogDebug("closestCluster") << " detset with the right detid. ";
335  //find the cluster close to the hitStrip
336  result.second = 1000.;
337  for(edmNew::DetSet<SiStripCluster>::const_iterator iter=begin;iter!=end;++iter) {
338  double dist = fabs(iter->barycenter()-hitStrip);
339  if(dist<result.second) { result.second = dist; result.first = &(*iter); }
340  }
341  break;
342  }
343  }
344  return result;
345 }
346 
347 // ------------ method called to produce the data ------------
348 void
350 {
351  using namespace edm;
352  // Retrieve commissioning information from "event summary"
355  if(runsummary->runType()==sistrip::APV_LATENCY) mode_ = 2; // LatencyScan
356  else if(runsummary->runType()==sistrip::FINE_DELAY) mode_ = 1; // DelayScan
357  else {
358  mode_ = 0; //unknown
359  return;
360  }
361 
362  if(noTracking_) {
363  produceNoTracking(iEvent,iSetup);
364  return;
365  }
366  event_ = &iEvent;
367  // container for the selected hits
368  std::vector< edm::DetSet<SiStripRawDigi> > output;
369  output.reserve(100);
370  // access the tracks
371  edm::Handle<reco::TrackCollection> trackCollection;
372  iEvent.getByLabel(trackLabel_,trackCollection);
373  const reco::TrackCollection *tracks=trackCollection.product();
375  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
376  if (tracks->size()) {
377  anglefinder_->init(iEvent,iSetup);
378  LogDebug("produce") << "Found " << tracks->size() << " tracks.";
379  // look at the hits if one needs them
381  const edm::DetSetVector<SiStripDigi>* hitSet = NULL;
382  if(homeMadeClusters_) {
383  iEvent.getByLabel(digiLabel_,hits);
384  hitSet = hits.product();
385  }
386  // look at the clusters
388  iEvent.getByLabel(clusterLabel_, clusters);
389  const edmNew::DetSetVector<SiStripCluster>* clusterSet = clusters.product();
390  // look at the trajectories if they are in the event
391  std::vector<Trajectory> trajVec;
393  iEvent.getByLabel(trackLabel_,TrajectoryCollection);
394  trajVec = *(TrajectoryCollection.product());
395  // loop on tracks
396  for(reco::TrackCollection::const_iterator itrack = tracks->begin(); itrack<tracks->end(); itrack++) {
397  // first check the track Pt
398  if((itrack->px()*itrack->px()+itrack->py()*itrack->py()+itrack->pz()*itrack->pz())<minTrackP2_) continue;
399  // check that we have something in the layer we are interested in
400  std::vector< std::pair<uint32_t,std::pair<double,double> > > intersections;
401  if(mode_==1) {
402  // Retrieve and decode commissioning information from "event summary"
404  iEvent.getByLabel( inputModuleLabel_, summary );
405  uint32_t layerCode = (const_cast<SiStripEventSummary*>(summary.product())->layerScanned())>>16;
407  if(((layerCode>>6)&0x3)==0) subdet = StripSubdetector::TIB;
408  else if(((layerCode>>6)&0x3)==1) subdet = StripSubdetector::TOB;
409  else if(((layerCode>>6)&0x3)==2) subdet = StripSubdetector::TID;
410  else if(((layerCode>>6)&0x3)==3) subdet = StripSubdetector::TEC;
411  int32_t layerIdx = (layerCode&0xF)*(((layerCode>>4)&0x3) ? -1 : 1);
412  intersections = detId(*tracker,&(*itrack),trajVec,subdet,layerIdx);
413  } else {
414  // for latency scans, no layer is specified -> no cut on detid
415  intersections = detId(*tracker,&(*itrack),trajVec);
416  }
417  LogDebug("produce") << " Found " << intersections.size() << " interesting intersections." << std::endl;
418  for(std::vector< std::pair<uint32_t,std::pair<double,double> > >::iterator it = intersections.begin();it<intersections.end();it++) {
419  std::pair<const SiStripCluster*,double> candidateCluster = closestCluster(*tracker,&(*itrack),it->first,*clusterSet,*hitSet);
420  if(candidateCluster.first) {
421  LogDebug("produce") << " Found a cluster."<< std::endl;
422  // cut on the distance
423  if(candidateCluster.second>maxClusterDistance_) continue;
424  LogDebug("produce") << " The cluster is close enough."<< std::endl;
425  // build the rawdigi corresponding to the leading strip and save it
426  // here, only the leading strip is retained. All other rawdigis in the module are set to 0.
427  const std::vector< uint8_t >& amplitudes = candidateCluster.first->amplitudes();
428  uint8_t leadingCharge = 0;
429  uint8_t leadingStrip = candidateCluster.first->firstStrip();
430  uint8_t leadingPosition = 0;
431  for(std::vector< uint8_t >::const_iterator amplit = amplitudes.begin();amplit<amplitudes.end();amplit++,leadingStrip++) {
432  if(leadingCharge<*amplit) {
433  leadingCharge = *amplit;
434  leadingPosition = leadingStrip;
435  }
436  }
437 
438  // look for an existing detset
439  std::vector< edm::DetSet<SiStripRawDigi> >::iterator newdsit = output.begin();
440  for(;newdsit!=output.end()&&newdsit->detId()!=connectionMap_[it->first];++newdsit) {}
441  // if there is no detset yet, create it.
442  if(newdsit==output.end()) {
444  output.push_back(newds);
445  newdsit = output.end()-1;
446  }
447 
448  LogDebug("produce") << " New Hit... TOF:" << it->second.first << ", charge: " << int(leadingCharge)
449  << " at " << int(leadingPosition) << "." << std::endl
450  << "Angular correction: " << it->second.second
451  << " giving a final value of " << int(leadingCharge*fabs(it->second.second))
452  << " for fed key = " << connectionMap_[it->first] << " (detid=" << it->first << ")" ;
453  // apply corrections to the leading charge, but only if it has not saturated.
454  if(leadingCharge<255) {
455  // correct the leading charge for the crossing angle
456  leadingCharge = uint8_t(leadingCharge*fabs(it->second.second));
457  // correct for module thickness for TEC and TOB
458  if((((it->first>>25)&0x7f)==0xd) ||
459  ((((it->first>>25)&0x7f)==0xe) && (((it->first>>5)&0x7)>4)))
460  leadingCharge = uint8_t((leadingCharge*0.64));
461  }
462  //code the time of flight in the digi
463  unsigned int tof = abs(int(round(it->second.first*10)));
464  tof = tof>255 ? 255 : tof;
465  SiStripRawDigi newSiStrip(leadingCharge + (tof<<8));
466  newdsit->push_back(newSiStrip);
467  LogDebug("produce") << "New edm::DetSet<SiStripRawDigi> added.";
468  }
469  if(homeMadeClusters_) delete candidateCluster.first; // we are owner of home-made clusters
470  }
471  }
472  }
473  // add the selected hits to the event.
474  LogDebug("produce") << "Putting " << output.size() << " new hits in the event.";
475  std::auto_ptr< edm::DetSetVector<SiStripRawDigi> > formatedOutput(new edm::DetSetVector<SiStripRawDigi>(output) );
476  iEvent.put(formatedOutput,"FineDelaySelection");
477 }
478 
479 // Simple solution when tracking is not available/ not working
480 void
482 {
483  event_ = &iEvent;
484  // container for the selected hits
485  std::vector< edm::DetSet<SiStripRawDigi> > output;
486  output.reserve(100);
487  // Retrieve and decode commissioning information from "event summary"
489  iEvent.getByLabel( inputModuleLabel_, summary );
490  uint32_t layerCode = (const_cast<SiStripEventSummary*>(summary.product())->layerScanned())>>16;
492  if(((layerCode>>6)&0x3)==0) subdet = StripSubdetector::TIB;
493  else if(((layerCode>>6)&0x3)==1) subdet = StripSubdetector::TOB;
494  else if(((layerCode>>6)&0x3)==2) subdet = StripSubdetector::TID;
495  else if(((layerCode>>6)&0x3)==3) subdet = StripSubdetector::TEC;
496  int32_t layerIdx = (layerCode&0xF)*(((layerCode>>4)&0x3) ? -1 : 1);
497  std::pair<uint32_t, uint32_t> mask = deviceMask(subdet,layerIdx);
498  // look at the clusters
500  iEvent.getByLabel(clusterLabel_,clusters);
501  for (edmNew::DetSetVector<SiStripCluster>::const_iterator DSViter=clusters->begin(); DSViter!=clusters->end();DSViter++ ) {
502  // check that we are in the layer of interest
503  if(mode_==1 && ((DSViter->id() & mask.first) != mask.second) ) continue;
504  // iterate over clusters
507  edm::DetSet<SiStripRawDigi> newds(connectionMap_[DSViter->id()]);
508  for(edmNew::DetSet<SiStripCluster>::const_iterator iter=begin;iter!=end;++iter) {
509  // build the rawdigi corresponding to the leading strip and save it
510  // here, only the leading strip is retained. All other rawdigis in the module are set to 0.
511  const std::vector< uint8_t >& amplitudes = iter->amplitudes();
512  uint8_t leadingCharge = 0;
513  uint8_t leadingStrip = iter->firstStrip();
514  uint8_t leadingPosition = 0;
515  for(std::vector< uint8_t >::const_iterator amplit = amplitudes.begin();amplit<amplitudes.end();amplit++,leadingStrip++) {
516  if(leadingCharge<*amplit) {
517  leadingCharge = *amplit;
518  leadingPosition = leadingStrip;
519  }
520  }
521  // apply some sanity cuts. This is needed since we don't use tracking to clean clusters
522  // 1.5< noise <8
523  // charge<250
524  // 50 > s/n > 10
525  edm::ESHandle<SiStripNoises> noiseHandle_;
526  iSetup.get<SiStripNoisesRcd>().get(noiseHandle_);
527  SiStripNoises::Range detNoiseRange = noiseHandle_->getRange(DSViter->id());
528  float noise=noiseHandle_->getNoise(leadingPosition, detNoiseRange);
529  if( noise<1.5 ) continue;
530  if( leadingCharge>=250 || noise>=8 || leadingCharge/noise>50 || leadingCharge/noise<10 ) continue;
531  // apply some correction to the leading charge, but only if it has not saturated.
532  if(leadingCharge<255) {
533  // correct for modulethickness for TEC and TOB
534  if((((((DSViter->id())>>25)&0x7f)==0xd)||((((DSViter->id())>>25)&0x7f)==0xe))&&((((DSViter->id())>>5)&0x7)>4))
535  leadingCharge = uint8_t((leadingCharge*0.64));
536  }
537  //code the time of flight == 0 in the digi
538  SiStripRawDigi newSiStrip(leadingCharge);
539  newds.push_back(newSiStrip);
540  }
541  //store into the detsetvector
542  output.push_back(newds);
543  LogDebug("produce") << "New edm::DetSet<SiStripRawDigi> added with fedkey = "
544  << std::hex << std::setfill('0') << std::setw(8)
545  << connectionMap_[DSViter->id()] << std::dec;
546  }
547  // add the selected hits to the event.
548  LogDebug("produce") << "Putting " << output.size() << " new hits in the event.";
549  std::auto_ptr< edm::DetSetVector<SiStripRawDigi> > formatedOutput(new edm::DetSetVector<SiStripRawDigi>(output) );
550  iEvent.put(formatedOutput,"FineDelaySelection");
551 }
552 
553 // ------------ method called once each job just before starting event loop ------------
554 void
556 {
557  // Retrieve FED cabling object
559  iSetup.get<SiStripFedCablingRcd>().get( cabling );
560  const std::vector< uint16_t > & feds = cabling->feds() ;
561  for(std::vector< uint16_t >::const_iterator fedid = feds.begin();fedid<feds.end();++fedid) {
562  const std::vector< FedChannelConnection > & connections = cabling->connections(*fedid);
563  for(std::vector< FedChannelConnection >::const_iterator conn=connections.begin();conn<connections.end();++conn) {
564  /*
565  SiStripFedKey key(conn->fedId(),
566  SiStripFedKey::feUnit(conn->fedCh()),
567  SiStripFedKey::feChan(conn->fedCh()));
568  connectionMap_[conn->detId()] = key.key();
569  */
570  // the key is computed using an alternate formula for performance reasons.
571  connectionMap_[conn->detId()] = ( ( conn->fedId() & sistrip::invalid_ ) << 16 ) | ( conn->fedCh() & sistrip::invalid_ );
572  }
573  }
574 }
#define LogDebug(id)
iterator end()
Definition: DetSet.h:61
const double Pi
T getParameter(std::string const &) const
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)
int i
Definition: DBlmapReader.cc:9
virtual void produceNoTracking(edm::Event &, const edm::EventSetup &)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator begin() const
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:150
std::pair< SiStripDigiIter, SiStripDigiIter > SiStripDigiRange
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
Constants and enumerated type for sistrip::RunType.
data_type const * const_iterator
Definition: DetSetNew.h:25
edm::InputTag clusterLabel_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::pair< uint32_t, uint32_t > deviceMask(const StripSubdetector::SubDetector subdet, const int substructure)
std::map< uint32_t, uint32_t > connectionMap_
virtual void beginRun(edm::Run &, const edm::EventSetup &)
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
virtual const Topology & topology() const =0
SiStripFineDelayHit(const edm::ParameterSet &)
std::vector< std::pair< std::pair< DetId, LocalPoint >,float > > findtrackangle(const std::vector< Trajectory > &traj)
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
ParameterVector parameters() const
Track parameters with one-to-one correspondence to the covariance matrix.
Definition: TrackBase.h:178
static double timeOfFlight(bool cosmics, bool field, double *trackParameters, double *hit, double *phit, bool onDisk)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
SiStripFineDelayTLA * anglefinder_
tuple result
Definition: query.py:137
def runsummary
Definition: dataDML.py:413
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
virtual void produce(edm::Event &, const edm::EventSetup &)
edm::InputTag inputModuleLabel_
float barycenter() const
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
#define end
Definition: vmac.h:38
static void trackParameters(const reco::Track &tk, double *trackParameters)
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
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:356
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:55
static const uint16_t invalid_
Definition: Constants.h:17
bool rechit(reco::Track *tk, uint32_t detId)
T const * product() const
Definition: Handle.h:74
std::vector< Trajectory > TrajectoryCollection
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
#define begin
Definition: vmac.h:31
const edm::Event * event_
void event_()
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:341
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:41
collection_type::const_iterator const_iterator
Definition: DetSet.h:34
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:106
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
T x() const
Definition: PV2DBase.h:44
T x() const
Definition: PV3DBase.h:61
tuple conn
Definition: results_mgr.py:53
Definition: Run.h:33
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:65