11/* *****************************************************************************
22 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3- * Copyright (C) 2019-2025 Members of R3B Collaboration *
3+ * Copyright (C) 2019-2026 Members of R3B Collaboration *
44 * *
55 * This software is distributed under the terms of the *
66 * GNU General Public Licence (GPL) version 3, *
@@ -85,33 +85,33 @@ void RemoveUsedCrystals(vector<uint16_t>& used,
8585 vector<R3BCalifaCrystalCalData*>& saturated)
8686{
8787
88- for (int p = 0 ; p < used.size (); p++)
88+ for (auto p = 0 ; p < used.size (); p++)
8989 {
90- for (int s = 0 ; s < all.size (); s++)
90+ for (auto s = 0 ; s < all.size (); s++)
9191
9292 if (all.at (s)->GetCrystalId () == used.at (p))
9393 all.erase (all.begin () + s);
9494 }
9595
96- for (int p = 0 ; p < used.size (); p++)
96+ for (auto p = 0 ; p < used.size (); p++)
9797 {
98- for (int s = 0 ; s < gamma.size (); s++)
98+ for (auto s = 0 ; s < gamma.size (); s++)
9999
100100 if (gamma.at (s)->GetCrystalId () == used.at (p))
101101 gamma.erase (gamma.begin () + s);
102102 }
103103
104- for (int p = 0 ; p < used.size (); p++)
104+ for (auto p = 0 ; p < used.size (); p++)
105105 {
106- for (int s = 0 ; s < proton.size (); s++)
106+ for (auto s = 0 ; s < proton.size (); s++)
107107
108108 if (proton.at (s)->GetCrystalId () == used.at (p))
109109 proton.erase (proton.begin () + s);
110110 }
111111
112- for (int p = 0 ; p < used.size (); p++)
112+ for (auto p = 0 ; p < used.size (); p++)
113113 {
114- for (int s = 0 ; s < saturated.size (); s++)
114+ for (auto s = 0 ; s < saturated.size (); s++)
115115
116116 if (saturated.at (s)->GetCrystalId () == used.at (p))
117117 saturated.erase (saturated.begin () + s);
@@ -152,7 +152,7 @@ R3BCalifaCrystalCal2Cluster::~R3BCalifaCrystalCal2Cluster()
152152
153153void R3BCalifaCrystalCal2Cluster::SetParContainers ()
154154{
155- FairRuntimeDb * rtdb = FairRuntimeDb::instance ();
155+ auto * rtdb = FairRuntimeDb::instance ();
156156 R3BLOG_IF (fatal, !rtdb, " FairRuntimeDb not found" );
157157
158158 fCalifaGeoPar = dynamic_cast <R3BTGeoPar*>(rtdb->getContainer (" CalifaGeoPar" ));
@@ -166,24 +166,35 @@ void R3BCalifaCrystalCal2Cluster::SetParContainers()
166166 else
167167 {
168168 R3BLOG (info, " Container CalifaGeoPar found." );
169- fCalifaPos .SetXYZ (fCalifaGeoPar ->GetPosX (), fCalifaGeoPar ->GetPosY (), fCalifaGeoPar ->GetPosZ ());
170169 }
171170
172- if (!fCalifaGeoPar || ! fTargetGeoPar )
171+ if (!fTargetGeoPar )
173172 {
174- R3BLOG_IF (warn, !fTargetGeoPar , " Could not get access to TargetGeoPar container. Setting nominal position. " );
173+ R3BLOG_IF (warn, !fTargetGeoPar , " Could not get access to TargetGeoPar container. Setting nominal position." );
175174 fTargetPos .SetXYZ (0.0 , 0.0 , 0.0 );
176175 }
177176 else
178177 {
179178 R3BLOG (info, " Container TargetGeoPar found." );
179+ }
180+
181+ return ;
182+ }
183+
184+ void R3BCalifaCrystalCal2Cluster::SetParameter ()
185+ {
186+ if (fCalifaGeoPar )
187+ {
188+ fCalifaPos .SetXYZ (fCalifaGeoPar ->GetPosX (), fCalifaGeoPar ->GetPosY (), fCalifaGeoPar ->GetPosZ ());
189+ }
190+
191+ if (fTargetGeoPar )
192+ {
180193 fTargetPos .SetXYZ (fTargetGeoPar ->GetPosX (), fTargetGeoPar ->GetPosY (), fTargetGeoPar ->GetPosZ ());
181194 }
182195
183196 LOG (info) << " Califa position : X = " << fCalifaPos .X () << " Y = " << fCalifaPos .Y () << " Z = " << fCalifaPos .Z ();
184197 LOG (info) << " Target position : X = " << fTargetPos .X () << " Y = " << fTargetPos .Y () << " Z = " << fTargetPos .Z ();
185-
186- return ;
187198}
188199
189200InitStatus R3BCalifaCrystalCal2Cluster::Init ()
@@ -199,6 +210,9 @@ InitStatus R3BCalifaCrystalCal2Cluster::Init()
199210 fCalifaClusterData = new TClonesArray (" R3BCalifaClusterData" );
200211 rootman->Register (" CalifaClusterData" , " CALIFA Cluster" , fCalifaClusterData , !fOnline );
201212
213+ // Load parameters
214+ SetParameter ();
215+
202216 if (R3BCalifaGeometry::Instance ()->IsSimulation () == true )
203217 {
204218 fTotalCrystals = R3BCalifaGeometry::Instance ()->GetNbCrystals () / 2 ;
@@ -223,7 +237,7 @@ InitStatus R3BCalifaCrystalCal2Cluster::Init()
223237 R3BLOG_IF (fatal, !fHistoFile , " Randomization file not found" );
224238
225239 fAngularDistributions = new TH2F*[fTotalCrystals ];
226- for (Int_t i = 0 ; i < fTotalCrystals ; i++)
240+ for (auto i = 0 ; i < fTotalCrystals ; i++)
227241 {
228242 std::string name = " distributionCrystalID_" + std::to_string (i + 1 );
229243 fHistoFile ->GetObject (name.c_str (), fAngularDistributions [i]);
@@ -235,14 +249,15 @@ InitStatus R3BCalifaCrystalCal2Cluster::Init()
235249InitStatus R3BCalifaCrystalCal2Cluster::ReInit ()
236250{
237251 SetParContainers ();
252+ SetParameter ();
238253 return kSUCCESS ;
239254}
240255
241256void R3BCalifaCrystalCal2Cluster::Exec (Option_t* /* opt*/ )
242257{
243258 Reset ();
244259
245- const int numCrystalHits = fCrystalCalData ->GetEntriesFast ();
260+ auto numCrystalHits = fCrystalCalData ->GetEntriesFast ();
246261
247262 if (numCrystalHits == 0 )
248263 return ;
@@ -256,10 +271,10 @@ void R3BCalifaCrystalCal2Cluster::Exec(Option_t* /*opt*/)
256271
257272 vector<uint16_t > usedCrystals;
258273
259- Double_t cryEnergy = 0 .;
260- Int_t cryId = 0 ;
274+ double cryEnergy = 0 .;
275+ int cryId = 0 ;
261276
262- for (Int_t i = 0 ; i < numCrystalHits; i++)
277+ for (auto i = 0 ; i < numCrystalHits; i++)
263278 {
264279 cryId = dynamic_cast <R3BCalifaCrystalCalData*>(fCrystalCalData ->At (i))->GetCrystalId ();
265280 cryEnergy = dynamic_cast <R3BCalifaCrystalCalData*>(fCrystalCalData ->At (i))->GetEnergy ();
@@ -294,9 +309,9 @@ void R3BCalifaCrystalCal2Cluster::Exec(Option_t* /*opt*/)
294309 }
295310
296311 /* ----- Remove duplicate entries in gamma clusters ----- */
297- for (int k = 0 ; k < gammaCandidatesVec.size (); k++)
312+ for (auto k = 0 ; k < gammaCandidatesVec.size (); k++)
298313 {
299- for (int s = 0 ; s < gammaCandidatesVec.size (); s++)
314+ for (auto s = 0 ; s < gammaCandidatesVec.size (); s++)
300315 {
301316 if (gammaCandidatesVec.at (k)->GetCrystalId () == (gammaCandidatesVec.at (s)->GetCrystalId () - fTotalCrystals ))
302317 gammaCandidatesVec.erase (gammaCandidatesVec.begin () + s);
@@ -313,7 +328,7 @@ void R3BCalifaCrystalCal2Cluster::Exec(Option_t* /*opt*/)
313328
314329 while (protonCandidatesVec.size ())
315330 {
316- Int_t motherId = protonCandidatesVec.at (0 )->GetCrystalId ();
331+ auto motherId = protonCandidatesVec.at (0 )->GetCrystalId ();
317332
318333 califa_candidate cluster = { motherId, vector<uint16_t >(), 0.0 , 0.0 , 0.0 , 0.0 , 0.0 };
319334
@@ -328,7 +343,6 @@ void R3BCalifaCrystalCal2Cluster::Exec(Option_t* /*opt*/)
328343
329344 if (fRand )
330345 {
331-
332346 if (motherId > fTotalCrystals )
333347 fAngularDistributions [protonCandidatesVec.at (0 )->GetCrystalId () - 1 - fTotalCrystals ]->GetRandom2 (
334348 fRandPhi , fRandTheta );
@@ -350,10 +364,10 @@ void R3BCalifaCrystalCal2Cluster::Exec(Option_t* /*opt*/)
350364
351365 addCrystal2Cluster (&cluster, protonCandidatesVec.at (0 ), " proton" , &usedCrystals, fTotalCrystals );
352366
353- for (Int_t j = 0 ; j < allCrystalVec.size (); j++)
367+ for (auto j = 0 ; j < allCrystalVec.size (); j++)
354368 {
355- Int_t thisCryId = allCrystalVec.at (j)->GetCrystalId ();
356- Float_t thisEnergy = allCrystalVec.at (j)->GetEnergy ();
369+ auto thisCryId = allCrystalVec.at (j)->GetCrystalId ();
370+ auto thisEnergy = allCrystalVec.at (j)->GetEnergy ();
357371
358372 if (thisCryId > fTotalCrystals && !isInside (usedCrystals, thisCryId) && !fSimulation )
359373 {
@@ -367,7 +381,6 @@ void R3BCalifaCrystalCal2Cluster::Exec(Option_t* /*opt*/)
367381 if (thisCryId <= fTotalCrystals && !isInside (usedCrystals, thisCryId) && !std::isnan (thisEnergy) &&
368382 !fSimulation )
369383 {
370-
371384 angles = R3BCalifaGeometry::Instance ()->GetAngles (thisCryId);
372385
373386 if (InsideClusterWindow (mother_angles, angles))
@@ -377,7 +390,6 @@ void R3BCalifaCrystalCal2Cluster::Exec(Option_t* /*opt*/)
377390 /* ------- Simulation ------- */
378391 if (!isInside (usedCrystals, thisCryId) && fSimulation )
379392 {
380-
381393 angles = R3BCalifaGeometry::Instance ()->GetAngles (thisCryId);
382394
383395 // add to gamma or proton cluster depending on crystal id
@@ -400,7 +412,7 @@ void R3BCalifaCrystalCal2Cluster::Exec(Option_t* /*opt*/)
400412 /* ------ Gamma Clusters ------- */
401413 while (gammaCandidatesVec.size ())
402414 {
403- Int_t motherId = gammaCandidatesVec.at (0 )->GetCrystalId ();
415+ auto motherId = gammaCandidatesVec.at (0 )->GetCrystalId ();
404416
405417 califa_candidate cluster = { motherId, vector<uint16_t >(), 0.0 , 0.0 , 0.0 , 0.0 , 0.0 };
406418
@@ -436,9 +448,9 @@ void R3BCalifaCrystalCal2Cluster::Exec(Option_t* /*opt*/)
436448
437449 addCrystal2Cluster (&cluster, gammaCandidatesVec.at (0 ), " gamma" , &usedCrystals, fTotalCrystals );
438450
439- for (Int_t j = 0 ; j < allCrystalVec.size (); j++)
451+ for (auto j = 0 ; j < allCrystalVec.size (); j++)
440452 {
441- Int_t thisCryId = allCrystalVec.at (j)->GetCrystalId ();
453+ auto thisCryId = allCrystalVec.at (j)->GetCrystalId ();
442454
443455 if (thisCryId <= fTotalCrystals && !isInside (usedCrystals, thisCryId) && !fSimulation )
444456 {
@@ -449,9 +461,9 @@ void R3BCalifaCrystalCal2Cluster::Exec(Option_t* /*opt*/)
449461 }
450462 }
451463
452- for (Int_t j = 0 ; j < allCrystalVec.size (); j++)
464+ for (auto j = 0 ; j < allCrystalVec.size (); j++)
453465 {
454- Int_t thisCryId = allCrystalVec.at (j)->GetCrystalId ();
466+ auto thisCryId = allCrystalVec.at (j)->GetCrystalId ();
455467
456468 if (thisCryId > fTotalCrystals && !isInside (usedCrystals, thisCryId) && !fSimulation )
457469 {
@@ -462,9 +474,9 @@ void R3BCalifaCrystalCal2Cluster::Exec(Option_t* /*opt*/)
462474 }
463475 }
464476
465- for (Int_t j = 0 ; j < allCrystalVec.size (); j++)
477+ for (auto j = 0 ; j < allCrystalVec.size (); j++)
466478 {
467- Int_t thisCryId = allCrystalVec.at (j)->GetCrystalId ();
479+ auto thisCryId = allCrystalVec.at (j)->GetCrystalId ();
468480
469481 if (!isInside (usedCrystals, thisCryId) && fSimulation )
470482 {
@@ -486,7 +498,7 @@ void R3BCalifaCrystalCal2Cluster::Exec(Option_t* /*opt*/)
486498 /* ----------- Saturation Clusters ----------- */
487499 while (saturatedCandidatesVec.size ())
488500 {
489- Int_t motherId = saturatedCandidatesVec.at (0 )->GetCrystalId ();
501+ auto motherId = saturatedCandidatesVec.at (0 )->GetCrystalId ();
490502
491503 califa_candidate cluster = { motherId, vector<uint16_t >(), 0.0 , 0.0 , 0.0 , 0.0 , 0.0 };
492504
@@ -507,9 +519,9 @@ void R3BCalifaCrystalCal2Cluster::Exec(Option_t* /*opt*/)
507519
508520 addCrystal2Cluster (&cluster, saturatedCandidatesVec.at (0 ), " gamma" , &usedCrystals, fTotalCrystals );
509521
510- for (Int_t j = 0 ; j < allCrystalVec.size (); j++)
522+ for (auto j = 0 ; j < allCrystalVec.size (); j++)
511523 {
512- Int_t thisCryId = allCrystalVec.at (j)->GetCrystalId ();
524+ auto thisCryId = allCrystalVec.at (j)->GetCrystalId ();
513525
514526 if (thisCryId > fTotalCrystals && !isInside (usedCrystals, thisCryId))
515527 {
@@ -562,7 +574,7 @@ R3BCalifaClusterData* R3BCalifaCrystalCal2Cluster::AddCluster(vector<uint16_t> c
562574 uint8_t clusterType)
563575{
564576 TClonesArray& clref = *fCalifaClusterData ;
565- Int_t size = clref.GetEntriesFast ();
577+ auto size = clref.GetEntriesFast ();
566578 return new (clref[size]) R3BCalifaClusterData (crystalList, ene, Nf, Ns, pAngle, aAngle, time, clusterType);
567579}
568580
0 commit comments