CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | Static Private Attributes
AlignmentStats Class Reference
Inheritance diagram for AlignmentStats:
edm::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 AlignmentStats (const edm::ParameterSet &iConfig)
 
void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
void beginJob () override
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void endJob () override
 
void endRun (edm::Run const &iRun, edm::EventSetup const &iSetup) override
 
 ~AlignmentStats () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Types

typedef std::map< uint32_t, uint32_t > DetHitMap
 

Private Attributes

float Chi2n [MAXTRKS_]
 
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordesTokenTkGeoER_
 
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcdesTokenTTopoER_
 
float Eta [MAXTRKS_]
 
int event_
 
std::vector< aliStats::GeoInfogeomInfoList_
 
DetHitMap hitmap_
 
TFile * hitsfile_
 
TTree * hitstree_
 
const std::string hitsTreeName_
 
unsigned int id_
 
bool is2D_
 
bool isStereo_
 
const bool keepHitPopulation_
 
const bool keepTrackStats_
 
unsigned int layer_
 
const edm::EDGetTokenT< AliClusterValueMapmapToken_
 
int Nhits [MAXTRKS_][7]
 
unsigned int nhits_
 
unsigned int noverlaps_
 
unsigned int ntracks
 
TTree * outtree_
 
const edm::InputTag overlapAM_
 
DetHitMap overlapmap_
 
float P [MAXTRKS_]
 
float Phi [MAXTRKS_]
 
float posEta_
 
float posPhi_
 
float posR_
 
float posX_
 
float posY_
 
float posZ_
 
const uint32_t prescale_
 
float Pt [MAXTRKS_]
 
int run_
 
const edm::InputTag src_
 
const std::string statsTreeName_
 
int subdet_
 
uint32_t tmpPresc_
 
std::unique_ptr< TrackerTopologytrackerTopology_
 
const edm::EDGetTokenT< reco::TrackCollectiontrackToken_
 
TFile * treefile_
 

Static Private Attributes

static const int MAXTRKS_ = 200
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 69 of file AlignmentStats.cc.

Member Typedef Documentation

◆ DetHitMap

typedef std::map<uint32_t, uint32_t> AlignmentStats::DetHitMap
private

Definition at line 122 of file AlignmentStats.cc.

Constructor & Destructor Documentation

◆ AlignmentStats()

AlignmentStats::AlignmentStats ( const edm::ParameterSet iConfig)

Definition at line 131 of file AlignmentStats.cc.

References outtree_.

132  : esTokenTTopoER_(esConsumes<edm::Transition::EndRun>()),
133  esTokenTkGeoER_(esConsumes<edm::Transition::EndRun>()),
134  src_(iConfig.getParameter<edm::InputTag>("src")),
135  overlapAM_(iConfig.getParameter<edm::InputTag>("OverlapAssoMap")),
136  keepTrackStats_(iConfig.getParameter<bool>("keepTrackStats")),
137  keepHitPopulation_(iConfig.getParameter<bool>("keepHitStats")),
138  statsTreeName_(iConfig.getParameter<string>("TrkStatsFileName")),
139  hitsTreeName_(iConfig.getParameter<string>("HitStatsFileName")),
140  prescale_(iConfig.getParameter<uint32_t>("TrkStatsPrescale")),
141  trackToken_(consumes<reco::TrackCollection>(src_)),
142  mapToken_(consumes<AliClusterValueMap>(overlapAM_)) {
143  //sanity checks
144 
145  //init
146  outtree_ = nullptr;
147 
148 } //end constructor
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const std::string hitsTreeName_
const bool keepHitPopulation_
const uint32_t prescale_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > esTokenTkGeoER_
const edm::EDGetTokenT< reco::TrackCollection > trackToken_
const edm::InputTag overlapAM_
const edm::InputTag src_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > esTokenTTopoER_
const std::string statsTreeName_
const edm::EDGetTokenT< AliClusterValueMap > mapToken_
const bool keepTrackStats_

◆ ~AlignmentStats()

AlignmentStats::~AlignmentStats ( )
overridedefault

Member Function Documentation

◆ analyze()

void AlignmentStats::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 278 of file AlignmentStats.cc.

