// ------------------------------------------------------------------------- // ----- PndDrc source file ----- // ----- Created 11/10/06 by Annalisa Cecchi ----- // ----- Modified 2006++ by Carsten Schwarz ----- // ----- Modified 2010++ by Maria Patsyuk ----- // ----- ----- // ------------------------------------------------------------------------- #include "PndGeoDrc.h" #include "PndDrcPDPoint.h" #include "PndDrcBarPoint.h" #include "PndDrcEVPoint.h" #include "PndGeoDrcPar.h" #include "PndDetectorList.h" #include "PndDrc.h" #include "TString.h" //#include using std::endl; using std::cout; #include "TClonesArray.h" #include "TVirtualMC.h" #include "TObjArray.h" #include "TGeoMCGeometry.h" #include "TLorentzVector.h" #include "TParticle.h" #include "TVirtualMC.h" #include "TGeoPgon.h" #include "TGeoSphere.h" #include "TGeoBBox.h" #include "TGeoArb8.h" #include "TGeoCone.h" #include "TGeoTrd2.h" #include "TGeoCompositeShape.h" #include "TGeoMatrix.h" #include "TGeoManager.h" #include "TObject.h" #include "TColor.h" #include "TCanvas.h" #include "TH1.h" #include "TH2.h" #include "FairGeoInterface.h" #include "FairGeoLoader.h" #include "FairGeoNode.h" #include "FairRootManager.h" #include "FairVolume.h" #include "FairGeoMedia.h" #include "FairGeoMedium.h" #include "FairGeoRootBuilder.h" #include "PndStack.h" #include "PndDetectorList.h" // add on for debug //#include "FairGeoG3Builder.h" #include "FairRun.h" //#include "FairRunSim.h" #include "FairRuntimeDb.h" #include "PndGeoHandling.h" #include // ----- Default constructor ------------------------------------------- PndDrc::PndDrc() : FairDetector("PndDrcDefault",kTRUE), fpi(TMath::Pi()), //! fzup(-999.), //! fzdown(-999.), fradius(-999.), fhthick(-999.), fpipehAngle(-999.), fbbGap(-999.), fbbnum(-999.), fbarnum(-999.), fphi0(-999.), fdphi(-999.), flside(-999.), fbarwidth(-999.), fGeoH(NULL), fRunCherenkov(kTRUE), //! Switch ON/OFF Cherenkov propagation fTrackID(-1), //! track index fPos(TLorentzVector(0,0,0,0)), //! position fMom(TLorentzVector(0,0,0,0)), //! momentum fTime(-1), //! time fLength(-1), //! length fAngIn(0), fNBar(0), fPosIndex(-1), //! volDetector(0), //! MC volume ID of drc fMass(-1), fMom1(TLorentzVector(0,0,0,0)), fMom2(TLorentzVector(0,0,0,0)), //! for transport efficiency calculation fPos2(TLorentzVector(0,0,0,0)), //! for transport efficiency calculation fBarEnd(0), fMirrorGap(0), // used in ProcessHits function: fbarID(0), //! ID number of DrcBarSensors fpdID(0), //! ID number of DrcPdSensor flens3ID(0), //! ID number of third lenses flens2ID(0), flens1ID(0), fbboxID(0), //! ID number of DrcBarBoxes fevID(0), //! ID number of Expansion Volume fDetEff(0x0), //! Detector Efficiency as a function of photon wavelength fDetEffAtProduction(kFALSE), fTransportEffAtProduction(kFALSE), frand(), fLastTrackID(-1), fCollectionEff(-1),//Collection Efficiency fStopTime(kFALSE), fPhoMaxTime(-1), fTakeDirect(kFALSE), fTakeReflected(kFALSE), fFocusing(-1), fTakeRealReflectivity(kFALSE), fStopSecondaries(kFALSE), fStopChargedTrackAfterDIRC(kFALSE), fGeo(new PndGeoDrc()), //! Pointer to basic DRC geometry data fPdgCode(-1), fThetaC(-1.), fDrcPDCollection(new TClonesArray("PndDrcPDPoint")), //! Hit collection fDrcEVCollection(new TClonesArray("PndDrcEVPoint")), fDrcBarCollection (new TClonesArray("PndDrcBarPoint")), //! Hit collection in the bar fEventID(0), fSenId1(0), fSenId2(0), fSenIdBar(0) { fListOfSensitives.push_back("Sensor"); if(fVerboseLevel > 0){ std::cout<<"-I- PndBarrelDIRC: fListOfSensitives contains:"; for(Int_t k=0; k 0){ std::cout<<"-I- PndBarrelDIRC: fListOfSensitives contains:"; for(Int_t k=0; kDelete(); delete fDrcPDCollection; } if (fDrcEVCollection) { fDrcEVCollection->Delete(); delete fDrcEVCollection; } if (fDrcBarCollection) { fDrcBarCollection->Delete(); delete fDrcBarCollection; } if (fGeoH) delete fGeoH; if (fGeo) delete fGeo; } // ----- Public method Intialize --------------------------------------- void PndDrc::Initialize() { cout << " -I- PndDrc: Intialization started... " << endl; FairDetector::Initialize(); //FairRun *sim = FairRun::Instance(); //FairRuntimeDb *rtdb = sim->GetRuntimeDb(); //PndGeoDrcPar *par = (PndGeoDrcPar*)(rtdb->getContainer("PndGeoDrcPar")); if (0==gGeoManager) cout << "We do not have gGeoManager" << endl; else cout << "there is gGeoManager" << endl; cout << "list of sensitives has " << fListOfSensitives.size() << " entries" << endl; fGeoH->CreateUniqueSensorId("", fListOfSensitives); if(fVerboseLevel>0) fGeoH->PrintSensorNames(); if (fRunCherenkov==kFALSE) cout << " -I- PndDrc: Switching OFF Cherenkov Propagation" << endl; // basic DIRC parameters: fpi = TMath::Pi(); fzup = fGeo->barBoxZUp(); fzdown = fGeo->barBoxZDown(); fradius = fGeo->radius(); //radius in the middle of the bar = 50.cm fhthick = fGeo->barHalfThick(); //half thickness of the bars=1.7/2 cm fpipehAngle = fGeo->PipehAngle(); fbbGap = fGeo->BBoxGap(); fbbnum = fGeo->BBoxNum(); fbarnum = fGeo->barNum(); fphi0 = (180.-2.*fpipehAngle)/fbbnum + fpipehAngle; fdphi = (180.-2.*fpipehAngle)/fbbnum*2.; flside = fGeo->Lside(); fbarwidth = fGeo->BarWidth(); cout<<"DRC parameters: fpi = "<VolId("DrcLENS2Sensor"); flens1ID = gMC->VolId("DrcLENS1Sensor"); } if(fFocusing == 3){ flens2ID = gMC->VolId("DrcLENS2Sensor"); flens1ID = gMC->VolId("DrcLENS1Sensor"); //cout<<"lens1 = "<FindNode("DrcLENS1Sensor_1")->GetVolume()->GetNumber()<< // ", lens2 = "<FindNode("DrcLENS2Sensor_1")->GetVolume()->GetNumber()<0) cout<<" \n\n>>>>>>>>>>>>>>>>>>>>new event in the Barrel DIRC" <GetName(); Int_t num = vol->getMCid(); fEventID = gMC->CurrentEvent(); fPdgCode = gMC->TrackPid(); fTrackID = gMC->GetStack()->GetCurrentTrackNumber(); fTime = gMC->TrackTime() * 1.0e09; fLength = gMC->TrackLength(); bool stop = true; if(gMC->GetStack()->GetCurrentParentTrackNumber()==0 && fPdgCode == 11){ //std::cout<<"E fPdgCode "<GetStack()->GetCurrentParentTrackNumber()==1 && fPdgCode == 50000050){ //std::cout<<"P fPdgCode "<GetStack()->GetCurrentParentTrackNumber()==0 && fPdgCode == 11){ // Int_t nproc = gMC->StepProcesses(fProc); // cout<<"-I- PndDrc:"<GetStack()->GetCurrentTrackNumber()<<" mother id = "<GetStack()->GetCurrentParentTrackNumber()<<": Z pos "<StopTrack(); gMC->TrackPosition(fPos); gMC->TrackMomentum(fMom); //stop secondaries so that they do not produce Cherenkov photons if(fStopSecondaries){ if(fPdgCode != 50000050){ if(gMC->GetStack()->GetCurrentParentTrackNumber() != -1 ){ if(gMC->IsNewTrack()){ gMC->StopTrack(); } } } } // stop the track after the DIRC: if(fStopChargedTrackAfterDIRC){ if(fPdgCode != 50000050 && gMC->IsTrackExiting()==1 && num == fbarID){ cout<<"track is exiting the bar!!!"<StopTrack(); } if(nam.BeginsWith("DrcEVSensor") && gMC->IsTrackExiting()&&fMom.Z() > 0.) gMC->StopTrack(); } if (fPdgCode == 50000050){ if (fRunCherenkov==kFALSE ) { //|| fabs(fMom.Vect().Mag()*1.0E9-3.18)>0.2 gMC->StopTrack(); if (fVerboseLevel >0) cout<< "Photon killed" << endl; } // apply detector efficiency at the production stage: if(fDetEffAtProduction && fLastTrackID != fTrackID){ Double_t lambda = 197.0*2.0*fpi/(fMom.Vect().Mag()*1.0E9); Double_t ra = frand.Uniform(0., 1.); //if(ra > fEfficiencyR[(int)lambda]){ if(ra > fDetEff->Eval(lambda)){ gMC->StopTrack(); }else{ nphotons = nphotons + 1; } } //if the photon goes backward through the lens, stop it if(fOptionForLUT){ if(gMC->IsTrackExiting() == 1){ if(nam.Contains("LENS")){ if(fMom.Z() > 0.) gMC->StopTrack(); } } if(fMom.Z() > 0.) gMC->StopTrack(); } // apply transport efficiency at production stage (Maria Patsyuk 20.04.2012): if(fTransportEffAtProduction && fLastTrackID != fTrackID){ gMC->TrackMomentum(fMom2); gMC->TrackPosition(fPos2); Double_t lam_tr = (197.0*2.0*fpi/(fMom2.Vect().Mag()*1.0E9)) / 1000.; // current volume (should be the radiator bar) Int_t barId = fGeoH->GetShortID(gMC->CurrentVolPath()); //calculate the number of bounces: Int_t NbouncesX, NbouncesY; Double_t angleX, angleY; // photon initial direction TVector3 PphoInitBar = fGeoH->MasterToLocalShortId(fMom2.Vect(), barId)- fGeoH->MasterToLocalShortId(TVector3(0.,0.,0.), barId); // vector NumberOfBounces(fPos2.Vect(), PphoInitBar, barId, &NbouncesX, &NbouncesY, &angleX, &angleY); // calculate the bounce probability Double_t n_quartz = sqrt(1. + (0.696*lam_tr*lam_tr/(lam_tr*lam_tr-pow(0.068,2))) + (0.407*lam_tr*lam_tr/(lam_tr*lam_tr-pow(0.116,2))) + 0.897*lam_tr*lam_tr/(lam_tr*lam_tr-pow(9.896,2))); //cout<<"n_quartz = "<Roughness()*n_quartz/lam_tr,2); Double_t bounce_probY = 1. - pow(4.*fpi*cos(angleY)*fGeo->Roughness()*n_quartz/lam_tr,2); Double_t TotalTrProb = pow(bounce_probX, (Int_t)NbouncesX)*pow(bounce_probY, (Int_t)NbouncesY); //cout<<"tr eff X = "<IsTrackEntering()==1 && num == fpdID){ // check how many photons get detected // nphotons = nphotons + 1; // cout<<"photon number "<GetStack()->GetCurrentTrackNumber()<StopTrack(); // } // cout<<"photon z coord = "<IsTrackExiting()==1){ if(num == flens3ID && fPos.Z() < fBarEnd){ if ((fPos.X()*fMom.X() + fPos.Y()*fMom.Y()) < 0.){ gMC->StopTrack(); } } } } //if(fMom.Z()>0) gMC->StopTrack(); // "TakeOnlyReflectedPho" option: if photon is exiting the bar - check its direction if(fTakeReflected){ if(gMC->IsTrackExiting()==1){ if(num == flens3ID && fPos.Z() < fBarEnd){ if ((fPos.X()*fMom.X() + fPos.Y()*fMom.Y()) > 0.){ gMC->StopTrack(); } } } } // kill photons older than fPhoMaxTime: if (fStopTime == kTRUE && gMC->TrackTime()*1.0e09 > fPhoMaxTime){ gMC->StopTrack(); } if(gMC->IsTrackEntering()==1 && num == fevID && fLastTrackID != fTrackID){ gMC->TrackMomentum(fMomAtEV); } // // js group velocity check // if ( gMC->IsTrackEntering() ) // { // fTime_in = gMC->TrackTime() * 1.0e09; // fLength_in = gfLength; // } // if ( gMC->IsTrackExiting() ) // { // fTime_out = gMC->TrackTime() * 1.0e09; // fLength_out = fLength; // fPEnergy = (sqrt(fMom.X()*fMom.X() + fMom.Y()*fMom.Y() + fMom.Z()*fMom.Z()))*1.0e09; // fLambda1 = 197.*2*TMath::Pi()/fPEnergy; // fDeltaT = fTime_out - fTime_in; // if ((0)&&(fDeltaT>0)) // { // cout << "time out: " << fTime_out << ", in: " << fTime_in // << ", deltaT: " << fTime_out-fTime_in // << ", t0: " << fTrackTime // << ", path out: " << fLength_out << ", in: " << fLength_in // << ", deltaP: " << fLength_out-fLength_in // << ", velocity: " << (fLength_out-fLength_in)/(fTime_out-fTime_in) // << ", energy: " << fPEnergy // << ", lambda: " << fLambda1 // << endl; // } // if ((1)&&(fDeltaT>0.01)&&(fPos.Z()<=-119.)&&(fPos.Z()>-120.1)) // { // cout // << fLambda1 << " %% " // << (fLength_out-fLength_in)/(fTime_out-fTime_in) // << " %% " <<(fLength_out-fLength_in) // << " %% " <IsTrackEntering()){ if ( gMC->IsNewTrack()==1 ) { fTimeStart = fTime; // charged particle time at entrance of radiator bar } // if(nam.BeginsWith("DrcLENS1Sensor")){ //DrcEntranceBox // // save the direction of the photon when it enters EntranceBox (for LUT generation) // Double_t nx,ny,nz; // bool bres = gMC->CurrentBoundaryNormal(nx,ny,nz); // AddEVHit(fTrackID, 9375, fPos.Vect(), fMom.Vect().Unit(), // fTime, fLength, fPdgCode, // fEventID, fTimeStart, fTimeAtEVEntrance, fVeloPhoton, TVector3(nx,ny,nz)); // } if(nam.BeginsWith("DrcEVSensor")){ if(fTimeAtEVEntrance ==0.){ fTimeAtEVEntrance= gMC->TrackTime()*1.0e09; fLengthEV=fLength; } fVeloPhoton=fLength/(fTime-fTimeStart); Double_t nx,ny,nz; bool bres = gMC->CurrentBoundaryNormal(nx,ny,nz); AddEVHit(fTrackID, 0, fPos.Vect(), fMom.Vect(), fTime, fLength, fPdgCode, fEventID, fTimeStart, fTimeAtEVEntrance, fVeloPhoton, TVector3(nx,ny,nz)); fTimeAtEVEntrance = 0.0; } } // if a photon is exiting the readout bar end if (gMC->IsTrackExiting()==1 && num == fbarID && fPos.Z()<-118.99){ fTimeAtEV = gMC->TrackTime()*1.0e09; //cout<<"time at EV = "<IsTrackEntering()==1){ if (nam.BeginsWith("DrcPDSensor")){ if(0==fGeoH) { std::cout<<" -E- No PndGeoHandling loaded."<GetShortID(gMC->CurrentVolPath()); Int_t mcpId, prismId; sscanf(gMC->CurrentVolPath(), "/cave_1/BarrelDIRC_0/DrcPDbase_%d/DrcMCP_%d", &prismId, &mcpId); if(fTrackID>-2){ AddHit(fTrackID, sensorId, mcpId, fPos.Vect(),fMom.Vect(),fMomAtEV.Vect(), fTimeAtEV, fTime, fLength, fPdgCode, fEventID); } gMC->StopTrack(); } PndStack* stack = (PndStack*) gMC->GetStack(); stack->AddPoint(kDRC); } //Lab if (fbLab && gMC->IsTrackExiting()){ AddBarHit(fTrackID, 0, fPos.Vect(), fMom.Vect(), fTime, fLength, fPdgCode, fThetaC, fNBar, fEventID, fMass); } } if(gMC->TrackCharge()!=0 || fOptionForLUT){ if (nam.BeginsWith("DrcBar") && gMC->IsTrackEntering()==1 ) { bool bpass = true; // if(fDrcBarCollection->GetEntriesFast()>0){ // PndDrcBarPoint *tBarPoint = (PndDrcBarPoint*) fDrcBarCollection->At(fDrcBarCollection->GetEntriesFast()-1); // if(tBarPoint->GetTrackID()==fTrackID && fLength - tBarPoint->GetLength()<0.1) bpass = false; // } if(bpass && nam.BeginsWith("DrcBarSensor") ){ Int_t s=0, b=0; //side and bar fNBar=0; TString path = gMC->CurrentVolPath(); if (fVerboseLevel >1) cout<< "Volume: " << nam << endl; sscanf(path, "/cave_1/BarrelDIRC_0/DrcBarBox_%d/DrcBarAirBox_0/DrcBarSensor_%d", &s, &b); if(s < 17) fNBar = s*10 + b; else std::cout<<"Error: Wrong BarBox Id "<< s <TrackMass(); Double_t fEnergy = TMath::Sqrt(fP*fP + fMass*fMass); if ( fP == 0. || fabs(1./(fGeo->nQuartz()*(fP/fEnergy)))>1){ fThetaC = -1; }else{ fThetaC = acos(1/(fGeo->nQuartz()*(fP/fEnergy))); } AddBarHit(fTrackID, fGeoH->GetShortID(path), fPos.Vect(), barMom, fTime, fLength, fPdgCode, fThetaC, fNBar, fEventID, fMass); if(gMC->GetStack()->GetCurrentParentTrackNumber() != -1 ){ fBarTrackStatus = 1; } PndStack* stack = (PndStack*) gMC->GetStack(); stack->AddPoint(kDRC); } } } fLastTrackID = fTrackID; ResetParameters(); return kTRUE; } void PndDrc::FinishPrimary(){ if(fBarTrackStatus == 1){ for(Int_t ibarp=0; ibarpGetEntriesFast(); ibarp++){ ((PndDrcBarPoint*)fDrcBarCollection->At(ibarp))->SetTrackStatus(1); } } //Lab if(fbLab){ gGeoManager->cd("/cave_1/AirBoxSensor_0/AirSensor_1/GlassSensor_1/AquaSensor_1/DrcLENS1Sensor_1"); const Double_t *tr = gGeoManager->GetCurrentMatrix()->GetRotationMatrix(); TGeoRotation *rm = new TGeoRotation(); rm->SetMatrix(tr); Double_t aa1,aaPhi,aa3; rm->GetAngles(aa1,aaPhi,aa3); Int_t barcolsize = fDrcBarCollection->GetEntriesFast(); if (barcolsize!=16) return; TVector3 ttmom, ttpos; ((PndDrcBarPoint*)fDrcBarCollection->At(4))->Momentum(ttmom); ((PndDrcBarPoint*)fDrcBarCollection->At(4))->Position(ttpos); ttmom = ttmom.Unit(); TVector3 head0 = ttpos; TVector3 tail0 = head0 + 10.*ttmom; ((PndDrcBarPoint*)fDrcBarCollection->At(12))->Momentum(ttmom); ((PndDrcBarPoint*)fDrcBarCollection->At(12))->Position(ttpos); ttmom = ttmom.Unit(); TVector3 head1 = ttpos; TVector3 tail1 = head1 + 10.*ttmom; TVector3 dir0 = head0 - tail0; TVector3 dir1 = head1 - tail1; TVector3 diff = tail0 - tail1; Double_t a = dir0.Dot(dir0); //always >= 0 Double_t b = dir0.Dot(dir1); Double_t c = dir1.Dot(dir1); //always >= 0 Double_t d = dir0.Dot(diff); Double_t e = dir1.Dot(diff); Double_t f = a * c - b * b; //always >= 0 Double_t sc,tc; if(f<0.000001){ //The lines are almost parallel sc = 0.; tc = b > c ? d / b : e / c; //Use the largest denominator }else{ sc = (b * e - c * d) / f; tc = (a * e - b * d) / f; } TVector3 point0 = tail0 + dir0 * sc; TVector3 point1 = tail1 + dir1 * tc; TVector3 point = 0.5*(point1+point1); point.Print(); if(point.Z()>-15){ AddHit(0, 0, 0, point, TVector3(0,0,0), TVector3(0,0,0),aaPhi, 0, 0, 0, 0); }else{ ((PndDrcBarPoint*)fDrcBarCollection->At(6))->Momentum(ttmom); ((PndDrcBarPoint*)fDrcBarCollection->At(6))->Position(ttpos); ttmom = ttmom.Unit(); head0 = ttpos; tail0 = head0 + 10.*ttmom; ((PndDrcBarPoint*)fDrcBarCollection->At(14))->Momentum(ttmom); ((PndDrcBarPoint*)fDrcBarCollection->At(14))->Position(ttpos); ttmom = ttmom.Unit(); head1 = ttpos; tail1 = head1 + 10.*ttmom; dir0 = head0 - tail0; dir1 = head1 - tail1; diff = tail0 - tail1; a = dir0.Dot(dir0); //always >= 0 b = dir0.Dot(dir1); c = dir1.Dot(dir1); //always >= 0 d = dir0.Dot(diff); e = dir1.Dot(diff); f = a * c - b * b; //always >= 0 if(f<0.000001){ //The lines are almost parallel sc = 0.; tc = b > c ? d / b : e / c; //Use the largest denominator }else{ sc = (b * e - c * d) / f; tc = (a * e - b * d) / f; } point0 = tail0 + dir0 * sc; point1 = tail1 + dir1 * tc; point = 0.5*(point1+point1); AddHit(0, 0, 0, point, TVector3(0,0,0), TVector3(0,0,0),aaPhi, 0, 0, 0, 0); } } } //------ Find Nubmer of Bounces ----------------------------------------- void PndDrc::NumberOfBounces(TVector3 start, TVector3 dir, Int_t barId, Int_t *n1, Int_t *n2, Double_t *alpha1, Double_t *alpha2) { // start - photon production point in global coord system // dir - photon direction in bar coord system // calculates the number of bounces in x and y direction and reflection angles in these directions. // Find coordinates of X0, Y0: Double_t Z0, X0, Y0; if(dir.Theta() < 3.1415/2.){ Z0 = -(fabs(fzup) + 2.*fzdown - start.Z()); } if(dir.Theta() >= 3.1415/2.){ Z0 = -(start.Z() - fzup); } X0 = Z0*tan(dir.Theta())*cos(dir.Phi()); Y0 = Z0*tan(dir.Theta())*sin(dir.Phi()); //cout<<"-I- NumberOfBounces: X0 = "<= 0. && x1 + xEn <= a){xK = x1 + xEn;} if(x0 >= 0. && x1 + xEn > a){xK = 2*a - x1 - xEn; n = 1. + n;} if(x0 < 0. && x1 + xEn >= 0.){xK = a - (x1 + xEn); n = -1. -n;} if(x0 < 0. && x1 + xEn < 0.) {xK = a + x1 + xEn; n = -n;} if(print){std::cout<<"xK = "<< xK<<", n = "<= 0. && x1 + xEn <= a){xK = a - (x1 + xEn);} if(x0 >= 0. && x1 + xEn > a){xK = x1 + xEn - a; n = 1. + n;} if(x0 < 0. && x1 + xEn >= 0.){xK = x1 + xEn; n = -1. -n;} if(x0 < 0. && x1 + xEn < 0.) {xK = - (x1 + xEn); n = -n;} if(print){std::cout<<"xK = "<< xK<<", n = "<Register("DrcBarPoint","Drc", fDrcBarCollection, kTRUE); FairRootManager::Instance()->Register("DrcEVPoint","Drc", fDrcEVCollection, kTRUE); FairRootManager::Instance()->Register("DrcPDPoint","Drc", fDrcPDCollection, kTRUE); } // ----- Public method GetCollection -------------------------------------- TClonesArray* PndDrc::GetCollection(Int_t iColl) const { if (iColl == 0) return fDrcPDCollection; if (iColl == 1) return fDrcEVCollection; if (iColl == 2) return fDrcBarCollection; return NULL; } // ----- Public method Print ---------------------------------------------- void PndDrc::Print() const { Int_t nPDHits = fDrcPDCollection->GetEntriesFast(); Int_t nBarHits = fDrcBarCollection->GetEntriesFast(); Int_t nEVHits = fDrcEVCollection->GetEntriesFast(); cout << "-I- PndDrc: " << nPDHits << " points registered in the photodetector for this event." << endl; cout << "-I- PndDrc: " << nEVHits << " points registered in the expansion volume for this event." << endl; cout << "-I- PndDrc: " << nBarHits << " points registered in the bar for this event." << endl; if (fVerboseLevel>1){ for (Int_t i=0; iPrint(); for (Int_t i=0; iPrint(); for (Int_t i=0; iPrint(); } } // ----- Public method Reset ---------------------------------------------- void PndDrc::Reset() { fDrcPDCollection->Delete(); fDrcEVCollection->Delete(); fDrcBarCollection->Delete(); fPosIndex = 0; } // ----- Public method CopyClones ----------------------------------------- void PndDrc::CopyClones(TClonesArray* clPD1, TClonesArray* clPD2,TClonesArray* clBar1, TClonesArray* clBar2, Int_t offset ) { Int_t nPDEntries = clPD1->GetEntriesFast(); cout << "-I- PndDrc: " << nPDEntries << " entries to add." << endl; TClonesArray& clrefPD = *clPD2; Int_t nBarEntries = clBar1->GetEntriesFast(); cout << "-I- PndDrc: " << nBarEntries << " entries to add." << endl; TClonesArray& clrefBar = *clBar2; PndDrcPDPoint* oldpointPD = NULL; PndDrcBarPoint* oldpointBar = NULL; for (Int_t i=0; iAt(i); Int_t indexPD = oldpointPD->GetTrackID() + offset; oldpointPD->SetTrackID(indexPD); new (clrefPD[fPosIndex]) PndDrcPDPoint(*oldpointPD); fPosIndex++; } for (Int_t i=0; iAt(i); Int_t indexBar = oldpointBar->GetTrackID() + offset; oldpointBar->SetTrackID(indexBar); new (clrefBar[fPosIndex]) PndDrcBarPoint(*oldpointBar); fPosIndex++; } cout << " -I- PndDrc: " << clPD2->GetEntriesFast() << " merged entries." << endl; cout << " -I- PndDrc: " << clBar2->GetEntriesFast() << " merged entries." << endl; } // ----- Public method ConstructGeometry ----------------------------------- void PndDrc::ConstructGeometry() { cout<< " " << endl; cout<< " ======= DRC:: ConstructGeometry() ======== " << endl; cout<< " ============================================= " << endl; TString fileName = GetGeometryFileName(); if(fileName.EndsWith(".root")){ ConstructRootGeometry(); if(fileName.Contains("_l0_")){ fBarEnd = -119.999; fFocusing = 0; } if(fileName.Contains("_l2_")){ fBarEnd = -119.999; fFocusing = 2; } if(fileName.Contains("_l1_")){ fBarEnd = -118.725; fFocusing = 1; } if(fileName.Contains("_l3_")){ fBarEnd = -119.8; fFocusing = 3; } fMirrorGap = 0.1; } else{ std::cout<<"Geometry format not supported!"<DefineOpSurface("LensSurface", kGlisur, kDielectric_dielectric, kGround, 0.0); gMC->DefineOpSurface("MirrSurface", kGlisur, kDielectric_metal, kPolished, 0.0); gMC->DefineOpSurface("EVSurface", kGlisur, kDielectric_metal, kPolished, 0.0); gMC->DefineOpSurface("BlackSurface", kGlisur, kDielectric_dielectric, kPolished, 0.0); // Double_t refractiveIndex[npoints_i]; // refractiveIndex[0] = 1.2; // refractiveIndex[1] = 1.2; // Double_t abs_i[npoints_i]; // abs_i[0] = 1000.; // abs_i[1] = 1000.; // // gMC->SetCerenkov(gMC->MediumId("BK7G18"),npoints_i, ephoton_i,abs_i , reflectivity_i, refractiveIndex); // gMC->SetMaterialProperty("LensSurface", "RINDEX", npoints_i, ephoton_i, refractiveIndex); // gMC->SetMaterialProperty("LensSurface", "REFLECTIVITY", npoints_i, ephoton_i, reflectivity_i); // gMC->SetSkinSurface("Lens3Sur", "DrcLENS3Sensor", "LensSurface"); // return; gMC->SetMaterialProperty("BlackSurface", "REFLECTIVITY", npoints_i, ephoton_i, reflectivity_b); if(fTakeRealReflectivity == kFALSE){ gMC->SetMaterialProperty("MirrSurface", "REFLECTIVITY", npoints_i, ephoton_i, reflectivity_i); } if(fTakeRealReflectivity == kTRUE){ gMC->SetMaterialProperty("MirrSurface", "REFLECTIVITY", npoints_r, ephoton_r, reflectivity_r); } for(Int_t i=0; iBBoxNum(); i++){ gMC->SetBorderSurface("AirCarbonSurface", "DrcBarBox", i, "DrcBarAirBox", 0, "BlackSurface"); gMC->SetBorderSurface("BarMirrorSurface", "DrcMirr", i, "BarrelDIRC", 0, "MirrSurface"); } if(fSetBlackLens == kTRUE){ gMC->SetMaterialProperty("EVSurface", "REFLECTIVITY", npoints_i, ephoton_i, reflectivity_b); for(Int_t i=0; ibarNum(); i++){ // upper and bottom surfaces of lenses are touching with BarrelDIRC volume gMC->SetBorderSurface("Lens1AirSurface", "DrcLENS1Sensor", i, "BarrelDIRC", 0, "EVSurface"); gMC->SetBorderSurface("Lens2AirSurface", "DrcLENS2Sensor", i, "BarrelDIRC", 0, "EVSurface"); gMC->SetBorderSurface("Lens3AirSurface", "DrcLENS3Sensor", i, "BarrelDIRC", 0, "EVSurface"); gMC->SetBorderSurface("Lens4AirSurface", "DrcLENS4Sensor", i, "BarrelDIRC", 0, "EVSurface"); gMC->SetBorderSurface("BarMirrorSurface", "DrcMLSensor", i, "DrcML", i, "MirrSurface"); for(Int_t isec=0; isecBBoxNum(); isec++){ // left and right surfaces of lenses are touching with DrcAirBox volume gMC->SetBorderSurface("Lens1AirSurface", "DrcLENS1Sensor", i, "DrcEntranceBox", isec+1, "EVSurface"); gMC->SetBorderSurface("Lens2AirSurface", "DrcLENS2Sensor", i, "DrcEntranceBox", isec+1, "EVSurface"); gMC->SetBorderSurface("Lens3AirSurface", "DrcLENS3Sensor", i, "DrcEntranceBox", isec+1, "EVSurface"); gMC->SetBorderSurface("Lens4AirSurface", "DrcLENS4Sensor", i, "DrcEntranceBox", isec+1, "EVSurface"); } } gMC->SetBorderSurface("BarboxWindowAirSurface", "DrcBarboxWindowSensor", 0, "BarrelDIRC", 0, "EVSurface"); gMC->SetBorderSurface("EVGreaseAirSurface", "DrcEVgrease", 0, "BarrelDIRC", 0, "EVSurface"); } //only direct //gMC->SetBorderSurface("EVAirSurface", "DrcEVSensor", 0, "DrcEVCoverSensor", 0, "BlackSurface"); gMC->SetSkinSurface("AirMirrorSurface", "DrcMirr", "MirrSurface"); //gMC->SetSkinSurface("AirMirrorSurface", "DrcML", "MirrSurface"); cout<<" ======= DRC::ConstructOpGeometry -> Finished! ====== "<< endl; } // ----- Public method CheckIfSensitive -------------------------------------- bool PndDrc::CheckIfSensitive(std::string name) { for (Int_t i = 0; i < fListOfSensitives.size(); i++){ if (name.find(fListOfSensitives[i]) != std::string::npos) return true; } return false; } // ----- Private method AddHit -------------------------------------------- PndDrcPDPoint* PndDrc::AddHit(Int_t trackID, Int_t copyNo, Int_t mcpId, TVector3 pos, TVector3 mom, TVector3 momAtEV, Double_t timeAtEV, Double_t time, Double_t length, Int_t pdgCode, Int_t eventID) { TClonesArray& clrefPD = *fDrcPDCollection; Int_t size = clrefPD.GetEntriesFast(); // if(size>2) return NULL; if (fVerboseLevel>1) cout << "-I- PndDrc: Adding PD Point at (" << pos.X() << ", " << pos.Y() << ", " << pos.Z() << ") cm, detector " << copyNo << ", track " << trackID <<" event "<GetEntriesFast()-1 <GetEntriesFast()-1, pos, mom, momAtEV, timeAtEV, time, length, pdgCode, eventID); } PndDrcEVPoint* PndDrc::AddEVHit(Int_t trackID, Int_t copyNo, TVector3 pos, TVector3 mom, Double_t time, Double_t length, Int_t pdgCode, Int_t eventID, Double_t timestart,Double_t timestartEV,Double_t VeloPhoton,TVector3 normal) { TClonesArray& clrefEV = *fDrcEVCollection; Int_t size = clrefEV.GetEntriesFast(); if (fVerboseLevel>2) cout << "-I- PndDrc: Adding EV Point at (" << pos.X() << ", " << pos.Y() << ", " << pos.Z() << ") cm, detector " << copyNo << ", track " << trackID <<" event "<1) cout << "-I- PndBarDrc: Adding Bar Point at (" << pos.X() << ", " << pos.Y() << ", " << pos.Z() << ") cm, detector " << copyNo << ", track " << trackID <<" event "<