Exemplo n.º 1
0
void G4Init(const bool do_tracking = true,
      const bool do_pstof = true,
	    const bool do_cemc = true,
	    const bool do_hcalin = true,
	    const bool do_magnet = true,
	    const bool do_hcalout = true,
	    const bool do_pipe = true,
	    const bool do_plugdoor = false
	    )
  {

  // load detector/material macros and execute Init() function

  if (do_pipe)
    {
      gROOT->LoadMacro("G4_Pipe.C");
      PipeInit();
    }  
  if (do_tracking)
    {
      gROOT->LoadMacro("G4_Tracking.C"); 
      TrackingInit();
    }

  if (do_pstof) 
    {
      gROOT->LoadMacro("G4_PSTOF.C");
      PSTOFInit();
    }

  if (do_cemc)
    {
      gROOT->LoadMacro("G4_CEmc_Spacal.C");
      CEmcInit(72); // make it 2*2*2*3*3 so we can try other combinations
    }

  if (do_hcalin) 
    {
      gROOT->LoadMacro("G4_HcalIn_ref.C");
      HCalInnerInit();
    }

  if (do_magnet)
    {
      gROOT->LoadMacro("G4_Magnet.C");
      MagnetInit();
    }
  if (do_hcalout)
    {
      gROOT->LoadMacro("G4_HcalOut_ref.C");
      HCalOuterInit();
    }

  if (do_pipe)
    {
      gROOT->LoadMacro("G4_PlugDoor.C");
      PlugDoorInit();
    }
}
Exemplo n.º 2
0
void G4Init(bool do_svtx = true,
	    bool do_preshower = false,
	    bool do_cemc = true,
	    bool do_hcalin = true,
	    bool do_magnet = true,
	    bool do_hcalout = true,
	    bool do_pipe = true,
	    bool do_bbc = true,
	    bool do_global = true,
	    bool do_FEMC = true,
	    bool do_FHCAL = true) {

  gROOT->LoadMacro("G4_Bbc.C");
  if (do_bbc) BbcInit();
  
  gROOT->LoadMacro("G4_Pipe.C");
  if (do_pipe) PipeInit();
  
  // load detector macros and execute Init() function
  gROOT->LoadMacro("G4_Svtx.C");           // default
  //gROOT->LoadMacro("G4_Svtx_ladders.C"); // testing
  //gROOT->LoadMacro("G4_Svtx_ITS.C");     // testing
  if (do_svtx) SvtxInit();

  if (do_preshower) {
    gROOT->LoadMacro("G4_PreShower.C");   // testing
    PreShowerInit();
  }

  gROOT->LoadMacro("G4_CEmc_Spacal.C");    //
  if (do_cemc) CEmcInit(72); // make it 2*2*2*3*3 so we can try other combinations
  
  //gROOT->LoadMacro("G4_Hcal_ref.C");     // deprecated
  //gROOT->LoadMacro("G4_Hcal_cross.C");   // deprecated

  gROOT->LoadMacro("G4_HcalIn_ref.C");       // default 
  if (do_hcalin) HCalInnerInit();

  gROOT->LoadMacro("G4_Magnet.C");
  if (do_magnet) MagnetInit();

  gROOT->LoadMacro("G4_HcalOut_ref.C");       // default 
  if (do_hcalout) HCalOuterInit();

  gROOT->LoadMacro("G4_Global.C");
  
  gROOT->LoadMacro("G4_Jets.C");

  gROOT->LoadMacro("G4_FwdJets.C");

  gROOT->LoadMacro("G4_FEMC.C");
  if ( do_FEMC ) FEMCInit();

  gROOT->LoadMacro("G4_FHCAL.C");
  if ( do_FHCAL ) FHCALInit();

}
Exemplo n.º 3
0
void G4Init(bool do_svtx = true,
	    bool do_preshower = false,
	    bool do_cemc = true,
	    bool do_hcalin = true,
	    bool do_magnet = true,
	    bool do_hcalout = true,
	    bool do_pipe = false) {

  gROOT->LoadMacro("G4_Pipe.C");
  if (do_pipe) PipeInit();
  
  // load detector macros and execute Init() function
  gROOT->LoadMacro("G4_Svtx.C");           // default
  //gROOT->LoadMacro("G4_Svtx_ladders.C"); // testing
  //gROOT->LoadMacro("G4_Svtx_ITS.C");     // testing
  if (do_svtx) SvtxInit();

  if (do_preshower) {
    gROOT->LoadMacro("G4_PreShower.C");   // testing
    PreShowerInit();
  }

  gROOT->LoadMacro("G4_CEmc_Spacal.C");    //
  //gROOT->LoadMacro("G4_CEmc_cross.C");   // obselete
  //gROOT->LoadMacro("G4_CEmc_Alice.C");   // obselete
  //gROOT->LoadMacro("G4_CEmc_Alice_W.C"); // obselete
  if (do_cemc) CEmcInit(Cemc_slats_per_cell);

  //gROOT->LoadMacro("G4_Hcal_ref.C");     // deprecated
  //gROOT->LoadMacro("G4_Hcal_cross.C");   // deprecated

  gROOT->LoadMacro("G4_HcalIn_ref.C");       // default 
  if (do_hcalin) HCalInnerInit();

  gROOT->LoadMacro("G4_Magnet.C");
  if (do_magnet) MagnetInit();

  gROOT->LoadMacro("G4_HcalOut_ref.C");       // default 
  if (do_hcalout) HCalOuterInit();

  gROOT->LoadMacro("G4_Jets.C");
}
Exemplo n.º 4
0
void G4Init(bool do_svtx = true,
	    bool do_preshower = false,
	    bool do_cemc = true,
	    bool do_hcalin = true,
	    bool do_magnet = true,
	    bool do_hcalout = true,
	    bool do_pipe = true)
  {

  // load detector/material macros and execute Init() function

  if (do_pipe)
    {
      gROOT->LoadMacro("G4_Pipe.C");
      PipeInit();
    }
  if (do_svtx)
    {
      //gROOT->LoadMacro("G4_Svtx.C");                 // default MIE projections
      gROOT->LoadMacro("G4_Svtx_pixels+strips.C"); // testing
      //gROOT->LoadMacro("G4_Svtx_pixels+tpc.C");    // testing
      //gROOT->LoadMacro("G4_Svtx_maps+strips.C");   // testing
      //gROOT->LoadMacro("G4_Svtx_maps+tpc.C");      // testing
      //gROOT->LoadMacro("G4_Svtx_ladders.C");       // testing
      //gROOT->LoadMacro("G4_Svtx_ITS.C");           // testing
      SvtxInit();
    }

  if (do_preshower)
    {
      gROOT->LoadMacro("G4_PreShower.C");
      PreShowerInit();
    }

  if (do_cemc)
    {
      if ( fast_sim_flag == 1 ) gROOT->LoadMacro("G4_CEmc_BlackHole.C"); // super fast sim for electrons???
      else if ( fast_sim_flag == 2 ) gROOT->LoadMacro("G4_CEmc_Galactic.C"); // super fast sim for pions???
      else gROOT->LoadMacro("G4_CEmc_Spacal.C"); // actual GEANT simulation
      CEmcInit(72); // make it 2*2*2*3*3 so we can try other combinations
    }

  if (do_hcalin)
    {
      //gROOT->LoadMacro("G4_HcalIn_ref.C");
      gROOT->LoadMacro("G4_HcalIn_Blackhole.C");
      HCalInnerInit();
    }

  if (do_magnet)
    {
      gROOT->LoadMacro("G4_Magnet.C");
      MagnetInit();
    }
  if (do_hcalout)
    {
      gROOT->LoadMacro("G4_HcalOut_ref.C");
      HCalOuterInit();
    }

}
Exemplo n.º 5
0
void G4Init(bool do_svtx = true,
	    bool do_preshower = false,
	    bool do_cemc = true,
	    bool do_hcalin = true,
	    bool do_magnet = true,
	    bool do_hcalout = true,
	    bool do_pipe = true,
	    bool do_FEMC = true,
	    bool do_FHCAL = true) {

  // load detector/material macros and execute Init() function

  if (do_pipe)
    {
      gROOT->LoadMacro("G4_Pipe.C");
      PipeInit();
    }
  if (do_svtx)
    {
      gROOT->LoadMacro("G4_Svtx.C");
      //gROOT->LoadMacro("G4_Svtx_ladders.C"); // testing
      //gROOT->LoadMacro("G4_Svtx_ITS.C");     // testing
      SvtxInit();
    }

  if (do_preshower) 
    {
      gROOT->LoadMacro("G4_PreShower.C");
      PreShowerInit();
    }

  if (do_cemc)
    {
      gROOT->LoadMacro("G4_CEmc_Spacal.C");
      CEmcInit(72); // make it 2*2*2*3*3 so we can try other combinations
    }  

  if (do_hcalin) 
    {
      gROOT->LoadMacro("G4_HcalIn_ref.C");
      HCalInnerInit();
    }

  if (do_magnet)
    {
      gROOT->LoadMacro("G4_Magnet.C");
      MagnetInit();
    }
  if (do_hcalout)
    {
      gROOT->LoadMacro("G4_HcalOut_ref.C");
      HCalOuterInit();
    }

  if (do_FEMC)
    {
      gROOT->LoadMacro("G4_FEMC.C");
      FEMCInit();
    }

  if (do_FHCAL) 
    {
      gROOT->LoadMacro("G4_FHCAL.C");
      FHCALInit();
    }
}
Exemplo n.º 6
0
/**
 * Run all tests
 */
