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 distortion 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 54 of file arichBtestModule.cc.

54 : Module(), m_end(0), m_events(0), m_file(NULL), m_timestart(0), m_mwpc(NULL)
55 {
56 //Set module properties
57 setDescription("Module for the ARICH Beamtest data analysis. It creates track form the MWPC hits and reads the HAPD hits");
58
59 //Parameter definition
60 addParam("outputFileName", m_outFile, "Output Root Filename", std::string("output.root"));
61 std::vector<std::string> defaultList;
62 addParam("runList", m_runList, "Data Filenames.", defaultList);
63 std::vector<int> defaultMask;
64 addParam("mwpcTrackMask", m_MwpcTrackMask, "Create track from MWPC layers", defaultMask);
65 m_fp = NULL;
66 addParam("beamMomentum", m_beamMomentum, "Momentum of the beam [GeV]", 0.0);
67
68 for (int i = 0; i < 32; i++) m_tdc[i] = 0;
69
70 }
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 descriptor 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:559

◆ 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 distortion 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 (useful 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 position 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 44 of file ARICHRateCalModule.cc.

44 : HistoModule()
45 {
46 // set module description (e.g. insert text)
47 setDescription("Fills ARICHHits collection from ARICHDigits");
49 addParam("nrun", m_nrun, "# of scan runs", 100);
50 addParam("nevents", m_nevents, "# of events per run", 1000);
51 double v = 0;
52 addParam("dth", m_dth, "dth", v);
53 addParam("th0", m_th0, "th0", v);
54 addParam("debug", m_debugmode, "debug mode", false);
55 addParam("internal", m_internalmode, "Internal thscan mode", false);
56 addParam("daqdb", m_daqdb, "daqdb config name", std::string(""));
57 }
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 39 of file ARICHReconstruction.cc.

39 :
40 m_arichgp(),
41 m_recPars(),
44 m_alignMirrors(true),
46 m_storePhot(storePhot)
47 {
48 for (unsigned i = 0; i < c_noOfHypotheses; i++) {p_mass[i] = 0;}
49 for (unsigned i = 0; i < c_noOfAerogels; i++) {
50 m_refractiveInd[i] = 0;
51 m_zaero[i] = 0;
52 m_thickness[i] = 0;
53 m_transmissionLen[i] = 0;
54 m_n0[i] = 0;
55 m_anorm[i] = ROOT::Math::XYZVector();
56 }
57
58 }
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 49 of file ARICHUnpackerModule.cc.

49 : Module(), m_bitMask(0), m_debug(0)
50 {
51 // set module description
52 setDescription("Raw data unpacker for ARICH");
54
55 addParam("bitMask", m_bitMask, "hit bit mask (8 bits/channel, only used for unsuppresed format!)", (uint8_t)0xFF);
56 addParam("debug", m_debug, "prints debug information", 0);
57
58 addParam("inputRawDataName", m_inputRawDataName, "name of RawARICH store array", std::string(""));
59 addParam("outputDigitsName", m_outputDigitsName, "name of ARICHDigit store array", std::string(""));
60 addParam("outputRawDigitsName", m_outputRawDigitsName, "name of ARICHRawDigit store array", std::string(""));
61 addParam("outputarichinfoName", m_outputarichinfoName, "name of ARICHInfo store array", std::string(""));
62 addParam("RawUnpackerMode", m_rawmode, "Activate RawUnpacker mode", 0);
63 addParam("DisableUnpackerMode", m_disable_unpacker, "Disable Regular Unpacker mode", 0);
64
65 }
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 140 of file arichBtestModule.cc.

141 {
142
143 B2INFO("arichBtestModule::beginRun()");
144
145 StoreObjPtr<EventMetaData> eventMetaDataPtr;
146 B2INFO("arichBtestModule::eventMetaDataPtr run:" << eventMetaDataPtr->getRun());
147 B2INFO("arichBtestModule::eventMetaDataPtr exp:" << eventMetaDataPtr->getExperiment());
148
149 ARICHBtestGeometryPar* _arichbtgp = ARICHBtestGeometryPar::Instance();
150 m_mwpc = _arichbtgp->getMwpc();
151
152 static int first = 1;
153 if (first) {
154 m_runCurrent = m_runList.begin();
155 first = 0;
156 m_mwpc[0].Print();
157 m_mwpc[1].Print();
158 m_mwpc[2].Print();
159 m_mwpc[3].Print();
160
161 }
162 m_end = 1;
163
164 if (m_runCurrent < m_runList.end()) {
165 if (m_fp) {
166 m_eveList.push_back(m_events);
167 gzclose(m_fp);
168 }
169 m_fp = gzopen((*m_runCurrent).c_str(), "rb");
170 if (m_fp == NULL) {
171 B2INFO("Cannot open " << *m_runCurrent);
172 m_end = 1;
173 } else {
174 B2INFO("File opened " << *m_runCurrent);
175 m_end = 0;
176 }
177 }
178 m_events = 0;
179 }
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 102 of file ARICHRateCalModule.cc.

103 {
104 StoreObjPtr<EventMetaData> evtmetadata;
105 //int expno = evtmetadata->getExperiment();
106 int runno = evtmetadata->getRun();
107 if (runno == 100 && !m_internalmode) {
108 terminate();
109 }
110 }
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 254 of file ARICHReconstruction.cc.

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

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

◆ deadPalette()

void deadPalette ( )

Set palette for sector dead-chip map.

Definition at line 208 of file hitMapMaker.cc.

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

◆ 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 63 of file ARICHRateCalModule.cc.

64 {
65 /*
66 if (m_daqdb.size() > 0) {
67 ConfigFile config("slowcontrol");
68 PostgreSQLInterface db(config.get("database.host"),
69 config.get("database.dbname"),
70 config.get("database.user"),
71 config.get("database.password"),
72 config.getInt("database.port"));
73 DBObject obj = DBObjectLoader::load(db, "arich_th",
74 StringUtil::replace(m_daqdb, ".", ":"));
75 obj.print();
76 m_dth = obj.getFloat("dth");
77 m_th0 = obj.getFloat("th0");
78 m_nrun = obj.getInt("nth");
79 db.close();
80 }
81 */
82
83 if (m_dth == 0) {
84 B2WARNING("dth is set to 0");
85 }
86 for (int i = 0; i < 100; i++) {
87 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,
88 m_nrun, (m_th0 - 0.5 * m_dth) * 1000, (m_th0 + (m_nrun - 0.5)*m_dth) * 1000);
89 }
90 }
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 546 of file arichBtestModule.cc.

