CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Attributes | Static Private Attributes
AlignmentStats Class Reference

#include <AlignmentStats.h>

Inheritance diagram for AlignmentStats:
edm::EDAnalyzer 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 endJob () override
 
 ~AlignmentStats () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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
 
ESProxyIndex const * esGetTokenIndices (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::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)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

typedef std::map< uint32_t, uint32_t > DetHitMap
 

Private Attributes

float Chi2n [MAXTRKS_]
 
float Eta [MAXTRKS_]
 
int event_
 
DetHitMap hitmap_
 
std::string hitsTreeName_
 
bool keepHitPopulation_
 
bool keepTrackStats_
 
int Nhits [MAXTRKS_][7]
 
unsigned int ntracks
 
TTree * outtree_
 
edm::InputTag overlapAM_
 
DetHitMap overlapmap_
 
float P [MAXTRKS_]
 
float Phi [MAXTRKS_]
 
uint32_t prescale_
 
float Pt [MAXTRKS_]
 
int run_
 
edm::InputTag src_
 
std::string statsTreeName_
 
uint32_t tmpPresc_
 
const TrackerGeometrytrackerGeometry_
 
const TrackerTopologytrackerTopology_
 
TFile * treefile_
 

Static Private Attributes

static const int MAXTRKS_ = 200
 

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 &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

Definition at line 28 of file AlignmentStats.h.

Member Typedef Documentation

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

Definition at line 58 of file AlignmentStats.h.

Constructor & Destructor Documentation

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

Definition at line 28 of file AlignmentStats.cc.

References outtree_.

29  : src_(iConfig.getParameter<edm::InputTag>("src")),
30  overlapAM_(iConfig.getParameter<edm::InputTag>("OverlapAssoMap")),
31  keepTrackStats_(iConfig.getParameter<bool>("keepTrackStats")),
32  keepHitPopulation_(iConfig.getParameter<bool>("keepHitStats")),
33  statsTreeName_(iConfig.getParameter<string>("TrkStatsFileName")),
34  hitsTreeName_(iConfig.getParameter<string>("HitStatsFileName")),
35  prescale_(iConfig.getParameter<uint32_t>("TrkStatsPrescale")) {
36  //sanity checks
37 
38  //init
39  outtree_ = nullptr;
40 
41 } //end constructor
T getParameter(std::string const &) const
uint32_t prescale_
edm::InputTag src_
std::string statsTreeName_
std::string hitsTreeName_
edm::InputTag overlapAM_
AlignmentStats::~AlignmentStats ( )
override

Definition at line 43 of file AlignmentStats.cc.

43  {
44  //
45 }

Member Function Documentation

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

Definition at line 80 of file AlignmentStats.cc.

References Chi2n, className(), SiStripRecHit1D::cluster(), SiStripRecHit2D::cluster(), SiPixelRecHit::cluster(), Eta, edm::EventID::event(), event_, Exception, edm::EventSetup::get(), edm::Event::getByLabel(), hitmap_, edm::EventBase::id(), AlignmentClusterFlag::isOverlap(), dqmiolumiharvest::j, dqmdumpme::k, MAXTRKS_, Nhits, ntracks, outtree_, overlapAM_, overlapmap_, Phi, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, pixelClusterTagInfos_cfi::pixelhit, prescale_, edm::ESHandle< T >::product(), Pt, edm::EventID::run(), run_, src_, DetId::subdetId(), SiStripDetId::TEC, SiStripDetId::TIB, SiStripDetId::TID, tmpPresc_, SiStripDetId::TOB, trackerGeometry_, trackerTopology_, and gather_cfg::Tracks.

