Skip to content

Commit

Permalink
[ZDC] bug fix and plot addition
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-zugravel committed Dec 4, 2024
1 parent e1052ca commit 9abbd30
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 8 deletions.
1 change: 1 addition & 0 deletions Modules/ZDC/include/ZDC/ZDCRawDataTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class ZDCRawDataTask final : public TaskInterface
std::string fNameChannel[o2::zdc::NModules][o2::zdc::NChPerModule];
std::vector<infoHisto1D> fMatrixHistoBaseline[o2::zdc::NModules][o2::zdc::NChPerModule];
std::vector<infoHisto1D> fMatrixHistoCounts[o2::zdc::NModules][o2::zdc::NChPerModule];
std::vector<infoHisto1D> fMatrixHistoCounts_a[o2::zdc::NModules][o2::zdc::NChPerModule];
std::vector<infoHisto2D> fMatrixHistoSignal[o2::zdc::NModules][o2::zdc::NChPerModule];
std::vector<infoHisto2D> fMatrixHistoBunch[o2::zdc::NModules][o2::zdc::NChPerModule];

Expand Down
65 changes: 65 additions & 0 deletions Modules/ZDC/src/ZDCRawDataTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ void ZDCRawDataTask::startOfActivity(const Activity& activity)
void ZDCRawDataTask::startOfCycle()
{
ILOG(Debug, Devel) << "startOfCycle" << ENDM;

// Reset at each QC cycle of the trending plot data for the rate measurement
for (int i = 0; i < o2::zdc::NModules; i++) {
for (int j = 0; j < o2::zdc::NChPerModule; j++) {
for (int k = 0; k < (int)fMatrixHistoCounts_a[i][j].size(); k++) {
fMatrixHistoCounts_a[i][j].at(k).histo->Reset();
}
}
}
fNumCycle++;
fNumCycleErr++;
}
Expand Down Expand Up @@ -324,6 +333,18 @@ void ZDCRawDataTask::initHisto()

addNewHisto("COUNTS", "hcounts-ZEM1_TR", "Counts ZEM1", "ZEM1_TR", "LBC");
addNewHisto("COUNTS", "hcounts-ZEM2_TR", "Counts ZEM2", "ZEM2_TR", "LBC");

addNewHisto("COUNTSA", "hcounts_ZNA_TC_TR", "Counts ZNA TC istantaneous" , "ZNA_TC_TR", "LBC");
addNewHisto("COUNTSA", "hcounts_ZNA_SUM" , "Counts ZNA SUM istantaneous", "ZNA_SUM" , "LBC");
addNewHisto("COUNTSA", "hcounts_ZNC_TC_TR", "Counts ZNC TC istantaneous" , "ZNC_TC_TR", "LBC");
addNewHisto("COUNTSA", "hcounts_ZNC_SUM" , "Counts ZNC SUM istantaneous", "ZNC_SUM" , "LBC");
addNewHisto("COUNTSA", "hcounts_ZPA_TC_TR", "Counts ZPA TC istantaneous" , "ZPA_TC_TR", "LBC");
addNewHisto("COUNTSA", "hcounts_ZPA_SUM" , "Counts ZPA SUM istantaneous", "ZPA_SUM" , "LBC");
addNewHisto("COUNTSA", "hcounts_ZPC_TC_TR", "Counts ZPC TC istantaneous" , "ZPC_TC_TR", "LBC");
addNewHisto("COUNTSA", "hcounts_ZPC_SUM" , "Counts ZPC SUM istantaneous", "ZPC_SUM" , "LBC");
addNewHisto("COUNTSA", "hcounts_ZEM1_TR" , "Counts ZEM1 istantaneous" , "ZEM1_TR" , "LBC");
addNewHisto("COUNTSA", "hcounts_ZEM2_TR" , "Counts ZEM2 istantaneous" , "ZEM2_TR" , "LBC");

