MonitorT0.C 4.21 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
/** @file MCBM DATA unpacking
 ** @author Florian Uhlig <f.uhlig@gsi.de>
 ** @date 20.06.2016
 ** Modified by P.-A. Loizeau
 ** @date 30.01.2019
 ** ROOT macro to read tsa files which have been produced with the new data transport
 ** Convert data into cbmroot format.
 ** Uses CbmMcbm2018Source as source task.
 */
// In order to call later Finish, we make this global
FairRunOnline* run = NULL;

Pierre-Alain Loizeau's avatar
Pierre-Alain Loizeau committed
13
14
/// FIXME: Disable clang formatting to keep easy parameters overview
/* clang-format off */
15
16
17
18
19
20
void MonitorT0(TString inFile           = "",
               TString sHostname        = "cbmflesnode8:5558;cbmflesnode9:5559",
               Int_t iServerHttpPort    = 8080,
               Int_t iServerRefreshRate = 100,
               UInt_t uRunId            = 0,
               UInt_t nrEvents          = 0) {
Pierre-Alain Loizeau's avatar
Pierre-Alain Loizeau committed
21
22
23
  /// FIXME: Re-enable clang formatting after parameters initial values setting
  /* clang-format on */

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
  TString srcDir = gSystem->Getenv("VMCWORKDIR");

  // --- Specify number of events to be produced.
  // --- -1 means run until the end of the input file.
  Int_t nEvents = -1;
  // --- Specify output file name (this is just an example)
  TString runId   = TString::Format("%u", uRunId);
  TString parFile = "data/moni_t0_params_" + runId + ".root";

  // --- Set log output levels
  FairLogger::GetLogger();
  gLogger->SetLogScreenLevel("INFO");
  //gLogger->SetLogScreenLevel("DEBUG");
  gLogger->SetLogVerbosityLevel("MEDIUM");

  // --- Define parameter files
  TList* parFileList = new TList();
  TString paramDir   = srcDir + "/macro/beamtime/mcbm2021/";

  TString paramFileTof       = paramDir + "mT0Par.par";
  TObjString* parTofFileName = new TObjString(paramFileTof);
  parFileList->Add(parTofFileName);

  // --- Set debug level
  gDebug = 0;

  std::cout << std::endl;

  // ========================================================================
  // ========================================================================
  std::cout << std::endl;
  std::cout << ">>> MonitorT0: Initialising..." << std::endl;
  CbmMcbm2018MonitorTaskT0* monitor_t0 = new CbmMcbm2018MonitorTaskT0();

  monitor_t0->SetIgnoreOverlapMs();
  monitor_t0->SetHistoryHistoSize(1800);
Pierre-Alain Loizeau's avatar
Pierre-Alain Loizeau committed
60
  if (0 < uRunId) monitor_t0->SetHistoFilename(Form("data/HistosMonitorT0_%03u.root", uRunId));
61
62
63
64
65
  monitor_t0->SetPulserTotLimits(180, 210);  // for runs  >  86

  // --- Source task
  CbmMcbm2018Source* source = new CbmMcbm2018Source();

Pierre-Alain Loizeau's avatar
Pierre-Alain Loizeau committed
66
  if ("" != inFile) { source->SetFileName(inFile); }  // if( "" != inFile )
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
  else {
    source->SetHostName(sHostname);
  }  // else of if( "" != inFile )

  // Use kHodo since there is no entry for T0 in the enum yet
  source->AddUnpacker(monitor_t0, 0x90, ECbmModuleId::kHodo);  //gDPB T0

  source->SetSubscriberHwm(1000);

  // --- Run
  run = new FairRunOnline(source);
  run->ActivateHttpServer(iServerRefreshRate,
                          iServerHttpPort);  // refresh each 100 events
  /// To avoid the server sucking all Histos from gROOT when no output file is used
  /// ===> Need to explicitely add the canvases to the server in the task!
  run->GetHttpServer()->GetSniffer()->SetScanGlobalDir(kFALSE);
  run->SetAutoFinish(kFALSE);


  // -----   Runtime database   ---------------------------------------------
  FairRuntimeDb* rtdb       = run->GetRuntimeDb();
  FairParAsciiFileIo* parIn = new FairParAsciiFileIo();
  parIn->open(parFileList, "in");
  rtdb->setFirstInput(parIn);

  run->Init();

  // --- Start run
  TStopwatch timer;
  timer.Start();
  std::cout << ">>> MonitorT0: Starting run..." << std::endl;
  if (0 == nrEvents) {
    run->Run(nEvents, 0);  // run until end of input file
Pierre-Alain Loizeau's avatar
Pierre-Alain Loizeau committed
100
101
  }
  else {
102
103
104
105
106
107
    run->Run(0, nrEvents);  // process  2000 Events
  }
  run->Finish();

  timer.Stop();

Pierre-Alain Loizeau's avatar
Pierre-Alain Loizeau committed
108
  std::cout << "Processed " << std::dec << source->GetTsCount() << " timeslices" << std::endl;
109
110
111
112
113
114

  // --- End-of-run info
  Double_t rtime = timer.RealTime();
  Double_t ctime = timer.CpuTime();
  std::cout << std::endl << std::endl;
  std::cout << ">>> MonitorT0: Macro finished successfully." << std::endl;
Pierre-Alain Loizeau's avatar
Pierre-Alain Loizeau committed
115
  std::cout << ">>> MonitorT0: Real time " << rtime << " s, CPU time " << ctime << " s" << std::endl;
116
117
118
119
120
121
  std::cout << std::endl;

  /// --- Screen output for automatic tests
  std::cout << " Test passed" << std::endl;
  std::cout << " All ok " << std::endl;
}