80  {
81  //load list of detunits needed then in endJob
82 
83  edm::ESHandle<TrackerGeometry> tmpTkGeometry;
84  iSetup.get<TrackerDigiGeometryRecord>().get(tmpTkGeometry);
85  trackerGeometry_ = &(*tmpTkGeometry);
86 
88  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
89  trackerTopology_ = tTopoHandle.product();
90 
91  //take trajectories and tracks to loop on
92  // edm::Handle<TrajTrackAssociationCollection> TrackAssoMap;
94  iEvent.getByLabel(src_, Tracks);
95 
96  //take overlap HitAssomap
98  iEvent.getByLabel(overlapAM_, hMap);
99  const AliClusterValueMap &OverlapMap = *hMap;
100 
101  // Initialise
102  run_ = 1;
103  event_ = 1;
104  ntracks = 0;
105  run_ = iEvent.id().run();
106  event_ = iEvent.id().event();
107  ntracks = Tracks->size();
108  // if(ntracks>1) std::cout<<"~~~~~~~~~~~~\n For this event processing "<<ntracks<<" tracks"<<std::endl;
109 
110  unsigned int trk_cnt = 0;
111 
112  for (int j = 0; j < MAXTRKS_; j++) {
113  Eta[j] = -9999.0;
114  Phi[j] = -8888.0;
115  P[j] = -7777.0;
116  Pt[j] = -6666.0;
117  Chi2n[j] = -2222.0;
118  for (int k = 0; k < 7; k++) {
119  Nhits[j][k] = 0;
120  }
121  }
122 
123  // int npxbhits=0;
124 
125  //loop on tracks
126  for (std::vector<reco::Track>::const_iterator ittrk = Tracks->begin(), edtrk = Tracks->end(); ittrk != edtrk;
127  ++ittrk) {
128  Eta[trk_cnt] = ittrk->eta();
129  Phi[trk_cnt] = ittrk->phi();
130  Chi2n[trk_cnt] = ittrk->normalizedChi2();
131  P[trk_cnt] = ittrk->p();
132  Pt[trk_cnt] = ittrk->pt();
133  Nhits[trk_cnt][0] = ittrk->numberOfValidHits();
134 
135  // if(ntracks>1)std::cout<<"Track #"<<trk_cnt+1<<" params: Eta="<< Eta[trk_cnt]<<" Phi="<< Phi[trk_cnt]<<" P="<<P[trk_cnt]<<" Nhits="<<Nhits[trk_cnt][0]<<std::endl;
136 
137  int nhit = 0;
138  //loop on tracking rechits
139  //std::cout << " loop on hits of track #" << (itt - tracks->begin()) << std::endl;
140  for (auto const &hit : ittrk->recHits()) {
141  if (!hit->isValid())
142  continue;
143  DetId detid = hit->geographicalId();
144  int subDet = detid.subdetId();
145  uint32_t rawId = hit->geographicalId().rawId();
146 
147  // if(subDet==1)npxbhits++;
148 
149  //look if you find this detid in the map
150  DetHitMap::iterator mapiter;
151  mapiter = hitmap_.find(rawId);
152  if (mapiter != hitmap_.end()) { //present, increase its value by one
153  // hitmap_[rawId]=hitmap_[rawId]+1;
154  ++(hitmap_[rawId]);
155  } else { //not present, let's add this key to the map with value=1
156  hitmap_.insert(pair<uint32_t, uint32_t>(rawId, 1));
157  }
158 
159  AlignmentClusterFlag inval;
160 
161  bool hitInPixel = (subDet == PixelSubdetector::PixelBarrel) || (subDet == PixelSubdetector::PixelEndcap);
162  bool hitInStrip = (subDet == SiStripDetId::TIB) || (subDet == SiStripDetId::TID) ||
163  (subDet == SiStripDetId::TOB) || (subDet == SiStripDetId::TEC);
164 
165  if (!(hitInPixel || hitInStrip)) {
166  //skip only this hit, don't stop everything throwing an exception
167  edm::LogError("AlignmentStats") << "Hit not belonging neither to pixels nor to strips! Skipping it. SubDet= "
168  << subDet;
169  continue;
170  }
171 
172  //check also if the hit is an overlap. If yes fill a dedicated hitmap
173  if (hitInStrip) {
174  const std::type_info &type = typeid(*hit);
175 
176  if (type == typeid(SiStripRecHit1D)) {
177  //Notice the difference respect to when one loops on Trajectories: the recHit is a TrackingRecHit and not a TransientTrackingRecHit
178  const SiStripRecHit1D *striphit = dynamic_cast<const SiStripRecHit1D *>(hit);
179  if (striphit != nullptr) {
180  SiStripRecHit1D::ClusterRef stripclust(striphit->cluster());
181  inval = OverlapMap[stripclust];
182  } else {
183  // edm::LogError("AlignmentStats")<<"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit1D failed! TypeId of the RecHit: "<<className(*hit);
184  throw cms::Exception("NullPointerError")
185  << "ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit1D failed! TypeId of the RecHit: "
186  << className(*hit);
187  }
188  } //end if sistriprechit1D
189  if (type == typeid(SiStripRecHit2D)) {
190  const SiStripRecHit2D *striphit = dynamic_cast<const SiStripRecHit2D *>(hit);
191  if (striphit != nullptr) {
192  SiStripRecHit2D::ClusterRef stripclust(striphit->cluster());
193  inval = OverlapMap[stripclust];
194  //cout<<"Taken the Strip Cluster with ProdId "<<stripclust.id() <<"; the Value in the map is "<<inval<<" (DetId is "<<hit->geographicalId().rawId()<<")"<<endl;
195  } else {
196  throw cms::Exception("NullPointerError")
197  << "ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit2D failed! TypeId of the RecHit: "
198  << className(*hit);
199  // edm::LogError("AlignmentStats")<<"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit2D failed! TypeId of the RecHit: "<<className(*hit);
200  }
201  } //end if sistriprechit2D
202 
203  } //end if hit in Strips
204  else {
205  const SiPixelRecHit *pixelhit = dynamic_cast<const SiPixelRecHit *>(hit);
206  if (pixelhit != nullptr) {
207  SiPixelClusterRefNew pixclust(pixelhit->cluster());
208  inval = OverlapMap[pixclust];
209  //cout<<"Taken the Pixel Cluster with ProdId "<<pixclust.id() <<"; the Value in the map is "<<inval<<" (DetId is "<<hit->geographicalId().rawId()<<")"<<endl;
210  } else {
211  edm::LogError("AlignmentStats")
212  << "ERROR in <AlignmentStats::analyze>: Dynamic cast of Pixel RecHit failed! TypeId of the RecHit: "
213  << className(*hit);
214  }
215  } //end else hit is in Pixel
216 
217  bool isOverlapHit(inval.isOverlap());
218 
219  if (isOverlapHit) {
220  //cout<<"This hit is an overlap !"<<endl;
221  DetHitMap::iterator overlapiter;
222  overlapiter = overlapmap_.find(rawId);
223 
224  if (overlapiter !=
225  overlapmap_.end()) { //the det already collected at least an overlap, increase its value by one
226  overlapmap_[rawId] = overlapmap_[rawId] + 1;
227  } else { //first overlap on det unit, let's add it to the map
228  overlapmap_.insert(pair<uint32_t, uint32_t>(rawId, 1));
229  }
230  } //end if the hit is an overlap
231 
232  int subdethit = static_cast<int>(hit->geographicalId().subdetId());
233  // if(ntracks>1)std::cout<<"Hit in SubDet="<<subdethit<<std::endl;
234  Nhits[trk_cnt][subdethit] = Nhits[trk_cnt][subdethit] + 1;
235  nhit++;
236  } //end loop on trackingrechits
237  trk_cnt++;
238 
239  } //end loop on tracks
240 
241  // cout<<"Total number of pixel hits is "<<npxbhits<<endl;
242 
243  tmpPresc_--;
244  if (tmpPresc_ < 1) {
245  outtree_->Fill();
247  }
248  if (trk_cnt != ntracks)
249  edm::LogError("AlignmentStats") << "\nERROR! trk_cnt=" << trk_cnt << " ntracks=" << ntracks;
250 
251  return;
252 }
RunNumber_t run() const
Definition: EventID.h:38
ClusterRef cluster() const
float Eta[MAXTRKS_]
type
Definition: HCALResponse.h:21
EventNumber_t event() const
Definition: EventID.h:40
uint32_t prescale_
DetHitMap hitmap_
static constexpr auto TID
Definition: SiStripDetId.h:38
edm::InputTag src_
DetHitMap overlapmap_
const TrackerTopology * trackerTopology_
float Chi2n[MAXTRKS_]
uint32_t tmpPresc_
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
ClusterRef cluster() const
static constexpr auto TOB
Definition: SiStripDetId.h:39
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
Definition: DetId.h:17
const TrackerGeometry * trackerGeometry_
ClusterRef cluster() const
Definition: SiPixelRecHit.h:47
static const int MAXTRKS_
std::pair< OmniClusterRef, TrackingParticleRef > P
static constexpr auto TIB
Definition: SiStripDetId.h:37
unsigned int ntracks
edm::EventID id() const
Definition: EventBase.h:59
int Nhits[MAXTRKS_][7]
float Pt[MAXTRKS_]
T get() const
Definition: EventSetup.h:73
edm::InputTag overlapAM_
T const * product() const
Definition: ESHandle.h:86
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
void AlignmentStats::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 47 of file AlignmentStats.cc.

