Skip to content

Commit

Permalink
Re-enable reading of configurable VDC v1.5 parameters via database
Browse files Browse the repository at this point in the history
Reading of "tdc.min", "tdc.max", "tdc.res" and "maxgap" was commented
out in the OldVDCPlane database reader. Re-enable these so that
if they are set in the new-style VDC database, they are read from there.

In this way, parameters supplied to the old and new VDC code stay
consistent, and OldVDC can be used to study /algorithm/ differences,
not differences in database parameters that accidentally creep in because
of technical differences (database vs. Set functiions).

These parameters can also be set via Set functions, in which case the
value supplied explicitly overrides the database value. We use
OldVDCPlane::fBits 14-17 as flags to indicate which Set function was
called. This is supported only for backward-compatibility with old
scripts.

Closes Redmine issue 250.
  • Loading branch information
hansenjo committed Jan 23, 2018
1 parent ab263d7 commit 044ed63
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 9 deletions.
20 changes: 20 additions & 0 deletions OldVDC/OldVDC.cxx
Expand Up @@ -1189,27 +1189,47 @@ bool OldVDC::OldVDCMatrixElement::match(const OldVDCMatrixElement& rhs) const
//_____________________________________________________________________________
void OldVDC::SetNMaxGap( Int_t val )
{
if( val < 0 || val > 2 ) {
Error( Here("SetNMaxGap"),
"Invalid max_gap = %d, must be betwwen 0 and 2.", val );
return;
}
fUpper->SetNMaxGap(val);
fLower->SetNMaxGap(val);
}

//_____________________________________________________________________________
void OldVDC::SetMinTime( Int_t val )
{
if( val < 0 || val > 4095 ) {
Error( Here("SetMinTime"),
"Invalid min_time = %d, must be betwwen 0 and 4095.", val );
return;
}
fUpper->SetMinTime(val);
fLower->SetMinTime(val);
}

//_____________________________________________________________________________
void OldVDC::SetMaxTime( Int_t val )
{
if( val < 1 || val > 4096 ) {
Error( Here("SetMaxTime"),
"Invalid max_time = %d. Must be between 1 and 4096.", val );
return;
}
fUpper->SetMaxTime(val);
fLower->SetMaxTime(val);
}

//_____________________________________________________________________________
void OldVDC::SetTDCRes( Double_t val )
{
if( val < 0 || val > 1e-6 ) {
Error( Here("SetTDCRes"),
"Nonsense TDC resolution = %8.1le s/channel.", val );
return;
}
fUpper->SetTDCRes(val);
fLower->SetTDCRes(val);
}
Expand Down
61 changes: 52 additions & 9 deletions OldVDC/OldVDCPlane.cxx
Expand Up @@ -61,6 +61,11 @@ OldVDCPlane::OldVDCPlane( const char* name, const char* description,
fWires = new TClonesArray("OldVDCWire", 368 );

fVDC = GetMainDetector();

ResetBit(kMaxGapSet);
ResetBit(kMinTimeSet);
ResetBit(kMaxTimeSet);
ResetBit(kTDCResSet);
}

//_____________________________________________________________________________
Expand Down Expand Up @@ -108,11 +113,10 @@ Int_t OldVDCPlane::DoReadDatabase( FILE* file, const TDatime& date )
vector<Int_t> detmap, bad_wirelist;
vector<Double_t> ttd_param;
vector<Float_t> tdc_offsets;
// Default values for optional parameters
fTDCRes = kDefaultTDCRes;
fNMaxGap = kDefaultNMaxGap;
fMinTime = kDefaultMinTime;
fMaxTime = kDefaultMaxTime;
Int_t maxgap = kDefaultNMaxGap;
Int_t mintime = kDefaultMinTime;
Int_t maxtime = kDefaultMaxTime;
Double_t tdcres = kDefaultTDCRes;

DBRequest request[] = {
{ "detmap", &detmap, kIntV },
Expand All @@ -122,12 +126,12 @@ Int_t OldVDCPlane::DoReadDatabase( FILE* file, const TDatime& date )
{ "wire.angle", &fWAngle, kDouble, 0, 0 },
{ "wire.badlist", &bad_wirelist, kIntV, 0, 1 },
{ "driftvel", &fDriftVel, kDouble, 0, 0, -1 },
// { "tdc.min", &fMinTime, kInt, 0, 1, -1 },
// { "tdc.max", &fMaxTime, kInt, 0, 1, -1 },
// { "tdc.res", &fTDCRes, kDouble, 0, 0, -1 },
{ "maxgap", &maxgap, kInt, 0, 1, -1 },
{ "tdc.min", &mintime, kInt, 0, 1, -1 },
{ "tdc.max", &maxtime, kInt, 0, 1, -1 },
{ "tdc.res", &tdcres, kDouble, 0, 0, -1 },
{ "tdc.offsets", &tdc_offsets, kFloatV },
{ "ttd.param", &ttd_param, kDoubleV, 0, 0, -1 },
// { "maxgap", &fNMaxGap, kInt, 0, 1, -1 },
{ "description", &fTitle, kTString, 0, 1 },
{ 0 }
};
Expand Down Expand Up @@ -163,6 +167,16 @@ Int_t OldVDCPlane::DoReadDatabase( FILE* file, const TDatime& date )
return kInitError;
}

// Values set via Set functions override database values
if( !TestBit(kMaxGapSet) )
fNMaxGap = maxgap;
if( !TestBit(kMinTimeSet) )
fMinTime = mintime;
if( !TestBit(kMaxTimeSet) )
fMaxTime = maxtime;
if( !TestBit(kTDCResSet) )
fTDCRes = tdcres;

if( fNMaxGap < 0 || fNMaxGap > 2 ) {
Error( Here(here), "Invalid max_gap = %d, must be betwwen 0 and 2. "
"Fix database.", fNMaxGap );
Expand All @@ -178,6 +192,11 @@ Int_t OldVDCPlane::DoReadDatabase( FILE* file, const TDatime& date )
"and >= min_time = %d. Fix database.", fMaxTime, fMinTime );
return kInitError;
}
if( fTDCRes < 0 || fTDCRes > 1e-6 ) {
Error( Here(here), "Nonsense TDC resolution = %8.1le s/channel. "
"Fix database.", fTDCRes );
return kInitError;
}

// Create time-to-distance converter
delete fTTDConv;
Expand Down Expand Up @@ -551,25 +570,49 @@ Int_t OldVDCPlane::FitTracks()
//_____________________________________________________________________________
void OldVDCPlane::SetNMaxGap( Int_t val )
{
if( val < 0 || val > 2 ) {
Error( Here("SetNMaxGap"),
"Invalid max_gap = %d, must be betwwen 0 and 2.", val );
return;
}
fNMaxGap = val;
SetBit(kMaxGapSet);
}

//_____________________________________________________________________________
void OldVDCPlane::SetMinTime( Int_t val )
{
if( val < 0 || val > 4095 ) {
Error( Here("SetMinTime"),
"Invalid min_time = %d, must be betwwen 0 and 4095.", val );
return;
}
fMinTime = val;
SetBit(kMinTimeSet);
}

//_____________________________________________________________________________
void OldVDCPlane::SetMaxTime( Int_t val )
{
if( val < 1 || val > 4096 ) {
Error( Here("SetMaxTime"),
"Invalid max_time = %d. Must be between 1 and 4096.", val );
return;
}
fMaxTime = val;
SetBit(kMaxTimeSet);
}

//_____________________________________________________________________________
void OldVDCPlane::SetTDCRes( Double_t val )
{
if( val < 0 || val > 1e-6 ) {
Error( Here("SetTDCRes"),
"Nonsense TDC resolution = %8.1le s/channel.", val );
return;
}
fTDCRes = val;
SetBit(kTDCResSet);
}


Expand Down
9 changes: 9 additions & 0 deletions OldVDC/OldVDCPlane.h
Expand Up @@ -92,6 +92,15 @@ class OldVDCPlane : public THaSubDetector {
Double_t fTDCRes; // TDC Resolution ( s / channel)
Double_t fDriftVel; // Drift velocity in the wire plane (m/s)

// Bits indicating that the corresponding Set function has been called.
// If set, the corresponding parameter is NOT taken from the database.
enum {
kMaxGapSet = BIT(14),
kMinTimeSet = BIT(15),
kMaxTimeSet = BIT(16),
kTDCResSet = BIT(17)
};

// Lookup table parameters
// Double_t fT0; // calculated zero time
// Int_t fNumBins; // size of lookup table
Expand Down
20 changes: 20 additions & 0 deletions OldVDC/OldVDCUVPlane.cxx
Expand Up @@ -260,27 +260,47 @@ Int_t OldVDCUVPlane::FineTrack( )
//_____________________________________________________________________________
void OldVDCUVPlane::SetNMaxGap( Int_t val )
{
if( val < 0 || val > 2 ) {
Error( Here("SetNMaxGap"),
"Invalid max_gap = %d, must be betwwen 0 and 2.", val );
return;
}
fU->SetNMaxGap(val);
fV->SetNMaxGap(val);
}

//_____________________________________________________________________________
void OldVDCUVPlane::SetMinTime( Int_t val )
{
if( val < 0 || val > 4095 ) {
Error( Here("SetMinTime"),
"Invalid min_time = %d, must be betwwen 0 and 4095.", val );
return;
}
fU->SetMinTime(val);
fV->SetMinTime(val);
}

//_____________________________________________________________________________
void OldVDCUVPlane::SetMaxTime( Int_t val )
{
if( val < 1 || val > 4096 ) {
Error( Here("SetMaxTime"),
"Invalid max_time = %d. Must be between 1 and 4096.", val );
return;
}
fU->SetMaxTime(val);
fV->SetMaxTime(val);
}

//_____________________________________________________________________________
void OldVDCUVPlane::SetTDCRes( Double_t val )
{
if( val < 0 || val > 1e-6 ) {
Error( Here("SetTDCRes"),
"Nonsense TDC resolution = %8.1le s/channel.", val );
return;
}
fU->SetTDCRes(val);
fV->SetTDCRes(val);
}
Expand Down

0 comments on commit 044ed63

Please sign in to comment.