BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
eventdisplay.C
Go to the documentation of this file.
1
Bool_t
SetupOffline
(
TString
simFile,
TString
recoFile);
2
Bool_t
SetupOnline
(
TString
endpoint);
3
void
SetupSim
(
TString
simFile,
TString
recoFile);
4
void
SetupExp
(
TString
recoFile);
5
Bool_t
LoadGeometry
(
Int_t
runPeriod,
Int_t
runNumber,
Bool_t
latest =
kFALSE
);
6
void
SetSimTasks
(
Color_t
mcPointColor =
kRed
,
Color_t
recoPointColor =
kBlack
,
Style_t
pointMarker =
kFullDotSmall
);
7
void
SetExpTasks
(
Color_t
pointColor =
kRed
,
Style_t
pointMarker =
kFullDotSmall
);
8
9
/// @brief Event Display macro for experimental and simulated data
10
/// @param simFile ROOT file with MC data (and detector geometry) in case of MC visualization
11
/// @param recoFile ROOT file with reconstructed data for simulated or experimental
12
/// @param endpoint ZMQ publisher socket url, for example tcp://localhost:5557.
13
/// If the values is not empty, the Event Display is started in online mode
14
void
eventdisplay
(
TString
simFile =
"$VMCWORKDIR/macro/run/bmnsim.root"
,
15
TString
recoFile =
"$VMCWORKDIR/macro/run/bmndst.root"
,
16
TString
endpoint =
""
)
17
{
18
FairRunAna* runAnaManager =
new
FairRunAna();
19
MpdEventManager
* eventManager =
new
MpdEventManager
();
20
21
if
(endpoint !=
""
) {
22
if
(!
SetupOnline
(endpoint))
23
return
;
24
}
else
{
25
// Offline mode
26
if
(!
SetupOffline
(simFile, recoFile))
27
return
;
28
}
29
// set output file
30
runAnaManager->SetSink(
new
FairRootFileSink(
"ed_out.root"
));
31
runAnaManager->SetGenerateRunInfo(
false
);
32
33
// light background color by default
34
eventManager->
background_color
= 17;
35
eventManager->
isDarkColor
=
false
;
36
37
eventManager->
Init
(3, 3, 10000);
38
}
39
40
Bool_t
SetupOffline
(
TString
simFile,
TString
recoFile)
41
{
42
if
(!
BmnFunctionSet::CheckFileExist
(recoFile)) {
43
LOG(error) <<
"Reconstruction file with was not found: "
<< recoFile;
44
return
kFALSE
;
45
}
46
47
if
(
BmnFunctionSet::isSimulationFile
(recoFile)) {
48
// Simulation
49
if
(!
BmnFunctionSet::CheckFileExist
(simFile)) {
50
LOG(error) <<
"ERROR: simulation file with detector geometry was not found: "
<< simFile;
51
return
kFALSE
;
52
}
53
54
SetupSim
(simFile, recoFile);
55
SetSimTasks
();
56
}
else
{
57
// Experiment
58
SetupExp
(recoFile);
59
SetExpTasks
();
60
}
61
62
return
kTRUE
;
63
}
64
65
Bool_t
SetupOnline
(
TString
endpoint)
66
{
67
FairRunAna::Instance()->SetSource(
new
BmnOnlineSource
(endpoint));
68
69
if
(!
LoadGeometry
(-1, -1,
kTRUE
))
70
return
kFALSE
;
71
72
MpdEventManager::Instance
()->
isOnline
=
kTRUE
;
73
MpdEventManager::Instance
()->
iDataSource
=
kTRUE
;
74
75
SetExpTasks
();
76
77
return
kTRUE
;
78
}
79
80
void
SetupSim
(
TString
simFile,
TString
recoFile)
81
{
82
auto
fileSource =
new
FairFileSource(simFile);
83
// add file with reconstructed data as a friend
84
fileSource->AddFriend(recoFile);
85
86
FairRunAna::Instance()->SetSource(fileSource);
87
88
// set parameter file with MC data and detector geometry
89
auto
runtimeDb = FairRunAna::Instance()->GetRuntimeDb();
90
auto
parIo =
new
FairParRootFileIo();
91
parIo->open(simFile);
92
runtimeDb->setFirstInput(parIo);
93
//! -----------------------------------
94
// runtimeDb->setOutput(parIo);
95
// runtimeDb->saveOutput();
96
//! -----------------------------------
97
98
MpdEventManager::Instance
()->
iDataSource
=
kFALSE
;
99
}
100
101
void
SetupExp
(
TString
recoFile)
102
{
103
Int_t
runPeriod, runNumber;
104
105
FairRunAna::Instance()->SetSource(
new
BmnFileSource
(recoFile, runPeriod, runNumber));
106
LoadGeometry
(runPeriod, runNumber);
107
108
MpdEventManager::Instance
()->
iDataSource
=
kTRUE
;
109
}
110
111
Bool_t
LoadGeometry
(
Int_t
runPeriod,
Int_t
runNumber,
Bool_t
latest =
kFALSE
)
112
{
113
// get geometry for run from the Geometry Database
114
// 'latest' means the last approved setup over all run periods
115
GeoSetup
gSetup;
116
auto
tagPrefix = latest ?
TString
(
"run"
) :
TString::Format
(
"run%d"
, runPeriod);
117
auto
setupTag = gSetup.
GetLastApprovedSetupTag
(tagPrefix.Data());
118
119
if
(gSetup.
LoadSetupToGeoManager
(setupTag) != 0) {
120
LOG(error) <<
"Could not load geometry '"
<< setupTag <<
"' from the Geometry Database for run period "
121
<< runPeriod <<
" and run number "
<< runNumber;
122
return
kFALSE
;
123
}
124
125
return
kTRUE
;
126
}
127
128
void
SetSimTasks
(
Color_t
mcPointColor =
kRed
,
Color_t
recoPointColor =
kBlack
,
Style_t
pointMarker =
kFullDotSmall
)
129
{
130
vector<TString> mcTasks = {
"ArmTrigPoint"
,
"BCPoint"
,
"FDPoint"
,
"MWPCPoint"
,
"BdPoint"
,
131
"SiliconPoint"
,
"StsPoint"
,
"CSCPoint"
,
"SiBTPoint"
,
"SiProfPoint"
,
132
"TOF400Point"
,
"DCHPoint"
,
"TOF700Point"
,
"SsdPoint"
,
"VacWallPoint"
,
133
"HodoPoint"
,
"ScWallPoint"
,
"FHCalPoint"
,
"NdetPoint"
,
"TOF701Point"
};
134
135
vector<TString> recoTasks = {
136
"BmnMwpcHit"
,
"BmnArmTrigHit"
,
"BmnBCHit"
,
"BmnGemStripHit"
,
"BmnTof400Hit"
,
"StsHit"
,
137
"BmnDchHit"
,
"BmnTof701Hit"
,
"BmnCSCHit"
,
"BmnSiliconHit"
,
"BmnTof700Hit"
,
"BmnUpstreamHit"
,
138
};
139
140
// draw MC Points
141
for
(
auto
mcTask : mcTasks)
142
MpdEventManager::Instance
()->
AddTask
(
new
MpdMCPointDraw
(mcTask, mcPointColor, pointMarker));
143
144
// draw MC Geometry Tracks
145
MpdEventManager::Instance
()->
AddTask
(
new
MpdMCTracks
(
"GeoTracks"
));
146
147
// draw Reconstructed Detector Hits
148
for
(
auto
recoTask : recoTasks)
149
MpdEventManager::Instance
()->
AddTask
(
new
MpdHitPointSetDraw
(recoTask, recoPointColor, pointMarker));
150
151
MpdEventManager::Instance
()->
AddTask
(
new
BmnCaloTowerDraw
(
"ZdcDigit"
,
kZDC
));
152
MpdEventManager::Instance
()->
AddTask
(
new
BmnCaloTowerDraw
(
"FHCalDigit"
,
kFHCAL
));
153
MpdEventManager::Instance
()->
AddTask
(
new
BmnCaloTowerDraw
(
"EcalDigit"
,
kECAL
));
154
155
// draw MWPC Tracks
156
MpdEventManager::Instance
()->
AddTask
(
new
BmnTrackDrawH
(
"BmnMwpcTrack"
,
"BmnMwpcHit"
));
157
// draw GEM Tracks
158
MpdEventManager::Instance
()->
AddTask
(
new
BmnTrackDrawH
(
"BmnGemTrack"
,
"BmnGemStripHit"
));
159
MpdEventManager::Instance
()->
AddTask
(
new
BmnTrackDrawH
(
"StsTrack"
,
"StsHit"
));
160
MpdEventManager::Instance
()->
AddTask
(
new
BmnTrackDrawH
(
"StsVector"
,
"StsHit"
));
161
162
// draw Reconstructed Global Tracks
163
MpdEventManager::Instance
()->
AddTask
(
new
BmnGlobalTrackDraw
(
"BmnGlobalTrack"
));
164
}
165
166
void
SetExpTasks
(
Color_t
pointColor =
kRed
,
Style_t
pointMarker =
kFullDotSmall
)
167
{
168
vector<TString> expTasks = {
169
"BmnTof701Hit"
,
"BmnSiliconHit"
,
"BmnGemStripHit"
,
"BmnDchHit"
,
"BmnSiBTHit"
,
"StsHit"
,
170
"BmnTof400Hit"
,
"BmnTof700Hit"
,
"BmnUpstreamHit"
,
"BmnCSCHit"
,
"BmnMwpcHit"
,
171
};
172
173
// draw Reconstructed Detector Hits
174
for
(
auto
expTask : expTasks) {
175
MpdEventManager::Instance
()->
AddTask
(
new
MpdHitPointSetDraw
(expTask, pointColor, pointMarker));
176
}
177
178
MpdEventManager::Instance
()->
AddTask
(
new
BmnCaloTowerDraw
(
"ZdcDigit"
,
kZDC
));
179
MpdEventManager::Instance
()->
AddTask
(
new
BmnCaloTowerDraw
(
"FHCalDigit"
,
kFHCAL
));
180
MpdEventManager::Instance
()->
AddTask
(
new
BmnCaloTowerDraw
(
"EcalDigit"
,
kECAL
));
181
182
// draw MWPC Tracks
183
MpdEventManager::Instance
()->
AddTask
(
new
BmnTrackDrawH
(
"BmnMwpcTrack"
,
"BmnMwpcHit"
));
184
// draw GEM Tracks
185
MpdEventManager::Instance
()->
AddTask
(
new
BmnTrackDrawH
(
"BmnGemTrack"
,
"BmnGemStripHit"
));
186
MpdEventManager::Instance
()->
AddTask
(
new
BmnTrackDrawH
(
"BmnBeamTrack"
,
"BmnSiBTHit"
));
187
MpdEventManager::Instance
()->
AddTask
(
new
BmnTrackDrawH
(
"StsTrack"
,
"StsHit"
));
188
MpdEventManager::Instance
()->
AddTask
(
new
BmnTrackDrawH
(
"StsVector"
,
"StsHit"
));
189
190
// draw Reconstructed Global Tracks
191
MpdEventManager::Instance
()->
AddTask
(
new
BmnGlobalTrackDraw
(
"BmnGlobalTrack"
));
192
}
Style_t
short Style_t
Bool_t
bool Bool_t
Int_t
int Int_t
Color_t
short Color_t
kFALSE
constexpr Bool_t kFALSE
kTRUE
constexpr Bool_t kTRUE
kRed
kRed
kBlack
kBlack
kFullDotSmall
kFullDotSmall
kFHCAL
@ kFHCAL
Definition
BmnDetectorList.h:34
kECAL
@ kECAL
Definition
BmnDetectorList.h:23
kZDC
@ kZDC
Definition
BmnDetectorList.h:20
BmnCaloTowerDraw
Definition
BmnCaloTowerDraw.h:18
BmnFileSource
BmnFileSource.h.
Definition
BmnFileSource.h:30
BmnFunctionSet::isSimulationFile
static int isSimulationFile(TString fileName="")
Definition
BmnFunctionSet.cxx:169
BmnFunctionSet::CheckFileExist
static int CheckFileExist(TString &fileName, int iVerbose=0, EAccessMode mode=kFileExists)
Definition
BmnFunctionSet.cxx:25
BmnGlobalTrackDraw
Definition
BmnGlobalTrackDraw.h:19
BmnOnlineSource
Definition
BmnOnlineSource.h:22
BmnTrackDrawH
Definition
BmnTrackDrawH.h:18
GeoSetup
GeoSetup class.
Definition
GeoSetup.h:40
GeoSetup::LoadSetupToGeoManager
int LoadSetupToGeoManager(string_view setup_tag)
Load selected geometry setup from the Local Geometry Database and create gGeoManager instance.
Definition
GeoSetup.cxx:512
GeoSetup::GetLastApprovedSetupTag
string GetLastApprovedSetupTag(string_view tag_prefix)
Get tag for the last approved setup corresponding to the pattern.
Definition
GeoSetup.cxx:122
MpdEventManager
Definition
MpdEventManager.h:32
MpdEventManager::Init
virtual void Init(Int_t visopt=1, Int_t vislvl=3, Int_t maxvisnds=10000)
Definition
MpdEventManager.cxx:325
MpdEventManager::isDarkColor
bool isDarkColor
Definition
MpdEventManager.h:148
MpdEventManager::Instance
static MpdEventManager * Instance()
Definition
MpdEventManager.cxx:30
MpdEventManager::iDataSource
int iDataSource
Definition
MpdEventManager.h:152
MpdEventManager::background_color
int background_color
Definition
MpdEventManager.h:146
MpdEventManager::isOnline
bool isOnline
Definition
MpdEventManager.h:150
MpdEventManager::AddTask
void AddTask(FairTask *t)
Definition
MpdEventManager.h:88
MpdHitPointSetDraw
Definition
MpdHitPointSetDraw.h:15
MpdMCPointDraw
Definition
MpdMCPointDraw.h:15
MpdMCTracks
MpdMCTracks.
Definition
MpdMCTracks.h:23
TString
TString::Format
static TString Format(const char *fmt,...)
SetSimTasks
void SetSimTasks(Color_t mcPointColor=kRed, Color_t recoPointColor=kBlack, Style_t pointMarker=kFullDotSmall)
Definition
eventdisplay.C:128
SetupExp
void SetupExp(TString recoFile)
Definition
eventdisplay.C:101
SetupOnline
Bool_t SetupOnline(TString endpoint)
Definition
eventdisplay.C:65
SetupSim
void SetupSim(TString simFile, TString recoFile)
Definition
eventdisplay.C:80
LoadGeometry
Bool_t LoadGeometry(Int_t runPeriod, Int_t runNumber, Bool_t latest=kFALSE)
Definition
eventdisplay.C:111
eventdisplay
void eventdisplay(TString simFile="$VMCWORKDIR/macro/run/bmnsim.root", TString recoFile="$VMCWORKDIR/macro/run/bmndst.root", TString endpoint="")
Event Display macro for experimental and simulated data.
Definition
eventdisplay.C:14
SetExpTasks
void SetExpTasks(Color_t pointColor=kRed, Style_t pointMarker=kFullDotSmall)
Definition
eventdisplay.C:166
SetupOffline
Bool_t SetupOffline(TString simFile, TString recoFile)
Definition
eventdisplay.C:40
macro
eventdisplay
eventdisplay.C
Generated on
for BmnRoot by
1.17.0