References Chi2n, Eta, event_, Nhits, ntracks, outtree_, Phi, prescale_, Pt, run_, statsTreeName_, tmpPresc_, and treefile_.

47  { // const edm::EventSetup &iSetup
48 
49  //book track stats tree
50  treefile_ = new TFile(statsTreeName_.c_str(), "RECREATE");
51  treefile_->cd();
52  outtree_ = new TTree("AlignmentTrackStats", "Statistics of Tracks used for Alignment");
53  // int nHitsinPXB[MAXTRKS_], nHitsinPXE[MAXTRKS_], nHitsinTEC[MAXTRKS_], nHitsinTIB[MAXTRKS_],nHitsinTOB[MAXTRKS_],nHitsinTID[MAXTRKS_];
54 
55  outtree_->Branch("Ntracks", &ntracks, "Ntracks/i");
56  outtree_->Branch("Run_", &run_, "Run_Nr/I");
57  outtree_->Branch("Event", &event_, "EventNr/I");
58  outtree_->Branch("Eta", &Eta, "Eta[Ntracks]/F");
59  outtree_->Branch("Phi", &Phi, "Phi[Ntracks]/F");
60  outtree_->Branch("P", &P, "P[Ntracks]/F");
61  outtree_->Branch("Pt", &Pt, "Pt[Ntracks]/F");
62  outtree_->Branch("Chi2n", &Chi2n, "Chi2n[Ntracks]/F");
63  outtree_->Branch("Nhits", &Nhits, "Nhits[Ntracks][7]/I");
64  /*
65  outtree_->Branch("NhitsPXB" , ,);
66  outtree_->Branch("NhitsPXE" , ,);
67  outtree_->Branch("NhitsTIB" , ,);
68  outtree_->Branch("NhitsTID" , ,);
69  outtree_->Branch("NhitsTOB" , ,);
70  outtree_->Branch("NhitsTOB" , ,);
71  */
72 
74 
75  //load the tracker geometry from the EventSetup
76  // iSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometry_);
77 
78 } //end beginJob
float Eta[MAXTRKS_]
uint32_t prescale_
float Chi2n[MAXTRKS_]
uint32_t tmpPresc_
float Phi[MAXTRKS_]
std::string statsTreeName_
std::pair< OmniClusterRef, TrackingParticleRef > P
unsigned int ntracks
int Nhits[MAXTRKS_][7]
float Pt[MAXTRKS_]
void AlignmentStats::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 254 of file AlignmentStats.cc.

