-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Valerii Panin
committed
Oct 27, 2023
1 parent
d67a4f3
commit 33dae92
Showing
5 changed files
with
233 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
/****************************************************************************** | ||
* Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * | ||
* Copyright (C) 2019-2023 Members of R3B Collaboration * | ||
* * | ||
* This software is distributed under the terms of the * | ||
* GNU General Public Licence (GPL) version 3, * | ||
* copied verbatim in the file "LICENSE". * | ||
* * | ||
* In applying this license GSI does not waive the privileges and immunities * | ||
* granted to it by virtue of its status as an Intergovernmental Organization * | ||
* or submit itself to any jurisdiction. * | ||
******************************************************************************/ | ||
|
||
#include "R3BOnlineSyncCheck.h" | ||
#include "R3BEventHeader.h" | ||
#include "R3BLogger.h" | ||
#include "R3BSyncCheckData.h" | ||
|
||
#include "FairLogger.h" | ||
#include "FairRootManager.h" | ||
#include "FairRunAna.h" | ||
#include "FairRunOnline.h" | ||
#include "FairRuntimeDb.h" | ||
#include "TCanvas.h" | ||
#include "TClonesArray.h" | ||
#include "TFolder.h" | ||
#include "TH2F.h" | ||
#include "THttpServer.h" | ||
|
||
R3BOnlineSyncCheck::R3BOnlineSyncCheck() | ||
: R3BOnlineSyncCheck("OnlineSyncCheck", 1) | ||
{ | ||
} | ||
|
||
R3BOnlineSyncCheck::R3BOnlineSyncCheck(const TString& name, Int_t iVerbose) | ||
: FairTask(name, iVerbose) | ||
, fCA(NULL) | ||
, header(nullptr) | ||
, fTpat(-1) | ||
, fTrig(-1) | ||
, canvas(nullptr) | ||
, fh2_array() | ||
{ | ||
} | ||
|
||
TString R3BOnlineSyncCheck::EnumName(int value) | ||
{ | ||
switch (value) | ||
{ | ||
case MASTER_SC: | ||
return TString("MASTER"); | ||
case MASTERREF_SC: | ||
return TString("MASTER_REF"); | ||
case MUSIC_SC: | ||
return TString("MUSIC"); | ||
case RPC_SC: | ||
return TString("RPC"); | ||
case S2_SC: | ||
return TString("S2"); | ||
case FOOT1_SC: | ||
return TString("FOOT1"); | ||
case FOOT2_SC: | ||
return TString("FOOT2"); | ||
default: | ||
return TString("Invalid enum value"); | ||
} | ||
} | ||
|
||
InitStatus R3BOnlineSyncCheck::Init() | ||
{ | ||
R3BLOG(info, ""); | ||
FairRootManager* mgr = FairRootManager::Instance(); | ||
R3BLOG_IF(fatal, NULL == mgr, "FairRootManager not found"); | ||
|
||
FairRunOnline* run = FairRunOnline::Instance(); | ||
run->GetHttpServer()->Register("", this); | ||
|
||
header = dynamic_cast<R3BEventHeader*>(mgr->GetObject("EventHeader.")); | ||
R3BLOG_IF(fatal, !header, "Branch EventHeader. not found"); | ||
|
||
fCA = dynamic_cast<TClonesArray*>(mgr->GetObject("SyncCheckData")); | ||
R3BLOG_IF(fatal, !fCA, "Branch SyncCheckData not found"); | ||
|
||
canvas = new TCanvas("Sync check", "Sync check"); | ||
canvas->Divide(NXPADS, NYPADS); | ||
|
||
for (int i = 0; i < NUM_SC; ++i) | ||
{ | ||
canvas->cd(i + 1); | ||
TString hname = EnumName(i); | ||
auto* fh2 = new TH2F(hname.Data(), hname.Data(), XBINS, XMIN, XMAX, YBINS, YMIN, YMAX); | ||
fh2->GetXaxis()->SetTitle(EnumName(MASTER_SC).Data()); | ||
fh2->GetYaxis()->SetTitle(EnumName(i).Data()); | ||
fh2->GetXaxis()->CenterTitle(true); | ||
fh2->GetYaxis()->CenterTitle(true); | ||
fh2->Draw("colz"); | ||
fh2_array.push_back(fh2); | ||
} | ||
TFolder* mainfol = new TFolder("SYNC_CHECK", "SYNC_CHECK"); | ||
mainfol->Add(canvas); | ||
run->AddObject(mainfol); | ||
run->GetHttpServer()->RegisterCommand("Reset_Sync_Check", Form("/Objects/%s/->Reset_Histo()", GetName())); | ||
return kSUCCESS; | ||
} | ||
|
||
void R3BOnlineSyncCheck::Reset_Histo() | ||
{ | ||
R3BLOG(info, ""); | ||
for (const auto& hist : fh2_array) | ||
{ | ||
hist->Reset(); | ||
} | ||
} | ||
|
||
void R3BOnlineSyncCheck::Exec(Option_t* option) | ||
{ | ||
if (fTpat >= 0 && header && ((header->GetTpat() & fTpat) != fTpat)) | ||
return; | ||
if (fTrig >= 0 && header && (header->GetTrigger() != fTrig)) | ||
return; | ||
if (fCA->GetEntriesFast() == 0) | ||
return; | ||
|
||
R3BSyncCheckData* sdata = dynamic_cast<R3BSyncCheckData*>(fCA->At(0)); | ||
R3BLOG_IF(fatal, !sdata, "Sync check data is empty!"); | ||
|
||
uint32_t val = 0; | ||
for (int i = 0; i < NUM_SC; ++i) | ||
{ | ||
switch (i) | ||
{ | ||
case MUSIC_SC: | ||
val = sdata->GetMusic(); | ||
break; | ||
case RPC_SC: | ||
val = sdata->GetRpc(); | ||
break; | ||
case S2_SC: | ||
val = sdata->GetS2(); | ||
break; | ||
case FOOT1_SC: | ||
val = sdata->GetFoot1(); | ||
break; | ||
case FOOT2_SC: | ||
val = sdata->GetFoot2(); | ||
break; | ||
default: | ||
val = 0; | ||
break; | ||
} | ||
fh2_array.at(i)->Fill(sdata->GetMaster(), val); | ||
} | ||
} | ||
|
||
void R3BOnlineSyncCheck::FinishEvent() { fCA->Clear(); } | ||
|
||
void R3BOnlineSyncCheck::FinishTask() { canvas->Write(); } | ||
|
||
ClassImp(R3BOnlineSyncCheck); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/****************************************************************************** | ||
* Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH * | ||
* Copyright (C) 2019-2023 Members of R3B Collaboration * | ||
* * | ||
* This software is distributed under the terms of the * | ||
* GNU General Public Licence (GPL) version 3, * | ||
* copied verbatim in the file "LICENSE". * | ||
* * | ||
* In applying this license GSI does not waive the privileges and immunities * | ||
* granted to it by virtue of its status as an Intergovernmental Organization * | ||
* or submit itself to any jurisdiction. * | ||
******************************************************************************/ | ||
|
||
#ifndef R3BOnlineSyncCheck_H | ||
#define R3BOnlineSyncCheck_H 1 | ||
|
||
#include "FairTask.h" | ||
|
||
class TClonesArray; | ||
class R3BEventHeader; | ||
class TCanvas; | ||
class TH1F; | ||
class TH2F; | ||
|
||
class R3BOnlineSyncCheck : public FairTask | ||
{ | ||
public: | ||
R3BOnlineSyncCheck(); | ||
R3BOnlineSyncCheck(const TString& name, Int_t iVerbose = 1); | ||
Check warning on line 29 in analysis/online/R3BOnlineSyncCheck.h GitHub Actions / clang-tidy
|
||
InitStatus Init(); | ||
void Exec(Option_t* option); | ||
void FinishEvent(); | ||
void FinishTask(); | ||
void Reset_Histo(); | ||
void SetTpat(Int_t tpat) { fTpat = tpat; } | ||
void SetTrig(Int_t trig) { fTrig = trig; } | ||
static TString EnumName(int val); | ||
|
||
private: | ||
enum SyncValues | ||
{ | ||
MUSIC_SC, | ||
RPC_SC, | ||
S2_SC, | ||
FOOT1_SC, | ||
FOOT2_SC, | ||
NUM_SC, | ||
MASTER_SC, | ||
MASTERREF_SC | ||
}; | ||
|
||
TClonesArray* fCA; | ||
R3BEventHeader* header; | ||
Int_t fTpat; | ||
Int_t fTrig; | ||
TCanvas* canvas; | ||
std::vector<TH2F*> fh2_array; | ||
static constexpr auto XBINS = 20; | ||
static constexpr auto YBINS = 50; | ||
static constexpr auto XMIN = 0; | ||
static constexpr auto XMAX = 20; | ||
static constexpr auto YMIN = 0; | ||
static constexpr auto YMAX = 500; | ||
static constexpr auto NXPADS = 3; | ||
static constexpr auto NYPADS = 3; | ||
|
||
public: | ||
ClassDef(R3BOnlineSyncCheck, 1) | ||
}; | ||
|
||
#endif /* R3BOnlineSyncCheck_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters