77 produces<edm::DetSetVector<SiStripRawDigi> >(
"FineDelaySelection");
116 const int substructure,
118 uint32_t rootDetId = 0;
119 uint32_t maskDetId = 0;
123 rootDetId = tkrTopo->
tibDetId(substructure, 0, 0, 0, 0, 0).
rawId();
128 rootDetId = tkrTopo->
tidDetId(substructure > 0 ? 2 : 1,
abs(substructure), 0, 0, 0, 0).
rawId();
133 rootDetId = tkrTopo->
tobDetId(substructure, 0, 0, 0, 0).
rawId();
138 rootDetId = tkrTopo->
tecDetId(substructure > 0 ? 2 : 1,
abs(substructure), 0, 0, 0, 0, 0).
rawId();
145 return std::make_pair(maskDetId, rootDetId);
152 const std::vector<Trajectory>& trajVec,
154 const int substructure) {
155 if (substructure == 0xff)
156 return detId(tracker, tkrTopo, tk, trajVec, 0, 0);
160 return detId(tracker, tkrTopo, tk, trajVec, mask.first, mask.second);
167 const std::vector<Trajectory>& trajVec,
168 const uint32_t& maskDetId,
169 const uint32_t& rootDetId) {
170 bool onDisk = ((maskDetId == tkrTopo->
tidDetId(3, 15, 0, 0, 0, 0).
rawId()) ||
171 (maskDetId == tkrTopo->
tecDetId(3, 15, 0, 0, 0, 0, 0).
rawId()));
172 std::vector<std::pair<uint32_t, std::pair<double, double> > >
result;
173 std::vector<uint32_t> usedDetids;
175 std::vector<std::pair<std::pair<DetId, LocalPoint>,
float> > hitangle;
179 for (std::vector<Trajectory>::const_iterator traj = trajVec.begin(); traj < trajVec.end(); ++traj) {
180 if (((traj->lastMeasurement().recHit()->geographicalId().rawId() ==
181 (*(tk->
recHitsEnd() - 1))->geographicalId().rawId()) &&
182 (traj->lastMeasurement().recHit()->localPosition().x() == (*(tk->
recHitsEnd() - 1))->localPosition().x())) ||
183 ((traj->firstMeasurement().recHit()->geographicalId().rawId() ==
184 (*(tk->
recHitsEnd() - 1))->geographicalId().rawId()) &&
185 (traj->firstMeasurement().recHit()->localPosition().x() == (*(tk->
recHitsEnd() - 1))->localPosition().x()))) {
197 LogDebug(
"DetId") <<
"number of hits for the track: " << hitangle.size();
198 std::vector<std::pair<std::pair<DetId, LocalPoint>,
float> >::iterator iter;
200 for (iter = hitangle.begin(); iter != hitangle.end(); iter++) {
205 LogDebug(
"DetId") <<
"check the detid: " << std::hex << (iter->first.first.rawId()) <<
" vs " << rootDetId
206 <<
" with a mask of " << maskDetId <<
std::dec << std::endl;
208 if (((iter->first.first.rawId() & maskDetId) != rootDetId))
210 if (
std::find(usedDetids.begin(), usedDetids.end(), iter->first.first.rawId()) != usedDetids.end())
213 LogDebug(
"DetId") <<
"check the angle: " << fabs((iter->second));
217 std::pair<uint32_t, std::pair<double, double> > el;
218 std::pair<double, double> subel;
219 el.first = iter->first.first.rawId();
224 double trackParameters[5];
225 for (
int i = 0;
i < 5;
i++)
240 subel.second = iter->second;
243 result.push_back(el);
244 usedDetids.push_back(el.first);
251 if ((*it)->geographicalId().rawId() == det_id) {
252 return (*it)->isValid();
263 const uint32_t& det_id,
266 std::pair<const SiStripCluster*, double>
result(
nullptr, 0.);
267 double hitStrip = -1;
271 LogDebug(
"closestCluster") <<
"(*it)->geographicalId().rawId() vs det_id" << (*it)->geographicalId().rawId() <<
" " 274 if ((*it)->geographicalId().rawId() == det_id) {
275 if (!(*it)->isValid())
277 LogDebug(
"closestCluster") <<
" using the single mono hit";
320 LogDebug(
"closestCluster") <<
" hit strip = " << hitStrip;
326 if (DSViter->id == det_id) {
329 minStrip = minStrip < 0 ? 0 : minStrip;
331 maxStrip = maxStrip >= nstrips ? nstrips - 1 : maxStrip;
335 if (digiIt->strip() >= minStrip && rangeStart == DSViter->
end())
337 if (digiIt->strip() <= maxStrip)
340 if (rangeStart != DSViter->
end()) {
341 if (rangeStop != DSViter->
end())
344 LogDebug(
"closestCluster") <<
"build a fake cluster ";
347 result.first = newCluster;
348 result.second = fabs(newCluster->
barycenter() - hitStrip);
357 if (DSViter->id() == det_id) {
358 LogDebug(
"closestCluster") <<
" detset with the right detid. ";
362 result.second = 1000.;
364 double dist = fabs(iter->barycenter() - hitStrip);
365 if (dist < result.second) {
366 result.second = dist;
367 result.first = &(*iter);
398 std::vector<edm::DetSet<SiStripRawDigi> >
output;
407 if (!tracks->empty()) {
409 LogDebug(
"produce") <<
"Found " << tracks->size() <<
" tracks.";
424 std::vector<Trajectory> trajVec;
428 trajVec = *(TrajectoryCollection.
product());
433 for (reco::TrackCollection::const_iterator itrack = tracks->begin(); itrack < tracks->end(); itrack++) {
435 if ((itrack->px() * itrack->px() + itrack->py() * itrack->py() + itrack->pz() * itrack->pz()) <
minTrackP2_)
438 std::vector<std::pair<uint32_t, std::pair<double, double> > > intersections;
446 if (((layerCode >> 6) & 0x3) == 0)
448 else if (((layerCode >> 6) & 0x3) == 1)
450 else if (((layerCode >> 6) & 0x3) == 2)
452 else if (((layerCode >> 6) & 0x3) == 3)
454 int32_t layerIdx = (layerCode & 0xF) * (((layerCode >> 4) & 0x3) ? -1 : 1);
455 intersections =
detId(*tracker, tTopo.
product(), &(*itrack), trajVec, subdet, layerIdx);
458 intersections =
detId(*tracker, tTopo.
product(), &(*itrack), trajVec);
460 LogDebug(
"produce") <<
" Found " << intersections.size() <<
" interesting intersections." << std::endl;
461 for (std::vector<std::pair<uint32_t, std::pair<double, double> > >::iterator it = intersections.begin();
462 it < intersections.end();
464 std::pair<const SiStripCluster*, double> candidateCluster =
465 closestCluster(*tracker, &(*itrack), it->first, *clusterSet, *hitSet);
466 if (candidateCluster.first) {
467 LogDebug(
"produce") <<
" Found a cluster." << std::endl;
471 LogDebug(
"produce") <<
" The cluster is close enough." << std::endl;
474 const auto& amplitudes = candidateCluster.first->amplitudes();
475 uint8_t leadingCharge = 0;
476 uint8_t leadingStrip = candidateCluster.first->firstStrip();
477 uint8_t leadingPosition = 0;
478 for (
auto amplit = amplitudes.begin(); amplit < amplitudes.end(); amplit++, leadingStrip++) {
479 if (leadingCharge < *amplit) {
480 leadingCharge = *amplit;
481 leadingPosition = leadingStrip;
486 std::vector<edm::DetSet<SiStripRawDigi> >::iterator newdsit = output.begin();
487 for (; newdsit != output.end() && newdsit->detId() !=
connectionMap_[it->first]; ++newdsit) {
490 if (newdsit == output.end()) {
492 output.push_back(newds);
493 newdsit = output.end() - 1;
496 LogDebug(
"produce") <<
" New Hit... TOF:" << it->second.first <<
", charge: " <<
int(leadingCharge)
497 <<
" at " <<
int(leadingPosition) <<
"." << std::endl
498 <<
"Angular correction: " << it->second.second <<
" giving a final value of " 499 <<
int(leadingCharge * fabs(it->second.second))
500 <<
" for fed key = " <<
connectionMap_[it->first] <<
" (detid=" << it->first <<
")";
502 if (leadingCharge < 255) {
504 leadingCharge = uint8_t(leadingCharge * fabs(it->second.second));
506 if ((((it->first >> 25) & 0x7f) == 0xd) ||
507 ((((it->first >> 25) & 0x7f) == 0xe) && (((it->first >> 5) & 0x7) > 4)))
508 leadingCharge = uint8_t((leadingCharge * 0.64));
511 unsigned int tof =
abs(
int(round(it->second.first * 10)));
512 tof = tof > 255 ? 255 : tof;
514 newdsit->push_back(newSiStrip);
515 LogDebug(
"produce") <<
"New edm::DetSet<SiStripRawDigi> added.";
518 delete candidateCluster.first;
523 LogDebug(
"produce") <<
"Putting " << output.size() <<
" new hits in the event.";
525 iEvent.
put(
std::move(formatedOutput),
"FineDelaySelection");
535 std::vector<edm::DetSet<SiStripRawDigi> >
output;
543 if (((layerCode >> 6) & 0x3) == 0)
545 else if (((layerCode >> 6) & 0x3) == 1)
547 else if (((layerCode >> 6) & 0x3) == 2)
549 else if (((layerCode >> 6) & 0x3) == 3)
551 int32_t layerIdx = (layerCode & 0xF) * (((layerCode >> 4) & 0x3) ? -1 : 1);
560 if (
mode_ == 1 && ((DSViter->id() & mask.first) != mask.second))
569 auto const& amplitudes = iter->amplitudes();
570 uint8_t leadingCharge = 0;
571 uint8_t leadingStrip = iter->firstStrip();
572 uint8_t leadingPosition = 0;
573 for (
auto amplit = amplitudes.begin(); amplit < amplitudes.end(); amplit++, leadingStrip++) {
574 if (leadingCharge < *amplit) {
575 leadingCharge = *amplit;
576 leadingPosition = leadingStrip;
586 float noise = noiseHandle_->
getNoise(leadingPosition, detNoiseRange);
589 if (leadingCharge >= 250 || noise >= 8 || leadingCharge / noise > 50 || leadingCharge / noise < 10)
592 if (leadingCharge < 255) {
594 if ((((((DSViter->id()) >> 25) & 0x7f) == 0xd) || ((((DSViter->id()) >> 25) & 0x7f) == 0xe)) &&
595 ((((DSViter->id()) >> 5) & 0x7) > 4))
596 leadingCharge = uint8_t((leadingCharge * 0.64));
600 newds.push_back(newSiStrip);
603 output.push_back(newds);
604 LogDebug(
"produce") <<
"New edm::DetSet<SiStripRawDigi> added with fedkey = " << std::hex << std::setfill(
'0')
608 LogDebug(
"produce") <<
"Putting " << output.size() <<
" new hits in the event.";
610 iEvent.
put(
std::move(formatedOutput),
"FineDelaySelection");
621 for (std::vector<FedChannelConnection>::const_iterator
conn = connections.begin();
conn < connections.end();
T getParameter(std::string const &) const
static constexpr auto TEC
virtual void produceNoTracking(edm::Event &, const edm::EventSetup &)
const_iterator end(bool update=false) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual const Topology & topology() const
std::pair< SiStripDigiIter, SiStripDigiIter > SiStripDigiRange
edm::EDGetTokenT< SiStripEventSummary > inputModuleToken_
constexpr uint32_t rawId() const
get the raw id
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
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::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)
std::vector< std::pair< std::pair< DetId, LocalPoint >, float > > findtrackangle(const std::vector< Trajectory > &traj)
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::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)
~SiStripFineDelayHit() override
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)
static constexpr auto TOB
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.
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
edm::EDGetTokenT< TrajectorySeedCollection > seedcollToken_
static constexpr auto TIB
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
std::pair< uint32_t, uint32_t > DeviceMask
static const uint16_t invalid_
bool rechit(reco::Track *tk, uint32_t detId)
ConnsConstIterRange fedConnections(uint16_t fed_id) const
std::map< uint32_t, uint32_t > connectionMap_
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
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 ...
static constexpr auto TID
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_
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.