Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • jlab/hallc/analyzer_software/hcana
  • whit/hcana
2 results
Show changes
Showing
with 627 additions and 560 deletions
Hall A/C Software
=================
Images for running containers for all aspects of the SANE experimental
analysis.
The starting point is a pre-built image for the ROOT libraries. (ubuntu + ROOT)
Main software libraries:
- `evio`: Built from https://github.com/whit2333/hallac_evio
- `analyzer`: Hall A analyzer (podd)from https://github.com/whit2333/analyzer
- `hcana`: Hall C analyzer from https://github.com/whit2333/hcana
These are all built using the super build project `cool_halls` (https://github.com/whit2333/cool_halls)
# You have to define the values in {}
#DOCKER_REPO={account-nr}.dkr.ecr.{region}.amazonaws.com
## optional aws-cli options
#AWS_CLI_PROFILE={aws-cli-profile}
#AWS_CLI_REGION={aws-cli-region}
# INSTALL
# - copy the files deploy.env, config.env, version.sh and Makefile to your repo
# - replace the vars in deploy.env
# - define the version script
# Build the container
make build
# Build and publish the container
make release
# Publish a container to AWS-ECR.
# This includes the login to the repo
make publish
# Run the container
make run
# Build an run the container
make up
# Stop the running container
make stop
# Build the container with differnt config and deploy file
make cnf=another_config.env dpl=another_deploy.env build
\ No newline at end of file
Bootstrap: docker
From: eicweb.phy.anl.gov:4567/jlab/hallc/analyzer_software/hcana:latest
%help
Hall A/C container.
Tools:
- evio : EVIO DAQ data format
- analyzer : Hall A analyzer (podd)
- hcana : Hall C analyzer (hcana)
- root : root version used for the analyzer
- rootls, rootbrowse, root_config
%labels
Maintainer "Whitney Armstrong, Sylvester Joosten"
Version v1.0
%setup -c /bin/bash
export SINGULARITY_SHELL=/bin/bash
%environment -c /bin/bash
export PYTHONPATH=/usr/local/lib:${PYTHONPATH}
export PATH=/usr/local/bin:${PATH}
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export ROOT_INCLUDE_PATH=/usr/local/include:/usr/local/include/podd:/usr/local/include/hcana
%post -c /bin/bash
echo "Hello from post"
echo "Install additional software here"
source /usr/local/bin/thisroot.sh
## libformat and nlohmann json used heavily in new generation replay scripts
## libformat
#cd /tmp && git clone https://github.com/fmtlib/fmt.git && cd fmt && \
# git checkout 5.3.0 && mkdir /tmp/build && cd /tmp/build && \
# cmake -DBUILD_SHARED_LIBS=TRUE ../fmt &&
# make -j4 install && cd /tmp && rm -r /tmp/build && rm -r /tmp/fmt
### json
# =======================
# global
# =======================
%runscript
echo "Launching a shell in the Hall A/C singularity container
exec bash
# =======================
# root
# =======================
%apprun root
root "$@"
%appenv root
export PYTHONPATH=/usr/local/lib:${PYTHONPATH}
export PATH=/usr/local/bin:${PATH}
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export ROOT_INCLUDE_PATH=/usr/local/include/podd:/usr/local/include/hcana
# =======================
# analyzer
# =======================
%apprun analyzer
analyzer "$@"
%appenv analyzer
export PYTHONPATH=/usr/local/lib:${PYTHONPATH}
export PATH=/usr/local/bin:${PATH}
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export ROOT_INCLUDE_PATH=/usr/local/include/podd:/usr/local/include/hcana
# =======================
# hcana
# =======================
%apphelp hcana
Run the Hall-C analyzer with same root-style arguments.
%apprun hcana
source /usr/local/bin/thisroot.sh
hcana "$@"
%appenv hcana
export DB_DIR=DBASE
export PYTHONPATH=/usr/local/lib:${PYTHONPATH}
export PATH=/usr/local/bin:${PATH}
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export ROOTSYS=/usr/local
export ROOT_INCLUDE_PATH=/usr/local/include
export ROOT_INCLUDE_PATH=/usr/local/include:/usr/local/include/podd:/usr/local/include/hcana
# =======================
# root-config
# =======================
%apprun root_config
root-config "$@"
%appenv root_config
export PYTHONPATH=/usr/local/lib:${PYTHONPATH}
export PATH=/usr/local/bin:${PATH}
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export ROOT_INCLUDE_PATH=/usr/local/include/podd:/usr/local/include/hcana
# =======================
# rootbrowse
# =======================
%apprun rootbrowse
rootbrowse "$@"
%appenv rootbrowse
export PYTHONPATH=/usr/local/lib:${PYTHONPATH}
export PATH=/usr/local/bin:${PATH}
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export ROOT_INCLUDE_PATH=/usr/local/include/podd:/usr/local/include/hcana
# =======================
# rootls
# =======================
%apprun rootls
rootls "$@"
%appenv rootls
export PYTHONPATH=/usr/local/lib:${PYTHONPATH}
export PATH=/usr/local/bin:${PATH}
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export ROOT_INCLUDE_PATH=/usr/local/include/podd:/usr/local/include/hcana
Subproject commit 9001670be3944886c4936d2b2eac8a94935b4390
Subproject commit 355b3ce629f8f47f107e2a0fcfa7ee55b3463b6c
......@@ -4,6 +4,7 @@ cmake_minimum_required(VERSION 3.5)
# Names of the main items we build here
set(LIBNAME HallC)
set(EXENAME hcana)
include(FindThreads)
#----------------------------------------------------------------------------
# Sources and headers
......
......@@ -7,8 +7,8 @@ namespace hcana {
Int_t Scandalizer::ReadOneEvent()
{
// Read one event from current run (fRun) and raw-decode it using the
// current decoder (fEvData)
// Read one event from current run (fRun) and raw-decode it using the
// current decoder (fEvData)
if( fDoBench ) {fBench->Begin("RawDecode");}
......
......@@ -39,7 +39,8 @@ THcAerogel::THcAerogel( const char* name, const char* description,
THaNonTrackingDetector(name,description,apparatus),
fPresentP(0),
fAdcPosTimeWindowMin(0), fAdcPosTimeWindowMax(0), fAdcNegTimeWindowMin(0),
fAdcNegTimeWindowMax(0), fRegionValue(0), fPosGain(0), fNegGain(0),
fAdcNegTimeWindowMax(0),fPedNegDefault(0),fPedPosDefault(0),
fRegionValue(0), fPosGain(0), fNegGain(0),
frPosAdcPedRaw(0), frPosAdcPulseIntRaw(0), frPosAdcPulseAmpRaw(0),
frPosAdcPulseTimeRaw(0), frPosAdcPed(0), frPosAdcPulseInt(0),
frPosAdcPulseAmp(0), frPosAdcPulseTime(0), frNegAdcPedRaw(0),
......@@ -59,7 +60,8 @@ THcAerogel::THcAerogel( const char* name, const char* description,
THcAerogel::THcAerogel( ) :
THaNonTrackingDetector(),
fAdcPosTimeWindowMin(0), fAdcPosTimeWindowMax(0), fAdcNegTimeWindowMin(0),
fAdcNegTimeWindowMax(0), fRegionValue(0), fPosGain(0), fNegGain(0),
fAdcNegTimeWindowMax(0),
fPedNegDefault(0),fPedPosDefault(0),fRegionValue(0), fPosGain(0), fNegGain(0),
frPosAdcPedRaw(0), frPosAdcPulseIntRaw(0), frPosAdcPulseAmpRaw(0),
frPosAdcPulseTimeRaw(0), frPosAdcPed(0), frPosAdcPulseInt(0),
frPosAdcPulseAmp(0), frPosAdcPulseTime(0), frNegAdcPedRaw(0),
......@@ -111,6 +113,8 @@ void THcAerogel::DeleteArrays()
delete [] fAdcPosTimeWindowMax; fAdcPosTimeWindowMax = 0;
delete [] fAdcNegTimeWindowMin; fAdcNegTimeWindowMin = 0;
delete [] fAdcNegTimeWindowMax; fAdcNegTimeWindowMax = 0;
delete [] fPedNegDefault; fPedNegDefault = 0;
delete [] fPedPosDefault; fPedPosDefault = 0;
// 6 GeV variables
delete fPosTDCHits; fPosTDCHits = NULL;
......@@ -296,6 +300,8 @@ Int_t THcAerogel::ReadDatabase( const TDatime& date )
fAdcPosTimeWindowMax = new Double_t [fNelem];
fAdcNegTimeWindowMin = new Double_t [fNelem];
fAdcNegTimeWindowMax = new Double_t [fNelem];
fPedNegDefault = new Int_t [fNelem];
fPedPosDefault = new Int_t [fNelem];
DBRequest list[]={
{"aero_num_regions", &fNRegions, kInt},
......@@ -315,6 +321,8 @@ Int_t THcAerogel::ReadDatabase( const TDatime& date )
{"aero_adcPosTimeWindowMax", fAdcPosTimeWindowMax, kDouble, static_cast<UInt_t>(fNelem), 1},
{"aero_adcNegTimeWindowMin", fAdcNegTimeWindowMin, kDouble, static_cast<UInt_t>(fNelem), 1},
{"aero_adcNegTimeWindowMax", fAdcNegTimeWindowMax, kDouble, static_cast<UInt_t>(fNelem), 1},
{"aero_PedNegDefault", fPedNegDefault, kInt, static_cast<UInt_t>(fNelem), 1},
{"aero_PedPosDefault", fPedPosDefault, kInt, static_cast<UInt_t>(fNelem), 1},
{"aero_adc_tdc_offset", &fAdcTdcOffset, kDouble, 0, 1},
{"aero_debug_adc", &fDebugAdc, kInt, 0, 1},
{"aero_six_gev_data", &fSixGevData, kInt, 0, 1},
......@@ -331,6 +339,8 @@ Int_t THcAerogel::ReadDatabase( const TDatime& date )
fAdcNegTimeWindowMin[ip] = -1000.;
fAdcPosTimeWindowMax[ip] = 1000.;
fAdcNegTimeWindowMax[ip] = 1000.;
fPedNegDefault[ip] = 0.;
fPedPosDefault[ip] = 0.;
}
fSixGevData = 0; // Set 6 GeV data parameter to false unless set in parameter file
......@@ -646,6 +656,21 @@ Int_t THcAerogel::Decode( const THaEvData& evdata )
if (rawPosAdcHit.GetPulseAmpRaw(thit) > 0) ((THcSignalHit*) fPosAdcErrorFlag->ConstructedAt(nrPosAdcHits))->Set(npmt, 0);
if (rawPosAdcHit.GetPulseAmpRaw(thit) <= 0) ((THcSignalHit*) fPosAdcErrorFlag->ConstructedAt(nrPosAdcHits))->Set(npmt, 1);
if (rawPosAdcHit.GetPulseAmpRaw(thit) <= 0) {
Double_t PeakPedRatio= rawPosAdcHit.GetF250_PeakPedestalRatio();
Int_t NPedSamples= rawPosAdcHit.GetF250_NPedestalSamples();
Double_t AdcToC = rawPosAdcHit.GetAdcTopC();
Double_t AdcToV = rawPosAdcHit.GetAdcTomV();
if (fPedPosDefault[npmt-1] !=0) {
Double_t tPulseInt = AdcToC*(rawPosAdcHit.GetPulseIntRaw(thit) - fPedPosDefault[npmt-1]*PeakPedRatio);
((THcSignalHit*) frPosAdcPulseInt->ConstructedAt(nrPosAdcHits))->Set(npmt, tPulseInt);
((THcSignalHit*) frPosAdcPedRaw->ConstructedAt(nrPosAdcHits))->Set(npmt, fPedPosDefault[npmt-1]);
((THcSignalHit*) frPosAdcPed->ConstructedAt(nrPosAdcHits))->Set(npmt, float(fPedPosDefault[npmt-1])/float(NPedSamples)*AdcToV);
}
((THcSignalHit*) frPosAdcPulseAmp->ConstructedAt(nrPosAdcHits))->Set(npmt, 0.);
}
++nrPosAdcHits;
fTotNumAdcHits++;
......@@ -669,6 +694,21 @@ Int_t THcAerogel::Decode( const THaEvData& evdata )
if (rawNegAdcHit.GetPulseAmpRaw(thit) > 0) ((THcSignalHit*) fNegAdcErrorFlag->ConstructedAt(nrNegAdcHits))->Set(npmt, 0);
if (rawNegAdcHit.GetPulseAmpRaw(thit) <= 0) ((THcSignalHit*) fNegAdcErrorFlag->ConstructedAt(nrNegAdcHits))->Set(npmt, 1);
if (rawNegAdcHit.GetPulseAmpRaw(thit) <= 0) {
Double_t PeakPedRatio= rawNegAdcHit.GetF250_PeakPedestalRatio();
Int_t NPedSamples= rawNegAdcHit.GetF250_NPedestalSamples();
Double_t AdcToC = rawNegAdcHit.GetAdcTopC();
Double_t AdcToV = rawNegAdcHit.GetAdcTomV();
if (fPedNegDefault[npmt-1] !=0) {
Double_t tPulseInt = AdcToC*(rawNegAdcHit.GetPulseIntRaw(thit) - fPedNegDefault[npmt-1]*PeakPedRatio);
((THcSignalHit*) frNegAdcPulseInt->ConstructedAt(nrNegAdcHits))->Set(npmt, tPulseInt);
((THcSignalHit*) frNegAdcPedRaw->ConstructedAt(nrNegAdcHits))->Set(npmt, fPedNegDefault[npmt-1]);
((THcSignalHit*) frNegAdcPed->ConstructedAt(nrNegAdcHits))->Set(npmt, float(fPedNegDefault[npmt-1])/float(NPedSamples)*AdcToV);
}
((THcSignalHit*) frNegAdcPulseAmp->ConstructedAt(nrNegAdcHits))->Set(npmt, 0.);
}
++nrNegAdcHits;
fTotNumAdcHits++;
fTotNumNegAdcHits++;
......@@ -690,6 +730,8 @@ Int_t THcAerogel::CoarseProcess( TClonesArray& ) //tracks
{
Double_t StartTime = 0.0;
if( fglHod ) StartTime = fglHod->GetStartTime();
Double_t OffsetTime = 0.0;
if( fglHod ) OffsetTime = fglHod->GetOffsetTime();
//cout << " starttime = " << StartTime << endl;
// Loop over the elements in the TClonesArray
for(Int_t ielem = 0; ielem < frPosAdcPulseInt->GetEntries(); ielem++) {
......@@ -700,18 +742,13 @@ Int_t THcAerogel::CoarseProcess( TClonesArray& ) //tracks
Double_t pulseIntRaw = ((THcSignalHit*) frPosAdcPulseIntRaw->ConstructedAt(ielem))->GetData();
Double_t pulseAmp = ((THcSignalHit*) frPosAdcPulseAmp->ConstructedAt(ielem))->GetData();
Double_t pulseTime = ((THcSignalHit*) frPosAdcPulseTime->ConstructedAt(ielem))->GetData();
Double_t adctdcdiffTime = StartTime-pulseTime;
Bool_t errorFlag = ((THcSignalHit*) fPosAdcErrorFlag->ConstructedAt(ielem))->GetData();
Double_t adctdcdiffTime = StartTime-pulseTime+OffsetTime;
//// Bool_t pulseTimeCut = adctdcdiffTime > fAdcTimeWindowMin && adctdcdiffTime < fAdcTimeWindowMax;
Bool_t pulseTimeCut = adctdcdiffTime > fAdcPosTimeWindowMin[npmt] && adctdcdiffTime < fAdcPosTimeWindowMax[npmt];
// By default, the last hit within the timing cut will be considered "good"
if (!errorFlag)
{
fGoodPosAdcMult.at(npmt) += 1;
}
if (!errorFlag && pulseTimeCut) {
if (pulseTimeCut) {
fGoodPosAdcPed.at(npmt) = pulsePed;
// cout << " out = " << npmt << " " << frPosAdcPulseInt->GetEntries() << " " <<fGoodPosAdcMult.at(npmt);
fGoodPosAdcPulseInt.at(npmt) = pulseInt;
......@@ -738,17 +775,13 @@ Int_t THcAerogel::CoarseProcess( TClonesArray& ) //tracks
Double_t pulseIntRaw = ((THcSignalHit*) frNegAdcPulseIntRaw->ConstructedAt(ielem))->GetData();
Double_t pulseAmp = ((THcSignalHit*) frNegAdcPulseAmp->ConstructedAt(ielem))->GetData();
Double_t pulseTime = ((THcSignalHit*) frNegAdcPulseTime->ConstructedAt(ielem))->GetData();
Double_t adctdcdiffTime = StartTime-pulseTime;
Bool_t errorFlag = ((THcSignalHit*) fNegAdcErrorFlag->ConstructedAt(ielem))->GetData();
Double_t adctdcdiffTime = StartTime-pulseTime+OffsetTime;
//// Bool_t pulseTimeCut = adctdcdiffTime > fAdcTimeWindowMin && adctdcdiffTime < fAdcTimeWindowMax;
Bool_t pulseTimeCut = adctdcdiffTime > fAdcNegTimeWindowMin[npmt] && adctdcdiffTime < fAdcNegTimeWindowMax[npmt];
if (!errorFlag)
{
fGoodNegAdcMult.at(npmt) += 1;
}
// By default, the last hit within the timing cut will be considered "good"
if (!errorFlag && pulseTimeCut) {
if (pulseTimeCut) {
fGoodNegAdcPed.at(npmt) = pulsePed;
fGoodNegAdcPulseIntRaw.at(npmt) = pulseIntRaw;
fGoodNegAdcPulseAmp.at(npmt) = pulseAmp;
......
......@@ -73,6 +73,8 @@ class THcAerogel : public THaNonTrackingDetector, public THcHitList {
Double_t *fAdcPosTimeWindowMax;
Double_t *fAdcNegTimeWindowMin;
Double_t *fAdcNegTimeWindowMax;
Int_t* fPedNegDefault;
Int_t* fPedPosDefault;
Double_t fAdcTdcOffset;
Double_t *fRegionValue;
......
......@@ -129,27 +129,20 @@ void THcCherenkov::DeleteArrays() {
fGain = NULL;
// 6 Gev variables
delete[] fPedSum;
fPedSum = NULL;
delete[] fPedSum2;
fPedSum2 = NULL;
delete[] fPedLimit;
fPedLimit = NULL;
delete[] fPedMean;
fPedMean = NULL;
delete[] fPedCount;
fPedCount = NULL;
delete[] fPed;
fPed = NULL;
delete[] fThresh;
fThresh = NULL;
delete[] fAdcTimeWindowMin;
fAdcTimeWindowMin = 0;
delete[] fAdcTimeWindowMax;
fAdcTimeWindowMax = 0;
delete[] fRegionValue;
fRegionValue = 0;
delete [] fPedSum; fPedSum = NULL;
delete [] fPedSum2; fPedSum2 = NULL;
delete [] fPedLimit; fPedLimit = NULL;
delete [] fPedMean; fPedMean = NULL;
delete [] fPedCount; fPedCount = NULL;
delete [] fPed; fPed = NULL;
delete [] fThresh; fThresh = NULL;
delete [] fPedDefault; fPedDefault = 0;
delete [] fAdcTimeWindowMin; fAdcTimeWindowMin = 0;
delete [] fAdcTimeWindowMax; fAdcTimeWindowMax = 0;
delete [] fRegionValue; fRegionValue = 0;
}
//_____________________________________________________________________________
......@@ -212,39 +205,48 @@ Int_t THcCherenkov::ReadDatabase(const TDatime& date) {
// << GetName() << " with " << fNelem << " PMTs" << endl;
// 6 GeV pedestal paramters
fPedLimit = new Int_t[fNelem];
fGain = new Double_t[fNelem];
fPedMean = new Double_t[fNelem];
fAdcTimeWindowMin = new Double_t[fNelem];
fAdcTimeWindowMax = new Double_t[fNelem];
fPedLimit = new Int_t[fNelem];
fGain = new Double_t[fNelem];
fPedMean = new Double_t[fNelem];
fAdcTimeWindowMin = new Double_t[fNelem];
fAdcTimeWindowMax= new Double_t[fNelem];
fPedDefault= new Int_t[fNelem];
// Region parameters
fRegionsValueMax = fNRegions * 8;
fRegionValue = new Double_t[fRegionsValueMax];
fAdcGoodElem = new Int_t[fNelem];
fAdcPulseAmpTest = new Double_t[fNelem];
DBRequest list[] = {{"_ped_limit", fPedLimit, kInt, (UInt_t)fNelem, optional},
{"_adc_to_npe", fGain, kDouble, (UInt_t)fNelem},
{"_red_chi2_min", &fRedChi2Min, kDouble},
{"_red_chi2_max", &fRedChi2Max, kDouble},
{"_beta_min", &fBetaMin, kDouble},
{"_beta_max", &fBetaMax, kDouble},
{"_enorm_min", &fENormMin, kDouble},
{"_enorm_max", &fENormMax, kDouble},
{"_dp_min", &fDpMin, kDouble},
{"_dp_max", &fDpMax, kDouble},
{"_mirror_zpos", &fMirrorZPos, kDouble},
{"_npe_thresh", &fNpeThresh, kDouble},
{"_debug_adc", &fDebugAdc, kInt, 0, 1},
{"_adcTimeWindowMin", fAdcTimeWindowMin, kDouble, (UInt_t)fNelem, 1},
{"_adcTimeWindowMax", fAdcTimeWindowMax, kDouble, (UInt_t)fNelem, 1},
{"_adc_tdc_offset", &fAdcTdcOffset, kDouble, 0, 1},
{"_region", &fRegionValue[0], kDouble, (UInt_t)fRegionsValueMax},
{"_adcrefcut", &fADC_RefTimeCut, kInt, 0, 1},
{0}};
for (Int_t i = 0; i < fNelem; i++) {
fAdcTimeWindowMin[i] = -1000.;
fAdcTimeWindowMax[i] = 1000.;
DBRequest list[]={
{"_ped_limit", fPedLimit, kInt, (UInt_t) fNelem, optional},
{"_adc_to_npe", fGain, kDouble, (UInt_t) fNelem},
{"_red_chi2_min", &fRedChi2Min, kDouble},
{"_red_chi2_max", &fRedChi2Max, kDouble},
{"_beta_min", &fBetaMin, kDouble},
{"_beta_max", &fBetaMax, kDouble},
{"_enorm_min", &fENormMin, kDouble},
{"_enorm_max", &fENormMax, kDouble},
{"_dp_min", &fDpMin, kDouble},
{"_dp_max", &fDpMax, kDouble},
{"_mirror_zpos", &fMirrorZPos, kDouble},
{"_npe_thresh", &fNpeThresh, kDouble},
{"_debug_adc", &fDebugAdc, kInt, 0, 1},
{"_adcTimeWindowMin", fAdcTimeWindowMin, kDouble,(UInt_t) fNelem,1},
{"_adcTimeWindowMax", fAdcTimeWindowMax, kDouble, (UInt_t) fNelem,1},
{"_PedDefault", fPedDefault, kInt, (UInt_t) fNelem,1},
{"_adc_tdc_offset", &fAdcTdcOffset, kDouble, 0, 1},
{"_region", &fRegionValue[0], kDouble, (UInt_t) fRegionsValueMax},
{"_adcrefcut", &fADC_RefTimeCut, kInt, 0, 1},
{0}
};
for (Int_t i=0;i<fNelem;i++) {
fAdcTimeWindowMin[i]=-1000.;
fAdcTimeWindowMax[i]=1000.;
fPedDefault[i]=0;
}
fDebugAdc = 0; // Set ADC debug parameter to false unless set in parameter file
fAdcTdcOffset = 0.0;
......@@ -298,32 +300,36 @@ Int_t THcCherenkov::DefineVariables(EMode mode) {
} // end debug statement
RVarDef vars[] = {
{"adcCounter", "ADC counter numbers", "frAdcPulseIntRaw.THcSignalHit.GetPaddleNumber()"},
{"adcErrorFlag", "Error Flag for When FPGA Fails", "fAdcErrorFlag.THcSignalHit.GetData()"},
{"numGoodAdcHits", "Number of Good ADC Hits Per PMT",
"fNumGoodAdcHits"}, // Cherenkov occupancy
{"totNumGoodAdcHits", "Total Number of Good ADC Hits",
"fTotNumGoodAdcHits"}, // Cherenkov multiplicity
{"numTracksMatched", "Number of Tracks Matched Per Region", "fNumTracksMatched"},
{"numTracksFired", "Number of Tracks that Fired Per Region", "fNumTracksFired"},
{"totNumTracksMatched", "Total Number of Tracks Matched Per Region", "fTotNumTracksMatched"},
{"totNumTracksFired", "Total Number of Tracks that Fired", "fTotNumTracksFired"},
{"xAtCer", "Track X at Cherenkov mirror", "fXAtCer"},
{"yAtCer", "Track Y at Cherenkov mirror", "fYAtCer"},
{"npe", "Number of PEs", "fNpe"},
{"npeSum", "Total Number of PEs", "fNpeSum"},
{"goodAdcPed", "Good ADC pedestals", "fGoodAdcPed"},
{"goodAdcMult", "Good ADC Multiplicity", "fGoodAdcMult"},
{"goodAdcHitUsed", "Good ADC Hit Used", "fGoodAdcHitUsed"},
{"goodAdcPulseInt", "Good ADC pulse integrals", "fGoodAdcPulseInt"},
{"goodAdcPulseIntRaw", "Good ADC raw pulse integrals", "fGoodAdcPulseIntRaw"},
{"goodAdcPulseAmp", "Good ADC pulse amplitudes", "fGoodAdcPulseAmp"},
{"goodAdcPulseTime", "Good ADC pulse times", "fGoodAdcPulseTime"},
{"goodAdcTdcDiffTime", "Good Hodo Start - ADC pulse times", "fGoodAdcTdcDiffTime"},
{0}};
{"adcCounter", "ADC counter numbers", "frAdcPulseIntRaw.THcSignalHit.GetPaddleNumber()"},
{"adcErrorFlag", "Error Flag for When FPGA Fails", "fAdcErrorFlag.THcSignalHit.GetData()"},
{"numGoodAdcHits", "Number of Good ADC Hits Per PMT", "fNumGoodAdcHits"}, // Cherenkov occupancy
{"totNumGoodAdcHits", "Total Number of Good ADC Hits", "fTotNumGoodAdcHits"}, // Cherenkov multiplicity
{"numTracksMatched", "Number of Tracks Matched Per Region", "fNumTracksMatched"},
{"numTracksFired", "Number of Tracks that Fired Per Region", "fNumTracksFired"},
{"totNumTracksMatched", "Total Number of Tracks Matched Per Region", "fTotNumTracksMatched"},
{"totNumTracksFired", "Total Number of Tracks that Fired", "fTotNumTracksFired"},
{"xAtCer", "Track X at Cherenkov mirror", "fXAtCer"},
{"yAtCer", "Track Y at Cherenkov mirror", "fYAtCer"},
{"npe", "Number of PEs", "fNpe"},
{"npeSum", "Total Number of PEs", "fNpeSum"},
{"goodAdcPed", "Good ADC pedestals", "fGoodAdcPed"},
{"goodAdcMult", "Good ADC Multiplicity", "fGoodAdcMult"},
{"goodAdcHitUsed", "Good ADC Hit Used", "fGoodAdcHitUsed"},
{"goodAdcPulseInt", "Good ADC pulse integrals", "fGoodAdcPulseInt"},
{"goodAdcPulseIntRaw", "Good ADC raw pulse integrals", "fGoodAdcPulseIntRaw"},
{"goodAdcPulseAmp", "Good ADC pulse amplitudes", "fGoodAdcPulseAmp"},
{"goodAdcPulseTime", "Good ADC pulse times", "fGoodAdcPulseTime"},
{"goodAdcTdcDiffTime", "Good Hodo Start - ADC pulse times", "fGoodAdcTdcDiffTime"},
{"RefTime", "Raw ADC RefTime (chan) ", "fRefTime"}, // Raw reference time
{ 0 }
};
return DefineVarsFromList(vars, mode);
}
......@@ -360,6 +366,7 @@ void THcCherenkov::Clear(Option_t* opt) {
fYAtCer = 0.0;
fNpeSum = 0.0;
fRefTime=kBig;
frAdcPedRaw->Clear();
frAdcPulseIntRaw->Clear();
......@@ -406,7 +413,12 @@ Int_t THcCherenkov::Decode(const THaEvData& evdata) {
}
fNhits = DecodeToHitList(evdata, !present);
if (gHaCuts->Result("Pedestal_event")) {
//THcHallCSpectrometer *app = dynamic_cast<THcHallCSpectrometer*>(GetApparatus());
// cout << "Cerenkov Event num = " << evdata.GetEvNum() << " spec = " << app->GetName() << endl;
if(gHaCuts->Result("Pedestal_event")) {
AccumulatePedestals(fRawHitList);
fAnalyzePedestals = 1; // Analyze pedestals first normal events
return (0);
......@@ -421,14 +433,16 @@ Int_t THcCherenkov::Decode(const THaEvData& evdata) {
UInt_t nrAdcHits = 0;
_waveforms.clear();
while (ihit < fNhits) {
THcCherenkovHit* hit = (THcCherenkovHit*)fRawHitList->At(ihit);
Int_t npmt = hit->fCounter;
THcRawAdcHit& rawAdcHit = hit->GetRawAdcHitPos();
_waveforms.push_back({rawAdcHit.GetSampleBuffer()});
while(ihit < fNhits) {
THcCherenkovHit* hit = (THcCherenkovHit*) fRawHitList->At(ihit);
Int_t npmt = hit->fCounter;
THcRawAdcHit& rawAdcHit = hit->GetRawAdcHitPos();
if (rawAdcHit.GetNPulses() >0 && rawAdcHit.HasRefTime()) {
fRefTime=rawAdcHit.GetRefTime() ;
}
//if (rawAdcHit.GetNPulses()>0) cout << "Cer npmt = " << " ped = " << rawAdcHit.GetPed() << endl;
for (UInt_t thit = 0; thit < rawAdcHit.GetNPulses(); thit++) {
......@@ -455,6 +469,23 @@ Int_t THcCherenkov::Decode(const THaEvData& evdata) {
if (rawAdcHit.GetPulseAmpRaw(thit) <= 0)
((THcSignalHit*)fAdcErrorFlag->ConstructedAt(nrAdcHits))->Set(npmt, 1);
if (rawAdcHit.GetPulseAmpRaw(thit) <= 0) {
Double_t PeakPedRatio= rawAdcHit.GetF250_PeakPedestalRatio();
Int_t NPedSamples= rawAdcHit.GetF250_NPedestalSamples();
Double_t AdcToC = rawAdcHit.GetAdcTopC();
Double_t AdcToV = rawAdcHit.GetAdcTomV();
if (fPedDefault[npmt-1] !=0) {
Double_t tPulseInt = AdcToC*(rawAdcHit.GetPulseIntRaw(thit) - fPedDefault[npmt-1]*PeakPedRatio);
((THcSignalHit*) frAdcPulseInt->ConstructedAt(nrAdcHits))->Set(npmt, tPulseInt);
((THcSignalHit*) frAdcPedRaw->ConstructedAt(nrAdcHits))->Set(npmt, fPedDefault[npmt-1]);
((THcSignalHit*) frAdcPed->ConstructedAt(nrAdcHits))->Set(npmt, float(fPedDefault[npmt-1])/float(NPedSamples)*AdcToV);
}
((THcSignalHit*) frAdcPulseAmp->ConstructedAt(nrAdcHits))->Set(npmt, 0.);
}
++nrAdcHits;
fTotNumAdcHits++;
fNumAdcHits.at(npmt - 1) = npmt;
......@@ -471,7 +502,9 @@ Int_t THcCherenkov::ApplyCorrections(void) { return (0); }
Int_t THcCherenkov::CoarseProcess(TClonesArray&) {
Double_t StartTime = 0.0;
if( fglHod ) StartTime = fglHod->GetStartTime();
for(Int_t ipmt = 0; ipmt < fNelem; ipmt++) {
Double_t OffsetTime = 0.0;
if( fglHod ) OffsetTime = fglHod->GetOffsetTime();
for(Int_t ipmt = 0; ipmt < fNelem; ipmt++) {
fAdcPulseAmpTest[ipmt] = -1000.;
fAdcGoodElem[ipmt]=-1;
}
......@@ -480,17 +513,18 @@ Int_t THcCherenkov::CoarseProcess(TClonesArray&) {
Int_t npmt = ((THcSignalHit*) frAdcPulseInt->ConstructedAt(ielem))->GetPaddleNumber() - 1;
Double_t pulseTime = ((THcSignalHit*) frAdcPulseTime->ConstructedAt(ielem))->GetData();
Double_t pulseAmp = ((THcSignalHit*) frAdcPulseAmp->ConstructedAt(ielem))->GetData();
Double_t adctdcdiffTime = StartTime-pulseTime;
Bool_t errorFlag = ((THcSignalHit*) fAdcErrorFlag->ConstructedAt(ielem))->GetData();
Bool_t errorFlag = ((THcSignalHit*) fAdcErrorFlag->ConstructedAt(ielem))->GetData();
Double_t adctdcdiffTime = StartTime-pulseTime+OffsetTime;
Bool_t pulseTimeCut = adctdcdiffTime > fAdcTimeWindowMin[npmt] && adctdcdiffTime < fAdcTimeWindowMax[npmt];
if (!errorFlag)
{
fGoodAdcMult.at(npmt) += 1;
}
if (!errorFlag && pulseTimeCut && pulseAmp > fAdcPulseAmpTest[npmt]) {
fAdcGoodElem[npmt]=ielem;
fAdcPulseAmpTest[npmt] = pulseAmp;
}
fGoodAdcMult.at(npmt) += 1;
if (!errorFlag) {
if (pulseTimeCut && pulseAmp > fAdcPulseAmpTest[npmt]) {
fAdcGoodElem[npmt]=ielem;
fAdcPulseAmpTest[npmt] = pulseAmp;
}
} else {
if (pulseTimeCut) fAdcGoodElem[npmt]=ielem;
}
}
// Loop over the npmt
for(Int_t npmt = 0; npmt < fNelem; npmt++) {
......@@ -501,17 +535,18 @@ Int_t THcCherenkov::CoarseProcess(TClonesArray&) {
Double_t pulseIntRaw = ((THcSignalHit*) frAdcPulseIntRaw->ConstructedAt(ielem))->GetData();
Double_t pulseAmp = ((THcSignalHit*) frAdcPulseAmp->ConstructedAt(ielem))->GetData();
Double_t pulseTime = ((THcSignalHit*) frAdcPulseTime->ConstructedAt(ielem))->GetData();
Double_t adctdcdiffTime = StartTime-pulseTime;
// By default, the last hit within the timing cut will be considered "good"
Double_t adctdcdiffTime = StartTime-pulseTime+OffsetTime;
fGoodAdcPed.at(npmt) = pulsePed;
fGoodAdcHitUsed.at(npmt) = ielem + 1;
fGoodAdcPulseInt.at(npmt) = pulseInt;
fGoodAdcPulseIntRaw.at(npmt) = pulseIntRaw;
fGoodAdcPulseAmp.at(npmt) = pulseAmp;
fGoodAdcPulseTime.at(npmt) = pulseTime;
fGoodAdcTdcDiffTime.at(npmt) = adctdcdiffTime;
fNpe.at(npmt) = fGain[npmt] * fGoodAdcPulseInt.at(npmt);
fGoodAdcTdcDiffTime.at(npmt) = adctdcdiffTime;
fNpe.at(npmt) = fGain[npmt]*pulseInt;
fNpeSum += fNpe.at(npmt);
fTotNumGoodAdcHits++;
......
......@@ -69,6 +69,7 @@ public:
Int_t fTotNumGoodAdcHits;
Int_t fTotNumTracksMatched;
Int_t fTotNumTracksFired;
Double_t fRefTime;
Double_t fNpeSum;
Double_t* fGain;
......@@ -102,6 +103,7 @@ public:
Double_t fNpeThresh;
Double_t* fAdcTimeWindowMin;
Double_t* fAdcTimeWindowMax;
Int_t* fPedDefault;
Double_t fAdcTdcOffset;
Double_t* fRegionValue;
......
......@@ -65,6 +65,14 @@ void THcCoinTime::Clear( Option_t* opt )
fROC2_ePosCoinTime=kBig;
fROC1_RAW_CoinTime=kBig;
fROC2_RAW_CoinTime=kBig;
fTRIG1_ePosCoinTime=kBig;
fTRIG4_ePosCoinTime=kBig;
fTRIG1_ePiCoinTime=kBig;
fTRIG4_ePiCoinTime=kBig;
fTRIG1_eKCoinTime=kBig;
fTRIG4_eKCoinTime=kBig;
fTRIG1_epCoinTime=kBig;
fTRIG4_epCoinTime=kBig;
}
//_____________________________________________________________________________
......@@ -263,6 +271,9 @@ Int_t THcCoinTime::Process( const THaEvData& evdata )
Double_t hms_ypfp = theHMSTrack->GetPhi();
Double_t HMS_FPtime = theHMSTrack->GetFPTime();
if (SHMS_FPtime==-2000 || HMS_FPtime==-2000) return 1;
if (SHMS_FPtime==-1000 || HMS_FPtime==-1000) return 1;
//Get raw TDC Times for HMS/SHMS (3/4 trigger)
pTRIG1_TdcTime_ROC1 = fCoinDet->Get_CT_Trigtime(0); //SHMS
pTRIG4_TdcTime_ROC1 = fCoinDet->Get_CT_Trigtime(1); //HMS
......
......@@ -227,7 +227,7 @@ protected:
public:
THcDriftChamberPlane* GetPlane(unsigned int i_plane) {
if(i_plane < fNPlanes) {
if(static_cast<int>(i_plane) < fNPlanes) {
return fPlanes[i_plane];
}
return nullptr;
......
......@@ -298,6 +298,7 @@ Int_t THcDriftChamberPlane::DefineVariables( EMode mode )
{"dist","Drift distancess",
"fHits.THcDCHit.GetDist()"},
{"nhit", "Number of hits", "GetNHits()"},
{"RefTime", "TDC reference time", "fTdcRefTime"},
{ 0 }
};
......@@ -351,7 +352,7 @@ Int_t THcDriftChamberPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit)
fHits->Clear();
fRawHits->Clear();
fTdcRefTime = kBig;
Int_t nrawhits = rawhits->GetLast()+1;
fNRawhits=0;
Int_t ihit = nexthit;
......@@ -365,6 +366,7 @@ Int_t THcDriftChamberPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit)
Int_t wireNum = hit->fCounter;
THcDCWire* wire = GetWire(wireNum);
Bool_t First_Hit_In_Window = kTRUE;
if (hit->GetRawTdcHit().HasRefTime()) fTdcRefTime = hit->GetRawTdcHit().GetRefTime();
for(UInt_t mhit=0; mhit<hit->GetRawTdcHit().GetNHits(); mhit++) {
fNRawhits++;
/* Sort into early, late and ontime */
......@@ -391,6 +393,7 @@ Int_t THcDriftChamberPlane::SubtractStartTime()
{
Double_t StartTime = 0.0;
if( fglHod ) StartTime = fglHod->GetStartTime();
if (StartTime == -1000) StartTime = 0.0;
for(Int_t ihit=0;ihit<GetNHits();ihit++) {
THcDCHit *thishit = (THcDCHit*) fHits->At(ihit);
Double_t temptime= thishit->GetTime()-StartTime;
......
......@@ -86,6 +86,8 @@ protected:
TClonesArray* fHits;
TClonesArray* fRawHits;
TClonesArray* fWires;
Double_t fTdcRefTime;
Int_t fVersion;
Int_t fWireOrder;
......
......@@ -142,6 +142,10 @@ Int_t THcHallCSpectrometer::DefineVariables( EMode mode )
fIsSetup = ( mode == kDefine );
RVarDef vars[] = {
{ "tr.betachisq", "Chi2 of beta", "fTracks.THaTrack.GetBetaChi2()"},
{ "tr.GoodPlane4", "Flag for track hitting hodo plane 4", "fTracks.THaTrack.GetGoodPlane4()"},
{ "tr.GoodPlane3", "Flag for track hitting hodo plane 3", "fTracks.THaTrack.GetGoodPlane3()"},
{ "tr.fptime", "Track hodo focal plane time", "fTracks.THaTrack.GetFPTime()"},
{ "tr.npmt", "Track number of hodo PMTs hit", "fTracks.THaTrack.GetNPMT()"},
{ "tr.PruneSelect", "Prune Select ID", "fPruneSelect"},
{ "present", "Trigger Type includes this spectrometer", "fPresent"},
{ 0 }
......
This diff is collapsed.
......@@ -6,107 +6,124 @@
// THcHelicity
//
// Helicity of the beam - from QWEAK electronics in delayed mode
//
//
////////////////////////////////////////////////////////////////////////
#include "hcana/Logger.h"
#include "THaHelicityDet.h"
#include "THcHelicityReader.h"
#include "hcana/Logger.h"
class TH1F;
class THcHelicityScaler;
class THcHelicity : public hcana::ConfigLogging<THaHelicityDet>, public THcHelicityReader {
class THcHelicity : public THaHelicityDet, public THcHelicityReader {
public:
THcHelicity( const char* name, const char* description,
THaApparatus* a = NULL );
THcHelicity(const char* name, const char* description, THaApparatus* a = NULL);
THcHelicity();
virtual ~THcHelicity();
virtual EStatus Init(const TDatime& date);
virtual void MakePrefix();
virtual void MakePrefix();
virtual Int_t Begin( THaRunBase* r=0 );
virtual void Clear( Option_t* opt = "" );
virtual Int_t Decode( const THaEvData& evdata );
virtual Int_t End( THaRunBase* r=0 );
virtual void SetDebug( Int_t level );
virtual Bool_t HelicityValid() const { return fValidHel; }
virtual Int_t Begin(THaRunBase* r = 0);
virtual void Clear(Option_t* opt = "");
virtual Int_t Decode(const THaEvData& evdata);
virtual Int_t End(THaRunBase* r = 0);
virtual void SetDebug(Int_t level);
virtual void SetHelicityScaler(THcHelicityScaler* f);
void PrintEvent(Int_t evtnum);
protected:
void Setup(const char* name, const char* description);
void Setup(const char* name, const char* description);
std::string fKwPrefix;
void FillHisto();
void LoadHelicity(Int_t reportedhelicity, Int_t cyclecount, Int_t missedcycles);
Int_t RanBit30(Int_t ranseed);
Int_t GetSeed30(Int_t currentseed);
// Fixed Parameters
Int_t fRingSeed_reported_initial;
Int_t fFirstCycle;
Int_t fRingSeed_reported_initial;
Int_t fFirstCycle;
Bool_t fFixFirstCycle;
Double_t fFreq;
Double_t fRecommendedFreq;
Double_t fTIPeriod; // Reversal period in TI time units
Double_t fTIPeriod; // Reversal period in TI time units
Double_t fPeriodCheck;
Double_t fPeriodCheckOffset;
Double_t fCycle;
Bool_t fFirstEvProcessed;
Int_t fLastReportedHelicity;
Bool_t fFirstEvProcessed;
Int_t fLastReportedHelicity;
Long64_t fFirstEvTime;
Long64_t fLastEvTime;
Long64_t fLastMPSTime;
Int_t fReportedHelicity;
Int_t fMPS;
Int_t fPredictedHelicity;
Int_t fActualHelicity;
Int_t fQuartetStartHelicity;
Int_t fQuartetStartPredictedHelicity;
Bool_t fFoundMPS;
Bool_t fFoundQuartet; // True if quartet phase probably found.
Bool_t fIsNewCycle;
Int_t fNCycle; // Count of # of helicity cycles
Int_t fQuartet[4]; // For finding and checking quartet pattern
Int_t fNBits;
Int_t fnQrt; // Position in quartet
Int_t fReportedHelicity;
Int_t fMPS;
Int_t fPredictedHelicity;
Int_t fActualHelicity;
Int_t fQuartetStartHelicity;
Int_t fQuartetStartPredictedHelicity;
Bool_t fFoundMPS;
Bool_t fFoundQuartet; // True if quartet phase probably found.
Bool_t fIsNewCycle;
Int_t fNCycle; // Count of # of helicity cycles
Int_t fNQuartet; // Quartet count
Int_t fNLastQuartet;
Int_t fQuartet[4]; // For finding and checking quartet pattern
Int_t fNBits;
Int_t fnQrt; // Position in quartet
Bool_t fHaveQRT; // QRT signal exists
Int_t fNQRTProblems;
Int_t fRingSeed_reported;
Int_t fRingSeed_actual;
// Offset between the ring reported value and the reported value
Int_t fHelDelay;
Int_t fHelDelay;
// delay of helicity (# windows)
Int_t fMAXBIT;
//number of bit in the pseudo random helcity generator
Int_t fMAXBIT;
// number of bit in the pseudo random helcity generator
std::vector<Int_t> fPatternSequence; // sequence of 0 and 1 in the pattern
Int_t fQWEAKNPattern; // maximum of event in the pattern
Bool_t HWPIN;
Int_t fQWEAKNPattern; // maximum of event in the pattern
Bool_t HWPIN;
Int_t fQrt;
Int_t fTSettle;
Bool_t fValidHel;
Int_t fHelicityLastTIR;
Int_t fPatternLastTIR;
void SetErrorCode(Int_t error);
void SetErrorCode(Int_t error);
Double_t fErrorCode;
Int_t fEvtype; // Current CODA event type
Int_t fLastActualHelicity;
Int_t fEvNumCheck;
Bool_t fDisabled;
static const Int_t NHIST = 2;
TH1F* fHisto[NHIST];
virtual Int_t DefineVariables( EMode mode = kDefine );
virtual Int_t ReadDatabase( const TDatime& date );
ClassDef(THcHelicity,0) // Beam helicity from QWEAK electronics in delayed mode
Int_t fEvtype; // Current CODA event type
Int_t fLastActualHelicity;
Int_t fEvNumCheck;
Bool_t fDisabled;
static const Int_t NHIST = 2;
TH1F* fHisto[NHIST];
virtual Int_t DefineVariables(EMode mode = kDefine);
virtual Int_t ReadDatabase(const TDatime& date);
THcHelicityScaler* fglHelicityScaler = nullptr;
Int_t* fHelicityHistory = nullptr;
Int_t fLastHelpCycle;
Int_t fScaleQuartet;
Int_t fQuadPattern[8];
Int_t fHelperHistory;
Int_t fHelperQuartetHistory;
Int_t fScalerSeed;
Int_t lastispos;
Int_t evnum;
Int_t fThisScaleHel;
Int_t fLastScaleHel;
Int_t fLastLastScaleHel;
ClassDef(THcHelicity, 0) // Beam helicity from QWEAK electronics in delayed mode
};
#endif
......
......@@ -7,30 +7,28 @@
////////////////////////////////////////////////////////////////////////
#include "THcHelicityReader.h"
#include "TError.h"
#include "TH1F.h"
#include "THaAnalysisObject.h" // For LoadDB
#include "THaEvData.h"
#include "THcGlobals.h"
#include "THcParmList.h"
#include "TMath.h"
#include "TError.h"
#include "VarDef.h"
#include "THaAnalysisObject.h" // For LoadDB
#include "hcana/Logger.h"
#include <iostream>
#include <vector>
#include "TH1F.h"
using namespace std;
//____________________________________________________________________
THcHelicityReader::THcHelicityReader()
: fTITime(0), fTITime_last(0), fTITime_rollovers(0),
fHaveROCs(kFALSE)
{
: hcana::ConfigLogging<podd2::EmptyBase>(), fTITime(0), fTITime_last(0), fTITime_rollovers(0),
fHaveROCs(kFALSE) {
// Default constructor
}
//____________________________________________________________________
THcHelicityReader::~THcHelicityReader()
{
THcHelicityReader::~THcHelicityReader() {
// Destructor
// Histograms will be deleted by ROOT
......@@ -40,34 +38,26 @@ THcHelicityReader::~THcHelicityReader()
}
//____________________________________________________________________
void THcHelicityReader::Clear( Option_t* )
{
fIsMPS = fIsQrt = fIsHelp = fIsHelm = kFALSE;
}
void THcHelicityReader::Clear(Option_t*) { fIsMPS = fIsQrt = fIsHelp = fIsHelm = kFALSE; }
//_____________________________________________________________________________
Int_t THcHelicityReader::ReadDatabase( const char* /*dbfilename*/,
const char* /*prefix*/,
const TDatime& /*date*/,
int /*debug_flag*/ )
{
Int_t THcHelicityReader::ReadDatabase(const char* /*dbfilename*/, const char* /*prefix*/,
const TDatime& /*date*/, int /*debug_flag*/) {
// Eventually get these from the parameter file
const static char* const here = "THcHelicityReader::ReadDatabase";
// SHMS settings see https://logbooks.jlab.org/entry/3614445
_logger->info("{}: Helicity information from ROC 2 (SHMS)", here);
SetROCinfo(kHel, 2, 14, 9);
SetROCinfo(kHelm, 2, 14, 8);
SetROCinfo(kMPS, 2, 14, 10);
SetROCinfo(kQrt, 2, 14, 7); // Starting about run 5818
SetROCinfo(kTime, 2, 21, 2);
SetROCinfo(kHel,2,14,9);
SetROCinfo(kHelm,2,14,8);
SetROCinfo(kMPS,2,14,10);
SetROCinfo(kQrt,2,14,7);
SetROCinfo(kTime,2,21,2);
fADCThreshold = 8000;
DBRequest list[] = {
{"helicity_adcthreshold",&fADCThreshold, kInt, 0, 1},
{0}
};
DBRequest list[] = {{"helicity_adcthreshold", &fADCThreshold, kInt, 0, 1}, {0}};
gHcParms->LoadParmValues(list, "");
......@@ -75,28 +65,25 @@ Int_t THcHelicityReader::ReadDatabase( const char* /*dbfilename*/,
}
//_____________________________________________________________________________
void THcHelicityReader::Begin()
{
void THcHelicityReader::Begin() {
// static const char* const here = "THcHelicityReader::Begin";
// cout<<here<<endl;
fTITime_last = 0;
fTITime = 0;
fTITime_last = 0;
fTITime = 0;
fTITime_rollovers = 0;
return;
}
//____________________________________________________________________
void THcHelicityReader::End()
{
void THcHelicityReader::End() {
// static const char* const here = "THcHelicityReader::End";
// cout<<here<<endl;
return;
}
//____________________________________________________________________
Int_t THcHelicityReader::ReadData( const THaEvData& evdata )
{
Int_t THcHelicityReader::ReadData(const THaEvData& evdata) {
// Obtain the present data from the event for QWEAK helicity mode.
static const char* here = "THcHelicityReader::ReadData";
......@@ -107,27 +94,48 @@ Int_t THcHelicityReader::ReadData( const THaEvData& evdata )
// std::cout<<" which="<<jk
// <<" roc="<<fROCinfo[jk].roc
// <<" header="<<fROCinfo[jk].header
// <<" index="<<fROCinfo[jk].index
// <<" index="<<fROCinfo[jk].index
// <<endl;
// }
// std::cout<<" fHaveROCs="<<fHaveROCs<<endl;
if( !fHaveROCs ) {
::Error( here, "ROC data (detector map) not properly set up." );
if (!fHaveROCs) {
::Error(here, "ROC data (detector map) not properly set up.");
return -1;
}
// Check if ROC info is correct
if (!evdata.GetModule(fROCinfo[kTime].roc, fROCinfo[kTime].slot)) {
_logger->info("{}: ROC 2 not found, changing to ROC 1 (HMS)", here);
SetROCinfo(kHel, 1, 18, 9);
SetROCinfo(kHelm, 1, 18, 8);
SetROCinfo(kMPS, 1, 18, 10);
SetROCinfo(kQrt, 1, 18, 7);
SetROCinfo(kTime, 1, 21, 2);
}
// Get the TI Data
// Int_t fTIType = evData.GetData(fTICrate, fTISlot, 0, 0);
// Int_t fTIEvNum = evData.GetData(fTICrate, fTISlot, 1, 0);
UInt_t titime = (UInt_t) evdata.GetData(fROCinfo[kTime].roc,
fROCinfo[kTime].slot,
fROCinfo[kTime].index, 0);
//cout << fTITime_last << " " << titime << endl;
if(titime < fTITime_last) {
UInt_t titime =
(UInt_t)evdata.GetData(fROCinfo[kTime].roc, fROCinfo[kTime].slot, fROCinfo[kTime].index, 0);
// Check again if ROC info is correct
if (titime == 0 && fTITime_last == 0) {
_logger->info("{}: ROC 2 not found, changing to ROC 1 (HMS)", here);
SetROCinfo(kHel, 1, 18, 9);
SetROCinfo(kHelm, 1, 18, 8);
SetROCinfo(kMPS, 1, 18, 10);
SetROCinfo(kQrt, 1, 18, 7);
SetROCinfo(kTime, 1, 21, 2);
titime =
(UInt_t)evdata.GetData(fROCinfo[kTime].roc, fROCinfo[kTime].slot, fROCinfo[kTime].index, 0);
}
// cout << fTITime_last << " " << titime << endl;
if (titime < fTITime_last) {
fTITime_rollovers++;
}
fTITime = titime + fTITime_rollovers*4294967296;
fTITime = titime + fTITime_rollovers * 4294967296;
fTITime_last = titime;
const_cast<THaEvData&>(evdata).SetEvTime(fTITime);
......@@ -135,36 +143,26 @@ Int_t THcHelicityReader::ReadData( const THaEvData& evdata )
// Get the helicity control signals. These are from the pedestals
// acquired by FADC channels.
Int_t helpraw = evdata.GetData(Decoder::kPulsePedestal,
fROCinfo[kHel].roc,
fROCinfo[kHel].slot,
fROCinfo[kHel].index, 0);
Int_t helmraw = evdata.GetData(Decoder::kPulsePedestal,
fROCinfo[kHelm].roc,
fROCinfo[kHelm].slot,
fROCinfo[kHelm].index, 0);
Int_t mpsraw = evdata.GetData(Decoder::kPulsePedestal,
fROCinfo[kMPS].roc,
fROCinfo[kMPS].slot,
fROCinfo[kMPS].index, 0);
Int_t qrtraw = evdata.GetData(Decoder::kPulsePedestal,
fROCinfo[kQrt].roc,
fROCinfo[kQrt].slot,
fROCinfo[kQrt].index, 0);
fIsQrt = qrtraw > fADCThreshold;
fIsMPS = mpsraw > fADCThreshold;
Int_t helpraw = evdata.GetData(Decoder::kPulsePedestal, fROCinfo[kHel].roc, fROCinfo[kHel].slot,
fROCinfo[kHel].index, 0);
Int_t helmraw = evdata.GetData(Decoder::kPulsePedestal, fROCinfo[kHelm].roc, fROCinfo[kHelm].slot,
fROCinfo[kHelm].index, 0);
Int_t mpsraw = evdata.GetData(Decoder::kPulsePedestal, fROCinfo[kMPS].roc, fROCinfo[kMPS].slot,
fROCinfo[kMPS].index, 0);
Int_t qrtraw = evdata.GetData(Decoder::kPulsePedestal, fROCinfo[kQrt].roc, fROCinfo[kQrt].slot,
fROCinfo[kQrt].index, 0);
fIsQrt = qrtraw > fADCThreshold;
fIsMPS = mpsraw > fADCThreshold;
fIsHelp = helpraw > fADCThreshold;
fIsHelm = helmraw > fADCThreshold;
return 0;
}
//TODO: this should not be needed once LoadDB can fill fROCinfo directly
// TODO: this should not be needed once LoadDB can fill fROCinfo directly
//____________________________________________________________________
Int_t THcHelicityReader::SetROCinfo( EROC which, Int_t roc,
Int_t slot, Int_t index )
{
Int_t THcHelicityReader::SetROCinfo(EROC which, Int_t roc, Int_t slot, Int_t index) {
// Define source and offset of data. Normally called by ReadDatabase
// of the detector that is a THcHelicityReader.
......@@ -173,18 +171,19 @@ Int_t THcHelicityReader::SetROCinfo( EROC which, Int_t roc,
// You must define at least the kHel and kTime ROCs.
// Returns <0 if parameter error, 0 if success
if( which<kHel || which>=kCount )
if (which < kHel || which >= kCount)
return -1;
if( roc <= 0 || roc > 255 )
if (roc <= 0 || roc > 255)
return -2;
fROCinfo[which].roc = roc;
fROCinfo[which].slot = slot;
fROCinfo[which].index = index;
fROCinfo[which].roc = roc;
fROCinfo[which].slot = slot;
fROCinfo[which].index = index;
_logger->info("SetROCInfo: {} (roc: {}, slot: {}, index: {})", which, fROCinfo[which].roc,
fROCinfo[which].slot, fROCinfo[which].index);
fHaveROCs = (fROCinfo[kHel].roc > 0 && fROCinfo[kTime].roc > 0 && fROCinfo[kMPS].roc);
//cout << "SetROCInfo: " << which << " " << fROCinfo[kHel].roc << " " << fROCinfo[kTime].roc << endl;
fHaveROCs = ( fROCinfo[kHel].roc > 0 && fROCinfo[kTime].roc > 0 );
return 0;
}
......
......@@ -10,60 +10,59 @@
//////////////////////////////////////////////////////////////////////////
#include "Rtypes.h"
#include "THaHelicityDet.h"
#include "hcana/Logger.h"
class THaEvData;
class TDatime;
class TH1F;
class THcHelicityReader {
class THcHelicityReader : public hcana::ConfigLogging<podd2::EmptyBase> {
public:
THcHelicityReader();
virtual ~THcHelicityReader();
struct ROCinfo {
Int_t roc; // ROC to read out
Int_t slot; // Headers to search for (0 = ignore)
Int_t index; // Index into buffer
Int_t roc; // ROC to read out
Int_t slot; // Headers to search for (0 = ignore)
Int_t index; // Index into buffer
};
protected:
protected:
// Used by ReadDatabase
enum EROC { kHel = 0, kHelm, kMPS, kQrt, kTime, kCount };
Int_t SetROCinfo( EROC which, Int_t roc, Int_t slot, Int_t index );
Int_t SetROCinfo(EROC which, Int_t roc, Int_t slot, Int_t index);
virtual void Clear( Option_t* opt="" );
virtual Int_t ReadData( const THaEvData& evdata );
Int_t ReadDatabase( const char* dbfilename, const char* prefix,
const TDatime& date, int debug_flag = 0 );
void Begin();
void End();
virtual void Clear(Option_t* opt = "");
virtual Int_t ReadData(const THaEvData& evdata);
Int_t ReadDatabase(const char* dbfilename, const char* prefix, const TDatime& date,
int debug_flag = 0);
void Begin();
void End();
ULong64_t fTITime;
UInt_t fTITime_last;
UInt_t fTITime_rollovers;
UInt_t fTITime_last;
UInt_t fTITime_rollovers;
// Reported Helicity status for the event
Bool_t fIsMPS;
Bool_t fIsQrt;
Bool_t fIsHelp;
Bool_t fIsHelm;
Int_t fADCThreshold; // Threshold for On/Off of helicity signals
Int_t fADCThreshold; // Threshold for On/Off of helicity signals
ROCinfo fROCinfo[kCount];
ROCinfo fROCinfo[kCount];
Int_t fQWEAKDebug; // Debug level
Bool_t fHaveROCs; // Required ROCs are defined
Bool_t fNegGate; // Invert polarity of gate, TO DO implement this functionality
Int_t fQWEAKDebug; // Debug level
Bool_t fHaveROCs; // Required ROCs are defined
Bool_t fNegGate; // Invert polarity of gate, TO DO implement this functionality
static const Int_t NHISTR = 12;
// TH1F* fHistoR[12]; // Histograms
private:
ClassDef(THcHelicityReader,0) // Helper class for reading QWEAK helicity data
ClassDef(THcHelicityReader, 0) // Helper class for reading QWEAK helicity data
};
#endif
......