Project
Loading...
Searching...
No Matches
testInteractionSampler.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#define BOOST_TEST_MODULE Test InteractionSampler class
13#define BOOST_TEST_MAIN
14#define BOOST_TEST_DYN_LINK
15
16#include <boost/test/unit_test.hpp>
21#include "TFile.h"
22#include "TGrid.h"
23#include <TH1F.h>
24
25namespace o2
26{
27
28BOOST_AUTO_TEST_CASE(NonUniformSampler)
29{
30 auto run_number = 559827;
31 TGrid::Connect("alien");
32 if (gGrid) {
34
36 sampler.setBunchFilling(runInfo.grpLHC->getBunchFilling());
37
38 // the test distribution provided by Igor Altsybeev
39 auto distr_file = TFile::Open("alien:///alice/cern.ch/user/s/swenzel/AliceO2_TestData/NBcVTX_559827/hBcTVX_data_PbPb_24ar_559827.root");
40
41 //
42 if (distr_file && !distr_file->IsZombie()) {
43 auto hist = distr_file->Get<TH1F>("hBcTVX");
44 if (hist) {
45 sampler.init();
46 sampler.setBCIntensityScales(*hist);
47
48 // sample into a vector of a certain size
49 std::vector<o2::InteractionTimeRecord> samples;
50
51 int N = 100000;
52 samples.resize(N);
53
54 sampler.generateCollisionTimes(samples);
55
56 // fill an output histogram
57 auto output_hist = (TH1F*)hist->Clone("h2"); // make a full copy
58 output_hist->Reset();
59
60 for (const auto& sample : samples) {
61 output_hist->Fill(sample.bc);
62 }
63
64 // Write out
65 auto fout = TFile::Open("NBCVTX_out.root", "RECREATE");
66 fout->WriteObject(output_hist, "NBcVTX");
67 fout->Close();
68
69 // compare mean values of original and newly sampled hist
70 BOOST_CHECK_CLOSE(hist->GetMean(), output_hist->GetMean(), 0.5);
71 }
72 }
73 }
74}
75
76} // namespace o2
container for the LHC InterFace data
static BasicCCDBManager & instance()
void setBunchFilling(const BunchFilling &bc)
GLuint sampler
Definition glcorearb.h:1630
GLsizei samples
Definition glcorearb.h:1309
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
BOOST_AUTO_TEST_CASE(FlatHisto)
static AggregatedRunInfo buildAggregatedRunInfo(int runnumber, long sorMS, long eorMS, long orbitResetMUS, const o2::parameters::GRPECSObject *grpecs, const std::vector< Long64_t > *ctfFirstRunOrbitVec, const o2::parameters::GRPLHCIFData *grplhcif=nullptr)