Skip to content

Commit 4433ee1

Browse files
mwinn2aphecetche
authored andcommitted
Digit moved + integer for adc(#2634)
* Digit moved * clean up headers and Cmakelists * adding MCHBase on top * Fix compilation and linking issues * linking and naming fixed * fixes * moving to integer for adc * adding class def * hand fixes local * ClassIMP removed * remove ClassImp * modifications clang Co-authored-by: Laurent Aphecetche <laurent.aphecetche@cern.ch>
1 parent 4c92d5f commit 4433ee1

File tree

17 files changed

+87
-39
lines changed

17 files changed

+87
-39
lines changed

Detectors/MUON/MCH/Base/CMakeLists.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
99
# submit itself to any jurisdiction.
1010

1111
o2_add_library(MCHBase
12-
SOURCES src/Mapping.cxx src/DigitBlock.cxx
13-
src/PreClusterBlock.cxx src/ClusterBlock.cxx
14-
src/TrackBlock.cxx
15-
PUBLIC_LINK_LIBRARIES ROOT::Core FairRoot::Base FairMQ::FairMQ)
12+
SOURCES
13+
src/ClusterBlock.cxx
14+
src/Digit.cxx
15+
src/DigitBlock.cxx
16+
src/Mapping.cxx
17+
src/PreClusterBlock.cxx
18+
src/TrackBlock.cxx
19+
PUBLIC_LINK_LIBRARIES ROOT::Core FairRoot::Base FairMQ::FairMQ)
20+
21+
o2_target_root_dictionary(MCHBase
22+
HEADERS include/MCHBase/Digit.h)

Detectors/MUON/MCH/Simulation/include/MCHSimulation/Digit.h renamed to Detectors/MUON/MCH/Base/include/MCHBase/Digit.h

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
* @author Michael Winn
1414
*/
1515

16-
#ifndef ALICEO2_MCH_DIGIT_H_
17-
#define ALICEO2_MCH_DIGIT_H_
16+
#ifndef ALICEO2_MCH_BASE_DIGIT_H_
17+
#define ALICEO2_MCH_BASE_DIGIT_H_
1818

19-
#include "CommonDataFormat/TimeStamp.h"
19+
#include "Rtypes.h"
2020

