CMS 3D CMS Logo

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

#include <DTSegment2DSLPhiQuality.h>

Inheritance diagram for DTSegment2DSLPhiQuality:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup)
 Perform the real analysis. More...
 
virtual void beginRun (const edm::Run &iRun, const edm::EventSetup &setup)
 
 DTSegment2DSLPhiQuality (const edm::ParameterSet &pset)
 Constructor. More...
 
void endJob ()
 
void endLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c)
 
virtual ~DTSegment2DSLPhiQuality ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

DQMStoredbe_
 
bool debug
 
bool doall
 
HEff2DHith2DHitEff_SuperPhi
 
HRes2DHith2DHitSuperPhi
 
bool local
 
std::string rootFileName
 
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::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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 33 of file DTSegment2DSLPhiQuality.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 40 of file DTSegment2DSLPhiQuality.cc.

References debug, DTHitQualityUtils::debug, DTRecHitQuality_cfi::doall, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), DTRecHitQuality_cfi::local, DTRecHitQuality_cfi::segment4DLabel, DTRecHitQuality_cfi::sigmaResAngle, DTRecHitQuality_cfi::sigmaResPos, and AddPileupSummary_cfi::simHitLabel.

40  {
41  // Get the debug parameter for verbose output
42  debug = pset.getUntrackedParameter<bool>("debug");
44 
45  // the name of the simhit collection
46  simHitLabel = pset.getUntrackedParameter<InputTag>("simHitLabel");
47  simHitToken_ = consumes<PSimHitContainer>(pset.getUntrackedParameter<InputTag>("simHitLabel"));
48  // the name of the 2D rec hit collection
49  segment4DLabel = pset.getUntrackedParameter<InputTag>("segment4DLabel");
50  segment4DToken_ = consumes<DTRecSegment4DCollection>(pset.getUntrackedParameter<InputTag>("segment4DLabel"));
51 
52  //sigma resolution on position
53  sigmaResPos = pset.getParameter<double>("sigmaResPos");
54  //sigma resolution on angle
55  sigmaResAngle = pset.getParameter<double>("sigmaResAngle");
56  doall = pset.getUntrackedParameter<bool>("doall", false);
57  local = pset.getUntrackedParameter<bool>("local", false);
58 }
edm::EDGetTokenT< edm::PSimHitContainer > simHitToken_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< DTRecSegment4DCollection > segment4DToken_
DTSegment2DSLPhiQuality::~DTSegment2DSLPhiQuality ( )
virtual

Destructor.

Definition at line 83 of file DTSegment2DSLPhiQuality.cc.

83  {
84 }

Member Function Documentation

void DTSegment2DSLPhiQuality::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
)

Perform the real analysis.

Definition at line 106 of file DTSegment2DSLPhiQuality.cc.

References relativeConstraints::chamber, DTGeometry::chamber(), gather_cfg::cout, debug, SoftLeptonByDistance_cfi::distance, DTRecHitQuality_cfi::doall, PV3DBase< T, PVType, FrameType >::eta(), DTHitQualityUtils::findMuSimSegment(), DTHitQualityUtils::findMuSimSegmentDirAndPos(), DTHitQualityUtils::findSegmentAlphaAndBeta(), edm::EventSetup::get(), edm::HandleBase::isValid(), DTRecSegment2D::localDirection(), DTRecSegment2D::localDirectionError(), DTRecSegment2D::localPosition(), DTRecSegment2D::localPositionError(), DTHitQualityUtils::mapMuSimHitsPerWire(), DTHitQualityUtils::mapSimHitsPerWire(), PV3DBase< T, PVType, FrameType >::phi(), DTRecHitQuality_cfi::segment4DLabel, DTRecHitQuality_cfi::sigmaResAngle, DTRecHitQuality_cfi::sigmaResPos, rpcPointValidation_cfi::simHit, trackerHits::simHits, mathSSE::sqrt(), GeomDet::toGlobal(), PV3DBase< T, PVType, FrameType >::x(), and LocalError::xx().