// Histograms Signal
int nBCAheadTrig = 3;
int nbx = (nBCAheadTrig + 1 + 12) * o2::zdc::NTimeBinsPerBC;
Expand Down Expand Up @@ -780,10 +801,17 @@ int ZDCRawDataTask::process(const o2::zdc::EventChData& ch)
if (fSummaryError && (f.error)) {
fSummaryError->Fill(fMatrixAlign[f.board][f.ch].bin - 1, 0);
}

// Fill counts
for (int i = 0; i < (int)fMatrixHistoCounts[f.board][f.ch].size(); i++) {
fMatrixHistoCounts[f.board][f.ch].at(i).histo->Fill(f.hits & 0xfff);
}

// Fill counts for trending
for (int i = 0; i < (int)fMatrixHistoCounts_a[f.board][f.ch].size(); i++) {
fMatrixHistoCounts_a[f.board][f.ch].at(i).histo->Fill(f.hits & 0xfff);
}

// Fill Summary
if (fMapBinNameIdSummaryHisto.find(getNameChannel(f.board, f.ch)) != fMapBinNameIdSummaryHisto.end()) {
if (fMatrixHistoBaseline[f.board][f.ch].size() > 0) {
Expand Down Expand Up @@ -952,12 +980,49 @@ bool ZDCRawDataTask::addNewHisto(std::string type, std::string name, std::string
return true;
}
}


if (type == "COUNTSA") {
// Check if Histogram Exist
if (std::find(fNameHisto.begin(), fNameHisto.end(), name) == fNameHisto.end()) {
fNameHisto.push_back(name);
h1d.histo = new TH1F(hname, htit, fNumBinX, fMinBinX, fMaxBinX);
h1d.condHisto.push_back(condition);
ih = (int)fMatrixHistoCounts_a[mod][ch].size();
fMatrixHistoCounts_a[mod][ch].push_back(h1d);

if (ih < (int)fMatrixHistoCounts_a[mod][ch].size()) {
getObjectsManager()->startPublishing(fMatrixHistoCounts_a[mod][ch].at(ih).histo);
try {
getObjectsManager()->addMetadata(fMatrixHistoCounts_a[mod][ch].at(ih).histo->GetName(), fMatrixHistoCounts_a[mod][ch].at(ih).histo->GetName(), "34");
return true;
} catch (...) {
ILOG(Warning, Support) << "Metadata could not be added to " << fMatrixHistoCounts_a[mod][ch].at(ih).histo->GetName() << ENDM;
return false;
}

delete h1d.histo;
h1d.condHisto.clear();
}
return true;
} else {
for (int i = 0; i < (int)fMatrixHistoCounts_a[mod][ch].size(); i++) {
fMatrixHistoCounts_a[mod][ch].at(i).histo->Reset();
}
return true;
}
}



// SIGNAL
if (type == "SIGNAL") {
// Check if Histogram Exist
if (std::find(fNameHisto.begin(), fNameHisto.end(), name) == fNameHisto.end()) {
fNameHisto.push_back(name);
h2d.histo = new TH2F(hname, htit, fNumBinX, fMinBinX, fMaxBinX, fNumBinY, fMinBinY, fMaxBinY);
h2d.histo->GetXaxis()->SetTitle("Sample number");
h2d.histo->GetYaxis()->SetTitle("ADC units");
h2d.condHisto.push_back(condition);
ih = (int)fMatrixHistoSignal[mod][ch].size();
fMatrixHistoSignal[mod][ch].push_back(h2d);
Expand Down
2 changes: 1 addition & 1 deletion Modules/ZDC/src/ZDCRecDataPostProcessing.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ void ZDCRecDataPostProcessing::updateSummaryPeak1pHistos(Trigger t, repository::
} else {
maxBin1p = 250;
}
h->GetXaxis()->SetRangeUser(2, 250);
h->GetXaxis()->SetRangeUser(minBin1p, maxBin1p);
mSummaryPeak1pHisto->SetBinContent(bin, h->GetBinCenter(h->GetMaximumBin()));
}
}
Expand Down
153 changes: 146 additions & 7 deletions Modules/ZDC/src/ZDCRecDataTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ void ZDCRecDataTask::initVecType()
insertTypeVec("ADC");
insertTypeVec("TDCV");
insertTypeVec("TDCA");
insertTypeVec("TDCAC");
insertTypeVec("ADCAC");
insertTypeVec("BC");
insertTypeVec("INFO");
}
Expand Down Expand Up @@ -292,6 +294,15 @@ void ZDCRecDataTask::initHisto()
addNewHisto("ADC1D", "h_ADC_ZPC_TC_H", "ADC ZPC TC ZOOM", "ADC", "ZPCC", "", "", 0);
addNewHisto("ADC1D", "h_ADC_ZPC_SUM_H", "ADC ZPC SUM ZOOM", "ADC", "ZPCS", "", "", 0);

