Skip to content

Commit 7dc2563

Browse files
authored
Merge branch 'AliceO2Group:master' into master
2 parents a928ff4 + 6d85da1 commit 7dc2563

File tree

4 files changed

+86
-6
lines changed

4 files changed

+86
-6
lines changed

MC/bin/o2dpg_sim_workflow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,9 @@ def remove_json_prefix(path):
20952095
TPCTStask['cmd'] += ' --primary-vertices '
20962096
TPCTStask['cmd'] += ' | o2-tpc-time-series-workflow --enable-unbinned-root-output --sample-unbinned-tsallis --sampling-factor 0.01 '
20972097
TPCTStask['cmd'] += putConfigValues() + ' ' + getDPL_global_options(bigshm=True)
2098-
workflow['stages'].append(TPCTStask)
2098+
if isActive('TOF') and isActive('TPC') and isActive('FT0'):
2099+
# could be relaxed or changed once the timerseries worklow is more reactive to input cluster- and track-types
2100+
workflow['stages'].append(TPCTStask)
20992101

21002102
# cleanup
21012103
# --------

MC/bin/o2dpg_sim_workflow_anchored.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,21 @@ def retrieve_CTPScalers(ccdbreader, run_number, timestamp=None):
266266
return ctpscaler
267267
return None
268268