References Chi2n, className(), SiStripRecHit1D::cluster(), SiStripRecHit2D::cluster(), Eta, event_, Exception, hitmap_, iEvent, AlignmentClusterFlag::isOverlap(), dqmiolumiharvest::j, dqmdumpme::k, mapToken_, MAXTRKS_, Nhits, ntracks, outtree_, overlapmap_, Phi, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, pixelClusterTagInfos_cfi::pixelhit, prescale_, Pt, nano_mu_digi_cff::rawId, run_, DetId::subdetId(), SiStripDetId::TEC, SiStripDetId::TIB, SiStripDetId::TID, tmpPresc_, SiStripDetId::TOB, gather_cfg::Tracks, and trackToken_.

278  {
279  //take trajectories and tracks to loop on
280  // edm::Handle<TrajTrackAssociationCollection> TrackAssoMap;
282 
283  //take overlap HitAssomap
284  const edm::Handle<AliClusterValueMap> &hMap = iEvent.getHandle(mapToken_);
285  const AliClusterValueMap &OverlapMap = *hMap;
286 
287  // Initialise
288  run_ = 1;
289  event_ = 1;
290  ntracks = 0;
291  run_ = iEvent.id().run();
292  event_ = iEvent.id().event();
293  ntracks = Tracks->size();
294  if (ntracks > 1)
295  edm::LogVerbatim("AlignmenStats") << "~~~~~~~~~~~~\n For this event processing " << ntracks << " tracks";
296 
297  unsigned int trk_cnt = 0;
298 
299  for (int j = 0; j < MAXTRKS_; j++) {
300  Eta[j] = -9999.0;
301  Phi[j] = -8888.0;
302  P[j] = -7777.0;
303  Pt[j] = -6666.0;
304  Chi2n[j] = -2222.0;
305  for (int k = 0; k < 7; k++) {
306  Nhits[j][k] = 0;
307  }
308  }
309 
310  // int npxbhits=0;
311 
312  //loop on tracks
313  for (const auto &ittrk : *Tracks) {
314  Eta[trk_cnt] = ittrk.eta();
315  Phi[trk_cnt] = ittrk.phi();
316  Chi2n[trk_cnt] = ittrk.normalizedChi2();
317  P[trk_cnt] = ittrk.p();
318  Pt[trk_cnt] = ittrk.pt();
319  Nhits[trk_cnt][0] = ittrk.numberOfValidHits();
320 
321  if (ntracks > 1)
322  edm::LogVerbatim("AlignmenStats") << "Track #" << trk_cnt + 1 << " params: Eta=" << Eta[trk_cnt]
323  << " Phi=" << Phi[trk_cnt] << " P=" << P[trk_cnt]
324  << " Nhits=" << Nhits[trk_cnt][0];
325 
326  //loop on tracking rechits
327  //edm::LogVerbatim("AlignmenStats") << " loop on hits of track #" << (itt - tracks->begin());
328  for (auto const &hit : ittrk.recHits()) {
329  if (!hit->isValid())
330  continue;
331  DetId detid = hit->geographicalId();
332  int subDet = detid.subdetId();
333  uint32_t rawId = hit->geographicalId().rawId();
334 
335  // if(subDet==1)npxbhits++;
336 
337  //look if you find this detid in the map
338  DetHitMap::iterator mapiter;
339  mapiter = hitmap_.find(rawId);
340  if (mapiter != hitmap_.end()) { //present, increase its value by one
341  // hitmap_[rawId]=hitmap_[rawId]+1;
342  ++(hitmap_[rawId]);
343  } else { //not present, let's add this key to the map with value=1
344  hitmap_.insert(pair<uint32_t, uint32_t>(rawId, 1));
345  }
346 
347  AlignmentClusterFlag inval;
348 
349  bool hitInPixel = (subDet == PixelSubdetector::PixelBarrel) || (subDet == PixelSubdetector::PixelEndcap);
350  bool hitInStrip = (subDet == SiStripDetId::TIB) || (subDet == SiStripDetId::TID) ||
351  (subDet == SiStripDetId::TOB) || (subDet == SiStripDetId::TEC);
352 
353  if (!(hitInPixel || hitInStrip)) {
354  //skip only this hit, don't stop everything throwing an exception
355  edm::LogError("AlignmentStats") << "Hit not belonging neither to pixels nor to strips! Skipping it. SubDet= "
356  << subDet;
357  continue;
358  }
359 
360  //check also if the hit is an overlap. If yes fill a dedicated hitmap
361  if (hitInStrip) {
362  const std::type_info &type = typeid(*hit);
363 
364  if (type == typeid(SiStripRecHit1D)) {
365  //Notice the difference respect to when one loops on Trajectories: the recHit is a TrackingRecHit and not a TransientTrackingRecHit
366  const SiStripRecHit1D *striphit = dynamic_cast<const SiStripRecHit1D *>(hit);
367  if (striphit != nullptr) {
368  SiStripRecHit1D::ClusterRef stripclust(striphit->cluster());
369  inval = OverlapMap[stripclust];
370  } else {
371  // edm::LogError("AlignmentStats")<<"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit1D failed! TypeId of the RecHit: "<<className(*hit);
372  throw cms::Exception("NullPointerError")
373  << "ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit1D failed! TypeId of the RecHit: "
374  << className(*hit);
375  }
376  } //end if sistriprechit1D
377  if (type == typeid(SiStripRecHit2D)) {
378  const SiStripRecHit2D *striphit = dynamic_cast<const SiStripRecHit2D *>(hit);
379  if (striphit != nullptr) {
380  SiStripRecHit2D::ClusterRef stripclust(striphit->cluster());
381  inval = OverlapMap[stripclust];
382  //edm::LogVerbatim("AlignmenStats")<<"Taken the Strip Cluster with ProdId "<<stripclust.id() <<"; the Value in the map is "<<inval<<" (DetId is "<<hit->geographicalId().rawId()<<")";
383  } else {
384  throw cms::Exception("NullPointerError")
385  << "ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit2D failed! TypeId of the RecHit: "
386  << className(*hit);
387  // edm::LogError("AlignmentStats")<<"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit2D failed! TypeId of the RecHit: "<<className(*hit);
388  }
389  } //end if sistriprechit2D
390 
391  } //end if hit in Strips
392  else {
393  const SiPixelRecHit *pixelhit = dynamic_cast<const SiPixelRecHit *>(hit);
394  if (pixelhit != nullptr) {
395  SiPixelClusterRefNew pixclust(pixelhit->cluster());
396  inval = OverlapMap[pixclust];
397  //edm::LogVerbatim("AlignmenStats")<<"Taken the Pixel Cluster with ProdId "<<pixclust.id() <<"; the Value in the map is "<<inval<<" (DetId is "<<hit->geographicalId().rawId()<<")";
398  } else {
399  edm::LogError("AlignmentStats")
400  << "ERROR in <AlignmentStats::analyze>: Dynamic cast of Pixel RecHit failed! TypeId of the RecHit: "
401  << className(*hit);
402  }
403  } //end else hit is in Pixel
404 
405  bool isOverlapHit(inval.isOverlap());
406 
407  if (isOverlapHit) {
408  edm::LogVerbatim("AlignmenStats") << "This hit is an overlap !";
409  DetHitMap::iterator overlapiter;
410  overlapiter = overlapmap_.find(rawId);
411 
412  if (overlapiter !=
413  overlapmap_.end()) { //the det already collected at least an overlap, increase its value by one
415  } else { //first overlap on det unit, let's add it to the map
416  overlapmap_.insert(pair<uint32_t, uint32_t>(rawId, 1));
417  }
418  } //end if the hit is an overlap
419 
420  int subdethit = static_cast<int>(hit->geographicalId().subdetId());
421  if (ntracks > 1)
422  edm::LogVerbatim("AlignmenStats") << "Hit in SubDet=" << subdethit;
423  Nhits[trk_cnt][subdethit] = Nhits[trk_cnt][subdethit] + 1;
424  } //end loop on trackingrechits
425  trk_cnt++;
426 
427  } //end loop on tracks
428 
429  //edm::LogVerbatim("AlignmenStats")<<"Total number of pixel hits is " << npxbhits;
430 
431  tmpPresc_--;
432  if (tmpPresc_ < 1) {
433  outtree_->Fill();
435  }
436  if (trk_cnt != ntracks)
437  edm::LogError("AlignmentStats") << "\nERROR! trk_cnt=" << trk_cnt << " ntracks=" << ntracks;
438 
439  return;
440 }
float Eta[MAXTRKS_]
Log< level::Info, true > LogVerbatim
static constexpr auto TID
Definition: SiStripDetId.h:38
DetHitMap overlapmap_
float Chi2n[MAXTRKS_]
const uint32_t prescale_
Log< level::Error, false > LogError
ClusterRef cluster() const
const edm::EDGetTokenT< reco::TrackCollection > trackToken_
int iEvent
Definition: GenABIO.cc:224
float Phi[MAXTRKS_]
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
static constexpr auto TOB
Definition: SiStripDetId.h:39
Definition: DetId.h:17
const edm::EDGetTokenT< AliClusterValueMap > mapToken_
static const int MAXTRKS_
std::pair< OmniClusterRef, TrackingParticleRef > P
static constexpr auto TIB
Definition: SiStripDetId.h:37
unsigned int ntracks
int Nhits[MAXTRKS_][7]
float Pt[MAXTRKS_]
ClusterRef cluster() const
static constexpr auto TEC
Definition: SiStripDetId.h:40
std::string className(const T &t)
Definition: ClassName.h:31
Our base class.
Definition: SiPixelRecHit.h:23