addNewHisto("ADC1D", "h_ADC_ZPA_TC_H_CUT", "ADC ZPA TC ZOOM with cut", "ADCAC", "ZPAC", "", "", 0);
addNewHisto("ADC1D", "h_ADC_ZPA_SUM_H_CUT", "ADC ZPA SUM ZOOM with cut", "ADCAC", "ZPAS", "", "", 0);
addNewHisto("ADC1D", "h_ADC_ZPC_TC_H_CUT", "ADC ZPC TC ZOOM with cut", "ADCAC", "ZPCC", "", "", 0);
addNewHisto("ADC1D", "h_ADC_ZPC_SUM_H_CUT", "ADC ZPC SUM ZOOM with cut", "ADCAC", "ZPCS", "", "", 0);
addNewHisto("ADC1D", "h_ADC_ZNA_TC_H_CUT", "ADC ZNA TC ZOOM with cut", "ADCAC", "ZNAC", "", "", 0);
addNewHisto("ADC1D", "h_ADC_ZNA_SUM_H_CUT", "ADC ZNA SUM ZOOM with cut", "ADCAC", "ZNAS", "", "", 0);
addNewHisto("ADC1D", "h_ADC_ZNC_TC_H_CUT", "ADC ZNC TC ZOOM with cut", "ADCAC", "ZNCC", "", "", 0);
addNewHisto("ADC1D", "h_ADC_ZNC_SUM_H_CUT", "ADC ZNC SUM ZOOM with cut", "ADCAC", "ZNCS", "", "", 0);

