11/* *****************************************************************************
22 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3- * Copyright (C) 2019-2023 Members of R3B Collaboration *
3+ * Copyright (C) 2019-2024 Members of R3B Collaboration *
44 * *
55 * This software is distributed under the terms of the *
66 * GNU General Public Licence (GPL) version 3, *
2727#include " R3BLogger.h"
2828#include " R3BMusicHitData.h"
2929#include " R3BMwpcHitData.h"
30+ #include " R3BShared.h"
3031#include " R3BTGeoPar.h"
3132#include " R3BTwimHitData.h"
3233
33- #include " FairLogger.h"
34- #include " FairRootManager.h"
35- #include " FairRunAna.h"
36- #include " FairRunOnline.h"
37- #include " FairRuntimeDb.h"
38-
39- #include " TArrow.h"
40- #include " TCanvas.h"
41- #include " TClonesArray.h"
42- #include " TFolder.h"
43- #include " TH1F.h"
44- #include " TH2F.h"
45- #include " THttpServer.h"
46- #include " TLatex.h"
47- #include " TLine.h"
48- #include " TMath.h"
49- #include " TRandom.h"
50- #include " TVector3.h"
34+ #include < FairLogger.h>
35+ #include < FairRootManager.h>
36+ #include < FairRunAna.h>
37+ #include < FairRunOnline.h>
38+ #include < FairRuntimeDb.h>
39+
40+ #include < TArrow.h>
41+ #include < TCanvas.h>
42+ #include < TClonesArray.h>
43+ #include < TFolder.h>
44+ #include < TH1F.h>
45+ #include < TH2F.h>
46+ #include < THttpServer.h>
47+ #include < TLatex.h>
48+ #include < TLine.h>
49+ #include < TMath.h>
50+ #include < TRandom.h>
51+ #include < TVector3.h>
52+ #include < cmath>
53+ #include < iostream>
5154
5255R3BIncomingTrackingOnlineSpectra::R3BIncomingTrackingOnlineSpectra ()
5356 : R3BIncomingTrackingOnlineSpectra(" IncomingTrackingOnlineSpectra" , 1 )
5457{
5558}
5659
57- R3BIncomingTrackingOnlineSpectra::R3BIncomingTrackingOnlineSpectra (const TString& name, Int_t iVerbose)
60+ R3BIncomingTrackingOnlineSpectra::R3BIncomingTrackingOnlineSpectra (const TString& name, int iVerbose)
5861 : FairTask(name, iVerbose)
59- , fNEvents(0 )
60- , fMwpc0HitDataCA(NULL )
61- , fMwpc1HitDataCA(NULL )
62- , fFrsHitDataCA(NULL )
63- , fDist_acelerator_glad(3855.0 )
64- , fPosTarget(2773.0 )
65- , fWidthTarget(40.0 )
66- , fCutIncoming(NULL )
67- , fNameCut(" " )
6862{
6963}
7064
@@ -74,40 +68,16 @@ R3BIncomingTrackingOnlineSpectra::R3BIncomingTrackingOnlineSpectra(const TString
7468 float aqmin,
7569 float aqmax)
7670 : FairTask(" IncomingTrackingOnlineSpectra_" + name, 1 )
77- , fNEvents(0 )
78- , fMwpc0HitDataCA(NULL )
79- , fMwpc1HitDataCA(NULL )
80- , fFrsHitDataCA(NULL )
81- , fDist_acelerator_glad(3855.0 )
82- , fPosTarget(2773.0 )
83- , fWidthTarget(40.0 )
8471 , fNameCut(name)
8572{
86- fCutIncoming = new TCutG (name, 5 );
73+ fCutIncoming = std::make_unique< TCutG> (name, 5 );
8774 fCutIncoming ->SetPoint (0 , zmin, aqmin);
8875 fCutIncoming ->SetPoint (1 , zmin, aqmax);
8976 fCutIncoming ->SetPoint (2 , zmax, aqmax);
9077 fCutIncoming ->SetPoint (3 , zmax, aqmin);
9178 fCutIncoming ->SetPoint (4 , zmin, aqmin);
9279}
9380
94- R3BIncomingTrackingOnlineSpectra::~R3BIncomingTrackingOnlineSpectra ()
95- {
96- R3BLOG (debug1, " Destructor" );
97- if (fMwpc0HitDataCA )
98- {
99- delete fMwpc0HitDataCA ;
100- }
101- if (fMwpc1HitDataCA )
102- {
103- delete fMwpc1HitDataCA ;
104- }
105- if (fFrsHitDataCA )
106- {
107- delete fFrsHitDataCA ;
108- }
109- }
110-
11181// ----- Public method SetParContainers --------------------------------
11282void R3BIncomingTrackingOnlineSpectra::SetParContainers ()
11383{
@@ -123,6 +93,10 @@ void R3BIncomingTrackingOnlineSpectra::SetParContainers()
12393
12494 fMw1GeoPar = dynamic_cast <R3BTGeoPar*>(rtdb->getContainer (" Mwpc1GeoPar" ));
12595 R3BLOG_IF (error, !fMw1GeoPar , " Could not get access to Mwpc1GeoPar container." );
96+
97+ fMw2GeoPar = dynamic_cast <R3BTGeoPar*>(rtdb->getContainer (" Mwpc2GeoPar" ));
98+ R3BLOG_IF (error, !fMw2GeoPar , " Could not get access to Mwpc2GeoPar container." );
99+
126100 return ;
127101}
128102
@@ -137,28 +111,27 @@ InitStatus R3BIncomingTrackingOnlineSpectra::Init()
137111{
138112 R3BLOG (info, " " );
139113 FairRootManager* mgr = FairRootManager::Instance ();
140- R3BLOG_IF (fatal, NULL == mgr , " FairRootManager not found" );
114+ R3BLOG_IF (fatal, mgr == nullptr , " FairRootManager not found" );
141115
142116 fMwpc0HitDataCA = dynamic_cast <TClonesArray*>(mgr->GetObject (" Mwpc0HitData" ));
143- if (! fMwpc0HitDataCA )
117+ if (fMwpc0HitDataCA == nullptr )
144118 {
145119 R3BLOG (fatal, " Mwpc0HitData not found" );
146120 return kFATAL ;
147121 }
148122
149123 fMwpc1HitDataCA = dynamic_cast <TClonesArray*>(mgr->GetObject (" Mwpc1HitData" ));
150- if (! fMwpc1HitDataCA )
124+ if (fMwpc1HitDataCA == nullptr )
151125 {
152126 R3BLOG (fatal, " Mwpc1HitData not found" );
153127 return kFATAL ;
154128 }
155129
130+ fMwpc2HitDataCA = dynamic_cast <TClonesArray*>(mgr->GetObject (" Mwpc2HitData" ));
131+ R3BLOG_IF (error, fMwpc2HitDataCA == nullptr , " Mwpc2HitData not found" );
132+
156133 fFrsHitDataCA = dynamic_cast <TClonesArray*>(mgr->GetObject (" FrsData" ));
157- if (!fFrsHitDataCA )
158- {
159- R3BLOG (warning, " FrsData not found" );
160- // return kFATAL;
161- }
134+ R3BLOG_IF (warning, fFrsHitDataCA == nullptr , " FrsData not found" );
162135
163136 // Create histograms for detectors
164137 TString Name1;
@@ -171,7 +144,8 @@ InitStatus R3BIncomingTrackingOnlineSpectra::Init()
171144 Name1 = " fh2_tracking_planeXZ" + fNameCut ;
172145 Name2 = " Tracking (Lab.) plane XZ info " + fNameCut ;
173146 Int_t histoYlim = 150 ;
174- fh2_tracking_planeXZ = new TH2F (Name1, Name2, 400 , 0 ., fDist_acelerator_glad , 400 , -1 . * histoYlim, histoYlim);
147+ fh2_tracking_planeXZ =
148+ R3B ::root_owned<TH2F >(Name1, Name2, 400 , 0 ., fDist_acelerator_glad , 400 , -1 . * histoYlim, histoYlim);
175149 fh2_tracking_planeXZ->GetXaxis ()->SetTitle (" Beam direction-Z [mm]" );
176150 fh2_tracking_planeXZ->GetYaxis ()->SetTitle (" (Wixhausen)<--- X [mm] ---> (Messel)" );
177151 fh2_tracking_planeXZ->GetYaxis ()->SetTitleOffset (1.1 );
@@ -216,7 +190,8 @@ InitStatus R3BIncomingTrackingOnlineSpectra::Init()
216190 " Tracking_before_GLAD_YZ" + fNameCut , " Tracking (Lab.) plane YZ info " + fNameCut , 10 , 10 , 800 , 700 );
217191 Name1 = " fh2_tracking_planeYZ" + fNameCut ;
218192 Name2 = " Tracking (Lab.) plane YZ info " + fNameCut ;
219- fh2_tracking_planeYZ = new TH2F (Name1, Name2, 400 , 0 ., fDist_acelerator_glad , 400 , -1 . * histoYlim, histoYlim);
193+ fh2_tracking_planeYZ =
194+ R3B ::root_owned<TH2F >(Name1, Name2, 400 , 0 ., fDist_acelerator_glad , 400 , -1 . * histoYlim, histoYlim);
220195 fh2_tracking_planeYZ->GetXaxis ()->SetTitle (" Beam direction-Z [mm]" );
221196 fh2_tracking_planeYZ->GetYaxis ()->SetTitle (" Y [mm]" );
222197 fh2_tracking_planeYZ->GetYaxis ()->SetTitleOffset (1.1 );
@@ -247,7 +222,7 @@ InitStatus R3BIncomingTrackingOnlineSpectra::Init()
247222 new TCanvas (" Beam_profile_XY_at_target" + fNameCut , " Beam profile XY info " + fNameCut , 10 , 10 , 800 , 700 );
248223 Name1 = " fh2_beam_profile_XY" + fNameCut ;
249224 Name2 = " Beam profile-XY (Lab.) at target position " + fNameCut ;
250- fh2_target_PosXY = new TH2F (Name1, Name2, 200 , -100 ., 100 ., 200 , -100 ., 100 .);
225+ fh2_target_PosXY = R3B ::root_owned< TH2F > (Name1, Name2, 200 , -100 ., 100 ., 200 , -100 ., 100 .);
251226 fh2_target_PosXY->GetXaxis ()->SetTitle (" (Wixhausen)<--- X [mm] ---> (Messel)" );
252227 fh2_target_PosXY->GetYaxis ()->SetTitle (" Y [mm]" );
253228 fh2_target_PosXY->GetYaxis ()->SetTitleOffset (1.1 );
@@ -262,14 +237,14 @@ InitStatus R3BIncomingTrackingOnlineSpectra::Init()
262237 // AngleX and positionX on the target position
263238 auto cAPX = new TCanvas (
264239 " AngleX_vs_positionX_target" + fNameCut , " Angle_XZ vs position X on target " + fNameCut , 10 , 10 , 800 , 700 );
265- fh2_angvsposx = new TH2F (" AngXvsPosX" + fNameCut ,
266- " Angle vs position on target " + fNameCut ,
267- 500 ,
268- -fWidthTarget ,
269- fWidthTarget ,
270- 500 ,
271- -10 .,
272- 10 .);
240+ fh2_angvsposx = R3B ::root_owned< TH2F > (" AngXvsPosX" + fNameCut ,
241+ " Angle vs position on target " + fNameCut ,
242+ 500 ,
243+ -fWidthTarget ,
244+ fWidthTarget ,
245+ 500 ,
246+ -10 .,
247+ 10 .);
273248 fh2_angvsposx->GetXaxis ()->SetTitle (" (Wixhausen)<--- X [mm] ---> (Messel)" );
274249 fh2_angvsposx->GetYaxis ()->SetTitle (" Angle plane_XZ [mrad]" );
275250 fh2_angvsposx->GetYaxis ()->SetTitleOffset (1.1 );
@@ -285,14 +260,14 @@ InitStatus R3BIncomingTrackingOnlineSpectra::Init()
285260 // AngleY and positionY on the target position
286261 auto cAPY = new TCanvas (
287262 " AngleY_vs_positionY_target" + fNameCut , " Angle_YZ vs position Y on target " + fNameCut , 10 , 10 , 800 , 700 );
288- fh2_angvsposy = new TH2F (" AngYvsPosY" + fNameCut ,
289- " Angle vs position on target " + fNameCut ,
290- 500 ,
291- -fWidthTarget ,
292- fWidthTarget ,
293- 500 ,
294- -10 .,
295- 10 .);
263+ fh2_angvsposy = R3B ::root_owned< TH2F > (" AngYvsPosY" + fNameCut ,
264+ " Angle vs position on target " + fNameCut ,
265+ 500 ,
266+ -fWidthTarget ,
267+ fWidthTarget ,
268+ 500 ,
269+ -10 .,
270+ 10 .);
296271 fh2_angvsposy->GetXaxis ()->SetTitle (" Y [mm]" );
297272 fh2_angvsposy->GetYaxis ()->SetTitle (" Angle plane_YZ [mrad]" );
298273 fh2_angvsposy->GetYaxis ()->SetTitleOffset (1.1 );
@@ -313,8 +288,8 @@ InitStatus R3BIncomingTrackingOnlineSpectra::Init()
313288 mainfol->Add (cAPX);
314289 mainfol->Add (cAPY);
315290
316- FairRunOnline* run = FairRunOnline::Instance ();
317- R3BLOG_IF (fatal, NULL == run , " FairRunOnline not found" );
291+ auto run = FairRunOnline::Instance ();
292+ R3BLOG_IF (fatal, run == nullptr , " FairRunOnline not found" );
318293 run->GetHttpServer ()->Register (" " , this );
319294 run->AddObject (mainfol);
320295
@@ -335,10 +310,10 @@ void R3BIncomingTrackingOnlineSpectra::Reset_Histo()
335310 fh2_angvsposy->Reset ();
336311}
337312
338- void R3BIncomingTrackingOnlineSpectra::Exec (Option_t* option)
313+ void R3BIncomingTrackingOnlineSpectra::Exec (Option_t* /* option*/ )
339314{
340- Double_t mwpc0x = -300 ., mwpc0y = -300 ., zrand = 0 .;
341- Double_t xtarget = -500 ., ytarget = -500 .;
315+ double mwpc0x = -300 ., mwpc0y = -300 ., zrand = 0 .;
316+ double xtarget = -500 ., ytarget = -500 .;
342317
343318 if (fCutIncoming && fFrsHitDataCA )
344319 {
@@ -370,7 +345,7 @@ void R3BIncomingTrackingOnlineSpectra::Exec(Option_t* option)
370345 }
371346
372347 // Fill Mwpc1 Hit data
373- if (fMwpc1HitDataCA && fMwpc1HitDataCA ->GetEntriesFast () > 0 && mwpc0y > -100 .)
348+ if (fMwpc1HitDataCA && fMwpc1HitDataCA ->GetEntriesFast () > 0 && mwpc0y > -100 . && fYearConf == 2022 )
374349 {
375350 nHits = fMwpc1HitDataCA ->GetEntriesFast ();
376351 Float_t mwpc1x = -150 .;
@@ -384,23 +359,53 @@ void R3BIncomingTrackingOnlineSpectra::Exec(Option_t* option)
384359 continue ;
385360 mwpc1x = hit->GetX () + fMw1GeoPar ->GetPosX () * 10 .;
386361 mwpc1y = hit->GetY () + fMw1GeoPar ->GetPosY () * 10 .;
387- // Float_t angX = (mwpc1x - mwpc0x) / (fMw1GeoPar->GetPosZ() - fMw0GeoPar->GetPosZ()) / 10.;
388- // Float_t angY = (mwpc1y - mwpc0y) / (fMw1GeoPar->GetPosZ() - fMw0GeoPar->GetPosZ()) / 10.;
389362 angX = (mwpc0x - mwpc1x) / (fMw0GeoPar ->GetPosZ () - fMw1GeoPar ->GetPosZ ()) / 10 .;
390363 angY = (mwpc0y - mwpc1y) / (fMw0GeoPar ->GetPosZ () - fMw1GeoPar ->GetPosZ ()) / 10 .;
391364 if (TMath::Abs (angX) < 0.075 && TMath::Abs (angY) < 0.075 && mwpc1x > -150 .)
392365 {
393366 zrand = gRandom ->Uniform (0 ., fDist_acelerator_glad );
394- // fh2_tracking_planeYZ->Fill(zrand, mwpc0y - angY * fMw0GeoPar->GetPosZ() * 10. + angY * zrand); //
395- // mm ytarget = mwpc0y - angY * fMw0GeoPar->GetPosZ() * 10. + angY * fPosTarget;
396- // fh2_tracking_planeXZ->Fill(zrand, mwpc0x - angX * fMw0GeoPar->GetPosZ() * 10. + angX * zrand); //
397- // mm xtarget = mwpc0x - angX * fMw0GeoPar->GetPosZ() * 10. + angX * fPosTarget;
398367 fh2_tracking_planeYZ->Fill (zrand, mwpc1y - angY * fMw1GeoPar ->GetPosZ () * 10 . + angY * zrand); // mm
399368 ytarget = mwpc1y - angY * fMw1GeoPar ->GetPosZ () * 10 . + angY * fPosTarget ;
400369 fh2_tracking_planeXZ->Fill (zrand, mwpc1x - angX * fMw1GeoPar ->GetPosZ () * 10 . + angX * zrand); // mm
401370 xtarget = mwpc1x - angX * fMw1GeoPar ->GetPosZ () * 10 . + angX * fPosTarget ;
402371 }
403372 }
373+
374+ if (xtarget > -500 . && ytarget > -500 .)
375+ {
376+ fh2_target_PosXY->Fill (xtarget, ytarget);
377+ fh2_angvsposx->Fill (xtarget, angX * 1000 .);
378+ fh2_angvsposy->Fill (ytarget, angY * 1000 .);
379+ }
380+ }
381+
382+ // Fill Mwpc2 Hit data
383+ if (fMwpc2HitDataCA && fMwpc2HitDataCA ->GetEntriesFast () > 0 && mwpc0y > -100 . && fYearConf == 2024 )
384+ {
385+ nHits = fMwpc2HitDataCA ->GetEntriesFast ();
386+ Float_t mwpc2x = -150 .;
387+ Float_t mwpc2y = -150 .;
388+ Float_t angX = -500 .;
389+ Float_t angY = -500 .;
390+ for (int ihit = 0 ; ihit < nHits; ihit++)
391+ {
392+ auto hit = dynamic_cast <R3BMwpcHitData*>(fMwpc2HitDataCA ->At (ihit));
393+ if (!hit)
394+ continue ;
395+ mwpc2x = hit->GetX () + fMw2GeoPar ->GetPosX () * 10 .;
396+ mwpc2y = hit->GetY () + fMw2GeoPar ->GetPosY () * 10 .;
397+ angX = std::atan ((mwpc0x - mwpc2x) / (fMw0GeoPar ->GetPosZ () - fMw2GeoPar ->GetPosZ ()) / 10 .);
398+ angY = std::atan ((mwpc0y - mwpc2y) / (fMw0GeoPar ->GetPosZ () - fMw2GeoPar ->GetPosZ ()) / 10 .);
399+ if (TMath::Abs (angX) < 0.075 && TMath::Abs (angY) < 0.075 && mwpc2x > -150 .)
400+ {
401+ zrand = gRandom ->Uniform (0 ., fDist_acelerator_glad );
402+ fh2_tracking_planeYZ->Fill (zrand, mwpc2y - angY * fMw2GeoPar ->GetPosZ () * 10 . + angY * zrand); // mm
403+ ytarget = mwpc2y - angY * fMw2GeoPar ->GetPosZ () * 10 . + angY * fPosTarget ;
404+ fh2_tracking_planeXZ->Fill (zrand, mwpc2x - angX * fMw2GeoPar ->GetPosZ () * 10 . + angX * zrand); // mm
405+ xtarget = mwpc2x - angX * fMw2GeoPar ->GetPosZ () * 10 . + angX * fPosTarget ;
406+ }
407+ }
408+
404409 if (xtarget > -500 . && ytarget > -500 .)
405410 {
406411 fh2_target_PosXY->Fill (xtarget, ytarget);
@@ -443,4 +448,4 @@ void R3BIncomingTrackingOnlineSpectra::FinishTask()
443448 }
444449}
445450
446- ClassImp (R3BIncomingTrackingOnlineSpectra);
451+ ClassImp (R3BIncomingTrackingOnlineSpectra)
0 commit comments