8 #include "FairVolume.h" 
    9 #include "FairGeoVolume.h" 
   10 #include "FairGeoNode.h" 
   11 #include "FairRootManager.h" 
   12 #include "FairGeoLoader.h" 
   13 #include "FairGeoInterface.h" 
   15 #include "FairRuntimeDb.h" 
   18 #include "TParticle.h" 
   20 #include "TClonesArray.h" 
   21 #include "TVirtualMC.h" 
   24 #include "FairGeoRootBuilder.h" 
   25 #include "FairGeoMedia.h" 
   26 #include "FairGeoLoader.h" 
   27 #include "TGeoCompositeShape.h" 
   29 #include "G4NistManager.hh" 
   36   : FairDetector(
"PndRich", kTRUE, 
kRICH),
 
   46     fUseProtection(kFALSE),
 
   47     fRunCherenkov(kFALSE),            
 
   48     fPndRichPDPointCollection(new TClonesArray(
"PndRichPDPoint")),
 
   49     fPndRichBarPointCollection(new TClonesArray(
"PndRichBarPoint"))
 
   52   if(fVerboseLevel > 0){
 
   53     std::cout<<
"-I- PndRich: fListOfSensitives contains:";
 
   65   : FairDetector(name, active, 
kRICH),
 
   75     fUseProtection(kFALSE),
 
   76     fRunCherenkov(kFALSE),            
 
   77     fPndRichPDPointCollection(new TClonesArray(
"PndRichPDPoint")),
 
   78     fPndRichBarPointCollection(new TClonesArray(
"PndRichBarPoint"))
 
   81   if(fVerboseLevel > 0){
 
   82     std::cout<<
"-I- PndRich: fListOfSensitives contains:";
 
   91    std::cout<<
"-I- PndRich:"<<std::endl;
 
  109   FairRun* 
fRun = FairRun::Instance();
 
  110   FairRuntimeDb* 
rtdb= FairRun::Instance()->GetRuntimeDb();
 
  113   par->setInputVersion(fRun->GetRunId(),1);
 
  116     cout << 
"We do not have gGeoManager" << endl;
 
  118     cout << 
"there is gGeoManager" << endl;  
 
  120   cout << 
"list of sensitives has " << 
fListOfSensitives.size() << 
" entries" << endl;
 
  125   if (
fRunCherenkov==kFALSE) cout << 
" -I- PndRich: Switching OFF Cherenkov Propagation" << endl;
 
  132    std::vector<Double_t> nopt = 
fGeo->
nOpt();
 
  135       for(
size_t i=0;
i<nopt.size();
i++)
 
  137       fnOpt /= nopt.size();
 
  138       std::cout << 
"Mid ref. index = " << 
fnOpt << std::endl;
 
  145    fZabar = richOffset.Z() + aerogelOffset.Z();
 
  148    std::string workdir(getenv( 
"VMCWORKDIR" ));
 
  149    std::string effFileName(workdir+
"/detectors/rich/pde_dpc3200_22.dat");
 
  150    std::ifstream from( effFileName.c_str() );
 
  153    while( !from.eof() ) {
 
  155       fPDE.push_back(pdei); 
 
  168   Int_t fEventID = gMC->CurrentEvent();
 
  169   Int_t fPdgCode = gMC->TrackPid();
 
  170   fTrackID = gMC->GetStack()->GetCurrentTrackNumber();    
 
  171   fTime    = gMC->TrackTime() * 1.0e09;
 
  231   gMC->TrackPosition(
fPos);
 
  232   gMC->TrackMomentum(
fMom);
 
  235    if ( fPdgCode == 50000050 ) {
 
  239          if (fVerboseLevel >0) cout<< 
"Photon killed" << endl;
 
  242       else if ( nam.BeginsWith(
"RichPhDetSi") && (gMC->IsTrackEntering()==1) && (gRandom->Uniform()<eff) ){
 
  243          fTrackID  = gMC->GetStack()->GetCurrentTrackNumber();
 
  255    if( (gMC->TrackCharge() != 0) && (
fMom.Beta() > 1.00/
fnOpt) &&
 
  256        gMC->IsTrackEntering()==1 && (
fPos.Z() < 
fZabar+0.001) &&
 
  261       fTrackID  = gMC->GetStack()->GetCurrentTrackNumber();
 
  266       fThetaC = 
fMom.Beta(); 
 
  268       TParticle *
particle = gMC->GetStack()->GetCurrentTrack();
 
  269       TVector3 pos0 = TVector3(particle->Vx(),particle->Vy(),particle->Vz());
 
  270       TVector3 mom0 = TVector3(particle->Px(),particle->Py(),particle->Pz());
 
  351    TString fileName = GetGeometryFileName();
 
  352    if( fileName.EndsWith(
".root") && (
fGeoVersion==313) ){
 
  353       char pat[] = 
"rich_v";
 
  354       size_t ind = fileName.Index(pat)+strlen(pat);
 
  356       std::cout << 
"GetGeometryFileName() = " << fileName << 
" " << 
fGeoVersion << std::endl;
 
  370       FairRootManager::Instance()->Register(
"RichPDPoint", 
"PndRich",
 
  372   FairRootManager::Instance()->Register(
"RichBarPoint", 
"PndRich",
 
  393   TString fileName = GetGeometryFileName();
 
  394   if(fileName.EndsWith(
".root")) {
 
  395      ConstructRootGeometry();
 
  502      FairGeoLoader*    
geoLoad = FairGeoLoader::Instance();
 
  503      FairGeoInterface* 
geoFace = geoLoad->getGeoInterface();
 
  505      Geo->setGeomFile(GetGeometryFileName());
 
  506      geoFace->addGeoModule(Geo);
 
  508      Bool_t rc = geoFace->readSet(Geo);
 
  509      if (rc) { Geo->create(geoLoad->getGeoBuilder()); }
 
  510      TList* volList = Geo->getListOfVolumes();
 
  513      FairRun* 
fRun = FairRun::Instance();
 
  514      FairRuntimeDb* 
rtdb= FairRun::Instance()->GetRuntimeDb();
 
  519      TListIter iter(volList);
 
  520      FairGeoNode* node   = NULL;
 
  521      FairGeoVolume* aVol=NULL;
 
  523      while( (node = (FairGeoNode*)iter.Next()) ) {
 
  524         aVol = 
dynamic_cast<FairGeoVolume*
> ( node );
 
  525         if ( node->isSensitive()  ) {
 
  526            fSensNodes->AddLast( aVol );
 
  528            fPassNodes->AddLast( aVol );
 
  532      par->setInputVersion(fRun->GetRunId(),1);
 
  534      ProcessNodes ( volList );
 
  541   cout<< 
" ==================================================== " << endl;
 
  542   cout<< 
" =======  Rich::  ConstructOpticalGeometry()  ======== " << endl; 
 
  551   std::vector<Double_t> nOpt = 
fGeo->
nOpt();
 
  552   UInt_t nAerogelLayers = nOpt.size();
 
  555       for(
size_t i=0;
i<nOpt.size();
i++)
 
  557       fnOpt /= nOpt.size();
 
  562   Double_t ephotonMin = 1.240*1.0e-09;  
 
  563   Double_t ephotonMax = 4.428*1.0e-09;  
 
  570   Double_t k = 2*3.1415927*197.3269602e-9; 
 
  574      ephoton[
i] = ephotonMin + 
i*(ephotonMax-ephotonMin)/(npoints-1);
 
  577      for(UInt_t l=0; l<nAerogelLayers; l++ )
 
  580      absLen[
i] = 4.5*std::pow(wl/400,4.0);
 
  585   cout << 
"nOpt.size() = " << nOpt.size() << endl;
 
  586   for(
size_t i=0;
i<nOpt.size();
i++) {
 
  589      Int_t mId = gMC->MediumId( Form(
"RichAerogel%d",(
int)
i) );
 
  591      gMC->SetCerenkov( mId, npoints, ephoton, absLen, qEff, refInd[i] );
 
  599   ephoton_i[0] = 1.240*1.0e-09;  
 
  600   ephoton_i[1] = 4.428*1.0e-09; 
 
  603   reflectivity_i[0] = 0.9;
 
  604   reflectivity_i[1] = 0.9;
 
  611   pdWindowRefInd[0] = 1.46;
 
  612   pdWindowRefInd[1] = 1.46;
 
  622   gMC->SetCerenkov( gMC->MediumId(
"RichAir"),      npoints_i, ephoton_i, abs_i, qEff_i, airRefInd );
 
  623   gMC->SetCerenkov( gMC->MediumId(
"RichPDWindow"), npoints_i, ephoton_i, abs_i, qEff_i, pdWindowRefInd );
 
  625   gMC->DefineOpSurface(
"RichMirrSurface",  kGlisur, kDielectric_metal, kPolished, 0.0);
 
  626   gMC->SetMaterialProperty(
"RichMirrSurface", 
"REFLECTIVITY", npoints_i, ephoton_i, reflectivity_i);
 
  627   gMC->SetBorderSurface(
"BarRichMirrorSurface", 
"RichMirror", 1, 
"RichAlBoxAir", 1, 
"RichMirrSurface");
 
  628   gMC->SetSkinSurface(
"RichAirMirrorSurface", 
"RichMirror", 
"RichMirrSurface");
 
  635   cout<<
" =======  RICH::ConstructOpGeometry -> Finished! ====== "<< endl;     
 
  647    const double LHCb_a0=0.05639, LHCb_wl0sqr = 83.22*83.22;
 
  648    double LHCb_RI2m1ref = LHCb_a0/(1-LHCb_wl0sqr/(400*400)); 
 
  649    double ri2m1_lhcb = LHCb_a0/(1-LHCb_wl0sqr/(wl*wl)); 
 
  650    return sqrt( 1 + (n400*n400-1)/LHCb_RI2m1ref*ri2m1_lhcb );
 
  665                                     TVector3 
pos, TVector3 
mom,
 
  670   Int_t size = clref.GetEntriesFast();
 
  672                                          time, length, eLoss, EventId);
 
  676                                       TVector3 
pos, TVector3 
mom,
 
  680                                       TVector3 pos0, TVector3 mom0 )
 
  683   Int_t size = clref.GetEntriesFast();
 
  685                                           time, length, pdgCode,
 
  686                                           thetaC, eventID, mass,
 
bool CheckIfSensitive(std::string name)
Double_t phDetQEff(Double_t wl)
TLorentzVector fMom
position at entrance 
friend F32vec4 sqrt(const F32vec4 &a)
Double_t fTime
momentum at entrance 
void CreateUniqueSensorId(TString startName, std::vector< std::string > listOfSensitives)
Has to be called during simulation to create unique sensor id. 
PndRichPDPoint * AddPDPoint(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, Double_t time, Double_t length, Double_t eLoss, UInt_t EventId=0)
TLorentzVector fPos
volume id 
virtual void Initialize()
virtual TClonesArray * GetCollection(Int_t iColl) const 
TObjArray * GetGeoSensitiveNodes()
TClonesArray * fPndRichBarPointCollection
TGeoManager * gGeoManager
std::map< Int_t, Int_t > trackid
void AddPoint(DetectorId iDet)
virtual void BeginEvent()
std::vector< Double_t > fWlPhoton
void ConstructOpGeometry()
TObjArray * GetGeoPassiveNodes()
std::vector< std::string > fListOfSensitives
Double_t lhcbaerindex(Double_t n400, Double_t wl)
static PndGeoHandling * Instance()
PndRichBarPoint * AddBarPoint(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom, Double_t time, Double_t length, Int_t pdgCode, Double_t thetaC, Int_t eventID, Double_t mass, TVector3 pos0, TVector3 mom0)
TClonesArray * fPndRichPDPointCollection
virtual void EndOfEvent()
FairGeoInterface * geoFace
Int_t fVolumeID
track index 
std::vector< Double_t > nOpt()
PndRichGeo * fGeo
energy loss 
virtual Bool_t ProcessHits(FairVolume *v=0)
std::vector< Double_t > fPDE