Skip to content

Commit

Permalink
Added second WR for sofia
Browse files Browse the repository at this point in the history
  • Loading branch information
jose-luis-rs authored and hapol committed Dec 21, 2022
1 parent 8bab983 commit c6d55c4
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 122 deletions.
13 changes: 7 additions & 6 deletions macros/s455/main_online.C
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void main_online()
// *********************************** //

// NumSofSci, file names and paths -----------------------------
Int_t sofiaWR, NumSofSci, IdS2, IdS8;
Int_t sofiaWR_SE, sofiaWR_ME, NumSofSci, IdS2, IdS8;
TString dir = gSystem->Getenv("VMCWORKDIR");
TString ntuple_options = "RAW";
TString ucesb_dir = getenv("UCESB_DIR");
Expand All @@ -70,7 +70,7 @@ void main_online()
NumSofSci = 1; // s444: PRIMARY BEAM EXP, 1 SofSci at CAVE C ONLY
IdS2 = 0;
IdS8 = 0;
sofiaWR = 0x500;
sofiaWR_SE = 0x500;

//filename = "--stream=lxir123:7803";
filename = "/lustre/land/202002_s444/stitched/main0040_0001.lmd";
Expand All @@ -87,7 +87,7 @@ void main_online()
NumSofSci = 4; // s467: SECONDARY BEAM EXP, 2 at S2, 1 at S8, 1 at CAVE C
IdS2 = 2;
IdS8 = 3;
sofiaWR = 0xe00;
sofiaWR_SE = 0xe00;

filename = "--stream=lxir123:7803";
//filename = "~/lmd/s467/main0*.lmd";
Expand All @@ -104,10 +104,11 @@ void main_online()
NumSofSci = 2;
IdS2 = 1;
IdS8 = 0;
sofiaWR = 0xe00;
sofiaWR_SE = 0xe00;
sofiaWR_ME = 0xf00;

filename = "--stream=lxlanddaq01:9000";
//filename = "~/lmd/main0042_0001.lmd";
// filename = "~/lmd/main0042_0001.lmd";

TString outputpath = "/d/land4/202103_s455/rootfiles/sofia/";
outputFilename = outputpath + "s455_data_sofia_online_" + oss.str() + ".root";
Expand Down Expand Up @@ -221,7 +222,7 @@ void main_online()
{
unpacksci = new R3BSofSciReader((EXT_STR_h101_SOFSCI_t*)&ucesb_struct.sci, offsetof(EXT_STR_h101, sci),NumSofSci);
unpackWRMaster = new R3BWhiterabbitMasterReader((EXT_STR_h101_WRMASTER*)&ucesb_struct.wrmaster, offsetof(EXT_STR_h101, wrmaster), 0x1000);
unpackWRSofia = new R3BSofWhiterabbitReader((EXT_STR_h101_WRSOFIA*)&ucesb_struct.wrsofia, offsetof(EXT_STR_h101, wrsofia), sofiaWR);
unpackWRSofia = new R3BSofWhiterabbitReader((EXT_STR_h101_WRSOFIA*)&ucesb_struct.wrsofia, offsetof(EXT_STR_h101, wrsofia), sofiaWR_SE, sofiaWR_ME);
}

if (fAms)
Expand Down
46 changes: 27 additions & 19 deletions sofonline/R3BSofOnlineSpectra.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -359,16 +359,20 @@ InitStatus R3BSofOnlineSpectra::Init()

