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")),
51 desc.add<
bool>(
"keepTrackStats",
false);
52 desc.add<
bool>(
"keepHitStats",
false);
55 desc.add<
unsigned int>(
"TrkStatsPrescale", 1);
56 descriptions.
add(
"AlignmentStats",
desc);
64 outtree_ =
new TTree(
"AlignmentTrackStats",
"Statistics of Tracks used for Alignment");
72 outtree_->Branch(
"P", &
P,
"P[Ntracks]/F");
116 unsigned int trk_cnt = 0;
124 for (
int k = 0;
k < 7;
k++) {
132 for (std::vector<reco::Track>::const_iterator ittrk =
Tracks->begin(), edtrk =
Tracks->end(); ittrk != edtrk;
134 Eta[trk_cnt] = ittrk->eta();
135 Phi[trk_cnt] = ittrk->phi();
136 Chi2n[trk_cnt] = ittrk->normalizedChi2();
137 P[trk_cnt] = ittrk->p();
138 Pt[trk_cnt] = ittrk->pt();
139 Nhits[trk_cnt][0] = ittrk->numberOfValidHits();
142 edm::LogVerbatim(
"AlignmenStats") <<
"Track #" << trk_cnt + 1 <<
" params: Eta=" <<
Eta[trk_cnt]
143 <<
" Phi=" <<
Phi[trk_cnt] <<
" P=" <<
P[trk_cnt]
144 <<
" Nhits=" <<
Nhits[trk_cnt][0];
149 for (
auto const &
hit : ittrk->recHits()) {
152 DetId detid =
hit->geographicalId();
154 uint32_t rawId =
hit->geographicalId().rawId();
159 DetHitMap::iterator mapiter;
161 if (mapiter !=
hitmap_.end()) {
165 hitmap_.insert(pair<uint32_t, uint32_t>(rawId, 1));
174 if (!(hitInPixel || hitInStrip)) {
176 edm::LogError(
"AlignmentStats") <<
"Hit not belonging neither to pixels nor to strips! Skipping it. SubDet= " 183 const std::type_info &
type =
typeid(*hit);
188 if (striphit !=
nullptr) {
190 inval = OverlapMap[stripclust];
194 <<
"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit1D failed! TypeId of the RecHit: " 200 if (striphit !=
nullptr) {
202 inval = OverlapMap[stripclust];
206 <<
"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit2D failed! TypeId of the RecHit: " 217 inval = OverlapMap[pixclust];
221 <<
"ERROR in <AlignmentStats::analyze>: Dynamic cast of Pixel RecHit failed! TypeId of the RecHit: " 230 DetHitMap::iterator overlapiter;
237 overlapmap_.insert(pair<uint32_t, uint32_t>(rawId, 1));
241 int subdethit =
static_cast<int>(
hit->geographicalId().subdetId());
244 Nhits[trk_cnt][subdethit] =
Nhits[trk_cnt][subdethit] + 1;
266 edm::LogInfo(
"AlignmentStats") <<
"Writing out the TrackStatistics in " << gDirectory->GetPath();
272 TFile *hitsfile =
new TFile(
hitsTreeName_.c_str(),
"RECREATE");
274 TTree *hitstree =
new TTree(
"AlignmentHitMap",
"Maps of Hits used for Alignment");
276 unsigned int id = 0,
nhits = 0, noverlaps = 0;
277 float posX(-99999.0),
posY(-77777.0), posZ(-88888.0);
278 float posEta(-6666.0), posPhi(-5555.0), posR(-4444.0);
280 unsigned int layer = 0;
281 bool is2D =
false, isStereo =
false;
282 hitstree->Branch(
"DetId", &
id,
"DetId/i");
283 hitstree->Branch(
"Nhits", &
nhits,
"Nhits/i");
284 hitstree->Branch(
"Noverlaps", &noverlaps,
"Noverlaps/i");
285 hitstree->Branch(
"SubDet", &subdet,
"SubDet/I");
286 hitstree->Branch(
"Layer", &
layer,
"Layer/i");
287 hitstree->Branch(
"is2D", &
is2D,
"is2D/B");
288 hitstree->Branch(
"isStereo", &isStereo,
"isStereo/B");
289 hitstree->Branch(
"posX", &
posX,
"posX/F");
290 hitstree->Branch(
"posY", &
posY,
"posY/F");
291 hitstree->Branch(
"posZ", &posZ,
"posZ/F");
292 hitstree->Branch(
"posR", &posR,
"posR/F");
293 hitstree->Branch(
"posEta", &posEta,
"posEta/F");
294 hitstree->Branch(
"posPhi", &posPhi,
"posPhi/F");
312 std::unique_ptr<AlignableTracker> theAliTracker =
314 const auto &Detunitslist = theAliTracker->deepComponents();
315 int ndetunits = Detunitslist.size();
316 edm::LogInfo(
"AlignmentStats") <<
"Number of DetUnits in the AlignableTracker: " << ndetunits;
318 for (
int det_cnt = 0; det_cnt < ndetunits; ++det_cnt) {
336 id =
static_cast<uint32_t
>(Detunitslist[det_cnt]->id());
343 hitmap_.insert(pair<uint32_t, uint32_t>(
id, 0));
352 overlapmap_.insert(pair<uint32_t, uint32_t>(
id, 0));
356 posX = Detunitslist[det_cnt]->globalPosition().x();
357 posY = Detunitslist[det_cnt]->globalPosition().y();
358 posZ = Detunitslist[det_cnt]->globalPosition().z();
396 edm::LogError(
"AlignmentStats") <<
"Detector not belonging neither to pixels nor to strips! Skipping it. SubDet= "
Log< level::Info, true > LogVerbatim
const std::string hitsTreeName_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > esTokenTkGeo_
static constexpr auto TID
Geom::Phi< T > phi() const
std::vector< Track > TrackCollection
collection of Tracks
Log< level::Error, false > LogError
ClusterRef cluster() const
std::unique_ptr< TrackerGeometry > trackerGeometry_
const edm::EDGetTokenT< reco::TrackCollection > trackToken_
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > 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) ...
static constexpr auto TOB
Log< level::Info, false > LogInfo
const std::string statsTreeName_
const edm::EDGetTokenT< AliClusterValueMap > mapToken_
AlignmentStats(const edm::ParameterSet &iConfig)
static const int MAXTRKS_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::pair< OmniClusterRef, TrackingParticleRef > P
static constexpr auto TIB
ClusterRef cluster() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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