79 produces<edm::DetSetVector<SiStripRawDigi> >(
"FineDelaySelection");
119 uint32_t rootDetId = 0;
120 uint32_t maskDetId = 0;
126 rootDetId = tkrTopo->
tibDetId(substructure,0,0,0,0,0).
rawId();
132 rootDetId = tkrTopo->
tidDetId(substructure>0 ? 2 : 1,
abs(substructure),0,0,0,0).
rawId();
144 rootDetId = tkrTopo->
tecDetId(substructure>0 ? 2 : 1,
abs(substructure),0,0,0,0,0).
rawId();
149 return std::make_pair(maskDetId,rootDetId);
154 if(substructure==0xff)
return detId(tracker,tkrTopo,tk,trajVec,0,0);
158 return detId(tracker,tkrTopo,tk,trajVec,mask.first,mask.second);
163 bool onDisk = ((maskDetId==tkrTopo->
tidDetId(3,15,0,0,0,0).
rawId())||(maskDetId==tkrTopo->
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;
167 std::vector<std::pair< std::pair<DetId, LocalPoint> ,
float> > hitangle;
171 for(std::vector<Trajectory>::const_iterator traj = trajVec.begin(); traj< trajVec.end(); ++traj) {
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()) ) ) {
188 LogDebug(
"DetId") <<
"number of hits for the track: " << hitangle.size();
189 std::vector<std::pair< std::pair<DetId, LocalPoint> ,
float> >::iterator iter;
191 for(iter=hitangle.begin();iter!=hitangle.end();iter++){
196 LogDebug(
"DetId") <<
"check the detid: " << std::hex << (iter->first.first.rawId()) <<
" vs " << rootDetId
197 <<
" with a mask of " << maskDetId <<
std::dec << std::endl;
199 if(((iter->first.first.rawId() & maskDetId) != rootDetId))
continue;
200 if(
std::find(usedDetids.begin(),usedDetids.end(),iter->first.first.rawId())!=usedDetids.end())
continue;
202 LogDebug(
"DetId") <<
"check the angle: " << fabs((iter->second));
205 std::pair<uint32_t,std::pair<double, double> > el;
206 std::pair<double, double> subel;
207 el.first = iter->first.first.rawId();
212 double trackParameters[5];
226 subel.second = iter->second;
229 result.push_back(el);
230 usedDetids.push_back(el.first);
238 if((*it)->geographicalId().rawId() == det_id) {
239 return (*it)->isValid();
249 std::pair<const SiStripCluster*,double>
result(
NULL,0.);
250 double hitStrip = -1;
254 LogDebug(
"closestCluster") <<
"(*it)->geographicalId().rawId() vs det_id" << (*it)->geographicalId().rawId() <<
" " << det_id;
256 if((*it)->geographicalId().rawId() == det_id) {
257 if(!(*it)->isValid())
continue;
258 LogDebug(
"closestCluster") <<
" using the single mono hit";
301 LogDebug(
"closestCluster") <<
" hit strip = " << hitStrip;
302 if(hitStrip<0)
return result;
306 if(DSViter->id==det_id) {
309 minStrip = minStrip<0 ? 0 : minStrip;
311 maxStrip = maxStrip>=nstrips ? nstrips-1 : maxStrip;
315 if(digiIt->strip()>=minStrip && rangeStart == DSViter->
end()) rangeStart = digiIt;
316 if(digiIt->strip()<=maxStrip) rangeStop = digiIt;
318 if(rangeStart != DSViter->
end()) {
319 if(rangeStop !=DSViter->
end()) ++rangeStop;
321 LogDebug(
"closestCluster") <<
"build a fake cluster ";
323 result.first = newCluster;
324 result.second = fabs(newCluster->
barycenter()-hitStrip);
332 if(DSViter->id()==det_id) {
333 LogDebug(
"closestCluster") <<
" detset with the right detid. ";
337 result.second = 1000.;
339 double dist = fabs(iter->barycenter()-hitStrip);
340 if(dist<result.second) { result.second = dist; result.first = &(*iter); }
370 std::vector< edm::DetSet<SiStripRawDigi> >
output;
379 if (tracks->size()) {
381 LogDebug(
"produce") <<
"Found " << tracks->size() <<
" tracks.";
396 std::vector<Trajectory> trajVec;
400 trajVec = *(TrajectoryCollection.
product());
405 for(reco::TrackCollection::const_iterator itrack = tracks->begin(); itrack<tracks->end(); itrack++) {
407 if((itrack->px()*itrack->px()+itrack->py()*itrack->py()+itrack->pz()*itrack->pz())<
minTrackP2_)
continue;
409 std::vector< std::pair<uint32_t,std::pair<double,double> > > intersections;
421 int32_t layerIdx = (layerCode&0xF)*(((layerCode>>4)&0x3) ? -1 : 1);
422 intersections =
detId(*tracker,tTopo.
product(),&(*itrack),trajVec,subdet,layerIdx);
425 intersections =
detId(*tracker,tTopo.
product(),&(*itrack),trajVec);
427 LogDebug(
"produce") <<
" Found " << intersections.size() <<
" interesting intersections." << std::endl;
428 for(std::vector< std::pair<uint32_t,std::pair<double,double> > >::iterator it = intersections.begin();it<intersections.end();it++) {
429 std::pair<const SiStripCluster*,double> candidateCluster =
closestCluster(*tracker,&(*itrack),it->first,*clusterSet,*hitSet);
430 if(candidateCluster.first) {
431 LogDebug(
"produce") <<
" Found a cluster."<< std::endl;
434 LogDebug(
"produce") <<
" The cluster is close enough."<< std::endl;
437 const auto & amplitudes = candidateCluster.first->amplitudes();
438 uint8_t leadingCharge = 0;
439 uint8_t leadingStrip = candidateCluster.first->firstStrip();
440 uint8_t leadingPosition = 0;
441 for(
auto amplit = amplitudes.begin();amplit<amplitudes.end();amplit++,leadingStrip++) {
442 if(leadingCharge<*amplit) {
443 leadingCharge = *amplit;
444 leadingPosition = leadingStrip;
449 std::vector< edm::DetSet<SiStripRawDigi> >::iterator newdsit = output.begin();
450 for(;newdsit!=output.end()&&newdsit->detId()!=
connectionMap_[it->first];++newdsit) {}
452 if(newdsit==output.end()) {
454 output.push_back(newds);
455 newdsit = output.end()-1;
458 LogDebug(
"produce") <<
" New Hit... TOF:" << it->second.first <<
", charge: " <<
int(leadingCharge)
459 <<
" at " <<
int(leadingPosition) <<
"." << std::endl
460 <<
"Angular correction: " << it->second.second
461 <<
" giving a final value of " <<
int(leadingCharge*fabs(it->second.second))
462 <<
" for fed key = " <<
connectionMap_[it->first] <<
" (detid=" << it->first <<
")" ;
464 if(leadingCharge<255) {
466 leadingCharge = uint8_t(leadingCharge*fabs(it->second.second));
468 if((((it->first>>25)&0x7f)==0xd) ||
469 ((((it->first>>25)&0x7f)==0xe) && (((it->first>>5)&0x7)>4)))
470 leadingCharge = uint8_t((leadingCharge*0.64));
473 unsigned int tof =
abs(
int(round(it->second.first*10)));
474 tof = tof>255 ? 255 : tof;
476 newdsit->push_back(newSiStrip);
477 LogDebug(
"produce") <<
"New edm::DetSet<SiStripRawDigi> added.";
484 LogDebug(
"produce") <<
"Putting " << output.size() <<
" new hits in the event.";
486 iEvent.
put(
std::move(formatedOutput),
"FineDelaySelection");
498 std::vector< edm::DetSet<SiStripRawDigi> >
output;
510 int32_t layerIdx = (layerCode&0xF)*(((layerCode>>4)&0x3) ? -1 : 1);
518 if(
mode_==1 && ((DSViter->id() & mask.first) != mask.second) )
continue;
526 auto const & amplitudes = iter->amplitudes();
527 uint8_t leadingCharge = 0;
528 uint8_t leadingStrip = iter->firstStrip();
529 uint8_t leadingPosition = 0;
530 for(
auto amplit = amplitudes.begin();amplit<amplitudes.end();amplit++,leadingStrip++) {
531 if(leadingCharge<*amplit) {
532 leadingCharge = *amplit;
533 leadingPosition = leadingStrip;
543 float noise=noiseHandle_->
getNoise(leadingPosition, detNoiseRange);
544 if( noise<1.5 )
continue;
545 if( leadingCharge>=250 || noise>=8 || leadingCharge/noise>50 || leadingCharge/noise<10 )
continue;
547 if(leadingCharge<255) {
549 if((((((DSViter->id())>>25)&0x7f)==0xd)||((((DSViter->id())>>25)&0x7f)==0xe))&&((((DSViter->id())>>5)&0x7)>4))
550 leadingCharge = uint8_t((leadingCharge*0.64));
554 newds.push_back(newSiStrip);
557 output.push_back(newds);
558 LogDebug(
"produce") <<
"New edm::DetSet<SiStripRawDigi> added with fedkey = " 559 << std::hex << std::setfill(
'0') << std::setw(8)
563 LogDebug(
"produce") <<
"Putting " << output.size() <<
" new hits in the event.";
565 iEvent.
put(
std::move(formatedOutput),
"FineDelaySelection");
575 auto feds = cabling->
fedIds() ;
576 for(
auto fedid = feds.begin();fedid<feds.end();++fedid) {
578 for(std::vector< FedChannelConnection >::const_iterator conn=connections.begin();conn<connections.end();++conn) {
T getParameter(std::string const &) const
virtual void produceNoTracking(edm::Event &, const edm::EventSetup &)
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator end(bool update=false) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
virtual ~SiStripFineDelayHit()
std::pair< SiStripDigiIter, SiStripDigiIter > SiStripDigiRange
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual const Topology & topology() const
edm::EDGetTokenT< SiStripEventSummary > inputModuleToken_
std::vector< Track > TrackCollection
collection of Tracks
void init(const edm::Event &e, const edm::EventSetup &c)
Constants and enumerated type for sistrip::RunType.
data_type const * const_iterator
std::pair< uint32_t, uint32_t > DeviceMask
const Vector & momentum() const
track momentum vector
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::map< uint32_t, uint32_t > connectionMap_
std::vector< std::pair< uint32_t, std::pair< double, double > > > detId(const TrackerGeometry &tracker, const TrackerTopology *tkrTopo, const reco::Track *tk, const std::vector< Trajectory > &trajVec, const StripSubdetector::SubDetector subdet=StripSubdetector::TIB, const int substructure=0xff)
uint32_t rawId() const
get the raw id
const sistrip::RunType & runType() const
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
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)
static float getNoise(uint16_t strip, const Range &range)
static double timeOfFlight(bool cosmics, bool field, double *trackParameters, double *hit, double *phit, bool onDisk)
FedsConstIterRange fedIds() const
SiStripFineDelayTLA * anglefinder_
Cos< T >::type cos(const T &t)
DetId tobDetId(uint32_t layer, uint32_t rod_fw_bw, uint32_t rod, uint32_t module, uint32_t ster) const
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
DetId tidDetId(uint32_t side, uint32_t wheel, uint32_t ring, uint32_t module_fw_bw, uint32_t module, uint32_t ster) const
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clustersToken_
Abs< T >::type abs(const T &t)
static void trackParameters(const reco::Track &tk, double *trackParameters)
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
DeviceMask deviceMask(const StripSubdetector::SubDetector subdet, const int substructure, const TrackerTopology *tkrTopo)
iterator end()
Return the off-the-end iterator.
edm::EDGetTokenT< TrajectorySeedCollection > seedcollToken_
edm::EDGetTokenT< edm::DetSetVector< SiStripDigi > > digiToken_
T const * product() const
DetId tibDetId(uint32_t layer, uint32_t str_fw_bw, uint32_t str_int_ext, uint32_t str, uint32_t module, uint32_t ster) const
def runsummary(schema, runnum, sessionflavor='')
static const uint16_t invalid_
bool rechit(reco::Track *tk, uint32_t detId)
ConnsConstIterRange fedConnections(uint16_t fed_id) const
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
std::vector< Trajectory > TrajectoryCollection
ParameterVector parameters() const
Track parameters with one-to-one correspondence to the covariance matrix.
const edm::Event * event_
const Range getRange(const uint32_t detID) const
const TrackerGeomDet * idToDet(DetId) const override
virtual void produce(edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< std::vector< Trajectory > > trackToken_
iterator begin()
Return an iterator to the first DetSet.
edm::EDGetTokenT< reco::TrackCollection > trackCollectionToken_
std::pair< ContainerIterator, ContainerIterator > Range
collection_type::const_iterator const_iterator
collection_type::const_iterator const_iterator
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
DetId tecDetId(uint32_t side, uint32_t wheel, uint32_t petal_fw_bw, uint32_t petal, uint32_t ring, uint32_t module, uint32_t ster) const
T const * product() const
const_iterator begin(bool update=false) const
double maxClusterDistance_
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.