References DEFINE_FWK_MODULE, PV3DBase< T, PVType, FrameType >::eta(), hitmap_, hitsTreeName_, triggerObjects_cff::id, fastTrackerRecHitType::is2D(), nhits, outtree_, overlapmap_, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, RecoTauValidation_cfi::posX, RecoTauValidation_cfi::posY, TrackerTopology::pxbLayer(), TrackerTopology::pxfDisk(), DetId::subdetId(), SiStripDetId::TEC, TrackerTopology::tecIsDoubleSide(), TrackerTopology::tecIsStereo(), TrackerTopology::tecWheel(), SiStripDetId::TIB, TrackerTopology::tibIsDoubleSide(), TrackerTopology::tibIsStereo(), TrackerTopology::tibLayer(), SiStripDetId::TID, TrackerTopology::tidIsDoubleSide(), TrackerTopology::tidIsStereo(), TrackerTopology::tidWheel(), SiStripDetId::TOB, TrackerTopology::tobIsDoubleSide(), TrackerTopology::tobIsStereo(), TrackerTopology::tobLayer(), trackerTopology_, and treefile_.

Referenced by o2olib.O2ORunMgr::executeJob().

254  {
255  treefile_->cd();
256  edm::LogInfo("AlignmentStats") << "Writing out the TrackStatistics in " << gDirectory->GetPath() << std::endl;
257  outtree_->Write();
258  delete outtree_;
259 
260  //create tree with hit maps (hitstree)
261  //book track stats tree
262  TFile *hitsfile = new TFile(hitsTreeName_.c_str(), "RECREATE");
263  hitsfile->cd();
264  TTree *hitstree = new TTree("AlignmentHitMap", "Maps of Hits used for Alignment");
265 
266  unsigned int id = 0, nhits = 0, noverlaps = 0;
267  float posX(-99999.0), posY(-77777.0), posZ(-88888.0);
268  float posEta(-6666.0), posPhi(-5555.0), posR(-4444.0);
269  int subdet = 0;
270  unsigned int layer = 0;
271  bool is2D = false, isStereo = false;
272  hitstree->Branch("DetId", &id, "DetId/i");
273  hitstree->Branch("Nhits", &nhits, "Nhits/i");
274  hitstree->Branch("Noverlaps", &noverlaps, "Noverlaps/i");
275  hitstree->Branch("SubDet", &subdet, "SubDet/I");
276  hitstree->Branch("Layer", &layer, "Layer/i");
277  hitstree->Branch("is2D", &is2D, "is2D/B");
278  hitstree->Branch("isStereo", &isStereo, "isStereo/B");
279  hitstree->Branch("posX", &posX, "posX/F");
280  hitstree->Branch("posY", &posY, "posY/F");
281  hitstree->Branch("posZ", &posZ, "posZ/F");
282  hitstree->Branch("posR", &posR, "posR/F");
283  hitstree->Branch("posEta", &posEta, "posEta/F");
284  hitstree->Branch("posPhi", &posPhi, "posPhi/F");
285 
286  /*
287  TTree *overlapstree=new TTree("OverlapHitMap","Maps of Overlaps used for Alignment");
288  hitstree->Branch("DetId", &id , "DetId/i");
289  hitstree->Branch("NOverlaps", &nhits , "Nhits/i");
290  hitstree->Branch("SubDet", &subdet, "SubDet/I");
291  hitstree->Branch("Layer", &layer, "Layer/i");
292  hitstree->Branch("is2D" , &is2D, "is2D/B");
293  hitstree->Branch("isStereo",&isStereo,"isStereo/B");
294  hitstree->Branch("posX", &posX, "posX/F");
295  hitstree->Branch("posY", &posY, "posY/F");
296  hitstree->Branch("posZ", &posZ, "posZ/F");
297  hitstree->Branch("posR", &posR, "posR/F");
298  hitstree->Branch("posEta", &posEta, "posEta/F");
299  hitstree->Branch("posPhi", &posPhi, "posPhi/F");
300  */
301 
302  std::unique_ptr<AlignableTracker> theAliTracker =
303  std::make_unique<AlignableTracker>(&(*trackerGeometry_), trackerTopology_);
304  const auto &Detunitslist = theAliTracker->deepComponents();
305  int ndetunits = Detunitslist.size();
306  edm::LogInfo("AlignmentStats") << "Number of DetUnits in the AlignableTracker: " << ndetunits << std::endl;
307 
308  for (int det_cnt = 0; det_cnt < ndetunits; ++det_cnt) {
309  //re-initialize for safety
310  id = 0;
311  nhits = 0;
312  noverlaps = 0;
313  posX = -99999.0;
314  posY = -77777.0;
315  posZ = -88888.0;
316  posEta = -6666.0;
317  posPhi = -5555.0;
318  posR = -4444.0;
319  subdet = 0;
320  layer = 0;
321  is2D = false;
322  isStereo = false;
323 
324  //if detunit in vector is found also in the map, look for how many hits were collected
325  //and save in the tree this number
326  id = static_cast<uint32_t>(Detunitslist[det_cnt]->id());
327  if (hitmap_.find(id) != hitmap_.end()) {
328  nhits = hitmap_[id];
329  }
330  //if not, save nhits=0
331  else {
332  nhits = 0;
333  hitmap_.insert(pair<uint32_t, uint32_t>(id, 0));
334  }
335 
336  if (overlapmap_.find(id) != overlapmap_.end()) {
337  noverlaps = overlapmap_[id];
338  }
339  //if not, save nhits=0
340  else {
341  noverlaps = 0;
342  overlapmap_.insert(pair<uint32_t, uint32_t>(id, 0));
343  }
344 
345  //take other geometrical infos from the det
346  posX = Detunitslist[det_cnt]->globalPosition().x();
347  posY = Detunitslist[det_cnt]->globalPosition().y();
348  posZ = Detunitslist[det_cnt]->globalPosition().z();
349 
350  align::GlobalVector vec(posX, posY, posZ);
351  posR = vec.perp();
352  posPhi = vec.phi();
353  posEta = vec.eta();
354  // posPhi = atan2(posY,posX);
355 
356  DetId detid(id);
357  subdet = detid.subdetId();
358 
359  //get layers, petals, etc...
360  if (subdet == PixelSubdetector::PixelBarrel) { //PXB
361 
362  layer = trackerTopology_->pxbLayer(id);
363  is2D = true;
364  isStereo = false;
365  } else if (subdet == PixelSubdetector::PixelEndcap) {
366  layer = trackerTopology_->pxfDisk(id);
367  is2D = true;
368  isStereo = false;
369  } else if (subdet == SiStripDetId::TIB) {
370  layer = trackerTopology_->tibLayer(id);
371  is2D = trackerTopology_->tibIsDoubleSide(id);
372  isStereo = trackerTopology_->tibIsStereo(id);
373  } else if (subdet == SiStripDetId::TID) {
374  layer = trackerTopology_->tidWheel(id);
375  is2D = trackerTopology_->tidIsDoubleSide(id);
376  isStereo = trackerTopology_->tidIsStereo(id);
377  } else if (subdet == SiStripDetId::TOB) {
378  layer = trackerTopology_->tobLayer(id);
379  is2D = trackerTopology_->tobIsDoubleSide(id);
380  isStereo = trackerTopology_->tobIsStereo(id);
381  } else if (subdet == SiStripDetId::TEC) {
382  layer = trackerTopology_->tecWheel(id);
383  is2D = trackerTopology_->tecIsDoubleSide(id);
384  isStereo = trackerTopology_->tecIsStereo(id);
385  } else {
386  edm::LogError("AlignmentStats") << "Detector not belonging neither to pixels nor to strips! Skipping it. SubDet= "
387  << subdet;
388  }
389 
390  //write in the hitstree
391  hitstree->Fill();
392  } //end loop over detunits
393 
394  //save hitstree
395  hitstree->Write();
396  delete hitstree;
397  //delete Detunitslist;
398  hitmap_.clear();
399  overlapmap_.clear();
400  delete hitsfile;
401 }
DetHitMap hitmap_
bool tecIsDoubleSide(const DetId &id) const
bool tobIsDoubleSide(const DetId &id) const
bool tibIsDoubleSide(const DetId &id) const
unsigned int tibLayer(const DetId &id) const
bool tobIsStereo(const DetId &id) const
static constexpr auto TID
Definition: SiStripDetId.h:38
unsigned int pxfDisk(const DetId &id) const
DetHitMap overlapmap_
const TrackerTopology * trackerTopology_
unsigned int tidWheel(const DetId &id) const
bool tidIsStereo(const DetId &id) const
bool tecIsStereo(const DetId &id) const
bool is2D(HitType hitType)
static constexpr auto TOB
Definition: SiStripDetId.h:39
unsigned int pxbLayer(const DetId &id) const
Definition: DetId.h:17
bool tibIsStereo(const DetId &id) const
bool tidIsDoubleSide(const DetId &id) const
static constexpr auto TIB
Definition: SiStripDetId.h:37
std::string hitsTreeName_
unsigned int tecWheel(const DetId &id) const
static constexpr auto TEC
Definition: SiStripDetId.h:40
unsigned int tobLayer(const DetId &id) const