// Difference between master and sofia WRs
cWr = new TCanvas("WR_Master_Sofia", "WR_Master_Sofia", 10, 10, 500, 500);
fh1_wr = new TH1F("fh1_WR_Master_Sofia", "WR-Master - WR-Sofia", 1200, -4100, 4100);
fh1_wr->GetXaxis()->SetTitle("WRs difference");
fh1_wr->GetYaxis()->SetTitle("Counts");
fh1_wr->GetYaxis()->SetTitleOffset(1.3);
fh1_wr->GetXaxis()->CenterTitle(true);
fh1_wr->GetYaxis()->CenterTitle(true);
fh1_wr->SetFillColor(29);
fh1_wr->SetLineColor(1);
fh1_wr->SetLineWidth(2);
fh1_wr->Draw("");
fh1_wr[0] = new TH1F("fh1_WRSE_Master_Sofia", "WR-Master - WRSE-Sofia(back) , WR-Master - WRME-Sofia(red) ", 1200, -4100, 4100);
fh1_wr[0]->GetXaxis()->SetTitle("WRs difference");
fh1_wr[0]->GetYaxis()->SetTitle("Counts");
fh1_wr[0]->GetYaxis()->SetTitleOffset(1.3);
fh1_wr[0]->GetXaxis()->CenterTitle(true);
fh1_wr[0]->GetYaxis()->CenterTitle(true);
fh1_wr[0]->SetFillColor(29);
fh1_wr[0]->SetLineColor(1);
fh1_wr[0]->SetLineWidth(2);
fh1_wr[0]->Draw("");
fh1_wr[1] = new TH1F("fh1_WRME_Master_Sofia", "WR-Master - WRME-Sofia", 1200, -4100, 4100);
fh1_wr[1]->SetLineColor(2);
fh1_wr[1]->SetLineWidth(2);
fh1_wr[1]->Draw("same");

// Difference between Califa-Sofia WRs
sprintf(Name1, "WRs_Sofia_vs_others");
Expand Down Expand Up @@ -471,7 +475,10 @@ void R3BSofOnlineSpectra::Reset_GENERAL_Histo()
LOG(INFO) << "R3BSofOnlineSpectra::Reset_General_Histo";
fh1_trigger->Reset();
if (fWRItemsMaster && fWRItemsSofia)
fh1_wr->Reset();
{
fh1_wr[0]->Reset();
fh1_wr[1]->Reset();
}
if (fWRItemsCalifa && fWRItemsSofia)
{
fh1_wrs[0]->Reset();
Expand Down Expand Up @@ -590,13 +597,13 @@ void R3BSofOnlineSpectra::Exec(Option_t* option)
{
// SOFIA
Int_t nHits = fWRItemsSofia->GetEntriesFast();
int64_t wrs = 0.;
int64_t wrs[2];
for (Int_t ihit = 0; ihit < nHits; ihit++)
{
R3BWRMasterData* hit = (R3BWRMasterData*)fWRItemsSofia->At(ihit);
if (!hit)
continue;
wrs = hit->GetTimeStamp();
wrs[ihit] = hit->GetTimeStamp();
}

// Califa
Expand All @@ -611,8 +618,8 @@ void R3BSofOnlineSpectra::Exec(Option_t* option)
continue;
wr[ihit] = hit->GetTimeStamp();
}
fh1_wrs[0]->Fill(wrs - wr[0]); // messel
fh1_wrs[1]->Fill(wrs - wr[1]); // wixhausen
fh1_wrs[0]->Fill(wrs[0] - wr[0]); // messel
fh1_wrs[1]->Fill(wrs[0] - wr[1]); // wixhausen
}
// Neuland
if (fWRItemsNeuland && fWRItemsNeuland->GetEntriesFast() > 0)
Expand All @@ -623,7 +630,7 @@ void R3BSofOnlineSpectra::Exec(Option_t* option)
R3BWRMasterData* hit = (R3BWRMasterData*)fWRItemsNeuland->At(ihit);
if (!hit)
continue;
fh1_wrs[2]->Fill(int64_t(wrs - hit->GetTimeStamp()));
fh1_wrs[2]->Fill(int64_t(wrs[0] - hit->GetTimeStamp()));
}
// fh1_wrs[4]->GetMaximum();
fh1_wrs[0]->SetMaximum(5. * fh1_wrs[2]->GetBinContent(fh1_wrs[2]->GetMaximumBin()));
Expand All @@ -637,7 +644,7 @@ void R3BSofOnlineSpectra::Exec(Option_t* option)
R3BWRMasterData* hit = (R3BWRMasterData*)fWRItemsS2->At(ihit);
if (!hit)
continue;
fh1_wrs[3]->Fill(int64_t(wrs - hit->GetTimeStamp()));
fh1_wrs[3]->Fill(int64_t(wrs[0] - hit->GetTimeStamp()));
}
}
// S8
Expand All @@ -649,7 +656,7 @@ void R3BSofOnlineSpectra::Exec(Option_t* option)
R3BWRMasterData* hit = (R3BWRMasterData*)fWRItemsS8->At(ihit);
if (!hit)
continue;
fh1_wrs[4]->Fill(int64_t(wrs - hit->GetTimeStamp()));
fh1_wrs[4]->Fill(int64_t(wrs[0] - hit->GetTimeStamp()));
}
}
// Master
Expand All @@ -664,7 +671,8 @@ void R3BSofOnlineSpectra::Exec(Option_t* option)
continue;
wrm = hit->GetTimeStamp();
}
fh1_wr->Fill(wrm - wrs);
fh1_wr[0]->Fill(wrm - wrs[0]);
fh1_wr[1]->Fill(wrm - wrs[1]);
}
}
fNEvents += 1;
Expand Down
2 changes: 1 addition & 1 deletion sofonline/R3BSofOnlineSpectra.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class R3BSofOnlineSpectra : public FairTask
TCanvas *cTrigger, *cWr, *cWrs;

