Skip to content
Snippets Groups Projects
Commit 30ccc1ce authored by Mark Jones's avatar Mark Jones
Browse files

Updated drift chamber debug messages

add flags debugflagpr and debugflagstubs
add method THcDC::PrintStubs
modify THcDC::PrintSpacePoints
Set THcDC::LinkStubs() to only set fNDCTracks=0 and retrun when
  fNDCTracks>10 for HMS style chambers to match engine.
parent b26acb29
No related branches found
No related tags found
No related merge requests found
...@@ -308,6 +308,8 @@ Int_t THcDC::ReadDatabase( const TDatime& date ) ...@@ -308,6 +308,8 @@ Int_t THcDC::ReadDatabase( const TDatime& date )
{"debuglinkstubs", &fdebuglinkstubs, kInt}, {"debuglinkstubs", &fdebuglinkstubs, kInt},
{"debugprintrawdc", &fdebugprintrawdc, kInt}, {"debugprintrawdc", &fdebugprintrawdc, kInt},
{"debugprintdecodeddc", &fdebugprintdecodeddc, kInt}, {"debugprintdecodeddc", &fdebugprintdecodeddc, kInt},
{"debugflagpr", &fdebugflagpr, kInt},
{"debugflagstubs", &fdebugflagstubs, kInt},
{"debugtrackprint", &fdebugtrackprint , kInt}, {"debugtrackprint", &fdebugtrackprint , kInt},
{0} {0}
}; };
...@@ -482,7 +484,8 @@ Int_t THcDC::CoarseTrack( TClonesArray& tracks ) ...@@ -482,7 +484,8 @@ Int_t THcDC::CoarseTrack( TClonesArray& tracks )
fChambers[i]->CorrectHitTimes(); fChambers[i]->CorrectHitTimes();
fChambers[i]->LeftRight(); fChambers[i]->LeftRight();
} }
if (fdebugprintdecodeddc) PrintSpacePoints(); if (fdebugflagpr) PrintSpacePoints();
if (fdebugflagstubs) PrintStubs();
// Now link the stubs between chambers // Now link the stubs between chambers
LinkStubs(); LinkStubs();
if(fNDCTracks > 0) { if(fNDCTracks > 0) {
...@@ -545,19 +548,36 @@ Int_t THcDC::FineTrack( TClonesArray& tracks ) ...@@ -545,19 +548,36 @@ Int_t THcDC::FineTrack( TClonesArray& tracks )
void THcDC::PrintSpacePoints() void THcDC::PrintSpacePoints()
{ {
for(Int_t ich=0;ich<fNChambers;ich++) { for(Int_t ich=0;ich<fNChambers;ich++) {
cout << " chamber = " << fChambers[ich]->GetChamberNum() << " number of hits = " << fChambers[ich]->GetNHits() << " number of spacepoints = " << fChambers[ich]->GetNSpacePoints() << endl; printf("%s %2d %s %3d %s %3d \n"," chamber = ",fChambers[ich]->GetChamberNum()," number of hits = ",fChambers[ich]->GetNHits()," number of spacepoints = ",fChambers[ich]->GetNSpacePoints());
printf("%6s %-8s %-8s %6s %6s %10s \n"," "," "," ","Number","Number","Plane Wire");
printf("%6s %-8s %-8s %6s %6s %10s \n","Point","x","y"," hits ","combos"," for each hit");
TClonesArray* spacepointarray = fChambers[ich]->GetSpacePointsP(); TClonesArray* spacepointarray = fChambers[ich]->GetSpacePointsP();
for(Int_t isp=0;isp<fChambers[ich]->GetNSpacePoints();isp++) { for(Int_t isp=0;isp<fChambers[ich]->GetNSpacePoints();isp++) {
THcSpacePoint* sp = (THcSpacePoint*)(spacepointarray->At(isp)); THcSpacePoint* sp = (THcSpacePoint*)(spacepointarray->At(isp));
cout << isp+1 << " " << sp->GetX() << " " << sp->GetY() << " " << sp->GetNHits()<< " " << sp->GetCombos() << " " ; printf("%5d %8.5f %8.5f %5d %5d ",isp+1,sp->GetX(),sp->GetY(),sp->GetNHits(),sp->GetCombos()) ;
for (Int_t ii=0;ii<sp->GetNHits();ii++) { for (Int_t ii=0;ii<sp->GetNHits();ii++) {
THcDCHit* hittemp = (THcDCHit*)(sp->GetHit(ii)); THcDCHit* hittemp = (THcDCHit*)(sp->GetHit(ii));
cout << hittemp->GetPlaneNum() << " " << hittemp->GetWireNum() << " "; printf("%3d %3d",hittemp->GetPlaneNum(),hittemp->GetWireNum());
} }
cout << endl; printf("\n");
}
}
}
//
//
void THcDC::PrintStubs()
{
for(Int_t ich=0;ich<fNChambers;ich++) {
printf("%s %3d \n"," Stub fit results Chamber = ",ich+1);
printf("%-5s %-18s %-18s %-18s %-18s\n","point","x_t","y_t","xp_t","yp_t");
printf("%-5s %-18s %-18s %-18s %-18s\n"," ","[cm]","[cm]","[cm]","[cm]");
TClonesArray* spacepointarray = fChambers[ich]->GetSpacePointsP();
for(Int_t isp=0;isp<fChambers[ich]->GetNSpacePoints();isp++) {
THcSpacePoint* sp = (THcSpacePoint*)(spacepointarray->At(isp));
Double_t *spstubt=sp->GetStubP();
printf("%-5d % 15.10e % 15.10e % 15.10e % 15.10e \n",isp+1,spstubt[0],spstubt[1],spstubt[2],spstubt[3]);
} }
} }
} }
// //
//_____________________________________________________________________________ //_____________________________________________________________________________
...@@ -581,13 +601,10 @@ void THcDC::LinkStubs() ...@@ -581,13 +601,10 @@ void THcDC::LinkStubs()
fSp.clear(); fSp.clear();
fSp.reserve(10); fSp.reserve(10);
// Make a vector of pointers to the SpacePoints // Make a vector of pointers to the SpacePoints
if (fdebuglinkstubs) cout << "Linking stubs Ch 1 has " << fChambers[0]->GetNSpacePoints()
<< " sp pts and ch 2 has " << fChambers[1]->GetNSpacePoints() << " sp pts" << endl;
for(Int_t ich=0;ich<fNChambers;ich++) { for(Int_t ich=0;ich<fNChambers;ich++) {
Int_t nchamber=fChambers[ich]->GetChamberNum(); Int_t nchamber=fChambers[ich]->GetChamberNum();
TClonesArray* spacepointarray = fChambers[ich]->GetSpacePointsP(); TClonesArray* spacepointarray = fChambers[ich]->GetSpacePointsP();
for(Int_t isp=0;isp<fChambers[ich]->GetNSpacePoints();isp++) { for(Int_t isp=0;isp<fChambers[ich]->GetNSpacePoints();isp++) {
if (fdebuglinkstubs) cout << " Chamber = " << nchamber << " number of space pts = " << fNSp << endl;
fSp.push_back(static_cast<THcSpacePoint*>(spacepointarray->At(isp))); fSp.push_back(static_cast<THcSpacePoint*>(spacepointarray->At(isp)));
fSp[fNSp]->fNChamber = nchamber; fSp[fNSp]->fNChamber = nchamber;
fNSp++; fNSp++;
...@@ -600,12 +617,9 @@ void THcDC::LinkStubs() ...@@ -600,12 +617,9 @@ void THcDC::LinkStubs()
Double_t stubminxp = 999999; Double_t stubminxp = 999999;
Double_t stubminyp = 999999; Double_t stubminyp = 999999;
Int_t stub_tracks[MAXTRACKS]; Int_t stub_tracks[MAXTRACKS];
if (fdebuglinkstubs) cout << "Fsinglestub (no = 0) = " << fSingleStub << endl;
if (fdebuglinkstubs) cout << "Joined space points = " << fNSp-1 << endl;
if(!fSingleStub) { if(!fSingleStub) {
for(Int_t isp1=0;isp1<fNSp-1;isp1++) { // isp1 is index/id in total list of space points for(Int_t isp1=0;isp1<fNSp-1;isp1++) { // isp1 is index/id in total list of space points
THcSpacePoint* sp1 = fSp[isp1]; THcSpacePoint* sp1 = fSp[isp1];
if (fdebuglinkstubs) cout << "Loop thru joined space points " << isp1+1<< endl;
Int_t sptracks=0; Int_t sptracks=0;
// Now make sure this sp is not already used in a sp. // Now make sure this sp is not already used in a sp.
// Could this be done by having a sp point to the track it is in? // Could this be done by having a sp point to the track it is in?
...@@ -623,7 +637,6 @@ void THcDC::LinkStubs() ...@@ -623,7 +637,6 @@ void THcDC::LinkStubs()
Int_t newtrack=1; Int_t newtrack=1;
for(Int_t isp2=isp1+1;isp2<fNSp;isp2++) { for(Int_t isp2=isp1+1;isp2<fNSp;isp2++) {
THcSpacePoint* sp2=fSp[isp2]; THcSpacePoint* sp2=fSp[isp2];
if (fdebuglinkstubs) cout << "second Loop space points " << isp2<< endl;
if(sp1->fNChamber!=sp2->fNChamber) { if(sp1->fNChamber!=sp2->fNChamber) {
Double_t *spstub1=sp1->GetStubP(); Double_t *spstub1=sp1->GetStubP();
Double_t *spstub2=sp2->GetStubP(); Double_t *spstub2=sp2->GetStubP();
...@@ -650,7 +663,6 @@ void THcDC::LinkStubs() ...@@ -650,7 +663,6 @@ void THcDC::LinkStubs()
if(TMath::Abs(dposy)<TMath::Abs(stubminy)) stubminy = dposy; if(TMath::Abs(dposy)<TMath::Abs(stubminy)) stubminy = dposy;
if(TMath::Abs(dposxp)<TMath::Abs(stubminxp)) stubminxp = dposxp; if(TMath::Abs(dposxp)<TMath::Abs(stubminxp)) stubminxp = dposxp;
if(TMath::Abs(dposyp)<TMath::Abs(stubminyp)) stubminyp = dposyp; if(TMath::Abs(dposyp)<TMath::Abs(stubminyp)) stubminyp = dposyp;
if (fdebuglinkstubs) printf("dposx = %f ,dposy = %f,dposxp = %f,dposyp = %f \n",dposx,dposy,dposxp,dposyp);
// if hbypass_track_eff_files == 0 then // if hbypass_track_eff_files == 0 then
// Print out each stubminX that is less that its criterion // Print out each stubminX that is less that its criterion
...@@ -660,7 +672,6 @@ void THcDC::LinkStubs() ...@@ -660,7 +672,6 @@ void THcDC::LinkStubs()
&& (TMath::Abs(dposxp) < fXptTrCriterion) && (TMath::Abs(dposxp) < fXptTrCriterion)
&& (TMath::Abs(dposyp) < fYptTrCriterion)) { && (TMath::Abs(dposyp) < fYptTrCriterion)) {
if(newtrack) { if(newtrack) {
if (fdebuglinkstubs) cout << " new track" << endl;
assert(sptracks==0); assert(sptracks==0);
//stubtest=1; Used in h_track_tests.f //stubtest=1; Used in h_track_tests.f
// Make a new track if there are not to many // Make a new track if there are not to many
...@@ -670,8 +681,6 @@ void THcDC::LinkStubs() ...@@ -670,8 +681,6 @@ void THcDC::LinkStubs()
THcDCTrack *theDCTrack = new( (*fDCTracks)[fNDCTracks++]) THcDCTrack(fNPlanes); THcDCTrack *theDCTrack = new( (*fDCTracks)[fNDCTracks++]) THcDCTrack(fNPlanes);
theDCTrack->AddSpacePoint(sp1); theDCTrack->AddSpacePoint(sp1);
theDCTrack->AddSpacePoint(sp2); theDCTrack->AddSpacePoint(sp2);
if (fdebuglinkstubs) cout << " # sp pts combined = " << theDCTrack->GetNSpacePoints() << endl;
if (fdebuglinkstubs) cout << " combine sp = " << isp1 << " and " << isp2 << endl;
// Now save the X, Y and XP for the two stubs // Now save the X, Y and XP for the two stubs
// in arrays hx_sp1, hy_sp1, hy_sp1, ... hxp_sp2 // in arrays hx_sp1, hy_sp1, hy_sp1, ... hxp_sp2
// Why not also YP? // Why not also YP?
...@@ -679,14 +688,12 @@ void THcDC::LinkStubs() ...@@ -679,14 +688,12 @@ void THcDC::LinkStubs()
newtrack = 0; // Make no more tracks in this loop newtrack = 0; // Make no more tracks in this loop
// (But could replace a SP?) // (But could replace a SP?)
} else { } else {
if (fdebuglinkstubs) cout << "EPIC FAIL 1: Too many tracks found in THcDC::LinkStubs" << endl; if (fHMSStyleChambers) {
fNDCTracks=0; fNDCTracks=0;
// Do something here to fail this event
return; return;
}
} }
} else { } else {
if (fdebuglinkstubs) cout << " check if another space point in same chamber sptracks= " << sptracks << endl;
// Check if there is another space point in the same chamber // Check if there is another space point in the same chamber
for(Int_t itrack=0;itrack<sptracks;itrack++) { for(Int_t itrack=0;itrack<sptracks;itrack++) {
Int_t track=stub_tracks[itrack]; Int_t track=stub_tracks[itrack];
...@@ -694,10 +701,8 @@ void THcDC::LinkStubs() ...@@ -694,10 +701,8 @@ void THcDC::LinkStubs()
Int_t spoint=-1; Int_t spoint=-1;
Int_t duppoint=0; Int_t duppoint=0;
if (fdebuglinkstubs) cout << "checking abother sp pt in cham track = " << itrack+1 << " with # sp pts = " << theDCTrack->GetNSpacePoints() << endl;
for(Int_t isp=0;isp<theDCTrack->GetNSpacePoints();isp++) { for(Int_t isp=0;isp<theDCTrack->GetNSpacePoints();isp++) {
// isp is index of space points in theDCTrack // isp is index of space points in theDCTrack
if (fdebuglinkstubs) cout << "looping of previous track = " << isp+1 << endl;
if(sp2->fNChamber == if(sp2->fNChamber ==
theDCTrack->GetSpacePoint(isp)->fNChamber) { theDCTrack->GetSpacePoint(isp)->fNChamber) {
spoint=isp; spoint=isp;
...@@ -715,24 +720,22 @@ void THcDC::LinkStubs() ...@@ -715,24 +720,22 @@ void THcDC::LinkStubs()
// If there is another point in the same chamber // If there is another point in the same chamber
// in this track create a new track with all the // in this track create a new track with all the
// same space points except spoint // same space points except spoint
if(fNDCTracks < MAXTRACKS) { if(fNDCTracks < MAXTRACKS) {
if (fdebuglinkstubs) cout << "found another track, presently # of tracks = " << fNDCTracks << endl;
stub_tracks[sptracks++] = fNDCTracks; stub_tracks[sptracks++] = fNDCTracks;
THcDCTrack *newDCTrack = new( (*fDCTracks)[fNDCTracks++]) THcDCTrack(fNPlanes); THcDCTrack *newDCTrack = new( (*fDCTracks)[fNDCTracks++]) THcDCTrack(fNPlanes);
if (fdebuglinkstubs) cout << "loop over theDCtrack # of sp tps = " << theDCTrack->GetNSpacePoints() << endl;
for(Int_t isp=0;isp<theDCTrack->GetNSpacePoints();isp++) { for(Int_t isp=0;isp<theDCTrack->GetNSpacePoints();isp++) {
if(isp!=spoint) { if(isp!=spoint) {
newDCTrack->AddSpacePoint(theDCTrack->GetSpacePoint(isp)); newDCTrack->AddSpacePoint(theDCTrack->GetSpacePoint(isp));
} else { } else {
newDCTrack->AddSpacePoint(sp2); newDCTrack->AddSpacePoint(sp2);
} // End check for dup on copy } // End check for dup on copy
if (fdebuglinkstubs) cout << "newDCtrack # of sp tps = " << newDCTrack->GetNSpacePoints() << endl;
} // End copy of track } // End copy of track
} else { } else {
if (fdebuglinkstubs) cout << "EPIC FAIL 2: Too many tracks found in THcDC::LinkStubs" << endl; if (fHMSStyleChambers) {
fNDCTracks=0; if (fdebuglinkstubs) cout << "EPIC FAIL 2: Too many tracks found in THcDC::LinkStubs maxtracks = " << MAXTRACKS << endl;
// Do something here to fail this event fNDCTracks=0;
return; // Max # of allowed tracks return; // Max # of allowed tracks
}
} }
} // end if on same chamber } // end if on same chamber
} // end if on duplicate point } // end if on duplicate point
...@@ -743,6 +746,8 @@ void THcDC::LinkStubs() ...@@ -743,6 +746,8 @@ void THcDC::LinkStubs()
} // end isp2 loop over new space points } // end isp2 loop over new space points
} // end test on tryflag } // end test on tryflag
} // end isp1 outer loop over space points } // end isp1 outer loop over space points
//
//
} else { // Make track out of each single space point } else { // Make track out of each single space point
for(Int_t isp=0;isp<fNSp;isp++) { for(Int_t isp=0;isp<fNSp;isp++) {
if(fNDCTracks<MAXTRACKS) { if(fNDCTracks<MAXTRACKS) {
...@@ -758,7 +763,19 @@ void THcDC::LinkStubs() ...@@ -758,7 +763,19 @@ void THcDC::LinkStubs()
} }
} }
/// ///
if (fdebuglinkstubs) cout << " End Linkstubs Found " << fNDCTracks << " tracks"<<endl; if (fdebuglinkstubs) {
cout << " Number of tracks from link stubs = " << fNDCTracks << endl;
printf("%s %s \n","Track","Plane Wire ");
for (Int_t itrack=0;itrack<fNDCTracks;itrack++) {
THcDCTrack *tempTrack = (THcDCTrack*)( fDCTracks->At(itrack));
printf("%-5d ",itrack+1);
for (Int_t ihit=0;ihit<tempTrack->GetNHits();ihit++) {
THcDCHit* hit=(THcDCHit*)(tempTrack->GetHit(ihit));
printf("%3d %3d",hit->GetPlaneNum(),hit->GetWireNum());
}
printf("\n");
}
}
} }
//_____________________________________________________________________________ //_____________________________________________________________________________
...@@ -871,14 +888,6 @@ void THcDC::TrackFit() ...@@ -871,14 +888,6 @@ void THcDC::TrackFit()
theDCTrack->SetResidual(planes[ihit], residual); theDCTrack->SetResidual(planes[ihit], residual);
chi2 += pow(residual/fSigma[planes[ihit]],2); chi2 += pow(residual/fSigma[planes[ihit]],2);
} }
if (fdebugtrackprint) {
cout << "Hit HDC_WIRE_COORD Fit postiion Residual " << endl;
for(Int_t ihit=0;ihit < theDCTrack->GetNHits();ihit++) {
THcDCHit* hit=theDCTrack->GetHit(ihit);
Int_t plane=hit->GetPlaneNum()-1;
cout << ihit+1 << " " << coords[ihit] << " " << theDCTrack->GetCoord(plane) << " " << theDCTrack->GetResidual(plane) << endl;
}
}
theDCTrack->SetVector(dray[0], dray[1], 0.0, dray[2], dray[3]); theDCTrack->SetVector(dray[0], dray[1], 0.0, dray[2], dray[3]);
} }
theDCTrack->SetChisq(chi2); theDCTrack->SetChisq(chi2);
...@@ -971,7 +980,44 @@ void THcDC::TrackFit() ...@@ -971,7 +980,44 @@ void THcDC::TrackFit()
fResiduals[ip] = theDCTrack->GetResidual(ip); fResiduals[ip] = theDCTrack->GetResidual(ip);
} }
} }
// print tracks if hdebugtrackprint is on //
if (fdebugtrackprint) {
printf("%5s %-14s %-14s %-14s %-14s %-10s %-10s \n","Track","x_t","y_t","xp_t","yp_t","chi2","DOF");
printf("%5s %-14s %-14s %-14s %-14s %-10s %-10s \n"," ","[cm]","[cm]","[rad]","[rad]"," "," ");
for(Int_t itr=0;itr < fNDCTracks;itr++) {
THcDCTrack *theDCTrack = static_cast<THcDCTrack*>( fDCTracks->At(itr));
printf("%-5d %14.6e %14.6e %14.6e %14.6e %10.3e %3d \n", itr+1,theDCTrack->GetX(),theDCTrack->GetY(),theDCTrack->GetXP(),theDCTrack->GetYP(),theDCTrack->GetChisq(),theDCTrack->GetNFree());
}
for(Int_t itr=0;itr < fNDCTracks;itr++) {
printf("%s %5d \n","Hit info for track number = ",itr+1);
printf("%5s %-15s %-15s %-15s \n","Plane","WIRE_COORD","Fit postiion","Residual");
THcDCTrack *theDCTrack = static_cast<THcDCTrack*>( fDCTracks->At(itr));
for(Int_t ihit=0;ihit < theDCTrack->GetNHits();ihit++) {
THcDCHit* hit=theDCTrack->GetHit(ihit);
Int_t plane=hit->GetPlaneNum()-1;
Double_t coords_temp;
if(fFixLR) {
if(fFixPropagationCorrection) {
coords_temp = hit->GetPos()
+ theDCTrack->GetHitLR(ihit)*theDCTrack->GetHitDist(ihit);
} else {
coords_temp = hit->GetPos()
+ theDCTrack->GetHitLR(ihit)*hit->GetDist();
}
} else {
if(fFixPropagationCorrection) {
coords_temp = hit->GetPos()
+ hit->GetLR()*theDCTrack->GetHitDist(ihit);
} else {
coords_temp = hit->GetCoord();
}
}
printf("%-5d %15.7e %15.7e %15.7e \n",plane+1,coords_temp,theDCTrack->GetCoord(plane),theDCTrack->GetResidual(plane));
}
}
}
//
} }
Double_t THcDC::DpsiFun(Double_t ray[4], Int_t plane) Double_t THcDC::DpsiFun(Double_t ray[4], Int_t plane)
{ {
......
...@@ -77,6 +77,8 @@ public: ...@@ -77,6 +77,8 @@ public:
protected: protected:
Int_t fdebuglinkstubs; Int_t fdebuglinkstubs;
Int_t fdebugprintrawdc; Int_t fdebugprintrawdc;
Int_t fdebugflagpr;
Int_t fdebugflagstubs;
Int_t fdebugtrackprint; Int_t fdebugtrackprint;
Int_t fdebugprintdecodeddc; Int_t fdebugprintdecodeddc;
Int_t fHMSStyleChambers; Int_t fHMSStyleChambers;
...@@ -172,6 +174,7 @@ protected: ...@@ -172,6 +174,7 @@ protected:
void Setup(const char* name, const char* description); void Setup(const char* name, const char* description);
void PrintSpacePoints(); void PrintSpacePoints();
void PrintStubs();
ClassDef(THcDC,0) // Set of Drift Chambers detector ClassDef(THcDC,0) // Set of Drift Chambers detector
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment