Skip to content

Commit

Permalink
Allow setting of TDC common start mode via database
Browse files Browse the repository at this point in the history
Currently available for THaScintillator and THaCherenkov
  • Loading branch information
hansenjo committed Mar 8, 2018
1 parent e73b4af commit 744cb11
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
22 changes: 18 additions & 4 deletions src/THaCherenkov.C
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ Int_t THaCherenkov::ReadDatabase( const TDatime& date )

vector<Int_t> detmap;
Int_t nelem;
Int_t tdc_mode = 0;

// Read configuration parameters
DBRequest config_request[] = {
{ "detmap", &detmap, kIntV },
{ "npmt", &nelem, kInt },
{ "detmap", &detmap, kIntV },
{ "npmt", &nelem, kInt },
{ "tdc.cmnstart", &tdc_mode, kInt, 0, 1 },
{ 0 }
};
err = LoadDB( file, date, config_request, fPrefix );
Expand Down Expand Up @@ -107,6 +109,15 @@ Int_t THaCherenkov::ReadDatabase( const TDatime& date )
"inconsistent with 2*number of PMTs (%d)", nelem, 2*fNelem );
err = kInitError;
}
// Set TDCs to common start mode, if set
if( tdc_mode != 0 ) {
Int_t nmodules = fDetMap->GetSize();
for( Int_t i = 0; i < nmodules; i++ ) {
THaDetMap::Module* d = fDetMap->GetModule(i);
if( d->IsTDC() )
d->SetTDCMode(tdc_mode);
}
}

if( err ) {
fclose(file);
Expand Down Expand Up @@ -141,7 +152,9 @@ Int_t THaCherenkov::ReadDatabase( const TDatime& date )
// Default TDC offsets (0), ADC pedestals (0) and ADC gains (1)
memset( fOff, 0, nval*sizeof(fOff[0]) );
memset( fPed, 0, nval*sizeof(fPed[0]) );
for( UInt_t i=0; i<nval; ++i ) { fGain[i] = 1.0; }
for( UInt_t i=0; i<nval; ++i ) {
fGain[i] = 1.0;
}

DBRequest calib_request[] = {
{ "tdc.offsets", fOff, kFloat, nval, 1 },
Expand Down Expand Up @@ -258,6 +271,7 @@ Int_t THaCherenkov::Decode( const THaEvData& evdata )
for( Int_t i = 0; i < fDetMap->GetSize(); i++ ) {
THaDetMap::Module* d = fDetMap->GetModule( i );
bool adc = (d->model ? d->IsADC() : i < fDetMap->GetSize()/2 );
bool not_common_stop_tdc = (adc || d->IsCommonStart());

// Loop over all channels that have a hit.
for( Int_t j = 0; j < evdata.GetNumChan( d->crate, d->slot ); j++) {
Expand Down Expand Up @@ -289,7 +303,7 @@ Int_t THaCherenkov::Decode( const THaEvData& evdata )
// Get the data. If multiple hits on a TDC channel, take
// either first or last hit, depending on TDC mode
assert( nhit>0 );
Int_t ihit = ( adc || d->IsCommonStart() ) ? 0 : nhit-1;
Int_t ihit = ( not_common_stop_tdc ) ? 0 : nhit-1;
Int_t data = evdata.GetData( d->crate, d->slot, chan, ihit );

// Get the detector channel number, starting at 0
Expand Down
23 changes: 19 additions & 4 deletions src/THaScintillator.C
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@ Int_t THaScintillator::ReadDatabase( const TDatime& date )

vector<Int_t> detmap;
Int_t nelem;
Int_t tdc_mode = 0;

// Read configuration parameters
DBRequest config_request[] = {
{ "detmap", &detmap, kIntV },
{ "npaddles", &nelem, kInt },
{ "detmap", &detmap, kIntV },
{ "npaddles", &nelem, kInt },
{ "tdc.cmnstart", &tdc_mode, kInt, 0, 1 },
{ 0 }
};
err = LoadDB( file, date, config_request, fPrefix );
Expand Down Expand Up @@ -128,6 +130,15 @@ Int_t THaScintillator::ReadDatabase( const TDatime& date )
"inconsistent with 4*number of paddles (%d)", nelem, 4*fNelem );
err = kInitError;
}
// Set TDCs to common start mode, if set
if( tdc_mode != 0 ) {
Int_t nmodules = fDetMap->GetSize();
for( Int_t i = 0; i < nmodules; i++ ) {
THaDetMap::Module* d = fDetMap->GetModule(i);
if( d->IsTDC() )
d->SetTDCMode(tdc_mode);
}
}

if( err ) {
fclose(file);
Expand Down Expand Up @@ -196,7 +207,10 @@ Int_t THaScintillator::ReadDatabase( const TDatime& date )
memset( fROff, 0, nval*sizeof(fROff[0]) );
memset( fLPed, 0, nval*sizeof(fLPed[0]) );
memset( fRPed, 0, nval*sizeof(fRPed[0]) );
for( UInt_t i=0; i<nval; ++i ) { fLGain[i] = 1.0; fRGain[i] = 1.0; }
for( UInt_t i=0; i<nval; ++i ) {
fLGain[i] = 1.0;
fRGain[i] = 1.0;
}

DBRequest calib_request[] = {
{ "L.off", fLOff, kDouble, nval, 1 },
Expand Down Expand Up @@ -378,6 +392,7 @@ Int_t THaScintillator::Decode( const THaEvData& evdata )
for( Int_t i = 0; i < fDetMap->GetSize(); i++ ) {
THaDetMap::Module* d = fDetMap->GetModule( i );
bool adc = ( d->model ? d->IsADC() : (i < fDetMap->GetSize()/2) );
bool not_common_stop_tdc = (adc || d->IsCommonStart());

// Loop over all channels that have a hit.
for( Int_t j = 0; j < evdata.GetNumChan( d->crate, d->slot ); j++) {
Expand Down Expand Up @@ -409,7 +424,7 @@ Int_t THaScintillator::Decode( const THaEvData& evdata )
// Get the data. If multiple hits on a TDC channel, take
// either first or last hit, depending on TDC mode
assert( nhit>0 );
Int_t ihit = ( adc || d->IsCommonStart() ) ? 0 : nhit-1;
Int_t ihit = ( not_common_stop_tdc ) ? 0 : nhit-1;
Int_t data = evdata.GetData( d->crate, d->slot, chan, ihit );

// Get the detector channel number, starting at 0
Expand Down

0 comments on commit 744cb11

Please sign in to comment.