Project
Loading...
Searching...
No Matches
RecoQCworkflow.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
15
16#include <fairlogger/Logger.h>
20#include "Framework/Task.h"
28#include "TStopwatch.h"
29#include <TString.h>
30#include <vector>
31#include <TH1F.h>
32#include <TH2F.h>
33#include <TFile.h>
34#include <TMath.h>
35#include <vector>
36#include <map>
37
38using namespace o2::framework;
39using namespace o2::math_utils::detail;
44
45namespace o2::ft0
46{
47
49{
50 mFileOut = TFile::Open("RecoQChistos.root", "RECREATE");
51 TString histnames[9] = {"hT0AcorrPV", "hT0CcorrPV", "resolution", "hT0A", "hT0C", "hT0AC"};
52 for (int ihist = 0; ihist < 6; ihist++) {
53 mHisto[ihist] = new TH1F(histnames[ihist].Data(), histnames[ihist].Data(), 300, -1000, 1000);
54 }
55 mVertexT0 = new TH1F("VertexT0", "T0 vertex", 100, -30, 30);
56 mPV = new TH1F("PV", "primary vertex", 100, -30, 30);
57 mVertexComp = new TH2F("hVertexComp", "FT0 and PV comparion", 100, -30, 30, 100, -30, 30);
58 mTimer.Stop();
59 mTimer.Reset();
60}
62{
64 recoData.collectData(pc, *mDataRequest);
65 auto primVertices = recoData.getPrimaryVertices();
66 auto ft0RecPoints = recoData.getFT0RecPoints();
67 std::map<uint64_t, o2::dataformats::PrimaryVertex const*> bcsMap;
68 for (auto& vertex : primVertices) {
69 auto& timeStamp = vertex.getTimeStamp();
70 double tsTimeStamp = timeStamp.getTimeStamp() * 1E3; // mus to ns
71 uint64_t globalBC = std::round(tsTimeStamp / o2::constants::lhc::LHCBunchSpacingNS);
72 auto [iter, inserted] = bcsMap.try_emplace(globalBC, &vertex);
73 if (!inserted) {
74 iter->second = nullptr;
75 }
76 }
77 float vertexT0;
78 for (auto& ft0RecPoint : ft0RecPoints) {
79 uint64_t bc = ft0RecPoint.getInteractionRecord().toLong();
80 auto item = bcsMap.find(bc);
81
82 if (std::abs(ft0RecPoint.getCollisionTimeA()) < 2000) {
83 mHisto[3]->Fill(ft0RecPoint.getCollisionTimeA());
84 }
85 if (std::abs(ft0RecPoint.getCollisionTimeC()) < 2000) {
86 mHisto[4]->Fill(ft0RecPoint.getCollisionTimeC());
87 }
88
89 if (std::abs(ft0RecPoint.getCollisionTimeC()) < 2000 &&
90 std::abs(ft0RecPoint.getCollisionTimeA()) < 2000) {
91 mHisto[5]->Fill(ft0RecPoint.getCollisionTimeMean());
92 vertexT0 = 0.5 * (ft0RecPoint.getCollisionTimeC() - ft0RecPoint.getCollisionTimeA()) * cSpeed;
93 mVertexT0->Fill(vertexT0);
94 }
95 if (item == bcsMap.end() || item->second == nullptr) {
96 LOG(debug) << "Error: could not find a corresponding BC ID for a FT0 rec. point; BC = " << bc;
97 continue;
98 }
99 auto& vertex = *item->second;
100 auto currentVertex = vertex.getZ();
101 mPV->Fill(currentVertex);
102 ushort ncont = vertex.getNContributors();
103 LOG(debug) << "CurrentVertex " << currentVertex << " ncont " << int(ncont);
104 if (ncont < 3) {
105 continue;
106 }
107 auto shift = currentVertex / cSpeed;
108 short t0A = ft0RecPoint.getCollisionTimeA() + shift;
109 short t0C = ft0RecPoint.getCollisionTimeC() - shift;
110
111 LOG(info) << " BC t0 " << bc << " shift " << shift << " A " << t0A << " C " << t0C << " vertex " << vertexT0 << " PV " << currentVertex;
112 mHisto[0]->Fill(t0A);
113 mHisto[1]->Fill(t0C);
114 mHisto[2]->Fill((t0C - t0A) / 2);
115 mVertexComp->Fill(vertexT0, currentVertex);
116 }
117 mTimer.Stop();
118}
120{
121 mFileOut->cd();
122 for (int ihist = 0; ihist < 6; ihist++) {
123 mHisto[ihist]->Write();
124 }
125 mPV->Write();
126 mVertexT0->Write();
127 mVertexComp->Write();
128 mFileOut->Close();
129}
130
132{
133 auto dataRequest = std::make_shared<DataRequest>();
134 LOG(info) << "@@ request primary vertex";
135 dataRequest->requestPrimaryVertices(false);
136 dataRequest->requestFT0RecPoints(false);
137 LOG(info) << "@@@ requested T0";
138 std::vector<OutputSpec> outputs; // empty
139
140 return DataProcessorSpec{
141 "reco-qc",
142 dataRequest->inputs,
143 outputs,
144 AlgorithmSpec{adaptFromTask<o2::ft0::RecoQCworkflow>(src, dataRequest)},
145 Options{}};
146}
147
148}; // namespace o2::ft0
Wrapper container for different reconstructed object types.
std::ostringstream debug
uint64_t vertex
Definition RawEventData.h:9
uint64_t bc
Definition RawEventData.h:5
Definition of the FIT RecPoints class.
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
Global index for barrel track: provides provenance (detectors combination), index in respective array...
void endOfStream(framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void init(InitContext &ic) final
void run(o2::framework::ProcessingContext &pc) final
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
framework::DataProcessorSpec getRecoQCworkflow(GID::mask_t src)
void collectData(o2::framework::ProcessingContext &pc, const DataRequest &request)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"