CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DTSegment2DSLPhiQuality Class Reference

#include <DTSegment2DSLPhiQuality.h>

Inheritance diagram for DTSegment2DSLPhiQuality:
DQMGlobalEDAnalyzer< Histograms > edm::global::EDAnalyzer< edm::RunCache< Histograms > > edm::global::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 DTSegment2DSLPhiQuality (const edm::ParameterSet &pset)
 Constructor. More...
 
- Public Member Functions inherited from edm::global::EDAnalyzer< edm::RunCache< Histograms > >
 EDAnalyzer ()=default
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void bookHistograms (DQMStore::ConcurrentBooker &, edm::Run const &, edm::EventSetup const &, Histograms &) const override
 Book the DQM plots. More...
 
void dqmAnalyze (edm::Event const &, edm::EventSetup const &, Histograms const &) const override
 Perform the real analysis. More...
 

Private Attributes

bool debug_
 
bool doall_
 
bool local_
 
edm::InputTag segment4DLabel_
 
edm::EDGetTokenT< DTRecSegment4DCollectionsegment4DToken_
 
double sigmaResAngle_
 
double sigmaResPos_
 
edm::InputTag simHitLabel_
 
edm::EDGetTokenT< edm::PSimHitContainersimHitToken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Basic analyzer class which accesses 2D DTSegments reconstructed with both SL Phi and plot resolution comparing reconstructed and simulated quantities

Author
S. Bolognesi and G. Cerminara - INFN Torino

Definition at line 31 of file DTSegment2DSLPhiQuality.h.

Constructor & Destructor Documentation

DTSegment2DSLPhiQuality::DTSegment2DSLPhiQuality ( const edm::ParameterSet pset)

Constructor.

Definition at line 34 of file DTSegment2DSLPhiQuality.cc.

References DTHitQualityUtils::debug, edm::ParameterSet::getParameter(), and edm::ParameterSet::getUntrackedParameter().

34  {
35  // Get the debug parameter for verbose output
36  debug_ = pset.getUntrackedParameter<bool>("debug");
38 
39  // the name of the simhit collection
40  simHitLabel_ = pset.getUntrackedParameter<InputTag>("simHitLabel");
41  simHitToken_ = consumes<PSimHitContainer>(pset.getUntrackedParameter<InputTag>("simHitLabel"));
42  // the name of the 2D rec hit collection
43  segment4DLabel_ = pset.getUntrackedParameter<InputTag>("segment4DLabel");
44  segment4DToken_ = consumes<DTRecSegment4DCollection>(pset.getUntrackedParameter<InputTag>("segment4DLabel"));
45 
46  // sigma resolution on position
47  sigmaResPos_ = pset.getParameter<double>("sigmaResPos");
48  // sigma resolution on angle
49  sigmaResAngle_ = pset.getParameter<double>("sigmaResAngle");
50  doall_ = pset.getUntrackedParameter<bool>("doall", false);
51  local_ = pset.getUntrackedParameter<bool>("local", false);
52 }
edm::EDGetTokenT< edm::PSimHitContainer > simHitToken_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< DTRecSegment4DCollection > segment4DToken_

Member Function Documentation

void DTSegment2DSLPhiQuality::bookHistograms ( DQMStore::ConcurrentBooker booker,
edm::Run const &  run,
edm::EventSetup const &  setup,
Histograms histograms 
) const
overrideprivatevirtual

Book the DQM plots.

Implements DQMGlobalEDAnalyzer< Histograms >.

Definition at line 54 of file DTSegment2DSLPhiQuality.cc.

References Histograms::h2DHitEff_SuperPhi, and Histograms::h2DHitSuperPhi.

54  {
55  // Book the histos
56  histograms.h2DHitSuperPhi = new HRes2DHit ("SuperPhi", booker, doall_, local_);
57  if (doall_) { histograms.h2DHitEff_SuperPhi = new HEff2DHit ("SuperPhi", booker);
58 }
59 }
HEff2DHit * h2DHitEff_SuperPhi
HRes2DHit * h2DHitSuperPhi
void DTSegment2DSLPhiQuality::dqmAnalyze ( edm::Event const &  event,
edm::EventSetup const &  setup,
Histograms const &  histograms 
) const
overrideprivate

