150 likes | 283 Views
Some GEANT4 exercises…. ADC. delay. PA. Sr 90. Sr. discr. &. Sr. diamond. Y. Gate. discr. Y. Scint. E, MeV. PM1. PM2. GEANT4 simulation of the diamond test setup. Sr. Emip = 1.5 MeV dE/dx = 5.57 MeV/cm R = 0.2 cm. Task:
E N D
Some GEANT4 exercises…
ADC delay PA Sr90 Sr discr & Sr diamond Y Gate discr Y Scint. E, MeV PM1 PM2 GEANT4 simulation of the diamond test setup Sr Emip = 1.5 MeV dE/dx = 5.57 MeV/cm R = 0.2 cm • Task: • to understand and improve the built setup… • are the electrons MIP? • is the ionization homogeneous in diamond? • can be geometry improved? MIP
GEANT4 geometry + source Source: G4GeneralParticleSource or G4RadioactiveDecay or your own... setup_PrimaryGeneratorAction.cc setup_PhysicsListLE.cc: …………………… void setup_PhysicsListLE::SetCuts(){ SetCutValue(0.01*mm, "gamma"); SetCutValue(0.01*mm, "e-"); SetCutValueForOthers(defaultCutValue); DumpCutValuesTable(); } GEANT REAL setup_geometry.cc : G4UserLimits *l = new G4UserLimits(); // Sets a max Step length in the diamond : G4double maxStep = 0.005*mm; l->SetMaxAllowedStep(maxStep); diamond_log->SetUserLimits(l);
setup_RootManager.hh : class setupRootManager{ //singleton public: ... static setupRootManager* getInstance(); void fillX(double dE, double x, double y, double z, int psN); void fillE(double iE, double dE, double sE); … private: static setupRootManager* instance; TFile* f; TNtuple* ntupleX; TNtuple* ntupleE; … }; setup_diamHit.hh : class setup_diamHit : public G4VHit{ public: …. private: G4int trackID; G4double edep; G4ThreeVector pos; G4String pname; …… } setup_diamSD.hh : class setup_diamSD : public G4VSensitiveDetector{ public: … G4bool ProcessHits(G4Step*, G4TouchableHistory*); private: setup_diamHitsCollection* diamCollection; }; setup_EventAction.cc : void setupEventAction::EndOfEventAction(const G4Event* anEvent){ setupRootManager* sRM = setupRootManager::getInstance(); // get information from setup_diamHitsCollection, setup_diamHitsCollection,... // and fill root histo/ntuple/tree… sRM->fillE(Eini,diamEnergy,scintEnergy); sRM->FillSomethingElse(…) };
energy spectra Diamond – spectrum (energy deposition) for any e- Initial electrons - spectrum for “diamond” e- Initial electrons - Spectrum for “triggered” e- Diamond – spectrum (energy deposition) for triggered e-
depth distributions all electrons in diamond triggered electrons in diamond
step limits influence - 0.3 MeV e- No step limits: => Step size is defined by a process… max Step length = 10 mm : => Step size is defined by the limit
More games… ROOT :)
histogram fitting… Simple?.. TH1F * signal = new TH1F(…); F1 * g1 = new TF1("g1", myFunc, min, max, npar); signal->Fit("g1","VR"); If the function is not so simple?... Signal = Gaus1 + Landau * Gauss2 Fit parameters: p[0] = Norm(Gauss1) p[1] = Mean(Gauss1) - fixed p[2] = Sigma(Gauss1) – fixed p[3] = Width(Langau) p[4] = MPV(Langau) p[5] = Area(Langau) p[6] = Sigma(Gauss2)
Simple fitting for the complicated case… Function: TF1 * glg = new TF1("glg", gaulangaufun, 50, 400, 7); Proper initial parameters: p[0] = 100.; p[1] = 139.1; p[2] = 17.7; // from noise gauss p[3] = 5.; p[4] = 180.; p[5] = 20000.; p[6] = 30.; // signal glg->SetParameters(p); And fit it: signal->Fit("glg","VR"); …. And get: FCN=140.264 FROM MIGRAD STATUS=FAILED 611 CALLS 612 TOTAL EDM=30.8846 STRATEGY= 1ERR MATRIX NOT POS-DEF EXT PARAMETER APPROXIMATE STEP FIRST NO. NAME VALUE ERROR SIZE DERIVATIVE 1 p0 1.72541e+01 9.99999e-01 -0.00000e+00 -1.74731e-03 2 p1 1.39100e+02 fixed 3 p2 1.77000e+01 fixed 4 p3 4.91314e+00 1.79039e+00 0.00000e+00 -4.07711e+00 5 p4 1.86918e+02 2.33982e+00 0.00000e+00 -4.67063e-03 6 p5 9.58479e+03 1.44047e+02 0.00000e+00 -3.45415e-09 7 p6 2.74389e+01 2.34762e+00 0.00000e+00 8.24991e-02
To try to improve the fit… To improve: signal->Fit("glg","EVR"); // „better error estimation“ … And it takes ~8 times loneger… …. And get: FCN=140.208 FROM MINOS STATUS=PROBLEMS 4058 CALLS 5120 TOTAL EDM=0.358165 STRATEGY= 1 ERR MATRIX NOT POS-DEF EXT PARAMETER PARABOLIC MINOS ERRORS NO. NAME VALUE ERROR NEGATIVE POSITIVE 1 p0 1.74193e+01 1.29294e+00 1.08485e+00 2 p1 1.39100e+02 fixed 3 p2 1.77000e+01 fixed 4 p3 4.87816e+00 1.56382e-03 5 p4 1.86941e+02 6.02893e-03 6 p5 9.58141e+03 1.62875e+02 7 p6 2.73866e+01 1.06973e+00 9.57228e-01
going back to MINUIT… Actually: ROOT uses MINUIT: signal->Fit("glg","VR"); <=> gMinuit->mnexcm("MIGRAD", arglist ,2,ierflg); signal->Fit("glg",“EVR"); <=> gMinuit->mnexcm("MIGRAD", arglist ,2,ierflg); +gMinuit->mnexcm("MINOS", arglist ,npar,ierflg); Then what is wrong? Probably, too many things are predefined? To use TMinuit class directly (only necessary and optimal things)?
going back to MINUIT… Everything (almost) as in Fortran: TMinuit *gMinuit = new TMinuit(7); gMinuit->SetFCN(fcn); // just Chi2 arglist[0] = 1; gMinuit->mnexcm("SET ERR", arglist, 1, ierflg); // UD = 1 for chisqr // Set starting values and step sizes for parameters Double_t vstart[7] = {100, 139.1, 17.7, 5., 180., 20000., 30.}; Double_t step[7] = {1 , 1 , 0.1, .02, .1, 50, .3}; gMinuit->mnparm(0, "PNorm", vstart[0], step[0], 0,0, ierflg); ………………………………….. arglist[0] = 1000; arglist[1] = .01; // with set maxcall and tolerance gMinuit->mnexcm("MIGRAD", arglist ,2,ierflg); arglist[0] = 200; arglist[1] = 5; // with set maxcall and npar gMinuit->mnexcm("MINOS", arglist ,2,ierflg);
and we’ve finally got… FCN=140.388 FROM MINOS STATUS=SUCCESSFUL 357 CALLS 1062 TOTAL EDM=0.000510439 STRATEGY= 1 ERR MATRIX NOT POS-DEF EXT PARAMETER PARABOLIC MINOS ERRORS NO. NAME VALUE ERROR NEGATIVE POSITIVE 1 PNorm 1.72476e+01 2.44167e+00 2 PMean 1.39100e+02 fixed 3 PSigma 1.77000e+01 fixed 4 LSigma 4.91366e+00 1.52320e-02 5 LMPV 1.86905e+02 2.15345e-01 -5.77136e-01 5.10611e-01 6 LNorm 9.57911e+03 1.02587e+02 7 GSigna 2.73663e+01 8.55687e-02 Chi2 LMPV