42 struct xqang_ { Float_t sum[15300] ; } xqang_1;
45 static Double_t c_b4 = 1e-15;
50 static Float_t bin[3] = { .1667f,.5f,.8333f };
60 static Long_t l, m, n;
62 static Long_t ii, ik, jk, ll, mm;
63 static Double_t pl[900] ;
65 static Double_t temp, plmm, dsum[15300] ;
78 for (ii = 1; ii <= 3; ++ii) {
81 for (ik = 1; ik <= 300; ++ik) {
82 for (jk = 1; jk <= 50; ++jk) {
84 dsum[ik + jk * 300 - 301] = 0.f;
87 for (iang = 1; iang <= 50; ++iang) {
88 for (iiter = 1; iiter <= 3; ++iiter) {
89 z__ = iang * .02f - bin[iiter - 1];
94 temp = 1.f - d__1 * d__1;
95 pl[31] = TMath::Sqrt(temp);
96 if (TMath::Abs(pl[31]) < 1e-15) {
97 pl[31] = TMath::Sign(c_b4, pl[31]);
101 pl[2] = (d__1 * d__1 * 3.f - 1.f) * .5f;
102 pl[32] = pl[31] * 3.f * z__;
104 for (l = 4; l <= 24; ++l) {
106 pl[l - 1] = (((ll << 1) - 1) * z__ * pl[l - 2] - (ll - 1) *
108 pl[l + 29] = (((ll << 1) - 1) * z__ * pl[l + 28] - ll * pl[l
111 for (m = 3; m <= i__1; ++m) {
113 pl[l + m * 30 - 31] = (ll + mm - 1) * pl[l - 1 + (m - 1) *
114 30 - 31] - (ll - mm + 1) * z__ * pl[l + (m - 1) *
116 pl[l + m * 30 - 31] /= pl[31];
121 for (l = 1; l <= 24; ++l) {
123 for (m = 1; m <= i__1; ++m) {
124 plmm = pl[l + m * 30 - 31] * 1e-10f;
125 if (l > 11 && m > (l - 1) / 2) {
126 plmm = pl[l + m * 30 - 31] * 1e-20f;
128 n = l * (l - 1) / 2 + m;
132 dsum[n + iang * 300 - 301] += d__1 * d__1;
139 for (n = 1; n <= 300; ++n) {
140 for (iang = 2; iang <= 50; ++iang) {
142 dsum[n + iang * 300 - 301] += dsum[n + (iang - 1) * 300 - 301];
144 if (dsum[n + 14699] == 0.f) {
145 dsum[n + 14699] = 1e-20;
147 for (iang = 1; iang <= 50; ++iang) {
148 dsum[n + iang * 300 - 301] /= dsum[n + 14699];
150 xqang_1.sum[n + iang * 300 - 301] = dsum[n + iang * 300 - 301];
157 Int_t getang_(Int_t *l, Int_t *m, Float_t *ct, Float_t *theta, Float_t *phi)
160 static Short_t isetup = 0;
168 static Int_t im, ict;
181 n = (*l) * (*l + 1) / 2 + im + 1;
183 for (ict = 1; ict <= 50; ++ict) {
185 if (x <= xqang_1.sum[n + ict * 300 - 301]) {
191 *ct = (*ct -
therand->Rndm()) * .02f;
197 *phi =
therand->Rndm() * 6.2831853999999998f;
198 *theta = TMath::ACos(*ct);
208 Short_t EvapLMOF::VERBOSE = 0;
209 const Short_t EvapLMOF::MAXCASCADE;
const Short_t EvapLMOF::MAXPARTICLES;
211 EvapLMOF::EvapLMOF() : fHeader(NULL), fGlobalRecord(NULL), fIdRecord(NULL), fDataRecord(NULL), fIdOnly(false), fInfile(NULL), fCurrent(-1), fMaxFiles(0), fStatus(kEmpty)
220 if ( fHeader != NULL ) {
222 delete fHeader; fHeader = NULL;
224 if ( fGlobalRecord != NULL ) {
226 delete fGlobalRecord; fGlobalRecord = NULL;
228 if ( fIdRecord != NULL ) {
230 delete fIdRecord; fIdRecord= NULL;
232 if ( fDataRecord != NULL ) {
234 delete fDataRecord; fDataRecord = NULL;
237 if ( fInfile ) { ::fclose(fInfile); fInfile = NULL; }
244 out <<
"--> Path to data:\n\t" << fPath <<
endl;
245 out <<
"--> Chain of files: " <<
endl;
246 for (
int i = 0; i < fMaxFiles; i++ ) {
247 if ( i == fCurrent ) cout <<
" [c] ";
249 out << fEventsRead[i] <<
" events read in " << fFileName[i] <<
endl;
251 if ( fWarning !=
"" ) out <<
" Warning: " << fWarning.Data() <<
endl;
252 if ( fStatus ==
kFail ) out <<
" Last Error: " << fError.Data() <<
endl;
253 if ( fStatus ==
kEoE ) out <<
" All events have been read " <<
endl;
260 out <<
" -- GLOBAL RECORD " <<
endl;
261 out <<
"AC: " << fGlobal.AC <<
", ZC: " << fGlobal.ZC <<
", NCASC: " << fGlobal.NCASC <<
", MDIR: " << fGlobal.MDIR
262 <<
", JCAS: " << fGlobal.JCASC <<
", ENER: " << fGlobal.ENER <<
", SIGMA: " << fGlobal.SIGMA
263 <<
", VRC: " << fGlobal.VRC <<
", MAX_P: " << fGlobal.MAX_P <<
endl;
264 out <<
" -- ID RECORD " <<
endl;
265 out <<
"MG: " << fId.MG <<
", EE: " << fId.EE <<
", JE: " << fId.JE <<
", L: " << fId.L
266 <<
", Z: " << fId.Z <<
", N: " << fId.N <<
", NUM: " << fId.NUM
267 <<
", WT: " << fId.WT <<
", FIS: " << fId.FIS <<
endl;
269 if ( fIdOnly )
return;
271 out <<
" -- DATA RECORD " <<
endl;
272 for ( i = 0; i < fId.NUM; i++ ) {
273 out <<
"Cascade " << i << endl <<
"MODE: " << fData.MODE[i] <<
", EI: " << fData.EI[i] <<
", JI: " << fData.JI[i] <<
", EP: " << fData.EP[i] <<
", LP: " << fData.LP[i] <<
", MP: " << fData.MP[i] <<
endl;
274 out <<
"VE0: " << fKin.VE[i][0] <<
", VE1: " << fKin.VE[i][1] <<
", VE2: " << fKin.VE[i][2] <<
", THETA: " << fKin.THETA[i] <<
", PHI: " << fKin.PHI[i] <<
", EEJ: " << fKin.EEJ[i] <<
", JF: " << fKin.JF[i] <<
endl;
277 if ( fData.MUL[i] > 0 ) out <<
" MODE " << i <<
" MULT: " << fData.MUL[i] <<
", ES: " << fData.ES[i] <<
", DJ: " << fData.DJ[i] <<
endl;
279 out <<
"ZB: " << fKin.ZB <<
", AB: " << fKin.AB <<
", ER: " << fKin.ER <<
", VO0: " << fKin.V0[0] <<
", VO1: " << fKin.V0[1] <<
", VO2: " << fKin.V0[2] <<
endl;
286 if ( fHeader != NULL ) {
290 else {
delete fHeader; fHeader = NULL; }
294 if ( fGlobalRecord != NULL ) {
295 if ( fGlobalRecord->
IsBytes(e) ) {
296 fGlobalRecord->
Reset();
298 else {
delete fGlobalRecord; fGlobalRecord = NULL; }
303 if ( fIdRecord != NULL ) {
307 else {
delete fIdRecord; fIdRecord = NULL; }
312 if ( fDataRecord != NULL ) {
313 if ( fDataRecord->
IsBytes(e) ) {
314 fDataRecord->
Reset();
316 else {
delete fDataRecord; fDataRecord = NULL; }
323 void EvapLMOF::ReadHeader()
328 Int_t magic1 = 0, magic2 = 0;
332 ::fread(&magic1,
sizeof(Int_t),1,fInfile); ::fread(&magic2,
sizeof(Int_t),1,fInfile);
333 if ( ::ferror(fInfile) == 0 ) {
335 if ( magic1 == 0x00000028 && magic2 == 0x77777777 ) { SetRecord(
Gws::Memory::kLittle);
return; }
336 if ( magic1 == 0x28000000 && magic2 == 0x77777777 ) { SetRecord(
Gws::Memory::kBig);
return; }
338 ::fclose(fInfile); fInfile = NULL; fStatus =
kFail;
347 if ( fMaxFiles == 0 ) { fStatus =
kEmpty;
return; }
350 if ( fInfile ) {
if ( ::ferror(fInfile) ) cout <<
"WARNING: ferror detected in EvapLMOF::NextFile" <<
endl; ::fclose(fInfile); fInfile = NULL; }
352 if ( fCurrent < fMaxFiles ) {
353 Int_t
tmp = fCurrent;
354 for (Int_t i = fCurrent+1; i < fMaxFiles; i++ ) {
356 std::string fullname;
357 fullname = fPath; fullname += fFileName[i]; fInfile = ::fopen(fullname.data(),
"r");
359 if ( fInfile ) { ReadHeader();
if (fStatus==
kGood ) { tmp = i;
break; } }
361 if ( tmp == fCurrent ) { fStatus =
kEoE; }
362 else { fCurrent =
tmp; }
364 else { fStatus =
kEoE; }
369 Bool_t EvapLMOF::ReadGlobal()
373 ::fread(fGlobalRecord->
GetBuffer(),fGlobalRecord->
Size(),1,fInfile);
if ( ::ferror(fInfile) != 0 )
return kFALSE;
377 (*fGlobalRecord) >> id;
if (
id != 0x77777777 ) { fError =
" Wrong GLOBAL record id ";
return kFALSE; }
379 (*fGlobalRecord) >> fGlobal.ZC;
380 (*fGlobalRecord) >> fGlobal.AC;
381 (*fGlobalRecord) >> fGlobal.NCASC;
382 (*fGlobalRecord) >> fGlobal.MDIR;
383 (*fGlobalRecord) >> fGlobal.JCASC;
384 (*fGlobalRecord) >> fGlobal.ENER;
385 (*fGlobalRecord) >> fGlobal.SIGMA;
386 (*fGlobalRecord) >> fGlobal.VRC;
387 (*fGlobalRecord) >> fGlobal.MAX_P;
392 Bool_t EvapLMOF::ReadId()
394 Short_t id, idok = 0xFFFF, idfission = 0xFFEE, idnodata = 0xFFFD; Char_t c; UChar_t uc;
396 ::fread(fIdRecord->
GetBuffer(),fIdRecord->
Size(),1,fInfile);
if ( ::ferror(fInfile) != 0 )
return kFALSE;
401 if ( !(
id == idok ||
id == idfission ||
id == idnodata) ) { fError =
" Wrong ID record ";
return kFALSE; }
403 if (
id == idfission ) fId.FIS = kTRUE;
404 else fId.FIS = kFALSE;
408 (*fIdRecord) >> id; fId.EE = id;
409 (*fIdRecord) >> uc; fId.JE = Short_t(uc);
410 (*fIdRecord) >> uc; fId.L = Short_t(uc);
411 (*fIdRecord) >> uc; fId.N = Short_t(uc);
412 (*fIdRecord) >> c; fId.Z = Short_t(c);
if ( c < 0 ) { fId.Z = - Short_t(c); fId.FIS = kTRUE; }
413 (*fIdRecord) >> fId.WT;
414 (*fIdRecord) >> fId.NUM;
416 if (
id == idnodata ) fId.NUM = 0;
421 Bool_t EvapLMOF::ReadData()
426 const Short_t zp[
MAXPARTICLES] = { 0,0,1,2,1,1,2,3,8,0,0,0 };
427 const Short_t ap[
MAXPARTICLES] = { 0,1,1,4,2,3,3,6,16,0,0,0 };
429 Int_t lengthstart, lengthend; Short_t id, dz, da; Char_t c;
435 if ( lengthstart > (Int_t)fDataRecord->
Size() || fId.NUM >
MAXCASCADE )
436 { fWarning =
" Large cascade reached and skipped "; ::fseek(fInfile,lengthstart,SEEK_CUR); decode = kFALSE; }
438 ::fread(fDataRecord->
GetBuffer(),lengthstart,1,fInfile);
443 if ( ::ferror(fInfile) != 0 ) { fError =
" PB to read data record from file ";
return kFALSE; }
444 if ( lengthstart != lengthend ) { fError =
" Start and end size of data record don't match ";
return kFALSE; }
446 if ( fIdOnly || decode == kFALSE )
return kTRUE;
450 ::memset(&fData,0,
sizeof(fData)); ::memset(&fKin,0,
sizeof(fKin)); fKin.ZB = fId.Z; fKin.AB = fId.Z + fId.N;
453 for (Short_t i = 0; i < fId.NUM; i++ ) {
454 (*fDataRecord) >> id; fData.EP[i] =
id / 10.;
455 (*fDataRecord) >> id; fData.EI[i] = id;
457 (*fDataRecord) >> c; fData.MODE[i] = Short_t(c);
458 (*fDataRecord) >> c; fData.JI[i] = Short_t(c);
459 (*fDataRecord) >> c; fData.MP[i] = Short_t(c);
460 (*fDataRecord) >> c; fData.LP[i] = Short_t(c);
463 if ( fData.MODE[i] <= fGlobal.MAX_P ) {
464 dz = zp[fData.MODE[i]];
465 da = ap[fData.MODE[i]];
475 if ( fData.MODE[i] == fGlobal.MAX_P + 4 ) {
476 fData.MUL[fGlobal.MAX_P+4] = fData.LP[i];
478 fData.ES[fGlobal.MAX_P+4] = fData.EI[i];
481 fData.MUL[fData.MODE[i]] += 1 ;
482 fData.ES[fData.MODE[i]] += fData.EP[i];
484 if ( fData.MODE[i] == fGlobal.MAX_P + 3 ) fId.FIS = kTRUE;
487 fId.MG = fData.MUL[fGlobal.MAX_P+1] + fData.MUL[fGlobal.MAX_P+2] + fData.MUL[fGlobal.MAX_P+4];
490 fKin.V0[0] = fGlobal.VRC * fGlobal.MDIR;
492 fKin.V0[2] = fGlobal.VRC * (1.0 - fGlobal.MDIR);
494 Int_t ac_run = fGlobal.AC, ar = ac_run, ml; Float_t vl[3], ct, avl, fug;
496 const Float_t massu = 931.5;
498 for (Short_t i = 0; i < fId.NUM; i++ ) {
500 Short_t jmode = fData.MODE[i];
502 if ( i < fId.NUM-1 ) {
503 fData.DJ[jmode] = fData.DJ[jmode] + fData.JI[i] - fData.JI[i+1];
504 fKin.JF[i] = fData.JI[i+1];
505 ml = fData.MP[i] - fData.MP[i+1];
508 if( jmode <= fGlobal.MAX_P ) {
509 fKin.JF[i] = fData.JI[i]; ml = 0;
512 if( jmode == (fGlobal.MAX_P + 1) ) { fKin.JF[i] = fData.JI[i]; ml = 0; }
514 if( jmode == (fGlobal.MAX_P + 2) ) {
516 fKin.JF[i] = fData.JI[i]-2; fData.DJ[jmode] += 2;
521 Int_t ll = fData.LP[i], al;
523 if ( jmode <= fGlobal.MAX_P ) al = ap[jmode] ;
525 getang_(&ll,&ml,&ct,&fKin.THETA[i],&fKin.PHI[i]);
527 Double_t st = TMath::Sin(fKin.THETA[i]);
528 Double_t cp = TMath::Cos(fKin.PHI[i]);
529 Double_t sp = TMath::Sin(fKin.PHI[i]);
531 ar = ac_run - al; avl = TMath::Sqrt(2.*fData.EP[i]/(massu*al)); fug= al / ar ;
537 for (Int_t j = 0; j < 3; j++ ) {
538 fKin.VE[i][j] = fKin.V0[j] + vl[j];
539 fKin.V0[j] = fKin.V0[j] - fug*vl[j];
544 for (Int_t j = 0; j < 3; j++ ) {
548 fKin.EEJ[i] = 0.5 * al * massu * ( fKin.VE[i][0]*fKin.VE[i][0] + fKin.VE[i][1]*fKin.VE[i][1] + fKin.VE[i][2]*fKin.VE[i][2] );
550 fKin.ER = 0.5 * ar * massu * ( fKin.V0[0]*fKin.V0[0] + fKin.V0[1]*fKin.V0[1] + fKin.V0[2]*fKin.V0[2] );
559 if ( fInfile ) { ::fclose(fInfile); fInfile = NULL; }
565 fCurrent = -1;
for ( Int_t i = 0; i < fMaxFiles; i++ ) { fEventsRead[i] = 0.0; }
574 Int_t bsize; Bool_t isok;
578 if ( fInfile == NULL || ::ferror(fInfile) != 0 || fStatus !=
kGood ) {
NextFile();
if ( fStatus !=
kGood )
return kFALSE; }
580 isok = kTRUE; ::fread(fHeader->
GetBuffer(),fHeader->
Size(),1,fInfile);
582 if ( ::feof(fInfile) != 0 ) {
584 if ( fStatus !=
kGood )
return kFALSE;
585 else ::fread(fHeader->
GetBuffer(),fHeader->
Size(),1,fInfile);
587 if ( ::ferror(fInfile) == 0 ) {
589 fHeader->
SetOffset(); (*fHeader) >> bsize ;
594 if ( ReadGlobal() == kFALSE )
595 { fStatus =
kFail;
return kFALSE; }
597 else { ::fread(fHeader->
GetBuffer(),fHeader->
Size(),1,fInfile); fHeader->
SetOffset(); (*fHeader) >> bsize ; }
600 if ( ReadId() == kFALSE ) { fStatus =
kFail;
return kFALSE; }
602 if ( ReadData() == kFALSE ) {
603 fStatus =
kFail;
return kFALSE;
605 else fEventsRead[fCurrent] += 1.0;
608 else { fError =
"Wrong size at position "; fError += (::ftell(fInfile)); fStatus =
kFail; isok = kFALSE; }
610 else { fStatus =
kFail; isok = kFALSE; }
624 for (UInt_t i = 1; i < end+1; i++ ) {
625 if (
NextEvent() == kFALSE ) { stop = i;
break; }
629 cout <<
" !!!!! Breaking at Event # " << stop <<
endl; cout << fError.Data() <<
endl;
635 TLeaf *leaf = NULL; TString
tmp = leafname;
638 if ( tmp ==
"AC" ) { leaf =
new TLeafI(); leaf->SetAddress(&fGlobal.AC); }
639 if ( tmp ==
"ZC" ) { leaf =
new TLeafI(); leaf->SetAddress(&fGlobal.ZC); }
640 if ( tmp ==
"NCASC" ) { leaf =
new TLeafI(); leaf->SetAddress(&fGlobal.NCASC); }
641 if ( tmp ==
"MDIR" ) { leaf =
new TLeafI(); leaf->SetAddress(&fGlobal.MDIR); }
642 if ( tmp ==
"JCASC" ) { leaf =
new TLeafI(); leaf->SetAddress(&fGlobal.JCASC); }
643 if ( tmp ==
"ENER" ) { leaf =
new TLeafF(); leaf->SetAddress(&fGlobal.ENER); }
644 if ( tmp ==
"SIGMA" ) { leaf =
new TLeafF(); leaf->SetAddress(&fGlobal.SIGMA);}
645 if ( tmp ==
"VRC" ) { leaf =
new TLeafF(); leaf->SetAddress(&fGlobal.VRC);}
646 if ( tmp ==
"MAX_P" ) { leaf =
new TLeafI(); leaf->SetAddress(&fGlobal.MAX_P);}
649 if ( tmp ==
"MG" ) { leaf =
new TLeafS(); leaf->SetAddress(&fId.MG); }
650 if ( tmp ==
"EE" ) { leaf =
new TLeafF(); leaf->SetAddress(&fId.EE); }
651 if ( tmp ==
"JE" ) { leaf =
new TLeafF(); leaf->SetAddress(&fId.JE); }
652 if ( tmp ==
"L" ) { leaf =
new TLeafF(); leaf->SetAddress(&fId.L); }
653 if ( tmp ==
"Z" ) { leaf =
new TLeafS(); leaf->SetAddress(&fId.Z); }
654 if ( tmp ==
"N" ) { leaf =
new TLeafS(); leaf->SetAddress(&fId.N); }
655 if ( tmp ==
"NUM" ) { leaf =
new TLeafS(); leaf->SetAddress(&fId.NUM); }
656 if ( tmp ==
"WT" ) { leaf =
new TLeafF(); leaf->SetAddress(&fId.WT); }
657 if ( tmp ==
"FIS" ) { leaf =
new TLeafB(); leaf->SetAddress(&fId.FIS);}
660 if ( tmp ==
"MODE" ) { leaf =
new TLeafS(); leaf->SetAddress(fData.MODE); }
661 if ( tmp ==
"EI" ) { leaf =
new TLeafF(); leaf->SetAddress(fData.EI); }
662 if ( tmp ==
"EP" ) { leaf =
new TLeafF(); leaf->SetAddress(fData.EP); }
663 if ( tmp ==
"JI" ) { leaf =
new TLeafS(); leaf->SetAddress(fData.JI); }
664 if ( tmp ==
"LP" ) { leaf =
new TLeafS(); leaf->SetAddress(fData.LP); }
665 if ( tmp ==
"MP" ) { leaf =
new TLeafS(); leaf->SetAddress(fData.MP); }
666 if ( tmp ==
"MUL" ) { leaf =
new TLeafS(); leaf->SetAddress(fData.MUL); }
667 if ( tmp ==
"ES" ) { leaf =
new TLeafF(); leaf->SetAddress(fData.ES); }
668 if ( tmp ==
"DJ" ) { leaf =
new TLeafF(); leaf->SetAddress(fData.DJ);}
671 if ( tmp ==
"V0" ) { leaf =
new TLeafF(); leaf->SetAddress(fKin.V0); }
672 if ( tmp ==
"VE" ) { leaf =
new TLeafF(); leaf->SetAddress(fKin.VE); }
673 if ( tmp ==
"THETA" ){ leaf =
new TLeafF(); leaf->SetAddress(fKin.THETA); }
674 if ( tmp ==
"PHI" ) { leaf =
new TLeafF(); leaf->SetAddress(fKin.PHI); }
675 if ( tmp ==
"ZB" ) { leaf =
new TLeafS(); leaf->SetAddress(&fKin.ZB); }
676 if ( tmp ==
"AB" ) { leaf =
new TLeafS(); leaf->SetAddress(&fKin.AB); }
677 if ( tmp ==
"ER" ) { leaf =
new TLeafF(); leaf->SetAddress(&fKin.ER); }
678 if ( tmp ==
"EEJ" ) { leaf =
new TLeafF(); leaf->SetAddress(fKin.EEJ); }
679 if ( tmp ==
"JF" ) { leaf =
new TLeafF(); leaf->SetAddress(fKin.JF);}
EEndian
The adjectives big-endian and little-endian refer to which bytes are most significant in multi-byte d...
void ShowCurrentEvent(std::ostream &out=std::cout)
The show the content of the current event on the standard ouput.
void Rewind()
To restart the data stream from the beginning.
void ShowCurrentConditions(std::ostream &out=std::cout)
The current status is shown on the standard ouptut.
TLeaf * GetLeaf(const char *leafname="no")
To get a ROOT leaf corresponding to one of the variable.
UInt_t Size() const
it returns the maximum number of bytes in this buffer
virtual void Reset()
Reset means set all elements to 0 and the current position is 0.
void SetPath(const char *path="./")
set the directory where to find the input files
void Scan(UInt_t start=0, UInt_t end=10)
To scan events and show them on the standard output.
void NextFile()
switch to next file.
static Buffer * New(Memory::EEndian e, UInt_t s=32 *KBYTE)
copy n bytes from one buffer to another one
UInt_t SetOffset(UInt_t off=0)
change the current position.
ADF::LogMessage & endl(ADF::LogMessage &log)
static const Short_t MAXPARTICLES
static Short_t VERBOSE
Set verbosity level.
Bool_t NextEvent(UInt_t next=0)
To load the next event.
Char_t * GetBuffer()
Pointer to the underlying array of chars.
bool IsStatus(Buffer::EStatus)
bool IsBytes(Memory::EEndian) const
static const Short_t MAXCASCADE