10#include <ecl/modules/eclDQMInjection/eclDQMInjection.h>
13#include <ecl/dataobjects/ECLDsp.h>
14#include <ecl/utility/ECLDspUtilities.h>
17#include <boost/format.hpp>
18#include <boost/range/combine.hpp>
21#include <TDirectory.h>
28using namespace Belle2::ECL;
41 m_calibrationThrApsd(
"ECL_FPGA_StoreWaveform")
47 std::string(
"ECLINJ"));
55 "Flag to control trigger of delayed bhabha events; 0 - select events by 'bha_delay' trigger bit, 1 - select by TTYP_DPHY",
false);
61 TDirectory* oldDir = gDirectory;
65 hHitsAfterInjLER =
new TH1F(
"ECLHitsInjLER",
"ECLHitsInjLER/Time;Time in #mus;Count/Time (5 #mus bins)", 4000, 0, 20000);
66 hHitsAfterInjHER =
new TH1F(
"ECLHitsInjHER",
"ECLHitsInjHER/Time;Time in #mus;Count/Time (5 #mus bins)", 4000, 0, 20000);
67 hEHitsAfterInjLER =
new TH1F(
"ECLEHitsInjLER",
"ECLEHitsInjLER/Time;Time in #mus;Triggers/Time (5 #mus bins)", 4000, 0, 20000);
68 hEHitsAfterInjHER =
new TH1F(
"ECLEHitsInjHER",
"ECLEHitsInjHER/Time;Time in #mus;Triggers/Time (5 #mus bins)", 4000, 0, 20000);
69 hBurstsAfterInjLER =
new TH1F(
"ECLBurstsInjLER",
"ECLBurstsInjLER/Time;Time in #mus;Count/Time (1 #mus bins)", 20000, 0, 20000);
70 hBurstsAfterInjHER =
new TH1F(
"ECLBurstsInjHER",
"ECLBurstsInjHER/Time;Time in #mus;Count/Time (1 #mus bins)", 20000, 0, 20000);
71 hEBurstsAfterInjLER =
new TH1F(
"ECLEBurstsInjLER",
"ECLEBurstsInjLER/Time;Time in #mus;Triggers/Time (1 #mus bins)", 20000, 0,
73 hEBurstsAfterInjHER =
new TH1F(
"ECLEBurstsInjHER",
"ECLEBurstsInjHER/Time;Time in #mus;Triggers/Time (1 #mus bins)", 20000, 0,
76 "ECL Hits for LER veto tuning (E > 20 MeV);"
77 "Time since last injection in #mus;Time within beam cycle in #mus", 500, 0, 30000, 100, 0,
80 "ECL Hits for HER veto tuning (E > 20 MeV);"
81 "Time since last injection in #mus;Time within beam cycle in #mus", 500, 0, 30000, 100, 0,
84 "ECL Occupancy after LER injection (E > 1 MeV);Time since last injection in #mus;Occupancy (Nhits/8736) [%]",
85 100, 0, 20000, 98, 2, 100);
87 "ECL Occupancy after HER injection (E > 1 MeV);Time since last injection in #mus;Occupancy (Nhits/8736) [%]",
88 100, 0, 20000, 98, 2, 100);
91 "LER Injection peak position in ECL data;"
92 "Time within beam cycle [ADC ticks];"
93 "Inj peak position [ADC ticks]",
94 18, 0, 18, 16, 0, 16);
96 "HER Injection peak position in ECL data;"
97 "Time within beam cycle [ADC ticks];"
98 "Inj peak position [ADC ticks]",
99 18, 0, 18, 16, 0, 16);
104 1.0, 1.5, 2.0, 4, 6, 8, 10
108 static const std::string part_names[] = {
"fwd",
"bar",
"bwd"};
109 static const std::string title_suffix[] = {
110 "in fwd endcap",
"in barrel",
"in bwd endcap"
113 for (
int ler_her = 0; ler_her < 2; ler_her++) {
114 std::string ring_name = (ler_her == 0) ?
"LER" :
"HER";
115 for (
int part = 0; part < 3; part++) {
116 std::string suffix = title_suffix[part];
117 for (
int i = 0; i < ped_peak_range_count; i++) {
120 std::string name, title;
121 name = str(boost::format(
"ped_peak_%s_%s_%d") %
122 ring_name % part_names[part] % i);
123 title = str(boost::format(
"Peak height %.1f-%.1f ms after %s inj %s") %
124 min_time % max_time % ring_name % suffix);
126 auto h =
new TH1F(name.c_str(), title.c_str(), 300, 0.0, 0.3);
127 h->GetXaxis()->SetTitle(
"Peak height in first 16 points [GeV]");
150 if (!
mapper.
initFromDB()) B2FATAL(
"ECL Display:: Can't initialize eclChannelMapper");
175 bool bhatrig =
false;
179 try { bhatrig =
m_l1Trigger->testInput(
"bha_delay"); }
180 catch (
const std::exception&) { bhatrig =
false; }
188 unsigned int ECLDigitsAboveThr = 0;
189 unsigned int ECLDigitsAboveThr1MeV = 0;
191 int amp = aECLDigit.getAmp();
192 amps[aECLDigit.getCellId() - 1] = amp;
194 if (amp > 20) ECLDigitsAboveThr1MeV += 1;
197 int discarded_wfs = 0;
199 int crate = aECLTrig.getTrigId();
200 int suppress = aECLTrig.getBurstSuppressionMask();
204 bool shaper_bit = suppress & 1;
208 for (
int channel_pos = 0; channel_pos < 16; channel_pos ++) {
209 if (
mapper.
getCellId(crate, shaper_pos, channel_pos) > 0) discarded_wfs += 1;
212 for (
int channel_pos = 0; channel_pos < 16; channel_pos ++) {
214 if (cid > 0 && amps[cid - 1] >= (
v_totalthrApsd[cid - 1] / 4 * 4)) discarded_wfs += 1;
223 B2DEBUG(29,
"TTD FTSW : " << hex << it.GetTTUtime(0) <<
" " << it.GetTTCtime(0) <<
" EvtNr " << it.GetEveNo(0) <<
" Type " <<
224 (it.GetTTCtimeTRGType(0) & 0xF) <<
" TimeSincePrev " << it.GetTimeSincePrevTrigger(0) <<
" TimeSinceInj " <<
225 it.GetTimeSinceLastInjection(0) <<
" IsHER " << it.GetIsHER(0) <<
" Bunch " << it.GetBunchNumber(0));
228 auto difference = it.GetTimeSinceLastInjection(0);
230 if (difference == 0x7FFFFFFF)
continue;
233 float diff2 = difference / 127.;
236 int time_within_cycle = difference % 1280;
238 double time_in_cycle_us = time_within_cycle / 127.;
241 int time_within_cycle_adc_ticks = (1280 - time_within_cycle) / 72;
243 int is_her = it.GetIsHER(0);
245 if (is_her < 0 || is_her > 1)
continue;
268 for (range_id = 0; range_id < range_count; range_id++) {
272 if (diff2 > min_time && diff2 < max_time)
break;
275 if (range_id < range_count) {
280 int cid = aECLDsp.getCellId();
285 int hist_id = is_her * 3 * range_count + part_id * range_count + range_id;
298 aECLDsp.getDspA(adc);
302 int* ped_max = std::max_element(adc, adc + 16);
303 int* ped_min = std::min_element(adc, adc + 16);
305 if (*ped_max - *ped_min < 200)
continue;
306 int max_ped_id = ped_max - adc;
bool initFromDB()
Initialize channel mapper from the conditions database.
int getCellId(int iCrate, int iShaper, int iChannel)
Get CellId by given crate number, shaper position in the crate and DSP channel number in the shaper.
TH1F * hHitsAfterInjHER
Histogram Hits after HER injection.
TH2F * hVetoAfterInjLER
Histogram Veto tuning w/ ECL hits after LER injection.
TH2F * hInjkickTimeShift[2]
Histograms to determine injkick signal time offset for LER/HER injections.
TH1F * hEHitsAfterInjLER
Histogram for Nr Entries (=Triggrs) for normalization after LER injection.
void initialize() override final
initialize function
TH1F * hEHitsAfterInjHER
Histogram for Nr Entries (=Triggrs) for normalization after HER injection.
TH1F * hHitsAfterInjLER
Histogram Hits after LER injection.
bool m_DPHYTTYP
Flag to select events triggered by delayed bhabha.
TH2F * hVetoAfterInjHER
Histogram Veto tuning w/ ECL hits after HER injection.
TH1F * hBurstsAfterInjLER
Histogram Bursts suppression after LER injection.
TH1F * hEBurstsAfterInjLER
Histogram Bursts suppression for normalization after LER injection.
ECLDQMInjectionModule()
Constructor defining the parameters.
StoreArray< ECLDsp > m_ECLDsps
Input array for ECL waveform data.
StoreObjPtr< TRGSummary > m_l1Trigger
StoreObjPtr TRGSummary
double m_revolutionTime
The beam revolution cycle time in .
StoreArray< RawFTSW > m_rawTTD
Input array for DAQ Status.
void defineHisto() override final
defineHisto function
int m_iEvent
Global event number.
void event() override final
event function
std::string m_histogramDirectoryName
Name of the histogram directory in ROOT file.
StoreArray< ECLDigit > m_storeHits
Input array for ECL Raw Hits.
std::string m_ECLDigitsName
The name of the StoreArray of ECLRawHits to be generated.
std::vector< float > m_ped_peak_range
Injection time range (in ms) for h_ped_peak histograms.
double m_ECLThresholdforVetoTuning
ECL threshold for injection veto tuning, ADC channels.
TH1F * hBurstsAfterInjHER
Histogram Bursts suppression after HER injection.
TH1F * hEBurstsAfterInjHER
Histogram Bursts suppression for normalization after HER injection.
void beginRun() override final
beginRun function
StoreArray< ECLTrig > m_ECLTrigs
Input array for ECL burst suppressions.
StoreObjPtr< EventMetaData > m_eventmetadata
StoreObjPtr EventMetaData.
std::vector< int > v_totalthrApsd
Vector to store psd wf amplitude threshold.
std::vector< TH1F * > h_ped_peak
Distribution of pedestal peak (peak in first 16 waveform samples) after HER/LER injection,...
DBObjPtr< ECLCrystalCalib > m_calibrationThrApsd
PSD waveform amplitude threshold.
TH2F * hOccAfterInjLER
Histogram Occupancy after LER injection.
TH2F * hOccAfterInjHER
Histogram Occupancy after HER injection.
ECLChannelMapper mapper
ECL channel mapper.
static ECLPedestalFit pedestalFit(std::vector< int > adc)
Fit pedestal part of the signal waveform (first 16 samples) This method will fit the first 16 samples...
static void initPedestalFit()
Load DSP coefficients used in the pedestal fit function.
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
@ TTYP_DPHY
delayed physics events for background
@ TTYP_RAND
random trigger events
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
bool isBarrel(int cellId)
Check whether the crystal is in barrel ECL.
const int c_NCrystals
Number of crystals.
bool isBackward(int cellId)
Check whether the crystal is in backward ECL.
Abstract base class for different kinds of events.