Belle II Software development
arich modules

Classes

class  arichBtestModule
 The UserTutorial module. More...
 
class  ARICHChannelMaskModule
 ARICH channel-mask calibration: data collector. More...
 
class  ARICHDigitizerModule
 ARICH digitizer module. More...
 
class  ARICHDQMModule
 Make summary of data quality from reconstruction. More...
 
class  ARICHFillHitsModule
 Fill ARICHHit collection from ARICHDigits. More...
 
class  ARICHMCParticlesModule
 Module to match ARICH hits to MCParticles. More...
 
class  ARICHNtupleModule
 ARICH reconstruction efficiency test module. More...
 
class  ARICHPackerModule
 Raw data packer for ARICH. More...
 
class  ARICHRateCalModule
 Fill ARICHHit collection from ARICHDigits. More...
 
class  ARICHRawUnpackerModule
 Fill ARICHHit collection from ARICHDigits. More...
 
class  ARICHReconstruction
 Internal ARICH track reconstruction. More...
 
class  ARICHReconstructorModule
 ARICH subdetector main module. More...
 
class  ARICHRelateModule
 Creates relations between ARICHAeroHits and ExtHits. More...
 
class  arichToNtupleModule
 This module extends existing variablesToNtuple to append detailed arich information to candidates in the analysis output ntuple. More...
 
struct  ARICHRawHeader
 ARICH raw-data header. More...
 
class  ARICHUnpackerModule
 Raw data unpacker for ARICH. More...
 

Macros

#define ARICH_BUFFER_NWORDS   252
 Arich number of words (ints) in buffer: 3 + 33 + 6 * 36 (3 merger header words + 5.5 FEB header words / FEB + 36 data words per / FEB).
 
#define ARICHFEB_HEADER_SIZE   10
 FEB header size in bytes.
 
#define ARICHRAW_HEADER_SIZE   12
 Raw header size in bytes.
 

Functions

 REG_MODULE (arichBtest)
 Register the Module.
 
 REG_MODULE (ARICHDigitizer)
 Register the Module.
 
TH2 * moduleHitMap (TH1 *hitMap, int moduleID)
 Make hit map in HAPD view (12*12 channels).
 
TH2 * moduleDeadMap (TH1 *hitMap, int moduleID)
 Make chip dead/alive map in HAPD view (2*2 chips).
 
TH1 * mergerClusterHitMap1D (TH1 *hitMap, int mergerID)
 Make 1D hit map of specified Merger Board.
 
TCanvas * mergerClusterHitMap2D (TH1 *hitMap, int mergerID)
 Make display of 6 HAPDs' 2D hit map of the Merger Board.
 
TCanvas * sectorHitMap (TH1 *hitMap, int sector)
 Make display of 70 HAPDs' 2D hit map of the sector.
 
TCanvas * sectorDeadMap (TH1 *hitMap, int sector)
 Make display of 70 HAPDs' 2D dead/alive map of the sector.
 
 REG_MODULE (ARICHDQM)
 
void deadPalette ()
 Set palette for sector dead-chip map.
 
 REG_MODULE (ARICHFillHits)
 Register module.
 
 REG_MODULE (ARICHMCParticles)
 Register module.
 
 REG_MODULE (ARICHNtuple)
 Register module.
 
 REG_MODULE (ARICHPacker)
 
 REG_MODULE (ARICHRateCal)
 
 REG_MODULE (ARICHRawUnpacker)
 
 REG_MODULE (ARICHReconstructor)
 Register the Module.
 
 REG_MODULE (ARICHRelate)
 Register module.
 
 REG_MODULE (ARICHUnpacker)
 Register module.
 
 arichBtestModule ()
 Constructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
int skipdata (gzFile fp)
 Skip the data part of the record.
 
void readmwpc (unsigned int *dbuf, unsigned int len, int print=0)
 Read the MWPC information from the data buffer.
 
int readhapd (unsigned int len, unsigned int *data)
 Read the HAPD hits from the data buffer.
 
int getTrack (int mask, ROOT::Math::XYZVector &r, ROOT::Math::XYZVector &dir)
 Beamtest Track reconstruction.
 
int readdata (gzFile fp, int rec_id, int print)
 Read the data from the file (can be compressed)
 
virtual void event () override
 Running over all events.
 
virtual void endRun () override
 Is called after processing the last event of a run.
 
virtual void terminate () override
 Is called at the end of your Module.
 
 ARICHDigitizerModule ()
 Constructor.
 
virtual ~ARICHDigitizerModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
void magFieldDistorsion (ROOT::Math::XYVector &hit, int copyno)
 Apply correction to hit position due to non-perpendicular component of magnetic field.
 
 ARICHDQMModule ()
 Constructor.
 
virtual ~ARICHDQMModule ()
 Destructor.
 
virtual void defineHisto () override
 Definition of the histograms.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
virtual void endRun () override
 End-of-run action.
 
 ARICHFillHitsModule ()
 Constructor.
 
virtual ~ARICHFillHitsModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void event () override
 Event processor.
 
void magFieldCorrection (ROOT::Math::XYZVector &hitpos)
 Corrects hit position for distorsion due to non-perpendicular magnetic field component.
 
 ARICHMCParticlesModule ()
 Constructor.
 
virtual ~ARICHMCParticlesModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void event () override
 Event processor.
 
 ARICHNtupleModule ()
 Constructor.
 
virtual ~ARICHNtupleModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void event () override
 Event processor.
 
virtual void terminate () override
 Termination action.
 
 ARICHPackerModule ()
 Constructor.
 
virtual ~ARICHPackerModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void event () override
 Event processor.
 
void writeHeader (int *buffer, unsigned &ibyte, const ARICHRawHeader &head)
 TODO!
 
unsigned int calbyte (const int *buf)
 Get calculated byte.
 
unsigned int calword (const int *buf)
 Get calculated word.
 
 ARICHRateCalModule ()
 Constructor.
 
virtual ~ARICHRateCalModule ()
 Destructor.
 
virtual void defineHisto () override
 Definition of the histograms.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
unsigned int calbyte (const int *buf)
 Read byte with number m_ibyte from the buffer and increase the number by 1.
 
unsigned int calword (const int *buf)
 Read word (4 bytes) from the buffer and increase the byte number m_ibyte by 4.
 
 ARICHRawUnpackerModule ()
 Constructor.
 
virtual ~ARICHRawUnpackerModule ()
 Destructor.
 
virtual void defineHisto () override
 Definition of the histograms.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void event () override
 Event processor.
 
 ARICHReconstruction (int storePhotons=0)
 Constructor.
 
void initialize ()
 Read geometry parameters from xml and initialize class members.
 
int InsideDetector (ROOT::Math::XYZVector a, int copyno)
 Returns 1 if vector "a" lies on "copyno"-th detector active surface of detector and 0 else.
 
int smearTrack (ARICHTrack &arichTrack)
 Smears track parameters ("simulate" the uncertainties of tracking).
 
ROOT::Math::XYZVector FastTracking (ROOT::Math::XYZVector dirf, ROOT::Math::XYZVector r, double *refind, double *z, int n, int opt)
 Calculates the intersection of the Cherenkov photon emitted from point "r" in "dirf" direction with the detector plane.
 
ROOT::Math::XYZVector HitVirtualPosition (const ROOT::Math::XYZVector &hitpos, int mirrorID)
 Returns the hit virtual position, assuming that it was reflected from mirror.
 
bool HitsMirror (const ROOT::Math::XYZVector &pos, const ROOT::Math::XYZVector &dir, int mirrorID)
 Returns true if photon at position pos with direction dir hits mirror plate with ID mirrorID.
 
int CherenkovPhoton (ROOT::Math::XYZVector r, ROOT::Math::XYZVector rh, ROOT::Math::XYZVector &rf, ROOT::Math::XYZVector &dirf, double *refind, double *z, int n, int mirrorID=0)
 Calculates the direction of photon emission.
 
int likelihood2 (ARICHTrack &arichTrack, const StoreArray< ARICHHit > &arichHits, ARICHLikelihood &arichLikelihood)
 Computes the value of identity likelihood function for different particle hypotheses.
 
void setTrackPositionResolution (double pRes)
 Sets track position resolution (from tracking).
 
void setTrackAngleResolution (double aRes)
 Sets track direction resolution (from tracking).
 
ROOT::Math::XYZVector getTrackMeanEmissionPosition (const ARICHTrack &track, int iAero)
 Returns mean emission position of Cherenkov photons from i-th aerogel layer.
 
ROOT::Math::XYZVector getTrackPositionAtZ (const ARICHTrack &track, double zout)
 Returns track direction at point with z coordinate "zout" (assumes straight track).
 
void transformTrackToLocal (ARICHTrack &arichTrack, bool align)
 Transforms track parameters from global Belle2 to ARICH local frame.
 
ROOT::Math::XYZVector getMirrorPoint (int mirrorID)
 Returns point on the mirror plate with id mirrorID.
 
ROOT::Math::XYZVector getMirrorNorm (int mirrorID)
 Returns normal vector of the mirror plate with id mirrorID.
 
void correctEmissionPoint (int tileID, double r)
 Correct mean emission point z position.
 
 ARICHReconstructorModule ()
 Constructor.
 
virtual ~ARICHReconstructorModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void beginRun () override
 Called when entering a new run.
 
virtual void event () override
 Event processor.
 
void printModuleParams ()
 Print module parameters.
 
 ARICHRelateModule ()
 Constructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void event () override
 Event processor.
 
unsigned int calbyte (const int *buf)
 calculate number of bytes in raw Unpacker
 
unsigned int cal2byte (const int *buf)
 calculate number of lines (2 bytes) in raw Unpacker
 
unsigned int calword (const int *buf)
 calculate number of words in raw Unpacker
 
 ARICHUnpackerModule ()
 Constructor.
 
virtual ~ARICHUnpackerModule ()
 Destructor.
 
virtual void initialize () override
 Initialize the Module.
 
virtual void event () override
 Event processor.
 
void readHeader (const int *buffer, unsigned &ibyte, ARICHRawHeader &head)
 Read Merger header.
 
void readFEHeader (const int *buffer, unsigned &ibyte, ARICHRawHeader &head)
 Read FE header.
 
void printBits (const int *buffer, int bufferSize)
 Unpack raw data given in production format.
 

Variables

TNtuple * m_tuple
 ntuple containing hapd hits
 
TH1F * hapd [6]
 histogram of hits for each hapd
 
TH1F * mwpc_tdc [4][5]
 tdc information from mwpcs
 
TH1F * mwpc_diff [4][2]
 tdc difference from mwpcs
 
TH1F * mwpc_sum [4][2]
 tdc sum from mwpcs
 
TH1F * mwpc_sum_cut [4][2]
 tdc sum from mwpcs, with sum cut applied
 
TH1F * mwpc_residuals [4][2]
 residuals from mwpcs
 
TH2F * mwpc_xy [4]
 calculated x-y track positions
 
TH2F * mwpc_residualsz [4][2]
 z-residuals from mwpcs
 

Detailed Description

Macro Definition Documentation

◆ ARICH_BUFFER_NWORDS

#define ARICH_BUFFER_NWORDS   252

Arich number of words (ints) in buffer: 3 + 33 + 6 * 36 (3 merger header words + 5.5 FEB header words / FEB + 36 data words per / FEB).

Definition at line 35 of file ARICHPackerModule.cc.

◆ ARICHFEB_HEADER_SIZE

#define ARICHFEB_HEADER_SIZE   10

FEB header size in bytes.

Definition at line 21 of file ARICHRawDataHeader.h.

◆ ARICHRAW_HEADER_SIZE

#define ARICHRAW_HEADER_SIZE   12

Raw header size in bytes.

Definition at line 24 of file ARICHRawDataHeader.h.

Function Documentation

◆ arichBtestModule()

Constructor.

Sets the module parameters.

Definition at line 63 of file arichBtestModule.cc.

63 : Module(), m_end(0), m_events(0), m_file(NULL), m_timestart(0), m_mwpc(NULL)
64 {
65 //Set module properties
66 setDescription("Module for the ARICH Beamtest data analysis. It creates track form the MWPC hits and reads the HAPD hits");
67
68 //Parameter definition
69 addParam("outputFileName", m_outFile, "Output Root Filename", std::string("output.root"));
70 std::vector<std::string> defaultList;
71 addParam("runList", m_runList, "Data Filenames.", defaultList);
72 std::vector<int> defaultMask;
73 addParam("mwpcTrackMask", m_MwpcTrackMask, "Create track from MWPC layers", defaultMask);
74 m_fp = NULL;
75 addParam("beamMomentum", m_beamMomentum, "Momentum of the beam [GeV]", 0.0);
76
77 for (int i = 0; i < 32; i++) m_tdc[i] = 0;
78
79 }
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
Module()
Constructor.
Definition: Module.cc:30
std::string m_outFile
output file name
time_t m_timestart
time of the first processed event
ARICHTracking * m_mwpc
Pointer to the tracking chambers.
int m_tdc[32]
raw MWPC TDC buffer
TFile * m_file
pointer to the root file
double m_beamMomentum
Momentum of the particles in the beam [GeV].
std::vector< std::string > m_runList
The filenames of the runs.
int m_events
number of events
std::vector< int > m_MwpcTrackMask
Bit mask of the MWPC tracking chambers used for the track creation.
gzFile m_fp
file desriptor of the data file
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560

◆ ARICHDigitizerModule()

Constructor.

Definition at line 51 of file ARICHDigitizerModule.cc.

51 : Module(),
52 m_maxQE(0)
53 {
54
55 // Set description()
56 setDescription("This module creates ARICHDigits from ARICHSimHits. Here spatial digitization is done, channel-by-channel QE is applied, and readout time window cut is applied.");
57
58 // Set property flags
60
61 // Add parameters
62 addParam("TimeWindow", m_timeWindow, "Readout time window width in ns", 250.0);
63 addParam("TimeWindowStart", m_timeWindowStart, "Shift of the readout time window with respect to the global zero in ns", -50.0);
64 addParam("BackgroundHits", m_bkgLevel, "Number of background hits per hapd per readout (electronics noise)", 0.066);
65 addParam("MagneticFieldDistorsion", m_bdistort, "Apply image distortion due to non-perp. magnetic field", 0);
66 }
double m_maxQE
QE at 400nm (from QE curve applied in SensitveDetector)
double m_bkgLevel
Number of background hits ped hapd per readout (electronics noise)
double m_timeWindow
Readout time window width in ns.
int m_bdistort
apply distorsion due to magnetic field
double m_timeWindowStart
Readout time window shift w.r.t.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80

◆ ARICHDQMModule()

Constructor.

Definition at line 44 of file ARICHDQMModule.cc.

44 : HistoModule()
45 {
46 // set module description (e.g. insert text)
47 setDescription("Make summary of data quality.");
49 addParam("debug", m_debug, "debug mode", false);
50 addParam("UpperMomentumLimit", m_momUpLim, "Upper momentum limit of tracks included in monitoring", 10.0);
51 addParam("LowerMomentumLimit", m_momDnLim, "Lower momentum limit of tracks included in monitoring", 2.5);
52 addParam("ArichEvents", m_arichEvents, "Include only hits from events where an extrapolated track to arich exists", false);
53 addParam("MaxHits", m_maxHits, "Include only events with less than MaxHits hits in ARICH (remove loud events)", 70000);
54 addParam("MinHits", m_minHits, "Include only events with more than MinHits hits in ARICH", 0);
55 }
int m_maxHits
Exclude events with very large number of hits in arich.
int m_minHits
Exclude events with number of hits lower than this.
double m_momDnLim
Lower momentum limit of tracks used in GeV (if set 0, no limit is applied).
double m_momUpLim
Upper momentum limit of tracks used in GeV (if set 0, no limit is applied).
bool m_arichEvents
Process only events that have extrapolated hit in arich.
HistoModule()
Constructor.
Definition: HistoModule.h:32

◆ ARICHFillHitsModule()

Constructor.

Definition at line 41 of file ARICHFillHitsModule.cc.

41 : Module()
42 {
43 // set module description (e.g. insert text)
44 setDescription("Fills ARICHHits collection from ARICHDigits");
46 addParam("bitMask", m_bitMask, "hit bit mask (8 bits/channel)", (uint8_t)0xFF);
47 addParam("maxApdHits", m_maxApdHits, "Remove hits with more than MaxApdHits per APD chip", (uint8_t)18);
48 addParam("maxHapdHits", m_maxHapdHits, "Remove hits with more than MaxHapdHits per HAPD", (uint8_t)100);
49 addParam("MagFieldCorrection", m_bcorrect, "Apply hit position correction due to non-perp. mag. field", 0);
50 addParam("fillAll", m_fillall, "Make hits for all active channels (useful for likelihood PDF studies)", 0);
51 }
int m_fillall
make hit for all active channels (usefull for likelihood PDF studies)
uint8_t m_maxApdHits
reject hits with more than number of hits in Apd
uint8_t m_bitMask
hit bit mask (only convert digits with hit in bitmask bits)
int m_bcorrect
apply hit position correction for the non-perp.
uint8_t m_maxHapdHits
reject hits with more than number of hits in Hapd

◆ ARICHMCParticlesModule()

Constructor.

Definition at line 39 of file ARICHMCParticlesModule.cc.

40 {
41 // set module description (e.g. insert text)
42 setDescription("Creates collection of MCParticles related to tracks that hit ARICH.");
43 // Set property flags
45
46 }

◆ ARICHNtupleModule()

Constructor.

Definition at line 54 of file ARICHNtupleModule.cc.

54 : Module(),
55 m_file(0),
56 m_tree(0)
57 {
58 // set module description (e.g. insert text)
59 setDescription("The module saves variables needed for performance analysis, such as postion and momentum of the hit, likelihoods for hypotheses and number of photons.");
60
61 // Add parameters
62 addParam("outputFile", m_outputFile, "ROOT output file name", std::string("ARICHNtuple.root"));
63 }
TTree * m_tree
pointer to output tree
std::string m_outputFile
output root file
TFile * m_file
pointer to output root file

◆ ARICHPackerModule()

Constructor.

Definition at line 46 of file ARICHPackerModule.cc.

46 : Module(),
48
49 {
50 // set module description (e.g. insert text)
51 setDescription("Raw data packer for ARICH");
53 addParam("nonSuppressed", m_nonSuppressed, "Pack in non-suppressed format (store all channels)", unsigned(0));
54 addParam("version", m_version, "dataformat version", unsigned(6));
55 addParam("bitMask", m_bitMask, "hit bit mask (4 bits/channel)", (unsigned)0xF);
56 addParam("debug", m_debug, "print packed bitmap", 0);
57 addParam("inputDigitsName", m_inputDigitsName, "name of ARICHDigit store array", std::string(""));
58 addParam("outputRawDataName", m_outputRawDataName, "name of RawARICH store array", std::string(""));
59
60 }
unsigned m_nonSuppressed
type of data (1 nonsuppressed, 0 suppressed)
unsigned m_version
dataformat version
std::string m_inputDigitsName
name of ARICHDigit store array
unsigned m_bitMask
bitmask for hit detection (4bit/hit)
std::string m_outputRawDataName
name of RawARICH store array

◆ ARICHRateCalModule()

Constructor.

Definition at line 45 of file ARICHRateCalModule.cc.

45 : HistoModule()
46 {
47 // set module description (e.g. insert text)
48 setDescription("Fills ARICHHits collection from ARICHDigits");
50 addParam("nrun", m_nrun, "# of scan runs", 100);
51 addParam("nevents", m_nevents, "# of events per run", 1000);
52 double v = 0;
53 addParam("dth", m_dth, "dth", v);
54 addParam("th0", m_th0, "th0", v);
55 addParam("debug", m_debugmode, "debug mode", false);
56 addParam("internal", m_internalmode, "Internal thscan mode", false);
57 addParam("daqdb", m_daqdb, "daqdb config name", std::string(""));
58 }
int m_nrun
number of scan runs
bool m_internalmode
whether internal thscan mode is requested
std::string m_daqdb
daqdb config name
int m_nevents
number of events per run
bool m_debugmode
whether debug mode is requested

◆ ARICHRawUnpackerModule()

Constructor.

Definition at line 36 of file ARICHRawUnpackerModule.cc.

36 : HistoModule()
37 {
38 m_debug = false;
39 }

◆ ARICHReconstruction()

ARICHReconstruction ( int  storePhotons = 0)
explicit

Constructor.

Definition at line 38 of file ARICHReconstruction.cc.

38 :
39 m_arichgp(),
40 m_recPars(),
43 m_alignMirrors(true),
45 m_storePhot(storePhot)
46 {
47 for (unsigned i = 0; i < c_noOfHypotheses; i++) {p_mass[i] = 0;}
48 for (unsigned i = 0; i < c_noOfAerogels; i++) {
49 m_refractiveInd[i] = 0;
50 m_zaero[i] = 0;
51 m_thickness[i] = 0;
52 m_transmissionLen[i] = 0;
53 m_n0[i] = 0;
54 m_anorm[i] = ROOT::Math::XYZVector();
55 }
56
57 }
DBObjPtr< ARICHReconstructionPar > m_recPars
reconstruction parameters from the DB
double m_zaero[c_noOfAerogels]
z-positions of aerogel layers
double p_mass[c_noOfHypotheses]
particle masses
double m_n0[c_noOfAerogels]
number of emitted photons per unit length
double m_transmissionLen[c_noOfAerogels]
transmission lengths of aerogel layers
bool m_alignMirrors
if set to true mirror alignment constants from DB are used
DBObjPtr< ARICHGeometryConfig > m_arichgp
geometry configuration parameters from the DB
double m_trackAngRes
track direction resolution (from tracking)
ROOT::Math::XYZVector m_anorm[c_noOfAerogels]
normal vector of the aerogel plane
double m_refractiveInd[c_noOfAerogels]
refractive indices of aerogel layers
unsigned int m_nAerogelLayers
number of aerogel layers
static const int c_noOfAerogels
Maximal number of aerogel layers to loop over.
double m_trackPosRes
track position resolution (from tracking)
static const int c_noOfHypotheses
Number of hypotheses to loop over.
int m_storePhot
set to 1 to store individual reconstructed photon information
double m_thickness[c_noOfAerogels]
thicknesses of aerogel layers

◆ ARICHReconstructorModule()

Constructor.

Definition at line 49 of file ARICHReconstructorModule.cc.

49 :
50 m_ana(NULL)
51 {
52 // Set description()
53 setDescription("This module calculates the ARICHLikelihood values for all particle id. hypotheses, for all tracks that enter ARICH in the event.");
54
55 // Set property flags
57
58 // Add parameters
59 addParam("trackPositionResolution", m_trackPositionResolution,
60 "Resolution of track position on aerogel plane (for additional smearing of MC tracks)", 1.0 * Unit::mm);
61 addParam("trackAngleResolution", m_trackAngleResolution,
62 "Resolution of track direction angle on aerogel plane (for additional smearing of MC tracks)", 2.0 * Unit::mrad);
63 addParam("inputTrackType", m_inputTrackType, "Input tracks switch: tracking (0), from AeroHits - MC info (1)", 0);
64 addParam("storePhotons", m_storePhot, "Set to 1 to store reconstructed photon information (Ch. angle,...)", 0);
65 addParam("useAlignment", m_align, "Use ARICH global position alignment constants", true);
66 addParam("useMirrorAlignment", m_alignMirrors, "Use ARICH mirror alignment constants", true);
67 }
ARICHReconstruction * m_ana
Class with reconstruction tools.
bool m_alignMirrors
Whether alignment constants for mirrors are used.
int m_inputTrackType
Input tracks from the tracking (0) or from MCParticles>AeroHits (1).
bool m_align
Whether alignment constants are used for global->local track transformation.
double m_trackAngleResolution
Track direction resolution; simulation smearing.
int m_storePhot
If == 1, individual reconstruced photon information (Cherenkov angle,...) is stored in ARICHTrack.
double m_trackPositionResolution
Track position resolution; simulation smearing.
static const double mm
[millimeters]
Definition: Unit.h:70
static const double mrad
[millirad]
Definition: Unit.h:108

◆ ARICHRelateModule()

Constructor.

Definition at line 40 of file ARICHRelateModule.cc.

41 {
42 // set module description (e.g. insert text)
43 setDescription("Creates relations between ARICHAeroHits and ExtHits. Allows to store simulation output without MCParticles");
44 // Set property flags
46
47 }

◆ ARICHUnpackerModule()

Constructor.

Definition at line 51 of file ARICHUnpackerModule.cc.

51 : Module(), m_bitMask(0), m_debug(0)
52 {
53 // set module description
54 setDescription("Raw data unpacker for ARICH");
56
57 addParam("bitMask", m_bitMask, "hit bit mask (8 bits/channel, only used for unsuppresed format!)", (uint8_t)0xFF);
58 addParam("debug", m_debug, "prints debug information", 0);
59
60 addParam("inputRawDataName", m_inputRawDataName, "name of RawARICH store array", std::string(""));
61 addParam("outputDigitsName", m_outputDigitsName, "name of ARICHDigit store array", std::string(""));
62 addParam("outputRawDigitsName", m_outputRawDigitsName, "name of ARICHRawDigit store array", std::string(""));
63 addParam("outputarichinfoName", m_outputarichinfoName, "name of ARICHInfo store array", std::string(""));
64 addParam("RawUnpackerMode", m_rawmode, "Activate RawUnpacker mode", 0);
65 addParam("DisableUnpackerMode", m_disable_unpacker, "Disable Regular Unpacker mode", 0);
66
67 }
std::string m_outputarichinfoName
name of ARICHInfo store object
int m_rawmode
Activate Raw Unpacker.
std::string m_outputRawDigitsName
name of ARICHRawDigit store array
uint8_t m_bitMask
bitmask for hit detection (8bits/hit)
std::string m_outputDigitsName
name of ARICHDigit store array
int m_disable_unpacker
Disable regular Unpacker.
std::string m_inputRawDataName
name of RawARICH store array

◆ beginRun() [1/5]

void beginRun ( void  )
overridevirtual

Called when entering a new run.

At the beginning of each run, the function gives you the chance to change run dependent constants like alignment parameters, etc.

Reimplemented from Module.

Definition at line 149 of file arichBtestModule.cc.

