-
Notifications
You must be signed in to change notification settings - Fork 0
/
waveformgen.C
848 lines (696 loc) · 27.1 KB
/
waveformgen.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
60
61
62
63
64
65
66
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
#ifndef MACRO_FUN4ALLG4SPHENIX_C
#define MACRO_FUN4ALLG4SPHENIX_C
#include <GlobalVariables.C>
#include <DisplayOn.C>
#include <G4Setup_sPHENIX.C>
#include <G4_Mbd.C>
#include <G4_CaloTrigger.C>
#include <G4_Centrality.C>
#include <G4_DSTReader.C>
#include <G4_Global.C>
#include <G4_HIJetReco.C>
#include <G4_Input.C>
#include <G4_Jets.C>
#include <G4_KFParticle.C>
#include <G4_ParticleFlow.C>
#include <G4_Production.C>
#include <G4_TopoClusterReco.C>
#include <Trkr_RecoInit.C>
#include <Trkr_Clustering.C>
#include <Trkr_LaserClustering.C>
#include <Trkr_Reco.C>
#include <Trkr_Eval.C>
#include <Trkr_QA.C>
#include <Trkr_Diagnostics.C>
#include <G4_User.C>
#include <QA.C>
#include <ffamodules/FlagHandler.h>
#include <ffamodules/HeadReco.h>
#include <ffamodules/SyncReco.h>
#include <ffamodules/CDBInterface.h>
#include <fun4all/Fun4AllDstOutputManager.h>
#include <fun4all/Fun4AllOutputManager.h>
#include <fun4all/Fun4AllServer.h>
#include <caloreco/CaloGeomMapping.h>
#include <caloreco/CaloTowerBuilder.h>
#include <caloreco/CaloTowerCalib.h>
#include <caloreco/CaloWaveformProcessing.h>
#include <caloreco/CaloTowerStatus.h>
#include <calowaveformsim/CaloWaveformSim.h>
#include <phool/PHRandomSeed.h>
#include <phool/recoConsts.h>
#include </sphenix/user/shuhangli/FunWithML/TreeMaker/singleparticleml/CaloAna24.h>
R__LOAD_LIBRARY(libCaloAna24.so)
R__LOAD_LIBRARY(libfun4all.so)
R__LOAD_LIBRARY(libg4centrality.so)
R__LOAD_LIBRARY(libCaloWaveformSim.so)
R__LOAD_LIBRARY(libcalo_reco.so)
R__LOAD_LIBRARY(libffamodules.so)
R__LOAD_LIBRARY(libfun4allutils.so)
// For HepMC Hijing
// try inputFile = /sphenix/sim/sim01/sphnxpro/sHijing_HepMC/sHijing_0-12fm.dat
int Fun4All_G4_sPHENIX(
const int nEvents = 1,
const string &inputFile = "https://www.phenix.bnl.gov/WWW/publish/phnxbld/sPHEN
IX/files/sPHENIX_G4Hits_sHijing_9-11fm_00000_00010.root",
const string &outputFile = "G4sPHENIX.root",
const string &embed_input_file = "https://www.phenix.bnl.gov/WWW/publish/phnxbl
d/sPHENIX/files/sPHENIX_G4Hits_sHijing_9-11fm_00000_00010.root",
const int skip = 0,
const string &outdir = ".")
{
Fun4AllServer *se = Fun4AllServer::instance();
se->Verbosity(2);
//Opt to print all random seed used for debugging reproducibility. Comment out to reduce stdout prints.
PHRandomSeed::Verbosity(1);
// just if we set some flags somewhere in this macro
recoConsts *rc = recoConsts::instance();
// By default every random number generator uses
// PHRandomSeed() which reads /dev/urandom to get its seed
// if the RANDOMSEED flag is set its value is taken as seed
// You can either set this to a random value using PHRandomSeed()
// which will make all seeds identical (not sure what the point of
// this would be:
// rc->set_IntFlag("RANDOMSEED",PHRandomSeed());
// or set it to a fixed value so you can debug your code
// rc->set_IntFlag("RANDOMSEED", 12345);
//===============
// Input options
//===============
// verbosity setting (applies to all input managers)
Input::VERBOSITY = 0;
// First enable the input generators
// Either:
// read previously generated g4-hits files, in this case it opens a DST and skips
// the simulations step completely. The G4Setup macro is only loaded to get information
// about the number of layers used for the cell reco code
// Input::READHITS = true;
INPUTREADHITS::filename[0] = inputFile;
// if you use a filelist
// INPUTREADHITS::listfile[0] = inputFile;
// Or:
// Use particle generator
// And
// Further choose to embed newly simulated events to a previous simulation. Not compatible with `readhits = true`
// In case embedding into a production output, please double check your G4Setup_sPHENIX.C and G4_*.C consistent with those in the production macro folder
// E.g. /sphenix/sim//sim01/production/2016-07-21/single_particle/spacal2d/
// Input::EMBED = true;
INPUTEMBED::filename[0] = embed_input_file;
// if you use a filelist
//INPUTEMBED::listfile[0] = embed_input_file;
Input::SIMPLE = true;
// Input::SIMPLE_NUMBER = 2; // if you need 2 of them
// Input::SIMPLE_VERBOSITY = 1;
// Enable this is emulating the nominal pp/pA/AA collision vertex distribution
// Input::BEAM_CONFIGURATION = Input::AA_COLLISION; // Input::AA_COLLISION (default), Input::pA_COLLISION, Input::pp_COLLISION
// Input::PYTHIA6 = true;
// Input::PYTHIA8 = true;
// Input::GUN = true;
// Input::GUN_NUMBER = 3; // if you need 3 of them
// Input::GUN_VERBOSITY = 1;
// Input::COSMIC = true;
//D0 generator
//Input::DZERO = false;
//Input::DZERO_VERBOSITY = 0;
//Lambda_c generator //Not ready yet
//Input::LAMBDAC = false;
//Input::LAMBDAC_VERBOSITY = 0;
// Upsilon generator
//Input::UPSILON = true;
//Input::UPSILON_NUMBER = 3; // if you need 3 of them
//Input::UPSILON_VERBOSITY = 0;
// Input::HEPMC = true;
INPUTHEPMC::filename = inputFile;
//-----------------
// Hijing options (symmetrize hijing, add flow, add fermi motion)
//-----------------
// INPUTHEPMC::HIJINGFLIP = true;
// INPUTHEPMC::FLOW = true;
// INPUTHEPMC::FLOW_VERBOSITY = 3;
// INPUTHEPMC::FERMIMOTION = true;
// Event pile up simulation with collision rate in Hz MB collisions.
//Input::PILEUPRATE = 50e3; // 50 kHz for AuAu
//Input::PILEUPRATE = 3e6; // 3MHz for pp
// Enable this is emulating the nominal pp/pA/AA collision vertex distribution
// for HepMC records (hijing, pythia8)
// Input::BEAM_CONFIGURATION = Input::AA_COLLISION; // for 2023 sims we want theAA geometry for no pileup sims
// Input::BEAM_CONFIGURATION = Input::pp_COLLISION; // for 2024 sims we want thepp geometry for no pileup sims
// Input::BEAM_CONFIGURATION = Input::pA_COLLISION; // for pAu sims we want thepA geometry for no pileup sims
//-----------------
// Initialize the selected Input/Event generation
//-----------------
// This creates the input generator(s)
InputInit();
//--------------
// Set generator specific options
//--------------
// can only be set after InputInit() is called
// Simple Input generator:
// if you run more than one of these Input::SIMPLE_NUMBER > 1
// add the settings for other with [1], next with [2]...
if (Input::SIMPLE)
{
INPUTGENERATOR::SimpleEventGenerator[0]->add_particles(111, 1);
if (Input::HEPMC || Input::EMBED)
{
INPUTGENERATOR::SimpleEventGenerator[0]->set_reuse_existing_vertex(true);
INPUTGENERATOR::SimpleEventGenerator[0]->set_existing_vertex_offset_vector(0.0, 0.0, 0.0);
}
else
{
INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_function(PHG4SimpleEventGenerator::Gaus,
PHG4SimpleEventGenerator::Gaus,
PHG4SimpleEventGenerator::Gaus);
INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_mean(0., 0.,0.);
INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_width(0.01,0.01, 5.);
}
INPUTGENERATOR::SimpleEventGenerator[0]->set_eta_range(-0.9, 0.9);
INPUTGENERATOR::SimpleEventGenerator[0]->set_phi_range(-M_PI, M_PI);
INPUTGENERATOR::SimpleEventGenerator[0]->set_pt_range(10, 30.);
}
// Upsilons
// if you run more than one of these Input::UPSILON_NUMBER > 1
// add the settings for other with [1], next with [2]...
if (Input::UPSILON)
{
INPUTGENERATOR::VectorMesonGenerator[0]->add_decay_particles("e", 0);
INPUTGENERATOR::VectorMesonGenerator[0]->set_rapidity_range(-1, 1);
INPUTGENERATOR::VectorMesonGenerator[0]->set_pt_range(0., 10.);
// Y species - select only one, last one wins
INPUTGENERATOR::VectorMesonGenerator[0]->set_upsilon_1s();
if (Input::HEPMC || Input::EMBED)
{
INPUTGENERATOR::VectorMesonGenerator[0]->set_reuse_existing_vertex(true);
INPUTGENERATOR::VectorMesonGenerator[0]->set_existing_vertex_offset_vector(0.
0, 0.0, 0.0);
}
}
// particle gun
// if you run more than one of these Input::GUN_NUMBER > 1
// add the settings for other with [1], next with [2]...
if (Input::GUN)
{
INPUTGENERATOR::Gun[0]->AddParticle("pi-", 0, 1, 0);
INPUTGENERATOR::Gun[0]->set_vtx(0, 0, 0);
}
// pythia6
if (Input::PYTHIA6)
{
//! Nominal collision geometry is selected by Input::BEAM_CONFIGURATION
Input::ApplysPHENIXBeamParameter(INPUTGENERATOR::Pythia6);
}
// pythia8
if (Input::PYTHIA8)
{
//! Nominal collision geometry is selected by Input::BEAM_CONFIGURATION
Input::ApplysPHENIXBeamParameter(INPUTGENERATOR::Pythia8);
}
//--------------
// Set Input Manager specific options
//--------------
// can only be set after InputInit() is called
if (Input::HEPMC)
{
//! Nominal collision geometry is selected by Input::BEAM_CONFIGURATION
Input::ApplysPHENIXBeamParameter(INPUTMANAGER::HepMCInputManager);
// optional overriding beam parameters
//INPUTMANAGER::HepMCInputManager->set_vertex_distribution_width(100e-4, 100e-4
, 8, 0); //optional collision smear in space, time
// INPUTMANAGER::HepMCInputManager->set_vertex_distribution_mean(0,0,0,0);//
optional collision central position shift in space, time
// //optional choice of vertex distribution function in space, time
//INPUTMANAGER::HepMCInputManager->set_vertex_distribution_function(PHHepMCGenH
elper::Gaus, PHHepMCGenHelper::Gaus, PHHepMCGenHelper::Gaus, PHHepMCGenHelper::Gaus
);
//! embedding ID for the event
//! positive ID is the embedded event of interest, e.g. jetty event from pythia
//! negative IDs are backgrounds, .e.g out of time pile up collisions
//! Usually, ID = 0 means the primary Au+Au collision background
//INPUTMANAGER::HepMCInputManager->set_embedding_id(Input::EmbedID);
if (Input::PILEUPRATE > 0)
{
// Copy vertex settings from foreground hepmc input
INPUTMANAGER::HepMCPileupInputManager->CopyHelperSettings(INPUTMANAGER::HepMC
InputManager);
// and then modify the ones you want to be different
// INPUTMANAGER::HepMCPileupInputManager->set_vertex_distribution_width(100e-
4,100e-4,8,0);
}
}
if (Input::PILEUPRATE > 0)
{
//! Nominal collision geometry is selected by Input::BEAM_CONFIGURATION
Input::ApplysPHENIXBeamParameter(INPUTMANAGER::HepMCPileupInputManager);
}
// register all input generators with Fun4All
InputRegister();
if (! Input::READHITS)
{
rc->set_IntFlag("RUNNUMBER",1);
SyncReco *sync = new SyncReco();
se->registerSubsystem(sync);
HeadReco *head = new HeadReco();
se->registerSubsystem(head);
}
// Flag Handler is always needed to read flags from input (if used)
// and update our rc flags with them. At the end it saves all flags
// again on the DST in the Flags node under the RUN node
FlagHandler *flag = new FlagHandler();
se->registerSubsystem(flag);
// set up production relatedstuff
// Enable::PRODUCTION = true;
//======================
// Write the DST
//======================
//Enable::DSTOUT = true;
Enable::DSTOUT_COMPRESS = false;
DstOut::OutputDir = outdir;
DstOut::OutputFile = outputFile;
//Option to convert DST to human command readable TTree for quick poke around the
outputs
// Enable::DSTREADER = true;
// turn the display on (default off)
//Enable::DISPLAY = true;
//======================
// What to run
//======================
// QA, main switch
Enable::QA = false;
// Global options (enabled for all enables subsystems - if implemented)
// Enable::ABSORBER = true;
// Enable::OVERLAPCHECK = true;
// Enable::VERBOSITY = 1;
// Enable::MBD = true;
// Enable::MBD_SUPPORT = true; // save hist in MBD/BBC support structure
// Enable::MBDRECO = Enable::MBD && true;
Enable::MBDFAKE = true; // Smeared vtx and t0, use if you don't want real MBD/BB
C in simulation
Enable::PIPE = true;
Enable::PIPE_ABSORBER = false;
// central tracking
Enable::MVTX = true;
Enable::MVTX_CELL = Enable::MVTX && false;
Enable::MVTX_CLUSTER = Enable::MVTX_CELL && true;
Enable::MVTX_QA = Enable::MVTX_CLUSTER && Enable::QA && true;
Enable::INTT = true;
// Enable::INTT_ABSORBER = true; // enables layerwise support structure readout
// Enable::INTT_SUPPORT = true; // enable global support structure readout
Enable::INTT_CELL = Enable::INTT && false;
Enable::INTT_CLUSTER = Enable::INTT_CELL && true;
Enable::INTT_QA = Enable::INTT_CLUSTER && Enable::QA && true;
Enable::TPC = true;
Enable::TPC_ABSORBER = false;
Enable::TPC_CELL = Enable::TPC && false;
Enable::TPC_CLUSTER = Enable::TPC_CELL && true;
Enable::TPC_QA = Enable::TPC_CLUSTER && Enable::QA && true;
Enable::MICROMEGAS = true;
// Enable::MICROMEGAS_CELL = Enable::MICROMEGAS && true;
Enable::MICROMEGAS_CLUSTER = Enable::MICROMEGAS_CELL && true;
Enable::MICROMEGAS_QA = Enable::MICROMEGAS_CLUSTER && Enable::QA && true;
//Enable::TRACKING_TRACK = (Enable::MICROMEGAS_CLUSTER && Enable::TPC_CLUSTER &&
Enable::INTT_CLUSTER && Enable::MVTX_CLUSTER) && true;
Enable::GLOBAL_RECO = (Enable::MBDFAKE || Enable::MBDRECO || Enable::TRACKING_TRA
CK) && true;
Enable::TRACKING_EVAL = Enable::TRACKING_TRACK && Enable::GLOBAL_RECO && true;
Enable::TRACKING_QA = Enable::TRACKING_TRACK && Enable::QA && true;
// only do track matching if TRACKINGTRACK is also used
Enable::TRACK_MATCHING = Enable::TRACKING_TRACK && false;
Enable::TRACK_MATCHING_TREE = Enable::TRACK_MATCHING && false;
Enable::TRACK_MATCHING_TREE_CLUSTERS = Enable::TRACK_MATCHING_TREE && false;
//Additional tracking tools
//Enable::TRACKING_DIAGNOSTICS = Enable::TRACKING_TRACK && true;
//G4TRACKING::filter_conversion_electrons = true;
// cemc electronics + thin layer of W-epoxy to get albedo from cemc
// into the tracking, cannot run together with CEMC
// Enable::CEMCALBEDO = true;
Enable::CEMC = true;
//Enable::CEMC_ABSORBER = true;
Enable::CEMC_CELL = Enable::CEMC && true;
Enable::CEMC_TOWER = Enable::CEMC_CELL && true;
//Enable::CEMC_CLUSTER = Enable::CEMC_TOWER && true;
//Enable::CEMC_EVAL = Enable::CEMC_G4Hit && Enable::CEMC_CLUSTER && true;
Enable::CEMC_QA = Enable::CEMC_CLUSTER && Enable::QA && true;
//Enable::HCALIN = true;
//Enable::HCALIN_ABSORBER = true;
Enable::HCALIN_CELL = Enable::HCALIN && true;
Enable::HCALIN_TOWER = Enable::HCALIN_CELL && true;
Enable::HCALIN_CLUSTER = Enable::HCALIN_TOWER && true;
//Enable::HCALIN_EVAL = Enable::HCALIN_G4Hit && Enable::HCALIN_CLUSTER && true;
Enable::HCALIN_QA = Enable::HCALIN_CLUSTER && Enable::QA && true;
//Enable::MAGNET = true;
//Enable::MAGNET_ABSORBER = true;
//Enable::HCALOUT = true;
//Enable::HCALOUT_ABSORBER = true;
Enable::HCALOUT_CELL = Enable::HCALOUT && true;
Enable::HCALOUT_TOWER = Enable::HCALOUT_CELL && true;
Enable::HCALOUT_CLUSTER = Enable::HCALOUT_TOWER && true;
//Enable::HCALOUT_EVAL = Enable::HCALOUT_G4Hit && Enable::HCALOUT_CLUSTER && true
;
Enable::HCALOUT_QA = Enable::HCALOUT_CLUSTER && Enable::QA && true;
Enable::EPD = true;
//Enable::EPD_TILE = Enable::EPD && true;
//Enable::BEAMLINE = true;
// Enable::BEAMLINE_ABSORBER = true; // makes the beam line magnets sensitive vol
umes
// Enable::BEAMLINE_BLACKHOLE = true; // turns the beamline magnets into black hol
es
//Enable::ZDC = true;
// Enable::ZDC_ABSORBER = true;
// Enable::ZDC_SUPPORT = true;
Enable::ZDC_TOWER = Enable::ZDC && true;
Enable::ZDC_EVAL = Enable::ZDC_TOWER && true;
//! forward flux return plug door. Out of acceptance and off by default.
Enable::PLUGDOOR = true;
Enable::PLUGDOOR_ABSORBER = true;
//Enable::GLOBAL_FASTSIM = true;
//Enable::KFPARTICLE = true;
//Enable::KFPARTICLE_VERBOSITY = 1;
//Enable::KFPARTICLE_TRUTH_MATCH = true;
//Enable::KFPARTICLE_SAVE_NTUPLE = true;
Enable::CALOTRIGGER = Enable::CEMC_TOWER && Enable::HCALIN_TOWER && Enable::HCALO
UT_TOWER && false;
//Enable::JETS = (Enable::GLOBAL_RECO || Enable::GLOBAL_FASTSIM) && true;
Enable::JETS_EVAL = Enable::JETS && true;
Enable::JETS_QA = Enable::JETS && Enable::QA && true;
// HI Jet Reco for p+Au / Au+Au collisions (default is false for
// single particle / p+p-only simulations, or for p+Au / Au+Au
// simulations which don't particularly care about jets)
Enable::HIJETS = Enable::JETS && Enable::CEMC_TOWER && Enable::HCALIN_TOWER && En
able::HCALOUT_TOWER && false;
// 3-D topoCluster reconstruction, potentially in all calorimeter layers
Enable::TOPOCLUSTER = Enable::CEMC_TOWER && Enable::HCALIN_TOWER && Enable::HCALO
UT_TOWER && false;
// particle flow jet reconstruction - needs topoClusters!
Enable::PARTICLEFLOW = Enable::TOPOCLUSTER && true;
// centrality reconstruction
Enable::CENTRALITY = true;
// new settings using Enable namespace in GlobalVariables.C
Enable::BLACKHOLE = true;
//Enable::BLACKHOLE_SAVEHITS = false; // turn off saving of bh hits
//Enable::BLACKHOLE_FORWARD_SAVEHITS = false; // disable forward/backward hits
//BlackHoleGeometry::visible = true;
// run user provided code (from local G4_User.C)
//Enable::USER = true;
//===============
// conditions DB flags
//===============
Enable::CDB = true;
// global tag
rc->set_StringFlag("CDB_GLOBALTAG",CDB::global_tag);
// 64 bit timestamp
rc->set_uint64Flag("TIMESTAMP",6);
CDBInterface::instance()->Verbosity(1);
//---------------
// World Settings
//---------------
// G4WORLD::PhysicsList = "FTFP_BERT"; //FTFP_BERT_HP best for calo
// G4WORLD::WorldMaterial = "G4_AIR"; // set to G4_GALACTIC for material scans
//---------------
// Magnet Settings
//---------------
// G4MAGNET::magfield = string(getenv("CALIBRATIONROOT"))+ string("/Field/Map/s
phenix3dbigmapxyz.root"); // default map from the calibration database
// G4MAGNET::magfield = "1.5"; // alternatively to specify a constant magnetic f
ield, give a float number, which will be translated to solenoidal field in T, if st
ring use as fieldmap name (including path)
// G4MAGNET::magfield_rescale = 1.; // make consistent with expected Babar field
strength of 1.4T
//---------------
// Pythia Decayer
//---------------
// list of decay types in
// $OFFLINE_MAIN/include/g4decayer/EDecayType.hh
// default is All:
// G4P6DECAYER::decayType = EDecayType::kAll;
// Initialize the selected subsystems
G4Init();
//---------------------
// GEANT4 Detector description
//---------------------
if (!Input::READHITS)
{
G4Setup();
}
//------------------
// Detector Division
//------------------
if ((Enable::MBD && Enable::MBDRECO) || Enable::MBDFAKE) Mbd_Reco();
if (Enable::MVTX_CELL) Mvtx_Cells();
if (Enable::INTT_CELL) Intt_Cells();
if (Enable::TPC_CELL) TPC_Cells();
if (Enable::MICROMEGAS_CELL) Micromegas_Cells();
if (Enable::CEMC_CELL) CEMC_Cells();
if (Enable::HCALIN_CELL) HCALInner_Cells();
if (Enable::HCALOUT_CELL) HCALOuter_Cells();
//-----------------------------
// CEMC towering and clustering
//-----------------------------
if (Enable::CEMC_TOWER) CEMC_Towers();
if (Enable::CEMC_CLUSTER) CEMC_Clusters();
CaloWaveformSim* caloWaveformSim = new CaloWaveformSim();
caloWaveformSim->set_detector_type(CaloTowerDefs::CEMC);
caloWaveformSim->set_detector("CEMC");
caloWaveformSim->set_nsamples(12);
caloWaveformSim->set_pedestalsamples(12);
caloWaveformSim->set_timewidth(0.2);
caloWaveformSim->set_peakpos(6);
caloWaveformSim->set_calibName("cemc_pi0_twrSlope_v1_default");
//caloWaveformSim->set_noise_type(CaloWaveformSim::NOISE_NONE);
caloWaveformSim->get_light_collection_model().load_data_file(
string(getenv("CALIBRATIONROOT")) +
string("/CEMC/LightCollection/Prototype3Module.xml"),
"data_grid_light_guide_efficiency", "data_grid_fiber_trans");
caloWaveformSim->Verbosity(2);
se->registerSubsystem(caloWaveformSim);
CaloTowerBuilder* ca2 = new CaloTowerBuilder();
ca2->set_detector_type(CaloTowerDefs::CEMC);
ca2->set_nsamples(12);
ca2->set_dataflag(false);
ca2->set_processing_type(CaloWaveformProcessing::TEMPLATE);
ca2->set_builder_type(CaloTowerDefs::kWaveformTowerv2);
//match our current ZS threshold ~14ADC for emcal
ca2->set_softwarezerosuppression(true, 14);
se->registerSubsystem(ca2);
CaloTowerStatus *statusEMC = new CaloTowerStatus("CEMCSTATUS");
statusEMC->set_detector_type(CaloTowerDefs::CEMC);
statusEMC->set_time_cut(1);
se->registerSubsystem(statusEMC);
std::cout << "Calibrating EMCal" << std::endl;
CaloTowerCalib *calibEMC = new CaloTowerCalib("CEMCCALIB");
calibEMC->set_detector_type(CaloTowerDefs::CEMC);
calibEMC->set_outputNodePrefix("TOWERINFO_CALIB_");
se->registerSubsystem(calibEMC);
std::cout << "Building clusters" << std::endl;
RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("EmcRaw
ClusterBuilderTemplate");
ClusterBuilder->Detector("CEMC");
ClusterBuilder->set_threshold_energy(0.030); // for when using basic calibration
std::string emc_prof = getenv("CALIBRATIONROOT");
emc_prof += "/EmcProfile/CEMCprof_Thresh30MeV.root";
ClusterBuilder->LoadProfile(emc_prof);
ClusterBuilder->set_UseTowerInfo(1); // to use towerinfo objects rather than old
RawTower
se->registerSubsystem(ClusterBuilder);
//--------------
// EPD tile reconstruction
//--------------
if (Enable::EPD_TILE) EPD_Tiles();
//-----------------------------
// HCAL towering and clustering
//-----------------------------
if (Enable::HCALIN_TOWER) HCALInner_Towers();
if (Enable::HCALIN_CLUSTER) HCALInner_Clusters();
if (Enable::HCALOUT_TOWER) HCALOuter_Towers();
if (Enable::HCALOUT_CLUSTER) HCALOuter_Clusters();
// if enabled, do topoClustering early, upstream of any possible jet reconstructi
on
if (Enable::TOPOCLUSTER) TopoClusterReco();
//--------------
// SVTX tracking
//--------------
if(Enable::TRACKING_TRACK)
{
TrackingInit();
}
if (Enable::MVTX_CLUSTER) Mvtx_Clustering();
if (Enable::INTT_CLUSTER) Intt_Clustering();
if (Enable::TPC_CLUSTER)
{
if(G4TPC::ENABLE_DIRECT_LASER_HITS || G4TPC::ENABLE_CENTRAL_MEMBRANE_HITS)
{
TPC_LaserClustering();
}
else
{
TPC_Clustering();
}
}
if (Enable::MICROMEGAS_CLUSTER) Micromegas_Clustering();
if (Enable::TRACKING_TRACK)
{
Tracking_Reco();
}
if(Enable::TRACKING_DIAGNOSTICS)
{
const std::string kshortFile = "./kshort_" + outputFile;
const std::string residualsFile = "./residuals_" + outputFile;
G4KshortReconstruction(kshortFile);
seedResiduals(residualsFile);
}
//-----------------
// Global Vertexing
//-----------------
if (Enable::GLOBAL_RECO && Enable::GLOBAL_FASTSIM)
{
cout << "You can only enable Enable::GLOBAL_RECO or Enable::GLOBAL_FASTSIM, not
both" << endl;
gSystem->Exit(1);
}
if (Enable::GLOBAL_RECO)
{
Global_Reco();
}
else if (Enable::GLOBAL_FASTSIM)
{
Global_FastSim();
}
//-----------------
// Centrality Determination
//-----------------
if (Enable::CENTRALITY)
{
Centrality();
}
//-----------------
// Calo Trigger Simulation
//-----------------
if (Enable::CALOTRIGGER)
{
CaloTrigger_Sim();
}
//---------
// Jet reco
//---------
if (Enable::JETS) Jet_Reco();
if (Enable::HIJETS) HIJetReco();
if (Enable::PARTICLEFLOW) ParticleFlow();
//----------------------
// Simulation evaluation
//----------------------
string outputroot = outputFile;
string remove_this = ".root";
size_t pos = outputroot.find(remove_this);
if (pos != string::npos)
{
outputroot.erase(pos, remove_this.length());
}
if (Enable::TRACKING_EVAL) Tracking_Eval(outputroot + "_g4svtx_eval.root");
if (Enable::CEMC_EVAL) CEMC_Eval(outputroot + "_g4cemc_eval.root");
if (Enable::HCALIN_EVAL) HCALInner_Eval(outputroot + "_g4hcalin_eval.root");
if (Enable::HCALOUT_EVAL) HCALOuter_Eval(outputroot + "_g4hcalout_eval.root");
if (Enable::JETS_EVAL) Jet_Eval(outputroot + "_g4jet_eval.root");
if (Enable::DSTREADER) G4DSTreader(outputroot + "_DSTReader.root");
if (Enable::USER) UserAnalysisInit();
// Writes electrons from conversions to a new track map on the node tree
// the ntuple file is for diagnostics, it is produced only if the flag is set in
G4_Tracking.C
if(G4TRACKING::filter_conversion_electrons) Filter_Conversion_Electrons(outputroo
t + "_secvert_ntuple.root");
//======================
// Run KFParticle on evt
//======================
if (Enable::KFPARTICLE && Input::UPSILON) KFParticle_Upsilon_Reco();
if (Enable::KFPARTICLE && Input::DZERO) KFParticle_D0_Reco();
CaloAna24 *caloana24 = new CaloAna24();
se->registerSubsystem(caloana24);
//----------------------
// Standard QAs
//----------------------
if (Enable::CEMC_QA) CEMC_QA();
if (Enable::HCALIN_QA) HCALInner_QA();
if (Enable::HCALOUT_QA) HCALOuter_QA();
if (Enable::JETS_QA) Jet_QA();
if (Enable::MVTX_QA) Mvtx_QA();
if (Enable::INTT_QA) Intt_QA();
if (Enable::TPC_QA) TPC_QA();
if (Enable::MICROMEGAS_QA) Micromegas_QA();
if (Enable::TRACKING_QA) Tracking_QA();
if (Enable::TRACKING_QA && Enable::CEMC_QA && Enable::HCALIN_QA && Enable::HCALOU
T_QA) QA_G4CaloTracking();
if (Enable::TRACK_MATCHING) Track_Matching(outputroot + "_g4trackmatching.root");
//--------------
// Set up Input Managers
//--------------
InputManagers();
Fun4AllInputManager *hitsin = new Fun4AllNoSyncDstInputManager("DST2");
hitsin->AddFile("pedestal-00046796.root");
hitsin->Repeat();
se->registerInputManager(hitsin);
if (Enable::PRODUCTION)
{
Production_CreateOutputDir();
}
if (Enable::DSTOUT)
{
string FullOutFile = DstOut::OutputDir + "/" + DstOut::OutputFile;
Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", FullOutFil
e);
if (Enable::DSTOUT_COMPRESS)
{
ShowerCompress();
DstCompress(out);
}
se->registerOutputManager(out);
}
//-----------------
// Event processing
//-----------------
if (Enable::DISPLAY)
{
DisplayOn();
gROOT->ProcessLine("Fun4AllServer *se = Fun4AllServer::instance();");
gROOT->ProcessLine("PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco(\"PHG4RECO\")
;");
cout << "-------------------------------------------------" << endl;
cout << "You are in event display mode. Run one event with" << endl;
cout << "se->run(1)" << endl;
cout << "Run Geant4 command with following examples" << endl;
gROOT->ProcessLine("displaycmd()");
return 0;
}
// if we use a negative number of events we go back to the command line here
if (nEvents < 0)
{
return 0;
}
// if we run the particle generator and use 0 it'll run forever
// for embedding it runs forever if the repeat flag is set
if (nEvents == 0 && !Input::HEPMC && !Input::READHITS && INPUTEMBED::REPEAT)
{
cout << "using 0 for number of events is a bad idea when using particle generat
ors" << endl;
cout << "it will run forever, so I just return without running anything" << end
l;
return 0;
}
se->skip(skip);
se->run(nEvents);
//-----
// QA output
//-----
if (Enable::QA) QA_Output(outputroot + "_qa.root");
//-----
// Exit
//-----
// CDBInterface::instance()->Print(); // print used DB files
se->End();
std::cout << "All done" << std::endl;
delete se;
if (Enable::PRODUCTION)
{
Production_MoveOutput();
}
gSystem->Exit(0);
return 0;
}
#endif