diff --git a/src/THcDC.cxx b/src/THcDC.cxx index 07eb1c6c3534741db4816b3df667b231e25018f9..26163a942b568ceab8363c9f9e9a61b07469e547 100644 --- a/src/THcDC.cxx +++ b/src/THcDC.cxx @@ -404,6 +404,7 @@ Int_t THcDC::CoarseTrack( TClonesArray& /* tracks */ ) for(Int_t i=0;i<fNChambers;i++) { fChambers[i]->FindSpacePoints(); + fChambers[i]->CorrectHitTimes(); } ApplyCorrections(); diff --git a/src/THcDC.h b/src/THcDC.h index d73491b49572d829720744d6f038eda2db06e7f0..aac69980c7ea9708e8b71e14d59ae4aa339acd5f 100644 --- a/src/THcDC.h +++ b/src/THcDC.h @@ -52,6 +52,8 @@ public: Int_t GetMaxHits(Int_t chamber) const { return fMaxHits[chamber-1];} Int_t GetMinCombos(Int_t chamber) const { return fMinCombos[chamber-1];} Double_t GetSpacePointCriterion(Int_t chamber) const { return TMath::Sqrt(fSpace_Point_Criterion2[chamber-1]);} + Double_t GetCentralTime(Int_t plane) const { return fCentralTime[plane-1];} + Int_t GetDriftTimeSign(Int_t plane) const { return fDriftTimeSign[plane-1];} Double_t GetPlaneTimeZero(Int_t plane) const { return fPlaneTimeZero[plane-1];} diff --git a/src/THcDriftChamber.cxx b/src/THcDriftChamber.cxx index 1a77d4d7f230f59aaed0cc5349e44412130cb4dc..fe2a9c51b85acfeb08b7e1a5baeacda44aec3a99 100644 --- a/src/THcDriftChamber.cxx +++ b/src/THcDriftChamber.cxx @@ -119,6 +119,7 @@ Int_t THcDriftChamber::ReadDatabase( const TDatime& date ) prefix[1]='\0'; DBRequest list[]={ {"_remove_sppt_if_one_y_plane",&fRemove_Sppt_If_One_YPlane, kInt}, + {"dc_wire_velocity", &fWireVelocity, kDouble}, {0} }; gHcParms->LoadParmValues((DBRequest*)&list,prefix); @@ -709,20 +710,36 @@ void THcDriftChamber::SelectSpacePoints() fNSpacePoints = sp_count; } -/* -* -* Now we know rough hit positions in the chambers so we can make -* wire velocity drift time corrections for each hit in the space point -* -* Assume all wires for a plane are read out on the same side (l/r or t/b). -* If the wire is closer to horizontal, read out left/right. If nearer -* vertical, assume top/bottom. (Note, this is not always true for the -* SOS u and v planes. They have 1 card each on the side, but the overall -* time offset per card will cancel much of the error caused by this. The -* alternative is to check by card, rather than by plane and this is harder. -*/ - - +void THcDriftChamber::CorrectHitTimes() +{ + // Use the rough hit positions in the chambers to correct the drift time + // for hits in the space points. + + // Assume all wires for a plane are read out on the same side (l/r or t/b). + // If the wire is closer to horizontal, read out left/right. If nearer + // vertical, assume top/bottom. (Note, this is not always true for the + // SOS u and v planes. They have 1 card each on the side, but the overall + // time offset per card will cancel much of the error caused by this. The + // alternative is to check by card, rather than by plane and this is harder. + for(Int_t isp=0;isp<fNSpacePoints;isp++) { + Double_t x = fSpacePoints[isp].x; + Double_t y = fSpacePoints[isp].y; + for(Int_t ihit=0;ihit<fSpacePoints[isp].nhits;ihit++) { + THcDCHit* hit = fSpacePoints[isp].hits[ihit]; + THcDriftChamberPlane* plane=hit->GetWirePlane(); + + // How do we know this correction only gets applied once? Is + // it determined that a given hit can only belong to one space point? + Double_t time_corr = plane->GetReadoutX() ? + fSpacePoints[isp].y*plane->GetReadoutCorr()/fWireVelocity : + fSpacePoints[isp].x*plane->GetReadoutCorr()/fWireVelocity; + + hit->SetTime(hit->GetTime() + - plane->GetCentralTime() + plane->GetDriftTimeSign()*time_corr); + hit->ConvertTimeToDist(); + } + } +} //_____________________________________________________________________________ THcDriftChamber::~THcDriftChamber() { diff --git a/src/THcDriftChamber.h b/src/THcDriftChamber.h index 96c293c0fbe4c6a7600a712c3a907a804cc0413f..0e7b6442d9a073aa44db9850c207f1a070de0651 100644 --- a/src/THcDriftChamber.h +++ b/src/THcDriftChamber.h @@ -33,6 +33,7 @@ public: virtual Int_t ApplyCorrections( void ); virtual void ProcessHits( void ); virtual Int_t FindSpacePoints( void ) ; + virtual void CorrectHitTimes( void ) ; virtual void Clear( Option_t* opt="" ); @@ -66,6 +67,7 @@ protected: Int_t fMaxHits; // Maximum required to do something Int_t fMinCombos; // Minimum # pairs in a space point Int_t fRemove_Sppt_If_One_YPlane; + Double_t fWireVelocity; Double_t fXCenter; Double_t fYCenter; diff --git a/src/THcDriftChamberPlane.cxx b/src/THcDriftChamberPlane.cxx index b23cfe21c160216f272ab7c3abd6cf807802dc2d..8c63c5d9b3a03d385d6bc14c9938776c23e385d0 100644 --- a/src/THcDriftChamberPlane.cxx +++ b/src/THcDriftChamberPlane.cxx @@ -110,6 +110,8 @@ Int_t THcDriftChamberPlane::ReadDatabase( const TDatime& date ) fTdcWinMax = fParent->GetTdcWinMax(fPlaneNum); fPlaneTimeZero = fParent->GetPlaneTimeZero(fPlaneNum); fCenter = fParent->GetCenter(fPlaneNum); + fCentralTime = fParent->GetCentralTime(fPlaneNum); + fDriftTimeSign = fParent->GetDriftTimeSign(fPlaneNum); fNSperChan = fParent->GetNSperChan(); @@ -133,6 +135,14 @@ Int_t THcDriftChamberPlane::ReadDatabase( const TDatime& date ) Double_t hychi = sinalpha*cosgamma; Double_t hypsi = cosalpha*cosgamma; + if(cosalpha <= 0.707) { // x-like wire, need dist from x=0 line + fReadoutX = 1; + fReadoutCorr = 1/sinalpha; + } else { + fReadoutX = 0; + fReadoutCorr = 1/cosalpha; + } + Double_t sumsqupsi = hzpsi*hzpsi+hxpsi*hxpsi+hypsi*hypsi; Double_t sumsquchi = hzchi*hzchi+hxchi*hxchi+hychi*hychi; Double_t sumcross = hzpsi*hzchi + hxpsi*hxchi + hypsi*hychi; diff --git a/src/THcDriftChamberPlane.h b/src/THcDriftChamberPlane.h index 78faf37fefb33635e0c8ac1546c2ea9caf34abe2..e81c9ee5730e37a24169974bbea53fd405c0e0fc 100644 --- a/src/THcDriftChamberPlane.h +++ b/src/THcDriftChamberPlane.h @@ -57,6 +57,10 @@ class THcDriftChamberPlane : public THaSubDetector { Int_t GetPlaneIndex() { return fPlaneIndex; } Double_t GetXsp() const { return fXsp; } Double_t GetYsp() const { return fYsp; } + Int_t GetReadoutX() { return fReadoutX; } + Double_t GetReadoutCorr() { return fReadoutCorr; } + Double_t GetCentralTime() { return fCentralTime; } + Int_t GetDriftTimeSign() { return fDriftTimeSign; } protected: @@ -78,6 +82,11 @@ class THcDriftChamberPlane : public THaSubDetector { Double_t fXsp; Double_t fYsp; + Int_t fReadoutX; + Double_t fReadoutCorr; + Double_t fCentralTime; + Int_t fDriftTimeSign; + Double_t fCenter; Double_t fNSperChan; /* TDC bin size */