Skip to content

Commit

Permalink
Brought in latest updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cdean-github committed Apr 4, 2022
2 parents 7bf46da + 56c8259 commit 0dd649a
Show file tree
Hide file tree
Showing 8 changed files with 1,210 additions and 628 deletions.
155 changes: 155 additions & 0 deletions common/G4_B0Tracking_EIC.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
#ifndef MACRO_G4B0TRACKINGEIC_C
#define MACRO_G4B0TRACKINGEIC_C

#include <GlobalVariables.C>

#include <trackreco/PHRaveVertexing.h>

#include <eicg4b0/B0TrackFastSimEval.h>
#include <eicg4b0/B0TrackFastSim.h>

#include <fun4all/Fun4AllServer.h>

#include <vector>

R__LOAD_LIBRARY(libtrack_reco.so)
R__LOAD_LIBRARY(libEICG4B0.so)//

namespace Enable
{
bool B0TRACKING = false;
bool B0TRACKING_EVAL = false;
int B0TRACKING_VERBOSITY = 0;
} // namespace Enable

namespace G4B0TRACKING
{
bool DISPLACED_VERTEX = false;
bool PROJECTION_B0 = false;
const double PositionResolution(30e-4);
} // namespace G4TRACKING

//-----------------------------------------------------------------------------//
void B0TrackingInit()
{
B0TRACKING::FastKalmanFilter = new B0TrackFastSim("B0TrackFastSim");
B0TRACKING::FastKalmanFilterB0Track = new B0TrackFastSim("FastKalmanFilterB0Track"); //b0Truth
}

void InitFastKalmanFilter(B0TrackFastSim *kalman_filter)
{
// kalman_filter->Smearing(false);
if (G4B0TRACKING::DISPLACED_VERTEX)
{
// do not use truth vertex in the track fitting,
// which would lead to worse momentum resolution for prompt tracks
// but this allows displaced track analysis including DCA and vertex finding
kalman_filter->set_use_vertex_in_fitting(false);
kalman_filter->set_vertex_xy_resolution(0); // do not smear the vertex used in the built-in DCA calculation
kalman_filter->set_vertex_z_resolution(0); // do not smear the vertex used in the built-in DCA calculation
kalman_filter->enable_vertexing(true); // enable vertex finding and fitting
}
else
{
// constraint to a primary vertex and use it as part of the fitting level arm
kalman_filter->set_use_vertex_in_fitting(true);
kalman_filter->set_vertex_xy_resolution(G4B0TRACKING::PositionResolution);
kalman_filter->set_vertex_z_resolution(G4B0TRACKING::PositionResolution);
}

kalman_filter->set_sub_top_node_name("TRACKS");
}

//-----------------------------------------------------------------------------//
void B0Tracking_Reco()
{
int verbosity = std::max(Enable::VERBOSITY, Enable::B0TRACKING_VERBOSITY);
//---------------
// Fun4All server
//---------------

Fun4AllServer *se = Fun4AllServer::instance();

if (B0TRACKING::FastKalmanFilter == nullptr)
{
cout << __PRETTY_FUNCTION__ << " : missing the expected initialization for B0TRACKING::FastKalmanFilter." << endl;
exit(1);
}

InitFastKalmanFilter(B0TRACKING::FastKalmanFilter);
B0TRACKING::FastKalmanFilter->Verbosity(verbosity);
B0TRACKING::FastKalmanFilter->set_trackmap_out_name(B0TRACKING::TrackNodeName);

//-------------------------
// B0
//-------------------------
if (Enable::B0TRACKING && G4B0TRACKING::PROJECTION_B0)
{
// TRACKING::FastKalmanFilter->add_state_name("b0Truth");
// TRACKING::ProjectionNames.insert("b0Truth");
}

se->registerSubsystem(B0TRACKING::FastKalmanFilter);

// next, tracks with partial usage of the tracker stack
if (B0TRACKING::FastKalmanFilterB0Track == nullptr)
{
cout << __PRETTY_FUNCTION__ << " : missing the expected initialization for TRACKING::FastKalmanFilterB0Track." << endl;
exit(1);
}
InitFastKalmanFilter(B0TRACKING::FastKalmanFilterB0Track);
B0TRACKING::FastKalmanFilterB0Track->Verbosity(verbosity);
B0TRACKING::FastKalmanFilterB0Track->set_trackmap_out_name("B0TrackMap");
B0TRACKING::FastKalmanFilterB0Track->enable_vertexing(false);
se->registerSubsystem(B0TRACKING::FastKalmanFilterB0Track);
return;
}

