40 const char* name,
const char* description,
210 if(ipm1==ipm2 && ipm1<
fNPlanes)
continue;
212 for(
Int_t i=0;i<3;i++) {
213 for(
Int_t j=i;j<3;j++) {
216 if(ipm1 != ip && ipm2 != ip) {
220 AA3[j][i] = AA3[i][j];
223 Int_t bitpat = allplanes & ~(1<<ipm1) & ~(1<<ipm2);
246 {
"maxhits",
"Maximum hits allowed",
"fMaxHits" },
247 {
"spacepoints",
"Space points of DC",
"fNSpacePoints" },
248 {
"nhit",
"Number of DC hits",
"fNhits" },
249 {
"trawhit",
"Number of True Raw hits",
"fN_True_RawHits" },
250 {
"sp_nhits",
"",
"fSpacePoints.THcSpacePoint.GetNHits()" },
251 {
"stub_x",
"",
"fSpacePoints.THcSpacePoint.GetStubX()" },
252 {
"stub_xp",
"",
"fSpacePoints.THcSpacePoint.GetStubXP()" },
253 {
"stub_y",
"",
"fSpacePoints.THcSpacePoint.GetStubY()" },
254 {
"stub_yp",
"",
"fSpacePoints.THcSpacePoint.GetStubYP()" },
255 {
"ncombos",
"",
"fSpacePoints.THcSpacePoint.GetCombos()" },
256 {
"U_pos",
"",
"fUPlaneClusters.THcDCPlaneCluster.GetX()" },
257 {
"X_pos",
"",
"fXPlaneClusters.THcDCPlaneCluster.GetX()" },
258 {
"V_pos",
"",
"fVPlaneClusters.THcDCPlaneCluster.GetX()" },
259 {
"UX_posx",
"",
"fUXPlaneClusters.THcDCPlaneCluster.GetX()" },
260 {
"UX_posy",
"",
"fUXPlaneClusters.THcDCPlaneCluster.GetY()" },
261 {
"VX_posx",
"",
"fVXPlaneClusters.THcDCPlaneCluster.GetX()" },
262 {
"VX_posy",
"",
"fVXPlaneClusters.THcDCPlaneCluster.GetY()" },
267 std::vector<RVarDef> ve;
268 ve.push_back( {
"sphit",
"",
"fSpHit.SpNHits" });
269 ve.push_back( {
"sphit_index",
"",
"fSpHit.SpHitIndex" });
296 cout <<
" Num of nits = " <<
fNhits << endl;
297 cout <<
" Num " <<
" Plane " <<
" Wire " <<
" Wire-Center " <<
" RAW TDC " <<
" Drift time" << endl;
316 if (
fhdebugflagpr) cout <<
" in newfindspacepoints " << endl;
328 if (idx >= 0 && idx < 6) {
336 cout << ihit1 <<
" " << hit1->
GetPos()<<
" " << ihit2 <<
" " << hit2->
GetPos() <<
" "
349 cout <<
" No match found" << endl;
351 if (idx >= 0 && idx < 6) {
358 cout << ihit1 <<
" " << hit1->
GetPos()<<
" " << plane1->
GetYsp()<<
" " << plane1->
GetXsp()<< endl;
370 cout <<
" nc = " << nc <<
" nhits = " << clus->
GetNHits() << endl;
375 cout <<
" nc = " << nc <<
" nhits = " << clus->
GetNHits()<< endl;
380 cout <<
" nc = " << nc <<
" nhits = " << clus->
GetNHits()<< endl;
452 cout <<
" nc = " << nc <<
" nhits = " << clus->
GetNHits() << endl;
457 cout <<
" nc = " << nc <<
" nhits = " << clus->
GetNHits()<< endl;
461 vector <THcDCHit*> UX_uHits;
462 vector <THcDCHit*> UX_xHits;
463 vector <THcDCHit*> VX_vHits;
464 vector <THcDCHit*> VX_xHits;
489 if (
fhdebugflagpr) cout <<
" vx_xhits = " << VX_xHits.size() <<
" ux_xhits = "<< UX_xHits.size() << endl;
490 if (VX_xHits.size() == UX_xHits.size() && UX_xHits.size()==1) {
491 if (VX_xHits[0] == UX_xHits[0]) Xhits_match =
kTRUE;
492 }
else if (VX_xHits.size() == UX_xHits.size() && UX_xHits.size()==2) {
493 if (VX_xHits[0] == UX_xHits[0] && VX_xHits[1] == UX_xHits[1]) Xhits_match =
kTRUE;
494 if (VX_xHits[0] == UX_xHits[1] && VX_xHits[1] == UX_xHits[0]) Xhits_match =
kTRUE;
496 if (
fhdebugflagpr) cout <<
" Xhits_match = " << Xhits_match <<
" dist2 = " << dist2 <<
" spcrit = " <<
fSpacePointCriterion <<
" VX_x " << vx_posx<<
" UX_x " << ux_posx<<
" VX_y " << vx_posy<<
" UX_y " << ux_posy << endl;
497 Int_t TotHits = UX_uHits.size()+UX_xHits.size()+VX_vHits.size();
498 if (dist2 <= fSpacePointCriterion && Xhits_match && TotHits>=
fMinHits) {
502 Double_t xt = (ux_posx + vx_posx)/2.;
503 Double_t yt = (ux_posy + vx_posy)/2.;
506 for (
UInt_t ih=0;ih<UX_uHits.size();ih++) { sp->
AddHit(UX_uHits[ih]);}
507 for (
UInt_t ih=0;ih<UX_xHits.size();ih++) { sp->
AddHit(UX_xHits[ih]);}
508 for (
UInt_t ih=0;ih<VX_vHits.size();ih++) { sp->
AddHit(VX_vHits[ih]);}
572 if (
fhdebugflagpr) cout <<
" In old findspacepoint " << endl;
575 Int_t plane_hitind=0;
576 Int_t planep_hitind=0;
590 Int_t PlaneInd=0,PlanePInd=0;
599 &&
pow( (
fHits[plane_hitind]->GetPos() -
fHits[planep_hitind]->GetPos()),2)
619 if (nadded)
if (
fhdebugflagpr) cout << nadded <<
" Space Points added with SpacePointMultiWire()" << endl;
657 Int_t easy_space_point=0;
665 if(ihit!=yplane_hitind && ihit!=yplanep_hitind) {
667 x_pos[ihit] = (thishit->
GetPos()
676 xt = (num_xhits>0?xt/num_xhits:0.0);
677 easy_space_point = 1;
680 if(ihit!=yplane_hitind && ihit!=yplanep_hitind) {
682 { easy_space_point=0;
break;}
685 if(easy_space_point) {
694 return(easy_space_point);
708 Int_t easy_space_point=0;
716 if(ihit!=xplane_hitind && ihit!=xplanep_hitind) {
718 y_pos[ihit] = (thishit->
GetPos()
727 yt = (num_yhits>0?yt/num_yhits:0.0);
728 easy_space_point = 1;
731 if(ihit!=xplane_hitind && ihit!=xplanep_hitind) {
733 { easy_space_point=0;
break;}
736 if(easy_space_point) {
745 return(easy_space_point);
752 Int_t MAX_NUMBER_PAIRS=1000;
758 Pair pairs[MAX_NUMBER_PAIRS];
760 Int_t ntest_points=0;
765 if(ntest_points < MAX_NUMBER_PAIRS) {
771 pairs[ntest_points].hit1 = hit1;
772 pairs[ntest_points].hit2 = hit2;
773 pairs[ntest_points].x = (hit1->
GetPos()*plane2->
GetYsp()
776 pairs[ntest_points].y = (hit2->
GetPos()*plane1->
GetXsp()
789 Combo combos[10*MAX_NUMBER_PAIRS];
790 for(
Int_t ipair1=0;ipair1<ntest_points-1;ipair1++) {
791 for(
Int_t ipair2=ipair1+1;ipair2<ntest_points;ipair2++) {
792 if(ncombos < 10*MAX_NUMBER_PAIRS) {
794 +
pow(pairs[ipair1].
y - pairs[ipair2].
y,2);
796 combos[ncombos].pair1 = &pairs[ipair1];
797 combos[ncombos].pair2 = &pairs[ipair2];
805 for(
Int_t icombo=0;icombo<ncombos;icombo++) {
807 hits[0]=combos[icombo].pair1->hit1;
808 hits[1]=combos[icombo].pair1->hit2;
809 hits[2]=combos[icombo].pair2->hit1;
810 hits[3]=combos[icombo].pair2->hit2;
812 Double_t xt = (combos[icombo].pair1->x + combos[icombo].pair2->x)/2.0;
813 Double_t yt = (combos[icombo].pair1->y + combos[icombo].pair2->y)/2.0;
831 iflag[0]=0;iflag[1]=0;iflag[2]=0;iflag[3]=0;
836 for(
Int_t icm_hit=0;icm_hit<4;icm_hit++) {
837 if(sp->
GetHit(isp_hit)==hits[icm_hit]) {
844 for(
Int_t icm1=0;icm1<3;icm1++) {
845 for(
Int_t icm2=icm1+1;icm2<4;icm2++) {
846 if(hits[icm1]==hits[icm2]) {
852 for(
Int_t icm=0;icm<4;icm++) {
874 if(hits[0] != hits[2] && hits[1] != hits[2]) {
877 if(hits[0] != hits[3] && hits[1] != hits[3]) {
891 if(hits[0] != hits[2] && hits[1] != hits[2]) {
894 if(hits[0] != hits[3] && hits[1] != hits[3]) {
914 spacepointsgood[i] = 0;
917 Int_t nplanes_hit = 0;
919 nhitsperplane[ip] = 0;
931 if(nhitsperplane[ip] > 0) {
937 spacepointsgood[ngood++] = isp;
947 Int_t osp=spacepointsgood[isp];
994 for(
Int_t isp=0;isp<nsp_totl;isp++) {
995 Int_t nplanes_hit = 0;
996 Int_t nplanes_mult = 0;
1002 nhitsperplane[ip] = 0;
1004 hits_plane[ip][ih] = 0;
1014 hits_plane[ip][nhitsperplane[ip]++] = hit;
1018 if(nhitsperplane[ip] > 0) {
1020 nsp_new *= nhitsperplane[ip];
1021 if(nhitsperplane[ip] > 1) nplanes_mult++;
1026 nsp_check=nsp_tot + nsp_new;
1031 if(nplanes_hit >= 4 && nplanes_mult < 4 && nplanes_mult >0
1032 && nsp_check < 20) {
1043 if(nhitsperplane[maxplane[ip2]] > nhitsperplane[maxplane[ip1]]) {
1044 Int_t temp = maxplane[ip1];
1045 maxplane[ip1] = maxplane[ip2];
1046 maxplane[ip2] = temp;
1051 for(
Int_t n1=0;n1<nhitsperplane[maxplane[0]];n1++) {
1052 for(
Int_t n2=0;n2<nhitsperplane[maxplane[1]];n2++) {
1053 for(
Int_t n3=0;n3<nhitsperplane[maxplane[2]];n3++) {
1058 if(n1==0 && n2==0 && n3==0) {
1068 newsp->
AddHit(hits_plane[maxplane[0]][n1]);
1069 newsp->
AddHit(hits_plane[maxplane[1]][n2]);
1070 newsp->
AddHit(hits_plane[maxplane[2]][n3]);
1071 newsp->
AddHit(hits_plane[maxplane[3]][0]);
1072 if(nhitsperplane[maxplane[4]] == 1) {
1073 newsp->
AddHit(hits_plane[maxplane[4]][0]);
1074 if(nhitsperplane[maxplane[5]] == 1)
1075 newsp->
AddHit(hits_plane[maxplane[5]][0]);
1085 newsp->
AddHit(hits_plane[maxplane[0]][n1]);
1086 newsp->
AddHit(hits_plane[maxplane[1]][n2]);
1087 newsp->
AddHit(hits_plane[maxplane[2]][n3]);
1088 newsp->
AddHit(hits_plane[maxplane[3]][0]);
1089 if(nhitsperplane[maxplane[4]] == 1) {
1090 newsp->
AddHit(hits_plane[maxplane[4]][0]);
1091 if(nhitsperplane[maxplane[5]] == 1)
1092 newsp->
AddHit(hits_plane[maxplane[5]][0]);
1101 nsp_tot += (ntot-1);
1106 assert (nsp_tot > 0);
1129 Int_t goodhit[startnum];
1130 for(
Int_t ihit=0;ihit<startnum;ihit++) {
1134 for(
Int_t ihit1=0;ihit1<startnum-1;ihit1++) {
1138 for(
Int_t ihit2=ihit1+1;ihit2<startnum;ihit2++) {
1142 if(plane1 == plane2) {
1143 if(tdrift1 > tdrift2) {
1153 for(
Int_t ihit=0;ihit<startnum;ihit++) {
1154 if(goodhit[ihit] > 0) {
1155 if (ihit > finalnum) {
1184 if(isp > sp_count) {
1255 double alpha =
static_cast<THcDC*
>(
fParent)->GetAlphaAngle(pln);
1264 switch (readoutSide){
1266 if (
x>xc){wireDistance = -readvert*wireDistance;}
1267 else{wireDistance = readvert*wireDistance;}
1271 if (
y>yc){wireDistance = -readhoriz*wireDistance;}
1272 else{wireDistance = readhoriz*wireDistance;}
1276 if (xc>
x){wireDistance= -readvert*wireDistance;}
1277 else{wireDistance = readvert*wireDistance;}
1281 if(yc>
y){wireDistance = -readhoriz*wireDistance;}
1282 else{wireDistance = readhoriz*wireDistance;}
1347 x =
x - ((
x >> 1) & 0x55555555);
1348 x = (
x & 0x33333333) + ((
x >> 2) & 0x33333333);
1349 return (((
x + (
x >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
1372 Int_t plusminusknown[nhits];
1373 Int_t plusminusbest[nhits];
1374 Int_t plusminus[nhits];
1375 Int_t tmp_plusminus[nhits];
1376 Int_t plane_list[nhits];
1382 if (
fhdebugflagpr) cout <<
"THcDriftChamber::LeftRight() nhits < 0" << endl;
1383 }
else if (nhits==0) {
1384 if (
fhdebugflagpr) cout <<
"THcDriftChamber::LeftRight() nhits = 0" << endl;
1386 for(
Int_t ihit=0;ihit < nhits;ihit++) {
1389 plane_list[ihit] = pindex;
1391 bitpat |= 1<<pindex;
1393 plusminusknown[ihit] = 0;
1398 nplusminus = 1<<nhits;
1400 Int_t smallAngOK = (hasy1>=0) && (hasy2>=0);
1405 plusminusknown[hasy1] = -1;
1406 plusminusknown[hasy2] = 1;
1408 plusminusknown[hasy1] = 1;
1409 plusminusknown[hasy2] = -1;
1411 nplusminus = 1<<(nhits-2);
1420 for(
Int_t ihit1=0;ihit1 < nhits;ihit1++) {
1423 if((pindex1%2)==0) {
1424 for(
Int_t ihit2=0;ihit2<nhits;ihit2++) {
1428 plusminusknown[ihit1] = -1;
1429 plusminusknown[ihit2] = 1;
1431 plusminusknown[ihit1] = 1;
1432 plusminusknown[ihit2] = -1;
1439 nplusminus = 1 << (nhits-npaired);
1443 if (
fdebugstubchisq) cout <<
"THcDriftChamber::LeftRight: numhits-2 < 0" << endl;
1444 }
else if (nhits == 2) {
1445 if (
fdebugstubchisq) cout <<
"THcDriftChamber::LeftRight: numhits-2 = 0" << endl;
1448 if (
fhdebugflagpr) cout <<
" num of pm = " << nplusminus <<
" num of hits =" << nhits << endl;
1451 for(
Int_t pmloop=0;pmloop<nplusminus;pmloop++) {
1453 for(
Int_t ihit=0;ihit<nhits;ihit++) {
1454 if(plusminusknown[ihit]!=0) {
1455 plusminus[ihit] = plusminusknown[ihit];
1458 if(pmloop & iswhit) {
1459 plusminus[ihit] = 1;
1461 plusminus[ihit] = -1;
1468 chi2 =
FindStub(nhits, sp,plane_list, bitpat, plusminus, stub);
1469 if (
fdebugstubchisq) cout <<
" pmloop = " << pmloop <<
" chi2 = " << chi2 << endl;
1470 if(chi2 < minchi2) {
1477 if(stub[2]*
fTanBeta[plane_list[0]]==-1.0) {
1478 if (
fhdebugflagpr) cout <<
"THcDriftChamber::LeftRight() Error 3" << endl;
1481 /(1+stub[2]*
fTanBeta[plane_list[0]]);
1485 for(
Int_t ihit=0;ihit<nhits;ihit++) {
1486 plusminusbest[ihit] = plusminus[ihit];
1490 if (chi2 < tmp_minchi2) {
1492 for(
Int_t ihit=0;ihit<nhits;ihit++) {
1493 tmp_plusminus[ihit] = plusminus[ihit];
1495 for(
Int_t i=0;i<4;i++) {
1496 tmp_stub[i] = stub[i];
1502 for(
Int_t ihit=0;ihit<nhits;ihit++) {
1503 plusminusbest[ihit] = plusminus[ihit];
1512 if (
fhdebugflagpr) cout <<
"pmloop=" << pmloop <<
" Chi2=" << chi2 << endl;
1514 if(stub[2]*
fTanBeta[plane_list[0]] == -1.0) {
1515 if (
fhdebugflagpr) cout <<
"THcDriftChamber::LeftRight() Error 3" << endl;
1518 /(1+stub[2]*
fTanBeta[plane_list[0]]);
1522 for(
Int_t ihit=0;ihit<nhits;ihit++) {
1523 plusminusbest[ihit] = plusminus[ihit];
1528 if (
fhdebugflagpr) cout <<
"Insufficient planes hit in THcDriftChamber::LeftRight()" << bitpat <<endl;
1532 if (minchi2 == maxchi2 && tmp_minchi2 == maxchi2) {
1535 if(minchi2 == maxchi2 ) {
1536 minchi2 = tmp_minchi2;
1537 for(
Int_t ihit=0;ihit<nhits;ihit++) {
1538 plusminusbest[ihit] = tmp_plusminus[ihit];
1546 for(
Int_t ihit=0; ihit<nhits; ihit++) {
1550 sp->
SetHitLR(ihit, plusminusbest[ihit]);
1555 Int_t pindex=plane_list[0];
1556 if(spstub[2] -
fTanBeta[pindex] == -1.0) {
1557 if (
fhdebugflagpr) cout <<
"THcDriftChamber::LeftRight(): stub3 error" << endl;
1559 stub[2] = (spstub[2] -
fTanBeta[pindex])
1560 / (1.0 + spstub[2]*
fTanBeta[pindex]);
1562 if (
fhdebugflagpr) cout <<
"THcDriftChamber::LeftRight(): stub4 error" << endl;
1566 stub[0] = spstub[0]*
fCosBeta[pindex]
1567 - spstub[0]*stub[2]*
fSinBeta[pindex];
1569 - spstub[1]*stub[3]*
fSinBeta[pindex];
1571 if (
fhdebugflagpr) cout <<
" Left/Right space pt " << isp+1 <<
" " << stub[0]<<
" " << stub[1] <<
" " << stub[2]<<
" " << stub[3] << endl;
1590 for(
Int_t ihit=0;ihit<nhits; ihit++) {
1593 -
fPsi0[plane_list[ihit]];
1596 /
fSigma[plane_list[ihit]];
1612 for(
Int_t ihit=0;ihit<nhits; ihit++) {
1613 chi2 +=
pow( dpos[ihit]/
fSigma[plane_list[ihit]]
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void xpos
Option_t Option_t TPoint TPoint const char mode
ClassImp(VDC::AnalyticTTDConv) using namespace std
#define MAX_HITS_PER_POINT
R__EXTERN class THcParmList * gHcParms
char * Form(const char *fmt,...)
void Clear(Option_t *option="") override
void Delete(Option_t *option="") override
TObject * ConstructedAt(Int_t idx)
static Int_t DefineVarsFromList(const void *list, EType type, EMode mode, const char *def_prefix, const TObject *obj, const char *prefix, const char *here, const char *comment_subst="")
THaDetectorBase * GetParent() const
THaApparatus * GetApparatus() const
Drift chamber wire hit info.
Int_t GetPlaneNum() const
virtual Double_t ConvertTimeToDist()
void SetDist(Double_t dist)
void SetLeftRight(Int_t lr)
void SetTime(Double_t time)
Int_t GetNPlaneClust() const
THcDriftChamberPlane * GetWirePlane() const
Int_t GetPlaneIndex() const
Class for clusters in the same orientation planes (V,X or U)
void AddHit(THcDCHit *hit)
THcDCHit * GetHit(Int_t ihit)
void SetXY(Double_t x, Double_t y)
Analyze a package of horizontal drift chambers.
Class for a a single Hall C horizontal drift chamber plane.
Double_t GetReadoutCorr()
Int_t GetReadoutTB() const
Int_t GetReadoutLR() const
Double_t GetCentralTime()
void SetPlaneIndex(Int_t index)
Int_t GetPlaneNum() const
Subdetector class for a single drift chamber with several planes.
Int_t fRemove_Sppt_If_One_YPlane
std::map< int, TMatrixD > fAA3Inv
SpacePointHitOutputData fSpHit
virtual Int_t DefineVariables(EMode mode=kDefine)
virtual void ProcessHits(void)
Int_t SpacePointMultiWire(void)
Int_t DestroyPoorSpacePoints(void)
TClonesArray * fTrackProj
TClonesArray * fVPlaneClusters
Int_t FindEasySpacePoint_SOS(Int_t xplane_hitind, Int_t xplanep_hitind)
Int_t FindEasySpacePoint_HMS(Int_t yplane_hitind, Int_t yplanep_hitind)
TClonesArray * fUXPlaneClusters
virtual void PrintDecode(void)
virtual void CorrectHitTimes(void)
std::vector< THcDCHit * > fHits
virtual Int_t ApplyCorrections(void)
TClonesArray * fSpacePoints
Int_t fFixPropagationCorrection
std::vector< THcDriftChamberPlane * > fPlanes
Int_t FindHardSpacePoints(void)
virtual Int_t Decode(const THaEvData &)
void ChooseSingleHit(void)
virtual Int_t NewFindSpacePoints(void)
UInt_t Count1Bits(UInt_t x)
virtual Int_t FindSpacePoints(void)
void Setup(const char *name, const char *description)
virtual void Clear(Option_t *opt="")
Double_t fRatio_xpfp_to_xfp
THaDetectorBase * fParent
TClonesArray * fUPlaneClusters
TClonesArray * fXPlaneClusters
TClonesArray * fVXPlaneClusters
virtual void AddPlane(THcDriftChamberPlane *plane)
virtual ~THcDriftChamber()
virtual void LeftRight(void)
void SelectSpacePoints(void)
virtual Int_t ReadDatabase(const TDatime &date)
Double_t fSpacePointCriterion
Double_t FindStub(Int_t nhits, THcSpacePoint *sp, Int_t *plane_list, UInt_t bitpat, Int_t *plusminus, Double_t *stub)
Int_t LoadParmValues(const DBRequest *list, const char *prefix="")
Retrieve parameter values from the parameter cache.
Class representing a single hit DC.
void SetHitLR(Int_t ihit, Int_t lr)
void SetStub(Double_t stub[4])
void SetCombos(Int_t ncombos)
void SetNHits(Int_t nhits)
void SetXY(Double_t x, Double_t y)
void AddHit(THcDCHit *hit)
THcDCHit * GetHit(Int_t ihit)
void ReplaceHit(Int_t ihit, THcDCHit *hit)
Double_t GetHitDist(Int_t ihit)
void Clear(Option_t *opt="")
void SetHitDist(Int_t ihit, Double_t dist)
TMatrixT< Element > & Invert(Double_t *det=nullptr)
const char * GetName() const override
const char * GetTitle() const override
TObject * At(Int_t idx) const override
const TVectorT< Element > & Use(const TVectorT< Element > &v) const
RVec< PromoteType< T > > abs(const RVec< T > &v)
RVec< PromoteTypes< T0, T1 > > pow(const RVec< T0 > &v, const T1 &y)
double dist(AxisAngle const &r1, AxisAngle const &r2)
Double_t Sqrt(Double_t x)
std::vector< Int_t > SpHitIndex
std::vector< Int_t > SpNHits