16 #include "FairGeoInterface.h" 
   17 #include "FairGeoLoader.h" 
   18 #include "FairGeoMedia.h" 
   19 #include "FairGeoNode.h" 
   21 #include "FairGeoRootBuilder.h" 
   23 #include "FairGeoMedium.h" 
   24 #include "FairRootManager.h" 
   25 #include "FairModule.h" 
   26 #include "FairVolume.h" 
   30 #include "FairRuntimeDb.h" 
   31 #include "TObjArray.h" 
   34 #include "TClonesArray.h" 
   35 #include "TGeoMCGeometry.h" 
   36 #include "TGeoManager.h" 
   37 #include "TLorentzVector.h" 
   38 #include "TParticle.h" 
   39 #include "TVirtualMC.h" 
   40 #include "TGeoSphere.h" 
   43 #include "TGeoCompositeShape.h" 
   44 #include "TGeoVoxelFinder.h" 
   45 #include "TGeoMatrix.h" 
   69   : FairDetector(name, active) 
 
  119   FairRun* 
sim = FairRun::Instance();
 
  120   FairRuntimeDb* 
rtdb=sim->GetRuntimeDb();
 
  139   Int_t copyNo = -1, 
id = -1;
 
  146   if ((nam.BeginsWith(
"Crystal"))) 
 
  150                 if ( gMC->IsTrackEntering() ) 
 
  152                         fTrackID = gMC->GetStack()->GetCurrentTrackNumber(); 
 
  159                         fTime =  gMC->TrackTime()* 1.0e09;
 
  160                         gMC->TrackPosition(
fPos); 
 
  161                         gMC->TrackMomentum(
fMom); 
 
  174     if ( gMC->IsTrackExiting()    ||
 
  175                                         gMC->IsTrackStop()       ||
 
  176                                         gMC->IsTrackDisappeared()) 
 
  193                         fnCopy = vol->getCopyNo();
 
  194                         cout << 
" Vol Name: " << gMC->CurrentVolPath() <<
" vol id "<<vol->getMCid()<<
" copyNo "<<vol->getCopyNo()<< endl;       
 
  208   if (nam.BeginsWith(
"Cryostat")|| nam.BeginsWith(
"Capsule") )
 
  212                 if ( gMC->IsTrackEntering() ) 
 
  214                                 fTrackID = gMC->GetStack()->GetCurrentTrackNumber(); 
 
  221                                 fTime =  gMC->TrackTime()* 1.0e09;
 
  222                                 gMC->TrackPosition(
fPos); 
 
  223                                 gMC->TrackMomentum(
fMom); 
 
  233     if ( gMC->IsTrackExiting()    ||
 
  234            gMC->IsTrackStop()       ||
 
  235            gMC->IsTrackDisappeared()) 
 
  250                         fnCopy = vol->getCopyNo();
 
  251                         cout << 
" Vol Name: " << gMC->CurrentVolPath() <<
" vol id " 
  252                         <<vol->getMCid()<<
" copyNo "<<vol->getCopyNo()<< endl;  
 
  273   if (fVerboseLevel)  
Print();
 
  281   FairRootManager::Instance()->Register(
"HypGePoint",
"HypGe", 
fHypGeCollection, kTRUE);
 
  282   FairRootManager::Instance()->Register(
"HypGeAlPoint",
"HypGeAl", 
fHypGeAlCollection, kTRUE);
 
  301     cout << 
