11 #include <asm/types.h>
16 #include "TGeoManager.h"
17 #include "TClonesArray.h"
18 #include "TVirtualMC.h"
19 #include "TLorentzVector.h"
21 #include <TParticle.h>
22 #include "TObjArray.h"
69 (
"Factory for parameter containers in lib" +
dname->
Name()).Data(),
71 (
dname->
Name() +
" Geometry Parameters").Data(),
72 (
dname->
Name() +
"DefaultContext").Data());
79 int EicDetector::SetEnergyCutOff(Int_t PDG,
const Double_t cutMin,
const Double_t cutMax)
81 if (cutMin <= 0.0 || cutMin >= cutMax)
return -1;
83 if (!_fCutOffMap) _fCutOffMap =
new std::map<Int_t, std::pair<Double_t,Double_t> >();
89 (*_fCutOffMap)[
abs(PDG)] = std::pair<Double_t, Double_t>(cutMin, cutMax);
100 if (fname.BeginsWith(
"/") || fname.BeginsWith(
"./") || fname.BeginsWith(
".."))
179 TParticle *primary = ((
PndStack*)gMC->GetStack())->GetParticle(0);
181 dbEntry->setPrimaryVtx (TVector3(primary->Vx(), primary->Vy(), primary->Vz()));
182 dbEntry->setPrimaryParticleMomentum(TVector3(primary->Px(), primary->Py(), primary->Pz()));
184 Int_t PDG = primary->GetPdgCode();
186 if (_fCutOffMap->find(
abs(PDG)) == _fCutOffMap->end())
188 printf(
"\n *** Primary mother PDG is not present in original MC file map; "
189 "(must be the wrong input MC file)! ***\n\n");
192 dbEntry->setPrimaryParticlePDG(PDG);
194 TClonesArray *arr = fThreadVar->GetArrayPtr();
197 unsigned int hNum = arr->GetEntriesFast();
199 printf(
"--> %4d hits ...\n", hNum);
201 for(
unsigned iq=0; iq<hNum; iq++)
210 if (point->_GetPrimaryMotherID())
214 printf(
"\n *** Primary mother ID is != 0; "
215 "(must be the wrong input MC file and/or generator)! ***\n\n");
221 new((*dbEntry->fHits)[dbEntry->fHits->GetEntriesFast()]) EicFakeMoCaPointDbHit(hit);
225 dbEntry->fHits->Delete();
257 #define _64BIT_VALUE_INVALID_ (~ULong64_t(0))
266 if (!
gptr)
return ret;
277 TString returnBackPath;
280 returnBackPath = gGeoManager->GetPath();
287 TGeoNode *node = lv ? gGeoManager->GetMother(lv) : gGeoManager->GetCurrentNode();
292 lvVolumeIds [lv] = node ? node->GetVolume()->GetNumber() : 0;
293 lvNodeIds [lv] = node ? node-> GetNumber() : 0;
318 cout<<
"-E- Eic"<<
dname->
Name() <<
": " <<
319 "Sensitive volume multi-index too large!" << endl;
322 if (!returnBackPath.IsNull()) gGeoManager->cd(returnBackPath);
336 TString path = gGeoManager->GetPath();
345 gGeoManager->cd(path);
354 if (!returnBackPath.IsNull()) gGeoManager->cd(returnBackPath);
367 Int_t PDG,
bool isPrimary,
368 bool isEntering,
bool isExiting,
372 if (!isEntering && !isExiting)
return;
380 if (!monitor->
mName.EqualTo(name))
continue;
387 if (PDG != monitor->
mPDG)
continue;
396 static unsigned counter = 0;
398 printf(
"%4d (%d .. %d) %d -> %f\n", counter++, isPrimary, monitor->
mPrimaryOnly, isEntering, energy);
405 TAxis *xaxis = monitor->
mHistogram->GetXaxis();
408 if (energy >= xaxis->GetXmin() && energy <= xaxis->GetXmax())
420 fTime = gMC->TrackTime() * 1.0e09;
422 gMC->TrackPosition(
fPosIn);
423 gMC->TrackMomentum(
fMomIn);
440 Int_t trackID = gMC->GetStack()->GetCurrentTrackNumber();
461 if (!wanted && !gMC->TrackCharge())
return kTRUE;
464 if ((gMC->IsTrackEntering() || gMC->IsNewTrack()) &&
gptr) {
468 if (step) gMC->SetMaxStep(step);
474 if (gMC->IsTrackEntering() || gMC->IsNewTrack()) {
485 Int_t PDG = particle->GetPdgCode();
488 if ((_fCutOffMap && !dbFile) && _fCutOffMap->find(
abs(PDG)) != _fCutOffMap->end()) {
490 gMC->TrackMomentum(fMom);
494 double eKin = fMom.E() - particle->GetMass();
496 if (eKin >= (*_fCutOffMap)[
abs(PDG)].first && eKin <= (*_fCutOffMap)[
abs(PDG)].second) {
500 AddFakeMoCaPoint(trackID, GetPrimaryMotherId(), PDG, volumeID, gGeoManager->GetPath(),
517 fStep += gMC->TrackStep();
523 const std::pair<TString, SteppingType> *steppingType =
526 if (steppingType) effectiveSteppingType = steppingType->second;
530 effectiveSteppingType =
fStType;
545 if (effectiveSteppingType ==
qOneStepOneHit || gMC->IsTrackExiting() || gMC->IsTrackStop() ||
546 gMC->IsTrackDisappeared() ) {
547 TLorentzVector fPosOut, fMomOut;
548 gMC->TrackPosition(fPosOut);
549 gMC->TrackMomentum(fMomOut);
553 if (wanted || (gMC->TrackCharge() &&
fELoss)) {
561 AddMoCaPoint(trackID, parents.first, parents.second, volumeID,
603 fFakeMoCaDatabaseFile = TString(outFileName);
604 dbFile =
new TFile(fFakeMoCaDatabaseFile,
"RECREATE");
607 dbTree =
new TTree(
dname->
Name() +
"EicFakeMoCaPointDatabase",
611 dbEntry =
new EicFakeMoCaPointDbEntry();
612 TBranch *branch = dbTree->Branch(
"EicFakeMoCaPointDbEntry",
613 "EicFakeMoCaPointDbEntry", &dbEntry, 16000, 1);
614 branch->SetFile(outFileName);
619 fgeo.GetObject(
dname->
Name() +
"EnergyCutOffTable", _fCutOffMap);
668 dbFile->WriteObject(_fCutOffMap,
dname->
Name() +
"EnergyCutOffTable");
693 cout<<
"-I- Eic"<<
dname->
Name() <<
": " << nHits <<
" points registered in this event." << endl;
703 std::cout<<
" --- Building " <<
dname->
NAME() <<
" Geometry ---"<<std::endl;
764 TGeoVolume *
volume = gGeoManager->GetVolume(
it->Data());
769 "volume attempted (%s)! \033[0m",
it->Data());
794 Bool_t rc = geoFace->
readSet(Geo);
798 std::cerr<<
dname->
Name() <<
"Det:: geometry could not be read!"<<std::endl;
808 TObjArray *fSensNodes = par->GetGeoSensitiveNodes();
809 TObjArray *fPassNodes = par->GetGeoPassiveNodes();
811 TListIter iter(volList);
818 fSensNodes->AddLast( aVol );
820 fPassNodes->AddLast( aVol );