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")) {
52 outtree_ =
new TTree(
"AlignmentTrackStats",
"Statistics of Tracks used for Alignment");
60 outtree_->Branch(
"P", &
P,
"P[Ntracks]/F");
110 unsigned int trk_cnt = 0;
118 for (
int k = 0;
k < 7;
k++) {
126 for (std::vector<reco::Track>::const_iterator ittrk =
Tracks->begin(), edtrk =
Tracks->end(); ittrk != edtrk;
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();
140 for (
auto const &
hit : ittrk->recHits()) {
143 DetId detid =
hit->geographicalId();
145 uint32_t rawId =
hit->geographicalId().rawId();
150 DetHitMap::iterator mapiter;
152 if (mapiter !=
hitmap_.end()) {
156 hitmap_.insert(pair<uint32_t, uint32_t>(rawId, 1));
165 if (!(hitInPixel || hitInStrip)) {
167 edm::LogError(
"AlignmentStats") <<
"Hit not belonging neither to pixels nor to strips! Skipping it. SubDet= "
174 const std::type_info &
type =
typeid(*hit);
179 if (striphit !=
nullptr) {
181 inval = OverlapMap[stripclust];
185 <<
"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit1D failed! TypeId of the RecHit: "
191 if (striphit !=
nullptr) {
193 inval = OverlapMap[stripclust];
197 <<
"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit2D failed! TypeId of the RecHit: "
208 inval = OverlapMap[pixclust];
212 <<
"ERROR in <AlignmentStats::analyze>: Dynamic cast of Pixel RecHit failed! TypeId of the RecHit: "
221 DetHitMap::iterator overlapiter;
228 overlapmap_.insert(pair<uint32_t, uint32_t>(rawId, 1));
232 int subdethit = static_cast<int>(
hit->geographicalId().subdetId());
234 Nhits[trk_cnt][subdethit] =
Nhits[trk_cnt][subdethit] + 1;
256 edm::LogInfo(
"AlignmentStats") <<
"Writing out the TrackStatistics in " << gDirectory->GetPath() << std::endl;
262 TFile *hitsfile =
new TFile(
hitsTreeName_.c_str(),
"RECREATE");
264 TTree *hitstree =
new TTree(
"AlignmentHitMap",
"Maps of Hits used for Alignment");
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);
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");
302 std::unique_ptr<AlignableTracker> theAliTracker =
304 const auto &Detunitslist = theAliTracker->deepComponents();
305 int ndetunits = Detunitslist.size();
306 edm::LogInfo(
"AlignmentStats") <<
"Number of DetUnits in the AlignableTracker: " << ndetunits << std::endl;
308 for (
int det_cnt = 0; det_cnt < ndetunits; ++det_cnt) {
326 id = static_cast<uint32_t>(Detunitslist[det_cnt]->
id());
333 hitmap_.insert(pair<uint32_t, uint32_t>(
id, 0));
342 overlapmap_.insert(pair<uint32_t, uint32_t>(
id, 0));
346 posX = Detunitslist[det_cnt]->globalPosition().x();
347 posY = Detunitslist[det_cnt]->globalPosition().y();
348 posZ = Detunitslist[det_cnt]->globalPosition().z();
386 edm::LogError(
"AlignmentStats") <<
"Detector not belonging neither to pixels nor to strips! Skipping it. SubDet= "