int
umain (void) {


    isActivated = false;
    isForward = true;
    MagnetInit();
    PIDInit();
    uint8_t num_low_readings = 0;
    activateRun();

    while(1){

        //Read Magnet data
        ComputeMagnetTarget();

        //uint8_t oldForward = isForward;

        if (fangle > 90 || fangle < -90) {
            isForward = false;
        } else {
            isForward = true;
        }

        //Determine if we should change from activated->deactivated or vice versa
        if (isActivated) {
            if (FieldStrength < DEACTIVATE_THRESH) {
                num_low_readings++;
                //Need START_RAMPDOWN readings to begin motor rampdown
                if (num_low_readings > START_RAMPDOWN) {
                    SetTargetVelocity(TARGET_VELOCITY*(1.0-(float)(num_low_readings-START_RAMPDOWN)/(float)(DEACTIVATE_SAMPLES-START_RAMPDOWN)));
                    //SetTargetVelocity(TARGET_VELOCITY);
                }
                //If you have DEACTIVATE_SAMPLES low readings, deactivate
                if (num_low_readings == DEACTIVATE_SAMPLES) {
                    isActivated = false;
                    num_low_readings = 0;
                    SetTargetVelocity(TARGET_VELOCITY);
                    printf("\nDEACTIVATED");
                }
            } else {
                //We had a good reading, reset bad reading count and motor velocity
                num_low_readings = 0;
                SetTargetVelocity(TARGET_VELOCITY);
            }
        } else {
            //Activate on a single high reading
            if (FieldStrength > ACTIVATE_THRESH) {
                isActivated = true;
                SetTargetVelocity(TARGET_VELOCITY);
                printf("\nACTIVATED");
                PIDReset();
            }
        }

        SetTargetVelocity(NearbyScale*TargetVelocity);

        //Stop if not activated, otherwise update PID
        if (!isActivated) {
            CoastMotors();
            //pause(100);
        } else {
            PIDUpdate();
        }

        //pause(100);

    }

    return 0;

}