Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions src/programs/Simulation/mcsmear/MyProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,16 @@ void MyProcessor::BeginRun(const std::shared_ptr<const JEvent>& event)
// Default parameters

int cdc_npeak = 1;
double cdc_nw = 179.;
double cdc_nw = 200.;

int fdc_nhits = 100;
// cathode strips fa125 readout
int fdc_npeak = 1;
double fdc_width = 80.;
double fdc_ie = 16;
double fdc_pg = 4;
double fdc_nw = 80.;

// wires f1tdc readout
int fdc_nhits = 100;
double fdc_width = 50;

int stc_npeak = 3;
int stc_nhits = 8;
double stc_width = 80;
Expand Down Expand Up @@ -307,28 +309,28 @@ void MyProcessor::BeginRun(const std::shared_ptr<const JEvent>& event)
cdc_nw = config->readout["CDC"].at("NW");
}

double cdc_gate = (cdc_nw - 21) * fadc125_period_ns;
// first 16 and last 20 samples are used for data processing
double cdc_gate = (cdc_nw - 36) * fadc125_period_ns;

hddm_s_merger::set_cdc_max_hits(cdc_npeak);
hddm_s_merger::set_cdc_integration_window_ns(cdc_gate);
hddm_s_merger::set_cdc_readout_window_ns(cdc_gate);



// hits merging / truncation parameters for the FDC
if(config->readout["FDC"].size() > 0){
fdc_nhits = config->readout["FDC"].at("NHITS");
fdc_width = config->readout["FDC"].at("WIDTH");
fdc_npeak = config->readout["FDC"].at("NPEAK");
fdc_width = config->readout["FDC"].at("WIDTH");
fdc_ie = config->readout["FDC"].at("IE");
fdc_pg = config->readout["FDC"].at("PG");
fdc_nw = config->readout["FDC"].at("NW");
}

double fdc_gate = (fdc_ie + fdc_pg) * fadc125_period_ns;
double fdc_gate = (fdc_nw - 36) * fadc125_period_ns;

hddm_s_merger::set_fdc_wires_max_hits(fdc_nhits);
hddm_s_merger::set_fdc_wires_min_delta_t_ns(fdc_width + 5.);
hddm_s_merger::set_fdc_strips_max_hits(fdc_npeak);
hddm_s_merger::set_fdc_strips_integration_window_ns(fdc_gate);
hddm_s_merger::set_fdc_strips_readout_window_ns(fdc_gate);



Expand Down
107 changes: 66 additions & 41 deletions src/programs/Simulation/mcsmear/hddm_s_merger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ static thread_local double t_shift_ns(0);

static thread_local bool enable_cdc_merging(true);
static thread_local int cdc_max_hits(1);
static thread_local double cdc_integration_window_ns(1432.);
static thread_local double cdc_readout_window_ns(1312.);

static thread_local bool enable_fdc_merging(true);
static thread_local int fdc_wires_max_hits(8);
static thread_local double fdc_wires_min_delta_t_ns(35.);
static thread_local int fdc_strips_max_hits(1);
static thread_local double fdc_strips_integration_window_ns(200.);
static thread_local double fdc_strips_readout_window_ns(352.);

static thread_local bool enable_stc_merging(true);
static thread_local int stc_adc_max_hits(3);
Expand Down Expand Up @@ -144,12 +144,12 @@ namespace hddm_s_merger {
cdc_max_hits = maxhits;
}