106  {
107  //theFile->cd();
108 
109  // Get the DT Geometry
110  ESHandle<DTGeometry> dtGeom;
111  eventSetup.get<MuonGeometryRecord>().get(dtGeom);
112 
113  // Get the SimHit collection from the event
115  event.getByToken(simHitToken_, simHits); //FIXME: second string to be removed
116 
117  //Map simHits by chamber
118  map<DTChamberId, PSimHitContainer > simHitsPerCh;
119  for(PSimHitContainer::const_iterator simHit = simHits->begin();
120  simHit != simHits->end(); simHit++){
121  // Create the id of the chamber (the simHits in the DT known their wireId)
122  DTChamberId chamberId = (((DTWireId(simHit->detUnitId())).layerId()).superlayerId()).chamberId();
123  // Fill the map
124  simHitsPerCh[chamberId].push_back(*simHit);
125  }
126 
127  // Get the 4D rechits from the event
129  event.getByToken(segment4DToken_, segment4Ds);
130 
131  if(!segment4Ds.isValid()) {
132  if(debug) cout << "[DTSegment2DSLPhiQuality]**Warning: no 4D Segments with label: " << segment4DLabel
133  << " in this event, skipping!" << endl;
134  return;
135  }
136 
137  // Loop over all chambers containing a segment
138  DTRecSegment4DCollection::id_iterator chamberId;
139  for (chamberId = segment4Ds->id_begin();
140  chamberId != segment4Ds->id_end();
141  ++chamberId){
142 
143  //------------------------- simHits ---------------------------//
144  //Get simHits of each chamber
145  PSimHitContainer simHits = simHitsPerCh[(*chamberId)];
146 
147  // Map simhits per wire
148  map<DTWireId, PSimHitContainer > simHitsPerWire = DTHitQualityUtils::mapSimHitsPerWire(simHits);
149  map<DTWireId, const PSimHit*> muSimHitPerWire = DTHitQualityUtils::mapMuSimHitsPerWire(simHitsPerWire);
150  int nMuSimHit = muSimHitPerWire.size();
151  if(nMuSimHit == 0 || nMuSimHit == 1) {
152  if(debug && nMuSimHit == 1)
153  cout << "[DTSegment2DSLPhiQuality] Only " << nMuSimHit << " mu SimHit in this chamber, skipping!" << endl;
154  continue; // If no or only one mu SimHit is found skip this chamber
155  }
156  if(debug)
157  cout << "=== Chamber " << (*chamberId) << " has " << nMuSimHit << " SimHits" << endl;
158 
159  //Find outer and inner mu SimHit to build a segment
160  pair<const PSimHit*, const PSimHit*> inAndOutSimHit = DTHitQualityUtils::findMuSimSegment(muSimHitPerWire);
161 
162  //Find direction and position of the sim Segment in Chamber RF
163  pair<LocalVector, LocalPoint> dirAndPosSimSegm = DTHitQualityUtils::findMuSimSegmentDirAndPos(inAndOutSimHit,
164  (*chamberId),&(*dtGeom));
165 
166  LocalVector simSegmLocalDir = dirAndPosSimSegm.first;
167  LocalPoint simSegmLocalPos = dirAndPosSimSegm.second;
168  const DTChamber* chamber = dtGeom->chamber(*chamberId);
169  GlobalPoint simSegmGlobalPos = chamber->toGlobal(simSegmLocalPos);
170 
171  //Atan(x/z) angle and x position in SL RF
172  float angleSimSeg = DTHitQualityUtils::findSegmentAlphaAndBeta(simSegmLocalDir).first;
173  float posSimSeg = simSegmLocalPos.x();
174  //Position (in eta,phi coordinates) in lobal RF
175  float etaSimSeg = simSegmGlobalPos.eta();
176  float phiSimSeg = simSegmGlobalPos.phi();
177 
178  if(debug)
179  cout<<" Simulated segment: local direction "<<simSegmLocalDir<<endl
180  <<" local position "<<simSegmLocalPos<<endl
181  <<" angle "<<angleSimSeg<<endl;
182 
183  //---------------------------- recHits --------------------------//
184  // Get the range of rechit for the corresponding chamberId
185  bool recHitFound = false;
186  DTRecSegment4DCollection::range range = segment4Ds->get(*chamberId);
187  int nsegm = distance(range.first, range.second);
188  if(debug)
189  cout << " Chamber: " << *chamberId << " has " << nsegm
190  << " 4D segments" << endl;
191 
192  if (nsegm!=0) {
193  // Find the best RecHit: look for the 4D RecHit with the phi angle closest
194  // to that of segment made of SimHits.
195  // RecHits must have delta alpha and delta position within 5 sigma of
196  // the residual distribution (we are looking for residuals of segments
197  // usefull to the track fit) for efficency purpose
198  const DTRecSegment2D* bestRecHit = 0;
199  bool bestRecHitFound = false;
200  double deltaAlpha = 99999;
201 
202  // Loop over the recHits of this chamberId
203  for (DTRecSegment4DCollection::const_iterator segment4D = range.first;
204  segment4D!=range.second;
205  ++segment4D){
206  // Check the dimension
207  if((*segment4D).dimension() != 4) {
208  if(debug) cout << "[DTSegment2DSLPhiQuality]***Error: This is not 4D segment!!!" << endl;
209  continue;
210  }
211 
212  //Get 2D superPhi segments from 4D segments
213  const DTChamberRecSegment2D* phiSegment2D = (*segment4D).phiSegment();
214  if((*phiSegment2D).dimension() != 2) {
215  if(debug) cout << "[DTSegment2DQuality]***Error: This is not 2D segment!!!" << endl;
216  abort();
217  }
218 
219  // Segment Local Direction and position (in Chamber RF)
220  LocalVector recSegDirection = (*phiSegment2D).localDirection();
221 
222  float recSegAlpha = DTHitQualityUtils::findSegmentAlphaAndBeta(recSegDirection).first;
223  if(debug)
224  cout << " RecSegment direction: " << recSegDirection << endl
225  << " position : " << (*phiSegment2D).localPosition() << endl
226  << " alpha : " << recSegAlpha << endl;
227 
228  if(fabs(recSegAlpha - angleSimSeg) < deltaAlpha) {
229  deltaAlpha = fabs(recSegAlpha - angleSimSeg);
230  bestRecHit = &(*phiSegment2D);
231  bestRecHitFound = true;
232  }
233  } // End of Loop over all 4D RecHits of this chambers
234 
235  if(bestRecHitFound) {
236  // Best rechit direction and position in Chamber RF
237  LocalPoint bestRecHitLocalPos = bestRecHit->localPosition();
238  LocalVector bestRecHitLocalDir = bestRecHit->localDirection();
239 
240  LocalError bestRecHitLocalPosErr = bestRecHit->localPositionError();
241  LocalError bestRecHitLocalDirErr = bestRecHit->localDirectionError();
242 
243  float angleBestRHit = DTHitQualityUtils::findSegmentAlphaAndBeta(bestRecHitLocalDir).first;
244  if(fabs(angleBestRHit - angleSimSeg) < 5*sigmaResAngle &&
245  fabs(bestRecHitLocalPos.x() - posSimSeg) < 5*sigmaResPos) {
246  recHitFound = true;
247  }
248 
249  // Fill Residual histos
250  h2DHitSuperPhi->Fill(angleSimSeg,
251  angleBestRHit,
252  posSimSeg,
253  bestRecHitLocalPos.x(),
254  etaSimSeg,
255  phiSimSeg,
256  sqrt(bestRecHitLocalPosErr.xx()),
257  sqrt(bestRecHitLocalDirErr.xx())
258  );
259  }
260  } //end of if(nsegm!=0)
261 
262  // Fill Efficiency plot
263  if(doall) {h2DHitEff_SuperPhi->Fill(etaSimSeg,
264  phiSimSeg,
265  posSimSeg,
266  angleSimSeg,
267  recHitFound);}
268  } // End of loop over chambers
269 }
edm::EDGetTokenT< edm::PSimHitContainer > simHitToken_
virtual LocalError localPositionError() const
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
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
virtual LocalError localDirectionError() const
the local direction error (xx,xy,yy) in SL frame: only xx is not 0.
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_
void Fill(float angleSimSegment, float angleRecSegment, float posSimSegment, float posRecSegment, float etaSimSegment, float phiSimSegment, float sigmaPos, float sigmaAngle)
Definition: Histograms.h:388
bool isValid() const
Definition: HandleBase.h:74
static std::pair< double, double > findSegmentAlphaAndBeta(const LocalVector &direction)
virtual LocalPoint localPosition() const
local position in SL frame
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...
void Fill(float etaSimSegm, float phiSimSegm, float posSimSegm, float angleSimSegm, bool fillRecHit)
Definition: Histograms.h:529
const T & get() const
Definition: EventSetup.h:56
const DTChamber * chamber(DTChamberId id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:100
T eta() const
Definition: PV3DBase.h:76
virtual LocalVector localDirection() const
the local direction in SL frame
std::vector< PSimHit > PSimHitContainer
static std::map< DTWireId, edm::PSimHitContainer > mapSimHitsPerWire(const edm::PSimHitContainer &simhits)
T x() const
Definition: PV3DBase.h:62
void DTSegment2DSLPhiQuality::beginRun ( const edm::Run iRun,
const edm::EventSetup setup 
)
virtual

Definition at line 61 of file DTSegment2DSLPhiQuality.cc.

References dbe_, debug, DTRecHitQuality_cfi::doall, DTRecHitQuality_cfi::local, and Utilities::operator.

61  {
62 
63  // get hold of back-end interface
64  dbe_ = 0;
66  if ( dbe_ ) {
67  if (debug) {
68  dbe_->setVerbose(1);
69  } else {
70  dbe_->setVerbose(0);
71  }
72  }
73  if ( dbe_ ) {
74  if ( debug ) dbe_->showDirStructure();
75  }
76 
77  // Book the histos
78  h2DHitSuperPhi = new HRes2DHit ("SuperPhi",dbe_,doall,local);
79  if(doall) h2DHitEff_SuperPhi = new HEff2DHit ("SuperPhi",dbe_);
80 }
void DTSegment2DSLPhiQuality::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 93 of file DTSegment2DSLPhiQuality.cc.

References DTRecHitQuality_cfi::doall.

93  {
94  // Write the histos to file
95  //theFile->cd();
96  //h2DHitSuperPhi->Write();
97 
99  //h2DHitEff_SuperPhi->Write();
100 
101  //if ( rootFileName.size() != 0 && dbe_ ) dbe_->save(rootFileName);
102  //theFile->Close();
103 }
void ComputeEfficiency()
Definition: Histograms.h:549
void DTSegment2DSLPhiQuality::endLuminosityBlock ( edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  c 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 86 of file DTSegment2DSLPhiQuality.cc.

87  {
88 }

Member Data Documentation

DQMStore* DTSegment2DSLPhiQuality::dbe_
private

Definition at line 76 of file DTSegment2DSLPhiQuality.h.

bool DTSegment2DSLPhiQuality::debug
private

Definition at line 61 of file DTSegment2DSLPhiQuality.h.

bool DTSegment2DSLPhiQuality::doall
private

Definition at line 77 of file DTSegment2DSLPhiQuality.h.

HEff2DHit* DTSegment2DSLPhiQuality::h2DHitEff_SuperPhi
private

Definition at line 75 of file DTSegment2DSLPhiQuality.h.

HRes2DHit* DTSegment2DSLPhiQuality::h2DHitSuperPhi
private

Definition at line 74 of file DTSegment2DSLPhiQuality.h.

bool DTSegment2DSLPhiQuality::local
private

Definition at line 78 of file DTSegment2DSLPhiQuality.h.

std::string DTSegment2DSLPhiQuality::rootFileName
private

Definition at line 63 of file DTSegment2DSLPhiQuality.h.

edm::InputTag DTSegment2DSLPhiQuality::segment4DLabel
private

Definition at line 66 of file DTSegment2DSLPhiQuality.h.

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

Definition at line 68 of file DTSegment2DSLPhiQuality.h.

double DTSegment2DSLPhiQuality::sigmaResAngle
private

Definition at line 72 of file DTSegment2DSLPhiQuality.h.

double DTSegment2DSLPhiQuality::sigmaResPos
private

Definition at line 70 of file DTSegment2DSLPhiQuality.h.

edm::InputTag DTSegment2DSLPhiQuality::simHitLabel
private

Definition at line 65 of file DTSegment2DSLPhiQuality.h.

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

Definition at line 67 of file DTSegment2DSLPhiQuality.h.