84 produces<edm::DetSetVector<SiStripRawDigi> >(
"FineDelaySelection");
124 uint32_t rootDetId = 0;
125 uint32_t maskDetId = 0;
135 rootDetId =
TIDDetId(substructure>0 ? 2 : 1,
abs(substructure),0,0,0,0).
rawId();
147 rootDetId =
TECDetId(substructure>0 ? 2 : 1,
abs(substructure),0,0,0,0,0).
rawId();
152 return std::make_pair(maskDetId,rootDetId);
157 if(substructure==0xff)
return detId(tracker,tk,trajVec,0,0);
159 std::pair<uint32_t, uint32_t>
mask =
deviceMask(subdet,substructure);
161 return detId(tracker,tk,trajVec,mask.first,mask.second);
166 bool onDisk = ((maskDetId==
TIDDetId(3,15,0,0,0,0).
rawId())||(maskDetId==
TECDetId(3,15,0,0,0,0,0).
rawId())) ;
167 std::vector< std::pair<uint32_t,std::pair<double, double> > >
result;
168 std::vector<uint32_t> usedDetids;
170 std::vector<std::pair< std::pair<DetId, LocalPoint> ,
float> > hitangle;
174 for(std::vector<Trajectory>::const_iterator traj = trajVec.begin(); traj< trajVec.end(); ++traj) {
176 ((traj->lastMeasurement().recHit()->geographicalId().rawId() == (*(tk->
recHitsEnd()-1))->geographicalId().rawId()) &&
177 ( traj->lastMeasurement().recHit()->localPosition().x() == (*(tk->
recHitsEnd()-1))->localPosition().x()) ) ||
178 ((traj->firstMeasurement().recHit()->geographicalId().rawId() == (*(tk->
recHitsEnd()-1))->geographicalId().rawId()) &&
179 ( traj->firstMeasurement().recHit()->localPosition().x() == (*(tk->
recHitsEnd()-1))->localPosition().x()) ) ) {
191 LogDebug(
"DetId") <<
"number of hits for the track: " << hitangle.size();
192 std::vector<std::pair< std::pair<DetId, LocalPoint> ,
float> >::iterator iter;
194 for(iter=hitangle.begin();iter!=hitangle.end();iter++){
199 LogDebug(
"DetId") <<
"check the detid: " << std::hex << (iter->first.first.rawId()) <<
" vs " << rootDetId
200 <<
" with a mask of " << maskDetId <<
std::dec << std::endl;
202 if(((iter->first.first.rawId() & maskDetId) != rootDetId))
continue;
203 if(
std::find(usedDetids.begin(),usedDetids.end(),iter->first.first.rawId())!=usedDetids.end())
continue;
205 LogDebug(
"DetId") <<
"check the angle: " << fabs((iter->second));
208 std::pair<uint32_t,std::pair<double, double> > el;
209 std::pair<double, double> subel;
210 el.first = iter->first.first.rawId();
215 double trackParameters[5];
229 subel.second = iter->second;
232 result.push_back(el);
233 usedDetids.push_back(el.first);
241 if((*it)->geographicalId().rawId() == det_id) {
242 return (*it)->isValid();
252 std::pair<const SiStripCluster*,double>
result(
NULL,0.);
253 double hitStrip = -1;
257 LogDebug(
"closestCluster") <<
"(*it)->geographicalId().rawId() vs det_id" << (*it)->geographicalId().rawId() <<
" " << det_id;
259 if((*it)->geographicalId().rawId() == det_id) {
260 if(!(*it)->isValid())
continue;
261 LogDebug(
"closestCluster") <<
" using the single mono hit";
304 LogDebug(
"closestCluster") <<
" hit strip = " << hitStrip;
305 if(hitStrip<0)
return result;
309 if(DSViter->id==det_id) {
312 minStrip = minStrip<0 ? 0 : minStrip;
314 maxStrip = maxStrip>=nstrips ? nstrips-1 : maxStrip;
318 if(digiIt->strip()>=minStrip && rangeStart == DSViter->
end()) rangeStart = digiIt;
319 if(digiIt->strip()<=maxStrip) rangeStop = digiIt;
321 if(rangeStart != DSViter->
end()) {
322 if(rangeStop !=DSViter->
end()) ++rangeStop;
324 LogDebug(
"closestCluster") <<
"build a fake cluster ";
326 result.first = newCluster;
327 result.second = fabs(newCluster->
barycenter()-hitStrip);
335 if(DSViter->id()==det_id) {
336 LogDebug(
"closestCluster") <<
" detset with the right detid. ";
340 result.second = 1000.;
342 double dist = fabs(iter->barycenter()-hitStrip);
343 if(dist<result.second) { result.second = dist; result.first = &(*iter); }
373 std::vector< edm::DetSet<SiStripRawDigi> >
output;
382 if (tracks->size()) {
384 LogDebug(
"produce") <<
"Found " << tracks->size() <<
" tracks.";
399 std::vector<Trajectory> trajVec;
403 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,&(*itrack),trajVec,subdet,layerIdx);
425 intersections =
detId(*tracker,&(*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");
495 std::vector< edm::DetSet<SiStripRawDigi> >
output;
507 int32_t layerIdx = (layerCode&0xF)*(((layerCode>>4)&0x3) ? -1 : 1);
515 if(
mode_==1 && ((DSViter->id() & mask.first) != mask.second) )
continue;
523 auto const & amplitudes = iter->amplitudes();
524 uint8_t leadingCharge = 0;
525 uint8_t leadingStrip = iter->firstStrip();
526 uint8_t leadingPosition = 0;
527 for(
auto amplit = amplitudes.begin();amplit<amplitudes.end();amplit++,leadingStrip++) {
528 if(leadingCharge<*amplit) {
529 leadingCharge = *amplit;
530 leadingPosition = leadingStrip;
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;
544 if(leadingCharge<255) {
546 if((((((DSViter->id())>>25)&0x7f)==0xd)||((((DSViter->id())>>25)&0x7f)==0xe))&&((((DSViter->id())>>5)&0x7)>4))
547 leadingCharge = uint8_t((leadingCharge*0.64));
551 newds.push_back(newSiStrip);
554 output.push_back(newds);
555 LogDebug(
"produce") <<
"New edm::DetSet<SiStripRawDigi> added with fedkey = " 556 << std::hex << std::setfill(
'0') << std::setw(8)
560 LogDebug(
"produce") <<
"Putting " << output.size() <<
" new hits in the event.";
562 iEvent.
put(
std::move(formatedOutput),
"FineDelaySelection");
572 auto feds = cabling->
fedIds() ;
573 for(
auto fedid = feds.begin();fedid<feds.end();++fedid) {
575 for(std::vector< FedChannelConnection >::const_iterator conn=connections.begin();conn<connections.end();++conn) {
T getParameter(std::string const &) const
const TrackerGeomDet * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
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 &)
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
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::pair< uint32_t, uint32_t > deviceMask(const StripSubdetector::SubDetector subdet, const int substructure)
std::map< uint32_t, uint32_t > connectionMap_
uint32_t rawId() const
get the raw id
const sistrip::RunType & runType() const
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)
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
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.
iterator end()
Return the off-the-end iterator.
edm::EDGetTokenT< TrajectorySeedCollection > seedcollToken_
edm::EDGetTokenT< edm::DetSetVector< SiStripDigi > > digiToken_
T const * product() 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
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 ...
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
const TrackerGeomDet * idToDet(DetId) const
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.