File indexing completed on 2025-08-05 08:20:35
0001 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
0002 #include <fun4all/Fun4AllServer.h>
0003 #include <fun4all/Fun4AllDstOutputManager.h>
0004 #include <fun4all/Fun4AllInputManager.h>
0005
0006 #include <fun4allraw/Fun4AllPrdfInputManager.h>
0007
0008 #include <phool/recoConsts.h>
0009
0010 #include <prototype4/CaloCalibration.h>
0011 #include <prototype4/CaloUnpackPRDF.h>
0012 #include <prototype4/EventInfoSummary.h>
0013 #include <prototype4/GenericUnpackPRDF.h>
0014 #include <prototype4/PROTOTYPE4_FEM.h>
0015 #include <prototype4/Prototype4DSTReader.h>
0016 #include <prototype4/RunInfoUnpackPRDF.h>
0017 #include <prototype4/TempInfoUnpackPRDF.h>
0018
0019 R__LOAD_LIBRARY(libfun4allraw.so)
0020 R__LOAD_LIBRARY(libPrototype4.so)
0021 #endif
0022
0023 void Fun4All_TestBeam(int nEvents = 100,
0024 const char *input_file = "/sphenix/data/data02/sphenix/t1044/fnal/beam/beam_00000406-0000.prdf",
0025 const char *output_file = "beam_00000406.root")
0026 {
0027 gSystem->Load("libfun4all");
0028 gSystem->Load("libPrototype4.so");
0029
0030 const bool do_cemc = true;
0031 const bool do_hcal = true;
0032
0033
0034
0035 Fun4AllServer *se = Fun4AllServer::instance();
0036 se->Verbosity(Fun4AllServer::VERBOSITY_SOME);
0037
0038 recoConsts *rc = recoConsts::instance();
0039
0040
0041
0042 RunInfoUnpackPRDF *unpack_run = new RunInfoUnpackPRDF();
0043
0044
0045 int i_offset = 0;
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060 i_offset = 0;
0061 unpack_run->add_channel("beam_MTNRG_GeV", 911, i_offset++, 1e-4);
0062 unpack_run->add_channel("beam_MT6SC1_Cnts", 911, i_offset++, 1e-4);
0063 unpack_run->add_channel("beam_MT6SC2_Cnts", 911, i_offset++, 1e-4);
0064 unpack_run->add_channel("beam_MT6SC3_Cnts", 911, i_offset++, 1e-4);
0065 unpack_run->add_channel("beam_MT6SC4_Cnts", 911, i_offset++, 1e-4);
0066 unpack_run->add_channel("beam_MT6SC5_Cnts", 911, i_offset++, 1e-4);
0067 unpack_run->add_channel("beam_2CH_mm", 911, i_offset++, 1e-4);
0068 unpack_run->add_channel("beam_2CV_mm", 911, i_offset++, 1e-4);
0069 unpack_run->add_channel("beam_2CMT6T_F", 911, i_offset++, 1e-4);
0070 unpack_run->add_channel("beam_2CMT6H_RH", 911, i_offset++, 1e-4);
0071 unpack_run->add_channel("beam_MT5CP2_Psia", 911, i_offset++, 1e-4);
0072 unpack_run->add_channel("beam_MT6CP2_Psia", 911, i_offset++, 1e-4);
0073
0074
0075 unpack_run->add_channel("EMCAL_A0_HighGain", 984, 0, 1);
0076
0077
0078 unpack_run->add_channel("EMCAL_GR0_BiasOffset_Tower21", 983, 21 - 1, 1);
0079
0080
0081 unpack_run->add_channel("EMCAL_T0_Tower21", 982, 21 - 1, 1e-3);
0082
0083 se->registerSubsystem(unpack_run);
0084
0085
0086
0087
0088
0089
0090
0091
0092 CaloCalibration *calib = NULL;
0093
0094 if (do_cemc)
0095 {
0096 SubsysReco *unpack = new CaloUnpackPRDF();
0097
0098 se->registerSubsystem(unpack);
0099
0100 calib = new CaloCalibration("CEMC");
0101
0102
0103
0104 calib->GetCalibrationParameters().ReadFromFile("CEMC", "xml", 0, 0,
0105 string(getenv("CALIBRATIONROOT")) + string("/Prototype4/Calibration/"));
0106 se->registerSubsystem(calib);
0107 }
0108
0109 if (do_hcal)
0110 {
0111
0112 const double cin_cali = 0.00270145;
0113 const double cout_cali = 0.0065718;
0114
0115 calib = new CaloCalibration("HCALIN");
0116 calib->set_calib_tower_node_prefix("CALIB_LG");
0117 calib->set_raw_tower_node_prefix("RAW_LG");
0118 calib->GetCalibrationParameters().set_name("hcalin_lg");
0119
0120
0121 calib->GetCalibrationParameters().ReadFromFile("hcalin_lg", "xml", 0, 0,
0122 string(getenv("CALIBRATIONROOT")) + string("/Prototype4/Calibration/"));
0123 se->registerSubsystem(calib);
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133 calib = new CaloCalibration("HCALOUT");
0134 calib->set_calib_tower_node_prefix("CALIB_LG");
0135 calib->set_raw_tower_node_prefix("RAW_LG");
0136 calib->GetCalibrationParameters().set_name("hcalout_lg");
0137
0138
0139 calib->GetCalibrationParameters().ReadFromFile("hcalout_lg", "xml", 0, 0,
0140 string(getenv("CALIBRATIONROOT")) + string("/Prototype4/Calibration/"));
0141 se->registerSubsystem(calib);
0142
0143 calib = new CaloCalibration("HCALOUT");
0144 calib->set_calib_tower_node_prefix("CALIB_HG");
0145 calib->set_raw_tower_node_prefix("RAW_HG");
0146 calib->GetCalibrationParameters().set_name("hcalout_hg");
0147
0148
0149 calib->GetCalibrationParameters().ReadFromFile("hcalout_hg", "xml", 0, 0,
0150 string(getenv("CALIBRATIONROOT")) + string("/Prototype4/Calibration/"));
0151 se->registerSubsystem(calib);
0152 }
0153
0154
0155
0156 const int first_packet_id = PROTOTYPE4_FEM::PACKET_ID;
0157
0158
0159 GenericUnpackPRDF *gunpack = NULL;
0160
0161 const int N_hodo = 8;
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175 gunpack = new GenericUnpackPRDF("HODO_VERTICAL");
0176 gunpack->add_channel(first_packet_id, 101, 0);
0177 gunpack->add_channel(first_packet_id, 100, 1);
0178 gunpack->add_channel(first_packet_id, 103, 2);
0179 gunpack->add_channel(first_packet_id, 102, 3);
0180 gunpack->add_channel(first_packet_id, 97, 4);
0181 gunpack->add_channel(first_packet_id, 96, 5);
0182 gunpack->add_channel(first_packet_id, 99, 6);
0183 gunpack->add_channel(first_packet_id, 98, 7);
0184 se->registerSubsystem(gunpack);
0185
0186 gunpack = new GenericUnpackPRDF("HODO_HORIZONTAL");
0187 gunpack->add_channel(first_packet_id, 109, 0);
0188 gunpack->add_channel(first_packet_id, 108, 1);
0189 gunpack->add_channel(first_packet_id, 111, 2);
0190 gunpack->add_channel(first_packet_id, 110, 3);
0191 gunpack->add_channel(first_packet_id, 105, 4);
0192 gunpack->add_channel(first_packet_id, 104, 5);
0193 gunpack->add_channel(first_packet_id, 107, 6);
0194 gunpack->add_channel(first_packet_id, 106, 7);
0195 se->registerSubsystem(gunpack);
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219 calib = new CaloCalibration("HODO_VERTICAL");
0220 calib->GetCalibrationParameters().set_int_param("use_chan_calibration", 1);
0221 calib->GetCalibrationParameters().set_double_param(Form("calib_const_column0_row%d", 0), 1 / 238.473);
0222 calib->GetCalibrationParameters().set_double_param(Form("calib_const_column0_row%d", 1), 1 / 225.202);
0223 calib->GetCalibrationParameters().set_double_param(Form("calib_const_column0_row%d", 2), 1 / 209.827);
0224 calib->GetCalibrationParameters().set_double_param(Form("calib_const_column0_row%d", 3), 1 / 217.544);
0225 calib->GetCalibrationParameters().set_double_param(Form("calib_const_column0_row%d", 4), 1 / 210.6);
0226 calib->GetCalibrationParameters().set_double_param(Form("calib_const_column0_row%d", 5), 1 / 252.022);
0227 calib->GetCalibrationParameters().set_double_param(Form("calib_const_column0_row%d", 6), 1 / 223.528);
0228 calib->GetCalibrationParameters().set_double_param(Form("calib_const_column0_row%d", 7), 1 / 244.299);
0229 se->registerSubsystem(calib);
0230
0231 calib = new CaloCalibration("HODO_HORIZONTAL");
0232 calib->GetCalibrationParameters().set_int_param("use_chan_calibration", 1);
0233 calib->GetCalibrationParameters().set_double_param(Form("calib_const_column0_row%d", 0), 1 / 319.879);
0234 calib->GetCalibrationParameters().set_double_param(Form("calib_const_column0_row%d", 1), 1 / 262.209);
0235 calib->GetCalibrationParameters().set_double_param(Form("calib_const_column0_row%d", 2), 1 / 296.343);
0236 calib->GetCalibrationParameters().set_double_param(Form("calib_const_column0_row%d", 3), 1 / 299.135);
0237 calib->GetCalibrationParameters().set_double_param(Form("calib_const_column0_row%d", 4), 1 / 290.498);
0238 calib->GetCalibrationParameters().set_double_param(Form("calib_const_column0_row%d", 5), 1 / 263.781);
0239 calib->GetCalibrationParameters().set_double_param(Form("calib_const_column0_row%d", 6), 1 / 336.446);
0240 calib->GetCalibrationParameters().set_double_param(Form("calib_const_column0_row%d", 7), 1 / 336.247);
0241 se->registerSubsystem(calib);
0242
0243
0244
0245
0246 gunpack = new GenericUnpackPRDF("C1");
0247
0248 gunpack->add_channel(first_packet_id, 165, 0);
0249 se->registerSubsystem(gunpack);
0250
0251 calib = new CaloCalibration("C1");
0252 calib->SetFitType(CaloCalibration::kPeakSample);
0253 se->registerSubsystem(calib);
0254
0255
0256 gunpack = new GenericUnpackPRDF("C2");
0257
0258 gunpack->add_channel(first_packet_id, 166, 0);
0259 gunpack->add_channel(first_packet_id, 160, 1);
0260 gunpack->add_channel(first_packet_id, 167, 10);
0261 se->registerSubsystem(gunpack);
0262
0263 calib = new CaloCalibration("C2");
0264 calib->SetFitType(CaloCalibration::kPeakSample);
0265 calib->GetCalibrationParameters().set_double_param("calib_const_scale", 1);
0266 calib->GetCalibrationParameters().set_int_param("use_chan_calibration", 1);
0267 calib->GetCalibrationParameters().set_double_param("calib_const_column0_row0", 1);
0268 calib->GetCalibrationParameters().set_double_param("calib_const_column0_row1", 1);
0269 calib->GetCalibrationParameters().set_double_param("calib_const_column0_row10", 1);
0270 calib->GetCalibrationParameters().set_double_param("calib_const_column0_row11", 1);
0271 se->registerSubsystem(calib);
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285 gunpack = new GenericUnpackPRDF("PbGL");
0286
0287 gunpack->add_channel(first_packet_id, 171, 0);
0288 se->registerSubsystem(gunpack);
0289
0290 calib = new CaloCalibration("PbGL");
0291 calib->GetCalibrationParameters().set_double_param("calib_const_scale", 1);
0292 se->registerSubsystem(calib);
0293
0294
0295 gunpack = new GenericUnpackPRDF("TRIGGER_VETO");
0296
0297 gunpack->add_channel(first_packet_id, 172, 0);
0298 gunpack->add_channel(first_packet_id, 173, 1);
0299 gunpack->add_channel(first_packet_id, 174, 2);
0300 gunpack->add_channel(first_packet_id, 175, 3);
0301 se->registerSubsystem(gunpack);
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314 calib = new CaloCalibration("TRIGGER_VETO");
0315 calib->SetFitType(CaloCalibration::kPeakSample);
0316 calib->GetCalibrationParameters().set_double_param("calib_const_scale", 1);
0317 calib->GetCalibrationParameters().set_int_param("use_chan_calibration", 1);
0318 calib->GetCalibrationParameters().set_double_param("calib_const_column0_row0", 1. / 295.811);
0319 calib->GetCalibrationParameters().set_double_param("calib_const_column0_row1", 1. / 305.247);
0320 calib->GetCalibrationParameters().set_double_param("calib_const_column0_row2", 1. / 451.48);
0321 calib->GetCalibrationParameters().set_double_param("calib_const_column0_row3", 1. / 624.076);
0322 se->registerSubsystem(calib);
0323
0324 const int N_TileMapper = 16;
0325
0326 gunpack = new GenericUnpackPRDF("TILE_MAPPER");
0327 for (int i = 0; i < N_TileMapper; ++i)
0328 gunpack->add_channel(first_packet_id, 176 + i, i);
0329 se->registerSubsystem(gunpack);
0330
0331 calib = new CaloCalibration("TILE_MAPPER");
0332 calib->GetCalibrationParameters().set_double_param("calib_const_scale", 1);
0333 se->registerSubsystem(calib);
0334
0335
0336 gunpack = new GenericUnpackPRDF("SC3");
0337
0338 gunpack->add_channel(first_packet_id, 169, 0);
0339 se->registerSubsystem(gunpack);
0340
0341 calib = new CaloCalibration("SC3");
0342 calib->GetCalibrationParameters().set_double_param("calib_const_scale", 1);
0343 se->registerSubsystem(calib);
0344
0345 gunpack = new GenericUnpackPRDF("FINGER_COUNTER");
0346
0347 gunpack->add_channel(first_packet_id, 168, 0);
0348 se->registerSubsystem(gunpack);
0349
0350 calib = new CaloCalibration("FINGER_COUNTER");
0351 calib->GetCalibrationParameters().set_double_param("calib_const_scale", 1);
0352 se->registerSubsystem(calib);
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376 Fun4AllDstOutputManager *out_Manager = new Fun4AllDstOutputManager("DSTOUT",
0377 output_file);
0378 se->registerOutputManager(out_Manager);
0379
0380
0381 Prototype4DSTReader *reader = new Prototype4DSTReader(
0382 string(output_file) + string("_DSTReader.root"));
0383
0384 reader->AddRunInfo("beam_MTNRG_GeV");
0385 reader->AddRunInfo("beam_2CH_mm");
0386 reader->AddRunInfo("beam_2CV_mm");
0387 reader->AddRunInfo("EMCAL_A0_HighGain");
0388 reader->AddRunInfo("EMCAL_GR0_BiasOffset_Tower21");
0389 reader->AddRunInfo("EMCAL_T0_Tower21");
0390 reader->AddRunInfo("EMCAL_Is_HighEta");
0391
0392
0393
0394
0395
0396
0397
0398 if (do_hcal)
0399 {
0400 reader->AddTower("RAW_LG_HCALIN");
0401
0402 reader->AddTower("RAW_LG_HCALOUT");
0403 reader->AddTower("RAW_HG_HCALOUT");
0404
0405 reader->AddTower("CALIB_LG_HCALIN");
0406
0407 reader->AddTower("CALIB_LG_HCALOUT");
0408 reader->AddTower("CALIB_HG_HCALOUT");
0409 }
0410
0411 if (do_cemc)
0412 {
0413 reader->AddTower("RAW_CEMC");
0414 reader->AddTower("CALIB_CEMC");
0415 }
0416
0417
0418 reader->AddTower("RAW_HODO_VERTICAL");
0419 reader->AddTower("RAW_HODO_HORIZONTAL");
0420 reader->AddTower("CALIB_HODO_VERTICAL");
0421 reader->AddTower("CALIB_HODO_HORIZONTAL");
0422
0423 reader->AddTower("RAW_C1");
0424 reader->AddTower("CALIB_C1");
0425
0426 reader->AddTower("RAW_C2");
0427 reader->AddTower("CALIB_C2");
0428
0429
0430
0431
0432 reader->AddTower("RAW_PbGL");
0433 reader->AddTower("CALIB_PbGL");
0434
0435 reader->AddTower("RAW_TRIGGER_VETO");
0436 reader->AddTower("CALIB_TRIGGER_VETO");
0437
0438 reader->AddTower("RAW_TILE_MAPPER");
0439 reader->AddTower("CALIB_TILE_MAPPER");
0440
0441 reader->AddTower("RAW_SC3");
0442 reader->AddTower("CALIB_SC3");
0443
0444 reader->AddTower("RAW_FINGER_COUNTER");
0445 reader->AddTower("CALIB_FINGER_COUNTER");
0446
0447
0448
0449
0450
0451
0452
0453
0454
0455
0456
0457 se->registerSubsystem(reader);
0458
0459 Fun4AllInputManager *in = new Fun4AllPrdfInputManager("PRDFin");
0460 in->fileopen(input_file);
0461 se->registerInputManager(in);
0462
0463 se->run(nEvents);
0464
0465 se->End();
0466 }