◆ beginJob()

void AlignmentStats::beginJob ( )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 162 of file AlignmentStats.cc.

References Chi2n, Eta, event_, hitsfile_, hitstree_, hitsTreeName_, id_, is2D_, isStereo_, layer_, Nhits, nhits_, noverlaps_, ntracks, outtree_, Phi, posEta_, posPhi_, posR_, posX_, posY_, posZ_, prescale_, Pt, run_, statsTreeName_, subdet_, tmpPresc_, and treefile_.

162  { // const edm::EventSetup &iSetup
163 
164  //book track stats tree
165  treefile_ = new TFile(statsTreeName_.c_str(), "RECREATE");
166  treefile_->cd();
167  outtree_ = new TTree("AlignmentTrackStats", "Statistics of Tracks used for Alignment");
168  // int nHitsinPXB[MAXTRKS_], nHitsinPXE[MAXTRKS_], nHitsinTEC[MAXTRKS_], nHitsinTIB[MAXTRKS_],nHitsinTOB[MAXTRKS_],nHitsinTID[MAXTRKS_];
169 
170  outtree_->Branch("Ntracks", &ntracks, "Ntracks/i");
171  outtree_->Branch("Run_", &run_, "Run_Nr/I");
172  outtree_->Branch("Event", &event_, "EventNr/I");
173  outtree_->Branch("Eta", &Eta, "Eta[Ntracks]/F");
174  outtree_->Branch("Phi", &Phi, "Phi[Ntracks]/F");
175  outtree_->Branch("P", &P, "P[Ntracks]/F");
176  outtree_->Branch("Pt", &Pt, "Pt[Ntracks]/F");
177  outtree_->Branch("Chi2n", &Chi2n, "Chi2n[Ntracks]/F");
178  outtree_->Branch("Nhits", &Nhits, "Nhits[Ntracks][7]/I");
179  /*
180  outtree_->Branch("NhitsPXB" , ,);
181  outtree_->Branch("NhitsPXE" , ,);
182  outtree_->Branch("NhitsTIB" , ,);
183  outtree_->Branch("NhitsTID" , ,);
184  outtree_->Branch("NhitsTOB" , ,);
185  outtree_->Branch("NhitsTOB" , ,);
186  */
187 
189 
190  // create tree with hit maps (hitstree)
191  // book hits stats tree
192  hitsfile_ = new TFile(hitsTreeName_.c_str(), "RECREATE");
193  hitsfile_->cd();
194  hitstree_ = new TTree("AlignmentHitMap", "Maps of Hits used for Alignment");
195  hitstree_->Branch("DetId", &id_, "DetId/i");
196  hitstree_->Branch("Nhits", &nhits_, "Nhits/i");
197  hitstree_->Branch("Noverlaps", &noverlaps_, "Noverlaps/i");
198  hitstree_->Branch("SubDet", &subdet_, "SubDet/I");
199  hitstree_->Branch("Layer", &layer_, "Layer/i");
200  hitstree_->Branch("is2D", &is2D_, "is2D/B");
201  hitstree_->Branch("isStereo", &isStereo_, "isStereo/B");
202  hitstree_->Branch("posX", &posX_, "posX/F");
203  hitstree_->Branch("posY", &posY_, "posY/F");
204  hitstree_->Branch("posZ", &posZ_, "posZ/F");
205  hitstree_->Branch("posR", &posR_, "posR/F");
206  hitstree_->Branch("posEta", &posEta_, "posEta/F");
207  hitstree_->Branch("posPhi", &posPhi_, "posPhi/F");
208 } //end beginJob
float Eta[MAXTRKS_]
const std::string hitsTreeName_
unsigned int layer_
float Chi2n[MAXTRKS_]
const uint32_t prescale_
unsigned int id_
unsigned int nhits_
float Phi[MAXTRKS_]
const std::string statsTreeName_
std::pair< OmniClusterRef, TrackingParticleRef > P
unsigned int ntracks
int Nhits[MAXTRKS_][7]
float Pt[MAXTRKS_]
unsigned int noverlaps_