Perform the real analysis.

Definition at line 62 of file DTSegment2DSLPhiQuality.cc.

References relativeConstraints::chamber, DTGeometry::chamber(), gather_cfg::cout, DEFINE_FWK_MODULE, SoftLeptonByDistance_cfi::distance, PV3DBase< T, PVType, FrameType >::eta(), HRes2DHit::fill(), HEff2DHit::fill(), DTHitQualityUtils::findMuSimSegment(), DTHitQualityUtils::findMuSimSegmentDirAndPos(), DTHitQualityUtils::findSegmentAlphaAndBeta(), edm::EventSetup::get(), Histograms::h2DHitEff_SuperPhi, Histograms::h2DHitSuperPhi, edm::HandleBase::isValid(), DTRecSegment2D::localDirection(), DTRecSegment2D::localDirectionError(), DTRecSegment2D::localPosition(), DTRecSegment2D::localPositionError(), DTHitQualityUtils::mapMuSimHitsPerWire(), DTHitQualityUtils::mapSimHitsPerWire(), PV3DBase< T, PVType, FrameType >::phi(), rpcPointValidation_cfi::simHit, trackerHits::simHits, mathSSE::sqrt(), GeomDet::toGlobal(), PV3DBase< T, PVType, FrameType >::x(), and LocalError::xx().

