10 #include "TClonesArray.h"
15 #include "FairRootManager.h"
18 #include "FairRuntimeDb.h"
36 fPrintTrack(true), fPrintMCHit(true), fPrintCluster(true), fPrintPixDigis(true), fPrintPixHit(true),
37 fPrintStripCluster(true), fPrintStripDigis(true), fPrintStripHit(true), fPrintTrackMatch(true), fPrintGhosts(true),
38 fNTracks(0), fNPossibleTracks(0), fNCompleteTracks(0), fNPartTracks(0), fNNotFoundPossibleTracks(0), fNNotFoundTracks(0),
39 fNGhostTracks(0), fEventNr(0)
54 FairRootManager* ioman = FairRootManager::Instance();
56 std::cout <<
"-E- PndMvdEventAnaTask::Init: "<<
"RootManager not instantiated!" << std::endl;
61 fMCTracks = (TClonesArray*) ioman->GetObject(
"MCTrack");
63 std::cout <<
"-W- PndMvdEventAnaTask::Init: "<<
"No MCTrack" <<
" array!" << std::endl;
67 fMCHits = (TClonesArray*) ioman->GetObject(
"MVDPoint");
69 std::cout <<
"-W- PndMvdEventAnaTask::Init: "<<
"No MVDPoint"<<
" array!" << std::endl;
73 fStripDigis = (TClonesArray*) ioman->GetObject(
"MVDStripDigis");
75 std::cout <<
"-W- PndMvdEventAnaTask::Init: "<<
"No MVDStripDigis"<<
" array!" << std::endl;
78 fPixDigis = (TClonesArray*) ioman->GetObject(
"MVDPixelDigis");
80 std::cout <<
"-W- PndMvdEventAnaTask::Init: "<<
"No MVDPixDigis"<<
" array!" << std::endl;
83 fPixReco = (TClonesArray*) ioman->GetObject(
"MVDHitsPixel");
85 std::cout <<
"-W- PndMvdEventAnaTask::Init: "<<
"No MVDHitsPixel"<<
" array!" << std::endl;
88 fStripReco = (TClonesArray*) ioman->GetObject(
"MVDHitsStrip");
90 std::cout <<
"-W- PndMvdEventAnaTask::Init: "<<
"No MVDHitsStrip" <<
" array!" << std::endl;
93 fPixCluster = (TClonesArray*) ioman->GetObject(
"MVDClusterCand");
95 std::cout <<
"-W- PndMvdEventAnaTask::Init: "<<
"No MVDClusterCand" <<
" array!" << std::endl;
98 fStripCluster = (TClonesArray*) ioman->GetObject(
"MVDStripClusterCand");
100 std::cout <<
"-W- PndMvdEventAnaTask::Init: " <<
"No MVDStripClusterCand" <<
" array!" << std::endl;
103 fTrackCand = (TClonesArray*) ioman->GetObject(
"MVDRiemannTrackCand");
105 std::cout <<
"-W- PndMvdEventAnaTask::Init: " <<
"No MVDRiemannTrackCand" <<
" array!" << std::endl;
106 fTrackCand = (TClonesArray*) ioman->GetObject(
"MVDIdealTrackCand");
108 std::cout <<
"-W- PndMvdEventAnaTask::Init: " <<
"No MVDIdealTrackCand" <<
" array!" << std::endl;
112 fHTracksPerEvent =
new TH1I(
"HTracksPerEvent",
"Tracks per Event", 21, -0.5, 20.5);
113 fHHitsPerTrack =
new TH1I(
"HHitsPerTrack",
"Hits per Track", 21,0.5,20.5);
114 fHEnergyPerHit =
new TH1D(
"HEnergyPerHit",
"Energy per Hit", 200, 0, 10000000);
116 fHPointRes =
new TH1D(
"HPointRes",
"Point Resolution", 1000, 0,0.1);
118 fHPointResS =
new TH1D(
"HPointResS",
"Point Resolution", 1000, 0,0.1);
120 fHPointResD =
new TH1D(
"HPointResD",
"Point Resolution", 1000, 0,0.1);
122 fHPointResM =
new TH1D(
"HPointResM",
"Point Resolution", 1000, 0,0.1);
126 fHEnergyRes =
new TH1D(
"HEnergyRes",
"Energy Resolution", 1000, -100000, 100000);
127 fHPRes =
new TH1D(
"HPRes",
"Momentum Resolution", 1000, -5,5);
128 fHPtRes =
new TH1D(
"HPtRes",
"Transversal Momentum Resolution", 1000, -5,5);
130 fHPointResStrip =
new TH1D(
"HPointResStrip",
"Point Resolution Strips", 1000, 0,0.1);
132 fHPointResSStrip =
new TH1D(
"HPointResSStrip",
"Point Resolution Strip", 1000, 0,0.1);
134 fHPointResDStrip =
new TH1D(
"HPointResDStrip",
"Point Resolution Strip", 1000, 0,0.1);
136 fHPointResMStrip =
new TH1D(
"HPointResMStrip",
"Point Resolution Strip", 1000, 0,0.1);
141 fHEnergyResStrip =
new TH1D(
"HEnergyResStrip",
"Energy Resolution Strips", 1000, -100000, 100000);
144 fHRiemannRes =
new TH1I(
"HRiemannRes",
"Quality of the Riemann Trackfinding", 16,-5.5,10.5);
145 fHRiemannFakes =
new TH1I(
"HRiemannFakes",
"Wrong assign hits in Track", 16, -5.5,10.5);
151 fHRiemannVertexResolutionX =
new TH1D(
"HRiemannVertexResolutionX",
"Difference between reco vertex and MC vertex", 1000, -1, 1);
152 fHRiemannVertexResolutionY =
new TH1D(
"HRiemannVertexResolutionY",
"Difference between reco vertex and MC vertex", 1000, -1, 1);
153 fHRiemannVertexResolutionZ =
new TH1D(
"HRiemannVertexResolutionZ",
"Difference between reco vertex and MC vertex", 1000, -1, 1);
170 std::map<int, std::vector<int> > mcHitMap;
171 std::map<int, std::vector<int> > trackToTrackCandMap;
173 std::vector<PndRiemannTrack> riemannTracks;
174 std::vector<int> MCTrackOrderRiemann;
176 TVector3 MCPos, RecoPos;
178 double TrackP, TrackPt;
186 std::cout <<
"------------Event " <<
fEventNr <<
"-------------" << std::endl;
191 for (
std::map<
int, std::vector<int> >::const_iterator kIt = mcHitMap.begin(); kIt!= mcHitMap.end(); kIt++){
193 std::vector<int> MChits = kIt->second;
199 std::cout <<
"<<<<<<<<<<< MCTrack >>>>>>>>>> " << std::endl;
200 myTrack->
Print(kIt->first);
202 std::cout <<
"Pt: " << TrackPt <<
" GeV/c; P: " << TrackP <<
" GeV/c" << std::endl;
203 std::cout <<
"StartVertex: " << startVertex.X() <<
" " << startVertex.Y() <<
" " << startVertex.Z() << std::endl;
205 for (
unsigned int p = 0;
p < MChits.size();
p++){
208 std::cout <<
"-------------------------------" << std::endl;
212 MCEnergy = myPoint->GetEnergyLoss()*10E9;
215 std::vector<int> pixCluster =
GetClusters(MChits[p],
true);
217 for (
unsigned int clInd = 0; clInd < pixCluster.size(); clInd++) {
221 int recoHit =
GetRecoHit(pixCluster[clInd],
true);
228 std::cout <<
"-W- No Reco Hit found!" << std::endl;
233 std::vector<int> stripCluster =
GetClusters(MChits[p],
false);
237 for (
unsigned int clInd = 0; clInd < stripCluster.size(); clInd++) {
242 recoHit =
GetRecoHit(stripCluster[clInd],
false);
245 std::cout <<
"RecoHit: " << recoHit << std::endl;
248 if (oldRecoHit != recoHit){
250 oldRecoHit = recoHit;
258 if ((oldRecoHit > -1) && (oldRecoHit != recoHit))
267 std::cout << std::endl;
268 std::cout <<
"TrackID " << kIt->first <<
": ";
269 for (
unsigned int testInd = 0; testInd < pixHits.size(); testInd++)
270 std::cout <<
" 5/" << pixHits[testInd];
272 for (
unsigned int testInd = 0; testInd < stripHits.size(); testInd++)
273 std::cout <<
" 4/" << stripHits[testInd];
274 std::cout << std::endl;
276 std::cout <<
"MCHitMap: ";
277 for (
unsigned int testInd = 0; testInd < mcHitMap[kIt->first].size(); testInd++)
278 std::cout << mcHitMap[kIt->first].at(testInd) <<
" ";
279 std::cout << std::endl;
281 std::vector<int> matches;
282 std::vector<int> candidates;
284 std::cout <<
"TrackCands for MCTrack: ";
285 for (
unsigned int i = 0;
i < candidates.size();
i++) std::cout << candidates[
i];
286 std::cout << std::endl;
287 trackToTrackCandMap[kIt->first] = candidates;
292 for (
unsigned int i = 0;
i < matches.size();
i++){
293 if (oldmatches < matches[
i]){
294 oldmatches = matches[
i];
299 MCTrackOrderRiemann.push_back(kIt->first);
301 for (UInt_t j = 0; j < myCand->
getNHits(); j++){
302 unsigned int detId, hitId;
303 myCand->
getHit(j, detId, hitId);
305 myRiemannTrack.
addHit(hit);
308 myRiemannTrack.
refit();
309 myRiemannTrack.
szFit();
310 TVectorD
n = myRiemannTrack.
n();
312 riemannTracks.push_back(myRiemannTrack);
314 double curv = myCand->
getCurv();
315 double dip = myCand->
getDip();
319 unsigned int detId, hitId;
322 myCand->
getHit(0,detId, hitId);
328 myCand->
getHit(0,detId, hitId);
329 std::cout << std::endl;
330 std::cout <<
"HitMatch: " << matches[
i] << std::endl;
331 std::cout <<
"Hits in Track: " << myCand->
getNHits() <<
" Difference: ";
332 if (detId > 0) std::cout << myCand->
getNHits() - matches[
i] << std::endl;
333 else std::cout << myCand->
getNHits() - matches [
i] -1 << std::endl;
336 std::cout <<
"Pt: " << pt <<
" GeV/c " <<
" P: " << pt/dip <<
" GeV/c" << std::endl;
337 std::cout <<
"Pt error: " << TrackPt - pt <<
" P error: " << TrackP - pt/dip << std::endl;
338 std::cout <<
"TrackID: " << kIt->first <<
" mcHitMap.size: " << mcHitMap[kIt->first].size() <<
" matches: " << matches[
i] << std::endl;
339 std::cout <<
"Missing Hits: " << mcHitMap[kIt->first].size() - matches[
i] << std::endl;
340 if (mcHitMap[kIt->first].size() < (myCand->
getNHits()-1))
345 if (mcHitMap[kIt->first].size() > 2){
346 if (mcHitMap[kIt->first].size() > 3){
361 if (matches.size() > 0){
363 double curv = myCand->
getCurv();
364 double dip = myCand->
getDip();
369 fHPRes->Fill(TrackP - pt/dip);
370 fHRiemannRes->Fill(mcHitMap[kIt->first].size() - matches[highestMatch]);
371 if (mcHitMap[kIt->first].size() - matches[highestMatch] == 0)
375 std::cout <<
"Found TracksPerTrack: " << TrackMatch;
376 if (mcHitMap[kIt->first].size() > 2) std::cout <<
" 3Hits+" << std::endl;
380 if (riemannTracks.size() > 1){
381 std::cout << riemannTracks.size() <<
" Riemann Tracks used!" << std::endl;
382 for (
unsigned int i = 0;
i < riemannTracks.size() - 1;
i++){
383 for (
unsigned int j =
i + 1; j < riemannTracks.size(); j++) {
395 std::cout <<
"Vertex Test for: " << MCTrackOrderRiemann[
i] <<
" and " << MCTrackOrderRiemann[j] << std::endl;
396 int result = riemannTracks[
i].calcIntersection(riemannTracks[j], p1, p2);
399 std::cout <<
"Vertex1: " << p1.X() <<
" " << p1.Y() <<
" " << p1.Z() << std::endl;
400 std::cout <<
"Vertex2: " << p2.X() <<
" " << p2.Y() <<
" " << p2.Z() << std::endl;
403 std::cout <<
"MCVertex " << MCTrackOrderRiemann[
i] <<
": "<< MCVertex.X() <<
" " << MCVertex.Y() <<
" " << MCVertex.Z() << std::endl;
404 MCVertex -= (p1+
p2)*0.5;
405 std::cout <<
"Difference: " << MCVertex.X() <<
" " << MCVertex.Y() <<
" " << MCVertex.Z() << std::endl;
416 std::cout << std::endl;
417 std::cout <<
"----Ghost TrackCandidates:-------" << std::endl;
418 for (
unsigned int tcIndex = 0; tcIndex <
fGhostCand.size(); tcIndex++){
426 std::cout << std::endl;
432 std::cout << std::endl;
433 std::cout <<
"--------- Summary Track Fitting -----------" << std::endl;
434 std::cout <<
"Number of Tracks: " <<
fNTracks << std::endl;
435 std::cout <<
"Number of Tracks with more than 3 hits: " <<
fNPossibleTracks << std::endl;
451 return (FairHit *)
fPixReco->At(hitId);
453 else if (detId == 4){
457 std::cout <<
"-E- FairRiemannTrackCandDraw::GetFairHit : Unknown Detector with ID: " << detId << std::endl;
464 TClonesArray* cluster;
466 std::vector<int> result;
476 for (
int clIndex = 0; clIndex < cluster->GetEntriesFast(); clIndex++){
479 result.push_back(clIndex);
497 for (
int hitIndex = 0; hitIndex < reco->GetEntriesFast(); hitIndex++){
508 std::vector<Int_t> digiInd,
bool pixel)
523 std::cout <<
"Hit belongs to cluster " << clIndex << std::endl;
525 for (
unsigned int s = 0;
s < digiInd.size();
s++) {
564 if (pixel) std::cout <<
"PixHit: ";
565 else std::cout <<
"StripHit: ";
566 std::cout << hitInd << std::endl;
570 double RecoEnergy = myHit->
GetEloss()*10E9;
571 TVector3 result = MCPos - RecoPos;
572 ((TH1D*)hPointRes)->Fill(result.Mag());
574 hPointResS->Fill(result.Mag());
576 hPointResD->Fill(result.Mag());
578 hPointResM->Fill(result.Mag());
579 ((TH1D*)hEnergyRes)->Fill(MCEnergy-RecoEnergy);
587 for (
unsigned int i = 0;
i < clusterList.size() && result ==
false;
i++){
594 if (myDigi->
GetIndex(j) == HitIndex)
602 std::vector<int>& matches, std::vector<int>& result)
604 unsigned int detId, hitId;
611 for (
unsigned int j = 0; j < myTrackCand->
getNHits(); j++){
612 myTrackCand->
getHit(j, detId, hitId);
615 for (
unsigned int k = 0; k < pixHitId.size(); k++){
617 if ((
int)hitId == pixHitId[k])
621 else if (detId == 4){
622 for (
unsigned int k = 0; k < stripHitId.size(); k++){
624 if ((
int)hitId == stripHitId[k])
631 matches.push_back(hitMatch);
642 std::map<int, std::vector<int> > result;
643 for (
int i = 0;
i <
fMCHits->GetEntriesFast();
i++){
646 result[myPoint->GetTrackID()].push_back(
i);
654 unsigned int det,
hit;
656 for (
unsigned int i = 0;
i < cand->
getNHits();
i++){
658 std::cout << det <<
"/" << hit <<
" ";
virtual void SetParContainers()
std::vector< Int_t > GetClusterList() const
TClonesArray * fStripDigis
TH1 * fHRiemannTracksPerTrackAdd
virtual void Print(const Option_t *opt=0) const
Base class for Digi information.
void PrintRecoHitInfo(int hitInd, int digiSize, TVector3 MCPos, double MCEnergy, bool pixel) const
TVector3 GetPosition() const
Class to store the Digis which belong to one cluster This class holds the information which Digi belo...
FairHit * GetFairHit(Int_t detId, Int_t hitId)
Int_t GetIndex(int i=0) const
std::map< int, std::vector< int > > AssignHitsToTracks()
Class for digitised strip hits.
unsigned int getNHits() const
TVector3 GetMomentum() const
TVector3 GetPositionOut() const
Double_t GetEloss() const
TH1 * fHRiemannVertexResolutionY
TH1 * fHDigisPerClusterStrip
void PrintTrackCand(GFTrackCand *cand) const
TString pt(TString pts, TString exts="px py pz")
const TVectorD & n() const
virtual InitStatus Init()
std::vector< int > fGhostCand
std::map< int, std::vector< int > > fTrackPixHitIdMap
TClonesArray * fStripCluster
TClonesArray * fStripReco
void getHit(unsigned int i, unsigned int &detId, unsigned int &hitId) const
Get detector ID and cluster index (hitId) for hit number i.
bool MCHitBelongsToCluster(int HitIndex, PndSdsCluster *cluster, bool pixCluster)
std::map< int, std::vector< int > > fTrackStripHitIdMap
virtual void Exec(Option_t *opt)
void refit(bool withErrorCalc=true)
void Print(Int_t iTrack=0) const
Track candidate – a list of cluster indices.
TH1 * fHRiemannTracksPerTrack
Int_t GetBotIndex() const
void PrintClusterDigiInfo(int clIndex, std::vector< Int_t > digiInd, bool pixel)
TClonesArray * fTrackCand
std::vector< int > GetClusters(int MCHit, bool pixel)
TH1 * fHRiemannVertexResolutionZ
TVector3 GetPosition() const
void GetTrackCandsForMCTrack(std::vector< int > pixHitId, std::vector< int > stripHitId, std::vector< int > &matches, std::vector< int > &result)
virtual ~PndMvdEventAnaTask()
void szFit(bool withErrorCalc=true)
void addHit(PndRiemannHit &hit)
Data class to store the digi output of a pixel module.
Int_t GetClusterIndex() const
Int_t GetNIndices() const
TVector3 GetStartVertex() const
TH1 * fHRiemannVertexResolutionX
Int_t GetMotherID() const
int GetRecoHit(int clIndex, bool pixel) const
TClonesArray * fPixCluster
int fNNotFoundPossibleTracks
virtual void Print(const Option_t *opt=0) const