41#ifdef CLUST_RAWDATA_HACK
55 fNHits(0), fNWiresHit(0), fNpass(0), fMinClustSize(0),
56 fMaxClustSpan(
kMaxInt), fNMaxGap(0), fMinTime(0), fMaxTime(
kMaxInt),
57 fMaxThits(0), fMinTdiff(0), fMaxTdiff(
kBig), fTDCRes(0), fDriftVel(0),
58 fT0Resolution(0), fOnlyFastestHit(false), fNoNegativeTime(false),
59 fWBeg(0), fWSpac(0), fWAngle(0), fSinWAngle(0),
60 fCosWAngle(1), fTTDConv(nullptr),
61 fVDC{dynamic_cast<
THaVDC*>( GetMainDetector() )},
62 fMaxData(
kMaxUInt), fNextHit(0), fPrevWire(nullptr)
95 if( uv_plane && strstr( uv_plane->
GetName(),
"uv1" ))
97 else if( uv_plane && strstr( uv_plane->
GetName(),
"uv2" ))
99 if( basename.
Length() == 0 )
100 basename =
fName +
".";
112 const char*
const here =
"ReadDatabase";
125 vector<Int_t> detmap, bad_wirelist;
126 vector<Double_t> ttd_param;
127 vector<Float_t> tdc_offsets;
128 TString ttd_conv =
"AnalyticTTDConv";
140 DBRequest request[] = {
141 {
"detmap", &detmap, kIntV },
146 {
"wire.badlist", &bad_wirelist, kIntV, 0,
true },
150 {
"tdc.hits" , &
fMaxThits, kUInt, 0,
true, -1 },
152 {
"tdc.offsets", &tdc_offsets, kFloatV },
153 {
"ttd.converter", &ttd_conv, kTString, 0,
true, -1 },
154 {
"ttd.param", &ttd_param, kDoubleV, 0,
false, -1 },
161 {
"description", &
fTitle, kTString, 0,
true },
175 for(
UInt_t i = 0; i < nmodules; i++ ) {
178 d->SetTDCMode(
false);
204 set<Int_t> bad_wires(ALL(bad_wirelist));
205 bad_wirelist.clear();
206 bad_wirelist.shrink_to_fit();
216 for(
int i = 0; i <
fNelem; i++ ) {
217 auto* wire =
new((*fWires)[i])
219 if( bad_wires.find(i) != bad_wires.end() )
231 {
"Detector pos VDC coord", pos,
kDouble, 3 },
233 {
"Wire angle (deg)", &
angle },
234 {
"Wire start pos (m)", &
fWBeg },
235 {
"Wire spacing (m)", &
fWSpac },
236 {
"TDC resolution (s/chan)", &
fTDCRes },
240 {
"Min adj wire tdiff (s)", &
fMinTdiff },
241 {
"Max adj wire tdiff (s)", &
fMaxTdiff },
242 {
"Time-to-dist conv param", &ttd_param, kDoubleV },
269 const char*
const here =
"ReadGeometry";
271 vector<Double_t> position,
size;
272 DBRequest request[] = {
273 {
"position", &position, kDoubleV, 0,
false, 0,
"\"position\" (detector position [m])" },
274 {
"size", &
size, kDoubleV, 0,
true, 0,
"\"size\" (detector size [m])" },
281 assert( !position.empty() );
288 if( !
size.empty() ) {
315 if( nchan != nwires ) {
317 "Number of detector map channels (%u) disagrees with "
318 "number of wires (%u)", nchan, nwires);
321 nchan = tdc_offsets.size();
322 if( nchan != nwires ) {
324 "Number of TDC offset values (%u) disagrees with "
325 "number of wires (%u)", nchan, nwires);
329 if( fMinClustSize < 1 || fMinClustSize > 6 ) {
331 "Invalid min_clust_size = %d, must be between 1 and 6. "
335 if( fMaxClustSpan < 2 || fMaxClustSpan > 12 ) {
337 "Invalid max_clust_span = %d, must be between 1 and 12. "
341 if( fNMaxGap < 0 || fNMaxGap > 2 ) {
343 "Invalid max_gap = %d, must be between 0 and 2. Fix database.",
347 if( fMinTime < 0 || fMinTime > 4095 ) {
349 "Invalid min_time = %d, must be between 0 and 4095. Fix database.",
355 "Invalid max_time = %d. Must be between 1 and 4096 "
364 const vector<Double_t>& size,
365 const char*
const here )
367 if( position.size() != 3 ) {
369 "detector position. Must be exactly 3. Fix database.",
370 static_cast<unsigned int>(position.size()) );
373 if( !
size.empty() ) {
374 if(
size.size() != 3 ) {
376 "detector size. Must be exactly 3. Fix database.",
377 static_cast<unsigned int>(
size.size()));
381 Error(
Here(
here),
"Illegal zero detector dimension. Fix database.");
386 "Taking absolute. Check database.");
394 const vector<Double_t>& ttd_param,
397 TClass* cl = TClass::GetClass(classname);
400 "Drift time-to-distance converter \"%s\" not available. "
401 "Load library or fix database.", classname ? classname :
"");
406 "Class \"%s\" is not a drift time-to-distance "
407 "converter. Fix database.", classname);
413 "Unexpected error creating drift time-to-distance converter "
414 "object \"%s\". Call expert.", classname);
421 "Error initializing drift time-to-distance converter "
422 "\"%s\". Check ttd.param in database.", classname);
451 {
"nhit",
"Number of hits",
"GetNHits()" },
452 {
"wire",
"Active wire numbers",
"fHits.THaVDCHit.GetWireNum()" },
453 {
"rawtime",
"Raw TDC values of wires",
"fHits.THaVDCHit.fRawTime" },
454 {
"time",
"TDC values of active wires",
"fHits.THaVDCHit.fTime" },
455 {
"nthit",
"tdc hits per channel",
"fHits.THaVDCHit.fNthit" },
456 {
"dist",
"Drift distances",
"fHits.THaVDCHit.fDist" },
457 {
"ddist",
"Drft dist uncertainty",
"fHits.THaVDCHit.fdDist" },
458 {
"trdist",
"Dist. from track",
"fHits.THaVDCHit.ftrDist" },
459 {
"ltrdist",
"Dist. from local track",
"fHits.THaVDCHit.fltrDist" },
460 {
"trknum",
"Track number (0=unused)",
"fHits.THaVDCHit.fTrkNum" },
461 {
"clsnum",
"Cluster number (-1=unused)",
"fHits.THaVDCHit.fClsNum" },
462 {
"nclust",
"Number of clusters",
"GetNClusters()" },
463 {
"clsiz",
"Cluster sizes",
"fClusters.THaVDCCluster.GetSize()" },
464 {
"clpivot",
"Cluster pivot wire num",
"fClusters.THaVDCCluster.GetPivotWireNum()" },
465 {
"clpos",
"Cluster intercepts (m)",
"fClusters.THaVDCCluster.fInt" },
466 {
"slope",
"Cluster best slope",
"fClusters.THaVDCCluster.fSlope" },
467 {
"lslope",
"Cluster local (fitted) slope",
"fClusters.THaVDCCluster.fLocalSlope" },
468 {
"t0",
"Timing offset (s)",
"fClusters.THaVDCCluster.fT0" },
469 {
"sigsl",
"Cluster slope error",
"fClusters.THaVDCCluster.fSigmaSlope" },
470 {
"sigpos",
"Cluster position error (m)",
"fClusters.THaVDCCluster.fSigmaInt" },
471 {
"sigt0",
"Timing offset error (s)",
"fClusters.THaVDCCluster.fSigmaT0" },
472 {
"clchi2",
"Cluster chi2",
"fClusters.THaVDCCluster.fChi2" },
473 {
"clndof",
"Cluster NDoF",
"fClusters.THaVDCCluster.fNDoF" },
474 {
"cltcor",
"Cluster Time correction",
"fClusters.THaVDCCluster.fTimeCorrection" },
475 {
"cltridx",
"Idx of track assoc w/cluster",
"fClusters.THaVDCCluster.GetTrackIndex()" },
476 {
"cltrknum",
"Cluster track number (0=unused)",
"fClusters.THaVDCCluster.fTrkNum" },
477 {
"clbeg",
"Cluster start wire",
"fClusters.THaVDCCluster.fClsBeg" },
478 {
"clend",
"Cluster end wire",
"fClusters.THaVDCCluster.fClsEnd" },
479 {
"npass",
"Number of hit passes for cluster",
"fNpass" },
500 assert( hitinfo.
nhit > 0 );
504 if( !wire || wire->GetFlag() != 0 )
567 const char*
const here =
"Decode";
568 bool has_warning =
false;
576 const auto& hitinfo = *hitIter;
616 <<
"VDC plane " <<
GetPrefixName() <<
": " << nhits <<
" hits" << endl;
618 for(
int i = 0; i <
TMath::Min(ncol, nhits); i++ )
619 cout <<
" Wire TDC ";
622 for(
int i = 0; i < (nhits+ncol-1)/ncol; i++ ) {
623 for(
int c = ncol*i;
c < ncol*(i+1);
c++ ) {
629 <<
" " << setw(5) << hit->GetRawTime()
633 cout << right << setw(12) <<
"<null>" << left;
656 for(
Int_t i = 0; i < nHits; ++i ) {
658 hit->SetTime(hit->GetTime() - evtT0);
695 if( ratio < -0.5 || ratio > 1.5 )
719 Int_t nLastUsed = -1;
723 vector<THaVDCHit*> clushits;
724 clushits.reserve(nHits);
729 while( nLastUsed != nUsed ) {
733 for(
Int_t i = 0; i < nHits; ) {
740 if( !timecut(hit) ) {
759 while( ++i < nHits ) {
763 if( !timecut(nextHit))
810 if( deltat < fMaxTdiff * ndif && span > 1 ) {
820 if( clushits.empty() ) {
821 clushits.push_back(hit);
825 clushits.push_back(nextHit);
836 auto* clust =
new((*fClusters)[nextClust++])
THaVDCCluster(
this);
837 for(
auto* clushit : clushits ) {
838 clushit->SetClsNum(nextClust - 1);
842 assert(clust->GetSize() > 0 && clust->GetSize() >= nwires);
844 clust->EstTrackParameters();
862 for (
int i = 0; i < nClust; i++) {
863 auto* clust =
static_cast<THaVDCCluster*
>( (*fClusters)[i] );
864 if( !clust )
continue;
878#ifdef CLUST_RAWDATA_HACK
882 clust->GetSize() <= 6 ) {
884 outp.open(
"u1_cluster_data.out",ios_base::app);
885 outp << clust->GetSize() << endl;
886 for(
int i=clust->GetSize()-1; i>=0; i-- ) {
887 outp << clust->GetHit(i)->GetPos() <<
" "
888 << clust->GetHit(i)->GetDist()
891 outp << 1./clust->GetSlope() <<
" "
892 << clust->GetIntercept()
size_t size(const MatrixT &matrix)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t org
static const char *const here
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Bool_t InheritsFrom(const char *cl) const override
void Clear(Option_t *option="") override
void Delete(Option_t *option="") override
void Sort(Int_t upto=kMaxInt) override
static Int_t LoadDB(FILE *file, const TDatime &date, const DBRequest *request, const char *prefix, Int_t search=0, const char *here="THaAnalysisObject::LoadDB")
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
const char * GetPrefix() const
TString GetPrefixName() const
UInt_t fNEventsWithWarnings
virtual FILE * OpenFile(const TDatime &date)
THaDetMap::MultiHitIterator MakeMultiHitIterator(const THaEvData &evdata)
Module * GetModule(UInt_t i) const
UInt_t GetTotNumChan() const
Int_t FillDetMap(const std::vector< Int_t > &values, UInt_t flags=0, const char *here="FillDetMap")
void DataLoadWarning(const DigitizerHitInfo_t &hitinfo, const char *here)
virtual void DefineAxes(Double_t rotation_angle)
TVector3 DetToTrackCoord(const TVector3 &point) const
virtual OptUInt_t LoadData(const THaEvData &evdata, const DigitizerHitInfo_t &hitinfo)
Bool_t IsPhysicsTrigger() const
THaDetectorBase * GetParent() const
Double_t GetSpacing() const
virtual void ConvertTimeToDist()
virtual void AddHit(THaVDCHit *hit)
UInt_t GetRawTime() const
void SetClsNum(Int_t num)
Int_t CreateTTDConv(const char *classname, const std::vector< Double_t > &ttd_param, const char *here)
virtual Int_t FitTracks()
Double_t GetMaxTime() const
Int_t ReadDatabaseErrcheck(const std::vector< Float_t > &tdc_offsets, const char *here)
THaVDCWire * GetWire(Int_t i) const
THaVDCHit * GetHit(Int_t i) const
virtual void Clear(Option_t *opt="")
virtual Int_t ReadDatabase(const TDatime &date)
virtual Int_t FindClusters()
Int_t GetNClusters() const
virtual Int_t Decode(const THaEvData &)
virtual Bool_t IsInActiveArea(Double_t x, Double_t y) const
virtual Int_t ApplyTimeCorrection()
void UpdateGeometry(Double_t x, Double_t y, bool force=false)
virtual Int_t StoreHit(const DigitizerHitInfo_t &hitinfo, UInt_t data)
THaVDCPlane(const char *name="", const char *description="", THaDetectorBase *parent=nullptr)
virtual void MakePrefix()
VDC::TimeToDistConv * fTTDConv
virtual Int_t DefineVariables(EMode mode=kDefine)
Int_t ReadGeometryErrcheck(const std::vector< Double_t > &position, const std::vector< Double_t > &size, const char *here)
virtual void PrintDecodedData(const THaEvData &evdata) const
virtual Int_t ReadGeometry(FILE *file, const TDatime &date, Bool_t required=false)
Double_t GetDriftVel() const
std::pair< Double_t, bool > GetTimeCorrection() const
Double_t GetVDCAngle() const
const char * GetName() const override
void Clear(Option_t *option="") override
TObject * At(Int_t idx) const override
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
const char * Data() const
TString & Append(char c, Ssiz_t rep=1)
TString & Prepend(char c, Ssiz_t rep=1)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
void SetXYZ(Double_t x, Double_t y, Double_t z)
void GetXYZ(Double_t *carray) const
TimeCut(THaVDC *vdc, THaVDCPlane *_plane)
bool operator()(const THaVDCHit *hit)
virtual Int_t SetParameters(const std::vector< double > &)
void SetDriftVel(Double_t v)
Double_t Min(Double_t a, Double_t b)
constexpr Double_t DegToRad()
constexpr Double_t RadToDeg()