◆ beginRun()

void AlignmentStats::beginRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverride

Definition at line 75 of file AlignmentStats.cc.

75 {};

◆ endJob()

void AlignmentStats::endJob ( )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 442 of file AlignmentStats.cc.

References geomInfoList_, hitmap_, hitsfile_, hitstree_, id_, is2D_, isStereo_, layer_, nhits_, noverlaps_, outtree_, overlapmap_, posEta_, posPhi_, posR_, posX_, posY_, posZ_, subdet_, and treefile_.

Referenced by o2olib.O2ORunMgr::executeJob().

442  {
443  treefile_->cd();
444  edm::LogInfo("AlignmentStats") << "Writing out the TrackStatistics in " << gDirectory->GetPath();
445  outtree_->Write();
446  delete outtree_;
447 
448  int ndetunits = geomInfoList_.size();
449  edm::LogInfo("AlignmentStats") << __PRETTY_FUNCTION__ << "Number of DetUnits in the AlignableTracker: " << ndetunits
450  << std::endl;
451 
452  hitsfile_->cd();
453  // save the information on hits and overlaps
454  for (const auto &detUnitInfo : geomInfoList_) {
455  detUnitInfo.printAll();
456 
457  // copy the values from the struct to the TTree
458  id_ = detUnitInfo.id_;
459  posX_ = detUnitInfo.posX_;
460  posY_ = detUnitInfo.posY_;
461  posZ_ = detUnitInfo.posZ_;
462  posEta_ = detUnitInfo.posEta_;
463  posPhi_ = detUnitInfo.posPhi_;
464  posR_ = detUnitInfo.posR_;
465  subdet_ = detUnitInfo.subdet_;
466  layer_ = detUnitInfo.layer_;
467  is2D_ = detUnitInfo.is2D_;
468  isStereo_ = detUnitInfo.isStereo_;
469 
470  if (hitmap_.find(id_) != hitmap_.end()) {
471  nhits_ = hitmap_[id_];
472  }
473  //if not, save nhits=0
474  else {
475  nhits_ = 0;
476  hitmap_.insert(pair<uint32_t, uint32_t>(id_, 0));
477  }
478 
479  if (overlapmap_.find(id_) != overlapmap_.end()) {
481  }
482  //if not, save nhits=0
483  else {
484  noverlaps_ = 0;
485  overlapmap_.insert(pair<uint32_t, uint32_t>(id_, 0));
486  }
487  //write in the hitstree
488  hitstree_->Fill();
489  } //end loop over detunits
490 
491  //save hitstree
492  hitstree_->Write();
493  delete hitstree_;
494  hitmap_.clear();
495  overlapmap_.clear();
496  delete hitsfile_;
497 }
unsigned int layer_
DetHitMap overlapmap_
std::vector< aliStats::GeoInfo > geomInfoList_
unsigned int id_
unsigned int nhits_
Log< level::Info, false > LogInfo
unsigned int noverlaps_

