73 combinatorialTracks_token_(
81 addLumi_(conf.getUntrackedParameter<
bool>(
"addLumi",
false)),
82 DEBUG_(conf.getParameter<
bool>(
"Debug")),
83 cutOnTracks_(conf.getUntrackedParameter<
bool>(
"cutOnTracks",
false)),
84 momentumCut_(conf.getUntrackedParameter<double>(
"MomentumCut", 3.)),
85 compSettings_(conf.getUntrackedParameter<
int>(
"CompressionSettings", -1)),
86 usePairsOnly_(conf.getUntrackedParameter<unsigned
int>(
"UsePairsOnly", 1)),
87 layers_(conf.getParameter<
int>(
"Layer")),
88 trackMultiplicityCut_(conf.getUntrackedParameter<unsigned
int>(
"trackMultiplicity", 100)) {
99 reso =
fs->make<TTree>(
"reso",
"tree hit pairs for resolution studies");
100 reso->Branch(
"momentum", &
mymom,
"momentum/F");
103 reso->Branch(
"detID1", &
iidd1,
"detID1/I");
107 reso->Branch(
"atEdge1", &
atEdge,
"atEdge1/F");
109 reso->Branch(
"detID2", &
iidd2,
"detID2/I");
114 reso->Branch(
"hitDX", &
hitDX,
"hitDX/F");
126 treso =
fs->make<TTree>(
"treso",
"tree tracks for resolution studies");
138 histos2d_[
"track_phi_vs_eta"] =
new TH2F(
"track_phi_vs_eta",
";track phi;track eta", 60, -3.5, 3.5, 60, -3., 3.);
139 histos2d_[
"residual_vs_trackMomentum"] =
new TH2F(
"residual_vs_trackMomentum",
140 ";track momentum [GeV]; x_{pred_track} - x_{reco_hit} [#mum]",
147 histos2d_[
"residual_vs_trackPt"] =
new TH2F(
148 "residual_vs_trackPt",
";track p_{T}[GeV];x_{pred_track} - x_{reco_hit} [#mum]", 60, 0., 10., 60, 0., 200.);
150 new TH2F(
"residual_vs_trackEta",
";track #eta;x_{pred_track} - x_{reco_hit} [#mum]", 60, 0., 3., 60, 0., 200.);
152 new TH2F(
"residual_vs_trackPhi",
";track #phi;x_{pred_track} - x_{reco_hit} [#mum]", 60, 0., 3.5, 60, 0., 200.);
153 histos2d_[
"residual_vs_expectedWidth"] =
new TH2F(
154 "residual_vs_expectedWidth",
";track Width;x_{pred_track} - x_{reco_hit} [#mum]", 3, 0., 3., 60, 0., 200.);
156 new TH2F(
"numHits_vs_residual",
";x_{pred_track} - x_{reco_hit} [#mum];N Hits", 60, 0., 200., 15, 0., 15.);
163 LogDebug(
"SiStripHitResolution:HitResol") <<
"beginning analyze from HitResol" << endl;
166 using namespace reco;
170 int run_nr =
e.id().run();
171 int ev_nr =
e.id().event();
180 e.getByToken(
tjToken_, trajectoryCollectionHandle);
227 LogDebug(
"HitResol") <<
"Starting analysis, nrun nevent, tracksCKF->size(): " << run_nr <<
" " << ev_nr <<
" " 228 << tracksCKF->size() << std::endl;
230 for (
unsigned int iT = 0; iT < tracksCKF->size(); ++iT) {
242 for (
const auto& traj : *trajectoryCollection) {
243 const auto& TMeas = traj.measurements();
246 for (
auto itm = TMeas.cbegin(); itm != TMeas.cend(); ++itm) {
247 if (!itm->updatedState().isValid()) {
248 LogDebug(
"HitResol") <<
"trajectory measurement not valid" << std::endl;
258 LogDebug(
"HitResol") <<
"TrackChi2 = " 260 <<
"itm->updatedState().globalMomentum().perp(): " 261 << itm->updatedState().globalMomentum().perp() <<
"\n" 262 <<
"numhits " << traj.foundHits() << std::endl;
267 mymom = itm->updatedState().globalMomentum().perp();
271 const auto hit1 = itm->recHit();
294 uint16_t firstStrip = hit1d->cluster()->firstStrip();
295 uint16_t lastStrip = firstStrip + (hit1d->cluster()->amplitudes()).
size() - 1;
304 uint16_t firstStrip = hit2d->cluster()->firstStrip();
305 uint16_t lastStrip = firstStrip + (hit2d->cluster()->amplitudes()).
size() - 1;
312 histos2d_[
"residual_vs_trackMomentum"]->Fill(itm->updatedState().globalMomentum().mag(),
315 histos2d_[
"residual_vs_trackEta"]->Fill(itm->updatedState().globalMomentum().eta(),
simpleRes * 10000);
316 histos2d_[
"residual_vs_trackPhi"]->Fill(itm->updatedState().globalMomentum().phi(),
simpleRes * 10000);
321 vector<TrajectoryMeasurement>::const_iterator itTraj2 = TMeas.end();
323 for (
auto itmCompare = itm - 1;
325 itmCompare >= TMeas.cbegin() && itmCompare > itm - 4;
327 const auto hit2 = itmCompare->recHit();
328 if (!hit2->isValid())
333 iidd1 = hit1->geographicalId().rawId();
334 iidd2 = hit2->geographicalId().rawId();
335 if (
id1.subdetId() !=
id2.subdetId() || ::checkLayer(
iidd1, tTopo) != ::checkLayer(
iidd2, tTopo))
342 LogDebug(
"HitResol") <<
"BAD GLUED: Have glued layer with id = " <<
id1.rawId()
346 LogDebug(
"HitResol") <<
"BAD GLUED: Have glued layer with id = " <<
id2.rawId()
350 itTraj2 = itmCompare;
354 if (itTraj2 == TMeas.cend()) {
356 LogDebug(
"HitResol") <<
"Found overlapping sensors " << std::endl;
362 const auto myhit2 = itTraj2->recHit();
363 const auto myhit_2 = (*itTraj2->recHit()).
hit();
365 const StripTopology& Topo_2 = stripdet_2->specificTopology();
367 float mypitch_2 = stripdet_2->surface().bounds().width() / Topo_2.
nstrips();
380 uint16_t firstStrip_2 = hit1d_2->cluster()->firstStrip();
381 uint16_t lastStrip_2 = firstStrip_2 + (hit1d_2->cluster()->amplitudes()).
size() - 1;
389 uint16_t firstStrip_2 = hit2d_2->cluster()->firstStrip();
390 uint16_t lastStrip_2 = firstStrip_2 + (hit2d_2->cluster()->amplitudes()).
size() - 1;
417 <<
" momentum " <<
mymom <<
"\n" 418 <<
" numHits " <<
numHits <<
"\n" 420 <<
" detID1 " <<
iidd1 <<
"\n" 423 <<
" expectedW1 " <<
expWidth <<
"\n" 424 <<
" atEdge1 " <<
atEdge <<
"\n" 426 <<
" detID2 " <<
iidd2 <<
"\n" 431 <<
" hitDX " <<
hitDX <<
"\n" 432 <<
" trackDX " <<
trackDX <<
"\n" 451 LogDebug(
"SiStripHitResolution:HitResol") <<
" Events Analysed " <<
events << endl;
454 reso->GetDirectory()->cd();
464 double consistency = separation /
error;
475 const auto& topol =
dynamic_cast<const StripTopology&
>(stripdet->topology());
478 (*pitch) = topol.localPitch(
position);
480 float anglealpha = 0;
481 if (trackdirection.
z() != 0) {
482 anglealpha = atan(trackdirection.
x() / trackdirection.
z()) * TMath::RadToDeg();
486 float thickness = stripdet->surface().bounds().thickness();
487 float tanalpha =
tan(anglealpha * TMath::DegToRad());
496 theCombinedPredictedState =
501 if (!theCombinedPredictedState.
isValid()) {
506 double recHitX_1 = firstRecHit->localPosition().x();
507 return (theCombinedPredictedState.
localPosition().
x() - recHitX_1);
565 std::pair<TrajectoryStateOnSurface, double> tsosWithS =
propagator.propagateWithPath(comb1, fwdPred2.
surface());
578 double predX1 = pars[3];
592 double predX2 = pars[3];
606 double c00 = covComb1(3, 3);
609 for (
int i = 1;
i < 5; ++
i) {
610 c10 += jacobian(3,
i) * covComb1(
i, 3);
611 for (
int j = 1;
j < 5; ++
j)
612 c11 += jacobian(3,
i) * covComb1(
i,
j) * jacobian(3,
j);
615 double diff = c00 - 2 * fabs(c10) + c11;
618 double relativeXSign_ = c10 > 0 ? -1 : 1;
620 (
trackDX) = predX1 + relativeXSign_ * predX2;
622 double recHitX_1 = traj1->
recHit()->localPosition().x();
623 double recHitX_2 = traj2->
recHit()->localPosition().x();
625 (
hitDX) = recHitX_1 + relativeXSign_ * recHitX_2;
635 desc.addUntracked<
int>(
"CompressionSettings", -1);
636 desc.add<
int>(
"Layer", 0);
637 desc.add<
bool>(
"Debug",
false);
638 desc.addUntracked<
bool>(
"addLumi",
false);
639 desc.addUntracked<
bool>(
"cutOnTracks",
false);
640 desc.addUntracked<
unsigned int>(
"trackMultiplicity", 100);
641 desc.addUntracked<
double>(
"MomentumCut", 3.);
642 desc.addUntracked<
unsigned int>(
"UsePairsOnly", 1);
std::pair< LocalPoint, LocalError > LocalValues
static const std::string kSharedResource
double checkConsistency(const StripClusterParameterEstimator::LocalValues ¶meters, double xx, double xerr)
static constexpr auto TEC
virtual int nstrips() const =0
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
const LocalTrajectoryError & localError() const
HitResol(const edm::ParameterSet &conf)
LocalPoint localPosition() const
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
T const * product() const
LocalVector drift(const StripGeomDetUnit *, const MagneticField &, const SiStripLorentzAngle &)
const GlobalTrajectoryParameters & globalParameters() const
std::vector< Track > TrackCollection
collection of Tracks
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepStd< double, 5, 5 > > AlgebraicMatrix55
const unsigned int usePairsOnly_
const edm::EDGetTokenT< reco::TrackCollection > combinatorialTracks_token_
const LocalTrajectoryParameters & localParameters() const
bool isStereo(const DetId &id) const
const SurfaceType & surface() const
const edm::ESGetToken< SiStripQuality, SiStripQualityRcd > siStripQualityToken_
const edm::EDGetTokenT< std::vector< Trajectory > > tjToken_
bool getPairParameters(const MagneticField *magField_, AnalyticalPropagator &propagator, const TrajectoryMeasurement *traj1, const TrajectoryMeasurement *traj2, float &pairPath, float &hitDX, float &trackDX, float &trackDXE, float &trackParamX, float &trackParamY, float &trackParamDXDZ, float &trackParamDYDZ, float &trackParamXE, float &trackParamYE, float &trackParamDXDZE, float &trackParamDYDZE)
virtual LocalVector driftDirection(const StripGeomDetUnit *) const =0
GlobalPoint globalPosition() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
void analyze(const edm::Event &e, const edm::EventSetup &c) override
AlgebraicVector5 vector() const
LocalVector localDirection() const
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)
ROOT::Math::SVector< double, 5 > AlgebraicVector5
float ChiSquaredProbability(double chiSquared, double nrDOF)
#define DEFINE_FWK_MODULE(type)
double getSimpleRes(const TrajectoryMeasurement *traj1)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
std::map< TString, TH2F * > histos2d_
uint32_t glued(const DetId &id) const
Log< level::Info, false > LogInfo
const AlgebraicMatrix55 & jacobian() const
static constexpr auto TIB
std::vector< Trajectory > TrajectoryCollection
const edm::ESGetToken< StripClusterParameterEstimator, TkStripCPERecord > cpeToken_
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
GlobalVector globalMomentum() const
static int position[264][3]
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
unsigned int clusterWidth
const AlgebraicSymMatrix55 & matrix() const
std::vector< LumiScalers > LumiScalersCollection
unsigned int clusterWidth_2
TSOS combine(const TSOS &pTsos1, const TSOS &pTsos2) const
const double momentumCut_
void getSimHitRes(const GeomDetUnit *det, const LocalVector &trackdirection, const TrackingRecHit &recHit, float &trackWidth, float *pitch, LocalVector &drift)
ConstRecHitPointer const & recHit() const