Back to home page

sPhenix code displayed by LXR

 
 

    


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 <prototype3/CaloCalibration.h>
0011 #include <prototype3/CaloUnpackPRDF.h>
0012 #include <prototype3/EventInfoSummary.h>
0013 #include <prototype3/GenericUnpackPRDF.h>
0014 #include <prototype3/PROTOTYPE3_FEM.h>
0015 #include <prototype3/Prototype3DSTReader.h>
0016 #include <prototype3/RunInfoUnpackPRDF.h>
0017 #include <prototype3/TempInfoUnpackPRDF.h>
0018 
0019 R__LOAD_LIBRARY(libfun4allraw.so)
0020 R__LOAD_LIBRARY(libPrototype3.so)
0021 #endif
0022 
0023 void
0024 Fun4All_TestBeam(int nEvents = 1000,
0025     const char *input_file = "/sphenix/data/data01/t1044-2016a/fnal/beam/beam_00003310-0000.prdf",
0026     const char *output_file = "beam_00003310.root")
0027 {
0028   gSystem->Load("libfun4all");
0029   gSystem->Load("libPrototype3.so");
0030 
0031   Fun4AllServer *se = Fun4AllServer::instance();
0032   se->Verbosity(Fun4AllServer::VERBOSITY_SOME);
0033 
0034   recoConsts *rc = recoConsts::instance();
0035   //rc->set_IntFlag("RUNNUMBER",0);
0036 
0037   // ------------------- Run info -> RUN node -------------------
0038   RunInfoUnpackPRDF *unpack_run = new RunInfoUnpackPRDF();
0039 //  unpack_run->Verbosity(RunInfoUnpackPRDF::VERBOSITY_SOME);
0040 
0041   int i_offset = 0;
0042 
0043   //    rcdaq_client create_device device_filenumbers_delete 9 911 "$HOME/beam_values.txt"
0044   //  S:MTNRG  =  120   GeV
0045   //  F:MT6SC1 =  11127     Cnts
0046   //  F:MT6SC2 =  10585     Cnts
0047   //  F:MT6SC3 =  10442     Cnts
0048   //  F:MT6SC4 =  0         Cnts
0049   //  F:MT6SC5 =  20251     Cnts
0050   //  E:2CH    =  981.9 mm
0051   //  E:2CV    =  93.17 mm
0052   //  E:2CMT6T =  76.11 F
0053   //  E:2CMT6H =  18.09 %Hum
0054   //  F:MT5CP2 =  .0301 Psia
0055   //  F:MT6CP2 =  .6905 Psia
0056   i_offset = 0;
0057   unpack_run->add_channel("beam_MTNRG_GeV", 911, i_offset++, 1e-4);
0058   unpack_run->add_channel("beam_MT6SC1_Cnts", 911, i_offset++, 1e-4);
0059   unpack_run->add_channel("beam_MT6SC2_Cnts", 911, i_offset++, 1e-4);
0060   unpack_run->add_channel("beam_MT6SC3_Cnts", 911, i_offset++, 1e-4);
0061   unpack_run->add_channel("beam_MT6SC4_Cnts", 911, i_offset++, 1e-4);
0062   unpack_run->add_channel("beam_MT6SC5_Cnts", 911, i_offset++, 1e-4);
0063   unpack_run->add_channel("beam_2CH_mm", 911, i_offset++, 1e-4);
0064   unpack_run->add_channel("beam_2CV_mm", 911, i_offset++, 1e-4);
0065   unpack_run->add_channel("beam_2CMT6T_F", 911, i_offset++, 1e-4);
0066   unpack_run->add_channel("beam_2CMT6H_RH", 911, i_offset++, 1e-4);
0067   unpack_run->add_channel("beam_MT5CP2_Psia", 911, i_offset++, 1e-4);
0068   unpack_run->add_channel("beam_MT6CP2_Psia", 911, i_offset++, 1e-4);
0069 
0070 //  rcdaq_client create_device device_filenumbers_delete 9 984 "$HOME/DB_LOGGER_EMCAL_A0_values.txt"
0071   unpack_run->add_channel("EMCAL_A0_HighGain", 984, 0, 1); // 1: pre-amp high gain, 0: nominal gain
0072 
0073   //  rcdaq_client create_device device_filenumbers_delete 9 983 "$HOME/DB_LOGGER_EMCAL_GR0.txt"
0074   unpack_run->add_channel("EMCAL_GR0_BiasOffset_Tower21", 983, 21-1, 1); // bias offset in mV for tower 21
0075 
0076     // rcdaq_client create_device device_filenumbers_delete 9 982 "$HOME/DB_LOGGER_EMCAL_T0_values.txt"
0077   unpack_run->add_channel("EMCAL_T0_Tower21", 982, 21-1, 1e-3); // temperature reading in C for tower 21
0078 
0079   se->registerSubsystem(unpack_run);
0080 
0081   // ------------------- Temperature output -------------------
0082   TempInfoUnpackPRDF *unpack_temp = new TempInfoUnpackPRDF();
0083   unpack_temp->Verbosity(RunInfoUnpackPRDF::VERBOSITY_SOME);
0084   se->registerSubsystem(unpack_temp);
0085 
0086   // ------------------- HCal and EMcal -------------------
0087   SubsysReco *unpack = new CaloUnpackPRDF();
0088 // unpack->Verbosity(1);
0089   se->registerSubsystem(unpack);
0090 
0091 
0092   CaloCalibration *calib = new CaloCalibration("CEMC");
0093   calib->GetCalibrationParameters().ReadFromFile("CEMC","xml",0,0,
0094       string(getenv("CALIBRATIONROOT")) + string("/Prototype3/Calibration/")); // calibration database
0095   se->registerSubsystem(calib);
0096 
0097   calib = new CaloCalibration("HCALIN");
0098   calib->set_calib_tower_node_prefix("CALIB_LG");
0099   calib->set_raw_tower_node_prefix("RAW_LG");
0100   calib->GetCalibrationParameters().set_name("hcalin_lg");
0101   calib->GetCalibrationParameters().ReadFromFile("hcalin_lg", "xml",0,0,
0102       string(getenv("CALIBRATIONROOT")) + string("/Prototype3/Calibration/")); // calibration database
0103   se->registerSubsystem(calib);
0104 
0105   calib = new CaloCalibration("HCALIN");
0106   calib->set_calib_tower_node_prefix("CALIB_HG");
0107   calib->set_raw_tower_node_prefix("RAW_HG");
0108   calib->GetCalibrationParameters().set_name("hcalin_hg");
0109   calib->GetCalibrationParameters().ReadFromFile("hcalin_hg", "xml",0,0,
0110       string(getenv("CALIBRATIONROOT")) + string("/Prototype3/Calibration/")); // calibration database
0111   se->registerSubsystem(calib);
0112 
0113   calib = new CaloCalibration("HCALOUT");
0114   calib->set_calib_tower_node_prefix("CALIB_LG");
0115   calib->set_raw_tower_node_prefix("RAW_LG");
0116   calib->GetCalibrationParameters().set_name("hcalout_lg");
0117   calib->GetCalibrationParameters().ReadFromFile("hcalout_lg", "xml",0,0,
0118       string(getenv("CALIBRATIONROOT")) + string("/Prototype3/Calibration/")); // calibration database
0119   se->registerSubsystem(calib);
0120 
0121   calib = new CaloCalibration("HCALOUT");
0122   calib->set_calib_tower_node_prefix("CALIB_HG");
0123   calib->set_raw_tower_node_prefix("RAW_HG");
0124   calib->GetCalibrationParameters().set_name("hcalout_hg");
0125   calib->GetCalibrationParameters().ReadFromFile("hcalout_hg", "xml",0,0,
0126       string(getenv("CALIBRATIONROOT")) + string("/Prototype3/Calibration/")); // calibration database
0127   se->registerSubsystem(calib);
0128 
0129   // ------------------- Hodoscpes -------------------
0130 
0131   const int first_packet_id = PROTOTYPE3_FEM::PACKET_ID; // 21101
0132   const int second_packet_id = 21102;
0133 
0134   const int N_hodo = 8;
0135 
0136   GenericUnpackPRDF *gunpack = new GenericUnpackPRDF("HODO_VERTICAL");
0137   for (int i = 0; i < N_hodo; ++i)
0138     gunpack->add_channel(first_packet_id, 104 + i, i); // 24 Cerenkov 1
0139   se->registerSubsystem(gunpack);
0140 
0141   gunpack = new GenericUnpackPRDF("HODO_HORIZONTAL");
0142   for (int i = 0; i < N_hodo; ++i)
0143     gunpack->add_channel(first_packet_id, 96 + i, i); // 24 Cerenkov 1
0144   se->registerSubsystem(gunpack);
0145 
0146   calib = new CaloCalibration("HODO_VERTICAL");
0147   calib->GetCalibrationParameters().set_int_param("use_chan_calibration", 1);
0148   // Martin find that even channel has negative polarity and odd channel has positive polarity
0149   for (int i = 0; i < N_hodo; ++i)
0150     calib->GetCalibrationParameters().set_double_param(
0151         Form("calib_const_column0_row%d", i), ((i % 2 > 0) ? -1 : +1));
0152   se->registerSubsystem(calib);
0153 
0154   calib = new CaloCalibration("HODO_HORIZONTAL");
0155   calib->GetCalibrationParameters().set_int_param("use_chan_calibration", 1);
0156   // Martin find that even channel has negative polarity and odd channel has positive polarity
0157   for (int i = 0; i < N_hodo; ++i)
0158     calib->GetCalibrationParameters().set_double_param(
0159         Form("calib_const_column0_row%d", i), ((i % 2 > 0) ? -1 : +1));
0160   se->registerSubsystem(calib);
0161 
0162   // ------------------- Other detectors -------------------
0163 
0164   gunpack = new GenericUnpackPRDF("C1");
0165 // unpack->Verbosity(1);
0166   gunpack->add_channel(second_packet_id, 24, 0); // 24 Cerenkov 1
0167   se->registerSubsystem(gunpack);
0168 
0169   calib = new CaloCalibration("C1");
0170   se->registerSubsystem(calib);
0171 
0172   // more info see https://wiki.bnl.gov/sPHENIX/index.php/T-1044#Cerenkov_Counters
0173   gunpack = new GenericUnpackPRDF("C2");
0174 // unpack->Verbosity(1);
0175   gunpack->add_channel(second_packet_id, 25, 0); //25 Cerenkov 2 Inner
0176   gunpack->add_channel(second_packet_id, 26, 1); //26  Cerenkov 2 Outer
0177   gunpack->add_channel(second_packet_id, 22, 10); //Channel 22 C2inner earlier copy added before run 2210
0178   gunpack->add_channel(second_packet_id, 23, 11); //Channel 23 C2outer earlier copy added before run 2210
0179   se->registerSubsystem(gunpack);
0180 
0181   calib = new CaloCalibration("C2");
0182   calib->GetCalibrationParameters().set_double_param("calib_const_scale", 1);
0183   calib->GetCalibrationParameters().set_int_param("use_chan_calibration", 1);
0184   calib->GetCalibrationParameters().set_double_param("calib_const_column0_row0", +1);
0185   calib->GetCalibrationParameters().set_double_param("calib_const_column0_row1", -1);
0186   calib->GetCalibrationParameters().set_double_param("calib_const_column0_row10", -1);
0187   calib->GetCalibrationParameters().set_double_param("calib_const_column0_row11", +1);
0188   se->registerSubsystem(calib);
0189 
0190 //  John H. : should be 19, 20, 21 and the other channels are a litle permuted from  what I thought
0191   gunpack = new GenericUnpackPRDF("HCAL_SCINT");
0192 // unpack->Verbosity(1);
0193   gunpack->add_channel(second_packet_id, 19, 1);
0194   gunpack->add_channel(second_packet_id, 20, 2);
0195   gunpack->add_channel(second_packet_id, 21, 3);
0196   se->registerSubsystem(gunpack);
0197 
0198   calib = new CaloCalibration("HCAL_SCINT");
0199   se->registerSubsystem(calib);
0200 
0201   gunpack = new GenericUnpackPRDF("PbGL");
0202 // unpack->Verbosity(1);
0203   gunpack->add_channel(second_packet_id, 27, 0); // 27  PbGl  From channel 2 of adjacent 612AM amplifier
0204   se->registerSubsystem(gunpack);
0205 
0206   calib = new CaloCalibration("PbGL");
0207   calib->GetCalibrationParameters().set_double_param("calib_const_scale", 1);
0208   se->registerSubsystem(calib);
0209 
0210   gunpack = new GenericUnpackPRDF("TRIGGER_VETO");
0211 // unpack->Verbosity(1);
0212   gunpack->add_channel(second_packet_id, 28, 0); //  28  Bottom trigger veto
0213   gunpack->add_channel(second_packet_id, 29, 1); //  29  Top trigger veto
0214   gunpack->add_channel(second_packet_id, 30, 2); //  30  Left trigger veto
0215   gunpack->add_channel(second_packet_id, 31, 3); //  31  Right trigger veto
0216   se->registerSubsystem(gunpack);
0217 
0218   // Calibrate the MIP peak to an relative energy of +1.0
0219   calib = new CaloCalibration("TRIGGER_VETO");
0220   calib->GetCalibrationParameters().set_double_param("calib_const_scale", 1);
0221   calib->GetCalibrationParameters().set_int_param("use_chan_calibration", 1);
0222   calib->GetCalibrationParameters().set_double_param("calib_const_column0_row0", -1./29.4155);
0223   calib->GetCalibrationParameters().set_double_param("calib_const_column0_row1", +1./91);
0224   calib->GetCalibrationParameters().set_double_param("calib_const_column0_row2", -1./31.3981);
0225   calib->GetCalibrationParameters().set_double_param("calib_const_column0_row3", +1./1.43839e+02);
0226   se->registerSubsystem(calib);
0227 
0228   const int N_TileMapper = 16;
0229 
0230   gunpack = new GenericUnpackPRDF("TILE_MAPPER");
0231   for (int i = 0; i < N_TileMapper; ++i)
0232     gunpack->add_channel(second_packet_id, 32 + i, i); // 24 Cerenkov 1
0233   se->registerSubsystem(gunpack);
0234 
0235   calib = new CaloCalibration("TILE_MAPPER");
0236   se->registerSubsystem(calib);
0237 
0238   //  https://wiki.bnl.gov/sPHENIX/index.php/2017_calorimeter_beam_test#Facility_Detector_ADC_Map
0239   gunpack = new GenericUnpackPRDF("SC3");
0240 // unpack->Verbosity(1);
0241   gunpack->add_channel(second_packet_id, 17, 0); // 17  SC3 From channel 3 of adjacent 612AM amplifier
0242   se->registerSubsystem(gunpack);
0243 
0244   calib = new CaloCalibration("SC3");
0245   calib->GetCalibrationParameters().set_double_param("calib_const_scale", 1);
0246   se->registerSubsystem(calib);
0247 
0248   gunpack = new GenericUnpackPRDF("SC_MWPC4");
0249 // unpack->Verbosity(1);
0250   gunpack->add_channel(second_packet_id, 18, 0); // 18  SC behind MWPC4 From channel 4 of adjacent 612AM amplifier
0251   se->registerSubsystem(gunpack);
0252 
0253   calib = new CaloCalibration("SC_MWPC4");
0254   calib->GetCalibrationParameters().set_double_param("calib_const_scale", -1);
0255   se->registerSubsystem(calib);
0256 
0257   gunpack = new GenericUnpackPRDF("SPILL_WARBLER");
0258 // unpack->Verbosity(1);
0259   gunpack->add_channel(second_packet_id, 16, 0); // Short Meritec cable 0 16  Spill warbler
0260   se->registerSubsystem(gunpack);
0261 
0262   // -------------------  Event summary -------------------
0263 
0264   se->registerSubsystem(new EventInfoSummary());
0265 
0266   // -------------------  Output -------------------
0267   //main DST output
0268   Fun4AllDstOutputManager *out_Manager = new Fun4AllDstOutputManager("DSTOUT",
0269       output_file);
0270   se->registerOutputManager(out_Manager);
0271 
0272   //alternatively, fast check on DST using DST Reader:
0273   Prototype3DSTReader *reader = new Prototype3DSTReader(
0274       string(output_file) + string("_DSTReader.root"));
0275 
0276   reader->AddRunInfo("beam_MTNRG_GeV");
0277   reader->AddRunInfo("beam_2CH_mm");
0278   reader->AddRunInfo("beam_2CV_mm");
0279   reader->AddRunInfo("EMCAL_A0_HighGain");
0280   reader->AddRunInfo("EMCAL_GR0_BiasOffset_Tower21");
0281   reader->AddRunInfo("EMCAL_T0_Tower21");
0282   reader->AddRunInfo("EMCAL_Is_HighEta");
0283 
0284   reader->AddEventInfo("beam_Is_In_Spill");
0285   reader->AddEventInfo("beam_SPILL_WARBLER_RMS");
0286   reader->AddEventInfo("CALIB_CEMC_Sum");
0287   reader->AddEventInfo("CALIB_LG_HCALIN_Sum");
0288   reader->AddEventInfo("CALIB_LG_HCALOUT_Sum");
0289 
0290   reader->AddTower("RAW_LG_HCALIN");
0291   reader->AddTower("RAW_HG_HCALIN");
0292   reader->AddTower("RAW_LG_HCALOUT");
0293   reader->AddTower("RAW_HG_HCALOUT");
0294 
0295   reader->AddTower("CALIB_LG_HCALIN");
0296   reader->AddTower("CALIB_HG_HCALIN");
0297   reader->AddTower("CALIB_LG_HCALOUT");
0298   reader->AddTower("CALIB_HG_HCALOUT");
0299 
0300   reader->AddTower("RAW_CEMC");
0301   reader->AddTower("CALIB_CEMC");
0302 
0303   reader->AddTower("RAW_HODO_VERTICAL");
0304   reader->AddTower("RAW_HODO_HORIZONTAL");
0305   reader->AddTower("CALIB_HODO_VERTICAL");
0306   reader->AddTower("CALIB_HODO_HORIZONTAL");
0307 
0308   reader->AddTower("RAW_C1");
0309   reader->AddTower("CALIB_C1");
0310 
0311   reader->AddTower("RAW_C2");
0312   reader->AddTower("CALIB_C2");
0313 
0314   reader->AddTower("RAW_HCAL_SCINT");
0315   reader->AddTower("CALIB_HCAL_SCINT");
0316 
0317   reader->AddTower("RAW_PbGL");
0318   reader->AddTower("CALIB_PbGL");
0319 
0320   reader->AddTower("RAW_TRIGGER_VETO");
0321   reader->AddTower("CALIB_TRIGGER_VETO");
0322 
0323   reader->AddTower("RAW_TILE_MAPPER");
0324   reader->AddTower("CALIB_TILE_MAPPER");
0325 
0326   reader->AddTower("RAW_SC3");
0327   reader->AddTower("CALIB_SC3");
0328 
0329   reader->AddTower("RAW_SC_MWPC4");
0330   reader->AddTower("CALIB_SC_MWPC4");
0331 
0332   reader->AddTower("RAW_SPILL_WARBLER");
0333 
0334 //  reader->AddTowerTemperature("EMCAL");
0335 //  reader->AddTowerTemperature("HCALIN");
0336 //  reader->AddTowerTemperature("HCALOUT");
0337 
0338   se->registerSubsystem(reader);
0339 
0340   Fun4AllInputManager *in = new Fun4AllPrdfInputManager("PRDFin");
0341   in->fileopen(input_file);
0342   se->registerInputManager(in);
0343 
0344   se->run(nEvents);
0345 
0346   se->End();
0347 
0348 }