Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Analysis/DataModel/include/PID/BetheBloch.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace o2::pid::tpc
class BetheBloch : public Parametrization
{
public:
BetheBloch() : Parametrization("BetheBloch", 7) { Printf("%s", fName.Data()); };
BetheBloch() : Parametrization("BetheBloch", 7){};
~BetheBloch() override = default;
float operator()(const float* x) const override
{
Expand Down
2 changes: 1 addition & 1 deletion Analysis/DataModel/include/PID/TOFReso.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace o2::pid::tof
class TOFReso : public Parametrization
{
public:
TOFReso() : Parametrization("TOFReso", 5) { Printf("%s", fName.Data()); };
TOFReso() : Parametrization("TOFReso", 5){};
~TOFReso() override = default;
float operator()(const float* x) const override
{
Expand Down
2 changes: 1 addition & 1 deletion Analysis/DataModel/include/PID/TPCReso.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace o2::pid::tpc
class TPCReso : public Parametrization
{
public:
TPCReso() : Parametrization("TPCReso", 2) { Printf("%s", fName.Data()); };
TPCReso() : Parametrization("TPCReso", 2){};
~TPCReso() override = default;
float operator()(const float* x) const override
{
Expand Down
5 changes: 5 additions & 0 deletions Analysis/DataModel/include/PIDBase/ParamBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ class Parametrization : public TNamed
/// Printer for parameters
void PrintParametrization() const;

/// Setter for the parameter at position iparam
/// \param iparam index in the array of the parameters
/// \param value value of the parameter at position iparam
void SetParameter(const unsigned int iparam, const pidvar_t value) { mParameters.SetParameter(iparam, value); }

/// Setter for the parameter, using an array
/// \param params array with parameters
void SetParameters(const std::vector<pidvar_t> params) { mParameters.SetParameters(params); }
Expand Down
52 changes: 35 additions & 17 deletions Analysis/DataModel/src/handleParamTPCBetheBloch.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ bool initOptionsAndParse(bpo::options_description& options, int argc, char* argv
"url,u", bpo::value<std::string>()->default_value("http://ccdb-test.cern.ch:8080"), "URL of the CCDB database")(
"start,s", bpo::value<long>()->default_value(0), "Start timestamp of object validity")(
"stop,S", bpo::value<long>()->default_value(4108971600000), "Stop timestamp of object validity")(
"delete_previous,d", bpo::value<int>()->default_value(0), "Flag to delete previous versions of converter objects in the CCDB before uploading the new one so as to avoid proliferation on CCDB")(
"file,f", bpo::value<std::string>()->default_value(""), "Option to save parametrization to file instead of uploading to ccdb")(
"delete-previous,d", bpo::value<int>()->default_value(0), "Flag to delete previous versions of converter objects in the CCDB before uploading the new one so as to avoid proliferation on CCDB")(
"save-to-file,f", bpo::value<std::string>()->default_value(""), "Option to save parametrization to file instead of uploading to ccdb")(
"read-from-file", bpo::value<std::string>()->default_value(""), "Option to get parametrization from a file")(
"mode,m", bpo::value<unsigned int>()->default_value(0), "Working mode: 0 push 1 pull and test")(
"verbose,v", bpo::value<int>()->default_value(0), "Verbose level 0, 1")(
"help,h", "Produce help message.");
Expand Down Expand Up @@ -75,35 +76,52 @@ int main(int argc, char* argv[])
return 1;
}
if (mode == 0) { // Push mode
const std::vector<float> bbparams = {0.0320981, 19.9768, 2.52666e-16, 2.72123, 6.08092, 50.f, 2.3};
const std::vector<float> resoparams = {0.07, 0.0};
BetheBloch tpc;
tpc.SetParameters(bbparams);
TPCReso reso;
reso.SetParameters(resoparams);
const std::string fname = vm["file"].as<std::string>();
BetheBloch* bb = nullptr;
TPCReso* reso = nullptr;
const std::string input_file_name = vm["read-from-file"].as<std::string>();

if (!input_file_name.empty()) {
TFile f(input_file_name.data(), "READ");
if (!f.IsOpen()) {
LOG(WARNING) << "Input file " << input_file_name << " is not reacheable, cannot get param from file";
}
f.GetObject("BetheBloch", bb);
f.GetObject("TPCReso", reso);
f.Close();
}
if (!bb) {
bb = new BetheBloch();
const std::vector<float> bbparams = {0.0320981, 19.9768, 2.52666e-16, 2.72123, 6.08092, 50.f, 2.3};
bb->SetParameters(bbparams);
}
if (!reso) {
reso = new TPCReso();
const std::vector<float> resoparams = {0.07, 0.0};
reso->SetParameters(resoparams);
}
const std::string fname = vm["save-to-file"].as<std::string>();
if (!fname.empty()) { // Saving it to file
TFile f(fname.data(), "RECREATE");
tpc.Write();
reso.Write();
bb->Write();
reso->Write();
f.ls();
f.Close();
} else { // Saving it to CCDB

long start = vm["start"].as<long>();
long stop = vm["stop"].as<long>();

if (vm["delete_previous"].as<int>()) {
if (vm["delete-previous"].as<int>()) {
api.truncate(path);
}
api.storeAsTFileAny(&tpc, path + "/BetheBloch", metadata, start, stop);
api.storeAsTFileAny(&reso, path + "/TPCReso", metadata, start, stop);
api.storeAsTFileAny(bb, path + "/BetheBloch", metadata, start, stop);
api.storeAsTFileAny(reso, path + "/TPCReso", metadata, start, stop);
}
} else { // Pull and test mode
const float x[2] = {1, 1};
BetheBloch* tpc = api.retrieveFromTFileAny<BetheBloch>(path + "/BetheBloch", metadata, -1, headers);
tpc->PrintParametrization();
LOG(INFO) << "BetheBloch " << tpc->operator()(x);
BetheBloch* bb = api.retrieveFromTFileAny<BetheBloch>(path + "/BetheBloch", metadata, -1, headers);
bb->PrintParametrization();
LOG(INFO) << "BetheBloch " << bb->operator()(x);
TPCReso* reso = api.retrieveFromTFileAny<TPCReso>(path + "/TPCReso", metadata, -1, headers);
reso->PrintParametrization();
LOG(INFO) << "TPCReso " << reso->operator()(x);
Expand Down
1 change: 0 additions & 1 deletion Analysis/Tasks/pidTOF.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ struct pidTOFTask {

void process(aod::Collision const& collision, soa::Join<aod::Tracks, aod::TracksExtra> const& tracks)
{
LOGF(info, "Tracks for collision: %d", tracks.size());
tof::EventTime evt = tof::EventTime();
evt.SetEvTime(0, collision.collisionTime());
evt.SetEvTimeReso(0, collision.collisionTimeRes());
Expand Down
186 changes: 120 additions & 66 deletions Analysis/Tasks/spectraTOF.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,80 +28,133 @@ using namespace o2;
using namespace o2::framework;
using namespace o2::framework::expressions;

struct TOFPIDQATask {
#define TRACKSELECTION \
UChar_t clustermap = i.itsClusterMap(); \
bool issel = (i.tpcNClsFindable() > 70) && (i.flags() & 0x4) && (TESTBIT(clustermap, 0) || TESTBIT(clustermap, 1)); \
issel = issel && (i.flags() & 0x2000); \
issel = issel && (i.flags() & 0x80000000); \
if (!issel) \
continue;

// #define TRACKSELECTION 1;

struct TOFQATask {
// Event quantities
DOTH1F(hvtxz, ";Vertex Z position;Events", 300, -15, 15);
DOTH1F(hevtime, ";Event time (ns);Tracks", 100, -2, 2);
// Track quantities
DOTH1F(hp_NoCut, ";#it{p} (GeV/#it{c});Tracks", 100, 0, 20);
DOTH1F(hp_TrkCut, ";#it{p} (GeV/#it{c});Tracks", 100, 0, 20);
DOTH1F(hp_TOFCut, ";#it{p} (GeV/#it{c});Tracks", 100, 0, 20);
// TOF Quantities
DOTH1F(hlength_NoCut, ";Track Length (cm);Tracks", 100, 0, 1000);
DOTH1F(htime_NoCut, ";TOF Time (ns);Tracks", 1000, 0, 600);
DOTH1F(hevtime_NoCut, ";Event time (ns);Tracks", 100, -2, 2);
DOTH2F(hp_pTOFexp_NoCut, ";#it{p} (GeV/#it{c});#it{p}_{Exp TOF} (GeV/#it{c});Tracks", 100, 0, 20, 100, 0, 20);
// T-Texp
DOTH2F(htimediffEl_NoCut, ";#it{p} (GeV/#it{c});(t-t_{evt}-t_{exp e});Tracks", 100, 0, 5, 100, -1000, 1000);
DOTH2F(htimediffMu_NoCut, ";#it{p} (GeV/#it{c});(t-t_{evt}-t_{exp #mu});Tracks", 100, 0, 5, 100, -1000, 1000);
DOTH2F(htimediffPi_NoCut, ";#it{p} (GeV/#it{c});(t-t_{evt}-t_{exp #pi});Tracks", 100, 0, 5, 100, -1000, 1000);
DOTH2F(htimediffKa_NoCut, ";#it{p} (GeV/#it{c});(t-t_{evt}-t_{exp K});Tracks", 100, 0, 5, 100, -1000, 1000);
DOTH2F(htimediffPr_NoCut, ";#it{p} (GeV/#it{c});(t-t_{evt}-t_{exp p});Tracks", 100, 0, 5, 100, -1000, 1000);
// NSigma
DOTH2F(hnsigmaEl_NoCut, ";#it{p} (GeV/#it{c});(t-t_{evt}-t_{exp e})/N_{sigma e};Tracks", 100, 0, 5, 100, -10, 10);
DOTH2F(hnsigmaMu_NoCut, ";#it{p} (GeV/#it{c});(t-t_{evt}-t_{exp #mu})/N_{sigma #mu};Tracks", 100, 0, 5, 100, -10, 10);
DOTH2F(hnsigmaPi_NoCut, ";#it{p} (GeV/#it{c});(t-t_{evt}-t_{exp #pi})/N_{sigma #pi};Tracks", 100, 0, 5, 100, -10, 10);
DOTH2F(hnsigmaKa_NoCut, ";#it{p} (GeV/#it{c});(t-t_{evt}-t_{exp K})/N_{sigma K};Tracks", 100, 0, 5, 100, -10, 10);
DOTH2F(hnsigmaPr_NoCut, ";#it{p} (GeV/#it{c});(t-t_{evt}-t_{exp p})/N_{sigma p};Tracks", 100, 0, 5, 100, -10, 10);
DOTH1F(heta, ";#eta;Tracks", 100, -1, 1);
DOTH1F(hp, ";#it{p} (GeV/#it{c});Tracks", 100, 0, 20);
DOTH1F(hpt, ";#it{p}_{T} (GeV/#it{c});Tracks", 100, 0, 20);
DOTH1F(hlength, ";Track Length (cm);Tracks", 100, 0, 1000);
DOTH1F(htime, ";TOF Time (ns);Tracks", 1000, 0, 600);
// Beta
DOTH2F(hp_beta, ";#it{p} (GeV/#it{c});TOF #beta;Tracks", 100, 0, 20, 100, 0, 2);

void process(aod::Collision const& collision, soa::Join<aod::Tracks, aod::TracksExtra, aod::pidRespTOF, aod::pidRespTOFbeta> const& tracks)
{
hvtxz->Fill(collision.posZ());
for (auto i : tracks) {
hp_NoCut->Fill(i.p());
// Track selection
UChar_t clustermap = i.itsClusterMap();
bool issel = (i.tpcNClsFindable() > 70) && (i.flags() & 0x4) && (TESTBIT(clustermap, 0) || TESTBIT(clustermap, 1));
if (issel)
hp_TrkCut->Fill(i.p());
issel = issel && (i.flags() & 0x2000); //kTOFout
issel = issel && (i.flags() & 0x80000000); //kTIME
if (issel)
hp_TOFCut->Fill(i.p());
hp_pTOFexp_NoCut->Fill(i.p(), i.tofExpMom() / (TMath::C() * 1.0e2f * 1.0e-12f));
//
hlength_NoCut->Fill(i.length());
htime_NoCut->Fill(i.tofSignal() / 1000);
TRACKSELECTION;
//
hevtime_NoCut->Fill(collision.collisionTime() / 1000);
// hevtime_NoCut->Fill(collision.collisionTime0() / 1000);
hevtime->Fill(collision.collisionTime() / 1000);
// hevtime->Fill(collision.collisionTime0() / 1000);
const float psq = sqrt(i.px() * i.px() + i.py() * i.py() + i.pz() * i.pz());
heta->Fill(i.eta());
hp->Fill(i.p());
hpt->Fill(i.pt());
//
htimediffEl_NoCut->Fill(i.p(), i.tofSignal() - collision.collisionTime() - i.tofExpSignalEl());
htimediffMu_NoCut->Fill(i.p(), i.tofSignal() - collision.collisionTime() - i.tofExpSignalMu());
htimediffPi_NoCut->Fill(i.p(), i.tofSignal() - collision.collisionTime() - i.tofExpSignalPi());
htimediffKa_NoCut->Fill(i.p(), i.tofSignal() - collision.collisionTime() - i.tofExpSignalKa());
htimediffPr_NoCut->Fill(i.p(), i.tofSignal() - collision.collisionTime() - i.tofExpSignalPr());
//
hnsigmaEl_NoCut->Fill(i.p(), i.tofNSigmaEl());
hnsigmaMu_NoCut->Fill(i.p(), i.tofNSigmaMu());
hnsigmaPi_NoCut->Fill(i.p(), i.tofNSigmaPi());
hnsigmaKa_NoCut->Fill(i.p(), i.tofNSigmaKa());
hnsigmaPr_NoCut->Fill(i.p(), i.tofNSigmaPr());
hlength->Fill(i.length());
htime->Fill(i.tofSignal() / 1000);
// Beta
hp_beta->Fill(i.p(), i.beta());
}
}
};

struct SpectraTask {
struct TOFExpTimeQATask {
// T-Texp
#define TIT(part) Form(";#it{p} (GeV/#it{c});(t-t_{evt}-t_{exp %s});Tracks", part)
DOTH2F(htimediffEl, TIT("e"), 100, 0, 5, 100, -1000, 1000);
DOTH2F(htimediffMu, TIT("#mu"), 100, 0, 5, 100, -1000, 1000);
DOTH2F(htimediffPi, TIT("#pi"), 100, 0, 5, 100, -1000, 1000);
DOTH2F(htimediffKa, TIT("K"), 100, 0, 5, 100, -1000, 1000);
DOTH2F(htimediffPr, TIT("p"), 100, 0, 5, 100, -1000, 1000);
DOTH2F(htimediffDe, TIT("d"), 100, 0, 5, 100, -1000, 1000);
DOTH2F(htimediffTr, TIT("t"), 100, 0, 5, 100, -1000, 1000);
DOTH2F(htimediffHe, TIT("^{3}He"), 100, 0, 5, 100, -1000, 1000);
DOTH2F(htimediffAl, TIT("#alpha"), 100, 0, 5, 100, -1000, 1000);
#undef TIT

void process(aod::Collision const& collision, soa::Join<aod::Tracks, aod::TracksExtra, aod::pidRespTOF, aod::pidRespTOFbeta> const& tracks)
{
for (auto i : tracks) {
// Track selection
TRACKSELECTION;
//
const float tof = i.tofSignal() - collision.collisionTime();
htimediffEl->Fill(i.p(), tof - i.tofExpSignalEl());
htimediffMu->Fill(i.p(), tof - i.tofExpSignalMu());
htimediffPi->Fill(i.p(), tof - i.tofExpSignalPi());
htimediffKa->Fill(i.p(), tof - i.tofExpSignalKa());
htimediffPr->Fill(i.p(), tof - i.tofExpSignalPr());
htimediffDe->Fill(i.p(), tof - i.tofExpSignalDe());
htimediffTr->Fill(i.p(), tof - i.tofExpSignalTr());
htimediffHe->Fill(i.p(), tof - i.tofExpSignalHe());
htimediffAl->Fill(i.p(), tof - i.tofExpSignalAl());
}
}
};

struct TOFNSigmaQATask {
// NSigma
#define TIT(part) Form(";#it{p} (GeV/#it{c});(t-t_{evt}-t_{exp %s})/N_{sigma %s};Tracks", part, part)
DOTH2F(hnsigmaEl, TIT("e"), 100, 0, 5, 100, -10, 10);
DOTH2F(hnsigmaMu, TIT("#mu"), 100, 0, 5, 100, -10, 10);
DOTH2F(hnsigmaPi, TIT("#pi"), 100, 0, 5, 100, -10, 10);
DOTH2F(hnsigmaKa, TIT("K"), 100, 0, 5, 100, -10, 10);
DOTH2F(hnsigmaPr, TIT("p"), 100, 0, 5, 100, -10, 10);
DOTH2F(hnsigmaDe, TIT("d"), 100, 0, 5, 100, -10, 10);
DOTH2F(hnsigmaTr, TIT("t"), 100, 0, 5, 100, -10, 10);
DOTH2F(hnsigmaHe, TIT("^{3}He"), 100, 0, 5, 100, -10, 10);
DOTH2F(hnsigmaAl, TIT("#alpha"), 100, 0, 5, 100, -10, 10);
#undef TIT

void process(aod::Collision const& collision, soa::Join<aod::Tracks, aod::TracksExtra, aod::pidRespTOF, aod::pidRespTOFbeta> const& tracks)
{
for (auto i : tracks) {
// Track selection
TRACKSELECTION;
//
hnsigmaEl->Fill(i.p(), i.tofNSigmaEl());
hnsigmaMu->Fill(i.p(), i.tofNSigmaMu());
hnsigmaPi->Fill(i.p(), i.tofNSigmaPi());
hnsigmaKa->Fill(i.p(), i.tofNSigmaKa());
hnsigmaPr->Fill(i.p(), i.tofNSigmaPr());
hnsigmaDe->Fill(i.p(), i.tofNSigmaDe());
hnsigmaTr->Fill(i.p(), i.tofNSigmaTr());
hnsigmaHe->Fill(i.p(), i.tofNSigmaHe());
hnsigmaAl->Fill(i.p(), i.tofNSigmaAl());
}
}
};

struct TOFSpectraTask {
// Pt
DOTH1F(hpt_El, ";#it{p}_{T} (GeV/#it{c});Tracks", 100, 0, 20);
DOTH1F(hpt_Pi, ";#it{p}_{T} (GeV/#it{c});Tracks", 100, 0, 20);
DOTH1F(hpt_Ka, ";#it{p}_{T} (GeV/#it{c});Tracks", 100, 0, 20);
DOTH1F(hpt_Pr, ";#it{p}_{T} (GeV/#it{c});Tracks", 100, 0, 20);
#define TIT ";#it{p}_{T} (GeV/#it{c});Tracks"
DOTH1F(hpt_El, TIT, 100, 0, 20);
DOTH1F(hpt_Pi, TIT, 100, 0, 20);
DOTH1F(hpt_Ka, TIT, 100, 0, 20);
DOTH1F(hpt_Pr, TIT, 100, 0, 20);
#undef TIT
// P
DOTH1F(hp_El, ";#it{p} (GeV/#it{c});Tracks", 100, 0, 20);
DOTH1F(hp_Pi, ";#it{p} (GeV/#it{c});Tracks", 100, 0, 20);
DOTH1F(hp_Ka, ";#it{p} (GeV/#it{c});Tracks", 100, 0, 20);
DOTH1F(hp_Pr, ";#it{p} (GeV/#it{c});Tracks", 100, 0, 20);
#define TIT ";#it{p} (GeV/#it{c});Tracks"
DOTH1F(hp_El, TIT, 100, 0, 20);
DOTH1F(hp_Pi, TIT, 100, 0, 20);
DOTH1F(hp_Ka, TIT, 100, 0, 20);
DOTH1F(hp_Pr, TIT, 100, 0, 20);
#undef TIT
//
DOTH1F(hlength_El, ";Track Length (cm);Tracks", 100, 0, 1000);
DOTH1F(htime_El, ";TOF Time (ns);Tracks", 1000, 0, 600);
Expand All @@ -115,15 +168,12 @@ struct SpectraTask {
void process(soa::Join<aod::Tracks, aod::TracksExtra, aod::pidRespTOF, aod::pidRespTOFbeta> const& tracks)
{
for (auto i : tracks) {
UChar_t clustermap = i.itsClusterMap();
bool issel = (i.tpcNClsFindable() > 70) && (i.flags() & 0x4) && (TESTBIT(clustermap, 0) || TESTBIT(clustermap, 1));
issel = issel && (i.flags() & 0x2000); //kTOFout
issel = issel && (i.flags() & 0x80000000); //kTIME
if (!issel)
continue;
// Track selection
TRACKSELECTION;
//
if (TMath::Abs(i.tofNSigmaPi()) < 3) {
hp_El->Fill(i.p());
hpt_El->Fill(i.pt());
hp_Pi->Fill(i.p());
hpt_Pi->Fill(i.pt());
} else if (TMath::Abs(i.tofNSigmaKa()) < 3) {
hp_Ka->Fill(i.p());
hpt_Ka->Fill(i.pt());
Expand All @@ -148,6 +198,10 @@ struct SpectraTask {
WorkflowSpec defineDataProcessing(ConfigContext const&)
{
return WorkflowSpec{
adaptAnalysisTask<TOFPIDQATask>("tofpidqa-task"),
adaptAnalysisTask<SpectraTask>("filterEl-task")};
adaptAnalysisTask<TOFQATask>("tofqa-task"),
adaptAnalysisTask<TOFExpTimeQATask>("tofexptime-task"),
adaptAnalysisTask<TOFNSigmaQATask>("tofnsigma-task"),
adaptAnalysisTask<TOFSpectraTask>("tofspectra-task")};
}

#undef TRACKSELECTION
Loading