// ------------------------------------------------------------------------- // ----- PndDrcRecoLookupMapS source file ----- // ----- Created 10/11/10 by Maria Patsyuk ----- // ----- ----- // ----- ----- // ------------------------------------------------------------------------- #include #include #include "stdio.h" #include "PndGeoDrc.h" #include "PndDrcRecoLookupMapS.h" #include "FairRootManager.h" #include "PndMCTrack.h" #include "PndDrcBarPoint.h" #include "PndDrcPDPoint.h" #include "PndDrcHit.h" #include "PndDrcPDHit.h" #include "TVector3.h" #include "TRandom.h" #include "FairRunAna.h" #include "FairRuntimeDb.h" #include "FairBaseParSet.h" #include "FairGeoVolume.h" #include "TString.h" #include "FairGeoTransform.h" #include "FairGeoVector.h" #include "FairGeoMedium.h" #include "FairGeoNode.h" #include "PndGeoDrcPar.h" #include "TFormula.h" #include "TMath.h" #include "TParticlePDG.h" #include "TDatabasePDG.h" #include "TPDGCode.h" #include "TGeoManager.h" #include "TCanvas.h" #include "TFile.h" #include "TLegend.h" #include "TStyle.h" #include "TF1.h" #include "TExec.h" #include "TLine.h" #include "TPolyLine.h" //#include "PndChPho.h" #include "PndDrcLutInfo.h" #include "PndDrcDigiPar.h" #include "TVectorD.h" using std::endl; using std::cout; // ----- Default constructor ------------------------------------------- PndDrcRecoLookupMapS::PndDrcRecoLookupMapS() :FairTask("PndDrcRecoLookupMapS") { fGeo = new PndGeoDrc(); fGeoH=NULL; fDigiPar = NULL; } // ----- Standard constructor with verbosity level ------------------------------------------- PndDrcRecoLookupMapS::PndDrcRecoLookupMapS(Int_t verbose) :FairTask("PndDrcRecoLookupMapS") { fVerbose = verbose; fGeo = new PndGeoDrc(); fGeoH=NULL; fDigiPar = NULL; } // ----- Destructor ---------------------------------------------------- PndDrcRecoLookupMapS::~PndDrcRecoLookupMapS() { if (fGeo) delete fGeo; if (fGeoH) delete fGeoH; fHistoList->Delete(); delete fHistoList; } // ----- Initialization ----------------------------------------------- InitStatus PndDrcRecoLookupMapS::Init() { cout << " ---------- INITIALIZATION ------------" << endl; nevents = 0; // Get RootManager FairRootManager* ioman = FairRootManager::Instance(); if ( ! ioman ) { cout << "-E- PndDrcRecoLookupMapS::Init: " << "RootManager not instantiated!" << endl; return kFATAL; } // Get input array fMCArray = (TClonesArray*) ioman->GetObject("MCTrack"); if ( ! fMCArray ) { cout << "-W- PndDrcRecoLookupMapS::Init: " << "No MCTrack array!" << endl; return kERROR; } // Get input array fBarPointArray = (TClonesArray*) ioman->GetObject("DrcBarPoint"); if ( ! fBarPointArray ) { cout << "-W- PndDrcRecoLookupMapS::Init: " << "No DrcBarPoint array!" << endl; return kERROR; } // Get Photon point array fPDPointArray = (TClonesArray*) ioman->GetObject("DrcPDPoint"); if ( ! fPDPointArray ) { cout << "-W- PndDrcRecoLookupMapS::Init: " << "No DrcPDPoint array!" << endl; return kERROR; } /* // Get input array fHitArray = (TClonesArray*) ioman->GetObject("DrcHit"); if ( ! fHitArray ) { cout << "-W- PndDrcRecoLookupMapS::Init: " << "No DrcHit array!" << endl; return kERROR; } */ // Get digi array fDigiArray = (TClonesArray*) ioman->GetObject("DrcDigi"); if ( ! fDigiArray ) { cout << "-W- PndDrcRecoLookupMapS::Init: " << "No DrcDigi array!" << endl; return kERROR; } // Get input array fPDHitArray = (TClonesArray*) ioman->GetObject("DrcPDHit"); if ( ! fPDHitArray ) { cout << "-W- PndDrcRecoLookupMapS::Init: " << "No DrcPDHit array!" << endl; return kERROR; } // Create and register output array // fChPhoArray = new TClonesArray("PndChPho"); // ioman->Register("ChPho","Drc",fChPhoArray, kTRUE); fDrcLutInfoArray = new TClonesArray("PndDrcLutInfo"); ioman->Register("DrcLutInfo","Drc",fDrcLutInfoArray, kTRUE); // Get parameters: fpi = TMath::Pi(); fR = fGeo->radius(); fzup = fGeo->barBoxZUp(); fzdown = fGeo->barBoxZDown(); fHThick = fGeo->barHalfThick(); fBboxNum = fGeo->BBoxNum(); fBarNum = fGeo->barNum(); fPipehAngle = fGeo->PipehAngle(); fBarBoxGap = fGeo->BBoxGap(); //fLength = (180. - 2.*fPipehAngle - fBarBoxGap/fR*(fBboxNum/2. - 1.)/fpi*180.)/(fBboxNum/2.) * fR/ 180.*fpi; fDphi = 2.*(180. - 2*fPipehAngle)/ fBboxNum; //[degrees] fLSide = fGeo->Lside();//(180. - 2.*fPipehAngle - fBarBoxGap/fR*(fBboxNum/2. - 1.)/fpi*180.)/(fBboxNum/2.) * fR/ 180.*fpi; fBarWidth = fGeo->BarWidth();//fLSide/fBarNum; // vectors of bar surfaces: fnX1.SetXYZ(-1., 0.,0.); fnY1.SetXYZ( 0., 1.,0.); cout << "-I- PndDrcRecoLookupMapS: Intialization successfull" << endl; CreateHisto(); return kSUCCESS; } // ----- Private method SetParContainers ------------------------------- void PndDrcRecoLookupMapS::SetParContainers() { // Get run and runtime database FairRunAna* run = FairRunAna::Instance(); if ( ! run ) Fatal("SetParContainers", "No analysis run"); FairRuntimeDb* db = run->GetRuntimeDb(); if ( ! db ) Fatal("SetParContainers", "No runtime database"); // Get DIRC digitisation parameter container fDigiPar = (PndDrcDigiPar*)(db->getContainer("DIRCLookupTable")); cout << "-I- PndDrcRecoLookupMapS::SetParContainers(). read parameters" << endl; cout<<"read them!"<GetNHitPixels()<< endl; cout << "-I- PndDrcRecoLookupMapS: Number of hit pixels "<< fDigiPar->GetNAmbiguities()<< endl; if ( fGeoH == NULL ) fGeoH = PndGeoHandling::Instance(); fGeoH->SetParContainers(); if(fVerbose>1) Info("SetParContainers","done."); return; } // ------------------------------------------------------------------------- // ----- Execution of Task --------------------------------------------- void PndDrcRecoLookupMapS::Exec(Option_t* option) { //if ( ! fChPhoArray ) Fatal("Exec", "No fChPhoArray"); //fChPhoArray->Clear(); fGeoH->SetVerbose(fVerbose); nevents++; fDetectorID = 0; cout<<"EVENT # "< 0) { cout <<"PndDrcRecoLookupMapS: Number of Detected MC Tracks : "<GetEntries()<GetEntriesFast(); j++) { hit = (PndDrcHit*)fHitArray->At(j); Int_t mcRef= hit->GetRefIndex(); pt= (PndDrcBarPoint*)fBarPointArray->At(mcRef); Int_t chtrID= pt->GetTrackID(); tr = (PndMCTrack*)fMCArray->At(chtrID); cout<<"nother track px = "<GetPx()<<", py = "<GetPy()<Clear(); PndDrcLutInfo lutinfo; PndDrcPDPoint* Ppt=NULL; PndDrcPDHit* pdhit=NULL; PndMCTrack* tr = NULL; PndMCTrack* trMr; if (fVerbose > 0) { cout <<"PndDrcRecoLookupMapS: Number of Detected Photon MCPDPoints : "<GetEntries()<GetEntries()<GetEntriesFast(); k++) { pdhit = (PndDrcPDHit*)fPDHitArray->At(k); Int_t mcPDRef= pdhit->GetRefIndex(); if(mcPDRef < 0)continue; Ppt = (PndDrcPDPoint*)fPDPointArray->At(mcPDRef); if(Ppt->GetBarPointID() < 0) continue; PndDrcBarPoint *fBarPoint= (PndDrcBarPoint*)fBarPointArray->At(Ppt->GetBarPointID()); fBarId = fBarPoint->GetDetectorID(); if(fBarId < 0)continue; //cout<<"bar name - "<GetPath(fBarId)<GetTrackID(); tr = (PndMCTrack*)fMCArray->At(trID); Int_t trMID=tr->GetMotherID(); //if(trMID > -1){ trMr = (PndMCTrack*)fMCArray->At(trMID); Int_t trMpdg=trMr->GetPdgCode(); if(trMr->GetMotherID()==-1){ // charged track is a primary lutinfo.SetChPartPdg(trMpdg); // expected cherenkov angle Double_t Mrmass; Int_t MoSign; if(fabs(trMpdg) == 11){Mrmass = 0.000511; MoSign = 1;} if(fabs(trMpdg) == 13){Mrmass = 0.105658; MoSign = 1;} if(fabs(trMpdg) == 211){Mrmass = 0.139570; MoSign = -1;} if(fabs(trMpdg) == 321){Mrmass = 0.49368; MoSign = -1;} if(fabs(trMpdg) == 2212){Mrmass = 0.938; MoSign = -1;} if(fabs(trMpdg) == 50000050){Mrmass = 0.0; MoSign = -1;} Double_t Mrmom = trMr->GetMomentum().Mag(); CHexp = acos(sqrt(pow(Mrmom,2) + pow(Mrmass,2))/Mrmom/fGeo->nQuartz()); lutinfo.SetCherenkovMC(CHexp); //cout<<"+++++++++++++++++++++++++++"<GetMomentum(); //cout<<"Initial momentum of the photon :"< 1.00028/fGeo->nQuartz() || (fkBar.Cross(fnY1)).Mag() > 1.00028/fGeo->nQuartz())){ ambig.push_back(fkBar); CHreco.push_back(fkBar.Angle(fPMoB)); CHdiff(8*i+jamb) = fabs(CHreco[8*i+jamb] - CHexp); Tamb.push_back(RecoAmbigTime(fkBar, fStartVertex, &fPath, 0)); Path.push_back(fPath); Adiff(8*i+jamb) = fkBar.Angle(fPphoB); //cout<<"reco ch angle = "<= 3.1415/2.){ Z0 = -(start.Z() - fzup); } X0 = Z0*TMath::Tan(dir.Theta())*TMath::Cos(dir.Phi()); Y0 = Z0*TMath::Tan(dir.Theta())*TMath::Sin(dir.Phi()); //cout<<"-I- NumberOfBounces: tan th = "<= 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(printt){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(printt){std::cout<<"xK = "<< xK<<", n = "<SetLineWidth(2); p6->Draw("same"); } //-------------------------------------------------------------------------------------------- Double_t PndDrcRecoLookupMapS::RecoAmbigTime(TVector3 kb, TVector3 start, Double_t *l, Bool_t printout){ // [ns] // group velocities for oil and quartz for Noil and Nquartz assuming that mean lambda = 410 nm: //Double_t nOil = fGeo->nEV(); Double_t u_oil = 19.8;//30./nOil; //Double_t u_quartz = 30./1.46907; // for lambda = 410 nm //Double_t u_quartz = 30./1.47012; // for lambda = 400 nm //Double_t u_quartz = 30./1.46838; // for lambda = 417 nm //Double_t u_quartz = 30./1.47125; // for lambda = 390 nm //Double_t u_quartz = 30./1.47248; // for lambda = 380 nm Double_t u_quartz = 20.;//30./fNquartz;//1.47805; // for lambda = 400 nm // kb - photon momentum at the production point, first calculate path in QUARTZ BAR: // assume that there are only DIRECT photons!!! // path in quartz: Double_t Z0 = 0.; Double_t kz = 0.; if(kb.Z() < 0.){Z0 = start.Z() - fGeo->barBoxZUp(); kz = kb.Z();} if(kb.Z() >= 0.){Z0 = 2.*fGeo->barBoxZDown() - fGeo->barBoxZUp() - start.Z(); kz = -kb.Z();} if(printout){ cout<<"-I- Reco ambig Time: Zstart = "<