R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandTacquilaMapped2QCalPar.cxx
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2019-2025 Members of R3B Collaboration *
4 * *
5 * This software is distributed under the terms of the *
6 * GNU General Public Licence (GPL) version 3, *
7 * copied verbatim in the file "LICENSE". *
8 * *
9 * In applying this license GSI does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 ******************************************************************************/
13
15#include "FairLogger.h"
16#include "FairRuntimeDb.h"
17#include "R3BEventHeader.h"
18#include "R3BNeulandQCalPar.h"
20#include "R3BTCalEngine.h"
21#include "TClonesArray.h"
22#include "TH1F.h"
23#include <FairRootManager.h>
24
25#define nPMTs 2 * fPaddles* fPlanes
26
28 : FairTask(name, iVerbose)
29 , fPar(NULL)
30 , fHits(NULL)
31{
32}
33
35 : FairTask("R3BNeulandTacquilaMapped2QCalPar")
36 , fPar(NULL)
37 , fHits(NULL)
38{
39}
40
42{
43 if (fData.size() > 0)
44 for (Int_t plane = fPlanes - 1; plane >= 0; plane--)
45 for (Int_t bar = fPaddles - 1; bar >= 0; bar--)
46 for (Int_t side = 1; side <= 2; side++)
47 fData.at(plane).at(bar).at(side)->Delete();
48
49 if (fPar)
50 delete fPar;
51}
52
54{
55 FairRootManager* fMan = FairRootManager::Instance();
56 if (!fMan)
57 {
58 LOG(fatal) << " FairRootManager not found.";
59 return kFATAL;
60 }
61 fHits = dynamic_cast<TClonesArray*>(fMan->GetObject("NeulandTacquilaMappedData"));
62 if (!fHits)
63 {
64 LOG(fatal) << " Branch: NeulandTacquilaMappedData not found in Tree.";
65 return kFATAL;
66 }
67 header = dynamic_cast<R3BEventHeader*>(fMan->GetObject("R3BEventHeader"));
68 if (!header)
69 {
70 LOG(fatal) << " Branch: R3BEventHeader not found in Tree.";
71 return kFATAL;
72 }
73
74 TH1F* histo;
75
76 for (Int_t plane = 1; plane <= fPlanes; plane++)
77 {
78 std::vector<std::vector<TH1F*>> v_plane;
79 for (Int_t bar = 1; bar <= fPaddles; bar++)
80 {
81 std::vector<TH1F*> v_bar;
82 for (Int_t side = 1; side <= 2; side++)
83 {
84 std::string s =
85 "h_pedpar_" + std::to_string(plane) + "_" + std::to_string(bar) + "_" + std::to_string(side);
86 histo = new TH1F(s.c_str(), "PedPar", 2001, -0.5, 2000.5);
87 v_bar.push_back(histo);
88 }
89 v_plane.push_back(v_bar);
90 }
91 fData.push_back(v_plane);
92 }
93 fPar = dynamic_cast<R3BNeulandQCalPar*>(FairRuntimeDb::instance()->getContainer("NeulandQCalPar"));
94
95 return kSUCCESS;
96}
97
99{
101 Int_t nHits = fHits->GetEntries();
102
103 if (header->GetTrigger() != 2)
104 return;
105
106 if (nHits < nPMTs)
107 return;
108
109 for (Int_t i = 0; i < nHits; i++)
110 {
111 hit = dynamic_cast<R3BNeulandTacquilaMappedData*>(fHits->At(i));
112 if (!hit)
113 continue;
114
115 fData.at(hit->GetPlane() - 1).at(hit->GetPaddle() - 1).at(hit->GetSide() - 1)->Fill(hit->GetQdcData());
116 }
117}
118
120{
121 Int_t i = 0;
122 TH1F* pars = new TH1F("QCalPar", "Pedestal Offset", nPMTs, 0.5, nPMTs + 0.5);
123 TH1F* histo;
124 fPar->SetSize(nPMTs);
125 for (Int_t plane = 1; plane <= fPlanes; plane++)
126 for (Int_t bar = 1; bar <= fPaddles; bar++)
127 for (Int_t side = 1; side <= 2; side++)
128 {
129 histo = fData.at(plane - 1).at(bar - 1).at(side - 1);
130 Int_t maxBinPos = histo->GetBinCenter(histo->GetMaximumBin());
131 pars->SetBinContent(i++ + 1, maxBinPos);
132 fPar->SetParAt(plane, bar, side, maxBinPos);
133 }
134 pars->Write();
135 fPar->setChanged();
136}
137
ClassImp(R3B::Neuland::Cal2HitPar)