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
16 changes: 16 additions & 0 deletions Modules/MUON/MCH/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ set(SRCS
src/DecodingErrorsTask.cxx
src/PedestalsCheck.cxx
src/PhysicsCheck.cxx
src/PhysicsOccupancyCheck.cxx
src/PhysicsPreclustersCheck.cxx
src/TH1MCHReductor.cxx
)

Expand All @@ -21,8 +23,15 @@ set(HEADERS
include/MCH/DecodingErrorsTask.h
include/MCH/PedestalsCheck.h
include/MCH/PhysicsCheck.h
include/MCH/PhysicsOccupancyCheck.h
include/MCH/PhysicsPreclustersCheck.h
include/MCH/TH1MCHReductor.h
include/MCH/MergeableTH2Ratio.h
include/MCH/MergeableTH1OccupancyPerDE.h
include/MCH/MergeableTH1OccupancyPerDECycle.h
include/MCH/MergeableTH1PseudoEfficiencyPerDE.h
include/MCH/MergeableTH1PseudoEfficiencyPerDECycle.h
include/MCH/MergeableTH1MPVPerDECycle.h
)

# ---- Library ----
Expand Down Expand Up @@ -67,11 +76,18 @@ add_root_dictionary(${MODULE_NAME}
include/MCH/PhysicsTaskDigits.h
include/MCH/PhysicsTaskPreclusters.h
include/MCH/PhysicsCheck.h
include/MCH/PhysicsOccupancyCheck.h
include/MCH/PhysicsPreclustersCheck.h
include/MCH/DecodingErrorsTask.h
include/MCH/PedestalsCheck.h
include/MCH/TH1MCHReductor.h
include/MCH/sampa_header.h
include/MCH/MergeableTH2Ratio.h
include/MCH/MergeableTH1OccupancyPerDE.h
include/MCH/MergeableTH1OccupancyPerDECycle.h
include/MCH/MergeableTH1PseudoEfficiencyPerDE.h
include/MCH/MergeableTH1PseudoEfficiencyPerDECycle.h
include/MCH/MergeableTH1MPVPerDECycle.h
LINKDEF include/MCH/LinkDef.h)

# ---- Tests ----
Expand Down
24 changes: 20 additions & 4 deletions Modules/MUON/MCH/include/MCH/GlobalHistogram.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,25 @@ namespace quality_control_modules
namespace muonchambers
{

std::string getHistoPath(int deId);

class DetectorHistogram : public TH2F
{
public:
DetectorHistogram(TString name, TString title, int deId);

void Fill(double padX, double padY, double padSizeX, double padSizeY, double val = 1);
void Set(double padX, double padY, double padSizeX, double padSizeY, double val);

private:
int mDeId{ 0 };

bool mFlipX{ false };
bool mFlipY{ false };
};

class GlobalHistogram : public TH2F
{
int getLR(int de);
void getDeCenter(int de, float& xB0, float& yB0, float& xNB0, float& yNB0);
void getDeCenterST3(int de, float& xB0, float& yB0, float& xNB0, float& yNB0);
void getDeCenterST4(int de, float& xB0, float& yB0, float& xNB0, float& yNB0);
Expand All @@ -43,13 +59,13 @@ class GlobalHistogram : public TH2F
void init();

// add the histograms of the individual detection elements
void add(std::map<int, TH2F*>& histB, std::map<int, TH2F*>& histNB);
void add(std::map<int, DetectorHistogram*>& histB, std::map<int, DetectorHistogram*>& histNB);

// replace the contents with the histograms of the individual detection elements, including null bins
void set_includeNull(std::map<int, TH2F*>& histB, std::map<int, TH2F*>& histNB);
void set_includeNull(std::map<int, DetectorHistogram*>& histB, std::map<int, DetectorHistogram*>& histNB);

// replace the contents with the histograms of the individual detection elements
void set(std::map<int, TH2F*>& histB, std::map<int, TH2F*>& histNB, bool doAverage = true, bool includeNullBins = false);
void set(std::map<int, DetectorHistogram*>& histB, std::map<int, DetectorHistogram*>& histNB, bool doAverage = true, bool includeNullBins = false);
};

} // namespace muonchambers
Expand Down
7 changes: 7 additions & 0 deletions Modules/MUON/MCH/include/MCH/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@
#pragma link C++ class o2::quality_control_modules::muonchambers::DecodingErrorsTask + ;
#pragma link C++ class o2::quality_control_modules::muonchambers::PedestalsCheck + ;
#pragma link C++ class o2::quality_control_modules::muonchambers::PhysicsCheck + ;
#pragma link C++ class o2::quality_control_modules::muonchambers::PhysicsOccupancyCheck + ;
#pragma link C++ class o2::quality_control_modules::muonchambers::PhysicsPreclustersCheck + ;
#pragma link C++ class o2::quality_control_modules::muonchambers::TH1MCHReductor + ;
#pragma link C++ class o2::quality_control_modules::muonchambers::MergeableTH2Ratio + ;
#pragma link C++ class o2::quality_control_modules::muonchambers::MergeableTH1OccupancyPerDE + ;
#pragma link C++ class o2::quality_control_modules::muonchambers::MergeableTH1OccupancyPerDECycle + ;
#pragma link C++ class o2::quality_control_modules::muonchambers::MergeableTH1PseudoEfficiencyPerDE + ;
#pragma link C++ class o2::quality_control_modules::muonchambers::MergeableTH1PseudoEfficiencyPerDECycle + ;
#pragma link C++ class o2::quality_control_modules::muonchambers::MergeableTH1MPVPerDECycle + ;

