14 #include "TGeoManager.h"
23 fVerbose(1), ioman(NULL), fNGhosts(0),
24 fTrackBranchName(trackBranchName), fIdealTrackName(idealTrackName), fPndTrackOrTrackCand(pndTrackData), fPossibleTrack(0),
25 fUseCorrectedSkewedHits(kFALSE),
26 fBranchNames(),fTrackIdMCId(),fMCIdIdealTrackId(),fMCTrackFound(),fMapTrackMCStatus(),fMapTrackQualification(),
27 fMapEfficiencies(),fMapPResolution(),fMapP(),fMapPtResolution(),fMapPt(),fMapPResolutionRel(),fMapPtResolutionRel(),
28 fTrack(NULL),fMCTrack(NULL),fIdealTrack(NULL),fIdealTrackCand(NULL)
31 std::cout <<
"-I- PndTrackingQualityBarrelAnalysisNewLinks::PndTrackingQualityBarrelAnalysisNewLinks no PossibleTrackFunctor given. Taking Standard!" << std::endl;
32 if (trackBranchName ==
"MVDTrack" ){
34 }
else if (trackBranchName ==
"CombiTrackCand" ) {
43 fVerbose(1), ioman(NULL), fNGhosts(0),
44 fTrackBranchName(trackBranchName), fIdealTrackName(idealTrackName), fPndTrackOrTrackCand(pndTrackData), fPossibleTrack(posTrack),
45 fUseCorrectedSkewedHits(kFALSE),
46 fBranchNames(),fTrackIdMCId(),fMCIdIdealTrackId(),fMCTrackFound(),fMapTrackMCStatus(),fMapTrackQualification(),
47 fMapEfficiencies(),fMapPResolution(),fMapP(),fMapPtResolution(),fMapPt(),fMapPResolutionRel(),fMapPtResolutionRel(),
48 fTrack(NULL),fMCTrack(NULL),fIdealTrack(NULL),fIdealTrackCand(NULL)
52 std::cout <<
"-I- PndTrackingQualityBarrelAnalysisNewLinks::PndTrackingQualityBarrelAnalysisNewLinks no PossibleTrackFunctor given. Taking Standard!" << std::endl;
53 if (trackBranchName ==
"MVDTrack" ){
55 }
else if (trackBranchName ==
"CombiTrackCand" ) {
70 ioman = FairRootManager::Instance();
72 std::cout <<
"-E- PndTrackingQualityTask::Init: "
73 <<
"RootManager not instantiated!" << std::endl;
93 std::cout <<
"-I- PndTrackingQualityBarrelAnalysisNewLinks::Init: PossibleTrackFunctor: ";
100 std::cout <<
"PndTrackingQualityBarrelAnalysisNewLinks::AnalyseEvent() Track quality map before analysis: " << std::endl << std::endl;
103 for (Int_t
i = 0;
i <
fTrack->GetEntriesFast();
i++){
105 std::cout <<
"----------------------------------" << std::endl;
107 std::cout <<
"Analyse Track: " <<
i << std::endl;
109 std::map<TString, FairMultiLinkedData> trackInfo;
119 std::cout <<
"PndTrackingQualityBarrelAnalysisNewLinks::AnalyseEvent Analyse track: " <<
i << std::endl;
122 std::cout <<
"mostProbableTrack " << mostProbableTrack << std::endl;
123 if (mostProbableTrack == -1)
continue;
131 int nof_asso_mctracks = trackInfo[
"AllHits"].GetNLinks();
133 int size = recoTrackInfo->GetEntriesFast();
141 if (iter->first > -1 && iter->second > 0) {
168 FairMultiLinkedData result;
169 result.SetInsertHistory(kFALSE);
171 FairMultiLinkedData linksOfType = trackCand->GetLinksWithType(
ioman->GetBranchId(branchName));
174 for (
int j = 0; j < linksOfType.GetNLinks(); j++){
175 FairMultiLinkedData_Interface* linkData = (FairMultiLinkedData_Interface*)FairRootManager::Instance()->GetCloneOfLinkData(linksOfType.GetLink(j));
178 FairMultiLinkedData linkDataType = linkData->GetLinksWithType(FairRootManager::Instance()->GetBranchId(
"MCTrack"));
179 linkDataType.SetAllWeights(1.);
180 result.AddLinks(linkDataType);
188 std::map<TString, FairMultiLinkedData> trackInfo;
191 std::cout <<
"PndTrackingQualityData::AnalyseTrackCand: TrackInfo" << std::endl;
194 for (
unsigned int branchIndex = 0; branchIndex <
fBranchNames.size(); branchIndex++){
196 trackInfo[
"AllHits"].AddLinks(trackInfo[fBranchNames[branchIndex]]);
206 Int_t mostProbableTrack = -1;
211 if (trackInfo[
"AllHits"].GetNLinks() == 1){
212 mostProbableTrack = trackInfo[
"AllHits"].GetLink(0).GetIndex();
216 if (nMCHits == trackInfo[
"AllHits"].GetLink(0).GetWeight()){
226 Int_t highestCount = 0;
228 for (
int i = 0;
i < trackInfo[
"AllHits"].GetNLinks();
i++){
229 allCounts += trackInfo[
"AllHits"].GetLink(
i).GetWeight();
230 if (trackInfo[
"AllHits"].GetLink(
i).GetWeight() > highestCount){
231 highestCount = trackInfo[
"AllHits"].GetLink(
i).GetWeight();
232 mostProbableTrack = trackInfo[
"AllHits"].GetLink(
i).GetIndex();
248 for (
int j = 0; j < trackInfo[
"AllHits"].GetNLinks(); j++){
249 FairLink myLink = trackInfo[
"AllHits"].GetLink(j);
252 std::cout <<
"Ideal Tracking: Track " << myLink.GetIndex() <<
": ";
255 std::cout <<
"Ideal Tracking: Track " << myLink.GetIndex() <<
" not available" << std::endl;
259 std::cout <<
"MostProbableTrack: " << mostProbableTrack <<
" Quality: " <<
fMapTrackQualification[mostProbableTrack] << std::endl;
260 std::cout << std::endl;
263 return mostProbableTrack;
276 Bool_t atLeastThreeHits = kFALSE;
282 Int_t nMVDPixel =
GetNIdealHits(*(idealTrackCand->GetPointerToLinks()),
"MVDHitsPixel");
283 Int_t nMVDStrip =
GetNIdealHits(*(idealTrackCand->GetPointerToLinks()),
"MVDHitsStrip");
284 Int_t nSTT =
GetNIdealHits(*(idealTrackCand->GetPointerToLinks()),
"STTHit");
294 if (nHits >= 5 && (nMVDPixel + nMVDStrip >=0 )) atLeastThreeHits = kTRUE;
297 if (atLeastThreeHits) {
305 else if (primaryTrack){
321 std::cout <<
"-I- PndMCTestPatternRecoQuality::FillMapTrackQualifikation:" << std::endl;
348 for (
unsigned int branchIndex = 0; branchIndex <
fBranchNames.size(); branchIndex++){
350 FairMultiLinkedData gemHits = trackData->GetLinksWithType(
ioman->GetBranchId(
"GEMPoint"));
351 result += gemHits.GetNLinks();
353 result += trackData->GetLinksWithType(
ioman->GetBranchId(
fBranchNames[branchIndex])).GetNLinks();
362 if (mostProbableTrack < 0)
return;
363 for (
unsigned int branchIndex = 0; branchIndex <
fBranchNames.size(); branchIndex++){
367 FairMultiLinkedData foundHits = trackInfo[
fBranchNames[branchIndex]];
368 for (
int i = 0;
i < foundHits.GetNLinks();
i++){
369 if (foundHits.GetLink(
i).GetIndex() == mostProbableTrack){
370 Double_t nFoundHits = foundHits.GetLink(
i).GetWeight();
371 if ((nFoundHits/nMcHits) >
fMapEfficiencies[mostProbableTrack][fBranchNames[branchIndex]].first){
372 std::pair<Double_t, Int_t> result(nFoundHits/nMcHits, nMcHits);
392 Int_t numberGemHits = 0;
393 if (branchName ==
"GEMHit"){
394 numberGemHits = track.GetLinksWithType(
ioman->GetBranchId(
"GEMPoint")).GetNLinks();
395 return numberGemHits;
397 else if (branchName ==
"MVDHitsPixel" || branchName ==
"MVDHitsStrip"){
399 FairMultiLinkedData links = track.GetLinksWithType(
ioman->GetBranchId(branchName));
405 return track.GetLinksWithType(
ioman->GetBranchId(branchName)).GetNLinks();
410 if (detailedInfo == kTRUE) std::cout << std::endl;
411 for (
unsigned int branchIndex = 0; branchIndex <
fBranchNames.size(); branchIndex++){
413 std::cout << branchName <<
" " <<
GetNIdealHits(trackData, branchName);
414 if (detailedInfo == kTRUE){
416 if (trackData.GetLinksWithType(
ioman->GetBranchId(branchName)).GetNLinks() > 0)
417 std::cout << trackData.GetLinksWithType(
ioman->GetBranchId(branchName));
418 std::cout << std::endl;
423 std::cout << std::endl;
430 std::cout <<
"TrackID: " << iter->first <<
" MCQuality: " <<
fMapTrackMCStatus[iter->first] <<
" Quality: " << iter->second <<
" Found: " <<
fMCTrackFound[iter->first] <<
" MCData: ";
436 std::cout << std::endl;
441 std::cout <<
"PrintTrackMCStatusMap: " << std::endl;
443 std::cout <<
"TrackID: " << iter->first <<
" Quality: " << iter->second <<
" Found: " <<
fMCTrackFound[iter->first];
444 std::cout << std::endl;
446 std::cout << std::endl;
452 std::cout <<
"TrackInfo: (MC-ID/NHits) : ";
453 for (std::map<TString, FairMultiLinkedData>::iterator iter = info.begin(); iter != info.end(); iter++){
454 std::cout << iter->first;
455 for (
int i = 0;
i < iter->second.GetNLinks();
i++){
456 std::cout <<
" : (" << iter->second.GetLink(
i).GetIndex() <<
"/" << iter->second.GetLink(
i).GetWeight() <<
")";
460 std::cout << std::endl;
478 std::map< int, int > noftruehits;
479 std::map< int, int > noffakehits;
480 std::map< int, int > nofmissinghits;
482 for (
unsigned int branchIndex = 0; branchIndex <
fBranchNames.size(); branchIndex++){
485 nofmissinghits.clear();
503 FairMultiLinkedData ptrlink = *trackcand->GetPointerToLinks();
505 FairMultiLinkedData links = ptrlink.GetLinksWithType(
ioman->GetBranchId(
fBranchNames[branchIndex]));
507 Int_t
nHits = links.GetNLinks();
508 std::cout <<
"----- reco track " << trackId <<
" (mc track " << mctrackId<<
") has " << nHits <<
" from " <<
fBranchNames[branchIndex] << std::endl;
511 for (
int ihit = 0; ihit <
nHits; ihit++){
512 FairLink link = links.GetLink(ihit);
513 int assomctrack = -1;
515 FairHit *
hit = (FairHit*) links.GetData(link);
517 std::cout <<
"ihit " << ihit <<
" " << link.GetIndex() <<
" is FAKE" << std::endl;
521 if(noffakehits.count(branchIndex) > 0) noffakehits[branchIndex]++;
522 else noffakehits[branchIndex] = 1;
527 FairMultiLinkedData hitlink = *hit->GetPointerToLinks();
529 FairMultiLinkedData mclinks = hitlink.GetLinksWithType(
ioman->GetBranchId(
"MCTrack"));
532 FairMultiLinkedData mvdstrhits = links.GetLinksWithType(FairRootManager::Instance()->GetBranchId(
"MVDHitsStrip"));
533 FairMultiLinkedData gemhits = links.GetLinksWithType(FairRootManager::Instance()->GetBranchId(
"GEMHit"));
534 if ((gemhits.GetNLinks() > 0 || mvdstrhits.GetNLinks() > 0) && mclinks.GetNLinks() > 1) {
538 for (
int imctrk = 0; imctrk < mclinks.GetNLinks(); imctrk++) {
539 FairLink mclink = mclinks.GetLink(imctrk);
540 assomctrack = mclink.GetIndex();
542 std::cout <<
"ihit " << ihit <<
" (hitid " << link.GetIndex() <<
") belongs to MC track " << assomctrack << std::endl;
543 if(assomctrack == mctrackId) isgood = kTRUE;
548 if(isgood == kTRUE) {
550 if(noftruehits.count(branchIndex) > 0)noftruehits[branchIndex]++;
551 else noftruehits[branchIndex] = 1;
554 if(noffakehits.count(branchIndex) > 0) noffakehits[branchIndex]++;
555 else noffakehits[branchIndex] = 1;
569 nofmissinghits[branchIndex] = nMcHits - noftruehits[branchIndex];
571 std::cout <<
"**** ideal track " << idealtrackid <<
" has " << nMcHits <<
" from " <<
fBranchNames[branchIndex] << std::endl;
575 std::cout <<
"===> BRANCH " <<
fBranchNames[branchIndex] <<
" of track " << trackId <<
" (mc track " << mctrackId <<
") has " << noftruehits[branchIndex] <<
" true, " << noffakehits[branchIndex] <<
" fake and " << nofmissinghits[branchIndex] <<
" missing hits" << std::endl;
606 if( iHit<0 || iHit>=links.GetNLinks() ){
607 std::cout <<
"IsBarrelMVD():: iHit " << iHit <<
" is out of range [0," << links.GetNLinks() <<
"]"<< std::endl;
610 FairLink link = links.GetLink(iHit);
613 std::cout <<
"IsBarrelMVD():: iHit " << iHit <<
" " << link.GetIndex() <<
" is FAKE" << std::endl;
618 TGeoHMatrix* transMat =
gGeoManager->GetCurrentMatrix();
620 std::cout<<
"\n\nIsBarrelMVD():: NO transition Matrix for MVD sensor "<<sensorID<<
"\n\n!!!"<<std::endl;
623 Double_t *mmm = transMat->GetRotationMatrix();
625 std::cout<<
"\n\nIsBarrelMVD():: Can not extract transition Matrix for MVD sensor "<<sensorID<<
", something is completely wrong\n\n!!!"<<std::endl;
628 bool forward = (
fabs(mmm[6]) < 0.999 &&
fabs(mmm[7]) < 0.999 );
635 for( Int_t ihit=0; ihit<links.GetNLinks(); ihit++ ){
static Int_t NBarrelMVD(FairMultiLinkedData &links)
std::map< Int_t, Double_t > fMapPResolutionRel
void AnalyseEvent(TClonesArray *recoTrackInfo)
std::map< Int_t, TVector3 > fMapP
void SetNofSttFakeHits(int nofstt)
void SetNofMvdStripFakeHits(int nofstr)
void AddHitsBranchName(TString name)
Adds branch names of detector data which should be taken into account in the analysis.
void PrintTrackQualityMap(Bool_t detailedInfo=kFALSE)
Bool_t IsBetterTrackExisting(Int_t &mcIndex, int quality)
static const int kLessThanThreePrim
void SetNofMvdPixelTrueHits(int nofpix)
Bool_t fPndTrackOrTrackCand
void SetNofMvdPixelMissingHits(int nofpix)
static const int kAtLeastThreeSec
void SetNofSttTrueHits(int nofstt)
TVector3 GetMomentum() const
std::vector< TString > fBranchNames
std::map< Int_t, Int_t > fTrackIdMCId
! map between track id and most probable MC track id
void SetNofMvdStripMissingHits(int nofstr)
std::map< Int_t, Int_t > fMCIdTrackId
! map between MC id and track id
static const int kPartiallyFound
std::map< Int_t, Double_t > fMapPResolution
void SetNofMCTracks(Int_t nofmctracks)
TGeoManager * gGeoManager
TClonesArray * fIdealTrack
Holding statically callable quality numbers.
void SetNofMvdPixelFakeHits(int nofpix)
std::map< Int_t, Int_t > fMapTrackQualification
! TrackId vs TrackStatus after analysis of track finding
std::map< Int_t, std::map< TString, std::pair< Double_t, Int_t > > > fMapEfficiencies
! MostProbable TrackId, BranchName, Efficiency, #FoundHits / #MCHits, #MCHits
std::map< Int_t, Int_t > fMCIdIdealTrackId
! map between MC id and ideal track id
PossibleTrackFunctor * fPossibleTrack
void SetMomentumLast(TVector3 mom)
void SetNofGemMissingHits(int nofgem)
static const int kAtLeastThreePrim
FairTrackParP GetParamLast()
PndTrackingQualityBarrelAnalysisNewLinks(TString trackBranchName, TString idealTrackName, Bool_t pndTrackData=kTRUE)
virtual Int_t AnalyseTrackInfo(std::map< TString, FairMultiLinkedData > &trackInfo, Int_t trackId)
ClassImp(PndTrackingQualityBarrelAnalysisNewLinks)
Int_t GetSumOfAllValidMCHits(FairMultiLinkedData *trackData)
friend F32vec4 fabs(const F32vec4 &a)
std::map< Int_t, Double_t > fMapPtResolution
static PndGeoHandling * Instance()
void SetPositionLast(TVector3 pos)
void PrintTrackDataSummary(FairMultiLinkedData &trackData, Bool_t detailedInfo=kFALSE)
std::map< Int_t, Double_t > fMapPtResolutionRel
PndTrackingQualityRecoInfo GetRecoInfoFromRecoTrack(Int_t trackId, Int_t mctrackId)
int hit(Int_t nEvents=0, TString inFile="sim.root", TString parFile="par.root", TString inDigi="digi.root", TString outFile="hit.root", Int_t timeBased=0)
static const int kFullyFound
Int_t GetNIdealHits(FairMultiLinkedData &track, TString branchName)
void SetPositionFirst(TVector3 pos)
FairMultiLinkedData GetMCInfoForBranch(TString branchName, PndTrackCand *trackCand)
void SetNofMvdStripTrueHits(int nofstr)
void SetNofSttMissingHits(int nofstt)
virtual void FillMapTrackQualifikation()
void SetMomentumFirst(TVector3 mom)
void PrintTrackMCStatusMap()
void SetNofGemTrueHits(int nofgem)
Int_t GetSensorID() const
std::map< Int_t, Int_t > fMapTrackMCStatus
! TrackId vs TrackStatus from MC
PndTrackCand * GetTrackCandPtr()
std::map< Int_t, Double_t > fMapPt
Int_t GetMotherID() const
static Bool_t IsBarrelMVD(FairMultiLinkedData &links, int iHit)
std::map< TString, FairMultiLinkedData > AnalyseTrackCand(PndTrackCand *trackCand)
void PrintTrackInfo(std::map< TString, FairMultiLinkedData > info)
virtual void CalcEfficiencies(Int_t mostProbableTrack, std::map< TString, FairMultiLinkedData > &trackInfo)
void SetNofGemFakeHits(int nofgem)
void SetMCTrackID(int mctrackid)
virtual ~PndTrackingQualityBarrelAnalysisNewLinks()
FairTrackParP GetParamFirst()
static const int kSpuriousFound
std::map< Int_t, Int_t > fMCTrackFound
! How often was a MC Track (key) found