Project
Loading...
Searching...
No Matches
test-raw2digit.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#include <TSystem.h>
13#include <TTree.h>
16#include <TFile.h>
17#include <iostream>
18
19using namespace o2::fv0;
20int main()
21{
22 using Digit = o2::fv0::Digit;
23 struct EventFV0_t {
24 Digit mDigit;
25 std::vector<o2::fv0::ChannelData> mVecChannelData;
26 bool operator==(const EventFV0_t& other) const
27 {
28 return mDigit == other.mDigit && mVecChannelData == other.mVecChannelData;
29 }
30 void print() const
31 {
32 mDigit.printLog();
33 for (const auto& entry : mVecChannelData) {
34 entry.printLog();
35 }
36 }
37 };
38 std::vector<EventFV0_t> vecTotalEvents, vecTotalEvents2;
39 gSystem->Exec("$O2_ROOT/bin/o2-sim -n 10 -m FV0 -g pythia8pp");
40 gSystem->Exec("$O2_ROOT/bin/o2-sim-digitizer-workflow -b");
41 TFile flIn("fv0digits.root");
42 std::unique_ptr<TTree> treeInput((TTree*)flIn.Get("o2sim"));
43 std::vector<Digit> vecDigits;
44 std::vector<Digit>* ptrVecDigits = &vecDigits;
45 std::vector<ChannelData> vecChannelData;
46 std::vector<ChannelData>* ptrVecChannelData = &vecChannelData;
47 treeInput->SetBranchAddress(Digit::sDigitBranchName, &ptrVecDigits);
48 treeInput->SetBranchAddress(ChannelData::sDigitBranchName, &ptrVecChannelData);
49 std::cout << "Tree nEntries:" << treeInput->GetEntries() << std::endl;
50 for (int iEvent = 0; iEvent < treeInput->GetEntries(); iEvent++) { //Iterating TFs in tree
51 treeInput->GetEntry(iEvent);
52 for (const auto& digit : (*ptrVecDigits)) { //Iterating over all digits in given TF
53 auto itBegin = ptrVecChannelData->begin();
54 std::advance(itBegin, digit.ref.getFirstEntry());
55 auto itEnd = ptrVecChannelData->begin();
56 std::advance(itEnd, digit.ref.getFirstEntry() + digit.ref.getEntries());
57 //Event within given TF
58 auto eventFV0 = EventFV0_t{digit, std::vector<ChannelData>{itBegin, itEnd}};
59 vecTotalEvents.push_back(eventFV0);
60 }
61 }
62 std::cout << "\n===================================\n";
63 for (const auto& entry : vecTotalEvents) {
64 entry.print();
65 }
66 std::cout << "\n===================================\n";
67
68 std::cout << "\nTOTAL EVENTS: " << vecTotalEvents.size() << std::endl;
69 std::cout << "Simulation completed!" << std::endl;
70 gSystem->Exec("$O2_ROOT/bin/o2-fv0-digi2raw --file-for link --configKeyValues \"HBFUtils.nHBFPerTF=128;HBFUtils.orbitFirst=0\"");
71 gSystem->Exec("$O2_ROOT/bin/o2-raw-file-reader-workflow -b --input-conf FV0raw.cfg --configKeyValues \"HBFUtils.nHBFPerTF=128;HBFUtils.orbitFirst=0\"|$O2_ROOT/bin/o2-fv0-flp-dpl-workflow -b");
72 TFile flIn2("o2_fv0digits.root");
73 std::unique_ptr<TTree> treeInput2((TTree*)flIn2.Get("o2sim"));
74 std::cout << "Reconstruction completed!" << std::endl;
75
76 treeInput2->SetBranchAddress(Digit::sDigitBranchName, &ptrVecDigits);
77 treeInput2->SetBranchAddress(ChannelData::sDigitBranchName, &ptrVecChannelData);
78 std::cout << "Tree nEntries: " << treeInput2->GetEntries() << std::endl;
79 for (int iEvent = 0; iEvent < treeInput2->GetEntries(); iEvent++) { //Iterating TFs in tree
80 treeInput2->GetEntry(iEvent);
81 for (const auto& digit : (*ptrVecDigits)) { //Iterating over all digits in given TF
82 auto itBegin = ptrVecChannelData->begin();
83 std::advance(itBegin, digit.ref.getFirstEntry());
84 auto itEnd = ptrVecChannelData->begin();
85 std::advance(itEnd, digit.ref.getFirstEntry() + digit.ref.getEntries());
86 //Event within given TF
87 auto eventFV0 = EventFV0_t{digit, std::vector<ChannelData>{itBegin, itEnd}};
88 vecTotalEvents2.push_back(eventFV0);
89 }
90 }
91 std::cout << "\n===================================\n";
92 for (const auto& entry : vecTotalEvents2) {
93 entry.print();
94 }
95 std::cout << "\n===================================\n";
96 std::cout << "\nTOTAL EVENTS: " << vecTotalEvents2.size() << std::endl;
97 if (vecTotalEvents == vecTotalEvents2) {
98 std::cout << "TEST IS OK!\n";
99 } else {
100 std::cout << "\nDIFFERENCE BETWEEN SRC AND DEST\n";
101 std::cout << "\n===============================\n";
102 for (int iEntry = 0; iEntry < std::max(vecTotalEvents.size(), vecTotalEvents2.size()); iEntry++) {
103 if (iEntry < vecTotalEvents.size() && iEntry < vecTotalEvents2.size()) {
104 if (vecTotalEvents[iEntry] == vecTotalEvents2[iEntry]) {
105 continue;
106 }
107 }
108 std::cout << "\nEntryID: " << iEntry;
109 std::cout << "\n------------------------------SOURCE------------------------------\n";
110 if (iEntry < vecTotalEvents.size()) {
111 vecTotalEvents[iEntry].print();
112 } else {
113 std::cout << "\nEMPTY!\n";
114 }
115 std::cout << "\n------------------------------DESTINATION------------------------------\n";
116 if (iEntry < vecTotalEvents2.size()) {
117 vecTotalEvents2[iEntry].print();
118 } else {
119 std::cout << "\nEMPTY!\n";
120 }
121 }
122 std::cout << "\nERROR!\n";
123 }
124 return 0;
125}
Class to describe fired triggered and/or stored channels for the BC and to refer to channel data.
Container class to store time and charge values of single FV0 channel.
void print() const
int main()
GLuint entry
Definition glcorearb.h:5735
static constexpr char sDigitBranchName[]
Definition ChannelData.h:28
void printLog() const
Definition Digit.cxx:38
static constexpr char sDigitBranchName[]
Definition Digit.h:59
bool operator==(const CoarseLocation &a, const CoarseLocation &b)
VectorOfTObjectPtrs other
TFile flIn("test_ctf_cpv.root")