#endif
106 changes: 106 additions & 0 deletions Modules/MUON/MCH/include/MCH/MergeableGlobalHistogramRatio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN 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.

/// \file MergeableGlobalHistogramRatio.h
/// \brief An example of a custom class inheriting MergeInterface
///
/// \author Piotr Konopka, piotr.jan.konopka@cern.ch, Sebastien Perrin

#ifndef O2_MERGEABLEGLOBALHISTOGRAMRATIO_H
#define O2_MERGEABLEGLOBALHISTOGRAMRATIO_H

#include <sstream>
#include <iostream>
#include <TObject.h>
#include <TH2.h>
#include <TList.h>
#include "Mergers/MergeInterface.h"
#include "MCH/GlobalHistogram.h"

using namespace std;
namespace o2::quality_control_modules::muonchambers
{

class MergeableGlobalHistogramRatio : public GlobalHistogram, public o2::mergers::MergeInterface
{
public:
MergeableGlobalHistogramRatio() = default;

MergeableGlobalHistogramRatio(MergeableGlobalHistogramRatio const& copymerge)
: GlobalHistogram(copymerge.getName(), copymerge.getTitle()), o2::mergers::MergeInterface(), mhistoNum(copymerge.getNum()), mhistoDen(copymerge.getDen()), mname(copymerge.getName()), mtitle(copymerge.getTitle())
{
update();
}

MergeableGlobalHistogramRatio(const char* name, const char* title, GlobalHistogram* histonum, GlobalHistogram* histoden)
: GlobalHistogram(name, title), o2::mergers::MergeInterface(), mhistoNum(histonum), mhistoDen(histoden), mname(name), mtitle(title)
{
update();
}

~MergeableGlobalHistogramRatio() override = default;

void merge(MergeInterface* const other) override
{
mhistoNum->Add(dynamic_cast<const MergeableGlobalHistogramRatio* const>(other)->getNum());
mhistoDen->Add(dynamic_cast<const MergeableGlobalHistogramRatio* const>(other)->getDen());
update();
}

GlobalHistogram* getNum() const
{
return mhistoNum;
}

GlobalHistogram* getDen() const
{
return mhistoDen;
}

const char* getName() const
{
return mname;
}

const char* getTitle() const
{
return mtitle;
}

void update()
{
std::cout << "A1" << endl;
Reset("MICES");
std::cout << "A2" << endl;
init();
std::cout << "A3" << endl;
Divide(mhistoNum, mhistoDen);
std::cout << "A4" << endl;
// SetName(mname);
// SetTitle(mtitle);
std::cout << "A5" << endl;
Scale(1 / 87.5);
SetOption("colz");
std::cout << "A6" << endl;
}

private:
GlobalHistogram* mhistoNum{ nullptr };
GlobalHistogram* mhistoDen{ nullptr };
std::string mTreatMeAs = "TH2F";
const char* mname = "DefaultName";
const char* mtitle = "DefaultTitle";

ClassDefOverride(MergeableGlobalHistogramRatio, 1);
};

} // namespace o2::quality_control_modules::muonchambers

