16 #include "TClonesArray.h"
20 #include "FairRootManager.h"
22 #include "FairRuntimeDb.h"
24 #include "FairMultiLinkedData.h"
29 #include "PndMCEntry.h"
39 #include "TGeoManager.h"
46 FairTask(
"Creates PndMC Barrel test"),
47 fBranchNames(),fMCInfoBranchName(
"MCTrackInfo"), fRecoInfoBranchName(
"RecoTrackInfo"),
48 fMapLinkData(), fMapEfficiencies(), fMCInfoIdIdealId(),
49 fNGhosts(0),fTrack(NULL), fMCTrack(NULL), fTrackCand(NULL), fSttHitArray(NULL), fMCTrackInfo(NULL), fRecoTrackInfo(NULL),
50 fIdealTrack(NULL), fSttTubeArray(NULL),
52 fMapTrackQualifikation(),
53 fTrackBranchName(trackBranchName), fIdealTrackBranchName(idealBranchName), fPndTrackOrTrackCand(pndTrackData),
54 fSttParameters(NULL), fTuple(NULL),
55 fPHisto(NULL),fPRelHisto(NULL),fPtHisto(NULL),fPtRelHisto(NULL),fQualyHisto(NULL),fQualyStack(NULL),
56 fQualyHisto_mc(NULL),fQualyHisto_neg(NULL),fQualyHisto_pos(NULL),fQualyHisto_all(NULL),
70 ioman = FairRootManager::Instance();
72 std::cout <<
"-E- PndTrackingQualityBarrelTaskNewLinks::Init: "
73 <<
"RootManager not instantiated!" << std::endl;
84 fMCTrackInfo =
new TClonesArray(
"PndTrackingQualityMCInfo");
116 <<
"-I- PndTrackingQualityBarrelTaskNewLinks::Init: Initialization successfull"
123 fPHisto =
new TH1D(
"fPHisto",
"Momentum Resolution", 1000, -1, 1);
124 fPHisto->GetXaxis()->SetTitle(
"p^{RECO} - p^{MC} / GeV");
125 fPHisto->GetYaxis()->SetTitle(
"counts");
126 fPRelHisto =
new TH1D(
"fPRelHisto",
"Relative Momentum Resolution", 1000, -1, 1);
127 fPRelHisto->GetXaxis()->SetTitle(
"(p^{RECO} - p^{MC}) / p^{MC}");
129 fPtHisto =
new TH1D(
"fPtHisto",
"Transverse Momentum Resolution", 1000, -1, 1);
130 fPtHisto->GetXaxis()->SetTitle(
"p_{t}^{RECO} - p_{t}^{MC} / GeV");
131 fPtHisto->GetYaxis()->SetTitle(
"counts");
132 fPtRelHisto =
new TH1D(
"fPtRelHisto",
"Relative Transverse Momentum Resolution", 1000, -1, 1);
133 fPtRelHisto->GetXaxis()->SetTitle(
"(p_{t}^{RECO} - p_{t}^{MC}) / p_{t}^{MC}");
136 fQualyHisto =
new TH1I(
"fQualyHisto",
"Quality of Trackfinding;;Counts", 26, -15.5, 10.5);
140 fQualyHisto_all =
new TH1I(
"fQualyHisto_all",
"Quality of Trackfinding;;Counts", 26, -15.5, 10.5);
141 fQualyHisto_pos =
new TH1I(
"fQualyHisto_pos",
"Quality of Trackfinding;;Counts", 26, -15.5, 10.5);
142 fQualyHisto_neg =
new TH1I(
"fQualyHisto_neg",
"Quality of Trackfinding;;Counts", 26, -15.5, 10.5);
143 fQualyHisto_mc =
new TH1I(
"fQualyHisto_mc",
"Quality of Trackfinding;;Counts", 26, -15.5, 10.5);
169 FairRuntimeDb*
rtdb = FairRun::Instance()->GetRuntimeDb();
178 std::cout <<
"----- Event " <<
fEventNr <<
" ------" << std::endl;
190 std::map<Int_t, TVector3> recoPMap = qaAna.
GetP();
203 for (std::map<Int_t, Int_t>::iterator iter = mcStatusMap.begin(); iter != mcStatusMap.end(); iter++) {
204 Int_t mcTrackId = iter->first;
206 Int_t trackQuality = iter->second;
229 for(
int itrk = 0; itrk <
fRecoTrackInfo->GetEntriesFast(); itrk++) {
241 for (std::map<Int_t, Int_t>::iterator iter = qualiMap.begin(); iter != qualiMap.end(); iter++) {
242 Int_t mcTrackId = iter->first;
243 Int_t trackQuality = iter->second;
245 TVector3 recoMomentum = recoPMap[mcTrackId];
254 fTuple->
Column(
"McTrackFoundNTimes", (Int_t) mcFoundMap[mcTrackId]);
256 fTuple->
Column(
"Mc_TrackQuality", (Int_t) mcStatusMap[mcTrackId] - 6);
280 for (
unsigned int branchIndex = 0; branchIndex <
fBranchNames.size(); branchIndex++){
281 result += trackData->GetLinksWithType(
ioman->GetBranchId(
fBranchNames[branchIndex])).GetNLinks();
291 for(std::map<Int_t, Int_t>::iterator iter = trackQualifikation.begin(); iter != trackQualifikation.end(); iter++){
293 if (iter->second > 0){
305 for(std::map<Int_t, Int_t>::iterator iter = trackMCStatus.begin(); iter != trackMCStatus.end(); iter++){
313 for (
std::map<Int_t,
std::map<
TString, std::pair<Double_t, Int_t> > >::iterator iterTracks = efficiencies.begin(); iterTracks != efficiencies.end(); iterTracks++ ){
314 std::map<TString, std::pair<Double_t, Int_t> > branchEfficiency = iterTracks->second;
315 for (
std::map<
TString, std::pair<Double_t, Int_t> >::iterator iterBranch = branchEfficiency.begin(); iterBranch != branchEfficiency.end(); iterBranch++ ){
316 fMapEfficiencies[iterBranch->first]->Fill(iterBranch->second.second, iterBranch->second.first);
321 for (std::map<Int_t, Double_t>::iterator iter = map.begin(); iter != map.end(); iter++ ){
322 histo->Fill(iter->second);
349 Int_t allTracksWithHits = 0;
350 Int_t allPossibleTracksWithHits = 0;
351 Int_t allTracksWithHitsNotFound = 0;
368 std::cout <<
"fQualyHisto: All Tracks: " <<
fQualyHisto->GetBinContent(
fQualyHisto->FindFixBin(-11)) + allTracksWithHits << std::endl
370 <<
" All Tracks with hits: " << allTracksWithHits <<
". Not Found: " << allTracksWithHitsNotFound << std::endl
429 TGeoHMatrix* transMat =
gGeoManager->GetCurrentMatrix();
431 std::cout<<
"\n\nIsBarrelMVD():: NO transition Matrix for MVD sensor "<<sensorID<<
"\n\n!!!"<<std::endl;
434 Double_t *mmm = transMat->GetRotationMatrix();
436 std::cout<<
"\n\nIsBarrelMVD():: Can not extract transition Matrix for MVD sensor "<<sensorID<<
", something is completely wrong\n\n!!!"<<std::endl;
440 bool forward = (
fabs(mmm[6]) < 0.999 &&
fabs(mmm[7]) < 0.999 );
451 Int_t nofmvdpixpoint = idealtrkcand->
GetNHitsDet(FairRootManager::Instance()->GetBranchId(
"MVDHitsPixel"));
452 Int_t nofmvdstrpoint = idealtrkcand->
GetNHitsDet(FairRootManager::Instance()->GetBranchId(
"MVDHitsStrip"));
454 Int_t nofgempoint = idealtrkcand->
GetNHitsDet(FairRootManager::Instance()->GetBranchId(
"GEMHit"));
456 int nofsttskewpoint = 0, nofsttparalpoint = 0;
458 for(UInt_t ihit = 0; ihit < idealtrkcand->
GetNHits(); ihit++) {
460 Int_t hitID = idealcandhit.
GetHitId();
461 Int_t detID = idealcandhit.
GetDetId();
463 if(detID != FairRootManager::Instance()->GetBranchId(
"STTHit"))
continue;
467 if(tube->
IsSkew()) nofsttskewpoint++;
468 else nofsttparalpoint++;
697 for(
int imctrk = 0; imctrk <
fMCTrackInfo->GetEntriesFast(); imctrk++) {
701 double tmpeff = 0., tmppur = 0.;
702 int tmptruerecotrackid = -1;
706 for(
int itrk = 0; itrk <
fRecoTrackInfo->GetEntriesFast(); itrk++) {
709 if(mctrackid != mctrackid0)
continue;
720 tmprecoinfo = recoinfo;
722 if(tmprecoinfo == NULL)
continue;
virtual void Exec(Option_t *opt)
UInt_t GetNHitsDet(Int_t detId)
std::map< int, int > fMCInfoIdIdealId
std::map< Int_t, Double_t > GetPResolutionRel()
void SetAssoRecoTrackID(int asso)
std::vector< TString > fBranchNames
void AnalyseEvent(TClonesArray *recoTrackInfo)
virtual InitStatus Init()
static const int kMcAtLeastThreeSec
std::map< Int_t, Int_t > GetMCTrackFound()
PndTrackingQualityMCInfo GetMCInfoFromIdealTrack(PndTrack *idealtrack)
std::map< Int_t, Int_t > GetTrackQualification()
void SetMCTrackID(Int_t mctrackid)
void LabelQualyHistogram(TH1 *)
virtual ~PndTrackingQualityBarrelTaskNewLinks()
Int_t GetIdealTrackIdFromRecoTrackId(int trackid)
void PrintTrackQualityMap(Bool_t detailedInfo=kFALSE)
virtual void FillMCStatus(std::map< Int_t, Int_t > trackMCStatus)
void SetMomentumLast(TVector3 mom)
static const int kLessThanThreePrim
Bool_t IsBarrelMVD(const PndSdsHit *hit)
PndTrackCandHit GetSortedHit(UInt_t i)
static const int kPossiblePrim
static const int kAtLeastThreeSec
TVector3 GetMomentum() const
void SetRecoTrackID(int recotrkid)
void AddHitsBranchName(TString name)
Adds branch names of detector data which should be taken into account in the analysis.
static const int kPartiallyFound
static const int kMcPossibleSec
void SetMCTrackInfo(PndTrackingQualityMCInfo *info)
TGeoManager * gGeoManager
virtual Int_t GetSumOfAllValidMCHits(FairMultiLinkedData *trackData)
Holding statically callable quality numbers.
virtual void MapToHist(std::map< Int_t, Double_t >, TH1 *)
std::map< Int_t, Double_t > GetPtResolutionRel()
void SetVerbose(Int_t val)
std::map< Int_t, std::map< TString, std::pair< Double_t, Int_t > > > GetEfficiencies()
Int_t GetAssoRecoTrackID() const
PndTrackingQualityBarrelTaskNewLinks(TString trackBranchName, TString idealBranchName, Bool_t pndTrackData=kTRUE)
static const int kPossibleSec
ClassImp(PndTrackingQualityBarrelTaskNewLinks)
TString fMCInfoBranchName
std::map< Int_t, TVector3 > GetP()
static const int kAtLeastThreePrim
TClonesArray * fSttHitArray
TClonesArray * fIdealTrack
FairTrackParP GetParamLast()
Int_t GetMCInfoIdFromIdealTrackId(int idealtrackid)
TClonesArray * FillTubeArray()
TClonesArray * fRecoTrackInfo
void Column(const char *label, Bool_t value, Bool_t defval=0, const char *block=0)
friend F32vec4 fabs(const F32vec4 &a)
void SetMomentumFirst(TVector3 mom)
static PndGeoHandling * Instance()
static const int kMcLessThanThreePrim
std::map< Int_t, Double_t > GetPtResolution()
virtual void FillEfficiencies(std::map< Int_t, std::map< TString, std::pair< Double_t, Int_t > > > efficiencies)
std::map< TString, TH2 * > fMapEfficiencies
Bool_t fPndTrackOrTrackCand
virtual void SetParContainers()
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
TClonesArray * fSttTubeArray
void SetHitsBranchNames(std::vector< TString > names)
TString fRecoInfoBranchName
void AssociateRecoTracksToMCTracks()
TClonesArray * fMCTrackInfo
static const int kMcAtLeastThreePrim
void SetPositionLast(TVector3 pos)
void SetPositionFirst(TVector3 pos)
TTree * GetInternalTree()
virtual void FillQualyHisto(std::map< Int_t, Int_t > trackQualifikation, Int_t nGhosts)
Int_t GetIdealTrackIdFromMCTrackId(int mctrackid)
PndGeoSttPar * fSttParameters
std::map< Int_t, Int_t > GetTrackMCStatus()
void InitializeHistograms()
Int_t GetSensorID() const
PndTrackCand * GetTrackCandPtr()
TString fIdealTrackBranchName
void SetQuality(int quality)
static const int kMcPossiblePrim
FairTrackParP GetParamFirst()
static const int kSpuriousFound
static const int kNotFound
std::map< Int_t, Double_t > GetPResolution()