// Unpack
TH1F *fh1_trigger, *fh1_wr;
TH1F *fh1_trigger, *fh1_wr[2];
TH1F* fh1_wrs[5];

public:
Expand Down
115 changes: 88 additions & 27 deletions sofsource/R3BSofWhiterabbitReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ extern "C"
#include "ext_h101_wrsofia.h"
}

R3BSofWhiterabbitReader::R3BSofWhiterabbitReader(EXT_STR_h101_WRSOFIA* data, UInt_t offset, UInt_t whiterabbit_id)
R3BSofWhiterabbitReader::R3BSofWhiterabbitReader(EXT_STR_h101_WRSOFIA* data,
UInt_t offset,
UInt_t whiterabbit_id1,
UInt_t whiterabbit_id2)
: R3BReader("R3BSofWhiterabbitReader")
, fNEvent(0)
, fData(data)
, fOffset(offset)
, fOnline(kFALSE)
, fLogger(FairLogger::GetLogger())
, fWhiterabbitId(whiterabbit_id)
, fWhiterabbitId1(whiterabbit_id1)
, fWhiterabbitId2(whiterabbit_id2)
, fEventHeader(nullptr)
, fArray(new TClonesArray("R3BWRMasterData"))
{
Expand Down Expand Up @@ -59,45 +63,102 @@ Bool_t R3BSofWhiterabbitReader::Init(ext_data_struct_info* a_struct_info)
FairRootManager::Instance()->Register("SofWRData", "SofWR", fArray, kFALSE);
}

fData->TIMESTAMP_SOFIA_ID = 0;
fData->TIMESTAMP_SOFIA1ID = 0;
fData->TIMESTAMP_SOFIA2ID = 0;
return kTRUE;
}