Member Data Documentation

float AlignmentStats::Chi2n[MAXTRKS_]
private

Definition at line 54 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

float AlignmentStats::Eta[MAXTRKS_]
private

Definition at line 54 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

int AlignmentStats::event_
private

Definition at line 52 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

DetHitMap AlignmentStats::hitmap_
private

Definition at line 59 of file AlignmentStats.h.

Referenced by analyze(), and endJob().

std::string AlignmentStats::hitsTreeName_
private

Definition at line 43 of file AlignmentStats.h.

Referenced by endJob().

bool AlignmentStats::keepHitPopulation_
private

Definition at line 41 of file AlignmentStats.h.

bool AlignmentStats::keepTrackStats_
private

Definition at line 40 of file AlignmentStats.h.

const int AlignmentStats::MAXTRKS_ = 200
staticprivate

Definition at line 51 of file AlignmentStats.h.

Referenced by analyze().

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

Definition at line 55 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

unsigned int AlignmentStats::ntracks
private

Definition at line 53 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

TTree* AlignmentStats::outtree_
private

Definition at line 50 of file AlignmentStats.h.

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

edm::InputTag AlignmentStats::overlapAM_
private

Definition at line 39 of file AlignmentStats.h.

Referenced by analyze().

DetHitMap AlignmentStats::overlapmap_
private