547 {
548 B2INFO(" arichBtestModule: End Run !!!");
549
550 m_file->Write();
551 m_file->Close();
552
553 if (m_fp) {
554 gzclose(m_fp);
555 m_eveList.push_back(m_events);
556 }
557 }

◆ 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 457 of file arichBtestModule.cc.

458 {
459
460
461
462
463
464 if (!m_fp) return;
465 unsigned int hdr[2];
466 EventRec rec;
467 BeginRec beginrec;
468 BeginRec endrec;
469 static char msg[1024];
470 int type;
471
472 const int sint = sizeof(unsigned int);
473 do {
474 if (gzread(m_fp, hdr, sint * 2) != 2 * sint && m_end) {
475 B2INFO("[" << m_events << "] End of file: " << *m_runCurrent);
476 ++m_runCurrent;
477 if (m_runCurrent == m_runList.end()) {
478 StoreObjPtr<EventMetaData> eventMetaDataPtr;
479 eventMetaDataPtr->setEndOfData();
480 return;
481 }
482 beginRun();
483 }
484
485 } while (m_end && m_runCurrent != m_runList.end());
486 if (m_events % 1000 == 0) {
487 time_t m_time;
488 time(&m_time);
489 B2INFO("neve= [" << m_events << "] in " << (double)(m_time - m_timestart) / 60. << " min (" << int(
490 m_time - m_timestart) << "s) from " << *m_runCurrent);
491
492 }
493 m_events++;
494
495 type = hdr[0];
496 // len = hdr[1];
497
498 gzseek(m_fp, 2 * sizeof(unsigned int), SEEK_CUR);
499 switch (type) {
500 case BEGIN_RECORD_TYPE: {
501 gzread(m_fp, &beginrec, sizeof(beginrec));
502 time_t t = beginrec.time;
503 sprintf(msg, "BeginRec run %u time %s", beginrec.runno, ctime(&t));
504 B2INFO(msg);
505 break;
506 }
507 case END_RECORD_TYPE: {
508 gzread(m_fp, &endrec, sizeof(endrec));
509 time_t t = endrec.time;
510 sprintf(msg, "EndRec run %u time %s", endrec.runno, ctime(&t));
511 B2INFO(msg);
512 break;
513 }
514 case EVENT_RECORD_TYPE: {
515 gzread(m_fp, &rec, sizeof(rec));
516 int print = !(rec.evtno % 10000);
517 time_t t = rec.time;
518 if (print) {
519 sprintf(msg, "EventRec run %u evt %u mstime %u, time %s", rec.runno, rec.evtno, rec.mstime, ctime(&t));
520 B2INFO(msg);
521 }
522 /* if you just want to jump to the end */
523 int pos = gztell(m_fp);
524 /* try to read inside data */
525 int buflen = rec.len - sizeof(rec) / sizeof(int);
526
527 //if (print) printf ("%d: buflen\n",buflen);
528 int n[5] = { 0 };
529 int i(0), j(0);
530 while (i < buflen && j < 5) {
531 n[j] = readdata(m_fp, j, print);
532 // n[j] = skipdata( m_fp );
533 i += n[j];
534 j++;
535 }
536 if (gzseek(m_fp, pos + buflen * sizeof(unsigned int), SEEK_SET) < 0) B2ERROR("gzseek returns -1 ");
537 break;
538 }
539 default:
540 B2ERROR("IO error unknown record type " << type);
541 break;
542 }
543 if (gzeof(m_fp)) m_end = 1;
544 }
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 overlaid 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 distortion 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 112 of file ARICHRateCalModule.cc.

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