if (auto param = mCustomParameters.find("TDCT"); param != mCustomParameters.end()) {
ILOG(Debug, Devel) << "Custom parameter - TDCT: " << param->second << ENDM;
tokenString = tokenLine(param->second, ";");
Expand Down Expand Up @@ -350,6 +361,17 @@ void ZDCRecDataTask::initHisto()
addNewHisto("TDC1D", "h_TDC_ZNC_SUM_A_H", "TDC Amplitude ZNC SUM ZOOM", "TDCA", "ZNCS", "", "", 0);
addNewHisto("TDC1D", "h_TDC_ZPC_TC_A_H", "TDC Amplitude ZPC TC ZOOM", "TDCA", "ZPCC", "", "", 0);
addNewHisto("TDC1D", "h_TDC_ZPC_SUM_A_H", "TDC Amplitude ZPC SUM ZOOM", "TDCA", "ZPCS", "", "", 0);

addNewHisto("TDC1D", "h_TDC_ZPA_TC_A_H_CUT", "TDC Amplitude ZPA TC ZOOM with cut", "TDCAC", "ZPAC", "", "", 0);
addNewHisto("TDC1D", "h_TDC_ZPA_SUM_A_H_CUT", "TDC Amplitude ZPA SUM ZOOM with cut", "TDCAC", "ZPAS", "", "", 0);
addNewHisto("TDC1D", "h_TDC_ZPC_TC_A_H_CUT", "TDC Amplitude ZPC TC ZOOM with cut", "TDCAC", "ZPCC", "", "", 0);
addNewHisto("TDC1D", "h_TDC_ZPC_SUM_A_H_CUT", "TDC Amplitude ZPC SUM ZOOM with cut", "TDCAC", "ZPCS", "", "", 0);
addNewHisto("TDC1D", "h_TDC_ZNA_TC_A_H_CUT", "TDC Amplitude ZNA TC ZOOM with cut", "TDCAC", "ZNAC", "", "", 0);
addNewHisto("TDC1D", "h_TDC_ZNA_SUM_A_H_CUT", "TDC Amplitude ZNA SUM ZOOM with cut", "TDCAC", "ZNAS", "", "", 0);
addNewHisto("TDC1D", "h_TDC_ZNC_TC_A_H_CUT", "TDC Amplitude ZNC TC ZOOM with cut", "TDCAC", "ZNCC", "", "", 0);
addNewHisto("TDC1D", "h_TDC_ZNC_SUM_A_H_CUT", "TDC Amplitude ZNC SUM ZOOM with cut", "TDCAC", "ZNCS", "", "", 0);


// Centroid ZPA
if (auto param = mCustomParameters.find("CENTR_ZPA"); param != mCustomParameters.end()) {
ILOG(Debug, Devel) << "Custom parameter - CENTR_ZPA: " << param->second << ENDM;
Expand Down Expand Up @@ -521,6 +543,8 @@ void ZDCRecDataTask::initHisto()
setBinHisto2D(200, -2, 2, 200, -2, 2);
}
addNewHisto("CENTR_ZNA", "h_CENTR_ZNA", "ZNA Centroid (cm)", "ADC", "CXZNA", "ADC", "CYZNA", 0);
addNewHisto("CENTR_ZNA", "h_CENTR_ZNA_cut_ZEM", "ZNA Centroid (cm)", "ADC", "CXZNA", "ADC", "CYZNA", 0);

// Centroid ZNC
if (auto param = mCustomParameters.find("CENTR_ZNC"); param != mCustomParameters.end()) {
ILOG(Debug, Devel) << "Custom parameter - CENTR_ZNC: " << param->second << ENDM;
Expand All @@ -530,6 +554,8 @@ void ZDCRecDataTask::initHisto()
setBinHisto2D(200, -2, 2, 200, -2, 2);
}
addNewHisto("CENTR_ZNC", "h_CENTR_ZNC", "ZNC Centroid (cm)", "ADC", "CXZNC", "ADC", "CYZNC", 0);
addNewHisto("CENTR_ZNC", "h_CENTR_ZNC_cut_ZEM", "ZNC Centroid (cm)", "ADC", "CXZNC", "ADC", "CYZNC", 0);

}

bool ZDCRecDataTask::add1DHisto(std::string typeH, std::string name, std::string title, std::string typeCh1, std::string ch1, int bin)
Expand Down Expand Up @@ -564,6 +590,8 @@ bool ZDCRecDataTask::add1DHisto(std::string typeH, std::string name, std::string
}
}



