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