Definition at line 60 of file AlignmentStats.h.

Referenced by analyze(), and endJob().

float AlignmentStats::P[MAXTRKS_]
private

Definition at line 54 of file AlignmentStats.h.

float AlignmentStats::Phi[MAXTRKS_]
private

Definition at line 54 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

uint32_t AlignmentStats::prescale_
private

Definition at line 44 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

float AlignmentStats::Pt[MAXTRKS_]
private

Definition at line 54 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

int AlignmentStats::run_
private

Definition at line 52 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

edm::InputTag AlignmentStats::src_
private

Definition at line 38 of file AlignmentStats.h.

Referenced by analyze().

std::string AlignmentStats::statsTreeName_
private

Definition at line 42 of file AlignmentStats.h.

Referenced by beginJob().

uint32_t AlignmentStats::tmpPresc_
private

Definition at line 46 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

const TrackerGeometry* AlignmentStats::trackerGeometry_
private

Definition at line 63 of file AlignmentStats.h.

Referenced by analyze().

const TrackerTopology* AlignmentStats::trackerTopology_
private

Definition at line 64 of file AlignmentStats.h.

Referenced by analyze(), and endJob().

TFile* AlignmentStats::treefile_
private

Definition at line 49 of file AlignmentStats.h.

Referenced by beginJob(), and endJob().