//-----------------------------------------------------------------------------//

void B0Tracking_Eval(const std::string &outputfile)
{
int verbosity = std::max(Enable::VERBOSITY, Enable::B0TRACKING_VERBOSITY);
//---------------
// Fun4All server
//---------------

Fun4AllServer *se = Fun4AllServer::instance();

//----------------
// Fast Tracking evaluation
//----------------

B0TrackFastSimEval *b0_fast_sim_eval = new B0TrackFastSimEval("B0FastTrackingEval");
b0_fast_sim_eval->set_trackmapname(B0TRACKING::TrackNodeName);
b0_fast_sim_eval->set_filename(outputfile);
b0_fast_sim_eval->Verbosity(verbosity);
//-------------------------
// FEMC
//-------------------------

cout << "Tracking_Eval(): configuration of track projections in B0TrackFastSimEval" << endl;
cout << "std::set<std::string> B0TRACKING::ProjectionNames = {";
bool first = true;
for (const string &proj : B0TRACKING::B0ProjectionNames)
{
if (first)
first = false;
else
cout << ", ";
cout << "\"" << proj << "\"";

b0_fast_sim_eval->AddProjection(proj);
}
cout << "};" << endl; // override the TRACKING::ProjectionNames in eval macros

se->registerSubsystem(b0_fast_sim_eval);
// now partial track fits
//B0TrackFastSimEval *b0_fast_sim_eval = new B0TrackFastSimEval("FastTrackingEval_B0TrackMap");
b0_fast_sim_eval = new B0TrackFastSimEval("FastTrackingEval_B0TrackMap");
b0_fast_sim_eval->set_trackmapname("B0TrackMap");
b0_fast_sim_eval->set_filename(outputfile + ".B0TrackMap_debug.root");
b0_fast_sim_eval->Verbosity(verbosity);
se->registerSubsystem(b0_fast_sim_eval);
}
#endif
150 changes: 150 additions & 0 deletions common/G4_BWD.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#ifndef MACRO_G4BWD_C
#define MACRO_G4BWD_C

#include <GlobalVariables.C>

//include our own Bwd Raw Tower Builder
#include <eicg4bwd/BwdRawTowerBuilderByHitIndex.h>

#include <g4calo/RawTowerDigitizer.h>

#include <g4eiccalos/PHG4ForwardCalCellReco.h>
// Use Forward Cal Cell Reco .

#include <eicg4bwd/EICG4BwdSubsystem.h>
// Include our Subsystem

//Standard RawTowerDefs.h is modified

#include <g4eval/CaloEvaluator.h>

#include <g4main/PHG4Reco.h>

#include <eiccaloreco/RawClusterBuilderkMA.h>
#include <eiccaloreco/RawClusterBuilderHelper.h>

#include <caloreco/RawClusterBuilderFwd.h>
#include <caloreco/RawClusterBuilderTemplate.h>
#include <caloreco/RawTowerCalibration.h>

#include <fun4all/Fun4AllServer.h>

R__LOAD_LIBRARY(libcalo_reco.so)
R__LOAD_LIBRARY(libg4calo.so)
R__LOAD_LIBRARY(libg4eiccalos.so)
R__LOAD_LIBRARY(libg4eval.so)

namespace Enable
{
bool BWD = false;
bool BWDN[5]={true,false,false,false,false};
bool BWD_ABSORBER = false;
bool BWD_CELL = false;
bool BWD_TOWER = false;
bool BWD_CLUSTER = false;
bool BWD_EVAL = false;
bool BWD_OVERLAPCHECK = false;
int BWD_VERBOSITY = 0;
} // namespace Enable