"-I- PndHypGe: " << nHits << 
" points registered in this event." 
  326   Int_t nEntries = cl1->GetEntriesFast();
 
  328   TClonesArray& clref = *cl2;
 
  330   for (Int_t 
i=0; 
i<nEntries; 
i++) {
 
  337   cout << 
" -I- PndHypGe: " << cl2->GetEntriesFast() << 
" merged entries." 
  344   TString fileName=GetGeometryFileName();
 
  346   if(fileName.EndsWith(
".root"))
 
  348     ConstructRootGeometry();
 
  359   cout<<
"----- constructing HPGe Geometry default -----"<<endl;
 
  363   FairGeoLoader*
geoLoad = FairGeoLoader::Instance();
 
  364   FairGeoInterface *
geoFace = geoLoad->getGeoInterface();
 
  365   FairGeoMedia *
Media =  geoFace->getMedia();
 
  366   FairGeoBuilder *
geobuild=geoLoad->getGeoBuilder();
 
  368   FairGeoMedium *medGe  = Media->getMedium(
"germanium");
 
  369   Int_t nmedGe=geobuild->createMedium(medGe);
 
  372   FairGeoMedium *medsci  = Media->getMedium(
"polypropylene");
 
  373   Int_t nmedsci=geobuild->createMedium(medsci);
 
  376   FairGeoMedium *medcap  = Media->getMedium(
"HYPaluminium");
 
  377   Int_t nmedcap=geobuild->createMedium(medcap);
 
  384    TGeoVolume *sphere = 
new TGeoVolumeAssembly(
"sphere");
 
  386   TGeoTube* Crystal_Tube = 
new TGeoTube(
"tube",0.,7.0/2.,7.8/2.);
 
  388   cout<< 
"tube fZ[%i]=%5.2f  fRmin[%i]=%5.2f  fRmax[%i]=%5.2f"<<
" " 
  389       <<
" "<<Crystal_Tube->GetDZ()<<
" " 
  390       <<Crystal_Tube->GetRmin()<<
" " 
  391       <<Crystal_Tube->GetRmax()<<endl;
 
  393   TGeoPgon* Crystal_Polyhedra = 
new TGeoPgon(
"Pgon",0., 360., 6,2);
 
  395   Crystal_Polyhedra->DefineSection(0,-3.9,0.,3.50*
cos(30.*deg));
 
  396   Crystal_Polyhedra->DefineSection(1,3.9,0.,(3.50));
 
  399   TGeoPgon* lay_sci = 
new TGeoPgon(
"PgLay",0., 360., 6,2);
 
  402      lay_sci->DefineSection(0,-0.25,0.,3.50*
cos(30.*deg));
 
  403      lay_sci->DefineSection(1,0.25,0.,(3.50)*
cos(30.*deg));
 
  407   TGeoPgon* lay_capl = 
new TGeoPgon(
"PgcapL",0., 360., 6,2);
 
  410   lay_capl->DefineSection(0,-4.2,0.,3.144);
 
  411   lay_capl->DefineSection(1,4.2,0.,(3.627));
 
  413   TGeoPgon* lay_caps = 
new TGeoPgon(
"PgcapS",0., 360., 6,2);
 
  416   lay_caps->DefineSection(0,-3.95,0.,3.078);
 
  417   lay_caps->DefineSection(1,3.95,0.,(3.553));
 
  419   for (Int_t j=0; j<Crystal_Polyhedra->GetNz(); j++) {
 
  421     cout<< 
"fZ[%i]=%5.2f  fRmin[%i]=%5.2f  fRmax[%i]=%5.2f"<<
" " 
  422         << j<<
" "<<Crystal_Polyhedra->GetZ()[j]<<
" " 
  423         <<Crystal_Polyhedra->GetRmin()[j]<<
" " 
  424         <<Crystal_Polyhedra->GetRmax()[j]<<endl;
 
  431   TGeoPgon* logicCrystal_test;
 
  432   logicCrystal_test = Crystal_Polyhedra ;
 
  433   TGeoCompositeShape* lay_cap = 
new TGeoCompositeShape(
"test",
"(PgcapL)-(PgcapS)");
 
  435   TList *ClusterList=0;
 
  436   TList *ClusterList1=0;
 
  437   TList *ClusterList2=0;
 
  438   TList *ClusterList3=0;
 
  439   TList *ClusterList4=0;
 
  440   TList *ClusterList5=0;
 
  441   TList *ClusterList6=0;
 
  442   TList *ClusterList7=0;
 
  443   TList *ClusterList8=0;
 
  444   TList *ClusterList9=0;
 
  445   TList *ClusterList10=0;
 
  446   TList *ClusterList11=0;
 
  447   TList *ClusterList12=0;
 
  448   TList *ClusterList13=0;
 
  449   TList *ClusterList14=0;
 
  457    ClusterList=HypGe->
CreateCluster(logicCrystal_test,lay_sci,lay_cap,*sphere,
 
  458                                       30.0, 168.0, 90., 2.0,1000); 
 
  460    for(Int_t 
i=0;
i<ClusterList->GetSize();
i++){
 
  461      AddSensitiveVolume((TGeoVolume *) ClusterList->At(
i));
 
  464    ClusterList1 = HypGe->
CreateCluster(logicCrystal_test,lay_sci,lay_cap,*sphere,
 
  465                                        30.0, 168.0,18, 2.0,1200); 
 
  467    for(Int_t 
i=0;
i<ClusterList1->GetSize();
i++)
 
  469        AddSensitiveVolume((TGeoVolume *) ClusterList1->At(
i));
 
  472    ClusterList2 =  HypGe->
CreateCluster(logicCrystal_test,lay_sci,lay_cap,*sphere,
 
  473                                         30.1, 168.0, 162, 2.0,400); 
 
  475    for(Int_t 
i=0;
i<ClusterList2->GetSize();
i++)
 
  477        AddSensitiveVolume((TGeoVolume *) ClusterList2->At(
i));
 
  480    ClusterList3 =  HypGe->
CreateCluster(logicCrystal_test,lay_sci,lay_cap,*sphere,
 
  481                                         30.3, 168.0, 234, 2.0,600); 
 
  483     for(Int_t 
i=0;
i<ClusterList3->GetSize();
i++)
 
  485        AddSensitiveVolume((TGeoVolume *) ClusterList3->At(
i));
 
  488      ClusterList9 =  HypGe->
CreateCluster(logicCrystal_test,lay_sci,lay_cap,*sphere,
 
  489                                         30., 168.0, 306., 2.0,1400); 
 
  491     for(Int_t 
i=0;
i<ClusterList9->GetSize();
i++)
 
  493        AddSensitiveVolume((TGeoVolume *) ClusterList9->At(
i));
 
  495    ClusterList4 =   HypGe->
CreateCluster(logicCrystal_test,lay_sci,lay_cap,*sphere,32.2,
 
  496                                          148.0, 54.0, 2.0,1100); 
 
  497     for(Int_t 
i=0;
i<ClusterList4->GetSize();
i++)
 
  499        AddSensitiveVolume((TGeoVolume *) ClusterList4->At(
i));
 
  502    ClusterList5 = HypGe->
CreateCluster(logicCrystal_test,lay_sci,lay_cap,*sphere,32.9,
 
  503                                        148.0, 126.0, 2.0,300); 
 
  504     for(Int_t 
i=0;
i<ClusterList5->GetSize();
i++)
 
  506        AddSensitiveVolume((TGeoVolume *) ClusterList5->At(
i));
 
  509    ClusterList6 = HypGe->
CreateCluster(logicCrystal_test,lay_sci,lay_cap,*sphere,31.4,
 
  510                                        148.0,  198.0, 2.0,500); 
 
  511     for(Int_t 
i=0;
i<ClusterList6->GetSize();
i++)
 
  513        AddSensitiveVolume((TGeoVolume *) ClusterList6->At(
i));
 
  516    ClusterList7 = HypGe->
CreateCluster(logicCrystal_test,lay_sci,lay_cap,*sphere,32.6,
 
  517                                        148.0,  270.0, 2.0,1500); 
 
  518     for(Int_t 
i=0;
i<ClusterList7->GetSize();
i++)
 
  520        AddSensitiveVolume((TGeoVolume *) ClusterList7->At(
i));
 
  522     ClusterList8 = HypGe->
CreateCluster(logicCrystal_test,lay_sci,lay_cap,*sphere,30.3,
 
  523                                        148.0,  342.0, 2.0,1300); 
 
  524     for(Int_t 
i=0;
i<ClusterList8->GetSize();
i++)
 
  526        AddSensitiveVolume((TGeoVolume *) ClusterList8->At(
i));
 
  529     ClusterList10=HypGe->
CreateCluster(logicCrystal_test,lay_sci,lay_cap,*sphere,
 
  530                                       30.0, 140.0, 90., 2.0,700); 
 
  532    for(Int_t 
i=0;
i<ClusterList10->GetSize();
i++){
 
  533      AddSensitiveVolume((TGeoVolume *) ClusterList10->At(
i));
 
  536    ClusterList11 = HypGe->
CreateCluster(logicCrystal_test,lay_sci,lay_cap,*sphere,
 
  537                                        30.2, 140.0,18., 2.0,800); 
 
  539    for(Int_t 
i=0;
i<ClusterList11->GetSize();
i++)
 
  541        AddSensitiveVolume((TGeoVolume *) ClusterList11->At(
i));
 
  544    ClusterList12 =  HypGe->
CreateCluster(logicCrystal_test,lay_sci,lay_cap,*sphere,
 
  545                                         30.15, 140.0, 162., 2.0,100); 
 
  547    for(Int_t 
i=0;
i<ClusterList12->GetSize();
i++)
 
  549        AddSensitiveVolume((TGeoVolume *) ClusterList12->At(
i));
 
  552    ClusterList13 =  HypGe->
CreateCluster(logicCrystal_test,lay_sci,lay_cap,*sphere,
 
  553                                         30.15, 140.0, 234., 2.0,200); 
 
  555     for(Int_t 
i=0;
i<ClusterList13->GetSize();
i++)
 
  557        AddSensitiveVolume((TGeoVolume *) ClusterList13->At(
i));
 
  560     ClusterList14 =  HypGe->
CreateCluster(logicCrystal_test,lay_sci,lay_cap,*sphere,
 
  561                                         30.2, 140.0, 306., 2.0,900); 
 
  563     for(Int_t 
i=0;
i<ClusterList14->GetSize();
i++)
 
  565        AddSensitiveVolume((TGeoVolume *) ClusterList14->At(
i));
 
  570   TGeoVolume* vcave = 
gGeoManager->FindVolumeFast(vname);
 
  572   vcave->AddNode(sphere, 1,
new TGeoCombiTrans(0., 0., 
fdist, 
new TGeoRotation (0)));
 
  596   Int_t size = clref.GetEntriesFast();
 
  598     cout << 
"-I- PndHypGe: Adding Point at IN (" << pos.X() << 
", " << pos.Y() 
 
  599          << 
", " << pos.Z() << 
") cm,  evt " << evtID << 
", track " 
  600          << trackID <<
", energy loss " << eLoss*1e06 << 
" keV " << 
" copy " << copy << endl;
 
  602   return new(clref[size]) 
PndHypGePoint(trackID, evtID,pdgCode,charge, pos, mom, 
 
  603                                         time, length, eLoss,copy);
 
  610   Int_t size = clref.GetEntriesFast();
 
  612     cout << 
"-I- PndHypGe: Adding Point at IN (" << pos.X() << 
", " << pos.Y() 
 
  613          << 
", " << pos.Z() << 
") cm,  evt " << evtID << 
", track " 
  614          << trackID <<
", energy loss " << eLoss*1e06 << 
" keV " << 
" copy " << copy << endl;
 
  616   return new(clref[size]) 
PndHypGePoint(trackID, evtID, pdgCode,charge,pos, mom, 
 
  617                                         time, length, eLoss,copy);
 
  626   fPos.SetXYZT(0., 0., 0., 0.);
 
  627   fMom.SetXYZT(0., 0., 0., 0.) ;
 
friend F32vec4 cos(const F32vec4 &a)
sim(Int_t nEvents=1, TString SimEngine="TGeant4", Float_t mom=6.231552)
virtual void Initialize()
bool CheckIfSensitive(std::string name)
virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
TClonesArray * fHypGeCollection
virtual void ConstructGeometry()
virtual void Print() const 
virtual void EndOfEvent()
void SetPathGeo(TString path)
TGeoManager * gGeoManager
void ConstructHPGeGeometry()
TClonesArray * fHypGeAlCollection
FairGeoBuilder * geobuild
std::vector< std::string > fListOfSensitives
TList * CreateCluster(TGeoPgon *logicCrystal_test, TGeoPgon *lay_sci, TGeoCompositeShape *lay_cap, TGeoVolume &sphere, double distance, double theta, double phi, double depth_first_interaction, int id_start)
virtual TClonesArray * GetCollection(Int_t iColl) const 
virtual void BeginEvent()
FairGeoInterface * geoFace
void SetTrackID(Int_t id)
PndHypGePoint * AddHit(Int_t trackID, Int_t evtID, Int_t pdgCode, Int_t charge, TVector3 pos, TVector3 mom, Double_t tof, Double_t length, Double_t eLoss, Short_t copy)
virtual Bool_t ProcessHits(FairVolume *vol=0)
PndHypGePoint * AddGeAlHit(Int_t trackID, Int_t evtID, Int_t pdgCode, Int_t charge, TVector3 pos, TVector3 mom, Double_t tof, Double_t length, Double_t eLoss, Short_t copy)