11 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,0)
18 #ifndef Gw_AgataGeometryTransformer
22 #define MAXEMITTED 200
23 #define MAXIMPACTS 1000
29 GeantLMOF::GeantLMOF()
31 SetPath(); fCurrent = -1; fMaxFiles = 0; fStatus = kEmpty; fDistFactor = fEnerFactor = 1.0;
45 fGamma = NULL; fFastOut =
false; SetRecoil();
48 GeantLMOF::~GeantLMOF()
50 if ( fGamma )
delete fGamma; fGamma = NULL;
53 TGeoVolume *GeantLMOF::ImportAgataG4(
const char *asolid,
const char *aclust,
const char *aeuler,
const char *)
55 return AgataGeometryTransformer::ImportAgata(asolid, aclust, aeuler);
58 void GeantLMOF::ShowCurrentConditions()
60 cout <<
"--> Energy Factor " << fEnerFactor <<
" and Distance Factor " << fDistFactor <<
endl;
61 cout <<
"--> Path to data:\n\t" << fPath <<
endl;
62 cout <<
"--> Chain of files: " <<
endl;
63 for (
int i = 0; i < fMaxFiles; i++ ) {
64 if ( i == fCurrent ) cout <<
" [c] ";
66 cout << fEventsRead[i] <<
" events read in " << fFileName[i] <<
endl;
68 cout <<
"--> Recoil: " << fRecoilBeta <<
" " << fRecoilSigma <<
" " << fRecoilDx <<
" " << fRecoilDy <<
" " << fRecoilDz <<
" " << fRecoilAngle <<
endl;
71 void GeantLMOF::ShowCurrentEvent()
75 cout <<
"list of emmited particles " <<
endl;
76 for ( i = 0; i < fNbEmitted; i++ ) {
77 cout <<
" " << fType[i]
82 <<
" " << fEvNum[i] <<
endl;
84 cout <<
"list of impacts " <<
endl;
85 for ( i = 0; i < fNbImpacts; i++ ) {
86 cout <<
" " << fNdet[i]
92 <<
" " << fPrimary[i] <<
endl;
97 void GeantLMOF::ReadHeader()
100 while( fInfile.good() ) {
104 fInfile.getline(buf,MAXCHARACTER);
106 TString id(buf,MAXCHARACTER);
107 if (
id.Contains(
"RECOIL") ) {
108 istringstream theline(buf+6);
110 theline >> fRecoilBeta >> fRecoilSigma >> fRecoilDx >> fRecoilDy >> fRecoilDz >> fRecoilAngle;
112 if (
id.Contains(
"DISTFACTOR") ) {
113 istringstream theline(buf+10);
115 theline >> fDistFactor;
117 if (
id.Contains(
"ENERFACTOR") ) {
118 istringstream theline(buf+10);
120 theline >> fEnerFactor;
123 if ( buf[0] ==
'$' ) {
return; }
125 cout <<
" Cannot find beginning of events $ !! " <<
endl;
126 fInfile.close(); fInfile.
clear(); fStatus = kFail;
129 void GeantLMOF::NextFile()
131 if ( fMaxFiles == 0 ) { fStatus = kEmpty;
return; }
133 if ( fInfile.is_open() ) { fInfile.close(); fInfile.
clear(); }
134 if ( fCurrent < fMaxFiles ) {
135 Int_t
tmp = fCurrent;
136 for (Int_t i = fCurrent+1; i < fMaxFiles; i++ ) {
138 std::string fullname;
139 fullname = fPath; fullname += fFileName[i]; fInfile.open(fullname.data());
141 if ( fInfile.is_open() ) { ReadHeader();
if (fStatus==kGood ) { tmp = i;
break; } }
143 if ( tmp == fCurrent ) { fStatus = kEoE; }
144 else { fCurrent =
tmp; }
146 else { fStatus = kEoE;
return; }
149 UInt_t GeantLMOF::OnlyType(
const GeantLMOF &input, Int_t typemin, Int_t typemax)
151 fNbImpacts = fNbEmitted = 0;
152 for (UInt_t i = 0; i < input.fNbImpacts; i++) {
153 if ( input.fType[input.fPrimary[i]] > typemin && input.fType[input.fPrimary[i]] < typemax + 1 ) {
154 fNdet[fNbImpacts] = input.fNdet[i];
155 fEdep[fNbImpacts] = input.fEdep[i];
156 fPx[fNbImpacts] = input.fPx[i];
157 fPy[fNbImpacts] = input.fPy[i];
158 fPz[fNbImpacts] = input.fPz[i];
159 fNseg[fNbImpacts] = input.fNseg[i];
160 fNInt[fNbImpacts] = input.fNInt[i];
163 for(UInt_t j = 0; j < fNbEmitted; j++ ) {
164 if ( input.fEvNum[i] == fEvNum[j] ) { anew =
false; fPrimary[fNbImpacts] = j;
break; }
167 fType[fNbEmitted] = input.fType[input.fPrimary[i]];
168 fEnergy[fNbEmitted] = input.fEnergy[input.fPrimary[i]];
169 fDx[fNbEmitted] = input.fDx[input.fPrimary[i]];
170 fDy[fNbEmitted] = input.fDy[input.fPrimary[i]];
171 fDz[fNbEmitted] = input.fDz[input.fPrimary[i]];
172 fEvNum[fNbEmitted] = input.fEvNum[input.fPrimary[i]];
174 fPrimary[fNbImpacts] = fNbEmitted++;
185 if ( tracker == NULL ) {
return; }
188 Double_t efactor = GetEnerFactor() / tracker->
GetEnerFactor();
189 Double_t pfactor = GetDistFactor() / tracker->
GetDistFactor();
191 if ( fFastOut ==
true ) {
192 tracker->
SetEvent(fNbImpacts,&fEdep[0],&fPx[0],&fPy[0],&fPz[0],efactor,pfactor);
195 if ( fGamma == NULL ) {
198 fGamma->OnlyType((*
this));
199 tracker->
SetEvent(fGamma->NbImpacts(),&fGamma->GetEdep()[0],
200 &fGamma->GetPx()[0],&fGamma->GetPy()[0],&fGamma->GetPz()[0],efactor,pfactor);
205 Bool_t GeantLMOF::NextEvent(UInt_t asked_mult)
211 if ( !fInfile.is_open() || !fInfile.good() || fStatus != kGood ) { NextFile();
if ( fStatus != kGood )
return kFALSE; }
214 UInt_t mult = asked_mult;
217 while( fInfile.good() ) {
219 Long_t fp = fInfile.tellg();
223 fInfile.getline(buf,MAXCHARACTER); istringstream theline(buf); theline.clear();
226 if (
id == -100 && fNbEmitted > 0 ) {
227 fEventsRead[fCurrent]++;
231 if (
id == -100 ) { mult = kMaxUInt;
continue; }
234 if ( gDebug == 1 ) cout <<
"New source velocity (-101) ... not yet treated " <<
endl;
continue;
237 if ( gDebug == 1 ) cout <<
"New source position (-102) ... not yet treated " <<
endl;
continue;
240 if ( gDebug ) cout <<
"New fTime emission (-103) ... not yet treated " <<
endl;
continue;
243 if ( gDebug == 1 ) cout <<
" Start new impact " << fNbEmitted <<
endl;
247 theline >> e; theline >> x >> y >> z; theline >> n;
249 fNdet[fNbImpacts] = id;
250 fEdep[fNbImpacts] = e;
254 fNseg[fNbImpacts] = n;
256 fPrimary[fNbImpacts] = fNbEmitted-1;
260 if ( gDebug == 1 ) cout <<
"End new impact " <<
endl;
263 if ( gDebug == 1 ) cout <<
"Start new particle " <<
endl;
267 theline >> e; theline >> x >> y >> z; theline >> n;
269 fType[fNbEmitted] = -id;
270 fEnergy[fNbEmitted] = e;
274 fEvNum[fNbEmitted] = n;
278 if ( gDebug == 1 ) cout <<
"End new particle " <<
id <<
" " << fNbEmitted <<
endl;
281 if ( fNbEmitted > mult ) { fInfile.seekg(fp,ios::beg); fNbEmitted--; fEventsRead[fCurrent]+=1.0;
break; }
285 cout <<
" WARNING - Too much emitted particles " << fNbEmitted <<
" or impacts " << fNbImpacts <<
endl;
290 if ( fNbEmitted > 0 )
return kTRUE;
Double_t GetDistFactor() const
Internal unit system for lengths and energies.
std::istream & operator>>(std::istream &is, ADF::FactoryItem &item)
Base class to build tracker families.
Double_t GetEnerFactor() const
virtual UInt_t SetEvent(UInt_t n, const Double_t *e, const Double_t *x, const Double_t *y, const Double_t *z, Double_t efactor=1.0, Double_t pfactor=1.0)
friend LogMessage & clear(LogMessage &)
others
Class to read/decode Geant List Mode Output Files.
ADF::LogMessage & endl(ADF::LogMessage &log)