-
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.
Implementation of Parameter finder for Tprev/Tnext calculation
Update of MSOffset classes
- Loading branch information
1 parent
b0f85c9
commit cb819cb
Showing
11 changed files
with
551 additions
and
34 deletions.
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
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,73 @@ | ||
/****************************************************************************** | ||
* 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. * | ||
******************************************************************************/ | ||
|
||
// | ||
// R3BMSOffsetContFact | ||
// | ||
// Factory for the parameter containers in libR3BMSOffset | ||
// | ||
|
||
#include "R3BMSOffsetContFact.h" | ||
#include "R3BMSOffsetPar.h" | ||
|
||
#include "FairParAsciiFileIo.h" | ||
#include "FairParRootFileIo.h" | ||
#include "FairRuntimeDb.h" | ||
|
||
#include "R3BLogger.h" | ||
|
||
#include "TClass.h" | ||
|
||
static const R3BMSOffsetContFact gR3BMSOffsetContFact; | ||
|
||
R3BMSOffsetContFact::R3BMSOffsetContFact() | ||
{ | ||
// Constructor (called when the library is loaded) | ||
fName = "R3BMSOffsetContFact"; | ||
fTitle = "Factory for parameter containers in libR3BMSOffset"; | ||
setAllContainers(); | ||
FairRuntimeDb::instance()->addContFactory(this); | ||
} | ||
|
||
void R3BMSOffsetContFact::setAllContainers() | ||
{ | ||
// Creates the Container objects with all accepted contexts and adds them to | ||
// the list of containers for the STS library. | ||
|
||
auto pOffset = std::make_unique<FairContainer>("MSOffsetPar", "MSOffsetPar Offset Parameters", "MSOffsetPar"); | ||
pOffset->addContext("MSOffsetPar"); | ||
|
||
containers->Add(pOffset.release()); | ||
} | ||
|
||
FairParSet* R3BMSOffsetContFact::createContainer(FairContainer* cOffset) | ||
{ | ||
// Trals the constructor of the corresponding parameter container. | ||
// For an actual context, which is not an empty string and not the default context | ||
// of this container, the name is concatinated with the context. | ||
|
||
// const char* name = cOffset->GetName(); | ||
// R3BLOG(info, name); | ||
// FairParSet* pOff = nullptr; | ||
// if (strcmp(name, "MSOffsetPar") == 0) | ||
const auto name = std::string_view{cOffset->GetName()}; | ||
R3BLOG(info, name); | ||
FairParSet* pOff = nullptr; | ||
if (name == "MSOffsetPar") | ||
{ | ||
pOff = new R3BMSOffsetPar(cOffset->getConcatName().Data(), cOffset->GetTitle(), cOffset->getContext()); | ||
} | ||
return pOff; | ||
} | ||
|
||
ClassImp(R3BMSOffsetContFact); |
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,33 @@ | ||
/****************************************************************************** | ||
* 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. * | ||
******************************************************************************/ | ||
#pragma once | ||
|
||
#include "FairContFact.h" | ||
|
||
class FairContainer; | ||
|
||
class R3BMSOffsetContFact : public FairContFact | ||
{ | ||
private: | ||
void setAllContainers(); | ||
|
||
public: | ||
R3BMSOffsetContFact(); | ||
R3BMSOffsetContFact(const R3BMSOffsetContFact&) = delete; | ||
R3BMSOffsetContFact(R3BMSOffsetContFact&&) = delete; | ||
R3BMSOffsetContFact& operator=(const R3BMSOffsetContFact&) = delete; | ||
R3BMSOffsetContFact& operator=(R3BMSOffsetContFact&&) = delete; | ||
~R3BMSOffsetContFact() override = default; | ||
FairParSet* createContainer(FairContainer* /*unused*/) override; | ||
ClassDefOverride(R3BMSOffsetContFact, 0) // Factory for all MSOffset parameter containers | ||
}; |
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,168 @@ | ||
/****************************************************************************** | ||
* 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. * | ||
******************************************************************************/ | ||
|
||
// ROOT headers | ||
#include "R3BSamplerMappedData.h" | ||
#include "R3BShared.h" | ||
#include "TClonesArray.h" | ||
#include "TF1.h" | ||
#include "TH1F.h" | ||
#include "TMath.h" | ||
#include "TObjArray.h" | ||
#include "TRandom.h" | ||
#include "TVector3.h" | ||
#include <cstdlib> | ||
#include <iostream> | ||
// Fair headers | ||
#include "FairLogger.h" | ||
#include "FairRootManager.h" | ||
#include "FairRunAna.h" | ||
#include "FairRuntimeDb.h" | ||
|
||
// R3B headers | ||
#include "R3BEventHeader.h" | ||
#include "R3BMSOffsetFinder.h" | ||
#include "R3BMSOffsetPar.h" | ||
|
||
// R3BMSOffsetFinder: Default Constructor -------------------------- | ||
R3BMSOffsetFinder::R3BMSOffsetFinder() | ||
: R3BMSOffsetFinder("R3B MS Offset Finder", 1) | ||
{ | ||
} | ||
|
||
// R3BMSOffsetFinder: Standard Constructor -------------------------- | ||
R3BMSOffsetFinder::R3BMSOffsetFinder(const TString& name, Int_t iVerbose) | ||
: FairTask(name, iVerbose) | ||
, fMSOffset(0.0) | ||
, fMinStatistics(1) | ||
, fMSOffsetPar(nullptr) | ||
, fSamplerMapped(nullptr) | ||
, fSamplerMSMapped(nullptr) | ||
, fh_Offset_Finder(nullptr) | ||
{ | ||
} | ||
|
||
void R3BMSOffsetFinder::SetParContainers() | ||
{ | ||
// Parameter Container | ||
if (auto* rtdb = FairRuntimeDb::instance(); rtdb == nullptr) | ||
{ | ||
LOG(error) << "FairRuntimeDb not opened!"; | ||
} | ||
} | ||
|
||
// ----- Public method Init -------------------------------------------- | ||
InitStatus R3BMSOffsetFinder::Init() | ||
{ | ||
|
||
LOG(info) << "R3BMSOffsetFinder: Init"; | ||
|
||
FairRootManager* rootManager = FairRootManager::Instance(); | ||
if (rootManager == nullptr) | ||
{ | ||
return kFATAL; | ||
} | ||
|
||
fSamplerMapped = dynamic_cast<TClonesArray*>(rootManager->GetObject("SamplerMapped")); | ||
if (fSamplerMapped == nullptr) | ||
{ | ||
return kFATAL; | ||
} | ||
|
||
fSamplerMSMapped = dynamic_cast<TClonesArray*>(rootManager->GetObject("SamplerMSMapped")); | ||
if (fSamplerMSMapped == nullptr) | ||
{ | ||
return kFATAL; | ||
} | ||
|
||
FairRuntimeDb* rtdb = FairRuntimeDb::instance(); | ||
if (rtdb == nullptr) | ||
{ | ||
return kFATAL; | ||
} | ||
|
||
fMSOffsetPar = dynamic_cast<R3BMSOffsetPar*>(rtdb->getContainer("MSOffsetPar")); | ||
if (fMSOffsetPar == nullptr) | ||
{ | ||
LOG(error) << "R3BMSOffsetFinder::Init() Couldn't get handle on MSOffsetPar container"; | ||
return kFATAL; | ||
} | ||
|
||
fh_Offset_Finder = R3B::root_owned<TH1F>("MSOffsetFinderHisto", "MSOffsetFinderHisto", 2000.0, -1000.0, 1000.0); | ||
|
||
return kSUCCESS; | ||
} | ||
|
||
// ----- Public method ReInit -------------------------------------------- | ||
InitStatus R3BMSOffsetFinder::ReInit() | ||
{ | ||
SetParContainers(); | ||
return kSUCCESS; | ||
} | ||
|
||
// ----- Public method Exec -------------------------------------------- | ||
void R3BMSOffsetFinder::Exec(Option_t* /*opt*/) | ||
{ | ||
|
||
const Int_t sampHits = fSamplerMapped->GetEntriesFast(); | ||
const Int_t sampmsHits = fSamplerMSMapped->GetEntriesFast(); | ||
if ((sampHits == 0) || (sampmsHits != 1)) | ||
{ | ||
return; | ||
} | ||
Double_t SAMPTime = 0; | ||
R3BSamplerMappedData* SAMPMapped = nullptr; | ||
|
||
R3BSamplerMappedData* SAMPMSMapped = dynamic_cast<R3BSamplerMappedData*>(fSamplerMSMapped->At(0)); | ||
auto SAMPMSTime = SAMPMSMapped->GetTime(); | ||
|
||
for (Int_t i = 0; i < sampHits; i++) | ||
{ | ||
SAMPMapped = dynamic_cast<R3BSamplerMappedData*>(fSamplerMapped->At(i)); | ||
SAMPTime = SAMPMapped->GetTime(); | ||
|
||
// Fill the histogram | ||
fh_Offset_Finder->Fill(SAMPTime - SAMPMSTime); | ||
} | ||
} | ||
|
||
// ---- Public method Reset -------------------------------------------------- | ||
void R3BMSOffsetFinder::Reset() {} | ||
|
||
void R3BMSOffsetFinder::FinishEvent() {} | ||
|
||
// ---- Public method Finish -------------------------------------------------- | ||
void R3BMSOffsetFinder::FinishTask() { SearchMSOffset(); } | ||
|
||
//------------------ | ||
|
||
void R3BMSOffsetFinder::SearchMSOffset() | ||
{ | ||
|
||
LOG(info) << "R3BMSOffsetFinder: Search MS Offset"; | ||
if (fh_Offset_Finder->GetEntries() >= fMinStatistics) | ||
{ | ||
auto MSpos = fh_Offset_Finder->GetMaximumBin(); | ||
auto offset = | ||
(fh_Offset_Finder->GetBinCenter(MSpos)) - | ||
0.5; // The bin is unitary, so the Bin Center will always be X.5 (the center of a unitary bin). To fix that | ||
// the -0.5 is added to the equation. The time here is in clock cycles, so thi -0.5 corrects that. | ||
fMSOffsetPar->SetMSOffset(offset); | ||
} | ||
|
||
// Fill container: | ||
|
||
fMSOffsetPar->setChanged(); | ||
} | ||
|
||
ClassImp(R3BMSOffsetFinder) |
Oops, something went wrong.