62  {
63  // Get the DT Geometry
64  ESHandle<DTGeometry> dtGeom;
65  setup.get<MuonGeometryRecord>().get(dtGeom);
66 
67  // Get the SimHit collection from the event
69  event.getByToken(simHitToken_, simHits); // FIXME: second string to be removed
70 
71  // Map simHits by chamber
72  map<DTChamberId, PSimHitContainer > simHitsPerCh;
73  for (const auto & simHit : *simHits) {
74  // Create the id of the chamber (the simHits in the DT known their wireId)
75  DTChamberId chamberId = (((DTWireId(simHit.detUnitId())).layerId()).superlayerId()).chamberId();
76  // Fill the map
77  simHitsPerCh[chamberId].push_back(simHit);
78  }
79 
80  // Get the 4D rechits from the event
82  event.getByToken(segment4DToken_, segment4Ds);
83 
84  if (!segment4Ds.isValid()) {
85  if (debug_) {
86  cout << "[DTSegment2DSLPhiQuality]**Warning: no 4D Segments with label: " << segment4DLabel_
87  << " in this event, skipping!" << endl;
88 }
89  return;
90  }
91 
92  // Loop over all chambers containing a segment
93  DTRecSegment4DCollection::id_iterator chamberId;
94  for (chamberId = segment4Ds->id_begin();
95  chamberId != segment4Ds->id_end();
96  ++chamberId) {
97 
98  //------------------------- simHits ---------------------------//
99  // Get simHits of each chamber
100  PSimHitContainer simHits = simHitsPerCh[(*chamberId)];
101 
102  // Map simhits per wire
103  map<DTWireId, PSimHitContainer > simHitsPerWire = DTHitQualityUtils::mapSimHitsPerWire(simHits);
104  map<DTWireId, const PSimHit*> muSimHitPerWire = DTHitQualityUtils::mapMuSimHitsPerWire(simHitsPerWire);
105  int nMuSimHit = muSimHitPerWire.size();
106  if (nMuSimHit == 0 || nMuSimHit == 1) {
107  if (debug_ && nMuSimHit == 1) {
108  cout << "[DTSegment2DSLPhiQuality] Only " << nMuSimHit << " mu SimHit in this chamber, skipping!" << endl;
109 }
110  continue; // If no or only one mu SimHit is found skip this chamber
111  }
112  if (debug_) {
113  cout << "=== Chamber " << (*chamberId) << " has " << nMuSimHit << " SimHits" << endl;
114 }
115 
116  // Find outer and inner mu SimHit to build a segment
117  pair<const PSimHit*, const PSimHit*> inAndOutSimHit = DTHitQualityUtils::findMuSimSegment(muSimHitPerWire);
118 
119  // Find direction and position of the sim Segment in Chamber RF
120  pair<LocalVector, LocalPoint> dirAndPosSimSegm = DTHitQualityUtils::findMuSimSegmentDirAndPos(inAndOutSimHit,
121  (*chamberId),&(*dtGeom));
122 
123  LocalVector simSegmLocalDir = dirAndPosSimSegm.first;
124  LocalPoint simSegmLocalPos = dirAndPosSimSegm.second;
125  const DTChamber* chamber = dtGeom->chamber(*chamberId);
126  GlobalPoint simSegmGlobalPos = chamber->toGlobal(simSegmLocalPos);
127 
128  // Atan(x/z) angle and x position in SL RF
129  float angleSimSeg = DTHitQualityUtils::findSegmentAlphaAndBeta(simSegmLocalDir).first;
130  float posSimSeg = simSegmLocalPos.x();
131  // Position (in eta, phi coordinates) in lobal RF
132  float etaSimSeg = simSegmGlobalPos.eta();
133  float phiSimSeg = simSegmGlobalPos.phi();
134 
135  if (debug_) {
136  cout << " Simulated segment: local direction " << simSegmLocalDir << endl
137  << " local position " << simSegmLocalPos << endl
138  << " angle " << angleSimSeg << endl;
139 }
140 
141  //---------------------------- recHits --------------------------//
142  // Get the range of rechit for the corresponding chamberId
143  bool recHitFound = false;
144  DTRecSegment4DCollection::range range = segment4Ds->get(*chamberId);
145  int nsegm = distance(range.first, range.second);
146  if (debug_) {
147  cout << " Chamber: " << *chamberId << " has " << nsegm
148  << " 4D segments" << endl;
149 }
150 
151  if (nsegm!= 0) {
152  // Find the best RecHit: look for the 4D RecHit with the phi angle closest
153  // to that of segment made of SimHits.
154  // RecHits must have delta alpha and delta position within 5 sigma of
155  // the residual distribution (we are looking for residuals of segments
156  // usefull to the track fit) for efficency purpose
157  const DTRecSegment2D* bestRecHit = nullptr;
158  bool bestRecHitFound = false;
159  double deltaAlpha = 99999;
160 
161  // Loop over the recHits of this chamberId
162  for (DTRecSegment4DCollection::const_iterator segment4D = range.first;
163  segment4D!= range.second;
164  ++segment4D) {
165  // Check the dimension
166  if ((*segment4D).dimension() != 4) {
167  if (debug_) { cout << "[DTSegment2DSLPhiQuality]***Error: This is not 4D segment!!!" << endl;
168 }
169  continue;
170  }
171 
172  // Get 2D superPhi segments from 4D segments
173  const DTChamberRecSegment2D* phiSegment2D = (*segment4D).phiSegment();
174  if ((*phiSegment2D).dimension() != 2) {
175  if (debug_) { cout << "[DTSegment2DQuality]***Error: This is not 2D segment!!!" << endl;
176 }
177  abort();
178  }
179 
180  // Segment Local Direction and position (in Chamber RF)
181  LocalVector recSegDirection = (*phiSegment2D).localDirection();
182 
183  float recSegAlpha = DTHitQualityUtils::findSegmentAlphaAndBeta(recSegDirection).first;
184  if (debug_) {
185  cout << " RecSegment direction: " << recSegDirection << endl
186  << " position : " << (*phiSegment2D).localPosition() << endl
187  << " alpha : " << recSegAlpha << endl;
188 }
189 
190  if (fabs(recSegAlpha - angleSimSeg) < deltaAlpha) {
191  deltaAlpha = fabs(recSegAlpha - angleSimSeg);
192  bestRecHit = &(*phiSegment2D);
193  bestRecHitFound = true;
194  }
195  } // End of Loop over all 4D RecHits of this chambers
196 
197  if (bestRecHitFound) {
198  // Best rechit direction and position in Chamber RF
199  LocalPoint bestRecHitLocalPos = bestRecHit->localPosition();
200  LocalVector bestRecHitLocalDir = bestRecHit->localDirection();
201 
202  LocalError bestRecHitLocalPosErr = bestRecHit->localPositionError();
203  LocalError bestRecHitLocalDirErr = bestRecHit->localDirectionError();
204 
205  float angleBestRHit = DTHitQualityUtils::findSegmentAlphaAndBeta(bestRecHitLocalDir).first;
206  if (fabs(angleBestRHit - angleSimSeg) < 5*sigmaResAngle_ &&
207  fabs(bestRecHitLocalPos.x() - posSimSeg) < 5*sigmaResPos_) {
208  recHitFound = true;
209  }
210 
211  // Fill Residual histos
212  histograms.h2DHitSuperPhi->fill(angleSimSeg,
213  angleBestRHit,
214  posSimSeg,
215  bestRecHitLocalPos.x(),
216  etaSimSeg,
217  phiSimSeg,
218  sqrt(bestRecHitLocalPosErr.xx()),
219  sqrt(bestRecHitLocalDirErr.xx())
220  );
221  }
222  } // end of if (nsegm!= 0)
223 
224  // Fill Efficiency plot
225  if (doall_) {
226  histograms.h2DHitEff_SuperPhi->fill(etaSimSeg,
227  phiSimSeg,
228  posSimSeg,
229  angleSimSeg,
230  recHitFound);
231  }
232  } // End of loop over chambers
233 }
edm::EDGetTokenT< edm::PSimHitContainer > simHitToken_
LocalError localPositionError() const override
local position error in SL frame
float xx() const
Definition: LocalError.h:24
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:99
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:54
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
static std::map< DTWireId, const PSimHit * > mapMuSimHitsPerWire(const std::map< DTWireId, edm::PSimHitContainer > &simHitWireMap)
Create a map between the Mu SimHits and corresponding MuBarWireId ;.
static std::pair< const PSimHit *, const PSimHit * > findMuSimSegment(const std::map< DTWireId, const PSimHit * > &mapWireAndMuSimHit)
Find Innermost and outermost SimHit from Mu in a SL (they identify a simulated segment) ...
T sqrt(T t)
Definition: SSEVec.h:18
edm::EDGetTokenT< DTRecSegment4DCollection > segment4DToken_
bool isValid() const
Definition: HandleBase.h:74
static std::pair< double, double > findSegmentAlphaAndBeta(const LocalVector &direction)
static std::pair< LocalVector, LocalPoint > findMuSimSegmentDirAndPos(const std::pair< const PSimHit *, const PSimHit * > &inAndOutSimHit, const DetId detId, const DTGeometry *muonGeom)
Find direction and position of a segment (in local RF) from outer and inner mu SimHit in the RF of ob...
LocalPoint localPosition() const override
local position in SL frame
T eta() const
Definition: PV3DBase.h:76
LocalVector localDirection() const override
the local direction in SL frame
std::vector< PSimHit > PSimHitContainer
static std::map< DTWireId, edm::PSimHitContainer > mapSimHitsPerWire(const edm::PSimHitContainer &simhits)
LocalError localDirectionError() const override
the local direction error (xx,xy,yy) in SL frame: only xx is not 0.
T x() const
Definition: PV3DBase.h:62