◆ 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 88 of file ARICHUnpackerModule.cc.

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

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

753 {
754 if (m_alignMirrors && m_mirrAlign.isValid()) {
755
756 ROOT::Math::XYZVector mirnorm = m_arichgp->getMirrors().getNormVector(mirrorID);
757
758 VectorUtil::setMagThetaPhi(mirnorm,
759 mirnorm.R(),
760 mirnorm.Theta() + m_mirrAlign->getAlignmentElement(mirrorID).getAlpha(),
761 mirnorm.Phi() + m_mirrAlign->getAlignmentElement(mirrorID).getBeta());
762
763 return mirnorm;
764
765 }
766 return m_arichgp->getMirrors().getNormVector(mirrorID);
767 }
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 743 of file ARICHReconstruction.cc.

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

◆ getTrack()

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

Beamtest Track reconstruction.

Definition at line 309 of file arichBtestModule.cc.

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

701 {
702 // Emission length measured from aerogel exit
703
704 ROOT::Math::XYZVector dir = track.getDirection();
705 if (dir.Z() == 0) return ROOT::Math::XYZVector();
706 double d = m_thickness[iAero] / dir.Z() / m_transmissionLen[iAero];
707 double dmean = 1 - d / expm1(d);
708 //double dmean = -log((1 + exp(-d)) / 2.);
709 double mel = dmean * m_transmissionLen[iAero];
710
711 return (getTrackPositionAtZ(track, m_zaero[iAero]) - mel * dir);
712 }
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 714 of file ARICHReconstruction.cc.

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

◆ 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 237 of file ARICHReconstruction.cc.

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

◆ 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 227 of file ARICHReconstruction.cc.

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

◆ initialize() [1/13]

void initialize ( )

Read geometry parameters from xml and initialize class members.

Definition at line 60 of file ARICHReconstruction.cc.

