28 src_(iConfig.getParameter<
edm::InputTag>(
"src")),
29 overlapAM_(iConfig.getParameter<
edm::InputTag>(
"OverlapAssoMap")),
30 keepTrackStats_(iConfig.getParameter<
bool>(
"keepTrackStats")),
31 keepHitPopulation_(iConfig.getParameter<
bool>(
"keepHitStats")),
32 statsTreeName_(iConfig.getParameter<
string>(
"TrkStatsFileName")),
33 hitsTreeName_(iConfig.getParameter<
string>(
"HitStatsFileName")),
34 prescale_(iConfig.getParameter<uint32_t>(
"TrkStatsPrescale"))
53 outtree_=
new TTree(
"AlignmentTrackStats",
"Statistics of Tracks used for Alignment");
62 outtree_->Branch(
"P" ,&
P ,
"P[Ntracks]/F");
114 unsigned int trk_cnt=0;
122 for(
int k=0;
k<7;
k++){
130 for(std::vector<reco::Track>::const_iterator ittrk = Tracks->begin(), edtrk = Tracks->end(); ittrk != edtrk; ++ittrk){
131 Eta[trk_cnt]=ittrk->eta();
132 Phi[trk_cnt]=ittrk->phi();
133 Chi2n[trk_cnt]=ittrk->normalizedChi2();
134 P[trk_cnt]=ittrk->p();
135 Pt[trk_cnt]=ittrk->pt();
136 Nhits[trk_cnt][0]=ittrk->numberOfValidHits();
143 for (
auto const&
hit : ittrk->recHits())
145 if(!
hit->isValid())
continue;
146 DetId detid =
hit->geographicalId();
148 uint32_t rawId =
hit->geographicalId().rawId();
153 DetHitMap::iterator mapiter;
160 hitmap_.insert(pair<uint32_t, uint32_t>(rawId, 1));
168 if(!(hitInPixel||hitInStrip)){
170 edm::LogError(
"AlignmentStats")<<
"Hit not belonging neither to pixels nor to strips! Skipping it. SubDet= "<<subDet;
176 const std::type_info &
type =
typeid(*hit);
181 if(striphit!=
nullptr){
183 inval = OverlapMap[stripclust];
187 throw cms::Exception(
"NullPointerError")<<
"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit1D failed! TypeId of the RecHit: "<<
className(*
hit);
192 if(striphit!=
nullptr){
194 inval = OverlapMap[stripclust];
198 throw cms::Exception(
"NullPointerError")<<
"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit2D failed! TypeId of the RecHit: "<<
className(*
hit);
206 if(pixelhit!=
nullptr){
208 inval = OverlapMap[pixclust];
212 edm::LogError(
"AlignmentStats")<<
"ERROR in <AlignmentStats::analyze>: Dynamic cast of Pixel RecHit failed! TypeId of the RecHit: "<<
className(*
hit);
221 DetHitMap::iterator overlapiter;
228 overlapmap_.insert(pair<uint32_t, uint32_t>(rawId, 1));
235 int subdethit=
static_cast<int>(
hit->geographicalId().subdetId());
237 Nhits[trk_cnt][subdethit]=
Nhits[trk_cnt][subdethit]+1;
259 edm::LogInfo(
"AlignmentStats")<<
"Writing out the TrackStatistics in "<<gDirectory->GetPath()<<std::endl;
267 TTree *hitstree=
new TTree(
"AlignmentHitMap",
"Maps of Hits used for Alignment");
269 unsigned int id=0,
nhits=0,noverlaps=0;
270 float posX(-99999.0),
posY(-77777.0),posZ(-88888.0);
271 float posEta(-6666.0),posPhi(-5555.0),posR(-4444.0);
273 unsigned int layer=0;
274 bool is2D=
false,isStereo=
false;
275 hitstree->Branch(
"DetId", &
id ,
"DetId/i");
276 hitstree->Branch(
"Nhits", &
nhits ,
"Nhits/i");
277 hitstree->Branch(
"Noverlaps",&noverlaps,
"Noverlaps/i");
278 hitstree->Branch(
"SubDet", &subdet,
"SubDet/I");
279 hitstree->Branch(
"Layer", &layer,
"Layer/i");
280 hitstree->Branch(
"is2D" , &is2D,
"is2D/B");
281 hitstree->Branch(
"isStereo", &isStereo,
"isStereo/B");
282 hitstree->Branch(
"posX", &
posX,
"posX/F");
283 hitstree->Branch(
"posY", &
posY,
"posY/F");
284 hitstree->Branch(
"posZ", &posZ,
"posZ/F");
285 hitstree->Branch(
"posR", &posR,
"posR/F");
286 hitstree->Branch(
"posEta", &posEta,
"posEta/F");
287 hitstree->Branch(
"posPhi", &posPhi,
"posPhi/F");
305 std::unique_ptr<AlignableTracker> theAliTracker=std::make_unique<AlignableTracker>(&(*trackerGeometry_),
trackerTopology_);
306 const auto& Detunitslist = theAliTracker->deepComponents();
307 int ndetunits=Detunitslist.size();
308 edm::LogInfo(
"AlignmentStats")<<
"Number of DetUnits in the AlignableTracker: "<< ndetunits<<std::endl;
310 for(
int det_cnt=0;det_cnt< ndetunits;++det_cnt){
329 id=static_cast <uint32_t>( Detunitslist[det_cnt]->id() );
336 hitmap_.insert(pair<uint32_t, uint32_t>(
id, 0));
345 overlapmap_.insert(pair<uint32_t, uint32_t>(
id, 0));
349 posX= Detunitslist[det_cnt]->globalPosition().x();
350 posY= Detunitslist[det_cnt]->globalPosition().y();
351 posZ= Detunitslist[det_cnt]->globalPosition().z();
400 edm::LogError(
"AlignmentStats")<<
"Detector not belonging neither to pixels nor to strips! Skipping it. SubDet= "<<subdet;
ClusterRef cluster() const
EventNumber_t event() const
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
unsigned int pxfDisk(const DetId &id) const
const TrackerTopology * trackerTopology_
Geom::Phi< T > phi() const
unsigned int tidWheel(const DetId &id) const
bool tidIsStereo(const DetId &id) const
bool tecIsStereo(const DetId &id) const
#define DEFINE_FWK_MODULE(type)
bool is2D(HitType hitType)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
ClusterRef cluster() const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
unsigned int pxbLayer(const DetId &id) const
const TrackerGeometry * trackerGeometry_
std::string statsTreeName_
ClusterRef cluster() const
bool tibIsStereo(const DetId &id) const
AlignmentStats(const edm::ParameterSet &iConfig)
bool tidIsDoubleSide(const DetId &id) const
static const int MAXTRKS_
std::pair< OmniClusterRef, TrackingParticleRef > P
std::string hitsTreeName_
~AlignmentStats() override
unsigned int tecWheel(const DetId &id) const
T const * product() const
std::string className(const T &t)
unsigned int tobLayer(const DetId &id) const
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override