72 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;
423 std::vector<Trajectory> trajVec;
427 trajVec = *(TrajectoryCollection.
product());
431 for (reco::TrackCollection::const_iterator itrack =
tracks->begin(); itrack <
tracks->end(); itrack++) {
433 if ((itrack->px() * itrack->px() + itrack->py() * itrack->py() + itrack->pz() * itrack->pz()) <
minTrackP2_)
436 std::vector<std::pair<uint32_t, std::pair<double, double> > > intersections;
444 if (((layerCode >> 6) & 0x3) == 0)
446 else if (((layerCode >> 6) & 0x3) == 1)
448 else if (((layerCode >> 6) & 0x3) == 2)
450 else if (((layerCode >> 6) & 0x3) == 3)
452 int32_t layerIdx = (layerCode & 0xF) * (((layerCode >> 4) & 0x3) ? -1 : 1);
453 intersections =
detId(tracker, tTopo, &(*itrack), trajVec, subdet, layerIdx);
456 intersections =
detId(tracker, tTopo, &(*itrack), trajVec);
458 LogDebug(
"produce") <<
" Found " << intersections.size() <<
" interesting intersections." << std::endl;
459 for (
std::vector<std::pair<uint32_t, std::pair<double, double> > >::iterator it = intersections.begin();
460 it < intersections.end();
462 std::pair<const SiStripCluster*, double> candidateCluster =
463 closestCluster(tracker, &(*itrack), it->first, *clusterSet, *hitSet);
464 if (candidateCluster.first) {
465 LogDebug(
"produce") <<
" Found a cluster." << std::endl;
469 LogDebug(
"produce") <<
" The cluster is close enough." << std::endl;
472 const auto& amplitudes = candidateCluster.first->amplitudes();
473 uint8_t leadingCharge = 0;
474 uint8_t leadingStrip = candidateCluster.first->firstStrip();
475 uint8_t leadingPosition = 0;
476 for (
auto amplit = amplitudes.begin(); amplit < amplitudes.end(); amplit++, leadingStrip++) {
477 if (leadingCharge < *amplit) {
478 leadingCharge = *amplit;
479 leadingPosition = leadingStrip;
484 std::vector<edm::DetSet<SiStripRawDigi> >::iterator newdsit =
output.begin();
488 if (newdsit ==
output.end()) {
491 newdsit =
output.end() - 1;
494 LogDebug(
"produce") <<
" New Hit... TOF:" << it->second.first <<
", charge: " << int(leadingCharge)
495 <<
" at " << int(leadingPosition) <<
"." << std::endl
496 <<
"Angular correction: " << it->second.second <<
" giving a final value of "
497 << int(leadingCharge * fabs(it->second.second))
498 <<
" for fed key = " <<
connectionMap_[it->first] <<
" (detid=" << it->first <<
")";
500 if (leadingCharge < 255) {
502 leadingCharge = uint8_t(leadingCharge * fabs(it->second.second));
504 if ((((it->first >> 25) & 0x7f) == 0xd) ||
505 ((((it->first >> 25) & 0x7f) == 0xe) && (((it->first >> 5) & 0x7) > 4)))
506 leadingCharge = uint8_t((leadingCharge * 0.64));
509 unsigned int tof =
abs(
int(round(it->second.first * 10)));
510 tof = tof > 255 ? 255 : tof;
512 newdsit->push_back(newSiStrip);
513 LogDebug(
"produce") <<
"New edm::DetSet<SiStripRawDigi> added.";
516 delete candidateCluster.first;
521 LogDebug(
"produce") <<
"Putting " <<
output.size() <<
" new hits in the event.";
523 iEvent.
put(
std::move(formatedOutput),
"FineDelaySelection");
532 std::vector<edm::DetSet<SiStripRawDigi> >
output;
540 if (((layerCode >> 6) & 0x3) == 0)
542 else if (((layerCode >> 6) & 0x3) == 1)
544 else if (((layerCode >> 6) & 0x3) == 2)
546 else if (((layerCode >> 6) & 0x3) == 3)
548 int32_t layerIdx = (layerCode & 0xF) * (((layerCode >> 4) & 0x3) ? -1 : 1);
557 if (
mode_ == 1 && ((DSViter->id() & mask.first) != mask.second))
566 auto const& amplitudes = iter->amplitudes();
567 uint8_t leadingCharge = 0;
568 uint8_t leadingStrip = iter->firstStrip();
569 uint8_t leadingPosition = 0;
570 for (
auto amplit = amplitudes.begin(); amplit < amplitudes.end(); amplit++, leadingStrip++) {
571 if (leadingCharge < *amplit) {
572 leadingCharge = *amplit;
573 leadingPosition = leadingStrip;
582 float noise = noises.getNoise(leadingPosition, detNoiseRange);
585 if (leadingCharge >= 250 || noise >= 8 || leadingCharge / noise > 50 || leadingCharge / noise < 10)
588 if (leadingCharge < 255) {
590 if ((((((DSViter->id()) >> 25) & 0x7f) == 0xd) || ((((DSViter->id()) >> 25) & 0x7f) == 0xe)) &&
591 ((((DSViter->id()) >> 5) & 0x7) > 4))
592 leadingCharge = uint8_t((leadingCharge * 0.64));
596 newds.push_back(newSiStrip);
599 output.push_back(newds);
600 LogDebug(
"produce") <<
"New edm::DetSet<SiStripRawDigi> added with fedkey = " << std::hex << std::setfill(
'0')
604 LogDebug(
"produce") <<
"Putting " << output.size() <<
" new hits in the event.";
606 iEvent.
put(
std::move(formatedOutput),
"FineDelaySelection");
613 auto feds = cabling.fedIds();
614 for (
auto fedid =
feds.begin(); fedid <
feds.end(); ++fedid) {
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.
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
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)
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
auto const & tracks
cannot be loose
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)
bool getData(T &iHolder) const
std::vector< std::pair< std::pair< DetId, LocalPoint >, float > > findtrackangle(const std::vector< Trajectory > &traj)
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)
edm::ESGetToken< SiStripNoises, SiStripNoisesRcd > noiseToken_
~SiStripFineDelayHit() override
static double timeOfFlight(bool cosmics, bool field, double *trackParameters, double *hit, double *phit, bool onDisk)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
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
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)
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
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)
const TrackerGeomDet * idToDet(DetId) const override
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
T getParameter(std::string const &) const
static const uint16_t invalid_
bool rechit(reco::Track *tk, uint32_t detId)
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_
void produce(edm::Event &, const edm::EventSetup &) override
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
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
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_
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
const_iterator begin(bool update=false) const
double maxClusterDistance_
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.