150 {
151
152 B2INFO("arichBtestModule::beginRun()");
153
154 StoreObjPtr<EventMetaData> eventMetaDataPtr;
155 B2INFO("arichBtestModule::eventMetaDataPtr run:" << eventMetaDataPtr->getRun());
156 B2INFO("arichBtestModule::eventMetaDataPtr exp:" << eventMetaDataPtr->getExperiment());
157
158 ARICHBtestGeometryPar* _arichbtgp = ARICHBtestGeometryPar::Instance();
159 m_mwpc = _arichbtgp->getMwpc();
160
161 static int first = 1;
162 if (first) {
163 m_runCurrent = m_runList.begin();
164 first = 0;
165 m_mwpc[0].Print();
166 m_mwpc[1].Print();
167 m_mwpc[2].Print();
168 m_mwpc[3].Print();
169
170 }
171 m_end = 1;
172
173 if (m_runCurrent < m_runList.end()) {
174 if (m_fp) {
175 m_eveList.push_back(m_events);
176 gzclose(m_fp);
177 }
178 m_fp = gzopen((*m_runCurrent).c_str(), "rb");
179 if (m_fp == NULL) {
180 B2INFO("Cannot open " << *m_runCurrent);
181 m_end = 1;
182 } else {
183 B2INFO("File opened " << *m_runCurrent);
184 m_end = 0;
185 }
186 }
187 m_events = 0;
188 }
void Print()
Debug printouts.
std::vector< std::string >::iterator m_runCurrent
current run
std::vector< int > m_eveList
The eventnumbers for each of the runs.
static ARICHBtestGeometryPar * Instance()
Static method to get a reference to the ARICHBtestGeometryPar instance.

◆ beginRun() [2/5]

void beginRun ( void  )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from Module.

Definition at line 89 of file ARICHDigitizerModule.cc.

90 {
91 if (m_simPar->getNBkgHits() > 0) m_bkgLevel = m_simPar->getNBkgHits();
92 }
DBObjPtr< ARICHSimulationPar > m_simPar
simulation parameters from the DB

◆ beginRun() [3/5]

void beginRun ( void  )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from HistoModule.

Definition at line 175 of file ARICHDQMModule.cc.