2121
namespace o2
2222
{
@@ -25,28 +25,30 @@ namespace mch
2525

2626
// \class Digit
2727
/// \brief MCH digit implementation
28-
using DigitBase = o2::dataformats::TimeStamp<double>;
29-
class Digit : public DigitBase
28+
class Digit
3029
{
3130
public:
3231
Digit() = default;
3332

34-
Digit(double time, int detid, int pad, double adc);
33+
Digit(double time, int detid, int pad, unsigned long adc);
3534
~Digit() = default;
3635

36+
bool operator==(const Digit&) const;
37+
38+
double getTimeStamp() const { return mTime; }
39+
3740
int getDetID() const { return mDetID; }
38-
void setDetID(int detid) { mDetID = detid; }
3941

4042
int getPadID() const { return mPadID; }
41-
void setPadID(int pad) { mPadID = pad; }
4243

43-
double getADC() const { return mADC; }
44-
void setADC(double adc) { mADC = adc; }
44+
unsigned long getADC() const { return mADC; }
45+
void setADC(unsigned long adc) { mADC = adc; }
4546

4647
private:
48+
double mTime;
4749
int mDetID;
48-
int mPadID; /// PadIndex to which the digit corresponds to
49-
double mADC; /// Amplitude of signal
50+
int mPadID; /// PadIndex to which the digit corresponds to
51+
unsigned long mADC; /// Amplitude of signal
5052

5153
ClassDefNV(Digit, 1);
5254
}; //class Digit
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
#include "MCHBase/Digit.h"
12+
#include <cmath>
13+
14+
namespace o2::mch
15+
{
16+
17+
bool closeEnough(double x, double y, double eps = 1E-6)
18+
{
19+
return std::fabs(x - y) <= eps * std::max(1.0, std::max(std::fabs(x), std::fabs(y)));
20+
}
21+
22+
Digit::Digit(double time, int detid, int pad, unsigned long adc)
23+
: mTime(time), mDetID(detid), mPadID(pad), mADC(adc)
24+
{
25+
}
26+
27+
bool Digit::operator==(const Digit& other) const
28+
{
29+
return mDetID == other.mDetID &&
30+
mPadID == other.mPadID &&
31+
mADC == other.mADC &&
32+
closeEnough(mTime, other.mTime);
33+
}
34+
35+
} // namespace o2::mch

Detectors/MUON/MCH/Simulation/src/Digit.cxx renamed to Detectors/MUON/MCH/Base/src/MCHBaseLinkDef.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88
// granted to it by virtue of its status as an Intergovernmental Organization
99
// or submit itself to any jurisdiction.
1010

11-
#include "MCHSimulation/Digit.h"
11+
#ifdef __CLING__
1212

13-
using namespace o2::mch;
13+
#pragma link off all globals;
14+
#pragma link off all classes;
15+
#pragma link off all functions;
1416

15-
ClassImp(o2::mch::Digit);
17+
#pragma link C++ namespace o2;
18+
#pragma link C++ namespace o2::mch;
1619

17-
Digit::Digit(double time, int detid, int pad, double adc)
18-
: DigitBase(time), mDetID(detid), mPadID(pad), mADC(adc)
19-
{
20-
}
20+
#pragma link C++ class o2::mch::Digit + ;
21+
#pragma link C++ class std::vector < o2::mch::Digit> + ;
22+
23+
#endif

Detectors/MUON/MCH/Simulation/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
o2_add_library(MCHSimulation
1212
SOURCES src/Detector.cxx
13-
src/Digit.cxx
1413
src/Digitizer.cxx
1514
src/Geometry.cxx
1615
src/GeometryTest.cxx
@@ -26,13 +25,13 @@ o2_add_library(MCHSimulation
2625
src/Station345Geometry.h
2726
src/Stepper.cxx
2827
src/Stepper.h
29-
PUBLIC_LINK_LIBRARIES O2::SimulationDataFormat
28+
PUBLIC_LINK_LIBRARIES O2::SimulationDataFormat
29+
O2::MCHBase
3030
O2::MCHMappingImpl3 O2::DetectorsBase
3131
RapidJSON::RapidJSON)
3232

3333
o2_target_root_dictionary(MCHSimulation
3434
HEADERS include/MCHSimulation/Detector.h
35-
include/MCHSimulation/Digit.h
3635
include/MCHSimulation/Digitizer.h
3736
include/MCHSimulation/Geometry.h
3837
include/MCHSimulation/GeometryTest.h
@@ -42,6 +41,6 @@ o2_target_root_dictionary(MCHSimulation
4241
if(BUILD_TESTING)
4342
add_subdirectory(test)
4443
o2_add_test_root_macro(macros/drawMCHGeometry.C
45-
PUBLIC_LINK_LIBRARIES O2::MCHSimulation
44+
PUBLIC_LINK_LIBRARIES O2::MCHSimulation O2::MCHBase
4645
LABELS "muon;mch")
4746
endif()

Detectors/MUON/MCH/Simulation/include/MCHSimulation/Digitizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#ifndef O2_MCH_SIMULATION_MCHDIGITIZER_H_
1717
#define O2_MCH_SIMULATION_MCHDIGITIZER_H_
1818

19-
#include "MCHSimulation/Digit.h"
19+
#include "MCHBase/Digit.h"
2020
#include "MCHSimulation/Hit.h"
2121

2222
#include "SimulationDataFormat/MCCompLabel.h"

Detectors/MUON/MCH/Simulation/include/MCHSimulation/Response.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#ifndef O2_MCH_SIMULATION_RESPONSE_H_
1212
#define O2_MCH_SIMULATION_RESPONSE_H_
1313

14-
#include "MCHSimulation/Digit.h"
14+
#include "MCHBase/Digit.h"
1515
#include "MCHSimulation/Detector.h"
1616
#include "MCHSimulation/Hit.h"
1717

@@ -37,7 +37,7 @@ class Response
3737
float etocharge(float edepos);
3838
double chargePadfraction(float xmin, float xmax, float ymin, float ymax);
3939
double chargefrac1d(float min, float max, double k2, double sqrtk3, double k4);
40-
double response(float charge);
40+
unsigned long response(float charge);
4141
float getAnod(float x);
4242
float chargeCorr();
4343

Detectors/MUON/MCH/Simulation/src/Response.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ double Response::chargefrac1d(float min, float max, double k2, double sqrtk3, do
8383
return 2. * k4 * (TMath::ATan(u2) - TMath::ATan(u1));
8484
}
8585
//______________________________________________________________________
86-
double Response::response(float charge)
86+
unsigned long Response::response(float charge)
8787
{
8888
//FEE effects
89-
return charge;
89+
return (unsigned long)charge;
9090
}
9191
//______________________________________________________________________
9292
float Response::getAnod(float x)

Detectors/MUON/MCH/Simulation/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ o2_add_test(simulation
1212
COMPONENT_NAME mchsimulation
1313
SOURCES testDigitMerging.cxx DigitMerging.cxx testGeometry.cxx
1414
testDigitization.cxx testResponse.cxx
15-
PUBLIC_LINK_LIBRARIES O2::MCHSimulation
15+
PUBLIC_LINK_LIBRARIES O2::MCHSimulation O2::MCHBase
1616
LABELS muon mch long CONFIGURATIONS RelWithDebInfo)
1717

1818
if(benchmark_FOUND)

Detectors/MUON/MCH/Simulation/test/DigitMerging.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#define O2_MCH_SIMULATION_TEST_DIGITMERGING_H
1313

1414
#include <vector>
15-
#include "MCHSimulation/Digit.h"
15+
#include "MCHBase/Digit.h"
1616
#include "SimulationDataFormat/MCCompLabel.h"
1717

1818
std::vector<o2::mch::Digit> mergeDigitsMW(const std::vector<o2::mch::Digit>& inputDigits, const std::vector<o2::MCCompLabel>& labels);

0 commit comments

Comments
 (0)