32 overlapAM_(iConfig.getParameter<
edm::
InputTag>(
"OverlapAssoMap")),
33 keepTrackStats_(iConfig.getParameter<
bool>(
"keepTrackStats")),
34 keepHitPopulation_(iConfig.getParameter<
bool>(
"keepHitStats")),
35 statsTreeName_(iConfig.getParameter<
string>(
"TrkStatsFileName")),
36 hitsTreeName_(iConfig.getParameter<
string>(
"HitStatsFileName")),
37 prescale_(iConfig.getParameter<uint32_t>(
"TrkStatsPrescale")) {
54 outtree_ =
new TTree(
"AlignmentTrackStats",
"Statistics of Tracks used for Alignment");
62 outtree_->Branch(
"P", &
P,
"P[Ntracks]/F");
107 unsigned int trk_cnt = 0;
115 for (
int k = 0;
k < 7;
k++) {
123 for (std::vector<reco::Track>::const_iterator ittrk =
Tracks->begin(), edtrk =
Tracks->end(); ittrk != edtrk;
125 Eta[trk_cnt] = ittrk->eta();
126 Phi[trk_cnt] = ittrk->phi();
127 Chi2n[trk_cnt] = ittrk->normalizedChi2();
128 P[trk_cnt] = ittrk->p();
129 Pt[trk_cnt] = ittrk->pt();
130 Nhits[trk_cnt][0] = ittrk->numberOfValidHits();
137 for (
auto const &
hit : ittrk->recHits()) {
140 DetId detid =
hit->geographicalId();
142 uint32_t rawId =
hit->geographicalId().rawId();
147 DetHitMap::iterator mapiter;
149 if (mapiter !=
hitmap_.end()) {
153 hitmap_.insert(pair<uint32_t, uint32_t>(rawId, 1));
162 if (!(hitInPixel || hitInStrip)) {
164 edm::LogError(
"AlignmentStats") <<
"Hit not belonging neither to pixels nor to strips! Skipping it. SubDet= " 171 const std::type_info &
type =
typeid(*hit);
176 if (striphit !=
nullptr) {
178 inval = OverlapMap[stripclust];
182 <<
"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit1D failed! TypeId of the RecHit: " 188 if (striphit !=
nullptr) {
190 inval = OverlapMap[stripclust];
194 <<
"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit2D failed! TypeId of the RecHit: " 205 inval = OverlapMap[pixclust];
209 <<
"ERROR in <AlignmentStats::analyze>: Dynamic cast of Pixel RecHit failed! TypeId of the RecHit: " 218 DetHitMap::iterator overlapiter;
225 overlapmap_.insert(pair<uint32_t, uint32_t>(rawId, 1));
229 int subdethit =
static_cast<int>(
hit->geographicalId().subdetId());
231 Nhits[trk_cnt][subdethit] =
Nhits[trk_cnt][subdethit] + 1;
253 edm::LogInfo(
"AlignmentStats") <<
"Writing out the TrackStatistics in " << gDirectory->GetPath() << std::endl;
259 TFile *hitsfile =
new TFile(
hitsTreeName_.c_str(),
"RECREATE");
261 TTree *hitstree =
new TTree(
"AlignmentHitMap",
"Maps of Hits used for Alignment");
263 unsigned int id = 0,
nhits = 0, noverlaps = 0;
264 float posX(-99999.0),
posY(-77777.0), posZ(-88888.0);
265 float posEta(-6666.0), posPhi(-5555.0), posR(-4444.0);
267 unsigned int layer = 0;
268 bool is2D =
false, isStereo =
false;
269 hitstree->Branch(
"DetId", &
id,
"DetId/i");
270 hitstree->Branch(
"Nhits", &
nhits,
"Nhits/i");
271 hitstree->Branch(
"Noverlaps", &noverlaps,
"Noverlaps/i");
272 hitstree->Branch(
"SubDet", &subdet,
"SubDet/I");
273 hitstree->Branch(
"Layer", &
layer,
"Layer/i");
274 hitstree->Branch(
"is2D", &
is2D,
"is2D/B");
275 hitstree->Branch(
"isStereo", &isStereo,
"isStereo/B");
276 hitstree->Branch(
"posX", &
posX,
"posX/F");
277 hitstree->Branch(
"posY", &
posY,
"posY/F");
278 hitstree->Branch(
"posZ", &posZ,
"posZ/F");
279 hitstree->Branch(
"posR", &posR,
"posR/F");
280 hitstree->Branch(
"posEta", &posEta,
"posEta/F");
281 hitstree->Branch(
"posPhi", &posPhi,
"posPhi/F");
299 std::unique_ptr<AlignableTracker> theAliTracker =
301 const auto &Detunitslist = theAliTracker->deepComponents();
302 int ndetunits = Detunitslist.size();
303 edm::LogInfo(
"AlignmentStats") <<
"Number of DetUnits in the AlignableTracker: " << ndetunits << std::endl;
305 for (
int det_cnt = 0; det_cnt < ndetunits; ++det_cnt) {
323 id =
static_cast<uint32_t
>(Detunitslist[det_cnt]->id());
330 hitmap_.insert(pair<uint32_t, uint32_t>(
id, 0));
339 overlapmap_.insert(pair<uint32_t, uint32_t>(
id, 0));
343 posX = Detunitslist[det_cnt]->globalPosition().x();
344 posY = Detunitslist[det_cnt]->globalPosition().y();
345 posZ = Detunitslist[det_cnt]->globalPosition().z();
383 edm::LogError(
"AlignmentStats") <<
"Detector not belonging neither to pixels nor to strips! Skipping it. SubDet= "
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > esTokenTkGeo_
static constexpr auto TID
Geom::Phi< T > phi() const
Log< level::Error, false > LogError
ClusterRef cluster() const
std::unique_ptr< TrackerGeometry > trackerGeometry_
constexpr std::array< uint8_t, layerIndexSize > layer
bool is2D(HitType hitType)
#define DEFINE_FWK_MODULE(type)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool getData(T &iHolder) const
static constexpr auto TOB
Log< level::Info, false > LogInfo
std::string statsTreeName_
AlignmentStats(const edm::ParameterSet &iConfig)
static const int MAXTRKS_
std::pair< OmniClusterRef, TrackingParticleRef > P
static constexpr auto TIB
std::string hitsTreeName_
~AlignmentStats() override
ClusterRef cluster() const
std::unique_ptr< TrackerTopology > trackerTopology_
static constexpr auto TEC
std::string className(const T &t)
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > esTokenTTopo_
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override