14 #include <FairLogger.h>
15 #include <FairRootManager.h>
16 #include <FairRuntimeDb.h>
19 #include <TClonesArray.h>
33 : FairTask(
"ATTPC APOLLO Digitizer"), fApolloPointDataCA(nullptr), fApolloCryCalDataCA(
"AtApolloCrystalCalData", 5)
39 LOG(INFO) <<
"AtApolloDigitizer: Delete instance";
41 if (fApolloPointDataCA) {
42 fApolloPointDataCA->Delete();
43 delete fApolloPointDataCA;
45 fApolloCryCalDataCA.Delete();
51 FairRuntimeDb *rtdb = FairRuntimeDb::instance();
53 LOG(ERROR) <<
"AtApolloDigitizer:: FairRuntimeDb not opened!";
57 void AtApolloDigitizer::SetParameter() {}
61 LOG(INFO) <<
"AtApolloDigitizer::Init ";
63 FairRootManager *rootManager = FairRootManager::Instance();
65 LOG(fatal) <<
"Init: No FairRootManager";
69 fApolloPointDataCA =
dynamic_cast<TClonesArray *
>(rootManager->GetObject(
"AtApolloPoint"));
70 if (!fApolloPointDataCA) {
71 LOG(fatal) <<
"Init: No AtApolloPoint CA";
75 rootManager->Register(
"ApolloCrystalCalData",
"CALIFA Crystal Cal", &fApolloCryCalDataCA, kTRUE);
87 Int_t nHits = fApolloPointDataCA->GetEntries();
91 std::vector<AtApolloPoint *> pointData;
94 for (Int_t i = 0; i < nHits; i++)
95 pointData.push_back(
dynamic_cast<AtApolloPoint *
>(fApolloPointDataCA->At(i)));
101 for (Int_t i = 0; i < nHits; i++) {
102 crystalId = pointData[i]->GetCrystalID();
103 time = pointData[i]->GetTime();
104 energy = pointData[i]->GetEnergyLoss();
106 Int_t nCrystalCals = fApolloCryCalDataCA.GetEntriesFast();
107 Bool_t existHit =
false;
108 if (nCrystalCals == 0)
111 for (Int_t j = 0; j < nCrystalCals; j++) {
127 Int_t nCrystalCals = fApolloCryCalDataCA.GetEntriesFast();
128 if (nCrystalCals == 0)
132 Int_t tempCryID, parThres;
137 for (Int_t i = 0; i < nCrystalCals; i++) {
142 if (temp < fThreshold) {
143 fApolloCryCalDataCA.RemoveAt(i);
144 fApolloCryCalDataCA.Compress();
150 if (isCsI(tempCryID) && fResolutionCsI > 0)
152 if (isLaBr(tempCryID) && fResolutionLaBr > 0)
167 FairRootManager::Instance()->Register(
"CrystalCal", GetName(), &fApolloCryCalDataCA, kTRUE);
173 LOG(DEBUG) <<
"Clearing ApolloCrystalCalData Structure";
174 fApolloCryCalDataCA.Clear();
183 fThreshold = thresholdEne;
184 LOG(INFO) <<
"AtApolloDigitizer::SetDetectionThreshold to " << fThreshold <<
" GeV.";
189 TClonesArray &clref = fApolloCryCalDataCA;
190 Int_t size = clref.GetEntriesFast();
192 LOG(INFO) <<
"-I- AtApolloDigitizer: Adding CrystalCalData "
193 <<
" with unique identifier " << ident <<
" entering with " << energy * 1e06 <<
" keV "
201 fResolutionCsI = crystalResCsI;
202 fResolutionLaBr = crystalResLaBr;
203 LOG(INFO) <<
"AtApolloDigitizer::SetExpEnergyRes to " << fResolutionCsI <<
"% @ 1 MeV for CsI and "
204 << fResolutionLaBr <<
"% @ 1 MeV for LaBr.";
207 Double_t AtApolloDigitizer::NUSmearing(Double_t inputEnergy)
212 return gRandom->Uniform(inputEnergy - inputEnergy * fNonUniformity / 100,
213 inputEnergy + inputEnergy * fNonUniformity / 100);
218 fNonUniformity = nonU;
219 LOG(INFO) <<
"AtApolloDigitizer::SetNonUniformity to " << fNonUniformity <<
" %";
222 Double_t AtApolloDigitizer::ExpResSmearingCsI(Double_t inputEnergy)
234 if (fResolutionCsI == 0)
238 Double_t randomIs = gRandom->Gaus(0, inputEnergy * fResolutionCsI * 1000 / (235 * sqrt(inputEnergy * 1000)));
239 return inputEnergy + randomIs / 1000;
242 Double_t AtApolloDigitizer::ExpResSmearingLaBr(Double_t inputEnergy)
244 if (fResolutionLaBr == 0)
248 Double_t randomIs = gRandom->Gaus(0, inputEnergy * fResolutionLaBr * 1000 / (235 * sqrt(inputEnergy * 1000)));
249 return inputEnergy + randomIs / 1000;
253 Bool_t AtApolloDigitizer::isCsI(Int_t
id)
255 if (
id > 6 &&
id < 27)
261 Bool_t AtApolloDigitizer::isLaBr(Int_t
id)
263 if (
id > 0 &&
id < 7)