176 {
177
178 h_chStat->Reset();
179 h_aeroStat->Reset();
180 h_chDigit->Reset();
181 h_chipDigit->Reset();
182 h_hapdDigit->Reset();
183
184 h_chHit->Reset();
185 h_chipHit->Reset();
186 h_hapdHit->Reset();
187 h_mergerHit->Reset();
188 h_bitsPerMergerNorm->Reset();
189 h_bitsPerHapdMerger->Reset();
190
191 h_aerogelHit->Reset();
192 h_bits->Reset();
193 h_bitsPerChannel->Reset();
194 h_hitsPerTrack2D->Reset();
195 h_tracks2D->Reset();
196 h_aerogelHits3D->Reset();
197
198 h_hitsPerEvent->Reset();
199 h_theta->Reset();
200 h_hitsPerTrack->Reset();
201 h_trackPerEvent->Reset();
202 h_flashPerAPD->Reset();
203 h_mirrorThetaPhi->Reset();
204 h_thetaPhi->Reset();
205
206 for (int i = 0; i < 6; i++) {
207 h_secTheta[i]->Reset();
208 h_secHitsPerTrack[i]->Reset();
209 }
210
211 h_ARICHOccAfterInjLer->Reset();
212 h_ARICHEOccAfterInjLer->Reset();
213 h_ARICHOccAfterInjHer->Reset();
214 h_ARICHEOccAfterInjHer->Reset();
215 }
TH1 * h_chipDigit
The number of raw digits in each ASIC chip.
TH2 * h_hitsPerTrack2D
Sum of 2D hit/track map on each position of track.
TH1 * h_chipHit
The number of hits in each ASIC chip.
TH2 * h_bitsPerChannel
Number of bits per channel.
TH1 * h_ARICHEOccAfterInjHer
Histogram for Nr Entries (=Triggrs) for normalization after HER injection.
TH3 * h_aerogelHits3D
3D histogram of hits.
TH1 * h_flashPerAPD
Number of flashes in each APD.
TH1 * h_hitsPerTrack
Average hits/track calculated from h_hits2D and h_track2D.
TH1 * h_trackPerEvent
Number of tracks in ARICH per event (with p>0.5 GeV).
TH1 * h_ARICHOccAfterInjLer
Histogram Ndigits after LER injection.
TH1 * h_chDigit
The number of raw digits in each channel.
TH1 * h_aerogelHit
The number of reconstructed photons in each aerogel tile.
TH1 * h_mergerHit
The number of hits in each Merger Boards.
TH1 * h_theta
Reconstructed Cherenkov angles.
TH2 * h_thetaPhi
Cherenkov theta vs phi for non-mirror-reflected photons.
TH2 * h_bitsPerMergerNorm
The number of hits in each bit in each Merger Board normalised to number of HAPDs and sum(bit1,...
TH1 * h_aeroStat
Status of each aerogel tile.
TH1 * h_ARICHOccAfterInjHer
Histogram Ndigits after HER injection.
TH3 * h_mirrorThetaPhi
Cherenkov theta vs phi for mirror-reflected photons (for each mirror plate).
TH1 * h_hapdDigit
The number of raw digits in each HAPD.
TH1 * h_chHit
The number of hits in each channel.
TH2 * h_bitsPerHapdMerger
The number of hits in each bit in each HAPD sorted by Merger Board.
TH1 * h_chStat
Status of each channel.
TH1 * h_secHitsPerTrack[6]
Detailed average hits/track for each sector.
TH1 * h_hapdHit
The number of hits in each HAPD.
TH1 * h_ARICHEOccAfterInjLer
Histogram for Nr Entries (=Triggrs) for normalization after LER injection.
TH1 * h_secTheta[6]
Detailed view of Cherenkov angle for each sector.
TH1 * h_hitsPerEvent
The number of all hits in each event.
TH2 * h_tracks2D
2D track distribution of whole ARICH.
TH1 * h_bits
Timing bits.

◆ beginRun() [4/5]

void beginRun ( void  )
overridevirtual

Called when entering a new run.

Set run dependent things like run header parameters, alignment, etc.

Reimplemented from HistoModule.

Definition at line 103 of file ARICHRateCalModule.cc.

104 {
105 StoreObjPtr<EventMetaData> evtmetadata;
106 //int expno = evtmetadata->getExperiment();
107 int runno = evtmetadata->getRun();
108 if (runno == 100 && !m_internalmode) {
109 terminate();
110 }
111 }
virtual void terminate() override
Function to terminate module.
Definition: HistoModule.h:46

◆ beginRun() [5/5]

void beginRun ( void  )
overridevirtual

Called when entering a new run.

Reimplemented from Module.

Definition at line 114 of file ARICHReconstructorModule.cc.

115 {
116 m_ana->initialize();
117 }
void initialize()
Read geometry parameters from xml and initialize class members.

◆ cal2byte()

unsigned int cal2byte ( const int *  buf)
inlineprotected

calculate number of lines (2 bytes) in raw Unpacker

Definition at line 107 of file ARICHUnpackerModule.h.

108 {
109 return (calbyte(buf) << 8) | calbyte(buf);
110 }
unsigned int calbyte(const int *buf)
calculate number of bytes in raw Unpacker

◆ calbyte() [1/3]

unsigned int calbyte ( const int *  buf)
inlineprotected

Get calculated byte.

Definition at line 86 of file ARICHRateCalModule.h.

87 {
88 int shift = (3 - m_ibyte % 4) * 8;
89 unsigned int val = 0xff & (buf[m_ibyte / 4] >> shift);
90 m_ibyte++;
91 return val;
92 }

◆ calbyte() [2/3]

unsigned int calbyte ( const int *  buf)
inlineprotected

Read byte with number m_ibyte from the buffer and increase the number by 1.

Parameters
[in]bufBuffer.

Definition at line 90 of file ARICHRawUnpackerModule.h.

91 {
92 int shift = (3 - m_ibyte % 4) * 8;
93 unsigned int val = 0xff & (buf[m_ibyte / 4] >> shift);
94 m_ibyte++;
95 return val;
96 }
unsigned int m_ibyte
Current byte number.

◆ calbyte() [3/3]

unsigned int calbyte ( const int *  buf)
inlineprotected

calculate number of bytes in raw Unpacker

Definition at line 96 of file ARICHUnpackerModule.h.

97 {
98 int shift = (3 - m_ibyte % 4) * 8;
99 unsigned int val = 0xff & (buf[m_ibyte / 4] >> shift);
100 m_ibyte++;
101 return val;
102 }
unsigned int m_ibyte
bye index of raw unpacker

◆ calword() [1/3]

unsigned int calword ( const int *  buf)
inlineprotected

Get calculated word.

Definition at line 94 of file ARICHRateCalModule.h.

95 {
96 return (calbyte(buf) << 24) | (calbyte(buf) << 16)
97 | (calbyte(buf) << 8) | calbyte(buf);
98 }

◆ calword() [2/3]

unsigned int calword ( const int *  buf)
inlineprotected

Read word (4 bytes) from the buffer and increase the byte number m_ibyte by 4.

Parameters
[in]bufBuffer.

Definition at line 98 of file ARICHRawUnpackerModule.h.

99 {
100 return (calbyte(buf) << 24) | (calbyte(buf) << 16)
101 | (calbyte(buf) << 8) | calbyte(buf);
102 }

◆ calword() [3/3]

unsigned int calword ( const int *  buf)
inlineprotected

calculate number of words in raw Unpacker

Definition at line 115 of file ARICHUnpackerModule.h.

116 {
117 return (calbyte(buf) << 24) | (calbyte(buf) << 16)
118 | (calbyte(buf) << 8) | calbyte(buf);
119 }

◆ CherenkovPhoton()

int CherenkovPhoton ( ROOT::Math::XYZVector  r,
ROOT::Math::XYZVector  rh,
ROOT::Math::XYZVector &  rf,
ROOT::Math::XYZVector &  dirf,
double *  refind,
double *  z,
int  n,
int  mirrorID = 0 
)
private

Calculates the direction of photon emission.

Given the Cherenkov photon emission point "r" and its position on detector plane "rh" (hit position) this methods calculates the direction "dirf" in which photon was emitted, under the assumption that it was reflected from "mirrorID"-th mirror plate (mirrorID=-1 for no reflection).

Parameters
[in]rVector of photon emission point.
[in]rhPhoton hit position.
[in]dirfVector of photon emission direction (this is output of method).
[in]rfVector of photon position on aerogel exit.
[in]refindArray of layers refractive indices.
[in]zArray of z coordinates of borders between layers.
[in]nNumber of aerogel layers through which photon passes.
[in]mirrorIDId of mirror from which the photon was reflected (assumption).

Definition at line 253 of file ARICHReconstruction.cc.

256 {
257 //
258 // Description:
259 // The method calculates the direction of the cherenkov photon
260 // and intersection with the aerogel exit point
261 //
262 // Called by: CerenkovAngle
263
264
265 // Arguments:
266 // Input:
267 // dir, r track position
268 // rh photon hit
269
270
271 // Output:
272 // rf aerogel exit from which the photon was emitted
273 // dirf photon direction in aerogel
274 static ROOT::Math::XYZVector norm(0, 0, 1); // detector plane normal vector
275
276 double dwin = m_arichgp->getHAPDGeometry().getWinThickness();
277 double refractiveInd0 = m_arichgp->getHAPDGeometry().getWinRefIndex();
278
279 // iteration is stoped when the difference of photon positions on first aerogel exit
280 // between two iterations is smaller than this value.
281 const double dmin = 0.0000001;
282 const int niter = 100; // maximal number of iterations
283 ROOT::Math::XYZVector dirw;
284 ROOT::Math::XYZVector rh1 = rh - dwin * norm;
285
286 std::vector <ROOT::Math::XYZVector > rf0(n + 2);
287 // rf0[0] .. track point
288 // rf0[1] 1. 1st aerogel exit
289 // rf0[n] n. aerogel exit ...
290 std::vector <ROOT::Math::XYZVector > dirf0(n + 2);
291 // dirf0[0] .. 1st aerogel direction
292 // dirf0[1] .. 2nd aerogel direction
293 // dirf0[n] .. direction after aerogels
294
295 // z[0] .. 1st aerogel exit
296 // z[n-1] .. 2nd aerogel exit
297 // z[n] .. detector position
298 // z[n+1] .. detector + window
299
300 rf0[0] = r;
301 rf0[1] = rf;
302
303 for (int iter = 0; iter < niter; iter++) {
304
305 // direction in the space between aerogels and detector
306 // *************************************
307 if (iter == 0) dirf0[n] = (rh1 - rf0[1]).Unit();
308 else dirf0[n] = (rh1 - rf0[n]).Unit();
309
310 // *************************************
311 // n-layers of aerogel // refractiveInd relative refractive index
312 for (int a = n - 1; a >= 0 ; a--) {
313 double rind = refractiveInd[a] / refractiveInd[a + 1];
314 dirf0[a] = Refraction(dirf0[a + 1], rind);
315 }
316
317 double path = (z[0] - r.Z()) / dirf0[0].Z();
318 double x1 = rf0[1].X();
319 double y1 = rf0[1].Y();
320 for (int a = 0; a < n ; a++) {
321 rf0[a + 1] = rf0[a] + dirf0[a] * path;
322 path = (z[a + 1] - rf0[a + 1].Z()) / dirf0[a + 1].Z();
323 }
324
325 Refraction(dirf0[n], norm, refractiveInd0, dirw);
326
327 // *************************************
328
329 path = dwin / (dirw.Dot(norm));
330 rh1 = rh - dirw * path;
331
332 double d2 = (rf0[1].X() - x1) * (rf0[1].X() - x1) + (rf0[1].Y() - y1) * (rf0[1].Y() - y1);
333
334 if ((d2 < dmin) && (iter)) {
335
336 // if mirror hypothesis check if reflection point lies on mirror plate
337 if (mirrorID) {
338 if (!HitsMirror(rf0[n], dirf0[n], mirrorID)) return -1;
339 }
340
341 rf = rf0[1];
342 dirf = dirf0[0];
343 return iter;
344 }
345 }
346 return -1;
347 }
bool HitsMirror(const ROOT::Math::XYZVector &pos, const ROOT::Math::XYZVector &dir, int mirrorID)
Returns true if photon at position pos with direction dir hits mirror plate with ID mirrorID.

◆ correctEmissionPoint()

void correctEmissionPoint ( int  tileID,
double  r 
)

Correct mean emission point z position.

Definition at line 768 of file ARICHReconstruction.cc.

769 {
770
771 double ang = m_tilePars[tileID - 1][0] + m_tilePars[tileID - 1][1] * r;
772 m_zaero[0] = m_arichgp->getAerogelPlane().getAerogelZPosition() + m_thickness[0] - ang * 50.;
773 m_zaero[1] = m_zaero[0] + m_thickness[1];
774
775 }
double m_tilePars[124][2]
array of tile parameters

◆ deadPalette()

void deadPalette ( )

Set palette for sector dead-chip map.

Definition at line 214 of file hitMapMaker.cc.

215 {
216 static Int_t colors[50];
217 static Bool_t initialized = kFALSE;
218 Double_t Red[3] = { 1.00, 0.00, 0.00};
219 Double_t Green[3] = { 0.00, 0.00, 0.00};
220 Double_t Blue[3] = { 0.00, 1.00, 1.00};
221 Double_t Length[3] = { 0.00, 0.20, 1.00 };
222 if (!initialized) {
223 Int_t FI = TColor::CreateGradientColorTable(3, Length, Red, Green, Blue, 50);
224 for (int i = 0; i < 50; i++) colors[i] = FI + i;
225 initialized = kTRUE;
226 return;
227 }
228 gStyle->SetPalette(50, colors);
229 }

◆ defineHisto() [1/3]

void defineHisto ( )
overridevirtual

Definition of the histograms.

Reimplemented from HistoModule.

Definition at line 61 of file ARICHDQMModule.cc.

62 {
63
64 TDirectory* oldDir = gDirectory;
65 TDirectory* dirARICHDQM = oldDir->mkdir("ARICH");
66 dirARICHDQM->cd();
67
68 //Histograms for analysis and statistics
69
70 h_chStat = new TH1D("chStat", "Status of channels;Channel serial;Status", 420 * 144, -0.5, 420 * 144 - 0.5);
71 h_aeroStat = new TH1D("aeroStat", "Status of aerogels;Aerogel tile serial;Status", 160, -0.5, 160 - 0.5);
72 h_chHit = new TH1D("chHit", "Number of hits in each channel;Channel serial;Hits", 420 * 144, -0.5, 420 * 144 - 0.5);
73 h_chipHit = new TH1D("chipHit", "Number of hits in each chip;Chip serial;Hits", 420 * 4, -0.5, 420 * 4 - 0.5);
74 h_hapdHit = new TH1D("hapdHit", "Number of hits in each HAPD;HAPD serial;Hits", 420, 0.5, 421 - 0.5);
75 h_hapdHitPerEvent = new TH2D("hapdHitPerEvent", "Number of hits in each HAPD per Event;HAPD serial;Hits/event", 420, 0.5, 420 + 0.5,
76 144, -0.5, 143.5);
77 h_trackPerEvent = new TH1D("trackPerEvent", "Number of tracks in ARICH per event; # of tracks;Events", 6, -0.5, 5.5);
78
79 h_mergerHit = new TH1D("mergerHit", "Number of hits in each merger board;MB ID;Hits", 72, 0.5, 72 + 0.5);
80 h_bitsPerMergerNorm = new TH2D("bitsPerMergerNorm", "Normalised number of hits in each bit in each Merger;Bit;MB ID;Hits", 5,
81 -1 - 0.5,
82 4 - 0.5, 72, 0.5, 72 + 0.5); // copy of h_bits, normalised to number of connected Hapds and to sum(bit1, bit2)
83 h_bitsPerHapdMerger = new TH2D("bitsPerHapdMerger",
84 "Number of hits in each bit in each Hapd sorted by mergers;Bit;HAPD unsorted;Hits", 5, -1 - 0.5,
85 4 - 0.5, 432, 1, 432);
86
87 h_aerogelHit = new TH1D("aerogelHit", "Number track associated hits in each aerogel tile;Aerogel slot ID;Hits", 125, -0.5,
88 125 - 0.5);
89 h_bits = new TH1D("bits", "Number of hits in each bit;Bit;Hits", 5, -1 - 0.5,
90 4 - 0.5); //Bin at -1 is added to set minimum 0 without SetMinimum(0) due to bugs in jsroot on DQM server.
91 h_bitsPerChannel = new TH2D("bitsPerChannel", "Number of hits in each bit in each chanenel;Bit;channel #;Hits", 4, - 0.5,
92 4 - 0.5, 420 * 144, -0.5, 420 * 144 - 0.5); // copy of h_bits
93 h_hitsPerTrack2D = new TH2D("hitsPerTrack2D", "2D distribution of track associated hits;X[cm];Y[cm];Hits", 230, -115, 115, 230,
94 -115, 115);
95 h_tracks2D = new TH2D("tracks2D", "Distribution track positions;X[cm];Y[cm];Tracks", 230, -115, 115, 230, -115, 115);
96
97 h_hitsPerEvent = new TH1D("hitsPerEvent", "Number of hit per event;Number of hits;Events", 150, -0.5, 150 - 0.5);
98 h_theta = new TH1D("theta", "Cherenkov angle distribution;Angle [rad];Events", 60, 0, M_PI / 6);
99 h_hitsPerTrack = new TH1D("hitsPerTrack", "Number of hit per track;Number of hits;Tracks", 150, -0.5, 150 - 0.5);
100
101 for (int i = 0; i < 6; i++) {
102 h_secTheta[i] = new TH1D(Form("thetaSec%d", i + 1), Form("Cherenkov angle distribution in sector %d;Angle [rad];Events", i + 1),
103 60, 0, M_PI / 6);
104 h_secHitsPerTrack[i] = new TH1D(Form("hitsPerTrackSec%d", i + 1),
105 Form("Number of hit per track in sector %d;Number of hits;Tracks", i + 1), 150, -0.5, 150 - 0.5);
106 h_secHapdHit[i] = new TH1D(Form("hapdHit%d", i + 1), Form("Number of hits in each HAPD in sector %d;HAPD serial;Hits", i + 1), 70,
107 0.5, 71 - 0.5);
108 }
109
110 h_chDigit = new TH1D("chDigit", "Number of raw digits in each channel;Channel serial;Hits", 420 * 144, -0.5, 420 * 144 - 0.5);
111 h_chipDigit = new TH1D("chipDigit", "Number of raw digits in each chip;Chip serial;Hits", 420 * 4, -0.5, 420 * 4 - 0.5);
112 h_hapdDigit = new TH1D("hapdDigit", "Number of raw digits in each HAPD;HAPD serial;Hits", 420, 0.5, 421 - 0.5);
113
114 h_aerogelHits3D = new TH3D("aerogelHits3D", "Number of track associated hits for each aerogel tile; #phi section; r section", 125,
115 -0.5, 124.5, 20, 0, 20, 20, 0, 20);
116 h_mirrorThetaPhi = new TH3D("mirrorThetaPhi",
117 "Cherenkov theta vs Cherenkov phi for mirror reflected photons; mirroID; #phi_{c} [rad]; #theta_{c} [rad]", 18, 0.5, 18.5, 100,
118 -M_PI, M_PI, 100, 0, 0.5);
119 h_thetaPhi = new TH2D("thetaPhi", "Cherenkov theta vs phi;#phi [rad];#theta_{c} [rad]", 100, -M_PI, M_PI, 100, 0., 0.5);
120
121 h_flashPerAPD = new TH1D("flashPerAPD", "Number of flashes per APD; APD serial; number of flash", 420 * 4, -0.5, 420 * 4 - 0.5);
122
123 h_ARICHOccAfterInjLer = new TH1F("ARICHOccInjLER", " ARICHOccInjLER /Time;Time in #mus;Nhits/Time (#mus bins)", 4000, 0, 20000);
124 h_ARICHOccAfterInjHer = new TH1F("ARICHOccInjHER", " ARICHOccInjHER /Time;Time in #mus;Nhits/Time (#mus bins)", 4000, 0, 20000);
125 h_ARICHEOccAfterInjLer = new TH1F("ARICHEOccInjLER", "ARICHEOccInjLER/Time;Time in #mus;Triggers/Time (#mus bins)", 4000, 0, 20000);
126 h_ARICHEOccAfterInjHer = new TH1F("ARICHEOccInjHER", "ARICHEOccInjHER/Time;Time in #mus;Triggers/Time (#mus bins)", 4000, 0, 20000);
127
128 //Set the minimum to 0
129 h_chDigit->SetMinimum(0);
130 h_chipDigit->SetMinimum(0);
131 h_hapdDigit->SetMinimum(0);
132 h_chHit->SetMinimum(0);
133 h_chipHit->SetMinimum(0);
134 h_hapdHit->SetMinimum(0);
135 h_mergerHit->SetMinimum(0);
136 h_bitsPerMergerNorm->SetMinimum(0);
137 h_bitsPerHapdMerger->SetMinimum(0);
138 h_aerogelHit->SetMinimum(0);
139 h_bits->SetMinimum(0);
140 h_bitsPerChannel->SetMinimum(0);
141 h_hitsPerTrack2D->SetMinimum(0);
142 h_tracks2D->SetMinimum(0);
143 h_flashPerAPD->SetMinimum(0);
144 h_hitsPerEvent->SetMinimum(0);
145 h_theta->SetMinimum(0);
146 h_hitsPerTrack->SetMinimum(0);
147 h_ARICHOccAfterInjLer->SetMinimum(0);
148 h_ARICHEOccAfterInjLer->SetMinimum(0);
149 h_ARICHOccAfterInjHer->SetMinimum(0);
150 h_ARICHEOccAfterInjHer->SetMinimum(0);
151
152 for (int i = 0; i < 6; i++) {
153 h_secTheta[i]->SetMinimum(0);
154 h_secHitsPerTrack[i]->SetMinimum(0);
155 }
156
157 oldDir->cd();
158 }
TH2 * h_hapdHitPerEvent
Number of hits in each HAPD per event.
TH1 * h_secHapdHit[6]
The number of hits in each HAPDs of each sector.

◆ defineHisto() [2/3]

void defineHisto ( )
overridevirtual

Definition of the histograms.

Reimplemented from HistoModule.

Definition at line 64 of file ARICHRateCalModule.cc.

65 {
66 /*
67 if (m_daqdb.size() > 0) {
68 ConfigFile config("slowcontrol");
69 PostgreSQLInterface db(config.get("database.host"),
70 config.get("database.dbname"),
71 config.get("database.user"),
72 config.get("database.password"),
73 config.getInt("database.port"));
74 DBObject obj = DBObjectLoader::load(db, "arich_th",
75 StringUtil::replace(m_daqdb, ".", ":"));
76 obj.print();
77 m_dth = obj.getFloat("dth");
78 m_th0 = obj.getFloat("th0");
79 m_nrun = obj.getInt("nth");
80 db.close();
81 }
82 */
83
84 if (m_dth == 0) {
85 B2WARNING("dth is set to 0");
86 }
87 for (int i = 0; i < 100; i++) {
88 h_rate2D[i] = new TH2F(Form("h_rate2D_%d", i), Form("MRG#%d;Channel ID; Vth [mV]", i), 144 * 6, -0.5, -0.5 + 144 * 6,
89 m_nrun, (m_th0 - 0.5 * m_dth) * 1000, (m_th0 + (m_nrun - 0.5)*m_dth) * 1000);
90 }
91 }
TH2 * h_rate2D[100]
2D histogram

◆ defineHisto() [3/3]

void defineHisto ( )
overridevirtual

Definition of the histograms.

Reimplemented from HistoModule.

Definition at line 45 of file ARICHRawUnpackerModule.cc.

46 {
47 h_rate_a_all = new TH1F("h_rate_a_all", ";Channel ID", 144 * 6, 0, 144 * 6); //yone
48 h_rate_b_all = new TH1F("h_rate_b_all", ";Channel ID", 144 * 6, 0, 144 * 6); //yone
49 h_rate_c_all = new TH1F("h_rate_c_all", ";Channel ID", 144 * 6, 0, 144 * 6); //yone
50 h_rate_d_all = new TH1F("h_rate_d_all", ";Channel ID", 144 * 6, 0, 144 * 6); //yone
51 }
TH1 * h_rate_d_all
Rate histogram (unused).
TH1 * h_rate_b_all
Rate histogram (unused).
TH1 * h_rate_a_all
Rate histogram (unused).
TH1 * h_rate_c_all
Rate histogram (unused).

◆ endRun() [1/2]

void endRun ( void  )
overridevirtual

Is called after processing the last event of a run.

Good e.g. for storing stuff, that you want to aggregate over one run.

Reimplemented from Module.

Definition at line 555 of file arichBtestModule.cc.

556 {
557 B2INFO(" arichBtestModule: End Run !!!");
558
559 m_file->Write();
560 m_file->Close();
561
562 if (m_fp) {
563 gzclose(m_fp);
564 m_eveList.push_back(m_events);
565 }
566 }

◆ endRun() [2/2]

void endRun ( void  )
overridevirtual

End-of-run action.

Save run-related stuff, such as statistics.

Reimplemented from HistoModule.

Definition at line 397 of file ARICHDQMModule.cc.

398 {
399 if (h_theta->GetEntries() < 200) return;
400 TF1* f1 = new TF1("arichFitFunc", "gaus(0)+pol1(3)", 0.25, 0.4);
401 f1->SetParameters(0.8 * h_theta->GetMaximum(), 0.323, 0.016, 0, 0);
402 f1->SetParName(0, "C");
403 f1->SetParName(1, "mean");
404 f1->SetParName(2, "sigma");
405 f1->SetParName(3, "p0");
406 f1->SetParName(4, "p1");
407 h_theta->Fit(f1, "R");
408
409 //Normalise bins in histogram bitsPerMergerNorm
410 for (int mergerID = 1; mergerID < 73; ++mergerID) {
411 double NHapd = 0;
412 for (int febSlot = 1; febSlot < 7; ++febSlot) {
413 if (m_arichMergerMap->getModuleID(mergerID, febSlot) > 0) NHapd++;
414 }
415
416 double bin_value[5];
417 for (int i = 1; i <= 5; ++i) {
418 // loop over bits and save values
419 bin_value[i - 1] = h_bitsPerMergerNorm->GetBinContent(i, mergerID);
420 }
421
422 for (int i = 1; i <= 5; ++i) {
423 // loop over bits again and set bin content
424 h_bitsPerMergerNorm->SetBinContent(i, mergerID,
425 bin_value[i - 1] / (bin_value[3] + bin_value[2]) / NHapd); // normalise with sum of bit1 and bit2, and number of connected HAPDs
426 }
427 }
428
429
430 }
DBObjPtr< ARICHMergerMapping > m_arichMergerMap
ARICH merger mapping payload.

◆ event() [1/12]

void event ( void  )
overridevirtual

Running over all events.

Function is called for each evRunning over all events This means, this function is called very often, and good performance of the code is of strong interest.

Reimplemented from Module.

Definition at line 466 of file arichBtestModule.cc.

467 {
468
469
470
471
472
473 if (!m_fp) return;
474 unsigned int hdr[2];
475 EventRec rec;
476 BeginRec beginrec;
477 BeginRec endrec;
478 static char msg[1024];
479 int type;
480
481 const int sint = sizeof(unsigned int);
482 do {
483 if (gzread(m_fp, hdr, sint * 2) != 2 * sint && m_end) {
484 B2INFO("[" << m_events << "] End of file: " << *m_runCurrent);
485 ++m_runCurrent;
486 if (m_runCurrent == m_runList.end()) {
487 StoreObjPtr<EventMetaData> eventMetaDataPtr;
488 eventMetaDataPtr->setEndOfData();
489 return;
490 }
491 beginRun();
492 }
493
494 } while (m_end && m_runCurrent != m_runList.end());
495 if (m_events % 1000 == 0) {
496 time_t m_time;
497 time(&m_time);
498 B2INFO("neve= [" << m_events << "] in " << (double)(m_time - m_timestart) / 60. << " min (" << int(
499 m_time - m_timestart) << "s) from " << *m_runCurrent);
500
501 }
502 m_events++;
503
504 type = hdr[0];
505 // len = hdr[1];
506
507 gzseek(m_fp, 2 * sizeof(unsigned int), SEEK_CUR);
508 switch (type) {
509 case BEGIN_RECORD_TYPE: {
510 gzread(m_fp, &beginrec, sizeof(beginrec));
511 time_t t = beginrec.time;
512 sprintf(msg, "BeginRec run %u time %s", beginrec.runno, ctime(&t));
513 B2INFO(msg);
514 break;
515 }
516 case END_RECORD_TYPE: {
517 gzread(m_fp, &endrec, sizeof(endrec));
518 time_t t = endrec.time;
519 sprintf(msg, "EndRec run %u time %s", endrec.runno, ctime(&t));
520 B2INFO(msg);
521 break;
522 }
523 case EVENT_RECORD_TYPE: {
524 gzread(m_fp, &rec, sizeof(rec));
525 int print = !(rec.evtno % 10000);
526 time_t t = rec.time;
527 if (print) {
528 sprintf(msg, "EventRec run %u evt %u mstime %u, time %s", rec.runno, rec.evtno, rec.mstime, ctime(&t));
529 B2INFO(msg);
530 }
531 /* if you just want to jump to the end */
532 int pos = gztell(m_fp);
533 /* try to read inside data */
534 int buflen = rec.len - sizeof(rec) / sizeof(int);
535
536 //if (print) printf ("%d: buflen\n",buflen);
537 int n[5] = { 0 };
538 int i(0), j(0);
539 while (i < buflen && j < 5) {
540 n[j] = readdata(m_fp, j, print);
541 // n[j] = skipdata( m_fp );
542 i += n[j];
543 j++;
544 }
545 if (gzseek(m_fp, pos + buflen * sizeof(unsigned int), SEEK_SET) < 0) B2ERROR("gzseek returns -1 ");
546 break;
547 }
548 default:
549 B2ERROR("IO error unknown record type " << type);
550 break;
551 }
552 if (gzeof(m_fp)) m_end = 1;
553 }
virtual void beginRun() override
Called when entering a new run.
int readdata(gzFile fp, int rec_id, int print)
Read the data from the file (can be compressed)
Begin record structure for the beamtest data.
unsigned int runno
Run number.
unsigned int time
Timestamp of the run.
Event record structure for the beamtest data.

◆ event() [2/12]

void event ( void  )
overridevirtual

Event processor.

Convert ARICHSimHits of the event to arichDigits.

Reimplemented from Module.

Definition at line 94 of file ARICHDigitizerModule.cc.

95 {
96
97 //---------------------------------------------------------------------
98 // Convert SimHits one by one to digitizer hits.
99 //---------------------------------------------------------------------
100
101 // We try to include the effect of opposite-polarity crosstalk among channels
102 // on each chip, which depend on number of p.e. on chip
103
104 std::map<std::pair<int, int>, int> photoElectrons; // this contains number of photoelectrons falling on each channel
105 std::map<std::pair<int, int>, int> chipHits; // this contains number of photoelectrons on each chip
106
107 // Loop over all photon hits
108 for (const ARICHSimHit& aSimHit : m_ARICHSimHits) {
109
110 // check for time window
111 double time = aSimHit.getGlobalTime() - m_timeWindowStart;
112
113 if (time < 0 || time > m_timeWindow) continue;
114
115 ROOT::Math::XYVector locpos = aSimHit.getLocalPosition();
116
117 // Get id of module
118 int moduleID = aSimHit.getModuleID();
119
120 if (m_bdistort) magFieldDistorsion(locpos, moduleID);
121
122 // skip if not active
123 if (!m_modInfo->isActive(moduleID)) continue;
124
125 // Get id number of hit channel
126 int chX, chY;
127 m_geoPar->getHAPDGeometry().getXYChannel(locpos.X(), locpos.Y(), chX, chY);
128
129 if (chX < 0 && chY < 0) continue;
130
131 int asicChannel = m_chnMap->getAsicFromXY(chX, chY);
132
133
134 // eliminate un-active channels
135 if (asicChannel < 0 || !m_chnMask->isActive(moduleID, asicChannel)) continue;
136
137 // apply channel dependent QE scale factor
138 //double qe_scale = 0.27 / m_maxQE;
139 //double qe_scale = m_modInfo->getChannelQE(moduleID, asicChannel) * m_simPar->getColEff() / m_maxQE; // eventually move collection efficiency to here!
140 double qe_scale = m_modInfo->getChannelQE(moduleID, asicChannel) / m_maxQE;
141
142 if (qe_scale > 1.) B2ERROR("Channel QE is higher than QE applied in SensitiveDetector");
143 if (gRandom->Uniform(1.) > qe_scale) continue;
144
145 // photon was converted to photoelectron
146 chipHits[std::make_pair(moduleID, asicChannel / 36)] += 1;
147 photoElectrons[std::make_pair(moduleID, asicChannel)] += 1;
148
149 }
150
151 // loop over produced photoelectrons. Apply suppression due to the reverse polarization crosstalk
152 // among channels on the same chip, and produce hit bitmap (4 bits).
153
154 for (std::map<std::pair<int, int>, int>::iterator it = photoElectrons.begin(); it != photoElectrons.end(); ++it) {
155
156 std::pair<int, int> modch = it->first;
157 double npe = double(it->second);
158
159 // reduce efficiency
160 npe /= (1.0 + m_simPar->getChipNegativeCrosstalk() * (double(chipHits[std::make_pair(modch.first, modch.second / 36)]) - 1.0));
161 if (npe < 1.0 && gRandom->Uniform(1) > npe) continue;
162
163 // Make hit bitmap (depends on number of p.e. on channel). For now bitmap is 0001 for single p.e., 0011 for 2 p.e., ...
164 // More proper implementation is to be done ...
165 uint8_t bitmap = 0;
166 for (int i = 0; i < npe; i++) {
167 bitmap |= 1 << i;
168 if (i == 3) break;
169 }
170
171 // make new digit!
172 m_ARICHDigits.appendNew(modch.first, modch.second, bitmap);
173
174 }
175
176 //--- if background not overlayed add electronic noise hits
177 if (m_bgOverlay) return;
178 uint8_t bitmap = 1;
179 unsigned nSlots = m_geoPar->getDetectorPlane().getNSlots();
180 for (unsigned id = 1; id < nSlots + 1; id++) {
181 if (!m_modInfo->isActive(id)) continue;
182 int nbkg = gRandom->Poisson(m_bkgLevel);
183 for (int i = 0; i < nbkg; i++) {
184 m_ARICHDigits.appendNew(id, gRandom->Integer(144), bitmap);
185 }
186 }
187
188 }
StoreArray< ARICHSimHit > m_ARICHSimHits
StoreArray containing the ARICHSimHits.
DBObjPtr< ARICHModulesInfo > m_modInfo
information on installed modules from the DB (QEs etc.)
DBObjPtr< ARICHGeometryConfig > m_geoPar
geometry configuration parameters from the DB
bool m_bgOverlay
True if BG overlay detected.
StoreArray< ARICHDigit > m_ARICHDigits
StoreArray containing the ARICHDigits.
DBObjPtr< ARICHChannelMapping > m_chnMap
HAPD (x,y) to asic channel mapping.
void magFieldDistorsion(ROOT::Math::XYVector &hit, int copyno)
Apply correction to hit position due to non-perpendicular component of magnetic field.

◆ event() [3/12]

void event ( void  )
overridevirtual

Event processor.

Reimplemented from HistoModule.

Definition at line 217 of file ARICHDQMModule.cc.

218 {
219 const ARICHGeoDetectorPlane& arichGeoDec = m_arichGeoConfig->getDetectorPlane();
220 const ARICHGeoAerogelPlane& arichGeoAero = m_arichGeoConfig->getAerogelPlane();
221
223
224 if (m_arichHits.getEntries() < m_minHits || m_arichHits.getEntries() > m_maxHits) { setReturnValue(0); return;}
225
226 if (!m_arichLikelihoods.getEntries() && m_arichEvents) { setReturnValue(0); return;}
227
228 std::vector<int> apds(420 * 4, 0);
229 for (const auto& digit : m_arichDigits) {
230 uint8_t bits = digit.getBitmap();
231 int moduleID = digit.getModuleID();
232 int channelID = digit.getChannelID();
233 int mergerID = m_arichMergerMap->getMergerID(moduleID);
234 int febSlot = m_arichMergerMap->getFEBSlot(moduleID);
235 unsigned binID = (mergerID - 1) * N_FEB2MERGER + (febSlot);
236
237 for (int i = 0; i < 8; i++) {
238 if ((bits & (1 << i)) && !(bits & ~(1 << i))) {
239 h_bits->Fill(i);
240 h_bitsPerChannel->Fill(i, (moduleID - 1) * 144 + channelID);
241 h_bitsPerMergerNorm->Fill(i, mergerID);
242 h_bitsPerHapdMerger->Fill(i, binID);
243 } else if (!bits) {
244 h_bits->Fill(8);
245 h_bitsPerChannel->Fill(8, (moduleID - 1) * 144 + channelID);
246 h_bitsPerMergerNorm->Fill(8, mergerID);
247 h_bitsPerHapdMerger->Fill(8, binID);
248 }
249 }
250
251 // fill occupancy histograms for raw data
252 h_chDigit ->Fill((moduleID - 1) * 144 + channelID);
253 int chip = (moduleID - 1) * 4 + channelID / 36;
254 h_chipDigit->Fill(chip);
255 apds[chip] += 1;
256 h_hapdDigit->Fill(moduleID);
257 }
258
259 int iapd = 0;
260 for (auto apd : apds) { if (apd > 20) h_flashPerAPD->Fill(iapd); iapd++;}
261
262 std::vector<int> hpd(420, 0);
263 int nHit = 0;
264
265 for (int i = 0; i < m_arichHits.getEntries(); i++) {
266
267 int moduleID = m_arichHits[i]->getModule();
268 int channelID = m_arichHits[i]->getChannel();
269 h_chHit->Fill((moduleID - 1) * 144 + channelID);
270 hpd[moduleID - 1]++;
271 h_chipHit->Fill((moduleID - 1) * 4 + channelID / 36);
272 h_hapdHit->Fill(moduleID);
273 if (moduleID > 420) B2INFO("Invalid hapd number " << LogVar("hapd ID", moduleID));
274
275 for (int j = 1; j <= 7; j++) {
276 int ringStart = (j - 1) * (84 + (j - 2) * 6) / 2 + 1; // The smallest module ID in each ring
277 int ringEnd = j * (84 + (j - 1) * 6) / 2; // The biggest module ID in each ring
278 if (ringStart <= moduleID && moduleID <= ringEnd) {
279 h_secHapdHit[(moduleID - ringStart) / (6 + j)]->Fill((moduleID - ringStart) % (6 + j) + 1 + (ringStart - 1) / 6);
280 }
281 }
282
283 int mergerID = m_arichMergerMap->getMergerID(moduleID);
284 h_mergerHit->Fill(mergerID);
285 nHit++;
286 }
287
288 h_hitsPerEvent->Fill(nHit);
289 int mmid = 1;
290 for (auto hh : hpd) { h_hapdHitPerEvent->Fill(mmid, hh); mmid++;}
291
292 int ntrk = 0;
293 for (const auto& arichTrack : m_arichTracks) {
294
295
296 //Momentum limits are applied
297 //if (arichTrack.getPhotons().size() == 0) continue;
298 if (arichTrack.getMomentum() > 0.5) ntrk++; // count tracks with momentum larger than 0.5 GeV
299 if (arichTrack.getMomentum() < m_momDnLim || arichTrack.getMomentum() > m_momUpLim) continue;
300
301 ROOT::Math::XYZVector recPos = arichTrack.getPosition();
302 int trSector = 0;
303 double dPhi = 0;
304 if (recPos.Phi() >= 0) {
305 dPhi = recPos.Phi();
306 } else {
307 dPhi = 2 * M_PI + recPos.Phi();
308 }
309 while (dPhi > M_PI / 3 && trSector < 5) {
310 dPhi -= M_PI / 3;
311 trSector++;
312 }
313 double trR = recPos.Rho();
314 double trPhi = 0;
315 if (recPos.Phi() >= 0) {
316 trPhi = recPos.Phi();
317 } else {
318 trPhi = 2 * M_PI + recPos.Phi();
319 }
320
321 int iRing = 0;
322 int iAzimuth = 0;
323 while (arichGeoAero.getRingRadius(iRing + 1) < trR && iRing < 4) {
324 iRing++;
325 }
326 if (iRing == 0) continue;
327 while (arichGeoAero.getRingDPhi(iRing) * (iAzimuth + 1) < trPhi) {
328 iAzimuth++;
329 }
330
331 h_tracks2D->Fill(recPos.X(), recPos.Y());
332
333 std::vector<ARICHPhoton> photons = arichTrack.getPhotons();
334 for (auto& photon : photons) {
335 if (photon.getMirror() == 0) {
336 if (trR < 93.) {
337 h_thetaPhi->Fill(photon.getPhiCer(), photon.getThetaCer());
338 h_theta->Fill(photon.getThetaCer());
339 }
340 int hitSector = 0;
341 double hitPhi = arichGeoDec.getSlotPhi(m_arichHits[photon.getHitID()]->getModule());
342 if (hitPhi < 0) hitPhi += 2 * M_PI;
343 while (hitPhi > M_PI / 3 && hitSector < 5) {
344 hitPhi -= M_PI / 3;
345 hitSector++;
346 }
347 h_secTheta[hitSector]->Fill(photon.getThetaCer());
348 } else {
349 if (trR > 95.) h_mirrorThetaPhi->Fill(photon.getMirror(), photon.getPhiCer(), photon.getThetaCer());
350 }
351 }
352
353 //Get ARICHLikelihood related to the ARICHTrack
354 const ExtHit* extHit = arichTrack.getRelated<ExtHit>();
355 const Track* mdstTrack = NULL;
356 if (extHit) mdstTrack = extHit->getRelated<Track>();
357 const ARICHLikelihood* lkh = NULL;
358 if (mdstTrack) lkh = mdstTrack->getRelated<ARICHLikelihood>();
359 else lkh = arichTrack.getRelated<ARICHLikelihood>();
360
361 if (lkh) {
362 if (!lkh->getFlag()) continue; //Fill only when the number of expected photons is more than 0.
363 double nphoton = lkh->getDetPhot();
364 h_hitsPerTrack->Fill(nphoton);
365 h_secHitsPerTrack[trSector]->Fill(nphoton);
366 h_hitsPerTrack2D->Fill(recPos.X(), recPos.Y(), nphoton);
367 int aeroID = arichGeoAero.getAerogelTileID(recPos.X(), recPos.Y());
368 h_aerogelHits3D->Fill(aeroID, (trPhi - arichGeoAero.getRingDPhi(iRing)*iAzimuth) / (arichGeoAero.getRingDPhi(iRing) / 20),
369 (trR - arichGeoAero.getRingRadius(iRing)) / ((arichGeoAero.getRingRadius(iRing + 1) - arichGeoAero.getRingRadius(iRing)) / 20),
370 nphoton);
371 h_aerogelHit->Fill(aeroID, nphoton);
372 }
373 }
374
375 h_trackPerEvent->Fill(ntrk);
376
377 for (auto& it : m_rawFTSW) {
378 B2DEBUG(29, "TTD FTSW : " << std::hex << it.GetTTUtime(0) << " " << it.GetTTCtime(0) << " EvtNr " << it.GetEveNo(0) << " Type " <<
379 (it.GetTTCtimeTRGType(0) & 0xF) << " TimeSincePrev " << it.GetTimeSincePrevTrigger(0) << " TimeSinceInj " <<
380 it.GetTimeSinceLastInjection(0) << " IsHER " << it.GetIsHER(0) << " Bunch " << it.GetBunchNumber(0));
381 auto difference = it.GetTimeSinceLastInjection(0);
382 if (difference != 0x7FFFFFFF) {
383 unsigned int nentries = m_arichDigits.getEntries();
384 float diff2 = difference / 127.; // 127MHz clock ticks to us, inexact rounding
385 if (it.GetIsHER(0)) {
386 h_ARICHOccAfterInjHer->Fill(diff2, nentries);
387 h_ARICHEOccAfterInjHer->Fill(diff2);
388 } else {
389 h_ARICHOccAfterInjLer->Fill(diff2, nentries);
390 h_ARICHEOccAfterInjLer->Fill(diff2);
391 }
392 }
393 }
394
395 }
StoreArray< ARICHHit > m_arichHits
ARICHHits StoreArray.
StoreArray< ARICHDigit > m_arichDigits
ARICHDigits StoreArray.
StoreArray< ARICHTrack > m_arichTracks
ARICHTracks StoreArray.
StoreArray< RawFTSW > m_rawFTSW
Input array for DAQ Status.
StoreArray< ARICHLikelihood > m_arichLikelihoods
ARICHLikelihoods StoreArray.
DBObjPtr< ARICHGeometryConfig > m_arichGeoConfig
ARICH Geometry configuration payload.
void setReturnValue(int value)
Sets the return value for this module as integer.
Definition: Module.cc:220
Class to store variables with their name which were sent to the logging service.

◆ event() [4/12]

void event ( void  )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 69 of file ARICHFillHitsModule.cc.

70 {
71 StoreObjPtr<EventMetaData> evtMetaData;
72
73 StoreArray<ARICHDigit> digits;
74 StoreArray<ARICHHit> arichHits;
75
76 // calculate number of hits on each apd and on each hapd
77 std::vector<uint8_t> apdHits(420 * 4, 0);
78 std::vector<uint8_t> hapdHits(420, 0);
79 for (const auto& digit : digits) {
80 uint8_t bits = digit.getBitmap();
81 if (!(bits & m_bitMask)) continue;
82
83 int moduleID = digit.getModuleID();
84 if (moduleID > 420 || moduleID < 1) continue;
85 moduleID--;
86 int channelID = digit.getChannelID();
87 if (channelID > 143 || channelID < 0) continue;
88 int chipID = moduleID * 4 + channelID / 36;
89 apdHits[chipID]++;
90 hapdHits[moduleID]++;
91 }
92
93 if (!m_fillall) {
94 for (const auto& digit : digits) {
95 int asicCh = digit.getChannelID();
96 int modID = digit.getModuleID();
97 if (modID > 420 || modID < 1) continue;
98 if (asicCh > 143 || asicCh < 0) continue;
99 uint8_t hitBitmap = digit.getBitmap();
100 if (!(hitBitmap & m_bitMask)) continue;
101
102 // remove hot and dead channels
103 if (!m_chnMask->isActive(modID, asicCh)) continue;
104
105 int chipID = (modID - 1) * 4 + asicCh / 36;
106
107 if (apdHits[chipID] > m_maxApdHits) continue;
108 if (hapdHits[modID - 1] > m_maxHapdHits) continue;
109
110
111 int xCh, yCh;
112 if (not m_chnMap->getXYFromAsic(asicCh, xCh, yCh)) {
113 B2ERROR("Invalid ARICH hit! This hit will be ignored.");
114 continue;
115 }
116
117 ROOT::Math::XYVector hitpos2D = m_geoPar->getChannelPosition(modID, xCh, yCh);
118 ROOT::Math::XYZVector hitpos3D(hitpos2D.X(), hitpos2D.Y(),
119 m_geoPar->getDetectorZPosition() + m_geoPar->getHAPDGeometry().getWinThickness());
120 hitpos3D = m_geoPar->getMasterVolume().pointToGlobal(hitpos3D);
121
122 if (m_bcorrect) magFieldCorrection(hitpos3D);
123 ARICHHit* hh = arichHits.appendNew(hitpos3D, modID, asicCh);
124 hh->addRelationTo(&digit);
125 }
126 } else {
127 for (int imod = 1; imod < 421; imod++) {
128 for (int ichn = 0; ichn < 144; ichn++) {
129
130 // remove hot and dead channels
131 if (!m_chnMask->isActive(imod, ichn)) continue;
132 int chipID = (imod - 1) * 4 + ichn / 36;
133
134 if (apdHits[chipID] > m_maxApdHits) continue;
135 if (hapdHits[imod - 1] > m_maxHapdHits) continue;
136
137 int xCh, yCh;
138 if (not m_chnMap->getXYFromAsic(ichn, xCh, yCh)) {
139 B2ERROR("Invalid ARICH hit! This hit will be ignored.");
140 continue;
141 }
142
143 ROOT::Math::XYVector hitpos2D = m_geoPar->getChannelPosition(imod, xCh, yCh);
144 ROOT::Math::XYZVector hitpos3D(hitpos2D.X(), hitpos2D.Y(),
145 m_geoPar->getDetectorZPosition() + m_geoPar->getHAPDGeometry().getWinThickness());
146 hitpos3D = m_geoPar->getMasterVolume().pointToGlobal(hitpos3D);
147 if (m_bcorrect) magFieldCorrection(hitpos3D);
148 arichHits.appendNew(hitpos3D, imod, ichn);
149 }
150 }
151 }
152
153 }
DBObjPtr< ARICHGeometryConfig > m_geoPar
geometry configuration parameters from the DB
DBObjPtr< ARICHChannelMapping > m_chnMap
(x,y) to asic channel mapping
DBObjPtr< ARICHChannelMask > m_chnMask
list of dead channels from the DB
void magFieldCorrection(ROOT::Math::XYZVector &hitpos)
Corrects hit position for distorsion due to non-perpendicular magnetic field component.

◆ event() [5/12]

void event ( void  )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 64 of file ARICHMCParticlesModule.cc.

65 {
66 const Const::EDetector arich = Const::EDetector::ARICH; // arich
67 const Const::ChargedStable particleHypothesis = Const::pion;
68 const int pdgCode = abs(particleHypothesis.getPDGCode());
69
70 for (int itrk = 0; itrk < m_tracks.getEntries(); ++itrk) {
71
72 const Track* track = m_tracks[itrk];
73 const TrackFitResult* fitResult = track->getTrackFitResultWithClosestMass(particleHypothesis);
74 if (!fitResult) {
75 B2ERROR("No TrackFitResult for " << particleHypothesis.getPDGCode());
76 continue;
77 }
78
79 const MCParticle* particle = track->getRelated<MCParticle>();
80 if (!particle) continue;
81
82 RelationVector<ExtHit> extHits = DataStore::getRelationsWithObj<ExtHit>(track);
83
84 for (unsigned i = 0; i < extHits.size(); i++) {
85 const ExtHit* extHit = extHits[i];
86 if (abs(extHit->getPdgCode()) != pdgCode or
87 extHit->getDetectorID() != arich or
88 extHit->getStatus() != EXT_EXIT or // particles registered at the EXIT of the Al plate
89 extHit->getMomentum().Z() < 0.0) continue; // track passes in backward
90 if (extHit->getCopyID() == 6789) {
91 //MCParticle arichMCP = *particle;
92 MCParticle* arichP = m_arichMCPs.appendNew(*particle);
93 track->addRelationTo(arichP);
94
95 }
96
97 }
98 }
99
100 }
StoreArray< MCParticle > m_arichMCPs
Required input array of MCParticles.
StoreArray< Track > m_tracks
Required input array of Tracks.
EDetector
Enum for identifying the detector components (detector and subdetector).
Definition: Const.h:42
static const ChargedStable pion
charged pion particle
Definition: Const.h:661
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246

◆ event() [6/12]

void event ( void  )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 138 of file ARICHNtupleModule.cc.

139 {
140
141 StoreObjPtr<EventMetaData> evtMetaData;
142 StoreArray<ARICHHit> arichHits;
143
144 if (!m_arichTracks.isValid()) return;
145
146#ifdef ALIGNMENT_USING_BHABHA
147 double E_tot = 0.;
148 StoreArray<ECLCluster> eclClusters;
149 for (const auto& trk : m_tracks) {
150 const ECLCluster* eclTrack = trk.getRelated<ECLCluster>();
151 if (eclTrack) {
152 if (eclTrack->getEnergy() > 0.1) E_tot += eclTrack->getEnergy();
153 }
154 }
155 for (const auto& cluster : eclClusters) {
156 if (!cluster.isNeutral()) continue;
157 if (cluster.getHypothesisId() != 5 && cluster.getHypothesisId() != 1)
158 continue;
159 if (cluster.getEnergy() > 0.1) E_tot += cluster.getEnergy();
160 }
161#endif
162
163 for (const auto& arichTrack : m_arichTracks) {
164
165 const ExtHit* extHit = arichTrack.getRelated<ExtHit>();
166
167 const Track* mdstTrack = NULL;
168 if (extHit) mdstTrack = extHit->getRelated<Track>();
169
170 const ARICHAeroHit* aeroHit = arichTrack.getRelated<ARICHAeroHit>();
171
172 const ARICHLikelihood* lkh = NULL;
173 if (mdstTrack) lkh = mdstTrack->getRelated<ARICHLikelihood>();
174 else lkh = arichTrack.getRelated<ARICHLikelihood>();
175
176 if (!lkh) continue;
177
178 m_arich.clear();
179
180 m_arich.evt = evtMetaData->getEvent();
181 m_arich.run = evtMetaData->getRun();
182 m_arich.exp = evtMetaData->getExperiment();
183
184 // set hapd window hit if available
185 if (arichTrack.hitsWindow()) {
186 m_arich.winHit[0] = arichTrack.windowHitPosition().X();
187 m_arich.winHit[1] = arichTrack.windowHitPosition().Y();
188 }
189
190 if (lkh->getFlag() == 1) m_arich.inAcc = 1;
191 m_arich.logL.e = lkh->getLogL(Const::electron);
192 m_arich.logL.mu = lkh->getLogL(Const::muon);
193 m_arich.logL.pi = lkh->getLogL(Const::pion);
194 m_arich.logL.K = lkh->getLogL(Const::kaon);
195 m_arich.logL.p = lkh->getLogL(Const::proton);
196 m_arich.logL.d = lkh->getLogL(Const::deuteron);
197
198 m_arich.expPhot.e = lkh->getExpPhot(Const::electron);
199 m_arich.expPhot.mu = lkh->getExpPhot(Const::muon);
200 m_arich.expPhot.pi = lkh->getExpPhot(Const::pion);
201 m_arich.expPhot.K = lkh->getExpPhot(Const::kaon);
202 m_arich.expPhot.p = lkh->getExpPhot(Const::proton);
203 m_arich.expPhot.d = lkh->getExpPhot(Const::deuteron);
204
205 m_arich.detPhot = lkh->getDetPhot();
206
207#ifdef ALIGNMENT_USING_BHABHA
208 m_arich.etot = E_tot;
209#endif
210 m_arich.status = 1;
211
212 m_arich.trgtype = 0;
213 if (m_arichInfo.getEntries() > 0) {
214 auto arichInfo = *m_arichInfo[0];
215 m_arich.trgtype = arichInfo.gettrgtype();
216 }
217
218 const MCParticle* particle = 0;
219
220 if (mdstTrack) {
221 const TrackFitResult* fitResult = mdstTrack->getTrackFitResultWithClosestMass(Const::pion);
222 if (fitResult) {
223 m_arich.pValue = fitResult->getPValue();
224 ROOT::Math::XYZVector trkPos = fitResult->getPosition();
225 m_arich.charge = fitResult->getChargeSign();
226 m_arich.z0 = trkPos.Z();
227 m_arich.d0 = trkPos.Rho();
228 m_arich.nCDC = fitResult->getHitPatternCDC().getNHits();
229#ifdef ALIGNMENT_USING_BHABHA
230 ROOT::Math::XYZVector trkMom = fitResult->getMomentum();
231 const ECLCluster* eclTrack = mdstTrack->getRelated<ECLCluster>();
232 if (eclTrack) {
233 m_arich.eop = eclTrack->getEnergy() / trkMom.R();
234 m_arich.e9e21 = eclTrack->getE9oE21();
235 }
236#endif
237 }
238 m_arich.status += 10;
239 int fromARICHMCP = 0;
240 particle = mdstTrack->getRelated<MCParticle>();
241 if (!particle) { particle = mdstTrack->getRelated<MCParticle>("arichMCParticles"); fromARICHMCP = 1;}
242 if (particle) {
243 m_arich.PDG = particle->getPDG();
244 m_arich.primary = particle->getStatus(MCParticle::c_PrimaryParticle);
245 m_arich.seen = particle->hasSeenInDetector(Const::ARICH);
246 ROOT::Math::XYZVector prodVertex = particle->getProductionVertex();
247 m_arich.rhoProd = prodVertex.Rho();
248 m_arich.zProd = prodVertex.Z();
249 m_arich.phiProd = prodVertex.Phi();
250 ROOT::Math::XYZVector decVertex = particle->getDecayVertex();
251 m_arich.rhoDec = decVertex.Rho();
252 m_arich.zDec = decVertex.Z();
253 m_arich.phiDec = decVertex.Phi();
254
255 if (!fromARICHMCP) {
256 MCParticle* mother = particle->getMother();
257 if (mother) m_arich.motherPDG = mother->getPDG();
258 std::vector<Belle2::MCParticle*> daughs = particle->getDaughters();
259 for (const auto daugh : daughs) {
260 if (daugh == NULL) continue;
261 if (daugh->getPDG() == particle->getPDG()) m_arich.scatter = 1;
262 }
263 }
264 }
265 }
266
267
268 // get reconstructed photons associated with track
269 const std::vector<ARICHPhoton>& photons = arichTrack.getPhotons();
270 m_arich.nRec = photons.size();
271 for (auto it = photons.begin(); it != photons.end(); ++it) {
272 ARICHPhoton iph = *it;
273 if (iph.getHitID() < arichHits.getEntries()) {
274 auto ihit = *arichHits[iph.getHitID()];
275 int module = ihit.getModule();
276 int channel = ihit.getChannel();
277 int chid = 1 << 16 | module << 8 | channel;
278 iph.setHitID(chid);
279 }
280 m_arich.photons.push_back(iph);
281 }
282
283 ROOT::Math::XYZVector recPos = arichTrack.getPosition();
284 m_arich.recHit.x = recPos.X();
285 m_arich.recHit.y = recPos.Y();
286 m_arich.recHit.z = recPos.Z();
287
288 ROOT::Math::XYZVector recMom = arichTrack.getDirection() * arichTrack.getMomentum();
289 m_arich.recHit.p = recMom.R();
290 m_arich.recHit.theta = recMom.Theta();
291 m_arich.recHit.phi = recMom.Phi();
292
293 if (aeroHit) {
294 ROOT::Math::XYZVector truePos = aeroHit->getPosition();
295 m_arich.mcHit.x = truePos.X();
296 m_arich.mcHit.y = truePos.Y();
297 m_arich.mcHit.z = truePos.Z();
298
299 ROOT::Math::XYZVector trueMom = aeroHit->getMomentum();
300 m_arich.mcHit.p = trueMom.R();
301 m_arich.mcHit.theta = trueMom.Theta();
302 m_arich.mcHit.phi = trueMom.Phi();
303
304 m_arich.mcHit.PDG = aeroHit->getPDG();
305 m_arich.status += 1000;
306
307 if (!particle) {
308 particle = aeroHit->getRelated<MCParticle>();
309 if (particle) {
310 m_arich.PDG = particle->getPDG();
311 MCParticle* mother = particle->getMother();
312 if (mother) m_arich.motherPDG = mother->getPDG();
313 m_arich.primary = particle->getStatus(MCParticle::c_PrimaryParticle);
314 m_arich.seen = particle->hasSeenInDetector(Const::ARICH);
315 ROOT::Math::XYZVector prodVertex = particle->getProductionVertex();
316 m_arich.rhoProd = prodVertex.Rho();
317 m_arich.zProd = prodVertex.Z();
318 m_arich.phiProd = prodVertex.Phi();
319 ROOT::Math::XYZVector decVertex = particle->getDecayVertex();
320 m_arich.rhoDec = decVertex.Rho();
321 m_arich.zDec = decVertex.Z();
322 m_arich.phiDec = decVertex.Phi();
323
324 std::vector<Belle2::MCParticle*> daughs = particle->getDaughters();
325 for (const auto daugh : daughs) {
326 if (daugh->getPDG() == particle->getPDG()) m_arich.scatter = 1;
327 }
328 }
329 }
330 }
331 m_tree->Fill();
332 }
333 }
StoreArray< ARICHTrack > m_arichTracks
Required array of input ARICHTracks.
ARICH::ARICHTree m_arich
ntuple structure
StoreArray< Track > m_tracks
Optional input array of Tracks.
StoreArray< ARICHInfo > m_arichInfo
Optional input array of ARICHInfo.
static const ChargedStable muon
muon particle
Definition: Const.h:660
static const ChargedStable proton
proton particle
Definition: Const.h:663
static const ChargedStable kaon
charged kaon particle
Definition: Const.h:662
static const ChargedStable electron
electron particle
Definition: Const.h:659
static const ChargedStable deuteron
deuteron particle
Definition: Const.h:664
@ c_PrimaryParticle
bit 0: Particle is primary particle.
Definition: MCParticle.h:47
Float_t zDec
Decay vertex (cylindrical coordinate z) of MCParticle.
Int_t detPhot
Number of detected photons.
Int_t nCDC
Number of track CDC hits.
Float_t winHit[2]
Track hit on hapd window (x,y coordinates).
Float_t rhoDec
Decay vertex (cylindrical coordinate r) of MCParticle.
ParticlesArray logL
Log likelihoods.
Int_t scatter
1 if particle scattered (i.e.
Int_t nRec
Number of reconstructed photons.
Short_t primary
Is a primary particle (from related MCParticle).
Int_t evt
Event number.
Short_t seen
Is seen in ARICH (from related MCParticle).
TrackHit recHit
Extrapolated Track hit.
Int_t motherPDG
PDG code of related mother MCParticle.
Int_t exp
Experiment number.
ParticlesArray expPhot
Number of expected photons (signal + bkg).
std::vector< Belle2::ARICHPhoton > photons
Vector of reconstructed photons.
Float_t phiProd
Production vertex (cylindrical coordinate phi) of MCParticle.
Int_t trgtype
Event trigger type.
Float_t rhoProd
Production vertex (cylindrical coordinate r) of MCParticle.
void clear()
Clear the structure: set elements to zero.
Float_t phiDec
Decay vertex (cylindrical coordinate phi) of MCParticle.
Bool_t inAcc
Track in detector acceptance, i.e.
TrackHit mcHit
Related MC particle hit.
Int_t PDG
PDG code of related MCParticle.
Int_t status
Track status (add proper description).
Float_t pValue
p-value of Track fit.
Float_t zProd
Production vertex (cylindrical coordinate z) of MCParticle.
Float_t p
momentum magnitude
Float_t z
impact point, z component
Float_t theta
momentum polar angle
Float_t phi
momentum azimuthal angle
Float_t x
impact point, x component
Float_t y
impact point, y component

◆ event() [7/12]

void event ( void  )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 76 of file ARICHPackerModule.cc.

77 {
78
79 StoreObjPtr<EventMetaData> evtMetaData;
80 StoreArray<ARICHDigit> digits(m_inputDigitsName);
81 StoreArray<RawARICH> rawData(m_outputRawDataName);
82
83 int nModules = N_MERGERS * N_FEB2MERGER;
84
85 std::vector<const ARICHDigit*>* sortedDigits = new std::vector<const ARICHDigit*>[nModules];
86 for (const auto& digit : digits) {
87 int moduleID = digit.getModuleID();
88 unsigned mergerID = m_mergerMap->getMergerID(moduleID);
89 if (!mergerID) { B2WARNING("No module2merger mapping for module ID: " << moduleID << "; Digit will not be packed!"); continue;}
90 if (!m_copperMap->getCopperID(mergerID)) { B2WARNING("No merger2copper mapping for merger ID: " << mergerID << "; Digit will not be packed!"); continue;}
91 sortedDigits[moduleID - 1].push_back(&digit);
92 }
93
94 int buffer[4][ARICH_BUFFER_NWORDS];
95
96 for (const auto& copperID : m_copperMap->getCopperIDs()) {
97
98 int bufferSize[4] = {0, 0, 0, 0};
99 for (int finesse = 0; finesse < 4; finesse++) {
100
101 unsigned ibyte = 0;
102
103 for (int j = 0; j < ARICH_BUFFER_NWORDS; j++) {
104 buffer[finesse][j] = 0;
105 }
106
107 auto* buf = buffer[finesse];
108
109 // get corresponding merger ID
110 unsigned mergerID = m_copperMap->getMergerID(copperID, finesse);
111 unsigned mergerSN = m_mergerMap->getMergerSN(mergerID);
112 if (!mergerID) continue;
113
114 ARICHRawHeader mergerHead;
115 unsigned dataFormat = m_nonSuppressed + 1; // production data -> TODO: use enum
116 mergerHead.type = dataFormat;
117 mergerHead.version = m_version;
118 mergerHead.mergerID = mergerSN;
119 mergerHead.FEBSlot = 0;
120 mergerHead.trigger = evtMetaData->getEvent();
121 // mergerHead.length dont forget
122
123 ibyte += ARICHRAW_HEADER_SIZE;
124
125 int nboards = N_FEB2MERGER;
126
127 for (int k = 0; k < nboards; k++) {
128
129 int moduleID = m_mergerMap->getModuleID(mergerID, k + 1);
130 if (moduleID <= 0) continue;
131
132 // FEB header
133 ARICHRawHeader FEBHead;
134 FEBHead.type = dataFormat;
135 FEBHead.version = m_version;
136 FEBHead.mergerID = mergerSN;
137 FEBHead.FEBSlot = k; // board slots go from 0-5 for now, if firmware is updated to 1-6 add +1 !!
138 FEBHead.trigger = evtMetaData->getEvent();
139
140 if (m_nonSuppressed) {
141 // data length in bytes
142 FEBHead.length = 144 + ARICHFEB_HEADER_SIZE; // 144ch * 1 byte
143 writeHeader(buf, ibyte, FEBHead);
144 ibyte += ARICHFEB_HEADER_SIZE; // leave slot for FEB header (FEB header to be implemented!)
145
146 // write data
147 for (const auto& digit : sortedDigits[moduleID - 1]) {
148 unsigned chn = digit->getChannelID();
149 //std::cout << "pack: mod: " << boardID << " ch " << chn<< std::endl;
150 unsigned shift = 143 - chn;
151 unsigned bitmap = (unsigned)digit->getBitmap();
152 buf[(ibyte + shift) / 4] += (bitmap << (3 - (ibyte + shift) % 4) * 8);
153 }
154 ibyte += 144;
155 } else {
156 FEBHead.length = ARICHFEB_HEADER_SIZE + sortedDigits[moduleID - 1].size() * 2; // each hit is 2 bytes! channel + bitmap
157 writeHeader(buf, ibyte, FEBHead);
158 ibyte += ARICHFEB_HEADER_SIZE; // leave slot for FEB header (FEB header to be implemented!)
159
160 for (const auto& digit : sortedDigits[moduleID - 1]) {
161 unsigned chn = digit->getChannelID();
162 //std::cout << "pack: mod: " << boardID << " ch " << chn<< std::endl;
163 unsigned shift = (3 - ibyte % 4) * 8;
164 buf[ibyte / 4] += (chn << shift);
165 ibyte++;
166 shift = (3 - ibyte % 4) * 8;
167 unsigned bitmap = (unsigned)digit->getBitmap();
168 buf[ibyte / 4] += (bitmap << shift);
169 ibyte++;
170 }
171 }
172 }
173
174 unsigned merg = 0;
175 mergerHead.length = ibyte - ARICHRAW_HEADER_SIZE;
176 writeHeader(buf, merg, mergerHead);
177
178 bufferSize[finesse] = ceil(ibyte / 4.);
179
180 if (m_debug) {
181 std::cout << "Pack finesse: " << finesse << std::endl;
182 for (int i = 0; i < bufferSize[finesse]; i++) {
183 std::cout << i << "-th word bitset " << std::bitset<32>(buf[i]) << std::endl;
184 }
185 }
186 }
187
188 RawCOPPERPackerInfo info;
189 info.exp_num = evtMetaData->getExperiment();
190 info.run_subrun_num = (evtMetaData->getRun() << 8) +
191 (evtMetaData->getSubrun() & 0xFF); // run number : 14bits, subrun # : 8bits
192 info.eve_num = evtMetaData->getEvent();
193 info.node_id = ARICH_ID + copperID;
194 info.tt_ctime = 0;
195 info.tt_utime = 0;
196 info.b2l_ctime = 0;
197 info.hslb_crc16_error_bit = 0;
198 info.truncation_mask = 0;
199 info.type_of_data = 0;
200
201 auto* raw = rawData.appendNew();
202 raw->PackDetectorBuf(buffer[0], bufferSize[0],
203 buffer[1], bufferSize[1],
204 buffer[2], bufferSize[2],
205 buffer[3], bufferSize[3],
206 info);
207
208 }
209
210 delete [] sortedDigits;
211
212 }
DBObjPtr< ARICHMergerMapping > m_mergerMap
mapping of modules to mergers
DBObjPtr< ARICHCopperMapping > m_copperMap
mapping of mergers to coppers
#define ARICHFEB_HEADER_SIZE
FEB header size in bytes.
#define ARICH_BUFFER_NWORDS
Arich number of words (ints) in buffer: 3 + 33 + 6 * 36 (3 merger header words + 5....
void writeHeader(int *buffer, unsigned &ibyte, const ARICHRawHeader &head)
TODO!
#define ARICHRAW_HEADER_SIZE
Raw header size in bytes.

◆ event() [8/12]

void event ( void  )
overridevirtual

Event processor.

Reimplemented from HistoModule.

Definition at line 113 of file ARICHRateCalModule.cc.

114 {
115 StoreObjPtr<EventMetaData> evtmetadata;
116 StoreObjPtr<ARICHInfo> arichinfo;
117 if (!arichinfo->getthscan_mode()) return;
118 double vth_thscan = arichinfo->getvth_thscan();
119
120 //int runno = m_internalmode ? m_run_count : evtmetadata->getRun();
121 //int raw_evtno = m_internalmode ? m_evt_count : evtmetadata->getEvent();
122 int runno = evtmetadata->getRun();
123 //int raw_evtno = evtmetadata->getEvent();
124
125 ARICHThParam param(runno, m_dth, m_th0, m_nrun);
126 StoreArray<ARICHRawDigit> rawdigits;
127 for (auto& rawdigit : rawdigits) {
128 const int mrgid = rawdigit.getBoardId();
129 //const int nfebs = rawdigit.getNFEBs();
130 //B2INFO("MB="<<mrgid<<" nfeb="<<nfebs);
131 std::vector<ARICHRawDigit::FEBDigit>& febs(rawdigit.getFEBs());
132 for (auto& feb : febs) {
133 const int febno = feb.febno;
134 std::vector<ARICHRawDigit::FEBDigit::ChannelDigit>& channels(feb());
135 for (auto& channel : channels) {
136 if (channel.val > 0) {
137 //B2INFO("MB="<<mrgid<<" ch="<< channel.chno);
138 double vth = m_internalmode ? vth_thscan * 1000 : param.getVth() * 1000 ;
139 h_rate2D[mrgid]->Fill(channel.chno + febno * 144, vth);
140 }
141 }
142 }
143 }
144
145 // evt,run counter for internal thscan mode
146 m_evt_count++;
147 if (m_evt_count == m_nevents) {
148 m_evt_count = 0;
149 m_run_count++;
150 }
151
152 }

◆ event() [9/12]

void event ( void  )
overridevirtual

Event processor.

Reimplemented from HistoModule.

Definition at line 62 of file ARICHRawUnpackerModule.cc.

63 {
64 StoreArray<RawARICH> rawdata;
65 StoreArray<ARICHRawDigit> rawdigits;
66 for (auto& raw : rawdata) {
67 for (int finesse = 0; finesse < 4; finesse++) {
68 const int* buf = (const int*)raw.GetDetectorBuffer(0, finesse);
69 int bufSize = raw.GetDetectorNwords(0, finesse);
70 if (bufSize < 1) continue;
71 m_ibyte = 0;
72 // read merger header
73 int type = calbyte(buf);
74 int ver = calbyte(buf);
75 int boardid = calbyte(buf);
76 int febno = calbyte(buf);
77 unsigned int length_all = calword(buf);
78 unsigned int mrg_evtno = calword(buf);
79 ARICHRawDigit* rawdigit = rawdigits.appendNew(type, ver, boardid, febno, length_all, mrg_evtno);
80 rawdigit->setCopperId(raw.GetNodeID(0));
81 rawdigit->setHslbId(finesse);
82 while (m_ibyte < length_all) {
83 int type_feb = calbyte(buf);
84 ver = calbyte(buf);
85 boardid = calbyte(buf);
86 febno = calbyte(buf);
87 unsigned int length = calword(buf);
88 int evtno = calword(buf);
89 unsigned int ibyte = 0;
90 std::stringstream ss;
91 ss << "type=" << type_feb << ", ver=" << ver << " "
92 << ", boardid=" << boardid << ", febno=" << febno
93 << ", length=" << length << ", evtno=" << evtno << " ";
94 bool hasHit = false;
95 long long feb_trigno = 0;
96 for (int i = 0; i < 10; i++) {
97 int val = calbyte(buf);
98 ibyte++;
99 if (i > 1 && i < 6) {
100 feb_trigno |= (0xff & val) << (5 - i) * 8;
101 }
102 }
103 ARICHRawDigit::FEBDigit feb;
104 if (type_feb == 0x02) {//Raw mode
105 int ch = 143;
106 //B2INFO("raw mode");
107 while (ibyte < length) {
108 int val = calbyte(buf);
109 if (val != 0) {
110 ibyte++;
111 ss << "ch# " << ch << "(" << val << ") ";
112 hasHit = true;
113 if (febno < 0 || febno > 6) {
114 B2ERROR("FEB is bad:" << LogVar("FEB", std::to_string(febno) + " hslb-" + std::to_string(finesse))
115 << LogVar("type", type_feb) << LogVar("ver", ver)
116 << LogVar("boardid", boardid) << LogVar("febno", febno)
117 << LogVar("length", length) << LogVar("evtno", evtno));
118 }
119 feb.push_back(ch, val);
120 }
121 ch--;
122 if (ch < 0) break;
123 }
124 } else if (type_feb == 0x01) { // Suppressed mode
125 if (length > 144 * 2 + 10) B2FATAL("error " << length);
126 //B2INFO("suppreed mode");
127 while (ibyte < length) {
128 int ch = calbyte(buf);
129 ibyte++;
130 int val = calbyte(buf);
131 ibyte++;
132 if (val != 0) {
133 ss << "ch# " << ch << "(" << val << ") ";
134 hasHit = true;
135 if (febno < 0 || febno > 6) {
136 B2ERROR("FEB is bad:" << LogVar("FEB", std::to_string(febno) + " hslb-" + std::to_string(finesse))
137 << LogVar("type", type_feb) << LogVar("ver", ver)
138 << LogVar("boardid", boardid) << LogVar("febno", febno)
139 << LogVar("length", length) << LogVar("evtno", evtno));
140 return;
141 }
142 feb.push_back(ch, val);
143 }
144 }
145 }
146 rawdigit->addFEB(feb, type, ver, boardid, febno, length, evtno, feb_trigno);
147 if (m_debug && hasHit) {
148 B2INFO(ss.str());
149 }
150 }
151 }
152 }
153 }
unsigned int calword(const int *buf)
Read word (4 bytes) from the buffer and increase the byte number m_ibyte by 4.

◆ event() [10/12]

void event ( void  )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 119 of file ARICHReconstructorModule.cc.

120 {
121 // using track information form tracking system (mdst Track)
122 if (m_inputTrackType == 0) {
123
124 Const::EDetector myDetID = Const::EDetector::ARICH; // arich
125 Const::ChargedStable hypothesis = Const::pion;
126 int pdgCode = abs(hypothesis.getPDGCode());
127
128 for (const Track& track : m_Tracks) {
129 const TrackFitResult* fitResult = track.getTrackFitResultWithClosestMass(hypothesis);
130 if (!fitResult) {
131 B2ERROR("No TrackFitResult for " << hypothesis.getPDGCode());
132 continue;
133 }
134
135 const MCParticle* mcParticle = track.getRelated<MCParticle>();
136
137 ARICHAeroHit* aeroHit = NULL;
138 if (mcParticle) aeroHit = mcParticle->getRelated<ARICHAeroHit>();
139
140 RelationVector<ExtHit> extHits = DataStore::getRelationsWithObj<ExtHit>(&track);
141 ARICHTrack* arichTrack = NULL;
142
143 //const ExtHit* arich1stHit = NULL;
144 const ExtHit* arich2ndHit = NULL;
145 const ExtHit* arichWinHit = NULL;
146
147 for (unsigned i = 0; i < extHits.size(); i++) {
148 const ExtHit* extHit = extHits[i];
149 if (abs(extHit->getPdgCode()) != pdgCode or
150 extHit->getDetectorID() != myDetID or
151 extHit->getStatus() != EXT_EXIT or // particles registered at the EXIT of the Al plate
152 extHit->getMomentum().Z() < 0.0 or // track passes in backward
153 extHit->getCopyID() == 12345) { continue;}
154 if (extHit->getCopyID() == 6789) { arich2ndHit = extHit; continue;}
155 arichWinHit = extHit;
156 }
157
158 if (arich2ndHit) {
159 // if aeroHit cannot be found using MCParticle check if it was already related to the extHit (by ARICHRelate module)
160 if (!aeroHit) aeroHit = arich2ndHit->getRelated<ARICHAeroHit>();
161
162 // make new ARICHTrack
163 arichTrack = m_ARICHTracks.appendNew(arich2ndHit);
164 if (arichWinHit) arichTrack->setHapdWindowHit(arichWinHit);
165 }
166
167 // skip if track has no extHit in ARICH
168 if (!arichTrack) continue;
169 // transform track parameters to ARICH local frame
170 m_ana->transformTrackToLocal(*arichTrack, m_align);
171 // make new ARICHLikelihood
172 ARICHLikelihood* like = m_ARICHLikelihoods.appendNew();
173 // calculate and set likelihood values
174 m_ana->likelihood2(*arichTrack, m_ARICHHits, *like);
175 // make relations
176 track.addRelationTo(like);
177 arichTrack->addRelationTo(arich2ndHit);
178 if (aeroHit) arichTrack->addRelationTo(aeroHit);
179
180 } // Tracks loop
181 } // input type if
182
183
184 // using track information form MC (stored in ARICHAeroHit)
185 else {
186
187 // Loop over all ARICHAeroHits
188 for (const ARICHAeroHit& aeroHit : m_aeroHits) {
189
190 // make new ARICHTrack
191 ARICHTrack* arichTrack = m_ARICHTracks.appendNew(&aeroHit);
192 // smearing of track parameters (to mimic tracking system resolutions)
193 m_ana->smearTrack(*arichTrack);
194 // transform track parameters to ARICH local frame
195 m_ana->transformTrackToLocal(*arichTrack, m_align);
196 // make associated ARICHLikelihood
197 ARICHLikelihood* like = m_ARICHLikelihoods.appendNew();
198 // calculate and set likelihood values
199 m_ana->likelihood2(*arichTrack, m_ARICHHits, *like);
200 // make relation
201 arichTrack->addRelationTo(like);
202 arichTrack->addRelationTo(&aeroHit);
203 } // for iTrack
204
205 }
206 }
StoreArray< ARICHAeroHit > m_aeroHits
Aerogel hits.
StoreArray< ARICHTrack > m_ARICHTracks
ARICH tracks.
StoreArray< ARICHLikelihood > m_ARICHLikelihoods
Likelihoods.
StoreArray< ARICHHit > m_ARICHHits
ARICH hits.
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
int likelihood2(ARICHTrack &arichTrack, const StoreArray< ARICHHit > &arichHits, ARICHLikelihood &arichLikelihood)
Computes the value of identity likelihood function for different particle hypotheses.
void transformTrackToLocal(ARICHTrack &arichTrack, bool align)
Transforms track parameters from global Belle2 to ARICH local frame.
int smearTrack(ARICHTrack &arichTrack)
Smears track parameters ("simulate" the uncertainties of tracking).

◆ event() [11/12]

void event ( void  )
overridevirtual

Event processor.

Reimplemented from Module.

Definition at line 60 of file ARICHRelateModule.cc.

61 {
62 int nHits = m_aeroHits.getEntries();
63 B2DEBUG(50, "No. of hits " << nHits);
64
65 for (const ARICHAeroHit& aeroHit : m_aeroHits) {
66 const MCParticle* particle = DataStore::getRelated<MCParticle>(&aeroHit);
67 if (!particle) {
68 B2DEBUG(50, "No MCParticle for AeroHit!");
69 continue;
70 }
71
72 // Find the track produced by MCParticle
73 const Track* track = DataStore::getRelated<Track>(particle);
74 if (!track) continue;
75
76 const TrackFitResult* fitResult = track->getTrackFitResultWithClosestMass(Const::pion);
77 if (!fitResult) continue;
78
79 RelationVector<ExtHit> extHits = DataStore::getRelationsWithObj<ExtHit>(track);
80 const Const::EDetector arich = Const::EDetector::ARICH;
81 for (const ExtHit& extHit : extHits) {
82 if (abs(extHit.getPdgCode()) != Const::pion.getPDGCode() or
83 extHit.getDetectorID() != arich or
84 extHit.getCopyID() != 6789 or // aerogel Al support plate
85 extHit.getStatus() != EXT_EXIT) continue; // particles registered at the EXIT of the Al plate
86 extHit.addRelationTo(&aeroHit);
87 break;
88 }
89 }
90 }
StoreArray< ARICHAeroHit > m_aeroHits
Required array of input ARICHAeroHits.
int getPDGCode() const
PDG code.
Definition: Const.h:473

◆ event() [12/12]

void event ( void  )
overridevirtual

Event processor.

temporary! FEB Slots on merger should be 1-6 (now 0-5). Remove when firmware is updated!

Reimplemented from Module.

Definition at line 90 of file ARICHUnpackerModule.cc.

91 {
92
93 StoreArray<RawARICH> rawData(m_inputRawDataName);
94 StoreArray<ARICHDigit> digits(m_outputDigitsName);
95 StoreArray<ARICHRawDigit> rawdigits(m_outputRawDigitsName);
96 StoreObjPtr<ARICHInfo> arichinfo(m_outputarichinfoName);
97 arichinfo.create();
98 StoreObjPtr<EventMetaData> evtMetaData;
99
100 digits.clear();
101 bool m_pciedata = false;
102 int trgtype = 16;
103 double vth_thscan = 0.0;
104
105 if (m_debug) {
106 std::cout << std::endl << "------------------------" << std::endl;
107 std::cout << "Run: " << evtMetaData->getRun() << " Event: " << evtMetaData->getEvent() << std::endl;
108 std::cout << "------------------------" << std::endl << std::endl;
109 }
110
111 unsigned thscan_mode = 0;
112 // regular Unpacker mode, fill ARICHDigit
113// if (m_disable_unpacker == 0) {
114
115 for (auto& raw : rawData) {
116 // Check PCIe40 data or Copper data
117 if (raw.GetMaxNumOfCh(0) == 48) { m_pciedata = true; } // Could be 36 or 48
118 else if (raw.GetMaxNumOfCh(0) == 4) { m_pciedata = false; }
119 else { B2FATAL("ARICHUnpackerModule: Invalid value of GetMaxNumOfCh from raw data: " << LogVar("Number of ch: ", raw.GetMaxNumOfCh(0))); }
120
121 for (int finesse = 0; finesse < raw.GetMaxNumOfCh(0); finesse++) {
122 const int* buffer = raw.GetDetectorBuffer(0, finesse);
123 int bufferSize = raw.GetDetectorNwords(0, finesse);
124
125 if (bufferSize < 1)
126 continue;
127
128 // record the trigger type from the B2L data
129 trgtype = raw.GetTRGType(0);
130
131 // read merger header
132 unsigned ibyte = 0;
133 ARICHRawHeader head;
134
135 readHeader(buffer, ibyte, head);
136
137 if (m_debug > 1) printBits(buffer, bufferSize);
138
139 if (m_debug) {
140 std::cout << "Merger header" << std::endl;
141 head.print();
142 }
143 //-- RawDigit for Merger info
144 int type = (int)head.type;
145 int ver = (int)head.version;
146 int boardid = (int)head.mergerID;
147 int febno = (int)head.FEBSlot;
148 unsigned int length_all = (unsigned int)head.length;
149 unsigned int mrg_evtno = (unsigned int)head.trigger;
150 ARICHRawDigit* rawdigit = rawdigits.appendNew(type, ver, boardid, febno, length_all, mrg_evtno);
151
152 if (!m_pciedata) {
153 rawdigit->setCopperId(raw.GetNodeID(0));
154 rawdigit->setHslbId(finesse);
155 } else {
156 if (raw.GetNodeID(0) == 0x4000001) {
157 rawdigit->setCopperId(raw.GetNodeID(0) + (int)(finesse / 4));
158 } else if (raw.GetNodeID(0) == 0x4000002) {
159 rawdigit->setCopperId(0x400000A + (int)(finesse / 4));
160 } else {
161 B2FATAL("ARICHUnpackerModule: Invalid Node ID from readout: " << LogVar("NodeID: ", raw.GetNodeID(0)));
162 }
163
164 rawdigit->setHslbId(finesse % 4);
165 rawdigit->setPcieId(raw.GetNodeID(0));
166 rawdigit->setPcieChId(finesse);
167 }
168
169 //-- end of RawDigit for Merger info
170
171 // record the ibyte here
172 unsigned begin = ibyte;
173
174 while (ibyte < head.length) {
175
176 // new feb
177 ARICHRawHeader febHead;
178 readFEHeader(buffer, ibyte, febHead);
179 if (febHead.thscan_mode) {thscan_mode++;}
180 if (m_debug) febHead.print();
181
182 if (/*febHead.type != head.type ||*/ febHead.version != head.version || febHead.mergerID != head.mergerID
183 || febHead.trigger != head.trigger) {
184 B2ERROR("ARICHUnpackerModule: data in FEB header not consistent with data in merger HEADER " << LogVar("FEB ID",
185 (unsigned)febHead.FEBSlot) <<
186 LogVar("merger ID", (unsigned)head.mergerID)); break;
187 }
188
189 // feb header shift
190 ibyte += ARICHFEB_HEADER_SIZE;
191 int dataLen = febHead.length - ARICHFEB_HEADER_SIZE;
192
193 febHead.FEBSlot += 1;
194
195 unsigned mergID = m_mergerMap->getMergerIDfromSN((unsigned)head.mergerID);
196
197 if (mergID == 99) { B2ERROR("ARICHUnpackerModule: unknown merger number. Merger data will be skipped. " << LogVar("merger ID", mergID) << LogVar("Serial Number", (unsigned)head.mergerID)); break;}
198
199 unsigned moduleID = m_mergerMap->getModuleID(mergID, (unsigned)febHead.FEBSlot);
200
201 if (!moduleID) { B2ERROR("ARICHUnpackerModule: no merger to FEB mapping. Merger data will be skipped. " << LogVar("merger ID", mergID) << LogVar("Serial Number", (unsigned)head.mergerID) << LogVar("FEB slot", (unsigned)febHead.FEBSlot)); break;}
202
203 // read data
204 if (m_debug) std::cout << "Hit channels: " << std::endl;
205 if (febHead.type == 1) {
206 for (int i = 0; i < dataLen / 2; i++) {
207 int shift = (3 - ibyte % 4) * 8;
208 uint8_t asicCh = buffer[ibyte / 4] >> shift;
209 ibyte++;
210 shift = (3 - ibyte % 4) * 8;
211 uint8_t hitBitSet = buffer[ibyte / 4] >> shift;
212 if (m_debug && hitBitSet) std::cout << "ch: " << (unsigned)asicCh << " " << std::bitset<8>(hitBitSet) << std::endl;
213 // store digit
214 digits.appendNew(moduleID, (unsigned)asicCh, hitBitSet);
215 ibyte++;
216 }
217 } else if (febHead.type == 2) {
218 unsigned asicCh = 143;
219 for (int i = 0; i < dataLen; i++) {
220 int shift = (3 - ibyte % 4) * 8;
221 uint8_t hitBitSet = buffer[ibyte / 4] >> shift;
222 // store digit if hit
223 if (hitBitSet & m_bitMask) {
224 digits.appendNew(moduleID, asicCh, hitBitSet);
225 }
226 asicCh--;
227 ibyte++;
228 }
229 } else B2ERROR("ARICHUnpackerModule: Unknown data type" << LogVar("type", febHead.type));
230
231 }
232
233 if (ceil(ibyte / 4.) != (unsigned)bufferSize)
234 B2WARNING("ARICHUnpackerModule: data buffer size mismatch " << LogVar("size from copper", bufferSize) << LogVar("size from merger",
235 ceil(
236 ibyte / 4.)));
237
238
239 //-- If thscan_mode detected from header: proceed to fill ARICHRawDigit
240 //-- If m_rawmode is set to 1: proceed to fill ARICHRawDigit
241 if (thscan_mode == 0 && m_rawmode == 0) continue;
242 //-- go back to beginning again for second loop in case of thscan
243 m_ibyte = begin;
244
245 while (m_ibyte < length_all) {
246 ARICHRawHeader febHead;
247 readFEHeader(buffer, m_ibyte, febHead);
248 int type_feb = febHead.type;
249 ver = febHead.version;
250 boardid = febHead.mergerID;
251 febno = febHead.FEBSlot;
252
253 vth_thscan = (febHead.vth * 0.0024) - 1.27;
254 unsigned int length = febHead.length;
255 int evtno = febHead.trigger;
256 unsigned int jbyte = 0;
257 std::stringstream ss;
258 ss << "type=" << type_feb << ", ver=" << ver << " "
259 << ", boardid=" << boardid << ", febno=" << febno
260 << ", length=" << length << ", evtno=" << evtno << " ";
261 bool hasHit = false;
262 long long feb_trigno = 0;
263 for (int i = 0; i < 10; i++) {
264 int val = calbyte(buffer);
265 jbyte++;
266 if (i > 1 && i < 6) {
267 feb_trigno |= (0xff & val) << (5 - i) * 8;
268 }
269 }
270 ARICHRawDigit::FEBDigit feb;
271 if (type_feb == 0x02) {//Raw mode
272 int ch = 143;
273 //B2INFO("raw mode");
274 while (jbyte < length) {
275 int val = calbyte(buffer);
276 if (val != 0) {
277 jbyte++;
278 ss << "ch# " << ch << "(" << val << ") ";
279 hasHit = true;
280 if (febno < 0 || febno > 6) {
281 B2ERROR("FEB is bad : " << LogVar("FEB no.", febno) << LogVar("hslb", finesse) << LogVar("type", type_feb) << LogVar("ver",
282 ver) << LogVar("boardid", boardid) << LogVar("febno", febno) << LogVar("length", length) << LogVar("evtno", evtno));
283 }
284 feb.push_back(ch, val);
285 }
286 ch--;
287 if (ch < 0) break;
288 }
289 } else if (type_feb == 0x01) { // Suppressed mode
290 // The below line is commented since it sometimes causes problem during processing threshold scan data.
291 // No harm to comment this line since it is only utilized for threshold scan data.
292 //if (length > 144 * 2 + 10) B2FATAL("error " << LogVar("length", length));
293 //B2INFO("suppreed mode");
294 while (jbyte < length) {
295 int ch = calbyte(buffer);
296 jbyte++;
297 int val = calbyte(buffer);
298 jbyte++;
299 if (val != 0) {
300 ss << "ch# " << ch << "(" << val << ") ";
301 hasHit = true;
302 if (febno < 0 || febno > 6) {
303 B2ERROR("FEB is bad : " << LogVar("FEB no.", febno) << LogVar("hslb", finesse) << LogVar("type", type_feb) << LogVar("ver",
304 ver) << LogVar("boardid", boardid) << LogVar("febno", febno) << LogVar("length", length) << LogVar("evtno", evtno));
305 return;
306 }
307 feb.push_back(ch, val);
308 }
309 }
310 }
311 rawdigit->addFEB(feb, type, ver, boardid, febno, length, evtno, feb_trigno);
312 if (m_debug && hasHit) {
313 B2INFO(ss.str());
314 }
315 }
316
317
318
319 }
320 } // end of rawData loop
321
322// } // end of regular unpacker
323 /*
324 // RawUnpacker mode, fill ARICHRawDigit
325 if (m_rawmode == 1) {
326 for (auto& raw : rawData) {
327 for (int finesse = 0; finesse < 4; finesse++) {
328 const int* buf = (const int*)raw.GetDetectorBuffer(0, finesse);
329 int bufSize = raw.GetDetectorNwords(0, finesse);
330 if (bufSize < 1) continue;
331 m_ibyte = 0;
332 // read merger header
333 int type = calbyte(buf);
334 int ver = calbyte(buf);
335 int boardid = calbyte(buf);
336 int febno = calbyte(buf);
337 unsigned int length_all = calword(buf);
338 unsigned int mrg_evtno = calword(buf);
339 ARICHRawDigit* rawdigit = rawdigits.appendNew(type, ver, boardid, febno, length_all, mrg_evtno);
340 rawdigit->setCopperId(raw.GetNodeID(0));
341 rawdigit->setHslbId(finesse);
342 int nfebs = 0;
343 //--done
344 while (m_ibyte < length_all) {
345 int type_feb = calbyte(buf);
346 ver = calbyte(buf);
347 boardid = calbyte(buf);
348 febno = calbyte(buf);
349
350 // first line: vth value
351 unsigned int vth_int = cal2byte(buf);
352 if (vth_int > 0) { vth_thscan = (vth_int * 0.0024) - 1.27; }
353 // second line: length
354 unsigned int length = cal2byte(buf);
355 int evtno = calword(buf);
356 unsigned int ibyte = 0;
357 std::stringstream ss;
358 ss << "type=" << type_feb << ", ver=" << ver << " "
359 << ", boardid=" << boardid << ", febno=" << febno
360 << ", length=" << length << ", evtno=" << evtno << " ";
361 bool hasHit = false;
362 long long feb_trigno = 0;
363 for (int i = 0; i < 10; i++) {
364 int val = calbyte(buf);
365 ibyte++;
366 if (i < 6) {
367 feb_trigno |= (0xff & val) << (5 - i) * 8;
368 }
369 }
370 ARICHRawDigit::FEBDigit feb;
371 nfebs++;
372 if (type_feb == 0x02) {//Raw mode
373 int ch = 143;
374 //B2INFO("raw mode");
375 while (ibyte < length) {
376 int val = calbyte(buf);
377 if (val != 0) {
378 ibyte++;
379 ss << "ch# " << ch << "(" << val << ") ";
380 hasHit = true;
381 if (febno < 0 || febno > 6) {
382 B2ERROR("FEB is bad : " << LogVar("FEB no.", febno) << LogVar("hslb", finesse) << LogVar("type", type_feb) << LogVar("ver",
383 ver) << LogVar("boardid", boardid) << LogVar("febno", febno) << LogVar("length", length) << LogVar("evtno", evtno));
384 }
385 feb.push_back(ch, val);
386 }
387 ch--;
388 if (ch < 0) break;
389 }
390 } else if (type_feb == 0x01) { // Suppressed mode
391 // The below line is commented since it sometimes causes problem during processing threshold scan data.
392 // No harm to comment this line since it is only utilized for threshold scan data.
393 //if (length > 144 * 2 + 10) B2FATAL("error " << LogVar("length", length));
394 //B2INFO("suppreed mode");
395 while (ibyte < length) {
396 int ch = calbyte(buf);
397 ibyte++;
398 int val = calbyte(buf);
399 ibyte++;
400 if (val != 0) {
401 ss << "ch# " << ch << "(" << val << ") ";
402 hasHit = true;
403 if (febno < 0 || febno > 6) {
404 B2ERROR("FEB is bad : " << LogVar("FEB no.", febno) << LogVar("hslb", finesse) << LogVar("type", type_feb) << LogVar("ver",
405 ver) << LogVar("boardid", boardid) << LogVar("febno", febno) << LogVar("length", length) << LogVar("evtno", evtno));
406 return;
407 }
408 feb.push_back(ch, val);
409 }
410 }
411 }
412 rawdigit->addFEB(feb, type, ver, boardid, febno, length, evtno, feb_trigno);
413 if (m_debug && hasHit) {
414 B2INFO(ss.str());
415 }
416 }
417 }
418 }
419
420 } // end of raw unpacker
421 */
422 arichinfo->settrgtype(trgtype);
423 arichinfo->setpciedata(m_pciedata);
424 if (vth_thscan > -1.27) { arichinfo->setvth_thscan(vth_thscan); }
425 arichinfo->setntrack(0);
426 arichinfo->setnexthit(0);
427 arichinfo->setnhit(0);
428 if (thscan_mode > 0 || m_rawmode != 0)
429 { arichinfo->setthscan_mode(true); }
430 else
431 { arichinfo->setthscan_mode(false); }
432
433 }
DBObjPtr< ARICHMergerMapping > m_mergerMap
mapping of modules to mergers
void printBits(const int *buffer, int bufferSize)
Unpack raw data given in production format.
void readHeader(const int *buffer, unsigned &ibyte, ARICHRawHeader &head)
Read Merger header.
void readFEHeader(const int *buffer, unsigned &ibyte, ARICHRawHeader &head)
Read FE header.

◆ FastTracking()

ROOT::Math::XYZVector FastTracking ( ROOT::Math::XYZVector  dirf,
ROOT::Math::XYZVector  r,
double *  refind,
double *  z,
int  n,
int  opt 
)
private

Calculates the intersection of the Cherenkov photon emitted from point "r" in "dirf" direction with the detector plane.

Parameters
[in]rVector of photon emission point.
[in]dirfDirection of photon emission.
[in]refindArray of layers refractive indices.
[in]zArray of z coordinates of borders between layers.
[in]nNumber of aerogel layers through which photon passes.
[in]optParameter can be set to 1 to return empty TVector3 in case of errors

Definition at line 151 of file ARICHReconstruction.cc.

153 {
154 //
155 // Description:
156 // The method calculates the intersection of the cherenkov photon
157 // with the detector plane
158
159 // z[n+1]
160 // z[0] .. 1st aerogel exit
161 // z[n-1] .. 2nd aerogel exit
162
163 double angmir = 0; int section[2] = {0, 0};
164
165 unsigned tileID = m_arichgp->getAerogelPlane().getAerogelTileID(r.X(), r.Y());
166
167 if (tileID == 0 && opt == 1) return ROOT::Math::XYZVector();
168
169 int nmir = m_arichgp->getMirrors().getNMirrors();
170 if (nmir > 0) {
171 double dangle = 2 * M_PI / nmir;
172 angmir = m_arichgp->getMirrors().getStartAngle() - dangle / 2.;
173
174 double trkangle = r.Phi() - angmir;
175 if (trkangle < 0) trkangle += 2 * M_PI;
176 if (trkangle > 2 * M_PI) trkangle -= 2 * M_PI;
177
178 section[1] = int(trkangle / dangle) + 1;
179 }
180
181 bool reflok = false; bool refl = false;
182 double path = (z[0] - r.Z()) / dirf.Z();
183 r += dirf * path;
184 for (int a = 1; a <= n + 1 ; a++) {
185 double rind = refractiveInd[a] / refractiveInd[a - 1];
186 dirf = Refraction(dirf, rind);
187 if (dirf.R() == 0) return ROOT::Math::XYZVector();
188 path = (z[a] - r.Z()) / dirf.Z();
189 ROOT::Math::XYZVector r0 = r;
190 if (a == n && opt == 1) {
191 if (m_arichgp->getAerogelPlane().getAerogelTileID(r.X(), r.Y()) != tileID) return ROOT::Math::XYZVector();
192 }
193 r += dirf * path;
194 ROOT::Math::XYVector rxy(r);
195 // check for possible reflections
196 if (a != n || nmir == 0) continue;
197 double angle = rxy.Phi() - angmir;
198 if (angle < 0) angle += 2 * M_PI;
199 if (angle > 2 * M_PI) angle -= 2 * M_PI;
200 double dangle = 2 * M_PI / nmir;
201 section[0] = int(angle / dangle) + 1;
202 if (r.R() > (r - 2 * m_mirrorPoints[section[0] - 1]).R()) {
203 refl = true;
204 int nrefl = 2;
205 if (section[0] == section[1]) nrefl = 1;
206 for (int k = 0; k < nrefl; k++) {
207 if (!HitsMirror(r0, dirf, section[k])) continue;
208 ROOT::Math::XYZVector mirpoint = m_mirrorPoints[section[k] - 1];
209 ROOT::Math::XYZVector mirnorm = m_mirrorNorms[section[k] - 1];
210 double s = dirf.Dot(mirnorm);
211 double s1 = (mirpoint - r0).Dot(mirnorm);
212 r = r0 + s1 / s * dirf;
213 dirf = dirf - 2 * (dirf.Dot(mirnorm)) * mirnorm;
214 path = (z[a] - r.Z()) / dirf.Z();
215 r += dirf * path;
216 reflok = true;
217 break;
218 }
219 }
220 }
221
222 if (!reflok && refl) return ROOT::Math::XYZVector();
223 return r;
224 }
std::vector< ROOT::Math::XYZVector > m_mirrorPoints
vector of points on all mirror plates
std::vector< ROOT::Math::XYZVector > m_mirrorNorms
vector of normal vectors of all mirror plates

◆ getMirrorNorm()

ROOT::Math::XYZVector getMirrorNorm ( int  mirrorID)
private

Returns normal vector of the mirror plate with id mirrorID.

Definition at line 751 of file ARICHReconstruction.cc.

752 {
753 if (m_alignMirrors && m_mirrAlign.isValid()) {
754
755 ROOT::Math::XYZVector mirnorm = m_arichgp->getMirrors().getNormVector(mirrorID);
756
757 VectorUtil::setMagThetaPhi(mirnorm,
758 mirnorm.R(),
759 mirnorm.Theta() + m_mirrAlign->getAlignmentElement(mirrorID).getAlpha(),
760 mirnorm.Phi() + m_mirrAlign->getAlignmentElement(mirrorID).getBeta());
761
762 return mirnorm;
763
764 }
765 return m_arichgp->getMirrors().getNormVector(mirrorID);
766 }
DBObjPtr< ARICHMirrorAlignment > m_mirrAlign
global alignment parameters from the DB

◆ getMirrorPoint()

ROOT::Math::XYZVector getMirrorPoint ( int  mirrorID)
private

Returns point on the mirror plate with id mirrorID.

Definition at line 742 of file ARICHReconstruction.cc.

743 {
744
745 ROOT::Math::XYZVector mirpoint = m_arichgp->getMirrors().getPoint(mirrorID);
746 if (m_alignMirrors && m_mirrAlign.isValid()) mirpoint += m_mirrAlign->getAlignmentElement(mirrorID).getTranslation();
747 return mirpoint;
748
749 }

◆ getTrack()

int getTrack ( int  mask,
ROOT::Math::XYZVector &  r,
ROOT::Math::XYZVector &  dir 
)
protected

Beamtest Track reconstruction.

Definition at line 318 of file arichBtestModule.cc.

319 {
320 int retval = 0;
321 //const int trgch = 13;
322 const double t0 = 0;// m_tdc[trgch];
323 for (int i = 0; i < 4; i++) {
324 ARICHTracking* w = &m_mwpc[i];
325
326 for (int k = 0; k < 4; k++) mwpc_tdc[i][k]->Fill(m_tdc[w->tdc[k]] - t0);
327 mwpc_tdc[i][4]->Fill(m_tdc[w->atdc] - t0);
328
329
330 for (int k = 0; k < 2; k++) { // axis x,y
331 w->status[k] = 1;
332 w->diff[k] = m_tdc[w->tdc[2 * k]] - m_tdc[w->tdc[2 * k + 1]];
333 w->sum[k] = m_tdc[w->tdc[2 * k + 1]] + m_tdc[w->tdc[2 * k]] - 2 * m_tdc[w->atdc];
334 mwpc_sum[i][k]->Fill(w->sum[k]);
335 if (w->sum[k] < w->cutll[k] || w->sum[k] > w->cutul[k]) continue;
336 mwpc_sum_cut[i][k]->Fill(w->sum[k]);
337 w->status[k] = 0;
338 w->reco[k] = w->diff[k] * w->slp[k] + w->offset[k];
339 w->reco[k] += w->pos[k];
340
341 mwpc_diff[i][k]->Fill(w->diff[k]);
342 }
343
344 w->reco[2] = w->pos[2]; // update z axis
345 if (!w->status[0] && !w->status[1]) mwpc_xy[i]->Fill(w->reco[0], w->reco[1]);
346
347 if (mask & (1 << i)) {
348 if (!w->status[0] && !w->status[1]) {
349 // add point to a fitter
350 } else {
351 retval = 1;
352 }
353 }
354 }
355
356 // replace by fitter
357 int ii[4] = {0, 1, 0, 0};
358 int ncnt = 0;
359 for (int i = 0; i < 4; i++) {
360 if (mask & (1 << i)) {
361 //B2INFO(ncnt << " " << i << " Mask " << mask);
362 ii[ncnt++] = i;
363 }
364 }
365 int i0 = ii[0];
366 int i1 = ii[1];
367
368 r.SetXYZ(m_mwpc[i0].reco[1], m_mwpc[i0].reco[0], m_mwpc[i0].reco[2]);
369 dir.SetXYZ(m_mwpc[i1].reco[1] - m_mwpc[i0].reco[1],
370 m_mwpc[i1].reco[0] - m_mwpc[i0].reco[0],
371 m_mwpc[i1].reco[2] - m_mwpc[i0].reco[2]);
372
373 dir = dir.Unit();
374
375// end replace by fitter
376 if (dir.Z() != 0) {
377 for (int i = 0; i < 4; i++) {
378 ARICHTracking* w = &m_mwpc[i];
379 double l = (w->reco[2] - r.Z()) / dir.Z() ;
380 ROOT::Math::XYZVector rext = r + dir * l;
381 if (!w->status[0]) mwpc_residuals[i][0]->Fill(w->reco[0] - rext.Y());
382 if (!w->status[1]) mwpc_residuals[i][1]->Fill(w->reco[1] - rext.X());
383
384 TAxis* axis = mwpc_residualsz[i][1]->GetYaxis();
385 for (int k = 0; k < axis->GetNbins(); k++) {
386 double ll = (w->reco[2] + axis->GetBinCenter(k + 1) - r.Z()) / dir.Z();
387 ROOT::Math::XYZVector rextt = r + dir * ll;
388 mwpc_residualsz[i][0]->Fill(w->reco[0] - rextt.Y(), axis->GetBinCenter(k + 1));
389 mwpc_residualsz[i][1]->Fill(w->reco[1] - rextt.X(), axis->GetBinCenter(k + 1));
390
391 }
392 }
393 }
394
395 return retval;
396 }
TH2F * mwpc_xy[4]
calculated x-y track positions
TH1F * mwpc_residuals[4][2]
residuals from mwpcs
TH1F * mwpc_sum_cut[4][2]
tdc sum from mwpcs, with sum cut applied
TH2F * mwpc_residualsz[4][2]
z-residuals from mwpcs
TH1F * mwpc_diff[4][2]
tdc difference from mwpcs
TH1F * mwpc_sum[4][2]
tdc sum from mwpcs
TH1F * mwpc_tdc[4][5]
tdc information from mwpcs

◆ getTrackMeanEmissionPosition()

ROOT::Math::XYZVector getTrackMeanEmissionPosition ( const ARICHTrack track,
int  iAero 
)
private

Returns mean emission position of Cherenkov photons from i-th aerogel layer.

Definition at line 699 of file ARICHReconstruction.cc.

700 {
701 // Emission length measured from aerogel exit
702
703 ROOT::Math::XYZVector dir = track.getDirection();
704 if (dir.Z() == 0) return ROOT::Math::XYZVector();
705 double d = m_thickness[iAero] / dir.Z() / m_transmissionLen[iAero];
706 double dmean = 1 - d / expm1(d);
707 //double dmean = -log((1 + exp(-d)) / 2.);
708 double mel = dmean * m_transmissionLen[iAero];
709
710 return (getTrackPositionAtZ(track, m_zaero[iAero]) - mel * dir);
711 }
ROOT::Math::XYZVector getTrackPositionAtZ(const ARICHTrack &track, double zout)
Returns track direction at point with z coordinate "zout" (assumes straight track).

◆ getTrackPositionAtZ()

ROOT::Math::XYZVector getTrackPositionAtZ ( const ARICHTrack track,
double  zout 
)
private

Returns track direction at point with z coordinate "zout" (assumes straight track).

Definition at line 713 of file ARICHReconstruction.cc.

714 {
715 ROOT::Math::XYZVector dir = track.getDirection();
716 ROOT::Math::XYZVector pos = track.getPosition();
717 if (dir.Z() == 0) return ROOT::Math::XYZVector(0, 0, 0);
718 double path = (zout - pos.Z()) / dir.Z();
719 return pos + dir * path;
720 }

◆ HitsMirror()

bool HitsMirror ( const ROOT::Math::XYZVector &  pos,
const ROOT::Math::XYZVector &  dir,
int  mirrorID 
)
private

Returns true if photon at position pos with direction dir hits mirror plate with ID mirrorID.

Parameters
[in]posPhoton position.
[in]dirPhoton direction.
[in]mirrorIDID of mirror plate.

Definition at line 236 of file ARICHReconstruction.cc.

237 {
238
239 ROOT::Math::XYZVector mirnorm = m_mirrorNorms[mirrorID - 1];
240 ROOT::Math::XYZVector mirpoint = m_mirrorPoints[mirrorID - 1];
241 ROOT::Math::Rotation3D rot = TransformToFixed(mirnorm);
242 ROOT::Math::XYZVector dirTr = rot * dir;
243 if (dirTr.Z() < 0) return 0; // comes from outter side
244 ROOT::Math::XYZVector posTr = rot * (pos - mirpoint);
245 ROOT::Math::XYZVector pointOnMirr = posTr - (posTr.Z() / dirTr.Z()) * dirTr;
246 if (fabs(pointOnMirr.Y()) < m_arichgp->getMirrors().getPlateLength() / 2.
247 && fabs(pointOnMirr.X()) < m_arichgp->getMirrors().getPlateWidth() / 2.) return 1;
248
249 return 0;
250 }

◆ HitVirtualPosition()

ROOT::Math::XYZVector HitVirtualPosition ( const ROOT::Math::XYZVector &  hitpos,
int  mirrorID 
)
private

Returns the hit virtual position, assuming that it was reflected from mirror.

Parameters
[in]hitposVector of hit positions.
[in]mirrorIDId of mirror from which the photon was reflected.

Definition at line 226 of file ARICHReconstruction.cc.

227 {
228
229 if (mirrorID == 0) return hitpos;
230 ROOT::Math::XYZVector mirpoint = m_mirrorPoints[mirrorID - 1];
231 ROOT::Math::XYZVector mirnorm = m_mirrorNorms[mirrorID - 1];
232 return hitpos - 2 * ((hitpos - mirpoint).Dot(mirnorm)) * mirnorm;
233 }

◆ initialize() [1/13]

void initialize ( )

Read geometry parameters from xml and initialize class members.

Definition at line 59 of file ARICHReconstruction.cc.

60 {
61
62 for (const auto& part : Const::chargedStableSet) {
63 p_mass[part.getIndex()] = part.getMass();
64 }
65
66 m_nAerogelLayers = m_arichgp->getAerogelPlane().getNLayers();
68 for (unsigned int i = 0; i < m_nAerogelLayers; i++) {
69 m_refractiveInd[i] = m_arichgp->getAerogelPlane().getLayerRefIndex(i + 1);
70 m_anorm[i] = ROOT::Math::XYZVector(0, 0, 1);
71 m_thickness[i] = m_arichgp->getAerogelPlane().getLayerThickness(i + 1);
72 if (i == 0) m_zaero[i] = m_arichgp->getAerogelPlane().getAerogelZPosition() + m_thickness[i];
73 else m_zaero[i] = m_zaero[i - 1] + m_thickness[i];
74
75 m_transmissionLen[i] = m_arichgp->getAerogelPlane().getLayerTrLength(i + 1) ; // aerogel transmission length;
76
77 // measured FOM; aeroMerit is number of detected photons for beam of beta=1 and perpedicular incidence to aerogel tile
78 // (corrected for geometrical acceptance). n0[i] is then calculated from
79 // aeroMerit[i]=n0[i]*sin2(thc)*transmissionLen[i] * (1 - exp(-thickness[i] / transmissionLen[i])
80 m_n0[i] = m_recPars->getAerogelFOM(i) / ((1. - 1. / m_refractiveInd[i] / m_refractiveInd[i]) * m_transmissionLen[i] * (1 - exp(
83 }
85 m_refractiveInd[m_nAerogelLayers + 1] = m_arichgp->getHAPDGeometry().getWinRefIndex();
86 m_zaero[m_nAerogelLayers ] = m_arichgp->getDetectorZPosition();
87 m_zaero[m_nAerogelLayers + 1] = m_zaero[m_nAerogelLayers] + m_arichgp->getHAPDGeometry().getWinThickness();
88
89 if (m_mirrAlign.hasChanged()) {
90 m_mirrorNorms.clear();
91 m_mirrorPoints.clear();
92 for (unsigned i = 1; i < m_arichgp->getMirrors().getNMirrors() + 1; i++) {
93 m_mirrorNorms.push_back(getMirrorNorm(i));
94 m_mirrorPoints.push_back(getMirrorPoint(i));
95 }
96 }
97
98 if (m_tileAlign) {
99 if (m_tileAlign.hasChanged()) {
100 for (int iTile = 1; iTile < 125; iTile++) {
101 m_tilePars[iTile - 1][0] = m_tileAlign->getAlignmentElement(iTile).getAlpha();
102 m_tilePars[iTile - 1][1] = m_tileAlign->getAlignmentElement(iTile).getBeta();
103 }
104 }
105 }
106 }
OptionalDBObjPtr< ARICHAeroTilesAlignment > m_tileAlign
alignment of aerogel tiles from DB
static const ParticleSet chargedStableSet
set of charged stable particles
Definition: Const.h:618
ROOT::Math::XYZVector getMirrorNorm(int mirrorID)
Returns normal vector of the mirror plate with id mirrorID.
ROOT::Math::XYZVector getMirrorPoint(int mirrorID)
Returns point on the mirror plate with id mirrorID.

◆ initialize() [2/13]

void initialize ( void  )
overridevirtual

Initialize the Module.

Function is called only once at the beginning of your job at the beginning of the corresponding module. Things that can be done here, should be done here, as it is relatively cheap in terms of CPU time.

Reimplemented from Module.

Definition at line 93 of file arichBtestModule.cc.

94 {
95 B2INFO("arichBtestModule::initialize()");
96 StoreArray<ARICHAeroHit> aeroHits;
97 StoreArray<ARICHDigit> digits;
98 aeroHits.registerInDataStore();
99 digits.registerInDataStore();
100
101 m_file = new TFile(m_outFile.c_str(), "RECREATE");
102 m_tuple = new TNtuple("nt", "Btest data hits", "x:y:xrec:yrec:m:c:gx:gy");
103 char hapdName[256];
104 for (int i = 0; i < 6; i++) {
105 sprintf(hapdName, "hapd%d", i);
106 hapd[i] = new TH1F(hapdName, hapdName, 145, -0.5, 144.5);
107 }
108 char name[256];
109
110 for (int i = 0; i < 4; i++) {
111 for (int k = 0; k < 2; k++) {
112 sprintf(name, "mwpc%d_a%d_", i, k);
113 mwpc_diff[i][k] = new TH1F(strcat(name, "diff"), name, 300, -150, 150);
114 sprintf(name, "mwpc%d_a%d_", i, k);
115 mwpc_sum[i][k] = new TH1F(strcat(name, "sum"), name, 200, -0.5, 199.5);
116 sprintf(name, "mwpc%d_a%d_", i, k);
117 mwpc_sum_cut[i][k] = new TH1F(strcat(name, "sum_cut"), name, 200, -0.5, 199.5);
118 sprintf(name, "mwpc%d_a%d_", i, k);
119 mwpc_residuals[i][k] = new TH1F(strcat(name, "resd"), name, 200, -100, 100);
120 sprintf(name, "mwpc%d_a%d_", i, k);
121 mwpc_residualsz[i][k] = new TH2F(strcat(name, "resd_z"), name, 200, -25, 25, 400, -1000, 1000);
122 }
123 for (int k = 0; k < 5; k++) {
124 sprintf(name, "mwpc%d_a%d_", i, k);
125 mwpc_tdc[i][k] = new TH1F(strcat(name, "tdc"), name, 1024, -1024, 1024);
126 }
127 sprintf(name, "mwpc%d_", i);
128 mwpc_xy[i] = new TH2F(strcat(name, "xy"), name, 120, -30, 30, 120, -30, 30);
129 }
130 //m_hapdmap = new TGraph("arich/modules/arichBtest/geometry/hapd.map");
131 //m_el2pos = new TGraph("arich/modules/arichBtest/geometry/hapdchmap_v0.dat");
132
133 /*
134 arich::ARICHGeometryPar* _arichgp = arich::ARICHGeometryPar::Instance();
135
136 ofstream dout;
137 dout.open ("ChannelCenterGlob.txt");
138 for (int i=0;i<6;i++){
139 for (int k=0;k<144;k++){
140 ROOT::Math::XYZVector r = _arichgp->getChannelCenterGlob(i + 1, k);
141 dout << r.X() << " " << r.Y() << endl;
142 }
143 }
144 dout.close();
145 */
146 time(&m_timestart);
147 }
TH1F * hapd[6]
histogram of hits for each hapd
TNtuple * m_tuple
ntuple containing hapd hits

◆ initialize() [3/13]

void initialize ( void  )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 73 of file ARICHDigitizerModule.cc.

74 {
75 // QE at 400nm (3.1eV) applied in SensitiveDetector
76 m_maxQE = m_simPar->getQE(3.1);
77
78 m_ARICHSimHits.isRequired();
79 m_ARICHDigits.registerInDataStore();
80
81 m_bgOverlay = false;
82 StoreObjPtr<BackgroundInfo> bgInfo("", DataStore::c_Persistent);
83 if (bgInfo.isValid()) {
84 if (bgInfo->getMethod() == BackgroundInfo::c_Overlay) m_bgOverlay = true;
85 }
86
87 }
@ c_Persistent
Object is available during entire execution time.
Definition: DataStore.h:60

◆ initialize() [4/13]

void initialize ( void  )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

better use isRequired(), but RawFTSW is not in sim

Reimplemented from HistoModule.

Definition at line 160 of file ARICHDQMModule.cc.

161 {
162 REG_HISTOGRAM
163 // Only need the Tracks via relations, but since DQM is only really possible if the
164 // Tracks StoreArray is present, make it a requirement instead of optional.
165 StoreArray<Track> tracks;
166 tracks.isOptional();
167
168 m_arichHits.isRequired();
169 m_arichDigits.isOptional();
170 m_arichTracks.isOptional();
171 m_arichLikelihoods.isOptional();
172 m_rawFTSW.isOptional();
173 }

◆ initialize() [5/13]

void initialize ( void  )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 57 of file ARICHFillHitsModule.cc.

58 {
59
60 StoreArray<ARICHDigit> digits;
61 digits.isRequired();
62
63 StoreArray<ARICHHit> arichHits;
64 arichHits.registerInDataStore();
65
66 arichHits.registerRelationTo(digits);
67 }

◆ initialize() [6/13]

void initialize ( void  )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 52 of file ARICHMCParticlesModule.cc.

54 {
55 // Dependecies check
56 m_tracks.isRequired();
57 m_extHits.isRequired();
58
60 m_tracks.registerRelationTo(m_arichMCPs);
61
62 }
StoreArray< ExtHit > m_extHits
Required input array of ExtHits.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.

◆ initialize() [7/13]

void initialize ( void  )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 69 of file ARICHNtupleModule.cc.

70 {
71
72 if (m_file) delete m_file;
73 m_file = new TFile(m_outputFile.c_str(), "RECREATE");
74 if (m_file->IsZombie()) {
75 B2FATAL("Couldn't open file '" << m_outputFile << "' for writing!");
76 return;
77 }
78
79 m_tree = new TTree("arich", "ARICH validation ntuple");
80
81 m_tree->Branch("evt", &m_arich.evt, "evt/I");
82 m_tree->Branch("run", &m_arich.run, "run/I");
83 m_tree->Branch("exp", &m_arich.exp, "exp/I");
84
85 m_tree->Branch("charge", &m_arich.charge, "charge/S");
86 m_tree->Branch("pValue", &m_arich.pValue, "pValue/F");
87 m_tree->Branch("d0", &m_arich.z0, "d0/F");
88 m_tree->Branch("z0", &m_arich.d0, "z0/F");
89
90#ifdef ALIGNMENT_USING_BHABHA
91 m_tree->Branch("eop", &m_arich.eop, "eop/F");
92 m_tree->Branch("e9e21", &m_arich.e9e21, "e9e21/F");
93 m_tree->Branch("etot", &m_arich.etot, "etot/F");
94#endif
95
96 m_tree->Branch("PDG", &m_arich.PDG, "PDG/I");
97 m_tree->Branch("motherPDG", &m_arich.motherPDG, "motherPDG/I");
98 m_tree->Branch("primary", &m_arich.primary, "primary/S");
99 m_tree->Branch("seen", &m_arich.seen, "seen/S");
100 m_tree->Branch("scatter", &m_arich.scatter, "scatter/I");
101
102 m_tree->Branch("rhoProd", &m_arich.rhoProd, "rhoProd/F");
103 m_tree->Branch("zProd", &m_arich.zProd, "zProd/F");
104 m_tree->Branch("phiProd", &m_arich.phiProd, "phiProd/F");
105 m_tree->Branch("rhoDec", &m_arich.rhoDec, "rhoDec/F");
106 m_tree->Branch("zDec", &m_arich.zDec, "zDec/F");
107 m_tree->Branch("phiDec", &m_arich.phiDec, "phiDec/F");
108 m_tree->Branch("status", &m_arich.status, "status/I");
109
110 m_tree->Branch("detPhot", &m_arich.detPhot, "detPhot/I");
111 m_tree->Branch("numBkg", &m_arich.numBkg, "e/F:mu:pi:K:p:d");
112 m_tree->Branch("expPhot", &m_arich.expPhot, "e/F:mu:pi:K:p:d");
113 m_tree->Branch("logL", &m_arich.logL, "e/F:mu:pi:K:p:d");
114
115 m_tree->Branch("recHit", &m_arich.recHit, "PDG/I:x/F:y:z:p:theta:phi");
116 m_tree->Branch("mcHit", &m_arich.mcHit, "PDG/I:x/F:y:z:p:theta:phi");
117 m_tree->Branch("winHit", &m_arich.winHit, "x/F:y");
118 m_tree->Branch("nrec", &m_arich.nRec, "nRec/I");
119 m_tree->Branch("nCDC", &m_arich.nCDC, "nCDC/I");
120 m_tree->Branch("inAcceptance", &m_arich.inAcc, "inAcc/O");
121 m_tree->Branch("photons", "std::vector<Belle2::ARICHPhoton>", &m_arich.photons);
122
123 // required input
124 m_arichTracks.isRequired();
125 m_arichLikelihoods.isRequired();
126
127 // optional input
128 m_tracks.isOptional();
130 m_arichAeroHits.isOptional();
131 m_arichInfo.isOptional();
132
133 StoreArray<ARICHHit> arichHits;
134 arichHits.isRequired();
135
136 }
StoreArray< ARICHAeroHit > m_arichAeroHits
Optional input array of ARICHAeroHits.
StoreArray< MCParticle > m_arichMCPs
Optional input array of MCParticles.
StoreArray< ARICHLikelihood > m_arichLikelihoods
Required array of input ARICHLikelihoods.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
ParticlesArray numBkg
Number of expected background photons.

◆ initialize() [8/13]

void initialize ( void  )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 66 of file ARICHPackerModule.cc.

67 {
68
69 StoreArray<ARICHDigit> digits(m_inputDigitsName);
70 digits.isRequired();
71
72 StoreArray<RawARICH> rawData(m_outputRawDataName);
73 rawData.registerInDataStore();
74 }

◆ initialize() [9/13]

void initialize ( void  )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from HistoModule.

Definition at line 93 of file ARICHRateCalModule.cc.

94 {
95
96 REG_HISTOGRAM
97 StoreArray<ARICHRawDigit> rawdata;
98 rawdata.isRequired();
99 //StoreArray<RawARICH> rawdata;
100 //rawdata.isRequired();
101 }

◆ initialize() [10/13]

void initialize ( void  )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from HistoModule.

Definition at line 53 of file ARICHRawUnpackerModule.cc.

54 {
55 REG_HISTOGRAM;
56 StoreArray<RawARICH> rawdata;
57 rawdata.isRequired();
58 StoreArray<ARICHRawDigit> rawdigit;
59 rawdigit.registerInDataStore();
60 }

◆ initialize() [11/13]

void initialize ( void  )
overridevirtual

Initialize the Module.

Reimplemented from Module.

Definition at line 74 of file ARICHReconstructorModule.cc.

75 {
76 // Initialize variables
77 if (m_ana) delete m_ana;
78 m_ana = new ARICHReconstruction(m_storePhot);
82
83 // Input: ARICHDigits
84 m_ARICHHits.isRequired();
85
86 m_Tracks.isOptional();
87 m_ExtHits.isOptional();
88 m_aeroHits.isOptional();
89
90 if (!m_aeroHits.isOptional()) {
91 m_Tracks.isRequired();
92 m_ExtHits.isRequired();
93 }
94
95 StoreArray<MCParticle> MCParticles;
96 MCParticles.isOptional();
97
98 // Output - log likelihoods
99 m_ARICHLikelihoods.registerInDataStore();
100
101 m_ARICHTracks.registerInDataStore();
102
103 if (m_inputTrackType) m_ARICHTracks.registerRelationTo(m_ARICHLikelihoods);
104 else {
105 m_ARICHTracks.registerRelationTo(m_ExtHits);
106 m_Tracks.registerRelationTo(m_ARICHLikelihoods);
107 }
108 //m_ARICHTracks.registerInDataStore(DataStore::c_DontWriteOut);
109 //m_ARICHTracks.registerRelationTo(m_ARICHLikelihoods, DataStore::c_Event, DataStore::c_DontWriteOut);
110 m_ARICHTracks.registerRelationTo(m_aeroHits);
112 }
void useMirrorAlignment(bool align)
Use mirror alignment or not.
StoreArray< ExtHit > m_ExtHits
Extrapolation hits.
void setTrackPositionResolution(double pRes)
Sets track position resolution (from tracking).
void setTrackAngleResolution(double aRes)
Sets track direction resolution (from tracking).
void printModuleParams()
Print module parameters.

◆ initialize() [12/13]

void initialize ( void  )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 49 of file ARICHRelateModule.cc.

51 {
52 // Dependecies check
54 m_mdstTracks.isRequired();
55 m_aeroHits.isRequired();
56 m_extHits.isRequired();
57 m_extHits.registerRelationTo(m_aeroHits);
58 }
StoreArray< Track > m_mdstTracks
Required array of input Tracks.
StoreArray< ExtHit > m_extHits
Required array of input ExtHits.
StoreArray< MCParticle > m_mcParticles
Required array of input MCParticles.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.

◆ initialize() [13/13]

void initialize ( void  )
overridevirtual

Initialize the Module.

This method is called at the beginning of data processing.

Reimplemented from Module.

Definition at line 73 of file ARICHUnpackerModule.cc.

74 {
75
76 StoreArray<RawARICH> rawData(m_inputRawDataName);
77 rawData.isRequired();
78
79 StoreArray<ARICHDigit> digits(m_outputDigitsName);
80 digits.registerInDataStore();
81
82 StoreArray<ARICHRawDigit> rawdigits(m_outputRawDigitsName);
83 rawdigits.registerInDataStore();
84
85 StoreObjPtr<ARICHInfo> arichinfo(m_outputarichinfoName);
86 arichinfo.registerInDataStore();
87
88 }

◆ InsideDetector()

int InsideDetector ( ROOT::Math::XYZVector  a,
int  copyno 
)
private

Returns 1 if vector "a" lies on "copyno"-th detector active surface of detector and 0 else.

Definition at line 109 of file ARICHReconstruction.cc.

110 {
111 if (copyno == -1) return 0;
112 ROOT::Math::XYVector origin;
113 origin.SetXY(m_arichgp->getDetectorPlane().getSlotR(copyno) * std::cos(m_arichgp->getDetectorPlane().getSlotPhi(copyno)),
114 m_arichgp->getDetectorPlane().getSlotR(copyno) * std::sin(m_arichgp->getDetectorPlane().getSlotPhi(copyno)));
115 ROOT::Math::XYVector a2(a);
116 double phi = m_arichgp->getDetectorPlane().getSlotPhi(copyno);
117 ROOT::Math::XYVector diff = a2 - origin;
118 diff.Rotate(-phi);
119 const double size = m_arichgp->getHAPDGeometry().getAPDSizeX();
120 if (fabs(diff.X()) < size / 2. && fabs(diff.Y()) < size / 2.) {
121 int chX, chY;
122 m_arichgp->getHAPDGeometry().getXYChannel(diff.X(), diff.Y(), chX, chY);
123 if (chX < 0 || chY < 0) return 0;
124 int asicChannel = m_chnMap->getAsicFromXY(chX, chY);
125 // eliminate un-active channels
126 if (asicChannel < 0 || !m_chnMask->isActive(copyno, asicChannel)) return 0;
127 return 1;
128 }
129 return 0;
130 }
DBObjPtr< ARICHChannelMapping > m_chnMap
map x,y channels to asic channels from the DB

◆ likelihood2()

int likelihood2 ( ARICHTrack arichTrack,
const StoreArray< ARICHHit > &  arichHits,
ARICHLikelihood arichLikelihood 
)

Computes the value of identity likelihood function for different particle hypotheses.

Definition at line 349 of file ARICHReconstruction.cc.

351 {
352
353 const unsigned int nPhotonHits = arichHits.getEntries(); // number of detected photons
354
355 if (m_nAerogelLayers + 1 > c_noOfAerogels) B2ERROR("ARICHReconstrucion: number of aerogel layers defined in the xml file exceeds "
356 << c_noOfAerogels);
357
358 double logL[c_noOfHypotheses] = {0.0};
359 double nSig_w_acc[c_noOfHypotheses][c_noOfAerogels] = { {0.0} }; // expected no. of signal photons, including geometrical acceptance
360 double nSig_wo_acc[c_noOfHypotheses][c_noOfAerogels][20] = { { {0.0} } }; // expected no. of signal photons, without geometrical acceptance, divided in 20 phi bins (used for PDF normalization)
361 double nSig_wo_accInt[c_noOfHypotheses][c_noOfAerogels] = { {0.0} }; // expected no. of signal photons, without geometrical acceptance, integrated over phi
362 double esigi[c_noOfHypotheses] = {0.0}; // expected number of signal photons in hit pixel
363 double thetaCh[c_noOfHypotheses][c_noOfAerogels] = { {0.0} }; // expected Cherenkov angle
364
365 // read some geometry parameters
366 double padSize = m_arichgp->getHAPDGeometry().getPadSize();
367 int nMirSeg = m_arichgp->getMirrors().getNMirrors();
368 double angmir = m_arichgp->getMirrors().getStartAngle();
369
370 // Detected photons in cherenkov ring (integrated over 0.1<theta<0.5)
371 int nDetPhotons = 0;
372
373 double ebgri[c_noOfHypotheses] = {0.0}; // number of expected background photons per pad
374 double nBgr[c_noOfHypotheses] = {0.0}; // total number of expected background photons (in 0.1-0.5 rad ring)
375
376 // reconstructed track direction
377 ROOT::Math::XYZVector edir = arichTrack.getDirection();
378 if (edir.Z() < 0) return 0;
379 double momentum = arichTrack.getMomentum();
380
381 double thcResolution = m_recPars->getThcResolution(momentum);
382 if (thcResolution < 0) thcResolution = 0.01; // happens for spurious tracks with 100 GeV momentum!
383
384 double wideGaussFract = (m_recPars->getParameters())[0];
385 double wideGaussSigma = (m_recPars->getParameters())[1];
386
387 unsigned tileID = m_arichgp->getAerogelPlane().getAerogelTileID(arichTrack.getPosition().X(), arichTrack.getPosition().Y());
388 double r = arichTrack.getPosition().Rho();
389 if (tileID > 0) correctEmissionPoint(tileID, r);
390
391 //------------------------------------------------------
392 // Calculate number of expected detected photons (emmited x geometrical acceptance).
393 // -----------------------------------------------------
394
395 float nphot_scaling = 20.; // number of photons to be traced is (expected number of emitted photons * nphot_scaling)
396 int nStep = 5; // number of steps in one aerogel layer
397
398 // loop over all particle hypotheses
399 for (int iHyp = 0; iHyp < c_noOfHypotheses; iHyp++) {
400
401 // absorbtion factor (scattering)
402 double abs = 1;
403
404 // loop over aerogel layers
405 for (int iAerogel = m_nAerogelLayers - 1; iAerogel >= 0; iAerogel--) {
406
407 thetaCh[iHyp][iAerogel] = ExpectedCherenkovAngle(momentum,
408 p_mass[iHyp],
409 m_refractiveInd[iAerogel]);
410
411 // track length in the radiator
412 double pathLengthRadiator = arichTrack.getDirection().Dot(m_anorm[iAerogel]);
413 if (pathLengthRadiator) pathLengthRadiator = m_thickness[iAerogel] / pathLengthRadiator;
414
415 // step length
416 double dxx = pathLengthRadiator / double(nStep);
417 // number of photons to be emmited per step (number of expected photons * nphot_scaling)
418 double nPhot = m_n0[iAerogel] * sin(thetaCh[iHyp][iAerogel]) * sin(thetaCh[iHyp][iAerogel]) * dxx * nphot_scaling;
419 ROOT::Math::XYZVector exit_point = getTrackPositionAtZ(arichTrack, m_zaero[iAerogel]);
420
421 // loop over emmision point steps
422 for (int iepoint = 0; iepoint < nStep; iepoint++) {
423
424 ROOT::Math::XYZVector epoint = exit_point - (0.5 + iepoint) * dxx * edir;
425 abs *= exp(-dxx / m_transmissionLen[iAerogel]);
426 unsigned int genPhot = nPhot * abs; // number of photons to emmit in current step, including scattering correction
427
428 // loop over emmited "photons"
429 for (unsigned int iPhoton = 0; iPhoton < genPhot; iPhoton++) {
430 double fi = 2 * M_PI * iPhoton / float(genPhot); // uniformly distributed in phi
431 ROOT::Math::XYZVector adirf = setThetaPhi(thetaCh[iHyp][iAerogel], fi); // photon direction in track system
432 adirf = TransformFromFixed(edir) * adirf; // photon direction in global system
433 int ifi = int (fi * 20 / 2. / M_PI); // phi bin
434 // track photon from emission point to the detector plane
435 ROOT::Math::XYZVector dposition = FastTracking(adirf, epoint, &m_refractiveInd[iAerogel], &m_zaero[iAerogel],
436 m_nAerogelLayers - iAerogel, 1);
437 if (dposition.R() > 1.0) {nSig_wo_acc[iHyp][iAerogel][ifi] += 1; nSig_wo_accInt[iHyp][iAerogel] += 1;}
438 else continue;
439 unsigned copyno = m_arichgp->getDetectorPlane().pointSlotID(dposition.X(), dposition.Y());
440 if (!copyno) continue;
441 // check if photon fell on photosensitive area
442 if (InsideDetector(dposition, copyno)) nSig_w_acc[iHyp][iAerogel] += 1;
443 }
444 }
445
446 // scale the obtained numbers
447 for (int ik = 0; ik < 20; ik++) {
448 nSig_wo_acc[iHyp][iAerogel][ik] /= nphot_scaling;
449 }
450 nSig_w_acc[iHyp][iAerogel] /= nphot_scaling;
451 nSig_wo_accInt[iHyp][iAerogel] /= nphot_scaling;
452 } // for (unsigned int iAerogel=0;iAerogel<m_nAerogelLayers;iAerogel++)
453
454 // sum up contribution from all aerogel layers
455 for (unsigned int iAerogel = 0; iAerogel < m_nAerogelLayers; iAerogel++) {
456 nSig_w_acc[iHyp][m_nAerogelLayers] += nSig_w_acc[iHyp][iAerogel];
457 nSig_wo_accInt[iHyp][m_nAerogelLayers] += nSig_wo_accInt[iHyp][iAerogel];
458
459 for (int ik = 0; ik < 20; ik++) {
460 nSig_wo_acc[iHyp][m_nAerogelLayers][ik] += nSig_wo_acc[iHyp][iAerogel][ik];
461 }
462 }
463
464 // get number of expected background photons in ring (integrated from 0.1 to 0.5 rad)
465 std::vector<double> bkgPars = {momentum / sqrt(p_mass[iHyp]*p_mass[iHyp] + momentum * momentum), double(arichTrack.hitsWindow())};
466 nBgr[iHyp] = m_recPars->getExpectedBackgroundHits(bkgPars);
467
468 } // for (int iHyp=0;iHyp < c_noOfHypotheses; iHyp++ )
469 //#####################################################
470
471 ROOT::Math::XYZVector track_at_detector = getTrackPositionAtZ(arichTrack, m_zaero[m_nAerogelLayers + 1]);
472
473 // the id numbers of mirrors from which the photons could possibly reflect are calculated
474 int mirrors[3];
475 mirrors[0] = 0; // for no reflection
476 int refl = 1;
477
478 // only if particle track on detector is at radius larger than 850mm (for now hardcoded)
479 // possible reflections are taken into account.
480 if (track_at_detector.Rho() > 85.0) {
481 double trackang = track_at_detector.Phi() - angmir;
482 if (trackang < 0) trackang += 2 * M_PI;
483 if (trackang > 2 * M_PI) trackang -= 2 * M_PI;
484 int section1 = int(trackang * nMirSeg / 2. / M_PI) + 1;
485 int section2 = section1 + 1;
486 if (section1 == nMirSeg) section2 = 1;
487 mirrors[1] = section1; mirrors[2] = section2;
488 refl = 3;
489 }
490
491 // loop over all detected photon hits
492
493 for (unsigned int iPhoton = 0; iPhoton < nPhotonHits; iPhoton++) {
494
495 ARICHHit* h = arichHits[iPhoton];
496 int modID = h->getModule();
497 int channel = h->getChannel();
498 ROOT::Math::XYZVector hitpos = m_arichgp->getMasterVolume().pointToLocal(h->getPosition());
499 bool bkgAdded = false;
500 int nfoo = nDetPhotons;
501 for (int iHyp = 0; iHyp < c_noOfHypotheses; iHyp++) { esigi[iHyp] = 0; ebgri[iHyp] = 0;}
502
503 bool reflOK = true; // remove window photons from reflected hypothesis
504
505 // loop over possible mirror reflections
506 for (int mirr = 0; mirr < refl; mirr++) {
507
508 if (!reflOK) break; // photon from window so break
509
510 // calculate fi_ch for a given track refl
511 ROOT::Math::XYZVector virthitpos = HitVirtualPosition(hitpos, mirrors[mirr]);
512
513 // if hit is more than 25cm from the track position on the detector plane, skip it.
514 // (not reconstructing hits with irrelevantly large Cherenkov angle)
515 if ((track_at_detector - virthitpos).R() > 25.0) continue;
516
517 double sigExpArr[c_noOfHypotheses] = {0.0}; // esigi for given mirror hypothesis only
518 double th_cer_all[c_noOfAerogels] = {0.0};
519 double fi_cer_all[c_noOfAerogels] = {0.0};
520
521 double weight[c_noOfHypotheses][c_noOfAerogels] = { {0.0} };
522 double weight_sum[c_noOfHypotheses] = {0.0};
523 int proc = 0;
524 double fi_cer_trk = 0.;
525
526 // loop over all aerogel layers
527 for (unsigned int iAerogel = 0; iAerogel < m_nAerogelLayers; iAerogel++) {
528
529 ROOT::Math::XYZVector initialrf = getTrackPositionAtZ(arichTrack, m_zaero[iAerogel]);
530 ROOT::Math::XYZVector epoint = getTrackMeanEmissionPosition(arichTrack, iAerogel);
531 ROOT::Math::XYZVector edirr = arichTrack.getDirection();
532 ROOT::Math::XYZVector photonDirection; // calculated photon direction
533
534 if (CherenkovPhoton(epoint, virthitpos, initialrf, photonDirection, &m_refractiveInd[iAerogel], &m_zaero[iAerogel],
535 m_nAerogelLayers - iAerogel, mirrors[mirr]) < 0) break;
536
537 ROOT::Math::XYZVector dirch = TransformToFixed(edirr) * photonDirection;
538 double fi_cer = dirch.Phi();
539 double th_cer = dirch.Theta();
540
541
542 th_cer_all[iAerogel] = th_cer;
543 fi_cer_all[iAerogel] = fi_cer;
544 auto deltaPhi = dirch.Phi() - edir.Phi();
545 if (deltaPhi > M_PI)
546 deltaPhi -= 2 * M_PI;
547 if (deltaPhi < -M_PI)
548 deltaPhi += 2 * M_PI;
549 fi_cer_trk = deltaPhi;
550
551 if (mirr == 0 && th_cer < 0.1) reflOK = false;
552 // skip photons with irrelevantly large/small Cherenkov angle
553 if (th_cer > 0.5 || th_cer < 0.1) continue;
554
555 // count photons with 0.1<thc<0.5
556 if (nfoo == nDetPhotons) nDetPhotons++;
557
558 if (fi_cer < 0) fi_cer += 2 * M_PI;
559 double fii = fi_cer;
560 if (mirr > 0) {
561 double fi_mir = m_mirrorNorms[mirrors[mirr] - 1].Phi();
562 fii = 2 * fi_mir - fi_cer - M_PI;
563 }
564
565
566 // loop over all particle hypotheses
567 for (int iHyp = 0; iHyp < c_noOfHypotheses; iHyp++) {
568
569 // track a photon from the mean emission point to the detector surface
570 ROOT::Math::XYZVector photonDirection1 = setThetaPhi(thetaCh[iHyp][iAerogel], fi_cer); // particle system
571 photonDirection1 = TransformFromFixed(edirr) * photonDirection1; // global system
572 int ifi = int (fi_cer * 20 / 2. / M_PI);
573 ROOT::Math::XYZVector detector_position;
574
575 detector_position = FastTracking(photonDirection1, epoint, &m_refractiveInd[iAerogel], &m_zaero[iAerogel],
576 m_nAerogelLayers - iAerogel, 0);
577
578 ROOT::Math::XYZVector meanr = detector_position - epoint;
579 double path = meanr.R();
580 meanr = meanr.Unit();
581
582 double meanpath = (m_recPars->getParameters())[2];
583 if (iAerogel == 1) meanpath = meanpath - m_thickness[iAerogel];
584
585 double detector_sigma = thcResolution * meanpath / meanr.Z();
586 double wide_sigma = wideGaussSigma * path / meanr.Z();
587 // calculate pad orientation and distance relative to that photon
588 double modphi = m_arichgp->getDetectorPlane().getSlotPhi(modID);
589
590 double pad_fi = fii - modphi;
591 double dx = (detector_position - hitpos).R();
592 double dr = (track_at_detector - detector_position).R();
593
594 if (dr > 0.01) {
595 double normalizacija = nSig_wo_acc[iHyp][iAerogel][ifi] * padSize / (0.1 * M_PI * dr * meanr.Z());
596 weight[iHyp][iAerogel] = normalizacija;
597 weight_sum[iHyp] += weight[iHyp][iAerogel];
598 double integralMain = SquareInt(padSize, pad_fi, dx, detector_sigma) / sqrt(2.);
599 double integralWide = SquareInt(padSize, pad_fi, dx, wide_sigma) / sqrt(2.);
600 // expected number of signal photons in each pixel
601 double exp = normalizacija * ((1 - wideGaussFract) * integralMain + wideGaussFract * integralWide);
602 esigi[iHyp] += exp;
603 sigExpArr[iHyp] += exp;
604 } // if (dr>0 && thetaCh[iHyp][iAerogel])
605
606 }// for (int iHyp=0;iHyp< c_noOfHypotheses; iHyp++)
607 if (iAerogel == m_nAerogelLayers - 1) proc = 1; // successfully processed for all layers
608 }// for (unsigned int iAerogel=0; iAerogel<m_nAerogelLayers;iAerogel++)
609
610 if (proc) {
611 // add background contribution if not yet (add only once)
612 if (!bkgAdded) {
613 for (int iHyp = 0; iHyp < c_noOfHypotheses; iHyp++) {
614 std::vector<double> pars = {momentum / sqrt(p_mass[iHyp]*p_mass[iHyp] + momentum * momentum), double(arichTrack.hitsWindow())};
615 ebgri[iHyp] += m_recPars->getBackgroundPerPad(th_cer_all[1], pars);
616 }
617 bkgAdded = true;
618 }
619 }
620 // create ARICHPhoton if desired
621 if (m_storePhot && th_cer_all[1] > 0 && th_cer_all[1] < 0.6) {
622 double n_cos_theta_ch[c_noOfHypotheses] = {0.0};
623 double phi_ch[c_noOfHypotheses] = {0.0};
624 for (int iHyp = 0; iHyp < c_noOfHypotheses; iHyp++) {
625 if (weight_sum[iHyp] > 0) {
626 for (unsigned int iAerogel = 0; iAerogel < m_nAerogelLayers; iAerogel++) {
627 double emission_prob = weight[iHyp][iAerogel] / weight_sum[iHyp];
628 n_cos_theta_ch[iHyp] += emission_prob * m_refractiveInd[iAerogel] * cos(th_cer_all[iAerogel]);
629 phi_ch[iHyp] += emission_prob * fi_cer_all[iAerogel];
630 }
631 //std::cout << iHyp << " " << n_cos_theta_ch[iHyp] << " " << phi_ch[iHyp] << std::endl;
632 } else {
633 n_cos_theta_ch[iHyp] = -99999.;
634 phi_ch[iHyp] = -99999.;
635 }
636 }
637 ARICHPhoton phot(iPhoton, th_cer_all[1], fi_cer_all[1], mirrors[mirr]); // th_cer of the first aerogel layer assumption is stored
638 phot.setBkgExp(ebgri); // store expected number of background hits
639 phot.setSigExp(sigExpArr); // store expected number of signal hits
640 phot.setPhiCerTrk(fi_cer_trk); // store phi angle in track coordinates
641 phot.setNCosThetaCh(n_cos_theta_ch); // store n cos(theta_th) for all particle hypotheses
642 phot.setPhiCh(phi_ch); // store phi_ch for all particle hypotheses
643 phot.setXY(hitpos.X(), hitpos.Y()); // store x-y hit position
644 phot.setModuleID(modID); // store module id
645 phot.setChannel(channel); // store channel
646 arichTrack.addPhoton(phot);
647 }
648
649
650 }// for (int mirr = 0; mirr < refl; mirr++)
651
652 //******************************************
653 // LIKELIHOOD construction
654 //*******************************************
655
656 for (int iHyp = 0; iHyp < c_noOfHypotheses; iHyp++) {
657 double expected = esigi[iHyp] + ebgri[iHyp];
658 if (bkgAdded) logL[iHyp] += expected + log(1 - exp(-expected));
659 }
660
661 } // for (unsigned int iPhoton=0; iPhoton< nPhotonHits; iPhoton++)
662
663 //*********************************************
664 // add constant term to the LIKELIHOOD function
665 //*********************************************
666 double exppho[c_noOfHypotheses] = {0.0};
667 for (int iHyp = 0; iHyp < c_noOfHypotheses; iHyp++) {
668 exppho[iHyp] = nSig_w_acc[iHyp][m_nAerogelLayers] * (1 - wideGaussFract) + wideGaussFract * 0.7 *
669 nSig_wo_accInt[iHyp][m_nAerogelLayers] + nBgr[iHyp];
670 logL[iHyp] -= exppho[iHyp];
671 if (isnan(logL[iHyp]) || isinf(logL[iHyp])) {
672 B2WARNING("ARICHReconstruction: log likelihood value infinite! Flat background hit probability is " << ebgri[iHyp] << "!");
673 logL[iHyp] = 0;
674 }
675 }
676
677 //******************************************
678 // store LikeliHOOD info
679 //******************************************
680
681 int flag = 1;
682 if ((thetaCh[0][0] > 0 || thetaCh[0][1] > 0) && nSig_w_acc[0][m_nAerogelLayers] == 0) flag = 0;
683
684 // set values of ARICHLikelihood
685 arichLikelihood.setValues(flag, logL, nDetPhotons, exppho);
686
687 return 1;
688 }
double R
typedef autogenerated by FFTW
ROOT::Math::XYZVector FastTracking(ROOT::Math::XYZVector dirf, ROOT::Math::XYZVector r, double *refind, double *z, int n, int opt)
Calculates the intersection of the Cherenkov photon emitted from point "r" in "dirf" direction with t...
int CherenkovPhoton(ROOT::Math::XYZVector r, ROOT::Math::XYZVector rh, ROOT::Math::XYZVector &rf, ROOT::Math::XYZVector &dirf, double *refind, double *z, int n, int mirrorID=0)
Calculates the direction of photon emission.
ROOT::Math::XYZVector HitVirtualPosition(const ROOT::Math::XYZVector &hitpos, int mirrorID)
Returns the hit virtual position, assuming that it was reflected from mirror.
void correctEmissionPoint(int tileID, double r)
Correct mean emission point z position.
int InsideDetector(ROOT::Math::XYZVector a, int copyno)
Returns 1 if vector "a" lies on "copyno"-th detector active surface of detector and 0 else.
ROOT::Math::XYZVector getTrackMeanEmissionPosition(const ARICHTrack &track, int iAero)
Returns mean emission position of Cherenkov photons from i-th aerogel layer.
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28

◆ magFieldCorrection()

void magFieldCorrection ( ROOT::Math::XYZVector &  hitpos)

Corrects hit position for distorsion due to non-perpendicular magnetic field component.

Definition at line 155 of file ARICHFillHitsModule.cc.

156 {
157 ROOT::Math::XYZVector Bfield = BFieldManager::getField(hitpos);
158 ROOT::Math::XYZVector shift = m_geoPar->getHAPDGeometry().getPhotocathodeApdDistance() / abs(Bfield.Z()) * Bfield;
159 hitpos.SetX(hitpos.X() - shift.X());
160 hitpos.SetY(hitpos.Y() - shift.Y());
161 }
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
Definition: BFieldManager.h:91

◆ magFieldDistorsion()

void magFieldDistorsion ( ROOT::Math::XYVector &  hit,
int  copyno 
)

Apply correction to hit position due to non-perpendicular component of magnetic field.

Parameters
hitlocal position of simhit
copynocopy number of hapd

Definition at line 190 of file ARICHDigitizerModule.cc.

191 {
192
193 ROOT::Math::XYVector hitGlob;
194 double phi = m_geoPar->getDetectorPlane().getSlotPhi(copyno);
195 double r = m_geoPar->getDetectorPlane().getSlotR(copyno);
196 double z = m_geoPar->getDetectorZPosition() + m_geoPar->getHAPDGeometry().getWinThickness();
197 hitGlob.SetXY(r * std::cos(phi), r * std::sin(phi));
198 ROOT::Math::XYVector shift = hit;
199 shift.Rotate(phi);
200 hitGlob += shift;
201 ROOT::Math::XYZVector Bfield = BFieldManager::getField(m_geoPar->getMasterVolume().pointToGlobal(ROOT::Math::XYZVector(hitGlob.X(),
202 hitGlob.Y(), z)));
203 double cc = m_geoPar->getHAPDGeometry().getPhotocathodeApdDistance() / abs(Bfield.Z());
204 shift.SetX(cc * Bfield.X());
205 shift.SetY(cc * Bfield.Y());
206 shift.Rotate(phi);
207 hit.SetX(hit.X() + shift.X());
208 hit.SetY(hit.Y() + shift.Y());
209 }

◆ mergerClusterHitMap1D()

TH1 * mergerClusterHitMap1D ( TH1 *  hitMap,
int  mergerID 
)

Make 1D hit map of specified Merger Board.

Parameters
hitMap1D hit map of all channels.
mergerIDMerger board identifier [1:72].
Returns
1D hit map of the merger board.

Definition at line 95 of file hitMapMaker.cc.

96 {
97
98 int m_mergerID = mergerID;
99
100 DBObjPtr<ARICHChannelMapping> arichChMap;
101 DBObjPtr<ARICHMergerMapping> arichMergerMap;
102
103 TH1* m_hitMap = hitMap;
104
105 std::vector<int> moduleIDs;
106 for (int i = 1; i < 7; i++) {
107 moduleIDs.push_back(arichMergerMap->getModuleID(m_mergerID, i));
108 }
109
110 TH1D* m_mergerHitMap1D = new TH1D("MergerHitMap1D", Form("Hit map in Merger Board %d", m_mergerID), 144 * 6, -0.5, 144 * 6 - 0.5);
111 for (int i = 1; i < 7; i++) {
112 for (int j = 0; j < 144; j++) {
113 int hitsNum = m_hitMap->GetBinContent((moduleIDs[i] - 1) * 144 + i);
114 m_mergerHitMap1D->Fill(144 * (i - 1) + j, hitsNum);
115 }
116 }
117 return m_mergerHitMap1D;
118 }

◆ mergerClusterHitMap2D()

TCanvas * mergerClusterHitMap2D ( TH1 *  hitMap,
int  mergerID 
)

Make display of 6 HAPDs' 2D hit map of the Merger Board.

Parameters
hitMap1D hit map of all channels.
mergerIDMerger board identifier [1:72].
Returns
Display of 6 HAPDs' 2D hit map.

Definition at line 120 of file hitMapMaker.cc.

121 {
122 int m_mergerID = mergerID;
123
124 DBObjPtr<ARICHChannelMapping> arichChMap;
125 DBObjPtr<ARICHMergerMapping> arichMergerMap;
126
127 TH1* m_hitMap = hitMap;
128
129
130 std::vector<int> moduleIDs;
131 for (int i = 1; i < 7; i++) {
132 moduleIDs.push_back(arichMergerMap->getModuleID(m_mergerID, i));
133 }
134
135 TCanvas* m_mergerHitMap = new TCanvas("MergerHitMap", "Hit map in Merger Board", 600, 400);
136 m_mergerHitMap->Divide(3, 2);
137 for (int i = 1; i < 7; i++) {
138 m_mergerHitMap->cd(i);
139 moduleHitMap(m_hitMap, moduleIDs[i])->Draw("coloz");
140 }
141 return m_mergerHitMap;
142 }
TH2 * moduleHitMap(TH1 *hitMap, int moduleID)
Make hit map in HAPD view (12*12 channels).
Definition: hitMapMaker.cc:38

◆ moduleDeadMap()

TH2 * moduleDeadMap ( TH1 *  hitMap,
int  moduleID 
)

Make chip dead/alive map in HAPD view (2*2 chips).

Parameters
hitMap1D hit map of all channels.
moduleIDModule identifier [1:420].
Returns
2D dead/alive map on HAPD.

Definition at line 62 of file hitMapMaker.cc.

63 {
64 int m_moduleID = moduleID;
65
66 DBObjPtr<ARICHChannelMapping> arichChMap;
67
68 TH2* m_moduleDeadMap = new TH2D(Form("HAPDDeadMapMod%d", moduleID), Form("HAPD alive/dead module %d;nChX;nChY", moduleID), 2, 0.5,
69 2.5,
70 2, 0.5, 2.5);
71 TH1* m_hitMap = hitMap;
72
73 int deadCh[2][2] = {};
74
75 for (int i = 0; i < 144; i++) {
76 int hitsNum = m_hitMap->GetBinContent((m_moduleID - 1) * 144 + i);
77 int xChn, yChn;
78 arichChMap->getXYFromAsic(i, xChn, yChn);
79 if (hitsNum == 0) deadCh[(int)xChn / 6][(int)yChn / 6]++;
80 }
81
82 for (int j = 0; j < 2; j++) {
83 for (int k = 0; k < 2; k++) {
84 if (deadCh[j][k] > 18) {
85 m_moduleDeadMap->Fill(j + 1, k + 1, 1);
86 } else {
87 m_moduleDeadMap->Fill(j + 1, k + 1, 10);
88 }
89 }
90 }
91
92 return m_moduleDeadMap;
93 }

◆ moduleHitMap()

TH2 * moduleHitMap ( TH1 *  hitMap,
int  moduleID 
)

Make hit map in HAPD view (12*12 channels).

Parameters
hitMap1D hit map of all channels.
moduleIDModule identifier [1:420].
Returns
2D hit map on HAPD.

Definition at line 38 of file hitMapMaker.cc.

39 {
40
41 int m_moduleID = moduleID;
42
43 DBObjPtr<ARICHChannelMapping> arichChMap;
44
45 TH2* m_moduleHitMap = new TH2D(Form("HAPDHitMapMod%d", moduleID), Form("HAPD hit map module %d;nChX;nChY", moduleID), 12, 0.5, 12.5,
46 12,
47 0.5, 12.5);
48 TH1* m_hitMap = hitMap;
49
50 for (int i = 0; i < 144; i++) {
51 int hitsNum = m_hitMap->GetBinContent((m_moduleID - 1) * 144 + i);
52 int xChn, yChn;
53 arichChMap->getXYFromAsic(i, xChn, yChn);
54 if (hitsNum != 0) {
55 m_moduleHitMap->Fill(xChn + 1, yChn + 1, hitsNum);
56 }
57 }
58
59 return m_moduleHitMap;
60 }

◆ printBits()

void printBits ( const int *  buffer,
int  bufferSize 
)
private

Unpack raw data given in production format.

Parameters
bufferraw data buffer
bufferSizebuffer size

Definition at line 529 of file ARICHUnpackerModule.cc.

530 {
531 for (int i = 0; i < bufferSize; i++) {
532 std::cout << i << "-th word bitset: " << std::bitset<32>(*(buffer + i)) << std::endl;
533 }
534 }

◆ printModuleParams()

void printModuleParams ( )
protected

Print module parameters.

Definition at line 208 of file ARICHReconstructorModule.cc.

209 {
210 if (m_inputTrackType == 0) { B2DEBUG(100, "ARICHReconstructorModule: track infromation is taken from mdst Tracks.");}
211 else B2DEBUG(100, "ARICHReconstructorModule: track information is taken from MC (ARICHAeroHit).");
212 }

◆ readdata()

int readdata ( gzFile  fp,
int  rec_id,
int  print 
)
protected

Read the data from the file (can be compressed)

Definition at line 398 of file arichBtestModule.cc.

399 {
400
401 unsigned int len, data[10000];
402 gzread(fp, &len, sizeof(unsigned int));
403 //if (print) printf( "[%3d] %d: ", len, rec_id );
404 gzread(fp, data, sizeof(unsigned int)*len);
405
406 ROOT::Math::XYZVector r;
407 ROOT::Math::XYZVector dir;
408 if (rec_id == 1) {
409 readmwpc(data, len);
410 int retval = getTrack(*(m_MwpcTrackMask.begin()), r, dir);
411 //dir = ROOT::Math::XYZVector(0,0,1);
412
413 if (!retval) {
414 // global transf, add track to datastore
415 StoreArray<ARICHAeroHit> arichAeroHits;
416
417 int particleId = 11;// geant4
418 dir *= m_beamMomentum * Unit::GeV;
419 r *= Unit::mm /*/ CLHEP::mm*/;
420 static ARICHBtestGeometryPar* _arichbtgp = ARICHBtestGeometryPar::Instance();
421 static ROOT::Math::XYZVector dr = _arichbtgp->getTrackingShift();
422
423 r += dr;
424
425 //----------------------------------------
426 // Track rotation
427 //
428 ROOT::Math::Rotation3D rot = _arichbtgp->getFrameRotation();
429 ROOT::Math::XYZVector rc = _arichbtgp->getRotationCenter();
430
431 ROOT::Math::XYZVector rrel = rc - rot * rc;
432 r = rot * r + rrel;
433 dir = rot * dir;
434 r.SetX(-r.X()); dir.SetX(-dir.X());
435
436 //
437 // end track rotation
438 //----------------------------------------
439 r.SetY(-r.Y());
440 dir.SetY(-dir.Y());
441 B2DEBUG(50, "-----------> " << rc.X() << " " << rc.Y() << " " << rc.Z() << "::::" << rrel.X() << " " << rrel.Y() << " " <<
442 rrel.Z() << " ----> R " << r.X() << " " << r.Y() << " " << r.Z() << " ----> S " << dir.X() << " " << dir.Y() << " " <<
443 dir.Z());
444
445 // Add new ARIHCAeroHit to datastore
446 arichAeroHits.appendNew(particleId, r, dir);
447
448 }
449 }
450
451 if (rec_id == 2) {
452 readhapd(len, data);
453 }
454
455 for (unsigned int j = 0; j < len; j++) {
456 //if( j%8==0 && j!= 0 ) printf( " " );
457 //printf( " %08x", data[j] );
458 //if( j%8==7 || j==len-1 ) putchar('\n');
459 }
460 return len + 1;
461 }
static const double GeV
Standard of [energy, momentum, mass].
Definition: Unit.h:51
int getTrack(int mask, ROOT::Math::XYZVector &r, ROOT::Math::XYZVector &dir)
Beamtest Track reconstruction.
void readmwpc(unsigned int *dbuf, unsigned int len, int print=0)
Read the MWPC information from the data buffer.
int readhapd(unsigned int len, unsigned int *data)
Read the HAPD hits from the data buffer.

◆ readFEHeader()

void readFEHeader ( const int *  buffer,
unsigned &  ibyte,
ARICHRawHeader head 
)
private

Read FE header.

Definition at line 483 of file ARICHUnpackerModule.cc.

484 {
485
486 // read the first line of header
487 char line1[4];
488 int shift;
489 for (int i = 0; i < 4; i++) {
490 shift = (3 - ibyte % 4) * 8;
491 line1[3 - i] = buffer[ibyte / 4] >> shift;
492 ibyte++;
493 }
494
495 head.type = line1[3];
496 head.version = line1[2];
497 head.mergerID = line1[1];
498 head.FEBSlot = line1[0];
499
500 // data length
501 unsigned char len[4];
502 for (int i = 0; i < 4; i++) {
503 shift = (3 - ibyte % 4) * 8;
504 len[3 - i] = buffer[ibyte / 4] >> shift;
505 ibyte++;
506 }
507
508 unsigned vth_info = len[3] * 256 + len[2];
509 if (vth_info >= 32768) { head.thscan_mode = true; vth_info -= 32768; }
510 head.vth = vth_info;
511 // This line (16 bits) is actaully not used for data length.
512 len[2] = 0;
513 len[3] = 0;
514 uint32_t* tmp = (uint32_t*)len;
515 head.length = *tmp;
516
517 // trigger number
518 char trg[4];
519 for (int i = 0; i < 4; i++) {
520 shift = (3 - ibyte % 4) * 8;
521 trg[3 - i] = buffer[ibyte / 4] >> shift;
522 ibyte++;
523 }
524 tmp = (uint32_t*)trg;
525 head.trigger = *tmp;
526
527 }

◆ readhapd()

int readhapd ( unsigned int  len,
unsigned int *  data 
)
protected

Read the HAPD hits from the data buffer.

Definition at line 268 of file arichBtestModule.cc.

269 {
270
271 ARICHGeometryPar* _arichgp = ARICHGeometryPar::Instance();
272 ARICHBtestGeometryPar* _arichbtgp = ARICHBtestGeometryPar::Instance();
273 //-----------------------------------------------------
274
275 unsigned int bmask = 0xF;
276
277 for (int module = 0; module < 6; module++) {
278 int istart = 19 * module;
279 int istop = 19 * module + 18;
280 for (int i = istart; i < istop; i++) {
281 for (int j = 0; j < 8; j++) {
282 unsigned int kdata = data[i] & (bmask << (j * 4));
283 if (kdata) {
284 int channelID = j + 8 * (i - istart);
285
286 if (_arichgp->isActive(module, channelID)) {
287
288 hapd[module]->Fill(channelID);
289
290 StoreArray<ARICHDigit> arichDigits;
291 double globalTime = 0;
292
293 double rposx = 0, rposy = 0;
294 std::pair<int, int> eposhapd(_arichbtgp->GetHapdElectronicMap(module * 144 + channelID));
295 int channel = eposhapd.second;
296
297 if ((channel < 108 && channel > 71) || channel < 36) channel = 108 - (int(channel / 6) * 2 + 1) * 6 +
298 channel;
299 else channel = 144 - (int((channel - 36) / 6) * 2 + 1) * 6 + channel - 36;
300 ROOT::Math::XYVector loc = _arichgp->getChannelCenterLoc(channel);
301 if (abs(loc.X()) > 2.3 || abs(loc.Y()) > 2.3) continue;
302
303 arichDigits.appendNew(module + 1, channel, globalTime);
304
305 ROOT::Math::XYZVector rechit = _arichgp->getChannelCenterGlob(module + 1, channel);
306 std::pair<double, double> poshapd(_arichbtgp->GetHapdChannelPosition(module * 144 + channelID));
307 m_tuple ->Fill(-poshapd.first, poshapd.second, rechit.X(), rechit.Y(), module, channelID, rposx, rposy);
308 }
309 }
310 }
311 }
312 }
313
314 return len;
315 }
static ARICHGeometryPar * Instance()
Static method to get a reference to the ARICHGeometryPar instance.

◆ readHeader()

void readHeader ( const int *  buffer,
unsigned &  ibyte,
ARICHRawHeader head 
)
private

Read Merger header.

Definition at line 435 of file ARICHUnpackerModule.cc.

436 {
437
438 // read the first line of header
439 char line1[4];
440 int shift;
441 for (int i = 0; i < 4; i++) {
442 shift = (3 - ibyte % 4) * 8;
443 line1[3 - i] = buffer[ibyte / 4] >> shift;
444 ibyte++;
445 }
446
447 head.type = line1[3];
448 head.version = line1[2];
449 head.mergerID = line1[1];
450 head.FEBSlot = line1[0];
451
452 // data length
453 unsigned char len[4];
454 for (int i = 0; i < 4; i++) {
455 shift = (3 - ibyte % 4) * 8;
456 len[3 - i] = buffer[ibyte / 4] >> shift;
457 ibyte++;
458 }
459
460 unsigned seu = len[2];
461 // This line (16 bits) is actaully not used for data length.
462 len[2] = 0;
463 len[3] = 0;
464 uint32_t* tmp = (uint32_t*)len;
465 head.length = *tmp;
466
467 for (int i = 0; i < 6; i ++) {
468 head.SEU_FEB[i] = (seu & (1 << i)) != 0;
469 }
470
471 // trigger number
472 char trg[4];
473 for (int i = 0; i < 4; i++) {
474 shift = (3 - ibyte % 4) * 8;
475 trg[3 - i] = buffer[ibyte / 4] >> shift;
476 ibyte++;
477 }
478 tmp = (uint32_t*)trg;
479 head.trigger = *tmp;
480
481 }

◆ readmwpc()

void readmwpc ( unsigned int *  dbuf,
unsigned int  len,
int  print = 0 
)
protected

Read the MWPC information from the data buffer.

Definition at line 198 of file arichBtestModule.cc.

199 {
200
201 const int unsigned MAXV1290 = 32;
202
203 unsigned int edge;
204 unsigned int tdcch;
205 unsigned int tdcl;
206 unsigned int nhits;
207
208 for (int i = 0; i < 32; i++) m_tdc[i] = 0XFFFF;
209 //TDC V1290
210 //for (int i=0;i<len;i++) printf("V1290 %d(%d) 0x%08x \n",i,len, dbuf[i],n);
211 for (unsigned int i = 0; i < len; i++) {
212 int rid = (dbuf[i] >> 27) & 0x1F;
213 switch (rid) {
214 case 0x18: // Filler
215 if (print1290) printf("Filler 0x%08x %u.data\n", dbuf[i], i);
216 break;
217 case 0x8: // Global Header
218 if (print1290) printf("Global Header 0x%08x %u.data\n", dbuf[i], i);
219 break;
220 case 0x10: // Global Trailer --- Last word of data
221 nhits = ((dbuf[i] >> 5) & 0xFFFF); //Word Count = bit 31...21< Word Count: 20 ... 5 > 4...0
222 if (print1290) printf("Global Trailer 0x%08x %u.data STATUS=0x%03x nhits=%u\n", dbuf[i], i, (dbuf[i] >> 24) & 0x7, nhits);
223
224 if (nhits != len) {
225 if (print1290) printf("V1290 nhits!=len %u %u\n", nhits, len);
226 };
227 break;
228 case 0x11: // Global Trigger TimeTag
229 if (print1290) printf("Global Trigger TimeTag 0x%08x %u.data\n", dbuf[i], i);
230 break;
231 case 0x1: // TDC header
232 if (print1290) printf("TDC header 0x%08x %u.data evid=%u wc=%u\n", dbuf[i], i, (dbuf[i] >> 12) & 0xFFF, dbuf[i] & 0xFFF);
233
234 break;
235 case 0x3: // TDC trailer
236 if (print1290) printf("TDC trailer 0x%08x %u.data\n", dbuf[i], i);
237
238 break;
239 case 0x4: // TDC Error
240 if (print1290) printf("TDC Error 0x%08x %u.data ERR=0x%x\n", dbuf[i], i, dbuf[i] & 0x3FFF);
241
242 break;
243 case 0x0 : // TDC data
244
245 edge = (dbuf[i] >> 26) & 0x1;
246 tdcch = (dbuf[i] >> 21) & 0x1F;
247 tdcl = dbuf[i] & 0x1FFFFF;
248 if (tdcch < MAXV1290) {
249 //if (tdcch>15) gV1290[tdcch]->Fill(tdcl/40);
250 //if (tdcch>15) if (tdcl< trg[tdcch-16] && tdcl>16000 && tdcl<20000 ) trg[tdcch-16]=tdcl;
251 if (print1290)
252 printf("V1290 0x%08x %u. [ch=%2u] edge=%u data=%u \n", dbuf[i], i, tdcch, edge, tdcl);
253 m_tdc[tdcch] = tdcl / 40;
254 }
255
256 break;
257
258 default:
259 if (print1290) printf("Unknown 0x%08x %u.data\n", dbuf[i], i);
260
261 break;
262
263 }
264 }
265
266 }

◆ REG_MODULE() [1/4]

REG_MODULE ( ARICHDQM  )

◆ REG_MODULE() [2/4]

REG_MODULE ( ARICHPacker  )

◆ REG_MODULE() [3/4]

REG_MODULE ( ARICHRateCal  )

◆ REG_MODULE() [4/4]

REG_MODULE ( ARICHRawUnpacker  )

◆ sectorDeadMap()

TCanvas * sectorDeadMap ( TH1 *  hitMap,
int  sector 
)

Make display of 70 HAPDs' 2D dead/alive map of the sector.

Parameters
hitMap1D hit map of all channels.
sectorSector identifier [1:6].
Returns
Display of 70 HAPDs' 2D dead/alive map.

Definition at line 176 of file hitMapMaker.cc.

177 {
178 //TH1* m_hitMap = NULL;
179 TH2* m_moduleDeadMap = NULL;
180 TExec* ex1 = NULL;
181
182 //m_hitMap = hitMap;
183 TPad* p_hitMaps[421] = {};
184 TCanvas* m_sectorDeadMap = new TCanvas(Form("c_deadMap%d", sector - 1), Form("Dead chip map of sector%d", sector - 1), 600, 400);
185 for (int i = 1; i < 421; i++) {
186 for (int iRing = 0; iRing < 7; iRing++) {
187 if (((iRing + 13)*iRing / 2) * 6 + (iRing + 7) * (sector - 1) < i && i <= ((iRing + 13)*iRing / 2) * 6 + (iRing + 7) * (sector)) {
188 m_sectorDeadMap->cd();
189 p_hitMaps[i] = new TPad(Form("p_deadMap%d", i), "",
190 (double)((double)(6 - iRing) / 2 + ((i - ((iRing + 13)*iRing / 2) * 6 + (iRing + 7) * (sector - 1) - 1) % (iRing + 7))) / 13,
191 (double)iRing / 7, (double)((double)(8 - iRing) / 2 + ((i - ((iRing + 13)*iRing / 2) * 6 + (iRing + 7) * (sector - 1) - 1) %
192 (iRing + 7))) / 13, (double)(iRing + 1) / 7);
193 p_hitMaps[i]->Draw();
194 p_hitMaps[i]->SetNumber(i);
195 m_sectorDeadMap->cd(i);
196 m_moduleDeadMap = moduleDeadMap(hitMap, i);
197 m_moduleDeadMap->SetTitleSize(0, "xyz");
198 m_moduleDeadMap->SetTitle(0);
199 m_moduleDeadMap->SetLineWidth(1);
200 m_moduleDeadMap->SetStats(0);
201 gStyle->SetLabelColor(0, "xyz");
202 ex1 = new TExec("ex1", "deadPalette();");
203 ex1->Draw();
204 m_moduleDeadMap->Draw("colz");
205 }
206 }
207 }
208 return m_sectorDeadMap;
209 }
TH2 * moduleDeadMap(TH1 *hitMap, int moduleID)
Make chip dead/alive map in HAPD view (2*2 chips).
Definition: hitMapMaker.cc:62

◆ sectorHitMap()

TCanvas * sectorHitMap ( TH1 *  hitMap,
int  sector 
)

Make display of 70 HAPDs' 2D hit map of the sector.

Parameters
hitMap1D hit map of all channels.
sectorSector identifier [1:6].
Returns
Display of 70 HAPDs' 2D hit map.

Definition at line 144 of file hitMapMaker.cc.

145 {
146 // TH1* m_hitMap = NULL;
147 TH2* m_moduleHitMap = NULL;
148
149 //m_hitMap = hitMap;
150 TPad* p_hitMaps[421] = {};
151 TCanvas* m_sectorHitMap = new TCanvas(Form("c_hitMap%d", sector - 1), Form("Hit map of sector%d", sector - 1), 600, 400);
152 for (int i = 1; i < 421; i++) {
153 for (int iRing = 0; iRing < 7; iRing++) {
154 if (((iRing + 13)*iRing / 2) * 6 + (iRing + 7) * (sector - 1) < i && i <= ((iRing + 13)*iRing / 2) * 6 + (iRing + 7) * (sector)) {
155 m_sectorHitMap->cd();
156 p_hitMaps[i] = new TPad(Form("p_hitMap%d", i), "",
157 (double)((double)(6 - iRing) / 2 + ((i - ((iRing + 13)*iRing / 2) * 6 + (iRing + 7) * (sector - 1) - 1) % (iRing + 7))) / 13,
158 (double)iRing / 7, (double)((double)(8 - iRing) / 2 + ((i - ((iRing + 13)*iRing / 2) * 6 + (iRing + 7) * (sector - 1) - 1) %
159 (iRing + 7))) / 13, (double)(iRing + 1) / 7);
160 p_hitMaps[i]->Draw();
161 p_hitMaps[i]->SetNumber(i);
162 m_sectorHitMap->cd(i);
163 m_moduleHitMap = moduleHitMap(hitMap, i);
164 m_moduleHitMap->SetTitleSize(0, "xyz");
165 m_moduleHitMap->SetTitle(0);
166 m_moduleHitMap->SetLineWidth(1);
167 gStyle->SetLabelColor(0, "xyz");
168 m_moduleHitMap->SetStats(0);
169 m_moduleHitMap->Draw("col");
170 }
171 }
172 }
173 return m_sectorHitMap;
174 }

◆ setTrackAngleResolution()

void setTrackAngleResolution ( double  aRes)

Sets track direction resolution (from tracking).

Definition at line 694 of file ARICHReconstruction.cc.

695 {
696 m_trackAngRes = aRes;
697 }

◆ setTrackPositionResolution()

void setTrackPositionResolution ( double  pRes)

Sets track position resolution (from tracking).

Definition at line 690 of file ARICHReconstruction.cc.

691 {
692 m_trackPosRes = pRes;
693 }

◆ skipdata()

int skipdata ( gzFile  fp)
protected

Skip the data part of the record.

Definition at line 190 of file arichBtestModule.cc.

191 {
192 unsigned int u;
193 gzread(fp, &u, sizeof(unsigned int));
194 gzseek(fp, u * sizeof(unsigned int), SEEK_CUR);
195 return u + 1;
196 }

◆ smearTrack()

int smearTrack ( ARICHTrack arichTrack)

Smears track parameters ("simulate" the uncertainties of tracking).

Definition at line 133 of file ARICHReconstruction.cc.

134 {
135 double a = gRandom->Gaus(0, m_trackAngRes);
136 double b = gRandom->Gaus(0, m_trackAngRes);
137 ROOT::Math::XYZVector dirf(a, b, sqrt(1 - a * a - b * b));
138 double dx = gRandom->Gaus(0, m_trackPosRes);
139 double dy = gRandom->Gaus(0, m_trackPosRes);
140 ROOT::Math::XYZVector mod(dx, dy, 0);
141 ROOT::Math::XYZVector rpoint = arichTrack.getPosition() + mod;
142 ROOT::Math::XYZVector odir = arichTrack.getDirection();
143 double omomentum = arichTrack.getMomentum();
144 ROOT::Math::XYZVector rdir = TransformFromFixed(odir) * dirf; // global system
145 double rmomentum = omomentum;
146 arichTrack.setReconstructedValues(rpoint, ROOT::Math::XYZVector(rdir), rmomentum);
147 return 1;
148 }

◆ terminate() [1/2]

void terminate ( void  )
overridevirtual

Is called at the end of your Module.

Function is called only once at the end of your job at the end of the corresponding module. This function is for cleaning up, closing files, etc.

Reimplemented from Module.

Definition at line 568 of file arichBtestModule.cc.

569 {
570 int j = 1;
571 BOOST_FOREACH(const std::string & fname, m_runList) {
572 B2INFO(m_eveList[j] << " events processed from file " << fname);
573 j++;
574 }
575 for (int i = 0; i < 4; i++) {
576 //ARICHTracking* w = &m_mwpc[i];
577 B2INFO(i << " a1=" << m_mwpc[i].tdc[0] << " a2=" << m_mwpc[i].tdc[1] << " a3=" << m_mwpc[i].tdc[2] << " a2=" << m_mwpc[i].tdc[3]
578 << " A=" << m_mwpc[i].atdc);
579 }
580
581 }

◆ terminate() [2/2]

void terminate ( void  )
overridevirtual

Termination action.

Clean-up, close files, summarize statistics, etc.

Reimplemented from Module.

Definition at line 335 of file ARICHNtupleModule.cc.

336 {
337 m_file->cd();
338 m_tree->Write();
339 m_file->Close();
340 }

◆ transformTrackToLocal()

void transformTrackToLocal ( ARICHTrack arichTrack,
bool  align 
)

Transforms track parameters from global Belle2 to ARICH local frame.

Definition at line 722 of file ARICHReconstruction.cc.

723 {
724 // tranform track from Belle II to local ARICH frame
725 ROOT::Math::XYZVector locPos = m_arichgp->getMasterVolume().pointToLocal(arichTrack.getPosition());
726 ROOT::Math::XYZVector locDir = m_arichgp->getMasterVolume().momentumToLocal(arichTrack.getDirection());
727
728 // apply the alignment correction
729 if (align && m_alignp.isValid()) {
730 // apply global alignment correction
731 locPos = m_alignp->pointToLocal(locPos);
732 locDir = m_alignp->momentumToLocal(locDir);
733 }
734
735 // set parameters and return
736 // is it needed to extrapolate to z of aerogel in local frame?? tabun
737 arichTrack.setReconstructedValues(locPos, locDir, arichTrack.getMomentum());
738 return;
739 }
DBObjPtr< ARICHGlobalAlignment > m_alignp
global alignment parameters from the DB

◆ writeHeader()

void writeHeader ( int *  buffer,
unsigned &  ibyte,
const ARICHRawHeader head 
)

TODO!

Definition at line 214 of file ARICHPackerModule.cc.

215 {
216
217 unsigned char line1[4];
218 int shift;
219
220 line1[3] = head.type;
221 line1[2] = head.version;
222 line1[1] = head.mergerID;
223 line1[0] = head.FEBSlot;
224
225 for (int i = 0; i < 4; i++) {
226 shift = (3 - ibyte % 4) * 8;
227 buffer[ibyte / 4] |= line1[3 - i] << shift;
228 ibyte++;
229 }
230
231 auto len = reinterpret_cast<const unsigned char*>(&head.length);
232
233 for (int i = 0; i < 4; i++) {
234 shift = (3 - ibyte % 4) * 8;
235 buffer[ibyte / 4] |= len[3 - i] << shift;
236 ibyte++;
237 }
238
239 // trigger number
240 auto trg = reinterpret_cast<const unsigned char*>(&head.trigger);
241 for (int i = 0; i < 4; i++) {
242 shift = (3 - ibyte % 4) * 8;
243 buffer[ibyte / 4] |= trg[3 - i] << shift;
244 ibyte++;
245 }
246
247 }

◆ ~ARICHDigitizerModule()

~ARICHDigitizerModule ( )
virtual

Destructor.

Definition at line 68 of file ARICHDigitizerModule.cc.

69 {
70
71 }

◆ ~ARICHDQMModule()

~ARICHDQMModule ( )
virtual

Destructor.

Definition at line 57 of file ARICHDQMModule.cc.

58 {
59 }

◆ ~ARICHFillHitsModule()

~ARICHFillHitsModule ( )
virtual

Destructor.

Definition at line 53 of file ARICHFillHitsModule.cc.

54 {
55 }

◆ ~ARICHMCParticlesModule()

~ARICHMCParticlesModule ( )
virtual

Destructor.

Definition at line 48 of file ARICHMCParticlesModule.cc.

49 {
50 }

◆ ~ARICHNtupleModule()

~ARICHNtupleModule ( )
virtual

Destructor.

Definition at line 65 of file ARICHNtupleModule.cc.

66 {
67 }

◆ ~ARICHPackerModule()

~ARICHPackerModule ( )
virtual

Destructor.

Definition at line 62 of file ARICHPackerModule.cc.

63 {
64 }

◆ ~ARICHRateCalModule()

~ARICHRateCalModule ( )
virtual

Destructor.

Definition at line 60 of file ARICHRateCalModule.cc.

61 {
62 }

◆ ~ARICHRawUnpackerModule()

~ARICHRawUnpackerModule ( )
virtual

Destructor.

Definition at line 41 of file ARICHRawUnpackerModule.cc.

42 {
43 }

◆ ~ARICHReconstructorModule()

Destructor.

Definition at line 69 of file ARICHReconstructorModule.cc.

70 {
71 if (m_ana) delete m_ana;
72 }

◆ ~ARICHUnpackerModule()

~ARICHUnpackerModule ( )
virtual

Destructor.

Definition at line 69 of file ARICHUnpackerModule.cc.

70 {
71 }

Variable Documentation

◆ hapd

TH1F* hapd[6]

histogram of hits for each hapd

Definition at line 82 of file arichBtestModule.cc.

◆ m_tuple

TNtuple* m_tuple

ntuple containing hapd hits

Definition at line 81 of file arichBtestModule.cc.

◆ mwpc_diff

TH1F* mwpc_diff[4][2]

tdc difference from mwpcs

Definition at line 84 of file arichBtestModule.cc.

◆ mwpc_residuals

TH1F* mwpc_residuals[4][2]

residuals from mwpcs

Definition at line 87 of file arichBtestModule.cc.

◆ mwpc_residualsz

TH2F* mwpc_residualsz[4][2]

z-residuals from mwpcs

Definition at line 89 of file arichBtestModule.cc.

◆ mwpc_sum

TH1F* mwpc_sum[4][2]

tdc sum from mwpcs

Definition at line 85 of file arichBtestModule.cc.

◆ mwpc_sum_cut

TH1F* mwpc_sum_cut[4][2]

tdc sum from mwpcs, with sum cut applied

Definition at line 86 of file arichBtestModule.cc.

◆ mwpc_tdc

TH1F* mwpc_tdc[4][5]

tdc information from mwpcs

Definition at line 83 of file arichBtestModule.cc.

◆ mwpc_xy

TH2F* mwpc_xy[4]

calculated x-y track positions

Definition at line 88 of file arichBtestModule.cc.