◆ endRun()

void AlignmentStats::endRun ( edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
override

Definition at line 211 of file AlignmentStats.cc.

References esTokenTkGeoER_, esTokenTTopoER_, PV3DBase< T, PVType, FrameType >::eta(), geomInfoList_, edm::EventSetup::getData(), hitsfile_, aliStats::GeoInfo::id_, aliStats::GeoInfo::is2D_, aliStats::GeoInfo::isStereo_, aliStats::GeoInfo::layer_, LogDebug, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, aliStats::GeoInfo::posEta_, aliStats::GeoInfo::posPhi_, aliStats::GeoInfo::posR_, aliStats::GeoInfo::posX_, aliStats::GeoInfo::posY_, aliStats::GeoInfo::posZ_, DetId::rawId(), aliStats::GeoInfo::subdet_, DetId::subdetId(), SiStripDetId::TEC, SiStripDetId::TIB, SiStripDetId::TID, SiStripDetId::TOB, and trackerTopology_.

211  {
212  if (!trackerTopology_) {
213  trackerTopology_ = std::make_unique<TrackerTopology>(iSetup.getData(esTokenTTopoER_));
214  const TrackerGeometry *trackerGeometry_ = &iSetup.getData(esTokenTkGeoER_);
215  auto theAliTracker = std::make_unique<AlignableTracker>(trackerGeometry_, trackerTopology_.get());
216 
217  hitsfile_->cd();
218  for (const auto &detUnit : theAliTracker->deepComponents()) {
219  aliStats::GeoInfo detUnitInfo;
220  detUnitInfo.id_ = static_cast<uint32_t>(detUnit->id());
221  DetId detid(detUnitInfo.id_);
222  detUnitInfo.subdet_ = detid.subdetId();
223 
224  //take other geometrical infos from the det
225  detUnitInfo.posX_ = detUnit->globalPosition().x();
226  detUnitInfo.posY_ = detUnit->globalPosition().y();
227  detUnitInfo.posZ_ = detUnit->globalPosition().z();
228 
229  align::GlobalVector vec(detUnitInfo.posX_, detUnitInfo.posY_, detUnitInfo.posZ_);
230  detUnitInfo.posR_ = vec.perp();
231  detUnitInfo.posPhi_ = vec.phi();
232  detUnitInfo.posEta_ = vec.eta();
233  // detUnitInfo.posPhi_ = atan2(posY_,posX_);
234 
235  //get layers, petals, etc...
236  if (detUnitInfo.subdet_ == PixelSubdetector::PixelBarrel) { //PXB
237  detUnitInfo.layer_ = trackerTopology_->pxbLayer(detUnitInfo.id_);
238  detUnitInfo.is2D_ = true;
239  detUnitInfo.isStereo_ = false;
240  } else if (detUnitInfo.subdet_ == PixelSubdetector::PixelEndcap) {
241  detUnitInfo.layer_ = trackerTopology_->pxfDisk(detUnitInfo.id_);
242  detUnitInfo.is2D_ = true;
243  detUnitInfo.isStereo_ = false;
244  } else if (detUnitInfo.subdet_ == SiStripDetId::TIB) {
245  detUnitInfo.layer_ = trackerTopology_->tibLayer(detUnitInfo.id_);
246  detUnitInfo.is2D_ = trackerTopology_->tibIsDoubleSide(detUnitInfo.id_);
247  detUnitInfo.isStereo_ = trackerTopology_->tibIsStereo(detUnitInfo.id_);
248  } else if (detUnitInfo.subdet_ == SiStripDetId::TID) {
249  detUnitInfo.layer_ = trackerTopology_->tidWheel(detUnitInfo.id_);
250  detUnitInfo.is2D_ = trackerTopology_->tidIsDoubleSide(detUnitInfo.id_);
251  detUnitInfo.isStereo_ = trackerTopology_->tidIsStereo(detUnitInfo.id_);
252  } else if (detUnitInfo.subdet_ == SiStripDetId::TOB) {
253  detUnitInfo.layer_ = trackerTopology_->tobLayer(detUnitInfo.id_);
254  detUnitInfo.is2D_ = trackerTopology_->tobIsDoubleSide(detUnitInfo.id_);
255  detUnitInfo.isStereo_ = trackerTopology_->tobIsStereo(detUnitInfo.id_);
256  } else if (detUnitInfo.subdet_ == SiStripDetId::TEC) {
257  detUnitInfo.layer_ = trackerTopology_->tecWheel(detUnitInfo.id_);
258  detUnitInfo.is2D_ = trackerTopology_->tecIsDoubleSide(detUnitInfo.id_);
259  detUnitInfo.isStereo_ = trackerTopology_->tecIsStereo(detUnitInfo.id_);
260  } else {
261  edm::LogError("AlignmentStats")
262  << "Detector not belonging neither to pixels nor to strips! Skipping it. SubDet= " << detUnitInfo.subdet_;
263  }
264 
265  LogDebug("AlignmentStats") << "id " << detUnitInfo.id_ << " detid.rawId()" << detid.rawId() << " subdet "
266  << detUnitInfo.subdet_;
267 
268  // push back in the list
269  geomInfoList_.push_back(detUnitInfo);
270  } // end loop over detunits
271 
272  int ndetunits = geomInfoList_.size();
273  edm::LogInfo("AlignmentStats") << __PRETTY_FUNCTION__
274  << " Number of DetUnits in the AlignableTracker: " << ndetunits;
275  }
276 }
static constexpr auto TID
Definition: SiStripDetId.h:38
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > esTokenTkGeoER_
unsigned int layer_
std::vector< aliStats::GeoInfo > geomInfoList_
Log< level::Error, false > LogError
unsigned int id_
static constexpr auto TOB
Definition: SiStripDetId.h:39
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > esTokenTTopoER_
Log< level::Info, false > LogInfo
Definition: DetId.h:17
static constexpr auto TIB
Definition: SiStripDetId.h:37
std::unique_ptr< TrackerTopology > trackerTopology_
static constexpr auto TEC
Definition: SiStripDetId.h:40
#define LogDebug(id)

◆ fillDescriptions()

void AlignmentStats::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 150 of file AlignmentStats.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

150  {
152  desc.add<edm::InputTag>("src", edm::InputTag("generalTracks"));
153  desc.add<edm::InputTag>("OverlapAssoMap", edm::InputTag("OverlapAssoMap"));
154  desc.add<bool>("keepTrackStats", false);
155  desc.add<bool>("keepHitStats", false);
156  desc.add<std::string>("TrkStatsFileName", "tracks_statistics.root");
157  desc.add<std::string>("HitStatsFileName", "HitMaps.root");
158  desc.add<unsigned int>("TrkStatsPrescale", 1);
159  descriptions.add("AlignmentStats", desc);
160 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ Chi2n

float AlignmentStats::Chi2n[MAXTRKS_]
private

Definition at line 109 of file AlignmentStats.cc.

Referenced by analyze(), and beginJob().

◆ esTokenTkGeoER_

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> AlignmentStats::esTokenTkGeoER_
private

Definition at line 86 of file AlignmentStats.cc.

Referenced by endRun().

◆ esTokenTTopoER_

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> AlignmentStats::esTokenTTopoER_
private

Definition at line 85 of file AlignmentStats.cc.

Referenced by endRun().

◆ Eta

float AlignmentStats::Eta[MAXTRKS_]
private

Definition at line 109 of file AlignmentStats.cc.

Referenced by analyze(), and beginJob().

◆ event_

int AlignmentStats::event_
private

Definition at line 107 of file AlignmentStats.cc.

Referenced by analyze(), and beginJob().

◆ geomInfoList_

std::vector<aliStats::GeoInfo> AlignmentStats::geomInfoList_
private

Definition at line 82 of file AlignmentStats.cc.

Referenced by endJob(), and endRun().

◆ hitmap_

DetHitMap AlignmentStats::hitmap_
private

Definition at line 123 of file AlignmentStats.cc.

Referenced by analyze(), and endJob().

◆ hitsfile_

TFile* AlignmentStats::hitsfile_
private

Definition at line 113 of file AlignmentStats.cc.

Referenced by beginJob(), endJob(), and endRun().

◆ hitstree_

TTree* AlignmentStats::hitstree_
private

Definition at line 114 of file AlignmentStats.cc.

Referenced by beginJob(), and endJob().

◆ hitsTreeName_

const std::string AlignmentStats::hitsTreeName_
private

Definition at line 94 of file AlignmentStats.cc.

Referenced by beginJob().

◆ id_

unsigned int AlignmentStats::id_
private

Definition at line 115 of file AlignmentStats.cc.

Referenced by beginJob(), and endJob().

◆ is2D_

bool AlignmentStats::is2D_
private

Definition at line 120 of file AlignmentStats.cc.

Referenced by beginJob(), and endJob().

◆ isStereo_

bool AlignmentStats::isStereo_
private

Definition at line 120 of file AlignmentStats.cc.

Referenced by beginJob(), and endJob().

◆ keepHitPopulation_

const bool AlignmentStats::keepHitPopulation_
private

Definition at line 92 of file AlignmentStats.cc.

◆ keepTrackStats_

const bool AlignmentStats::keepTrackStats_
private

Definition at line 91 of file AlignmentStats.cc.

◆ layer_

unsigned int AlignmentStats::layer_
private

Definition at line 119 of file AlignmentStats.cc.

Referenced by beginJob(), and endJob().

◆ mapToken_

const edm::EDGetTokenT<AliClusterValueMap> AlignmentStats::mapToken_
private

Definition at line 98 of file AlignmentStats.cc.

Referenced by analyze().

◆ MAXTRKS_

const int AlignmentStats::MAXTRKS_ = 200
staticprivate

Definition at line 106 of file AlignmentStats.cc.

Referenced by analyze().

◆ Nhits

int AlignmentStats::Nhits[MAXTRKS_][7]
private

Definition at line 110 of file AlignmentStats.cc.

Referenced by analyze(), and beginJob().

◆ nhits_

unsigned int AlignmentStats::nhits_
private

Definition at line 115 of file AlignmentStats.cc.

Referenced by beginJob(), and endJob().

◆ noverlaps_

unsigned int AlignmentStats::noverlaps_
private

Definition at line 115 of file AlignmentStats.cc.

Referenced by beginJob(), and endJob().

◆ ntracks

unsigned int AlignmentStats::ntracks
private

Definition at line 108 of file AlignmentStats.cc.

Referenced by analyze(), and beginJob().

◆ outtree_

TTree* AlignmentStats::outtree_
private

Definition at line 105 of file AlignmentStats.cc.

Referenced by AlignmentStats(), analyze(), beginJob(), and endJob().

◆ overlapAM_

const edm::InputTag AlignmentStats::overlapAM_
private

Definition at line 90 of file AlignmentStats.cc.

◆ overlapmap_

DetHitMap AlignmentStats::overlapmap_
private

Definition at line 124 of file AlignmentStats.cc.

Referenced by analyze(), and endJob().

◆ P

float AlignmentStats::P[MAXTRKS_]
private

Definition at line 109 of file AlignmentStats.cc.

◆ Phi

float AlignmentStats::Phi[MAXTRKS_]
private

Definition at line 109 of file AlignmentStats.cc.

Referenced by analyze(), and beginJob().

◆ posEta_

float AlignmentStats::posEta_
private

Definition at line 117 of file AlignmentStats.cc.

Referenced by beginJob(), and endJob().

◆ posPhi_

float AlignmentStats::posPhi_
private

Definition at line 117 of file AlignmentStats.cc.

Referenced by beginJob(), and endJob().

◆ posR_

float AlignmentStats::posR_
private

Definition at line 117 of file AlignmentStats.cc.

Referenced by beginJob(), and endJob().

◆ posX_

float AlignmentStats::posX_
private

Definition at line 116 of file AlignmentStats.cc.

Referenced by beginJob(), and endJob().

◆ posY_

float AlignmentStats::posY_
private

Definition at line 116 of file AlignmentStats.cc.

Referenced by beginJob(), and endJob().

◆ posZ_

float AlignmentStats::posZ_
private

Definition at line 116 of file AlignmentStats.cc.

Referenced by beginJob(), and endJob().

◆ prescale_

const uint32_t AlignmentStats::prescale_
private

Definition at line 95 of file AlignmentStats.cc.

Referenced by analyze(), and beginJob().

◆ Pt

float AlignmentStats::Pt[MAXTRKS_]
private

Definition at line 109 of file AlignmentStats.cc.

Referenced by analyze(), and beginJob().

◆ run_

int AlignmentStats::run_
private

Definition at line 107 of file AlignmentStats.cc.

Referenced by analyze(), and beginJob().

◆ src_

const edm::InputTag AlignmentStats::src_
private

Definition at line 89 of file AlignmentStats.cc.

◆ statsTreeName_

const std::string AlignmentStats::statsTreeName_
private

Definition at line 93 of file AlignmentStats.cc.

Referenced by beginJob().

◆ subdet_

int AlignmentStats::subdet_
private

Definition at line 118 of file AlignmentStats.cc.

Referenced by beginJob(), and endJob().

◆ tmpPresc_

uint32_t AlignmentStats::tmpPresc_
private

Definition at line 101 of file AlignmentStats.cc.

Referenced by analyze(), and beginJob().

◆ trackerTopology_

std::unique_ptr<TrackerTopology> AlignmentStats::trackerTopology_
private

Definition at line 126 of file AlignmentStats.cc.

Referenced by endRun().

◆ trackToken_

const edm::EDGetTokenT<reco::TrackCollection> AlignmentStats::trackToken_
private

Definition at line 97 of file AlignmentStats.cc.

Referenced by analyze().

◆ treefile_

TFile* AlignmentStats::treefile_
private

Definition at line 104 of file AlignmentStats.cc.

Referenced by beginJob(), and endJob().