Пример #1
0
void Svtx_Cells(int verbosity = 0)
{
  // runs the cellularization of the energy deposits (g4hits) 
  // into detector hits (g4cells)

  //---------------
  // Load libraries
  //---------------

  gSystem->Load("libfun4all.so");
  gSystem->Load("libg4detectors.so");

  //---------------
  // Fun4All server
  //---------------

  Fun4AllServer *se = Fun4AllServer::instance();

  //-----------
  // SVTX cells
  //-----------

  // The pattern recognition layers (4 & 6) are set at 2 mm in Z and 240 microns 
  // pitch to make the area the same as the long strips
  // Layers 3, 5 and 7 are long strips parallel to the beam line

  // 60 micron X strips, 240 micron pattern reco strips
  double svxcellsizex[2] = {0.0050, 0.0050};

  // 8 mm tracking strips, 2 mm pattern reco strips
  double svxcellsizey[2] = {0.0425, 0.0425};
  
  PHG4CylinderCellReco *svtx_cells = new PHG4CylinderCellReco();
  svtx_cells->Detector("SVTX");
  svtx_cells->Verbosity(verbosity);
  int idx = 0;
  for (int i = Min_si_layer; i < 2; ++i) {
    svtx_cells->cellsize(i, svxcellsizex[idx], svxcellsizey[idx]);
    ++idx;
  }
  se->registerSubsystem(svtx_cells);
  
  PHG4SiliconTrackerCellReco *reco = new PHG4SiliconTrackerCellReco("SILICON_TRACKER");
  reco->Verbosity(verbosity);
  se->registerSubsystem(reco);

  return;
}
void Svtx_Cells(int verbosity = 0)
{
  // runs the cellularization of the energy deposits (g4hits)
  // into detector hits (g4cells)

  //---------------
  // Load libraries
  //---------------

  gSystem->Load("libfun4all.so");
  gSystem->Load("libg4detectors.so");

  //---------------
  // Fun4All server
  //---------------

  Fun4AllServer* se = Fun4AllServer::instance();

  //-----------
  // SVTX cells
  //-----------

  if (verbosity)
  {
    cout << "  TPC Drift Velocity: " << TPCDriftVelocity << " cm/nsec" << endl;
    cout << "  TPC Transverse Diffusion: " << TPC_Trans_Diffusion << " cm/SQRT(cm)" << endl;
    cout << "  TPC Longitudinal Diffusion: " << TPC_Long_Diffusion << " cm/SQRT(cm)" << endl;
    cout << "  TPC dE/dx: " << TPC_dEdx << " keV/cm" << endl;
    cout << "  TPC N Primary: " << TPC_NPri << " electrons/cm" << endl;
    cout << "  TPC N Total: " << TPC_NTot << " electrons/cm" << endl;
    cout << "  TPC Electrons Per keV: " << TPC_ElectronsPerKeV << " electrons/keV" << endl;
    cout << "  TPC ADC Clock: " << TPCADCClock << " nsec" << endl;
    cout << "  TPC ADC Rate: " << 1000.0 / TPCADCClock << " MHZ" << endl;
    cout << "  TPC Shaping Lead: " << TPCShapingRMSLead << " nsec" << endl;
    cout << "  TPC Shaping Tail: " << TPCShapingRMSTail << " nsec" << endl;
    cout << "  TPC z cell " << tpc_cell_z << " cm" << endl;
    cout << "  TPC Smear R-Phi " << TPC_SmearRPhi << " cm" << endl;
    cout << "  TPC Smear Z " << TPC_SmearZ << " cm" << endl;
  }

  if (n_maps_layer > 0)
  {
    // MAPS cells
    PHG4MapsCellReco* maps_cells = new PHG4MapsCellReco("MAPS");
    maps_cells->Verbosity(verbosity);
    for (int ilayer = 0; ilayer < n_maps_layer; ilayer++)
    {
      maps_cells->set_timing_window(ilayer, -5000, 5000);
    }
    se->registerSubsystem(maps_cells);
  }

  if (n_intt_layer > 0)
  {
    // INTT cells
    PHG4SiliconTrackerCellReco* reco = new PHG4SiliconTrackerCellReco("SILICON_TRACKER");
    // The timing windows are hard-coded in the INTT ladder model
    reco->Verbosity(verbosity);
    reco->checkenergy(1);
    se->registerSubsystem(reco);
  }

  // Main switch for TPC distortion
  const bool do_tpc_distortion = true;
  PHG4TPCSpaceChargeDistortion* tpc_distortion = NULL;
  if (do_tpc_distortion)
  {
    if (inner_cage_radius != 20. && inner_cage_radius != 30.)
    {
      cout << "Svtx_Cells - Fatal Error - TPC distortion required that "
              "inner_cage_radius is either 20 or 30 cm."
           << endl;
      exit(3);
    }

    string TPC_distortion_file =
        string(getenv("CALIBRATIONROOT")) +
        Form("/Tracking/TPC/SpaceChargeDistortion/TPCCAGE_20_78_211_2.root");
    tpc_distortion =
        new PHG4TPCSpaceChargeDistortion(TPC_distortion_file);
    //tpc_distortion -> setAccuracy(0); // option to over write default  factors
    //tpc_distortion -> setPrecision(0.001); // option to over write default  factors      // default is 0.001
  }

  PHG4CylinderCellTPCReco* svtx_cells = new PHG4CylinderCellTPCReco(n_maps_layer + n_intt_layer);
  svtx_cells->Detector("SVTX");
  svtx_cells->setDistortion(tpc_distortion);
  //svtx_cells->setZigzags(true);  // set zigzag pads option on if true, use rectangular pads if false  (not required, defaults to true in code).
  svtx_cells->setDiffusionT(TPC_Trans_Diffusion);
  svtx_cells->setDiffusionL(TPC_Long_Diffusion);
  svtx_cells->setSigmaT(TPC_SigmaT);  
  svtx_cells->setShapingRMSLead(TPCShapingRMSLead * TPCDriftVelocity);
  svtx_cells->setShapingRMSTail(TPCShapingRMSTail * TPCDriftVelocity);
  // Expected cluster resolutions:
  //     r-phi: diffusion + GEM smearing = 750 microns, assume resolution is 20% of that => 150 microns
  //    Tune TPC_SmearRPhi and TPC_SmearZ to get 150 microns in the outer layers
  svtx_cells->setSmearRPhi(TPC_SmearRPhi);  // additional random displacement of cloud positions wrt hits
  svtx_cells->setSmearZ(TPC_SmearZ);        // additional random displacement of cloud positions wrt hits
  svtx_cells->set_drift_velocity(TPCDriftVelocity);
  svtx_cells->setHalfLength(105.5);
  svtx_cells->setElectronsPerKeV(TPC_ElectronsPerKeV);
  svtx_cells->Verbosity(0);

  // The maps cell size is set when the detector is constructed because it is needed by the geometry object
  // The INTT ladder cell size is set in the detector construction code

  // set cylinder cell TPC cell sizes
  //======================

  double tpc_timing_window = 105.5 / TPCDriftVelocity;  // half length in cm / Vd in cm/ns => ns

  // inner layers
  double radius_layer = inner_readout_radius ;
  for (int i = n_maps_layer + n_intt_layer; i < n_maps_layer + n_intt_layer + n_tpc_layer_inner; i++)
  {
    // this calculates the radius at the middle of the layer
    double tpc_cell_rphi = 2 * TMath::Pi() * radius_layer / (double) tpc_layer_rphi_count_inner;
    svtx_cells->cellsize(i, tpc_cell_rphi, tpc_cell_z);
    svtx_cells->set_timing_window(i, -tpc_timing_window, +tpc_timing_window);
    if (verbosity)
      cout << "TPC cells inner: layer " << i << " center radius " << radius_layer << " tpc_cell_rphi " << tpc_cell_rphi << " tpc_cell_z " << tpc_cell_z << endl;
    radius_layer += tpc_layer_thick_inner;
  }


  // mid layers
  for (int i = n_maps_layer + n_intt_layer + n_tpc_layer_inner; i < n_maps_layer + n_intt_layer + n_tpc_layer_inner + n_tpc_layer_mid; i++)
  {
    double tpc_cell_rphi = 2 * TMath::Pi() * radius_layer / (double) tpc_layer_rphi_count_mid;
    svtx_cells->cellsize(i, tpc_cell_rphi, tpc_cell_z);
    svtx_cells->set_timing_window(i, -tpc_timing_window, +tpc_timing_window);
    if (verbosity)
      cout << "TPC cells mid: layer " << i << " center radius " << radius_layer << " tpc_cell_rphi " << tpc_cell_rphi << " tpc_cell_z " << tpc_cell_z << endl;
    radius_layer += tpc_layer_thick_mid;
  }

  // outer layers
  for (int i = n_maps_layer + n_intt_layer + n_tpc_layer_inner + n_tpc_layer_mid; i < n_maps_layer + n_intt_layer + n_tpc_layer_inner + n_tpc_layer_mid + n_tpc_layer_outer; i++)
  {
    double tpc_cell_rphi = 2 * TMath::Pi() * radius_layer / (double) tpc_layer_rphi_count_outer;
    svtx_cells->cellsize(i, tpc_cell_rphi, tpc_cell_z);
    svtx_cells->set_timing_window(i, -tpc_timing_window, +tpc_timing_window);
    if (verbosity)
      cout << "TPC cells outer: layer " << i << " center radius " << radius_layer << " tpc_cell_rphi " << tpc_cell_rphi << " tpc_cell_z " << tpc_cell_z << endl;

    radius_layer += tpc_layer_thick_outer;
  }

  se->registerSubsystem(svtx_cells);

  return;
}