269+
def retrieve_ITS_RampDuration(ccdbreader, timestamp):
270+
"""
271+
Retrieves the ITS ramp-up duration for a given timestamp and
272+
returns it in milliseconds.
273+
ITS does not deliver digits during a certain ramp-up period so
274+
the start of run is adjusted accordingly using this value.
275+
"""
276+
_, ramp_duration = ccdbreader.fetch("ITS/Calib/RampDuration", "vector<float>", timestamp=timestamp)
277+
if ramp_duration and len(ramp_duration) > 0:
278+
# The vector contains the duration in seconds, convert to milliseconds
279+
duration_ms = int(ramp_duration[0] * 1000)
280+
return duration_ms
281+
print("WARNING: ITS ramp duration vector is empty, using 0")
282+
return 0
283+
269284
def retrieve_MinBias_CTPScaler_Rate(ctpscaler, finaltime, trig_eff_arg, NBunches, ColSystem, eCM):
270285
"""
271286
retrieves the CTP scalers object for a given timestamp
@@ -520,7 +535,11 @@ def main():
520535
run_start = GLOparams["SOR"]
521536
run_end = GLOparams["EOR"]
522537

523-
mid_run_timestamp = (run_start + run_end) // 2
538+
# Adjust start of run using ITS ramp-up period
539+
ITS_rampup = retrieve_ITS_RampDuration(ccdbreader, run_start)
540+
print(f"ITS ramp-up time: {ITS_rampup} ms")
541+
effective_run_start = run_start + ITS_rampup
542+
mid_run_timestamp = (effective_run_start + run_end) // 2
524543

525544
# --------
526545
# fetch other important global properties needed further below
@@ -580,16 +599,16 @@ def main():
580599
timestamp = 0
581600
prod_offset = 0
582601
if args.timeframeID != -1:
583-
timestamp = determine_timestamp_from_timeframeID(run_start, run_end, args.timeframeID, GLOparams["OrbitsPerTF"])
602+
timestamp = determine_timestamp_from_timeframeID(effective_run_start, run_end, args.timeframeID, GLOparams["OrbitsPerTF"])
584603
prod_offset = args.timeframeID
585604
else:
586-
timestamp, prod_offset = determine_timestamp(run_start, run_end, [args.split_id - 1, args.prod_split], args.cycle, args.tf, GLOparams["OrbitsPerTF"])
605+
timestamp, prod_offset = determine_timestamp(effective_run_start, run_end, [args.split_id - 1, args.prod_split], args.cycle, args.tf, GLOparams["OrbitsPerTF"])
587606

588607
# determine orbit corresponding to timestamp (mainly used in exclude_timestamp function)
589608
orbit = GLOparams["FirstOrbit"] + int((timestamp - GLOparams["SOR"]) / ( LHCOrbitMUS / 1000))
590609

591610
# this is anchored to
592-
print ("Determined start-of-run to be: ", run_start)
611+
print ("Determined start-of-run to be: ", effective_run_start)
593612
print ("Determined end-of-run to be: ", run_end)
594613
print ("Determined timestamp to be : ", timestamp)
595614
print ("Determined offset to be : ", prod_offset)
@@ -630,7 +649,7 @@ def main():
630649
# However, the last passed argument wins, so they would be overwritten. If this should not happen, the option
631650
# needs to be handled as further below:
632651
energyarg = (" -eCM " + str(eCM)) if A1 == A2 else (" -eA " + str(eA) + " -eB " + str(eB))
633-
forwardargs += " -tf " + str(args.tf) + " --sor " + str(run_start) + " --timestamp " + str(timestamp) + " --production-offset " + str(prod_offset) + " -run " + str(args.run_number) + " --run-anchored --first-orbit " \
652+
forwardargs += " -tf " + str(args.tf) + " --sor " + str(effective_run_start) + " --timestamp " + str(timestamp) + " --production-offset " + str(prod_offset) + " -run " + str(args.run_number) + " --run-anchored --first-orbit " \
634653
+ str(GLOparams["FirstOrbit"]) + " --orbitsPerTF " + str(GLOparams["OrbitsPerTF"]) + " -col " + str(ColSystem) + str(energyarg)
635654
# the following options can be overwritten/influence from the outside
636655
if not '--readoutDets' in forwardargs:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[GeneratorExternal]
2+
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_longlived_gaptriggered.C
3+
funcName=generateLongLivedGapTriggered({1000010020}, 1, 4, 0.4, 8.0)
4+
5+
[GeneratorPythia8]
6+
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/common/pythia8/generator/pythia8_OO_536.cfg
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
int External()
2+
{
3+
std::string path{"o2sim_Kine.root"};
4+
std::vector<int> possiblePDGs = {1000010020, -1000010020};
5+
6+
int nPossiblePDGs = possiblePDGs.size();
7+
8+
TFile file(path.c_str(), "READ");
9+
if (file.IsZombie())
10+
{
11+
std::cerr << "Cannot open ROOT file " << path << "\n";
12+
return 1;
13+
}
14+
15+
auto tree = (TTree *)file.Get("o2sim");
16+
if (!tree)
17+
{
18+
std::cerr << "Cannot find tree o2sim in file " << path << "\n";
19+
return 1;
20+
}
21+
std::vector<o2::MCTrack> *tracks{};
22+
tree->SetBranchAddress("MCTrack", &tracks);
23+
24+
std::vector<int> injectedPDGs;
25+
26+
auto nEvents = tree->GetEntries();
27+
for (int i = 0; i < nEvents; i++)
28+
{
29+
auto check = tree->GetEntry(i);
30+
for (int idxMCTrack = 0; idxMCTrack < tracks->size(); ++idxMCTrack)
31+
{
32+
auto track = tracks->at(idxMCTrack);
33+
auto pdg = track.GetPdgCode();
34+
auto it = std::find(possiblePDGs.begin(), possiblePDGs.end(), pdg);
35+
if (it != possiblePDGs.end() && track.isPrimary()) // found
36+
{
37+
injectedPDGs.push_back(pdg);
38+
}
39+
}
40+
}
41+
std::cout << "--------------------------------\n";
42+
std::cout << "# Events: " << nEvents << "\n";
43+
if(injectedPDGs.empty()){
44+
std::cerr << "No injected particles\n";
45+
return 1; // At least one of the injected particles should be generated
46+
}
47+
for (int i = 0; i < nPossiblePDGs; i++)
48+
{
49+
std::cout << "# Injected nuclei \n";
50+
std::cout << possiblePDGs[i] << ": " << std::count(injectedPDGs.begin(), injectedPDGs.end(), possiblePDGs[i]) << "\n";
51+
}
52+
return 0;
53+
}

0 commit comments

Comments
 (0)