GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CascadeEvents.C
Go to the documentation of this file.
1 
2 
31 #ifndef __CINT__
32 #include <stdio.h>
33 #include <time.h>
34 #include "Riostream.h"
35 #include <cstdlib>
36 #include <iostream>
37 #include <fstream>
38 #include <string>
39 #include <istream>
40 #include "TRandom.h"
41 #include "TTimeStamp.h"
42 #include "TMatrixD.h"
43 using namespace std;
44 #endif
45 
46 using namespace Gw;
47 
61 void cascataAGS(const Int_t, Int_t, FILE, const Double_t, const BaseGEM);
62 
77 void matriceRES(FILE, Int_t*, Double_t**, Double_t*, Int_t, Int_t, Int_t*);
78 
88 Int_t eccresiduoa(const Double_t&, Int_t&, Int_t&, Double_t&, const Double_t*);
89 
95 Int_t eccresiduop(const Double_t&, Int_t&, Int_t&, Double_t&, const Double_t*);
96 
102 Int_t eccresiduon(const Double_t&, Int_t&, Int_t&, Double_t&, const Double_t*);
103 
114 Double_t trovame(Int_t&, Int_t&);
115 
117 void posizioneAin_me();
118 
130 void parabola(const Int_t*, const Double_t*, const Int_t&, Double_t&, Double_t&, Double_t&);
131 
139 Double_t parabolame(Int_t&, Int_t&, Int_t&);
140 
146 Double_t wei1(Int_t&, Int_t&);
147 
156 void trovaAZ(const Int_t&, const Int_t&, Int_t&, Int_t&);
157 
158 
159 /*
160 //enrico
161 #define AV 15500.0
162 #define AS 16800.0
163 #define AC 720.0
164 #define APa 34000.0
165 #define AAS 23000.0
166 */
167 #define MP 938280.0
168 #define MN 939573.0
169 #define MALFA 3727409.0
170 
171 //frobrich
172 #define AV 15677.0
173 #define AS 18560.0
174 #define AC 720.0
175 #define APa 33500.0
176 #define AAS 23500.0
177 
178 
179 Int_t Z[3000], A[3000];
180 Double_t me[3000];
181 Int_t numnuclei;
182 Int_t posizA[3000];
183 Int_t AGS[200];
184 Int_t numA;
185 Int_t massa[29];
186 Int_t NmenoZ[11];
187 Int_t rettA, rettZ;
188 Int_t amin, zmin;
189 
190 
191 void CascadeEvents(const Char_t *finput, Int_t nbcas = 100, const Char_t *nameOUT = "toGEANT101.event")
192 {
193  for (int i = 0; i < 3000; i++) {Z[i] = 0; A[i] = 0; me[i] = 0;}
194  int i,j,k;
195  for (i = 0; i < 200; i++) AGS[i] = 0;
196 
197  FILE *fileIN = fopen(finput,"r");
198  if ( fileIN == NULL ) {
199  printf(" Cannot open file %s \n",finput);
200  return;
201  }
202 
203  //---------carico le masse
204  FILE *fileMAS = fopen("mastab.dat","r");
205  if ( fileMAS == NULL ) {
206  printf(" Cannot open file mastab.dat \n");
207  return;
208  }
209  Char_t Line[300];
210  fgets (Line, 300, fileMAS);
211  sscanf(Line,"%*c%*c%*d%*d%d%d%*s%*s%lf", &Z[0], &A[0], &me[0]);
212  i = 0;
213  while (!feof(fileMAS)){
214  fgets (Line, 300, fileMAS);
215  sscanf(Line,"%*c%*c%*d%*d%d%d%*s%lf", &Z[i], &A[i], &me[i]);
216  if (A[i] > 0) i++;
217  }
218  numnuclei = i;
219  posizioneAin_me();
220 
221  //---------carico gli spettri evaporativi
222  Char_t buf[100], buf2[100], buf3[100];
223  while ((strcmp(buf, "SUMMED")) || (strcmp(buf2, "EVAPORATION")) || (strcmp(buf3, "SPECTRA"))) {
224  fgets (Line, 300, fileIN);
225  sscanf(Line,"%s %s %s", buf, buf2, buf3);
226  }
227  for (int i=0; i < 3; i++) fgets (Line, 300, fileIN);
228  Float_t epart[50], dn[50], dp[50], da[50], eg[50], dg[50];
229  int indice=0;
230  while (strcmp(buf, "0")) {
231  fgets (Line, 300, fileIN);
232  sscanf(Line,"%s", buf);
233  if (strcmp(buf, "0")) {
234  sscanf(Line,"%f%f%f%f %*41c %f %f", &epart[indice], &dn[indice], &dp[indice], &da[indice], &eg[indice], &dg[indice]);
235  }
236  indice++;
237  }
238  Float_t dcumn[50], dcump[50], dcuma[50], dcumg[50];
239  dcumn[0] = 0; dcump[0] = 0; dcuma[0] = 0; dcumg[0] = 0;
240  for (int i = 1; i < 50; i++){
241  dcumn[i] = dcumn[i-1] + dn[i-1];
242  dcump[i] = dcump[i-1] + dp[i-1];
243  dcuma[i] = dcuma[i-1] + da[i-1];
244  }
245 
246  //---------calcolo l'enegia "media" delle particelle evaporate (en media := en t.c. il 50% ha meno energia)
247  Float_t eamed, epmed, enmed;
248  Float_t soglia = dcuma[49]*0.5;
249  for (int j = 0; j < 50; j++){
250  if (dcuma[j] < soglia) eamed = 1000 * epart[j];
251  }
252  soglia = dcump[49]*0.5;
253  for (int j = 0; j < 50; j++){
254  if (dcump[j] < soglia) epmed = 1000 * epart[j];
255  }
256  soglia = dcumn[49]*0.5;
257  for (int j = 0; j < 50; j++){
258  if (dcumn[j] < soglia) enmed = 1000 * epart[j];
259  }
260  cout << "eamed = " << eamed << " epmed = " << epmed << " enmed = " << enmed << '\n';
261 
262  //---------carico la reazione
263  while (strcmp(buf, "ENTR.CHANNEL,")) {
264  fgets (Line, 300, fileIN);
265  sscanf(Line,"%s", buf);
266  }
267  Int_t zp, ap, zb, ab, zcn, acn;
268  Float_t ep, ecccn;
269  sscanf(Line,"%*s%*s%*s %d%d %d%d %f %d%d %f", &zp, &ap, &zb, &ab, &ep, &zcn, &acn, &ecccn);
270 
271  //---------carico la matrice dei nuclei residui
272  //Int_t massa[29]; //globale
273  Double_t pop[29][6];
274  Double_t popsum[29];
275  Int_t numpari, numdispari;
276  //Int_t NmenoZ[11]; //globale
277  matriceRES(fileIN, massa, pop, popsum, numpari, numdispari, NmenoZ); //carica la matrice con i nuclei residui
278 
279  Double_t total = 0;
280  Int_t numpop=0;
281  for (i = 0; i < 29; i++){
282  if (massa[i] % 2) {for (j = 0; j < numdispari; j++) {total += pop[i][j]; if (pop[i][j] > 0) numpop++; }} //se massa[i] e' dispari
283  else {for (j = 0; j < numpari; j++) {total += pop[i][j]; if (pop[i][j] > 0) numpop++;}} //se massa[i] e' pari
284  }
285 
286  Double_t popcum[29][6];
287  Double_t sumparz = 0;
288  for (i = 0; i < 29; i++) {
289  if (massa[i] % 2) {for (j = 0; j < numdispari; j++) {sumparz += pop[i][j] / total; popcum[i][j] = sumparz;}} //se massa[i] e' dispari
290  else {for (j = 0; j < numpari; j++) {sumparz += pop[i][j] / total; popcum[i][j] = sumparz;}} //se massa[i] e' pari
291  }
292 
293  //---------trovo amin e zmin dei nuclei popolati
294  Int_t atmp, ztmp;
295  amin = 99999;
296  zmin = 99999;
297  for (i = 0; i < 29; i++){
298  if (massa[i] % 2) {for (j = 0; j < numdispari; j++) {if (pop[i][j] > 0) { trovaAZ(i, j, atmp, ztmp); if (atmp < amin) amin = atmp; if (ztmp < zmin) zmin = ztmp;}}}//se massa[i] e' dispari
299  else {for (j = 0; j < numpari; j++) {if (pop[i][j] > 0) { trovaAZ(i, j, atmp, ztmp); if (atmp < amin) amin = atmp; if (ztmp < zmin) zmin = ztmp;}}} //se massa[i] e' pari
300  }
301 
302  //---------trovo gli eccessi di massa nel rettangolo (amin,zmin)-(acn,zcn)
303  rettA = acn-amin+1;
304  rettZ = zcn-zmin+1;
305  Double_t *mecalc = new Double_t[rettA * rettZ];
306  cout << "Calcolo la massa dei nuclei coinvolti ...\n";
307  for (int a = 0; a < rettA; a++) {
308  for (int z = 0; z < rettZ; z++) {
309  mecalc[a * rettZ + z] = trovame(a + amin, z + zmin);
310  //cout << "mecalc[" << (a + amin) << "][" << (z + zmin) << "]: " << mecalc[a * rettZ + z] << '\n';
311  }
312  }
313  cout << "Fatto\n";
314 
315  //---------inizializzo gli spettri
316  cout << "spettri\n";
317  Int_t r=0;
318  Int_t residuo[165];
319  for (i = 0; i < 29; i++){
320  if (massa[i] % 2) {for (j = 0; j < numdispari; j++) {if (pop[i][j] > 0) {residuo[r] = i * 10 + j; r++;}}} //se massa[i] e' dispari
321  else {for (j = 0; j < numpari; j++) {if (pop[i][j] > 0) {residuo[r] = i * 10 + j; r++;}}} //se massa[i] e' pari
322  }
323  for (int enr=0; enr<r; enr++) {cout << enr << " - " << residuo[enr] << '\n';}
324  cout << "spettri\n";
325 
326  // load AGS file(s)
327  BaseGEM* random = new BaseGEM[numpop];
328  cout << "numpop: " << numpop << "\n";
329  for (int r = 0; r < numpop; r++) {
330  //trovo A e Z del nucleo r-esimo
331  Int_t posi = residuo[r] / 10;
332  Int_t posj = residuo[r] - 10 * posi;
333  Int_t posA, posZ;
334  trovaAZ(posi, posj, posA, posZ);
335  /*
336  Int_t posA = massa[posi];
337  Int_t posNmZ;
338  if ((massa[posi] % 2) == (NmenoZ[0] % 2)) {posNmZ = NmenoZ[2 * posj];}
339  else {posNmZ = NmenoZ[2 * posj + 1];}
340  Int_t posZ = (posA - posNmZ) / 2;
341  */
342 
343  //converto nell'elemento
344  //char chem[109][3] = {"H","He","Li","Be","B","C","N","O","F","Ne","Na","Mg","Al","Si","P","S","Cl","Ar","K","Ca","Sc","Ti","V","Cr","Mn","Fe","Co","Ni","Cu","Zn","Ga","Ge","As","Se","Br","Kr","Rb","Sr","Y","Zr","Nb","Mo","Tc","Ru","Rh","Pd","Ag","Cd","In","Sn","Sb","Te","I","Xe","Cs","Ba","La","Ce","Pr","Nd","Pm","Sm","Eu","Gd","Tb","Dy","Ho","Er","Tm","Yb","Lu","Hf","Ta","W","Re","Os","Ir","Pt","Au","Hg","Tl","Pb","Bi","Po","At","Rn","Fr","Ra","Ac","Th","Pa","U","Np","Pu","Am","Cm","Bk","Cf","Es","Fm","Md","No","Lr","Rf","Db","Sg","Bh","Hs","Mt"};
345  char chem[259][3] = {"H","He","Li","Be","B","C","N","O","F","Ne","Na","Mg","Al","Si","P","S","Cl","Ar","K","Ca","Sc","Ti","V","Cr","Mn","Fe","Co","Ni","Cu","Zn","Ga","Ge","As","Se","Br","Kr","Rb","Sr","Y","Zr","Nb","Mo","Tc","Ru","Rh","Pd","Ag","Cd","In","Sn","Sb","Te","I","Xe","Cs","Ba","La","Ce","Pr","Nd","Pm","Sm","Eu","Gd","Tb","Dy","Ho","Er","Tm","Yb","Lu","Hf","Ta","W","Re","Os","Ir","Pt","Au","Hg","Tl","Pb","Bi","Po","At","Rn","Fr","Ra","Ac","Th","Pa","U","Np","Pu","Am","Cm","Bk","Cf","Es","Fm","Md","No","Lr","Rf","Db","Sg","Bh","Hs","Mt","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X","X"};
346 
347  //costruisco il nomefileAGS
348  char nomefileAGS [500];
349  sprintf (nomefileAGS, "../ags/%d%s_ensdf_A.ags", posA, chem[posZ-1]);
350  printf ("nomefileAGS: %s\n", nomefileAGS);
351  Char_t *nameAGS = nomefileAGS;
352 
353  //controllo se il file AGS esiste
354  FILE *fileAGS = fopen(nameAGS,"r");
355  if ( fileAGS == NULL ) {
356  printf(" File AGS non esiste\n");
357  AGS[r] = 0;
358  }
359  else {
360  if ( random[r].InitAGS(nameAGS) == 0 ) {
361  cout << " GLS level Scheme not correctly loaded " << endl << "Nucleo Z:" << posZ << " A:" << posA << " posi:" << posi << " posj:" << posj << endl;
362  AGS[r] = 0;
363  }
364  else {
365  cout << "Loaded GLS level Scheme for nucleo " << r << '\n';
366  AGS[r] = 1;
367  }
368  }
369  cout << posA << chem[posZ-1] << " (" << posZ << ") in posizione " << residuo[r] << " processato" << '\n';
370  cout << "numpop: " << numpop << " |r: " << r << '\n';
371  if (r == (numpop -1)) break;
372  }
373 
374  cout << numpop << " FILE AGS CARICATI" << '\n';
375 
376 
377  // open a file to store the simulated events.
378  FILE *fileOUT = fopen(nameOUT,"w");
379  if ( fileOUT == NULL ) {
380  printf(" Cannot open file %s \n",nameOUT); return;
381  }
382  fprintf(fileOUT,"FORMAT 4 4 \n");
383  fprintf(fileOUT,"# \n");
384  fprintf(fileOUT,"# PARTICLES GENERATED FROM CASCADE OUTPUT \n");
385  fprintf(fileOUT,"# GAMMAS GENERATED FROM THE LEVEL SCHEME \n");
386  fprintf(fileOUT,"# \n");
387  fprintf(fileOUT,"REACTION %d %d %d %d %.1f\n", zp, ap, zb, ab, ep);
388  fprintf(fileOUT,"# \n");
389  fprintf(fileOUT,"EMITTED 4 1 2 3 7 \n");
390  fprintf(fileOUT,"# \n");
391 
392 
393 
394 
395 
396  //---------genero eventi
397  Int_t numev[29][6];
398  //inizializzo gRandom con i nanosecondi
399  Double_t rndmdb, rndmener;
400  Double_t nanos = TTimeStamp().GetNanoSec();
401  //gRandom -> SetSeed((UInt_t)nanos);
402  gRandom -> SetSeed(0);
403  for (i = 0; i < 29; i++) for (j = 0; j < 6; j++) numev[i][j] = 0;
404  //Float_t eaemitted[10], epemitted[10], enemitted[10];
405  Int_t Aemitter,Zemitter;
406  Double_t eccemitter;
407 
408  //******************************************************************************************************
409  //*******************************INIZIO***********************************************************************
410  //******************************************************************************************************
411 
412  for (k = 0; k < nbcas; k++) {
413  //------------------------estraggo un nucleo residuo
414  rndmdb = gRandom -> Rndm();
415  Int_t posi = 0;
416  Int_t posj = 0;
417  Int_t posOK = 0;
418  for (i = 0; i < 29; i++) {
419  if (massa[i] % 2) {for (j = 0; j < numdispari; j++) {if ((rndmdb < popcum[i][j]) && (posOK == 0)) {posOK = 1; posi = i; posj = j;}}} //se massa[i] e' dispari
420  else {for (j = 0; j < numpari; j++) {if ((rndmdb < popcum[i][j]) && (posOK == 0)) {posOK = 1; posi = i; posj = j;}}} //se massa[i] e' pari
421  if (posOK) break;
422  }
423 
424 
425  numev[posi][posj]++;
426  Int_t posA, posZ;
427  trovaAZ(posi, posj, posA, posZ);
428  /*
429  //trovo A
430  Int_t posA;
431  posA = massa[posi];
432  //trovo N-Z
433  Int_t posNmZ;
434  if ((massa[posi] % 2) == (NmenoZ[0] % 2)) {posNmZ = NmenoZ[2 * posj];}
435  else {posNmZ = NmenoZ[2 * posj + 1];}
436  Int_t posZ = (posA - posNmZ) / 2;
437  */
438 
439  //------------------------numero di particelle da emettere
440  Int_t diffp = zcn - posZ;
441  Int_t diffn = acn - posA - diffp;
442  Int_t nalfa = 0, nprot = 0, nneut = 0;
443  while ((diffp >= 2) && (diffn >= 2)) {
444  nalfa++;
445  diffp -= 2;
446  diffn -= 2;
447  }
448  nprot = diffp;
449  nneut = diffn;
450  //cout << "Acn: " << acn << " Zcn: " << zcn << " Af: " << posA << " Zf: " << posZ << " alfa: " << nalfa << " prot: " << nprot << " neut: " << nneut << '\n';
451 
452 
453  //------------------------emetti particelle
454  Double_t* eaemitted = new Double_t[nalfa]; //Double_t *eaemitted; //eaemitted = (Double_t*)calloc(nalfa, sizeof(Double_t));
455  Double_t* epemitted = new Double_t[nprot];
456  Double_t* enemitted = new Double_t[nneut];
457  Int_t ok = 1;
458  Int_t risparopart = 0;
459  Double_t ridprob = 1;
460 
461  while (ok == 1){
462  ok = 0;
463  Aemitter = acn;
464  Zemitter = zcn;
465  eccemitter = ecccn * 1000;
466  //cout << "eccemitter = " << eccemitter << '\n';
467  for (int i = 0; i < nalfa; i++){
468  if (eccemitter <= eamed) ok = 1;
469  //rndmener = dcuma[49]*(gRandom -> Rndm());
470  rndmener = dcuma[49]*(gRandom -> Rndm()) * ridprob;
471  for (int j = 0; j < 50; j++){
472  if (dcuma[j] > rndmener) {
473  eaemitted[i] = 1000 * (epart[j-1] - 0.5 + (rndmener - dcuma[j-1]) / da[j-1]);
474  //cout << "mecalc " << mecalc << " &mecalc " << &mecalc << "\n";
475  eccresiduoa(eaemitted[i], Aemitter, Zemitter, eccemitter, mecalc);
476  break;
477  }
478  }
479  //cout << "eccemitter = " << eccemitter << " eaemitted = " << eaemitted[i] << '\n';
480  }
481  for (int i = 0; i < nprot; i++){
482  if (eccemitter <= epmed) ok = 1;
483  //rndmener = dcump[49]*(gRandom -> Rndm());
484  rndmener = dcump[49]*(gRandom -> Rndm()) * ridprob;
485  for (int j = 0; j < 50; j++){
486  if (dcump[j] > rndmener) {
487  epemitted[i] = 1000 * (epart[j-1] - 0.5 + (rndmener - dcump[j-1]) / dp[j-1]);
488  //cout << "mecalc " << mecalc << " &mecalc " << &mecalc << "\n";
489  eccresiduop(epemitted[i],Aemitter,Zemitter,eccemitter, mecalc);
490  break;
491  }
492  }
493  //cout << "eccemitter = " << eccemitter << " epemitted = " << epemitted[i] << '\n';
494  }
495  for (int i = 0; i < nneut; i++){
496  if (eccemitter <= enmed) ok = 1;
497  //rndmener = dcumn[49]*(gRandom -> Rndm());
498  rndmener = dcumn[49]*(gRandom -> Rndm()) * ridprob;
499  for (int j = 0; j < 50; j++){
500  if (dcumn[j] > rndmener) {
501  enemitted[i] = 1000 * (epart[j-1] - 0.5 + (rndmener - dcumn[j-1]) / dn[j-1]);
502  //cout << "mecalc " << mecalc << " &mecalc " << &mecalc << "\n";
503  eccresiduon(enemitted[i],Aemitter,Zemitter,eccemitter, mecalc);
504  break;
505  }
506  }
507  //cout << "eccemitter = " << eccemitter << " enemitted = " << enemitted[i] << '\n';
508  }
509  if (eccemitter <= 0) ok = 1;
510  if (ok == 1) {risparopart++; ridprob *= 0.9; /*cout <<"RISPARO PARTICELLE (energia)************" << risparopart << '\n';*/}
511  }
512 
513  //------------------------scrivi dati sorgente
514  fprintf(fileOUT," $ \n -101 \n ");
515 
516  //------------------------scrivi le particelle
517  for (int i = 0; i < nalfa; i++) fprintf(fileOUT,"7 %.1lf 0. 0.\n ", eaemitted[i]);
518  for (int i = 0; i < nprot; i++) fprintf(fileOUT,"3 %.1lf 0. 0.\n ", epemitted[i]);
519  for (int i = 0; i < nneut; i++) fprintf(fileOUT,"2 %.1lf 0. 0.\n ", enemitted[i]);
520 
521  /*//converto nell'elemento
522  char chem[109][3] = {"H","He","Li","Be","B","C","N","O","F","Ne","Na","Mg","Al","Si","P","S","Cl","Ar","K","Ca","Sc","Ti","V","Cr","Mn","Fe","Co","Ni","Cu","Zn","Ga","Ge","As","Se","Br","Kr","Rb","Sr","Y","Zr","Nb","Mo","Tc","Ru","Rh","Pd","Ag","Cd","In","Sn","Sb","Te","I","Xe","Cs","Ba","La","Ce","Pr","Nd","Pm","Sm","Eu","Gd","Tb","Dy","Ho","Er","Tm","Yb","Lu","Hf","Ta","W","Re","Os","Ir","Pt","Au","Hg","Tl","Pb","Bi","Po","At","Rn","Fr","Ra","Ac","Th","Pa","U","Np","Pu","Am","Cm","Bk","Cf","Es","Fm","Md","No","Lr","Rf","Db","Sg","Bh","Hs","Mt"};
523  //costruisco il nomefileAGS
524  char nomefileAGS [500];
525  sprintf (nomefileAGS, "../ags/%d%s_ensdf_A.ags", posA, chem[posZ-1]);
526  printf ("nomefileAGS: %s", nomefileAGS);
527  //sparo una cascata
528  Char_t *nameAGS = nomefileAGS;*/
529 
530  //------------------------emetti e scrivi gamma nello spettro noto
531  //trovo r(posi,posj) -> resi
532  Int_t resi = 0;
533  while (residuo[resi] != (10 *posi + posj)) resi++;
534  cascataAGS(resi, 1, fileOUT, eccemitter, random);
535 
536  if(k && !(k%1000)) {printf("%10d eventi\r",k);}
537  }
538 
539  //******************************************************************************************************
540  //*******************************FINE***********************************************************************
541  //******************************************************************************************************
542 
543 
544  //output matrice (N-Z) - A dei nuclei simulati (frequenze)
545  Int_t jmax;
546  for (i = 0; i < 29; i++) {
547  if ((massa[i] % 2) == ((NmenoZ[0] * NmenoZ[0]) % 2)) {jmax = 6;}
548  else {jmax = 5;}
549  for (j = 0; j < jmax; j++) {cout << numev[i][j] << "\t";}
550  cout << '\n';
551  }
552 
553  // close the output file
554  fprintf(fileOUT, "# \n");
555  fclose(fileOUT);
556  cout << '\n';
557 }
558 
559 
560 
561 
562 void cascataAGS(const Int_t r, Int_t nbcas = 1, FILE *fileOUT, const Double_t eccemitter, const BaseGEM random[])
563 {
564 
565  //cout << "nucleo " << r << '\n';
566  // start the Monte-Carlo
567  Cascade cas; GammaLink *gam;
568  Double_t etotg;
569  Int_t risparogamma = 0;
570  for (Int_t i = 0; i < nbcas; i++ ) {
571  if ((AGS[r] == 1) && (risparogamma < 50)) {
572  etotg = 0;
573  random[r].DoCascade(&cas); // next cascade
574  for (Int_t j = 0; j < cas.GetSize(); j++ ) {
575  gam = (GammaLink *)cas.At(j);
576  etotg += gam->GetEnergy().Get();
577  }
578  //cout << "etotg = " << etotg << " |eccemitter = " << eccemitter << '\n';
579  if (etotg >= eccemitter) {
580  //cout << "RISPARO GAMMA" << '\n';
581  risparogamma++;
582  i--;
583  continue;
584  }
585  else {
586  risparogamma = 0;
587  fprintf(fileOUT,"1 %.1f 0. %.1f \n ", (eccemitter - etotg), 0); //gamma di raccordo
588  for (Int_t j = 0; j < cas.GetSize(); j++ ) {
589  gam = (GammaLink *)cas.At(j);
590  fprintf(fileOUT,"1 %.1lf 0. %.1f \n ",gam->GetEnergy().Get(),0.);
591  }
592  //cout << "gammascritti" << "\n\n";
593  }
594  }
595  else {
596  fprintf(fileOUT,"1 %.1lf 0. %.1f \n ", eccemitter, 0.);//gamma di raccordo e basta
597  //cout << "gammascritto" << "\n\n";
598  }
599  }
600 }
601 
602 
603 
604 void matriceRES(FILE *fileIN, Int_t massa[29], Double_t pop[29][6], Double_t popsum[29], Int_t& numpari, Int_t& numdispari, Int_t NmenoZ[11])
605 {
606  //mi porto su OUTPUT OPTIONS
607  char s[256];
608  //int num;
609  fscanf(fileIN, "%s", s);
610  Int_t outputopt = 0;
611  while (outputopt == 0) {
612  while (strcmp(s, "OUTPUT")) fscanf(fileIN, "%s", s);
613  fscanf(fileIN, "%s", s);
614  if (!strcmp(s, "OPTIONS")) {outputopt = 1;}
615  }
616 
617  //mi porto su ------...
618  for (int i=0; i < 15; i++) {
619  fscanf(fileIN, "%s",s);
620  if (!strcmp(s, "------------------------------------------------------------------------------------")) {break;}
621  }
622 
623  fscanf(fileIN, "%s", s); // carico A
624  //Int_t NmenoZ[11];
625  for (int i = 0; i < 11; i++) {fscanf(fileIN, "%d", &NmenoZ[i]);}
626  //Int_t numpari, numdispari;
627 
628  if ((NmenoZ[0] * NmenoZ[0]) % 2) { // se NmenoZ[0] e' dispari
629  numpari = 5;
630  numdispari = 6;
631  }
632  else {
633  numpari = 6;
634  numdispari = 5;
635  }
636  /*
637  fscanf(fileIN, "%s", &s); // carico "(N-Z)"
638 
639  for (i = 0; i < 29; i++) {
640  fscanf(fileIN, "%d", &massa[i]);
641  if (massa[i] % 2) {for (int j = 0; j < numdispari; j++) {fscanf(fileIN, "%lf", &pop[i][j]);}} //se massa[i] e' dispari
642  else {for (j = 0; j < numpari; j++) {fscanf(fileIN, "%lf", &pop[i][j]);}} //se massa[i] e' pari
643  fscanf(fileIN, "%lf", &popsum[i]);
644  fscanf(fileIN, "%s", &s); //carico il grafico
645  }
646  */
647 
648  Char_t Line[300];
649  fgets (Line, 300, fileIN);
650  fgets (Line, 300, fileIN);
651  for (int i = 0; i < 29; i++) {
652  fgets (Line, 300, fileIN);
653  sscanf(Line,"%d",&massa[i]);
654  if ((massa[i]%2) == ((NmenoZ[0]*NmenoZ[0])%2)) sscanf(Line,"%*d%lf%lf%lf%lf%lf%lf%lf", &pop[i][0], &pop[i][1], &pop[i][2], &pop[i][3], &pop[i][4], &pop[i][5], &popsum[i]);
655  else sscanf(Line,"%*d%lf%lf%lf%lf%lf%lf", &pop[i][0], &pop[i][1], &pop[i][2], &pop[i][3], &pop[i][4], &popsum[i]);
656  }
657  //cout << "esco da matriceres\n";
658 
659 }
660 
661 
662 
663 Int_t eccresiduoa(const Double_t &eaemitted, Int_t &Aemitter, Int_t &Zemitter, Double_t &eccemitter, const Double_t* mecalc)
664 {
665  //cout << "mecalc " << mecalc << " *mecalc " << *mecalc << "\n\n";
666  Double_t u = 931494.043;
667  Double_t ma = 3728401.08760000021;
668  //Double_t meemitter = trovame(Aemitter, Zemitter);
669  Double_t meemitter = mecalc[(Aemitter - amin) * rettZ + (Zemitter - zmin)];
670  //cout << "A: " << Aemitter << " Z: " << Zemitter << "massa emitter: " << (meemitter + Aemitter * u)<< '\n';
671  //Double_t meresiduo = trovame((Aemitter - 4), (Zemitter - 2));
672  Double_t meresiduo = mecalc[(Aemitter - 4 - amin) * rettZ + (Zemitter - 2 - zmin)];
673  //cout << "A: " << (Aemitter - 4) << " Z: " << (Zemitter - 2) << "massa residuo: " << (meresiduo + (Aemitter - 4) * u) << '\n';
674  eccemitter = eccemitter + Aemitter * u + meemitter - eaemitted - ma - sqrt(((Aemitter-4)*u + meresiduo) * ((Aemitter-4)*u + meresiduo) + eaemitted * eaemitted + 2 * eaemitted * ma);
675  Aemitter -= 4;
676  Zemitter -= 2;
677  return 0;
678 }
679 
680 
681 
682 Int_t eccresiduop(const Double_t &epemitted, Int_t &Aemitter, Int_t &Zemitter, Double_t &eccemitter, const Double_t* mecalc)
683 {
684  //cout << "mecalc " << mecalc << " *mecalc " << *mecalc << "\n\n";
685  Double_t u = 931494.043;
686  Double_t mp = 938783.013500000038;
687  //Double_t meemitter = trovame(Aemitter, Zemitter);
688  Double_t meemitter = mecalc[(Aemitter - amin) * rettZ + (Zemitter - zmin)];
689  //cout << "A: " << Aemitter << " Z: " << Zemitter << "massa emitter: " << (meemitter + Aemitter * u)<< '\n';
690  //Double_t meresiduo = trovame((Aemitter - 1), (Zemitter - 1));
691  Double_t meresiduo = mecalc[(Aemitter - 1 - amin) * rettZ + (Zemitter - 1 - zmin)];
692  //cout << "A: " << (Aemitter - 1) << " Z: " << (Zemitter - 1)<< "massa residuo: " << (meresiduo + (Aemitter - 1) * u) << '\n';
693  eccemitter = eccemitter + Aemitter * u + meemitter - epemitted - mp - sqrt(((Aemitter-1)*u + meresiduo) * ((Aemitter-1)*u + meresiduo) + epemitted * epemitted + 2 * epemitted * mp);
694  Aemitter -= 1;
695  Zemitter -= 1;
696  return 0;
697 }
698 
699 
700 
701 Int_t eccresiduon(const Double_t &enemitted, Int_t &Aemitter, Int_t &Zemitter, Double_t &eccemitter, const Double_t* mecalc)
702 {
703  //cout << "mecalc " << mecalc << " *mecalc " << *mecalc << "\n\n";
704  Double_t u = 931494.043;
705  Double_t mn = 939565.360100000021;
706  //Double_t meemitter = trovame(Aemitter, Zemitter); //keV
707  Double_t meemitter = mecalc[(Aemitter - amin) * rettZ + (Zemitter - zmin)];
708  //cout << "A: " << Aemitter << " Z: " << Zemitter << "massa emitter: " << (meemitter + Aemitter * u)<< '\n';
709  //Double_t meresiduo = trovame((Aemitter - 1), Zemitter);
710  Double_t meresiduo = mecalc[(Aemitter - 1 - amin) * rettZ + (Zemitter - zmin)];
711  //cout << "A: " << (Aemitter - 1) << " Z: " << Zemitter << "massa residuo: " << (meresiduo + (Aemitter - 1) * u) << '\n';
712  eccemitter = eccemitter + Aemitter * u + meemitter - enemitted - mn - sqrt(((Aemitter-1)*u + meresiduo) * ((Aemitter-1)*u + meresiduo) + enemitted * enemitted + 2 * enemitted * mn);
713  Aemitter -= 1;
714  return 0;
715 }
716 
717 
718 
719 Double_t trovame(Int_t &Anuc, Int_t &Znuc)
720 {
721  Double_t massapar;
722  //me tabulato
723  for (int z = posizA[Anuc]; z < numnuclei; z++) {
724  if ((Znuc == Z[z]) && (Anuc == A[z])) {/*cout << "me tabulato ";*/ return me[z];}
725  }
726 
727  //me non tabulato ma ho nuclei con lo stesso A
728  Int_t numA = 0;
729  for (int z = posizA[Anuc]; z < numnuclei; z++) {
730  if (A[z] == Anuc) numA++; //conta nuclei con massa Anuc
731  else break;
732  }
733  //cout << "posizA Anuc " << posizA[Anuc]<< " numA " << numA << '\n';
734  if (numA >= 3) {
735  massapar = parabolame(Anuc, Znuc, numA);
736  //cout << "massapar " << Znuc << " " << massapar << '\n';
737  //cout << "me da parabola ";
738  return massapar;
739  }
740 
741  //me da stimare
742  Double_t massawei;
743  massawei = wei1(Anuc, Znuc);
744  //cout << "me da weizsacker ";
745  return massawei;
746 
747 }
748 
749 
750 
752 {
753  cout << "numnuclei " << numnuclei << " | ";
754  for (int a = 1; a < A[numnuclei - 1]; a++) {
755  for (int i = 0; i < numnuclei; i++) {
756  if (A[i] == a) {posizA[a] = i; break;}
757  }
758  }
759  cout << "posizioneAin_me OK" << '\n';
760 }
761 
762 
763 
764 void parabola(const Int_t x[], const Double_t y[], const Int_t &Nnuc, Double_t &a, Double_t &b, Double_t &c)
765 {
766  Int_t* x2 = new Int_t[Nnuc];
767  Int_t* x3 = new Int_t[Nnuc];
768  Int_t* x4 = new Int_t[Nnuc];
769  Double_t* xy = new Double_t[Nnuc];
770  Double_t* x2y = new Double_t[Nnuc];
771  for (int i = 0; i < Nnuc; i++) {
772  x2[i] = x[i] * x[i];
773  x3[i] = x2[i] * x[i];
774  x4[i] = x3[i] * x[i];
775  xy[i] = x[i] * y[i];
776  x2y[i] = xy[i] * x[i];
777  }
778  Int_t Sx, Sx2, Sx3, Sx4;
779  Double_t Sy, Sxy, Sx2y;
780  for (int i = 0; i < Nnuc; i++) {
781  Sx += x[i];
782  Sx2 += x2[i];
783  Sx3 += x3[i];
784  Sx4 += x4[i];
785  Sy += y[i];
786  Sxy += xy[i];
787  Sx2y += x2y[i];
788  }
789  Double_t sumel[9];
790  sumel[0] = Sx4;
791  sumel[1] = Sx3;
792  sumel[2] = Sx2;
793  sumel[3] = Sx3;
794  sumel[4] = Sx2;
795  sumel[5] = Sx;
796  sumel[6] = Sx2;
797  sumel[7] = Sx;
798  sumel[8] = Nnuc;
799  TMatrixD sum(3, 3, sumel,0);
800  /*cout << sum[0][0] << " " << sum[0][1] << " " << sum[0][2] << "\n";
801  cout << sum[1][0] << " " << sum[1][1] << " " << sum[1][2] << "\n";
802  cout << sum[2][0] << " " << sum[2][1] << " " << sum[2][2] << "\n";*/
803  Double_t det;
804  TMatrixD sumold = sum;
805  sum.Invert(&det);
806 
807  /*
808  cout << "\n MATRICI\n";
809  cout << sum[0][0] << " \t" << sum[0][1] << " \t" << sum[0][2] <<'\n';
810  cout << sum[1][0] << " \t" << sum[1][1] << " \t" << sum[1][2] <<'\n';
811  cout << sum[2][0] << " \t" << sum[2][1] << " \t" << sum[2][2] <<"\n\n";
812 
813  cout << sumold[0][0] << " \t" << sumold[0][1] << " \t" << sumold[0][2] <<'\n';
814  cout << sumold[1][0] << " \t" << sumold[1][1] << " \t" << sumold[1][2] <<'\n';
815  cout << sumold[2][0] << " \t" << sumold[2][1] << " \t" << sumold[2][2] <<"\n\n";
816 
817  TMatrixD prod(3, 3);
818  for (int h = 0; h < 3; h++){
819  for (int k = 0; k < 3; k++){
820  for (int i = 0; i < 3; i++){
821  prod[h][k] += sum[h][i] * sumold[i][k];
822  }
823  }
824  }
825  cout << prod[0][0] << " \t" << prod[0][1] << " \t" << prod[0][2] <<'\n';
826  cout << prod[1][0] << " \t" << prod[1][1] << " \t" << prod[1][2] <<'\n';
827  cout << prod[2][0] << " \t" << prod[2][1] << " \t" << prod[2][2] <<'\n';
828  */
829 
830  a = sum[0][0] * Sx2y + sum[0][1] * Sxy + sum[0][2] * Sy;
831  b = sum[1][0] * Sx2y + sum[1][1] * Sxy + sum[1][2] * Sy;
832  c = sum[2][0] * Sx2y + sum[2][1] * Sxy + sum[2][2] * Sy;
833 }
834 
835 
836 Double_t parabolame(Int_t &Anuc, Int_t &Znuc, Int_t &numA)
837 {
838  Double_t a, b, c, massa;
839 
840  switch (Anuc%2) {
841  case 0: //pari-pari e diapari-dispari
842  int numAp = 0;
843  Int_t* Znp = new Int_t[numA];
844  Double_t* menp = new Double_t[numA];
845 
846  for (int i = 0; i < numA; i++) {
847  if ((Z[posizA[Anuc] + i]%2) == Znuc%2) {
848  Znp[numAp] = Z[posizA[Anuc] + i];
849  menp[numAp] = me[posizA[Anuc] + i];
850  numAp++;
851  }
852  }
853  parabola(Znp, menp, numAp, a, b, c);
854  massa = a * Znuc * Znuc + b * Znuc + c;
855  //cout << "PARI-PARI DISP-DISP" << "PARI-PARI DISP-DISP" << "PARI-PARI DISP-DISP" << '\n';
856  return massa;
857 
858  case 1: //pari-dispari
859  Int_t* Zn = new Int_t[numA];
860  Double_t* men = new Double_t[numA];
861  //cout << "numA " << numA<< '\n';
862  //for (int i = 0; i < numA; i++) cout << "Z[posizA[Anuc] + i]" << Z[posizA[Anuc] + i] << '\n';
863  for (int i=0; i<numA; i++){
864  Zn[i] = Z[posizA[Anuc] + i];
865  men[i] = me[posizA[Anuc] + i];
866  }
867  //for (int i=0; i<numA; i++) cout << Zn[i] << " " << men[i] << "|";
868  parabola(Zn, men, numA, a, b, c);
869  massa = a * Znuc * Znuc + b * Znuc +c;
870  //cout << "PARI-DISP" << "PARI-DISP" << "PARI-DISP" << "PARI-DISP" << "PARI-DISP" << "PARI-DISP" << '\n';
871  return massa;
872  }
873 
874 }
875 
876 
877 Double_t wei1(Int_t &a, Int_t &z)
878 {
879  double mas;
880  double delt;
881 
882  mas = AV*a;
883  mas -= AS * pow(a, (2./3.));
884  mas -= AC * z * (z-1)/pow(a, (1./3.));
885  mas -= AAS * pow((a-2*z), 2.)/a;
886  /*
887  if( (a/2-floor(a/2)) > 0.30 ) delt = 0.;
888  else if( (z/2-floor(z/2)) > 0.30 ) delt = -APa * pow(a, -0.75);
889  else delt = APa * pow(a, -0.75);
890  */
891  if (a%2 == 1) delt = 0.;
892  else if (z%2 == 1) delt = -APa * pow(a, -0.75);
893  else delt = APa * pow(a, -0.75);
894 
895  mas += delt;
896  mas -= 2*mas;
897  mas += z*MP;
898  mas += (a-z)*MN;
899 
900  mas -= a * 931494.043;
901  return mas;
902 }
903 
904 
905 void trovaAZ(const Int_t &posi, const Int_t &posj, Int_t &posA, Int_t &posZ)
906 {
907  //for (int i = 0; i < 11; i++) cout << "NmenoZ[" << i << "] = " << NmenoZ[i] << '\n';
908  //cout << "posj = " << posj << '\n';
909  //trovo A
910  posA = massa[posi];
911  //trovo N-Z
912  Int_t posNmZ;
913  if ((massa[posi] % 2) == ((NmenoZ[0] * NmenoZ[0]) % 2)) {posNmZ = NmenoZ[2 * posj];}
914  else {posNmZ = NmenoZ[2 * posj + 1];}
915  //cout << "posNmZ = " << posNmZ << '\n';
916  posZ = (posA - posNmZ) / 2;
917 }
918 
void CascadeEvents(const Char_t *finput, Int_t nbcas=100, const Char_t *nameOUT="toGEANT101.event")
TBrowser * b
Int_t rettA
printf("******************************************************************** \n")
A cascade is a list of links.
Definition: Cascade.h:51
#define AC
#define AS
Int_t amin
Class to get randomly cascades of gammas on the basis of a level scheme.
Definition: BaseGEM.h:107
void cascataAGS(const Int_t, Int_t, FILE, const Double_t, const BaseGEM)
This function calculates and writes in a file the gamma cascades.
#define AAS
Int_t zmin
void matriceRES(FILE, Int_t *, Double_t **, Double_t *, Int_t, Int_t, Int_t *)
This function loads the residue nuclei matrix from CASCADE output.
Int_t eccresiduoa(const Double_t &, Int_t &, Int_t &, Double_t &, const Double_t *)
This function calculates the excitation energy after the emission of an alpha particle.
Double_t trovame(Int_t &, Int_t &)
This function return nucleus mass for a given A and Z.
virtual Data_T Get() const
get the value, can be overloaded
Definition: Data.h:70
#define MP
Double_t parabolame(Int_t &, Int_t &, Int_t &)
This function calculates the mass of a nucleus using the 3 coefficients calculated with void parabola...
Int_t NmenoZ[11]
Double_t me[3000]
Int_t massa[29]
Int_t Z[3000]
Double_t wei1(Int_t &, Int_t &)
This function calculates the mass of a nucleus using a semiempirical formula.
Int_t eccresiduop(const Double_t &, Int_t &, Int_t &, Double_t &, const Double_t *)
This function calculate the excitation energy after the emission of a proton.
Int_t numnuclei
Int_t rettZ
void parabola(const Int_t *, const Double_t *, const Int_t &, Double_t &, Double_t &, Double_t &)
This function calculates the coefficients of the parabola for the calculation of the nucleus mass fro...
Int_t A[3000]
void posizioneAin_me()
A bit of output for debug.
#define AV
Int_t numA
Int_t eccresiduon(const Double_t &, Int_t &, Int_t &, Double_t &, const Double_t *)
This function calculate the excitation energy after the emission of a neutron.
virtual Int_t DoCascade(TSeqCollection &cascade, Option_t *opt="")
cascade simulation
Definition: BaseGEM.cpp:523
ADF::LogMessage & endl(ADF::LogMessage &log)
Int_t AGS[200]
#define MN
#define APa
Int_t posizA[3000]
void trovaAZ(const Int_t &, const Int_t &, Int_t &, Int_t &)
This function calculates A and Z of the nucleus from its position in the residue nuclei matrix...