42 const char* name,
const char* description,
100 static const char*
const here =
"Setup";
105 fPrefix[0]=tolower(app->GetName()[0]);
108 cout <<
"No apparatus found" << endl;
115 string planenamelist;
121 {
"dc_plane_names",&planenamelist, kString},
137 cout <<
"Plane Name List: " << planenamelist << endl;
138 cout <<
"Drift Chambers: " <<
fNPlanes <<
" planes in " <<
fNChambers <<
" chambers" << endl;
140 vector<string> plane_names = Podd::vsplit(planenamelist);
143 cout <<
"ERROR: Number of planes " <<
fNPlanes <<
" doesn't agree with number of plane names " << plane_names.size() << endl;
148 fPlaneNames[i] =
new char[plane_names[i].length()+1];
152 size_t buflen = strlen(description)+100;
153 char *desc =
new char[buflen];
157 strcpy(desc, description);
158 strcat(desc,
" Plane ");
162 if( !newplane or newplane->
IsZombie() ) {
163 Error(
Here(here),
"Error creating Drift Chamber plane %s. Call expert.", name);
181 cout <<
"Created Drift Chamber " << i+1 <<
", " << desc << endl;
202 char EngineDID[] =
"xDC";
205 static const char*
const here =
"Init()";
206 Error(
Here(here),
"Error filling detectormap for %s.", EngineDID );
378 DBRequest listOpt[]={
386 cout <<
"Plane counts:";
409 {
"stubtest",
"stub test",
"fStubTest" },
410 {
"nhit",
"Number of DC hits",
"fNhits" },
411 {
"tnhit",
"Number of good DC hits",
"fNthits" },
412 {
"trawhit",
"Number of true raw DC hits",
"fN_True_RawHits" },
413 {
"ntrack",
"Number of Tracks",
"fNDCTracks" },
414 {
"nsp",
"Number of Space Points",
"fNSp" },
415 {
"track_nsp",
"Number of spacepoints in track",
"fDCTracks.THcDCTrack.GetNSpacePoints()"},
416 {
"track_chisq",
"Chisq of track",
"fDCTracks.THcDCTrack.GetChisq()"},
417 {
"track_nhits",
"Number of hits in track",
"fDCTracks.THcDCTrack.GetNHits()"},
418 {
"track_sp1ID",
"CH 1 Spacepoint index",
"fDCTracks.THcDCTrack.GetSp1_ID()"},
419 {
"track_sp2ID",
"CH 2 Spacepoint index",
"fDCTracks.THcDCTrack.GetSp2_ID()"},
420 {
"x",
"X at focal plane",
"fDCTracks.THcDCTrack.GetX()"},
421 {
"y",
"Y at focal plane",
"fDCTracks.THcDCTrack.GetY()"},
422 {
"xp",
"XP at focal plane",
"fDCTracks.THcDCTrack.GetXP()"},
423 {
"yp",
"YP at focal plane",
"fDCTracks.THcDCTrack.GetYP()"},
424 {
"x_fp",
"X at focal plane (golden track)",
"fX_fp_best"},
425 {
"y_fp",
"Y at focal plane( golden track)",
"fY_fp_best"},
426 {
"xp_fp",
"XP at focal plane (golden track)",
"fXp_fp_best"},
427 {
"yp_fp",
"YP at focal plane(golden track) ",
"fYp_fp_best"},
428 {
"chisq",
"chisq/dof (golden track) ",
"fChisq_best"},
429 {
"sp1_id",
" (golden track) ",
"fSp1_ID_best"},
430 {
"sp2_id",
" (golden track) ",
"fSp2_ID_best"},
431 {
"InsideDipoleExit",
" ",
"fInSideDipoleExit_best"},
432 {
"gtrack_nsp",
" Number of space points in golden track ",
"fNsp_best"},
433 {
"pos_best",
"Pos (golden track)",
"fPos_best"},
434 {
"dist_best",
"Dist (golden track)",
"fDist_best"},
435 {
"lr_best",
"LR sign (golden track)",
"fLR_best"},
436 {
"residual",
"Residuals",
"fResiduals"},
437 {
"residualExclPlane",
"Residuals",
"fResidualsExclPlane"},
438 {
"wireHitDid",
"Wire did have matched track hit",
"fWire_hit_did"},
439 {
"wireHitShould",
"Wire should have matched track hit",
"fWire_hit_should"},
457 for (vector<THcDriftChamberPlane*>::iterator ip =
fPlanes.begin();
458 ip !=
fPlanes.end(); ++ip)
delete *ip;
460 for (vector<THcDriftChamber*>::iterator ip =
fChambers.begin();
584 cout <<
" RAW_TOT_HITS = " <<
fNRawHits << endl;
585 cout <<
" Hit # " <<
"Plane " <<
" Wire " <<
" Raw TDC " << endl;
588 for(
UInt_t imhit = 0; imhit < hit->GetRawTdcHit().GetNHits(); imhit++) {
590 cout << counter <<
" " << hit->fPlane <<
" " << hit->fCounter <<
" " << hit->GetRawTdcHit().GetTimeRaw(imhit) << endl;
617 fPlanes[ip]->SubtractStartTime();
678 track->
SetTarget(0.0, ytar*100.0, xptar, yptar);
679 track->
SetDp(delta*100.0);
735 if ( (wire_num-wire_track_num) ==0)
fWire_hit_did[plane]=wire_num;
747 printf(
"%s %2d %s %3d %s %3d \n",
" chamber = ",
fChambers[ich]->GetChamberNum(),
" number of hits = ",
fChambers[ich]->GetNHits(),
" number of spacepoints = ",
fChambers[ich]->GetNSpacePoints());
748 printf(
"%6s %-8s %-8s %6s %6s \n",
" ",
" ",
" ",
"Number",
"Number");
749 printf(
"%6s %-8s %-8s %6s %6s \n",
"Point",
"x",
"y",
" hits ",
"combos");
766 printf(
"%s %3d \n",
" Stub fit results Chamber = ",ich+1);
767 printf(
"%-5s %-18s %-18s %-18s %-18s\n",
"point",
"x_t",
"y_t",
"xp_t",
"yp_t");
768 printf(
"%-5s %-18s %-18s %-18s %-18s\n",
" ",
"[cm]",
"[cm]",
"[cm]",
"[cm]");
773 printf(
"%-5d % 15.10e % 15.10e % 15.10e % 15.10e \n",isp+1,spstubt[0],spstubt[1],spstubt[2],spstubt[3]);
783 std::vector<THcSpacePoint*> fSp;
792 fSp[
fNSp]->fNChamber = nchamber;
793 fSp[
fNSp]->fNChamber_spnum = isp;
802 for(
Int_t isp2=ch1_nsp;isp2<ch1_nsp+ch2_nsp;isp2++) {
807 Double_t dposx = spstub1[0] - spstub2[0];
814 dposy = spstub1[1] - spstub2[1];
816 Double_t dposxp = spstub1[2] - spstub2[2];
817 Double_t dposyp = spstub1[3] - spstub2[3];
840 for(
Int_t isp2=ch1_nsp;isp2<ch1_nsp+ch2_nsp;isp2++) {
876 std::vector<THcSpacePoint*> fSp;
890 fSp[
fNSp]->fNChamber = nchamber;
891 fSp[
fNSp]->fNChamber_spnum = isp;
893 if (ich==0 &&
fNSp>50)
break;
920 for(
Int_t isp2=isp1+1;isp2<
fNSp;isp2++) {
925 Double_t dposx = spstub1[0] - spstub2[0];
936 dposy = spstub1[1] - spstub2[1];
938 Double_t dposxp = spstub1[2] - spstub2[2];
939 Double_t dposyp = spstub1[3] - spstub2[3];
981 for(
Int_t itrack=0;itrack<sptracks;itrack++) {
982 Int_t track=stub_tracks[itrack];
1023 if (
fdebuglinkstubs) cout <<
"EPIC FAIL 2: Too many tracks found in THcDC::LinkStubs maxtracks = " <<
MAXTRACKS << endl;
1043 if (fSp[isp]->GetSetStubFlag()) {
1048 if (
fdebuglinkstubs) cout <<
"EPIC FAIL 3: Too many tracks found in THcDC::LinkStubs" << endl;
1057 cout <<
" Number of tracks from link stubs = " <<
fNDCTracks << endl;
1058 printf(
"%s %s \n",
"Track",
"Plane Wire ");
1061 printf(
"%-5d ",itrack+1);
1073 const Int_t raycoeffmap[]={4,5,2,3};
1078 for(
Int_t ihit=0;ihit < TrackHits;ihit++) {
1079 TT[irayp] += (coords[ihit]*
fPlaneCoeffs[planes[ihit]][raycoeffmap[irayp]])/
pow(wiresigma[ihit],2);
1085 AA[irayp][jrayp] = 0.0;
1087 AA[irayp][jrayp] = AA[jrayp][irayp];
1089 for(
Int_t ihit=0;ihit <TrackHits ;ihit++) {
1090 AA[irayp][jrayp] +=
fPlaneCoeffs[planes[ihit]][raycoeffmap[irayp]]*
1091 fPlaneCoeffs[planes[ihit]][raycoeffmap[jrayp]]/
pow(wiresigma[ihit],2);
1105 sumcoord +=
fPlaneCoeffs[iplane][raycoeffmap[ir]]*dray[ir];
1107 TrackCoord[iplane]=sumcoord;
1116 Int_t plusminus[MAXHITS];
1117 Int_t plusminusknown[MAXHITS];
1121 Int_t planes[TrackHits];
1124 for(
Int_t ihit=0;ihit<MAXHITS;ihit++) {
1125 plusminusknown[ihit]=0;
1127 Int_t nplusminus=1<<TrackHits;
1128 for(
Int_t pmloop=0;pmloop<nplusminus;pmloop++) {
1130 for(
Int_t ihit=0;ihit<TrackHits;ihit++) {
1131 if(plusminusknown[ihit]!=0) {
1132 plusminus[ihit] = plusminusknown[ihit];
1134 if(pmloop & iswhit) {
1135 plusminus[ihit] = 1;
1137 plusminus[ihit] = -1;
1142 for(
Int_t ihit=0;ihit<TrackHits;ihit++) {
1148 FitLineToTrack(TrackHits,coords,planes,wiresigma,TrackCoord,save_ray);
1150 for(
Int_t ihit=0;ihit < TrackHits;ihit++) {
1151 Double_t residual = coords[ihit] - TrackCoord[planes[ihit]];
1152 chi2 +=
pow(residual/wiresigma[ihit],2);
1154 if (chi2 < minchi2) {
1156 tr->
SetVector(save_ray[0], save_ray[1], 0.0, save_ray[2], save_ray[3]);
1157 for(
Int_t ihit=0;ihit < TrackHits;ihit++) {
1158 tr->
SetHitLR(ihit, plusminus[ihit]);
1159 tr->
SetCoord(planes[ihit], TrackCoord[planes[ihit]]);
1160 Double_t residual = coords[ihit] -TrackCoord[planes[ihit]] ;
1170 const Int_t raycoeffmap[]={4,5,2,3};
1171 for(
Int_t ihit=0;ihit<TrackHits;ihit++) {
1190 if (ihit != ipl_hit) {
1191 TT[irayp] += (coords[ihit]*
1200 AA[irayp][jrayp] = 0.0;
1202 AA[irayp][jrayp] = AA[jrayp][irayp];
1210 if (ihit != ipl_hit) {
1211 AA[irayp][jrayp] +=
fPlaneCoeffs[planes[ihit]][raycoeffmap[irayp]]*
1228 coord +=
fPlaneCoeffs[planes[ipl_hit]][raycoeffmap[ir]]*dray[ir];
1231 Double_t residual = coords[ipl_hit] - coord;
1248 const Int_t raycoeffmap[]={4,5,2,3};
1257 while (CheckResid) {
1258 Int_t MaxResidHitIndex = -1;
1269 coords[ihit] = hit->
GetPos()
1272 coords[ihit] = hit->
GetPos()
1278 coords[ihit] = hit->
GetPos()
1316 AA[irayp][jrayp] = 0.0;
1318 AA[irayp][jrayp] = AA[jrayp][irayp];
1325 AA[irayp][jrayp] +=
fPlaneCoeffs[planes[ihit]][raycoeffmap[irayp]]*
1344 coord +=
fPlaneCoeffs[iplane][raycoeffmap[ir]]*dray[ir];
1347 theDCTrack->
SetCoord(iplane,coord);
1358 if (
abs(residual) > MaxResid) {
1359 MaxResidHitIndex =ihit;
1360 MaxResid =
abs(residual);
1369 theDCTrack->
SetVector(dray[0], dray[1], 0.0, dray[2], dray[3]);
1373 for(
Int_t ipl_hit=0;ipl_hit < theDCTrack->
GetNHits();ipl_hit++) {
1386 if (ihit != ipl_hit) {
1387 TT[irayp] += (coords[ihit]*
1396 AA[irayp][jrayp] = 0.0;
1398 AA[irayp][jrayp] = AA[jrayp][irayp];
1406 if (ihit != ipl_hit) {
1407 AA[irayp][jrayp] +=
fPlaneCoeffs[planes[ihit]][raycoeffmap[irayp]]*
1424 coord +=
fPlaneCoeffs[planes[ipl_hit]][raycoeffmap[ir]]*dray[ir];
1427 Double_t residual = coords[ipl_hit] - coord;
1438 theDCTrack->
RemoveHit(MaxResidHitIndex);
1442 if (NLoops == NLoopsMax) CheckResid =
kFALSE;
1463 hit=theDCTrack2->
GetHit(ihit);
1469 theDCTrack1->
GetRay(ray1);
1470 theDCTrack2->
GetRay(ray2);
1535 printf(
"%5s %-14s %-14s %-14s %-14s %-10s %-10s \n",
"Track",
"x_t",
"y_t",
"xp_t",
"yp_t",
"chi2",
"DOF");
1536 printf(
"%5s %-14s %-14s %-14s %-14s %-10s %-10s \n",
" ",
"[cm]",
"[cm]",
"[rad]",
"[rad]",
" ",
" ");
1539 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());
1542 printf(
"%s %5d \n",
"Hit info for track number = ",itr+1);
1543 printf(
"%5s %-15s %-15s %-15s \n",
"Plane",
"WIRE_COORD",
"Fit postiion",
"Residual");
1551 coords_temp = hit->
GetPos()
1554 coords_temp = hit->
GetPos()
1559 coords_temp = hit->
GetPos()
1565 printf(
"%-5d %15.7e %15.7e %15.7e \n",plane+1,coords_temp,theDCTrack->
GetCoord(plane),theDCTrack->
GetResidual(plane));
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
R__EXTERN class THaVarList * gHaVars
R__EXTERN class THaCutList * gHaCuts
ClassImp(VDC::AnalyticTTDConv) using namespace std
R__EXTERN class THcParmList * gHcParms
R__EXTERN class THcDetectorMap * gHcDetectorMap
char * Form(const char *fmt,...)
void Delete(Option_t *option="") override
virtual void SetDebug(Int_t level)
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="")
virtual const char * Here(const char *) const
virtual Int_t Result(const char *cutname="", EWarnMode mode=kWarn)
UInt_t GetTotNumChan() const
THaApparatus * GetApparatus() const
Double_t GetPcentral() const
virtual void TransportToLab(Double_t p, Double_t th, Double_t ph, TVector3 &pvect) const
void SetPvect(const TVector3 &pvect)
void Set(Double_t x, Double_t y, Double_t theta, Double_t phi)
void SetMomentum(Double_t p)
void SetFlag(UInt_t flag)
void SetTarget(Double_t x, Double_t y, Double_t theta, Double_t phi)
Double_t GetTTheta() const
void SetChi2(Double_t chi2, Int_t ndof)
virtual THaTrack * AddTrack(TClonesArray &tracks, Double_t x, Double_t y, Double_t theta, Double_t phi, THaTrackID *ID=nullptr)
THaVar * Define(const char *name, const Byte_t &var, const Int_t *count=nullptr)
virtual THaVar * Find(const char *name) const
const void * GetValuePointer() const
Drift chamber wire hit info.
Int_t GetPlaneNum() const
Double_t GetCoord() const
Double_t GetWireSigma() const
Class representing a track found from linking DC Space points.
void SetResidual(Int_t ip, Double_t coord)
Double_t GetResidualExclPlane(Int_t ip) const
Double_t GetSp2_ID() const
void SetChisq(Double_t chi2)
void SetSp2_ID(Int_t isp2)
virtual void RemoveHit(Int_t RemoveHitIndex)
virtual void AddSpacePoint(THcSpacePoint *sp)
THcDCHit * GetHit(Int_t i) const
Double_t GetHitDist(Int_t ihit)
void GetRay(Double_t *ray) const
Int_t GetNSpacePoints() const
void SetNFree(Int_t nfree)
Int_t GetHitLR(Int_t ihit)
void SetCoord(Int_t ip, Double_t coord)
Double_t GetCoord(Int_t ip) const
void SetSp1_ID(Int_t isp1)
void SetResidualExclPlane(Int_t ip, Double_t coord)
void SetVector(Double_t x, Double_t y, Double_t z, Double_t xp, Double_t yp)
Double_t GetChisq() const
void SetDoubleResidual(Int_t ip, Double_t coord)
Double_t GetSp1_ID() const
THcSpacePoint * GetSpacePoint(Int_t i) const
Double_t GetResidual(Int_t ip) const
void SetHitLR(Int_t ihit, Int_t lrtemp)
Analyze a package of horizontal drift chambers.
virtual Int_t End(THaRunBase *run=0)
Bool_t fInSideDipoleExit_best
Int_t GetNChamber(Int_t plane) const
virtual Int_t ReadDatabase(const TDatime &date)
virtual EStatus Init(const TDatime &run_time)
Int_t fFixPropagationCorrection
void Setup(const char *name, const char *description)
void NewTrackFit(UInt_t TrackIndex)
std::vector< THcDriftChamberPlane * > fPlanes
Double_t * fSpace_Point_Criterion
std::vector< THcDriftChamber * > fChambers
virtual Int_t ApplyCorrections(void)
Double_t * fPlaneTimeZero
static const UInt_t MAXTRACKS
Double_t * fResidualsExclPlane
Double_t DpsiFun(Double_t ray[4], Int_t plane)
Double_t * fWire_hit_should
virtual Int_t Decode(const THaEvData &)
Int_t fdebugprintdecodeddc
void EfficiencyPerWire(Int_t golden_track_index)
virtual Int_t CoarseTrack(TClonesArray &tracks)
void FitLineToTrack(Int_t TrackHits, Double_t coords[], Int_t planes[], Double_t wiresigma[], Double_t TrackCoord[], Double_t save_ray[])
Double_t fTrackLargeResidCut
virtual Int_t FineTrack(TClonesArray &tracks)
Int_t fUseNewFindSpacePoints
virtual Int_t DefineVariables(EMode mode=kDefine)
void SetFocalPlaneBestTrack(Int_t golden_track_index)
virtual Int_t FillMap(THaDetMap *detmap, const char *detectorname)
Class for a a single Hall C horizontal drift chamber plane.
Subdetector class for a single drift chamber with several planes.
void SetHMSStyleFlag(Int_t flag)
A standard Hall C spectrometer apparatus.
virtual void CalculateTargetQuantities(THaTrack *track, Double_t &gbeam_y, Double_t &xptar, Double_t &ytar, Double_t &yptar, Double_t &delta)
Transport focal plane track to target.
virtual Int_t DecodeToHitList(const THaEvData &evdata, Bool_t suppress=kFALSE)
Populate the hitlist from the raw event data.
TClonesArray * fRawHitList
void CreateMissReportParms(const char *prefix) const
void InitHitList(THaDetMap *detmap, const char *hitclass, Int_t maxhits, Int_t tdcref_cut=0, Int_t adcref_cut=0)
Save the electronics module to detector mapping and initialize a hit array of hits of class hitclass.
void MissReport(const char *name) const
Int_t LoadParmValues(const DBRequest *list, const char *prefix="")
Retrieve parameter values from the parameter cache.
Class representing for drift chamber wire (or other device with a single multihit TDC channel per det...
Class representing a single hit DC.
THcDCHit * GetHit(Int_t ihit)
TMatrixT< Element > & Invert(Double_t *det=nullptr)
const char * GetName() const override
const char * GetTitle() const override
TObject * At(Int_t idx) const override
R__ALWAYS_INLINE Bool_t IsZombie() const
virtual void Error(const char *method, const char *msgfmt,...) const
RVec< PromoteType< T > > abs(const RVec< T > &v)
RVec< PromoteType< T > > round(const RVec< T > &v)
RVec< PromoteTypes< T0, T1 > > pow(const RVec< T0 > &v, const T1 &y)