bool ZDCRecDataTask::add2DHisto(std::string typeH, std::string name, std::string title, std::string typeCh1, std::string ch1, std::string typeCh2, std::string ch2)
{
TString hname = TString::Format("%s", name.c_str());
Expand Down Expand Up @@ -638,8 +666,43 @@ int ZDCRecDataTask::process(const gsl::span<const o2::zdc::BCRecData>& RecBC,
// Histo 1D
for (int i = 0; i < (int)mHisto1D.size(); i++) {
// Fill ADC 1D
if (mHisto1D.at(i).typeh == "ADC1D" && mHisto1D.at(i).typech == "ADC") {
mHisto1D.at(i).histo->Fill(getADCRecValue(mHisto1D.at(i).typech, mHisto1D.at(i).ch));
if (mHisto1D.at(i).typeh == "ADC1D" && (mHisto1D.at(i).typech == "ADC" || mHisto1D.at(i).typech == "ADCAC")) {

if (mHisto1D.at(i).typech == "ADC") {
mHisto1D.at(i).histo->Fill(getADCRecValue(mHisto1D.at(i).typech, mHisto1D.at(i).ch));
}

if (mHisto1D.at(i).typech == "ADCAC") {
if (mHisto1D.at(i).ch == "ZPAC" || mHisto1D.at(i).ch == "ZPAS" ){
if (mEv.NtdcA(o2::zdc::TDCZNAC) == 0 && mEv.NtdcA(o2::zdc::TDCZNAS) == 0 ){
if (getADCRecValue("ADC", mHisto1D.at(i).ch) > -8000){
mHisto1D.at(i).histo->Fill(getADCRecValue("ADC", mHisto1D.at(i).ch));
}
}
}
if (mHisto1D.at(i).ch == "ZPCC" || mHisto1D.at(i).ch == "ZPCS" ){
if (mEv.NtdcA(o2::zdc::TDCZNCC) == 0 && mEv.NtdcA(o2::zdc::TDCZNCS) == 0 ){
if (getADCRecValue("ADC", mHisto1D.at(i).ch) > -8000){
mHisto1D.at(i).histo->Fill(getADCRecValue("ADC", mHisto1D.at(i).ch));
}
}
}
if (mHisto1D.at(i).ch == "ZNAC" || mHisto1D.at(i).ch == "ZNAS" ){
if (mEv.NtdcA(o2::zdc::TDCZPAC) == 0 && mEv.NtdcA(o2::zdc::TDCZPAS) == 0 ){
if (getADCRecValue("ADC", mHisto1D.at(i).ch) > -8000){
mHisto1D.at(i).histo->Fill(getADCRecValue("ADC", mHisto1D.at(i).ch));
}
}
}
if (mHisto1D.at(i).ch == "ZNCC" || mHisto1D.at(i).ch == "ZNCS" ){
if (mEv.NtdcA(o2::zdc::TDCZPCC) == 0 && mEv.NtdcA(o2::zdc::TDCZPCS) == 0 ){
if (getADCRecValue("ADC", mHisto1D.at(i).ch) > -8000){
mHisto1D.at(i).histo->Fill(getADCRecValue("ADC", mHisto1D.at(i).ch));
}
}
}
}

}

// Fill TDC 1D
Expand All @@ -657,6 +720,65 @@ int ZDCRecDataTask::process(const gsl::span<const o2::zdc::BCRecData>& RecBC,
}
}
}

// Fill TDCA with cut 1D
if (mHisto1D.at(i).typeh == "TDC1D" && (mHisto1D.at(i).typech == "TDCAC")) {
int tdcid = getIdTDCch("TDCA", mHisto1D.at(i).ch);
auto nhitv = mEv.NtdcV(tdcid);
if (tdcid == o2::zdc::TDCZPAC || tdcid == o2::zdc::TDCZPAS ){
if (mEv.NtdcA(o2::zdc::TDCZNAC) == 0 && mEv.NtdcA(o2::zdc::TDCZNAS) == 0 ){
if (mEv.NtdcA(tdcid) == nhitv && nhitv > 0) {
for (int ihit = 0; ihit < nhitv; ihit++) {
if (mHisto1D.at(i).typech == "TDCAC") {
if (( mEv.tdcV(tdcid, ihit) > -2.5 && mEv.tdcV(tdcid, ihit) < 2.5 )){
mHisto1D.at(i).histo->Fill(mEv.tdcA(tdcid, ihit));
}
}
}
}
}
}
if (tdcid == o2::zdc::TDCZPCC || tdcid == o2::zdc::TDCZPCS ){
if (mEv.NtdcA(o2::zdc::TDCZNCC) == 0 && mEv.NtdcA(o2::zdc::TDCZNCS) == 0 ){
if (mEv.NtdcA(tdcid) == nhitv && nhitv > 0) {
for (int ihit = 0; ihit < nhitv; ihit++) {
if (mHisto1D.at(i).typech == "TDCAC") {
if (( mEv.tdcV(tdcid, ihit) > -2.5 && mEv.tdcV(tdcid, ihit) < 2.5 )){
mHisto1D.at(i).histo->Fill(mEv.tdcA(tdcid, ihit));
}
}
}
}
}
}
if (tdcid == o2::zdc::TDCZNAC || tdcid == o2::zdc::TDCZNAS ){
if (mEv.NtdcA(o2::zdc::TDCZPAC) == 0 && mEv.NtdcA(o2::zdc::TDCZPAS) == 0 ){
if (mEv.NtdcA(tdcid) == nhitv && nhitv > 0) {
for (int ihit = 0; ihit < nhitv; ihit++) {
if (mHisto1D.at(i).typech == "TDCAC") {
if (( mEv.tdcV(tdcid, ihit) > -2.5 && mEv.tdcV(tdcid, ihit) < 2.5 )){
mHisto1D.at(i).histo->Fill(mEv.tdcA(tdcid, ihit));
}
}
}
}
}
}
if (tdcid == o2::zdc::TDCZNCC || tdcid == o2::zdc::TDCZNCS ){
if (mEv.NtdcA(o2::zdc::TDCZPCC) == 0 && mEv.NtdcA(o2::zdc::TDCZPCS) == 0 ){
if (mEv.NtdcA(tdcid) == nhitv && nhitv > 0) {
for (int ihit = 0; ihit < nhitv; ihit++) {
if (mHisto1D.at(i).typech == "TDCAC") {
if (( mEv.tdcV(tdcid, ihit) > -2.5 && mEv.tdcV(tdcid, ihit) < 2.5 )){
mHisto1D.at(i).histo->Fill(mEv.tdcA(tdcid, ihit));
}
}
}
}
}
}
}

// Fill CENTROID ZP
if (mHisto1D.at(i).typeh == "CENTR_ZPA" && mHisto1D.at(i).typech == "ADC") {
mHisto1D.at(i).histo->Fill(mEv.xZPA());
Expand Down Expand Up @@ -717,12 +839,29 @@ int ZDCRecDataTask::process(const gsl::span<const o2::zdc::BCRecData>& RecBC,
}
}
if (mHisto2D.at(i).typeh == "CENTR_ZNA" && mHisto2D.at(i).typech1 == "ADC" && mHisto2D.at(i).typech2 == "ADC") {
mEv.centroidZNA(x, y);
mHisto2D.at(i).histo->Fill(x, y);
if (mHisto2D.at(i).histo->GetName() == TString::Format("h_CENTR_ZNA")) {
mEv.centroidZNA(x, y);
mHisto2D.at(i).histo->Fill(x, y);
}
else {
//if (( (float)o2::zdc::TDCZEM2 > -2.5 && (float)o2::zdc::TDCZEM2 < 2.5 ) && ( (float)o2::zdc::TDCZEM1 > -2.5 && (float)o2::zdc::TDCZEM1 < 2.5 ) ){
if (( (float)mEv.tdcV(5, 0) > -2.5 && (float)mEv.tdcV(5, 0) < 2.5 ) && ( (float)mEv.tdcV(4, 0) > -2.5 && (float)mEv.tdcV(4, 0) < 2.5 ) ){
mEv.centroidZNA(x, y);
mHisto2D.at(i).histo->Fill(x, y);
}
}
}
if (mHisto2D.at(i).typeh == "CENTR_ZNC" && mHisto2D.at(i).typech1 == "ADC" && mHisto2D.at(i).typech2 == "ADC") {
mEv.centroidZNC(x, y);
mHisto2D.at(i).histo->Fill(x, y);
if (mHisto2D.at(i).histo->GetName() == TString::Format("h_CENTR_ZNC")) {
mEv.centroidZNC(x, y);
mHisto2D.at(i).histo->Fill(x, y);
}
else {
if (( (float)mEv.tdcV(5, 0) > -2.5 && (float)mEv.tdcV(5, 0) < 2.5 ) && ( (float)mEv.tdcV(4, 0) > -2.5 && (float)mEv.tdcV(4, 0) < 2.5 ) ){
mEv.centroidZNC(x, y);
mHisto2D.at(i).histo->Fill(x, y);
}
}
}
} // for histo 2D
} // while
Expand Down Expand Up @@ -809,7 +948,7 @@ float ZDCRecDataTask::getADCRecValue(std::string typech, std::string ch)
if (typech == "ADC" && ch == "ZEM2") {
return mEv.EZEM2();
}
return 0.00;
return -9000.0;
}

int ZDCRecDataTask::getIdTDCch(std::string typech, std::string ch)
Expand Down

0 comments on commit 9abbd30

Please sign in to comment.