double get_cdc_integration_window_ns() {
return cdc_integration_window_ns;
double get_cdc_readout_window_ns() {
return cdc_readout_window_ns;
}

void set_cdc_integration_window_ns(double dt_ns) {
cdc_integration_window_ns = dt_ns;
void set_cdc_readout_window_ns(double dt_ns) {
cdc_readout_window_ns = dt_ns;
}

bool get_fdc_merging() {
Expand Down Expand Up @@ -184,12 +184,12 @@ namespace hddm_s_merger {
fdc_strips_max_hits = maxhits;
}

double get_fdc_strips_integration_window_ns() {
return fdc_strips_integration_window_ns;
double get_fdc_strips_readout_window_ns() {
return fdc_strips_readout_window_ns;
}

void set_fdc_strips_integration_window_ns(double dt_ns) {
fdc_strips_integration_window_ns = dt_ns;
void set_fdc_strips_readout_window_ns(double dt_ns) {
fdc_strips_readout_window_ns = dt_ns;
}

bool get_stc_merging() {
Expand Down Expand Up @@ -742,7 +742,7 @@ hddm_s::CdcStrawHitList &operator+=(hddm_s::CdcStrawHitList &dst,

double t = iter_firsthit->getT() + t_shift_ns;

if (t > cdc_integration_window_ns) return dst; // new hit is too late, don't use it.
if (t > cdc_readout_window_ns) return dst; // new hit is too late, don't use it.


double newQ = iter_firsthit->getQ();
Expand Down Expand Up @@ -963,41 +963,66 @@ hddm_s::FdcCathodeStripList &operator+=(hddm_s::FdcCathodeStripList &dst,
hddm_s::FdcCathodeHitList &operator+=(hddm_s::FdcCathodeHitList &dst,
hddm_s::FdcCathodeHitList &src)
{
// order by t, merge with existing hit if close enough
int iord = 0;

// There should be no more than one hit in dst - assume this is the case. (otherwise, would have to pick the earliest)

// Find the earliest (random) hit in src, ignore the later ones, if any.
// If it is before the original hit, replace the original hit's time and peak height.
// If it is at the same time sample as the original hit, sum the pulse height.
// If it is after the original hit, leave the original hit's time and peak height alone.


hddm_s::FdcCathodeHitList::iterator iter;
hddm_s::FdcCathodeHitList::iterator iter_firsthit;

iter_firsthit = src.begin();
double t_firsthit = iter_firsthit->getT();

for (iter = src.begin(); iter != src.end(); ++iter) {
double t = iter->getT() + t_shift_ns;
double ti = fdc_strips_integration_window_ns;
double dt = ti + 2*fadc125_period_ns;
double newQ = iter->getQ();
while (iord > 0 && dst(iord).getT() > t)
--iord;
while (iord < dst.size() && dst(iord).getT() < t)
++iord;
if (iord > 0 && t - dst(iord - 1).getT() < dt) {
--iord;
double oldQ = dst(iord).getQ();
double pulse_fraction = 1 - (t - dst(iord).getT()) / ti;
if (pulse_fraction > 0)
dst(iord).setQ(oldQ + newQ * pulse_fraction);
}
else if (iord < dst.size() && dst(iord).getT() - t < dt) {
double oldQ = dst(iord).getQ();
double pulse_fraction = 1 - (dst(iord).getT() - t) / ti;
if (pulse_fraction > 0)
dst(iord).setQ(newQ + oldQ * pulse_fraction);
else
dst(iord).setQ(newQ);
dst(iord).setT(t);
}
else {
dst.add(1, (iord < dst.size())? iord : -1);
dst(iord).setQ(newQ);
dst(iord).setT(t);
double this_t = iter->getT();
if (this_t < t_firsthit) {
t_firsthit = this_t;
iter_firsthit = iter;
}
}

double t = iter_firsthit->getT() + t_shift_ns;
if (t > fdc_strips_readout_window_ns) return dst; // random is too late

double newQ = iter_firsthit->getQ();

if (dst.size() == 0) { // no hits exist, add the random
dst.add(1, -1);
dst(0).setT(t);
dst(0).setQ(newQ);

} else {

// convert time into 8ns samples to see if hits arrive in same sample

double origT = dst(0).getT();

int src_hitsample = (int)(t/fadc125_period_ns);
int dst_hitsample = (int)(origT/fadc125_period_ns);

double origQ = dst(0).getQ();

if (src_hitsample == dst_hitsample) { // same sample, add pulse heights

if (t < origT) dst(0).setT(t);
dst(0).setQ(origQ + newQ);

} else if (src_hitsample < dst_hitsample) { // random arrives earlier, replace hit time and pulse height

dst(0).setT(t);
dst(0).setQ(newQ);

} // if the random hit is after the original one, it is too late, ignore it.

}

return dst;

}

hddm_s::StartCntrList &operator+=(hddm_s::StartCntrList &dst,
Expand Down
8 changes: 4 additions & 4 deletions src/programs/Simulation/mcsmear/hddm_s_merger.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ namespace hddm_s_merger {
void set_cdc_merging(bool merging_status);
int get_cdc_max_hits();
void set_cdc_max_hits(int maxhits);
double get_cdc_integration_window_ns();
void set_cdc_integration_window_ns(double dt_ns);
double get_cdc_readout_window_ns();
void set_cdc_readout_window_ns(double dt_ns);

// hits merging / truncation parameters for the FDC
bool get_fdc_merging();
Expand All @@ -35,8 +35,8 @@ namespace hddm_s_merger {
void set_fdc_wires_min_delta_t_ns(double dt_ns);
int get_fdc_strips_max_hits();
void set_fdc_strips_max_hits(int maxhits);
double get_fdc_strips_integration_window_ns();
void set_fdc_strips_integration_window_ns(double dt_ns);
double get_fdc_strips_readout_window_ns();
void set_fdc_strips_readout_window_ns(double dt_ns);

// hits merging / truncation parameters for the STC
bool get_stc_merging();
Expand Down
Loading