61 {
62
63 for (const auto& part : Const::chargedStableSet) {
64 p_mass[part.getIndex()] = part.getMass();
65 }
66
67 m_nAerogelLayers = m_arichgp->getAerogelPlane().getNLayers();
69 for (unsigned int i = 0; i < m_nAerogelLayers; i++) {
70 m_refractiveInd[i] = m_arichgp->getAerogelPlane().getLayerRefIndex(i + 1);
71 m_anorm[i] = ROOT::Math::XYZVector(0, 0, 1);
72 m_thickness[i] = m_arichgp->getAerogelPlane().getLayerThickness(i + 1);
73 if (i == 0) m_zaero[i] = m_arichgp->getAerogelPlane().getAerogelZPosition() + m_thickness[i];
74 else m_zaero[i] = m_zaero[i - 1] + m_thickness[i];
75
76 m_transmissionLen[i] = m_arichgp->getAerogelPlane().getLayerTrLength(i + 1) ; // aerogel transmission length;
77
78 // measured FOM; aeroMerit is number of detected photons for beam of beta=1 and perpedicular incidence to aerogel tile
79 // (corrected for geometrical acceptance). n0[i] is then calculated from
80 // aeroMerit[i]=n0[i]*sin2(thc)*transmissionLen[i] * (1 - exp(-thickness[i] / transmissionLen[i])
81 m_n0[i] = m_recPars->getAerogelFOM(i) / ((1. - 1. / m_refractiveInd[i] / m_refractiveInd[i]) * m_transmissionLen[i] * (1 - exp(
84 }
86 m_refractiveInd[m_nAerogelLayers + 1] = m_arichgp->getHAPDGeometry().getWinRefIndex();
87 m_zaero[m_nAerogelLayers ] = m_arichgp->getDetectorZPosition();
88 m_zaero[m_nAerogelLayers + 1] = m_zaero[m_nAerogelLayers] + m_arichgp->getHAPDGeometry().getWinThickness();
89
90 if (m_mirrAlign.hasChanged()) {
91 m_mirrorNorms.clear();
92 m_mirrorPoints.clear();
93 for (unsigned i = 1; i < m_arichgp->getMirrors().getNMirrors() + 1; i++) {
94 m_mirrorNorms.push_back(getMirrorNorm(i));
95 m_mirrorPoints.push_back(getMirrorPoint(i));
96 }
97 }
98
99 if (m_tileAlign) {
100 if (m_tileAlign.hasChanged()) {
101 for (int iTile = 1; iTile < 125; iTile++) {
102 m_tilePars[iTile - 1][0] = m_tileAlign->getAlignmentElement(iTile).getAlpha();
103 m_tilePars[iTile - 1][1] = m_tileAlign->getAlignmentElement(iTile).getBeta();
104 }
105 }
106 }
107 }
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 84 of file arichBtestModule.cc.

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

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

◆ 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 // Dependencies 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 71 of file ARICHUnpackerModule.cc.

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

◆ 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 110 of file ARICHReconstruction.cc.

111 {
112 if (copyno == -1) return 0;
113 ROOT::Math::XYVector origin;
114 origin.SetXY(m_arichgp->getDetectorPlane().getSlotR(copyno) * std::cos(m_arichgp->getDetectorPlane().getSlotPhi(copyno)),
115 m_arichgp->getDetectorPlane().getSlotR(copyno) * std::sin(m_arichgp->getDetectorPlane().getSlotPhi(copyno)));
116 ROOT::Math::XYVector a2(a);
117 double phi = m_arichgp->getDetectorPlane().getSlotPhi(copyno);
118 ROOT::Math::XYVector diff = a2 - origin;
119 diff.Rotate(-phi);
120 const double size = m_arichgp->getHAPDGeometry().getAPDSizeX();
121 if (fabs(diff.X()) < size / 2. && fabs(diff.Y()) < size / 2.) {
122 int chX, chY;
123 m_arichgp->getHAPDGeometry().getXYChannel(diff.X(), diff.Y(), chX, chY);
124 if (chX < 0 || chY < 0) return 0;
125 int asicChannel = m_chnMap->getAsicFromXY(chX, chY);
126 // eliminate un-active channels
127 if (asicChannel < 0 || !m_chnMask->isActive(copyno, asicChannel)) return 0;
128 return 1;
129 }
130 return 0;
131 }
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 350 of file ARICHReconstruction.cc.

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

◆ 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 89 of file hitMapMaker.cc.

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

◆ 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 114 of file hitMapMaker.cc.

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

◆ 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 56 of file hitMapMaker.cc.

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

◆ 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 32 of file hitMapMaker.cc.

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

◆ 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 527 of file ARICHUnpackerModule.cc.

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

◆ 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 information 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 389 of file arichBtestModule.cc.

390 {
391
392 unsigned int len, data[10000];
393 gzread(fp, &len, sizeof(unsigned int));
394 //if (print) printf( "[%3d] %d: ", len, rec_id );
395 gzread(fp, data, sizeof(unsigned int)*len);
396
397 ROOT::Math::XYZVector r;
398 ROOT::Math::XYZVector dir;
399 if (rec_id == 1) {
400 readmwpc(data, len);
401 int retval = getTrack(*(m_MwpcTrackMask.begin()), r, dir);
402 //dir = ROOT::Math::XYZVector(0,0,1);
403
404 if (!retval) {
405 // global transf, add track to datastore
406 StoreArray<ARICHAeroHit> arichAeroHits;
407
408 int particleId = 11;// geant4
409 dir *= m_beamMomentum * Unit::GeV;
410 r *= Unit::mm /*/ CLHEP::mm*/;
411 static ARICHBtestGeometryPar* _arichbtgp = ARICHBtestGeometryPar::Instance();
412 static ROOT::Math::XYZVector dr = _arichbtgp->getTrackingShift();
413
414 r += dr;
415
416 //----------------------------------------
417 // Track rotation
418 //
419 ROOT::Math::Rotation3D rot = _arichbtgp->getFrameRotation();
420 ROOT::Math::XYZVector rc = _arichbtgp->getRotationCenter();
421
422 ROOT::Math::XYZVector rrel = rc - rot * rc;
423 r = rot * r + rrel;
424 dir = rot * dir;
425 r.SetX(-r.X()); dir.SetX(-dir.X());
426
427 //
428 // end track rotation
429 //----------------------------------------
430 r.SetY(-r.Y());
431 dir.SetY(-dir.Y());
432 B2DEBUG(50, "-----------> " << rc.X() << " " << rc.Y() << " " << rc.Z() << "::::" << rrel.X() << " " << rrel.Y() << " " <<
433 rrel.Z() << " ----> R " << r.X() << " " << r.Y() << " " << r.Z() << " ----> S " << dir.X() << " " << dir.Y() << " " <<
434 dir.Z());
435
436 // Add new ARIHCAeroHit to datastore
437 arichAeroHits.appendNew(particleId, r, dir);
438
439 }
440 }
441
442 if (rec_id == 2) {
443 readhapd(len, data);
444 }
445
446 for (unsigned int j = 0; j < len; j++) {
447 //if( j%8==0 && j!= 0 ) printf( " " );
448 //printf( " %08x", data[j] );
449 //if( j%8==7 || j==len-1 ) putchar('\n');
450 }
451 return len + 1;
452 }
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 481 of file ARICHUnpackerModule.cc.

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

◆ readhapd()

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

Read the HAPD hits from the data buffer.

Definition at line 259 of file arichBtestModule.cc.

260 {
261
262 ARICHGeometryPar* _arichgp = ARICHGeometryPar::Instance();
263 ARICHBtestGeometryPar* _arichbtgp = ARICHBtestGeometryPar::Instance();
264 //-----------------------------------------------------
265
266 unsigned int bmask = 0xF;
267
268 for (int module = 0; module < 6; module++) {
269 int istart = 19 * module;
270 int istop = 19 * module + 18;
271 for (int i = istart; i < istop; i++) {
272 for (int j = 0; j < 8; j++) {
273 unsigned int kdata = data[i] & (bmask << (j * 4));
274 if (kdata) {
275 int channelID = j + 8 * (i - istart);
276
277 if (_arichgp->isActive(module, channelID)) {
278
279 hapd[module]->Fill(channelID);
280
281 StoreArray<ARICHDigit> arichDigits;
282 double globalTime = 0;
283
284 double rposx = 0, rposy = 0;
285 std::pair<int, int> eposhapd(_arichbtgp->GetHapdElectronicMap(module * 144 + channelID));
286 int channel = eposhapd.second;
287
288 if ((channel < 108 && channel > 71) || channel < 36) channel = 108 - (int(channel / 6) * 2 + 1) * 6 +
289 channel;
290 else channel = 144 - (int((channel - 36) / 6) * 2 + 1) * 6 + channel - 36;
291 ROOT::Math::XYVector loc = _arichgp->getChannelCenterLoc(channel);
292 if (abs(loc.X()) > 2.3 || abs(loc.Y()) > 2.3) continue;
293
294 arichDigits.appendNew(module + 1, channel, globalTime);
295
296 ROOT::Math::XYZVector rechit = _arichgp->getChannelCenterGlob(module + 1, channel);
297 std::pair<double, double> poshapd(_arichbtgp->GetHapdChannelPosition(module * 144 + channelID));
298 m_tuple ->Fill(-poshapd.first, poshapd.second, rechit.X(), rechit.Y(), module, channelID, rposx, rposy);
299 }
300 }
301 }
302 }
303 }
304
305 return len;
306 }
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 433 of file ARICHUnpackerModule.cc.

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

◆ readmwpc()

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

Read the MWPC information from the data buffer.

Definition at line 189 of file arichBtestModule.cc.

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

◆ 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 170 of file hitMapMaker.cc.

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

◆ 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 138 of file hitMapMaker.cc.

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

◆ setTrackAngleResolution()

void setTrackAngleResolution ( double  aRes)

Sets track direction resolution (from tracking).

Definition at line 695 of file ARICHReconstruction.cc.

696 {
697 m_trackAngRes = aRes;
698 }

◆ setTrackPositionResolution()

void setTrackPositionResolution ( double  pRes)

Sets track position resolution (from tracking).

Definition at line 691 of file ARICHReconstruction.cc.

692 {
693 m_trackPosRes = pRes;
694 }

◆ skipdata()

int skipdata ( gzFile  fp)
protected

Skip the data part of the record.

Definition at line 181 of file arichBtestModule.cc.

182 {
183 unsigned int u;
184 gzread(fp, &u, sizeof(unsigned int));
185 gzseek(fp, u * sizeof(unsigned int), SEEK_CUR);
186 return u + 1;
187 }

◆ smearTrack()

int smearTrack ( ARICHTrack arichTrack)

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

Definition at line 134 of file ARICHReconstruction.cc.

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

◆ 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 559 of file arichBtestModule.cc.

560 {
561 int j = 1;
562 for (const std::string& fname : m_runList) {
563 B2INFO(m_eveList[j] << " events processed from file " << fname);
564 j++;
565 }
566 for (int i = 0; i < 4; i++) {
567 //ARICHTracking* w = &m_mwpc[i];
568 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]
569 << " A=" << m_mwpc[i].atdc);
570 }
571
572 }

◆ 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 723 of file ARICHReconstruction.cc.

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

60 {
61 }

◆ ~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 67 of file ARICHUnpackerModule.cc.

68 {
69 }

Variable Documentation

◆ hapd

TH1F* hapd[6]

histogram of hits for each hapd

Definition at line 73 of file arichBtestModule.cc.

◆ m_tuple

TNtuple* m_tuple

ntuple containing hapd hits

Definition at line 72 of file arichBtestModule.cc.

◆ mwpc_diff

TH1F* mwpc_diff[4][2]

tdc difference from mwpcs

Definition at line 75 of file arichBtestModule.cc.

◆ mwpc_residuals

TH1F* mwpc_residuals[4][2]

residuals from mwpcs

Definition at line 78 of file arichBtestModule.cc.

◆ mwpc_residualsz

TH2F* mwpc_residualsz[4][2]

z-residuals from mwpcs

Definition at line 80 of file arichBtestModule.cc.

◆ mwpc_sum

TH1F* mwpc_sum[4][2]

tdc sum from mwpcs

Definition at line 76 of file arichBtestModule.cc.

◆ mwpc_sum_cut

TH1F* mwpc_sum_cut[4][2]

tdc sum from mwpcs, with sum cut applied

Definition at line 77 of file arichBtestModule.cc.

◆ mwpc_tdc

TH1F* mwpc_tdc[4][5]

tdc information from mwpcs

Definition at line 74 of file arichBtestModule.cc.

◆ mwpc_xy

TH2F* mwpc_xy[4]

calculated x-y track positions

Definition at line 79 of file arichBtestModule.cc.