Member Data Documentation

bool DTSegment2DSLPhiQuality::debug_
private

Definition at line 60 of file DTSegment2DSLPhiQuality.h.

bool DTSegment2DSLPhiQuality::doall_
private

Definition at line 56 of file DTSegment2DSLPhiQuality.h.

bool DTSegment2DSLPhiQuality::local_
private

Definition at line 57 of file DTSegment2DSLPhiQuality.h.

edm::InputTag DTSegment2DSLPhiQuality::segment4DLabel_
private

Definition at line 46 of file DTSegment2DSLPhiQuality.h.

edm::EDGetTokenT<DTRecSegment4DCollection> DTSegment2DSLPhiQuality::segment4DToken_
private

Definition at line 48 of file DTSegment2DSLPhiQuality.h.

double DTSegment2DSLPhiQuality::sigmaResAngle_
private

Definition at line 54 of file DTSegment2DSLPhiQuality.h.

double DTSegment2DSLPhiQuality::sigmaResPos_
private

Definition at line 51 of file DTSegment2DSLPhiQuality.h.

edm::InputTag DTSegment2DSLPhiQuality::simHitLabel_
private

Definition at line 45 of file DTSegment2DSLPhiQuality.h.

edm::EDGetTokenT<edm::PSimHitContainer> DTSegment2DSLPhiQuality::simHitToken_
private

Definition at line 47 of file DTSegment2DSLPhiQuality.h.