|
| 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 | +/// \file checkAOD2CTPDigits.C |
| 13 | +/// \brief create CTP config, test it and add to database |
| 14 | +/// \author Roman Lietava |
| 15 | + |
| 16 | +#if !defined(__CLING__) || defined(__ROOTCLING__) |
| 17 | + |
| 18 | +#include <fairlogger/Logger.h> |
| 19 | +#include "TFile.h" |
| 20 | +#include "TTree.h" |
| 21 | +#include <string> |
| 22 | +#include <iostream> |
| 23 | +#include <vector> |
| 24 | +#include "TKey.h" |
| 25 | +#include "TTreeReader.h" |
| 26 | +#include "TTreeReaderValue.h" |
| 27 | +#endif |
| 28 | +// To produce CTP digits: |
| 29 | +// o2-raw-tf-reader-workflow -b --onlyDet CTP,FT0 --input-data list.txt | o2-ctp-reco-workflow -b --use-verbose-mode |
| 30 | +// To produce AOD: |
| 31 | +// WORKFLOW_PARAMETERS="AOD" WORKFLOW_DETECTORS="CTP,FT0,FV0" IGNORE_EXISTING_SHMFILES=1 $O2_ROOT/prodtests/full-system-test/run-workflow-on-inputlist.sh TF list.txt |
| 32 | +using namespace o2::ctp; |
| 33 | +int CheckAOD2CTPDigits(bool files = 0) |
| 34 | +{ |
| 35 | + if (files == 0) { |
| 36 | + return 0; |
| 37 | + } |
| 38 | + int fRunNumber; |
| 39 | + ULong64_t fGlobalBC; |
| 40 | + ULong64_t fTriggerMask; |
| 41 | + std::unique_ptr<TFile> file(TFile::Open("AO2D.root")); |
| 42 | + file->ls(); |
| 43 | + TIter keyList(file->GetListOfKeys()); |
| 44 | + TKey* key; |
| 45 | + TTree* tree; |
| 46 | + ; |
| 47 | + std::map<ULong64_t, ULong64_t> bc2classmask; |
| 48 | + // Find aod trigger info |
| 49 | + while ((key = (TKey*)keyList())) { |
| 50 | + std::cout << key->GetName() << std::endl; |
| 51 | + tree = (TTree*)file->Get(Form("%s/O2bc", key->GetName())); |
| 52 | + if (tree != 0) { |
| 53 | + std::cout << "found O2bc" << std::endl; |
| 54 | + tree->SetBranchAddress("fRunNumber", &fRunNumber); |
| 55 | + tree->SetBranchAddress("fGlobalBC", &fGlobalBC); |
| 56 | + tree->SetBranchAddress("fTriggerMask", &fTriggerMask); |
| 57 | + std::cout << "# of entries:" << tree->GetEntries() << std::endl; |
| 58 | + int NN = tree->GetEntries(); |
| 59 | + int Nloop = NN; |
| 60 | + for (int n{0}; n < Nloop; ++n) { |
| 61 | + tree->GetEvent(n); |
| 62 | + if (fTriggerMask) { |
| 63 | + bc2classmask[fGlobalBC] = fTriggerMask; |
| 64 | + // std::cout << std::dec << n << " Run:" << fRunNumber << " GBC:" << std::hex << fGlobalBC << " TM:0x" << std::hex << fTriggerMask << " count:" << bc2classmask.count(fGlobalBC) << std::endl; |
| 65 | + } |
| 66 | + } |
| 67 | + } else { |
| 68 | + return 1; |
| 69 | + } |
| 70 | + } |
| 71 | + // Read CTP digits and check if every class mask in digits is in AOD |
| 72 | + // CTP digits |
| 73 | + TFile* fileDigits = TFile::Open("ctpdigits.root"); |
| 74 | + // |
| 75 | + fileDigits->ls(); |
| 76 | + o2::ctp::CTPDigit* dig = new o2::ctp::CTPDigit; |
| 77 | + // |
| 78 | + // tree->Print(); |
| 79 | + TTreeReader reader("o2sim", fileDigits); |
| 80 | + TTreeReaderValue<std::vector<o2::ctp::CTPDigit>> ctpdigs(reader, "CTPDigits"); |
| 81 | + // TTreeReaderArray<o2::ctp::CTPDigit> ctpdigs(reader,"CTPDigits"); |
| 82 | + bool firstE = true; |
| 83 | + // |
| 84 | + std::bitset<48> tvxmask; |
| 85 | + tvxmask.set(2); |
| 86 | + int ncls = 0; |
| 87 | + int nnotf = 0; |
| 88 | + while (reader.Next()) { |
| 89 | + if (ctpdigs.GetSetupStatus() < 0) { |
| 90 | + std::cout << "Error:" << std::dec << ctpdigs.GetSetupStatus() << " for:" << ctpdigs.GetBranchName() << std::endl; |
| 91 | + return 1; |
| 92 | + } |
| 93 | + // std::cout << "size:" << std::dec << ctpdigs.GetSize() << std::endl; |
| 94 | + std::cout << "size:" << std::dec << ctpdigs->size() << std::endl; |
| 95 | + for (auto const& dig : *ctpdigs) { |
| 96 | + if (dig.CTPClassMask.count()) { |
| 97 | + ULong64_t gbc = dig.intRecord.toLong(); |
| 98 | + // int del = 280+17; |
| 99 | + if (bc2classmask.count(gbc)) { |
| 100 | + // std::cout << std::hex << gbc << "aod clsmask:" << bc2classmask[gbc] << " " << dig.CTPClassMask.to_ullong() << " inps:" << dig.CTPInputMask.to_ullong() << std::endl; |
| 101 | + // dig.printStream(std::cout); |
| 102 | + } else { |
| 103 | + std::cout << std::dec << dig.intRecord.orbit << " " << dig.intRecord.bc << " " << std::hex << dig.intRecord.toLong() << " not found " << bc2classmask.count(gbc) << std::endl; |
| 104 | + } |
| 105 | + } |
| 106 | + } |
| 107 | + } |
| 108 | + return 0; |
| 109 | +} |
0 commit comments