Bool_t R3BSofWhiterabbitReader::Read()
{
if (!fData->TIMESTAMP_SOFIA_ID)
if (!fData->TIMESTAMP_SOFIA1ID)
{
return kTRUE;
}

if (fWhiterabbitId != fData->TIMESTAMP_SOFIA_ID)
{
char strMessage[1000];
snprintf(strMessage,
sizeof strMessage,
"Event %u: Whiterabbit ID mismatch: expected 0x%x, got 0x%x.\n",
fEventHeader->GetEventno(),
fWhiterabbitId,
fData->TIMESTAMP_SOFIA_ID);
LOG(error) << strMessage;
}

if (fEventHeader != nullptr)
else if (fData->TIMESTAMP_SOFIA1ID && !fData->TIMESTAMP_SOFIA2ID)
{
uint64_t timestamp = ((uint64_t)fData->TIMESTAMP_SOFIA_WR_T4 << 48) |
((uint64_t)fData->TIMESTAMP_SOFIA_WR_T3 << 32) |
((uint64_t)fData->TIMESTAMP_SOFIA_WR_T2 << 16) | (uint64_t)fData->TIMESTAMP_SOFIA_WR_T1;

// fEventHeader->SetTimeStamp(timestamp);
fNEvent = fEventHeader->GetEventno();
new ((*fArray)[fArray->GetEntriesFast()]) R3BWRMasterData(timestamp);
if (fWhiterabbitId1 != fData->TIMESTAMP_SOFIA1ID)
{
char strMessage[1000];
snprintf(strMessage,
sizeof strMessage,
"Event %u: Whiterabbit ID mismatch: expected 0x%x, got 0x%x.\n",
fEventHeader->GetEventno(),
fWhiterabbitId1,
fData->TIMESTAMP_SOFIA2ID);
LOG(error) << strMessage;
}

if (fEventHeader != nullptr)
{
uint64_t timestamp =
((uint64_t)fData->TIMESTAMP_SOFIA1WR_T4 << 48) | ((uint64_t)fData->TIMESTAMP_SOFIA1WR_T3 << 32) |
((uint64_t)fData->TIMESTAMP_SOFIA1WR_T2 << 16) | (uint64_t)fData->TIMESTAMP_SOFIA1WR_T1;

// fEventHeader->SetTimeStamp(timestamp);
fNEvent = fEventHeader->GetEventno();
new ((*fArray)[fArray->GetEntriesFast()]) R3BWRMasterData(timestamp);
}
else
{
fNEvent++;
}

fData->TIMESTAMP_SOFIA1ID = 0;
return kTRUE;
}
else
else if (fData->TIMESTAMP_SOFIA1ID && fData->TIMESTAMP_SOFIA2ID)
{
fNEvent++;

if (fWhiterabbitId1 != fData->TIMESTAMP_SOFIA1ID)
{
char strMessage[1000];
snprintf(strMessage,
sizeof strMessage,
"Event %u: Whiterabbit ID mismatch: expected 0x%x, got 0x%x.\n",
fEventHeader->GetEventno(),
fWhiterabbitId1,
fData->TIMESTAMP_SOFIA1ID);
LOG(error) << strMessage;
}

if (fWhiterabbitId2 != fData->TIMESTAMP_SOFIA2ID)
{
char strMessage[1000];
snprintf(strMessage,
sizeof strMessage,
"Event %u: Whiterabbit ID mismatch: expected 0x%x, got 0x%x.\n",
fEventHeader->GetEventno(),
fWhiterabbitId2,
fData->TIMESTAMP_SOFIA2ID);
LOG(error) << strMessage;
}

if (fEventHeader != nullptr)
{
uint64_t timestamp1 =
((uint64_t)fData->TIMESTAMP_SOFIA1WR_T4 << 48) | ((uint64_t)fData->TIMESTAMP_SOFIA1WR_T3 << 32) |
((uint64_t)fData->TIMESTAMP_SOFIA1WR_T2 << 16) | (uint64_t)fData->TIMESTAMP_SOFIA1WR_T1;

// fEventHeader->SetTimeStamp(timestamp);
fNEvent = fEventHeader->GetEventno();
new ((*fArray)[fArray->GetEntriesFast()]) R3BWRMasterData(timestamp1);

uint64_t timestamp2 =
((uint64_t)fData->TIMESTAMP_SOFIA2WR_T4 << 48) | ((uint64_t)fData->TIMESTAMP_SOFIA2WR_T3 << 32) |
((uint64_t)fData->TIMESTAMP_SOFIA2WR_T2 << 16) | (uint64_t)fData->TIMESTAMP_SOFIA2WR_T1;
new ((*fArray)[fArray->GetEntriesFast()]) R3BWRMasterData(timestamp2);
}
else
{
fNEvent++;
}

fData->TIMESTAMP_SOFIA1ID = 0;
fData->TIMESTAMP_SOFIA2ID = 0;
return kTRUE;
}

fData->TIMESTAMP_SOFIA_ID = 0;
return kTRUE;
}

Expand Down
5 changes: 3 additions & 2 deletions sofsource/R3BSofWhiterabbitReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class R3BEventHeader;
class R3BSofWhiterabbitReader : public R3BReader
{
public:
R3BSofWhiterabbitReader(EXT_STR_h101_WRSOFIA*, UInt_t, UInt_t);
R3BSofWhiterabbitReader(EXT_STR_h101_WRSOFIA*, UInt_t, UInt_t, UInt_t);

~R3BSofWhiterabbitReader();

Expand All @@ -35,7 +35,8 @@ class R3BSofWhiterabbitReader : public R3BReader
/* FairLogger */
FairLogger* fLogger;
/* The whiterabbit subsystem ID */
UInt_t fWhiterabbitId;
UInt_t fWhiterabbitId1;
UInt_t fWhiterabbitId2;
/* A pointer to the R3BEventHeader structure */
R3BEventHeader* fEventHeader;
// Don't store data for online
Expand Down
Loading

0 comments on commit c6d55c4

Please sign in to comment.