#endif //O2_MERGEABLEGLOBALHISTOGRAMRATIO_H
126 changes: 126 additions & 0 deletions Modules/MUON/MCH/include/MCH/MergeableTH1MPVPerDECycle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN 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.

/// \file MergeableTH1OccupancyPerDE.h
/// \brief An example of a custom TH2Quotient inheriting MergeInterface
///
/// \author Piotr Konopka, piotr.jan.konopka@cern.ch, Sebastien Perrin

#ifndef O2_MERGEABLETH1MPVPERDECYCLE_H
#define O2_MERGEABLETH1MPVPERDECYCLE_H

#include <sstream>
#include <iostream>
#include <TObject.h>
#include <TF1.h>
#include <TH1.h>
#include <TH2.h>
#include <TList.h>
#include <algorithm>

#include "Mergers/MergeInterface.h"
#include "MCHRawElecMap/Mapper.h"
#ifdef HAVE_DIGIT_IN_DATAFORMATS
#include "DataFormatsMCH/Digit.h"
#else
#include "MCHBase/Digit.h"
#endif

using namespace std;
namespace o2::quality_control_modules::muonchambers
{

class MergeableTH1MPVPerDECycle : public TH1F, public o2::mergers::MergeInterface
{
public:
MergeableTH1MPVPerDECycle() = default;

MergeableTH1MPVPerDECycle(MergeableTH1MPVPerDECycle const& copymerge)
: TH1F("DefaultNameCycle", "DefaultTitleCycle", 1100, -0.5, 1099.5), o2::mergers::MergeInterface(), mhistosCharge(copymerge.getNum())
{
}

MergeableTH1MPVPerDECycle(const char* name, const char* title, std::map<int, TH1F*> histosnum)
: TH1F(name, title, 1100, -0.5, 1099.5), o2::mergers::MergeInterface(), mhistosCharge(histosnum)
{
update();
}

~MergeableTH1MPVPerDECycle() override = default;

void merge(MergeInterface* const other) override
{ //FIXME
for (auto de : o2::mch::raw::deIdsForAllMCH) {
auto hnum = dynamic_cast<const MergeableTH1MPVPerDECycle* const>(other)->getNum().find(de);
if ((hnum != dynamic_cast<const MergeableTH1MPVPerDECycle* const>(other)->getNum().end()) && (hnum->second != NULL)) {

auto hnumfinal = mhistosCharge.find(de);
if ((hnumfinal != mhistosCharge.end()) && (hnumfinal->second != NULL)) {
hnumfinal->second->Add(hnum->second);
}
}
}

update();
}

std::map<int, TH1F*> getNum() const
{
return mhistosCharge;
}

void update()
{ //FIXME
const char* name = this->GetName();
const char* title = this->GetTitle();
Reset();
SetNameTitle(name, title);

TF1* f1 = new TF1("f1", "landau", 200, 5000); //1650V [200,5k] 1700V [400,10k]

for (auto de : o2::mch::raw::deIdsForAllMCH) {
auto hLandauCycle = mhistosCharge.find(de);
if ((hLandauCycle != mhistosCharge.end()) && (hLandauCycle->second != NULL)) {

double chindf = 0;
double mpv = 0;

if (hLandauCycle->second->GetEntries() > 0) {
f1->SetParameter(1, 0);
f1->SetParameter(2, 500); // Start Sigma at 500
// f1->FixParameter(1,1000); // Fix MPV 1650V 500 1700V 1000
f1->SetParLimits(2, 100, 10000);
f1->SetParLimits(1, 0, 10000);
f1->SetParLimits(0, 0, 100000); // Say we want a positive Normalisation
TFitResultPtr ptr = hLandauCycle->second->Fit("f1", "RB");
chindf = f1->GetChisquare() / f1->GetNDF();
mpv = f1->GetParameter(1);
if (mpv > 0) {
cout << "DE : " << de << endl;
cout << "Chi2/ndf :" << chindf << endl;
cout << "MPV :" << mpv << endl;
}
}

SetBinContent(de + 1, mpv);
}
}
}

private:
std::map<int, TH1F*> mhistosCharge;
std::string mTreatMeAs = "TH1F";

ClassDefOverride(MergeableTH1MPVPerDECycle, 1);
};

} // namespace o2::quality_control_modules::muonchambers

#endif //O2_MERGEABLETH1MPVPERDECYCLE_H
Loading