namespace G4BWD
{

string mapname[5]={"BWD_mapping_v1.txt","BWD_mapping_v2.txt","BWD_mapping_v3.txt","BWD_mapping_v4.txt","BWD_mapping_v5.txt"};
double minz = -5000;
double maxz = -300;
double radius = 100;

// Default set to B0 Ecal position at IP6

// Digitization (default photon digi):
RawTowerDigitizer::enu_digi_algorithm TowerDigi = RawTowerDigitizer::kNo_digitization;
// directly pass the energy of sim tower to digitized tower
// kNo_digitization
// simple digitization with photon statistics, single amplitude ADC conversion and pedestal
// kSimple_photon_digitization
// digitization with photon statistics on SiPM with an effective pixel N, ADC conversion and pedestal
// kSiPM_photon_digitization

} // namespace G4B0ECAL

void BWDInit()
{
}

void BWDSetup(PHG4Reco *g4Reco)
{
//Done in G4_hFarBwdBeamLine.C
}

void BWD_Cells(int verbosity = 0)
{
return;
}

void BWD_Towers()
{
int verbosity = std::max(Enable::VERBOSITY, Enable::BWD_VERBOSITY);


for (int i = 0; i < 5; i++){
if (!Enable::BWDN[i])continue;
Fun4AllServer *se = Fun4AllServer::instance();
ostringstream mapping_bwd;
mapping_bwd << getenv("CALIBRATIONROOT") << "/BWD/mapping/"<<G4BWD::mapname[i];
//mapping_bwd << G4BWD::mapname[i];
BwdRawTowerBuilderByHitIndex *tower_BWD = new BwdRawTowerBuilderByHitIndex(Form("TowerBuilder_BWD_%d", i));
tower_BWD->Detector(Form("BWD_%d", i));
tower_BWD->set_sim_tower_node_prefix("SIM");
tower_BWD->GeometryTableFile(mapping_bwd.str());

se->registerSubsystem(tower_BWD);


RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer(Form("BWDRawTowerDigitizer_%d",i));
TowerDigitizer->Detector(Form("BWD_%d", i));
TowerDigitizer->Verbosity(verbosity);
TowerDigitizer->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
se->registerSubsystem(TowerDigitizer);

RawTowerCalibration *TowerCalibration = new RawTowerCalibration(Form("BWDRawTowerCalibration_%d",i));
TowerCalibration->Detector(Form("BWD_%d", i));
TowerCalibration->Verbosity(verbosity);
TowerCalibration->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
TowerCalibration->set_calib_const_GeV_ADC(1. );
TowerCalibration->set_pedstal_ADC(0);
se->registerSubsystem(TowerCalibration);
}
}

void BWD_Clusters()
{
int verbosity = std::max(Enable::VERBOSITY, Enable::BWD_VERBOSITY);

for (int i = 0; i < 5; i++){
if (!Enable::BWDN[i])continue;
Fun4AllServer *se = Fun4AllServer::instance();
RawClusterBuilderFwd *ClusterBuilder = new RawClusterBuilderFwd(Form("BWDRawClusterBuilderFwd_%d",i));
ClusterBuilder->Detector(Form("BWD_%d", i));
ClusterBuilder->Verbosity(verbosity);
ClusterBuilder->set_threshold_energy(0.100);
se->registerSubsystem(ClusterBuilder);
}
return;
}

void BWD_Eval(const std::string &outputfile)
{
int verbosity = std::max(Enable::VERBOSITY, Enable::BWD_VERBOSITY);
string filename=outputfile.c_str();
for (int i = 0; i < 5; i++){
if (!Enable::BWDN[i])continue;
Fun4AllServer *se = Fun4AllServer::instance();
CaloEvaluator *eval = new CaloEvaluator(Form("BWDEVALUATOR_%d",i), Form("BWD_%d", i), (filename+Form("_%d.root",i)) );
eval->Verbosity(verbosity);
se->registerSubsystem(eval);
}
return;
}
#endif
Loading

0 comments on commit 0dd649a

Please sign in to comment.