// ------------------------------------------------------------------------- // ----- PndPhoGunShort source file ----- // ----- Created 12/10/10 by Maria Patsyuk ----- // ----- ----- // ----- ----- // ------------------------------------------------------------------------- #include #include #include "stdio.h" #include "PndGeoDrc.h" #include "PndPhoGunShort.h" #include "FairRootManager.h" #include "PndMCTrack.h" #include "TVector3.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 "TMath.h" #include "TParticlePDG.h" #include "TDatabasePDG.h" #include "TPDGCode.h" #include "TGeoManager.h" #include "TFile.h" #include "TExec.h" using std::endl; using std::cout; // ----- Default constructor ------------------------------------------- PndPhoGunShort::PndPhoGunShort() :FairTask("PndPhoGunShort") { fGeo = new PndGeoDrc(); fGeoH=NULL; } // ----- Standard constructor with verbosity level ------------------------------------------- PndPhoGunShort::PndPhoGunShort(Int_t verbose) :FairTask("PndPhoGunShort") { fVerbose = verbose; fGeo = new PndGeoDrc(); fGeoH=NULL; } // ----- Destructor ---------------------------------------------------- PndPhoGunShort::~PndPhoGunShort() { if (fGeo) delete fGeo; if (fGeoH) delete fGeoH; fHistoList->Delete(); delete fHistoList; } // ----- Initialization ----------------------------------------------- InitStatus PndPhoGunShort::Init() { cout << " ---------- INITIALIZATION ------------" << endl; nevents = 0; // Get RootManager FairRootManager* ioman = FairRootManager::Instance(); if ( ! ioman ) { cout << "-E- PndPhoGunShort::Init: " << "RootManager not instantiated!" << endl; return kFATAL; } // Get input array fMCArray = (TClonesArray*) ioman->GetObject("MCTrack"); if ( ! fMCArray ) { cout << "-W- PndPhoGunShort::Init: " << "No MCTrack array!" << endl; return kERROR; } // Get Photon point array fPDPointArray = (TClonesArray*) ioman->GetObject("DrcPDPoint"); if ( ! fPDPointArray ) { cout << "-W- PndPhoGunShort::Init: " << "No DrcPDPoint array!" << endl; return kERROR; } // Get input array fPDHitArray = (TClonesArray*) ioman->GetObject("DrcPDHit"); if ( ! fPDHitArray ) { cout << "-W- PndPhoGunShort::Init: " << "No DrcPDHit array!" << endl; return kERROR; } fEVPointArray = (TClonesArray*) ioman->GetObject("DrcEVPoint"); if ( ! fEVPointArray ) { cout << "-W- PndPhoGunShort::Init: " << "No DrcEVPoint array!" << endl; return kERROR; } fBarPointArray = (TClonesArray*) ioman->GetObject("DrcBarPoint"); if ( ! fBarPointArray ) { cout << "-W- PndDrcLogLikeli::Init: " << "No DrcBarPoint array!" << endl; return kERROR; } fDigiArray = (TClonesArray*) ioman->GetObject("DrcDigi"); if ( ! fDigiArray ) { cout << "-W- PndPhoGunShortP::Init: " << "No DrcDigi array!" << endl; return kERROR; } // Get parameters: fpi = TMath::Pi(); fR = fGeo->radius(); fHThick = fGeo->barHalfThick(); fBboxNum = fGeo->BBoxNum(); fPipehAngle = fGeo->PipehAngle(); fBarBoxGap = fGeo->BBoxGap(); fLength = (180. - 2.*fPipehAngle - fBarBoxGap/fR*(fBboxNum/2. - 1.)/fpi*180.)/(fBboxNum/2.) * fR/ 180.*fpi; fDphi = fGeo->BBoxAngle();//21.65 degrees = 2.*(180. - 2*fPipehAngle)/ fBboxNum; //[degrees] fPixelSize = fGeo->PixelSize(); //Double_t EVlen = gGeoManager->GetVolume("DrcEVSensor")->GetShape()->Dz(); //fEVlen = fGeo->EVlen(); fEVdrop = fGeo->EVdrop(); fEVlen =fEVdz; fRBottom = fR - fHThick - fEVdrop + fR*(1.-cos(fDphi/2./180.*fpi))/cos(fDphi/2./180.*fpi); //cout<<"fR = "<Branch(Form("LUT%d",iLut),&fLut[iLut],256000,0); } InitLut(); if ( fGeoH == NULL ) fGeoH = PndGeoHandling::Instance(); fGeoH->SetParContainers(); //fGeoH->GetGeoManager(); //const Double_t *truuu = gGeoManager->GetVolume("DrcEVSensor")->GetShape()->GetTransform()->GetTranslation(); //fLowZ = truuu[2]-fGeo->EVlen(); //cout<<"posZ = "<SetVerbose(fVerbose); fDetectorID = 0; /*if(nevents%1000==0)*/ cout<<"Event # "<GetEntriesFast(); k++) { pdhit = (PndDrcPDHit*)fPDHitArray->At(k); Int_t mcPDRef= pdhit->GetRefIndex(); fDigi = (PndDrcDigi*) fDigiArray->At(mcPDRef); Int_t pointID= fDigi->GetIndex(0); Ppt = (PndDrcPDPoint*)fPDPointArray->At(pointID); Int_t trID= Ppt->GetTrackID(); tr = (PndMCTrack*)fMCArray->At(trID); EVpt = (PndDrcEVPoint*)fEVPointArray->At(mcPDRef); if(trID!=EVpt->GetTrackID())cout<<"different track IDs"<GetEntriesFast(); if(trID!=EVpt->GetTrackID())continue; PndDrcBarPoint *fBarPoint= (PndDrcBarPoint*)fBarPointArray->At(Ppt->GetBarPointID()); // fBarId = fBarPoint->GetDetectorID(); fBarId = fBarPoint->GetBarId(); // production point of the photon fStartVertex = tr->GetStartVertex(); // find PHIrot to get to the bar coord. syst: fPhiRot = InBarCoordSyst(fStartVertex, &fBBver1, &fBBver2, &fBBver3, &fBBver4); // check if the last of the EV points is on the PD plane as the reflection was in the grease layer/window/photocathode, then exclude this point if(((PndDrcEVPoint*)fEVPointArray->At(EVEntry-1))->GetZ() < ((PndDrcEVPoint*)fEVPointArray->At(0))->GetZ()-fEVlen+0.01){EVEntry = EVEntry - 1;} //check if there are EVpoints on the PD plane and these points are not the last in the array, then reject the photon Bool_t wePho = kFALSE; for(Int_t k2 = 1; k2 < fEVPointArray->GetEntriesFast()-1; k2++){ if((((PndDrcEVPoint*)fEVPointArray->At(k2))->GetZ()) < ((PndDrcEVPoint*)fEVPointArray->At(0))->GetZ()-fEVlen+0.01){ //cout<<"this is a weird photon - has EV points at the PD plane!!!"<4){ fNweirdPhotons += 1; continue; } ReflName=""; if(EVEntry==1)ReflName="DD"; fZin = ((PndDrcEVPoint*)fEVPointArray->At(0))->GetZ(); if(EVEntry>1){ for(Int_t k1 = 1; k1 < EVEntry; k1++){ Int_t EVS=0; EVt = (PndDrcEVPoint*)fEVPointArray->At(k1); fEVSec.SetXYZ(EVt->GetX(),EVt->GetY(),EVt->GetZ()); fPhiRotEV=InBarCoordSyst(fEVSec, &fBBver1, &fBBver2, &fBBver3, &fBBver4); fPhiRotEV=fPhiRotEV*180./fpi; fEVPhi=fEVSec.Phi()*180./fpi; //cout<<"EV phi = "<=6)ReflName.Append("XX"); ReflName.Prepend(Form("%d",PhiSec)); } // 24 ambiguities in total: if(ReflName == "DD"){fNoDD +=1;SelectionName=1;ambiguity =1;} if(ReflName == "0B1"){fNoB +=1;SelectionName=1;ambiguity =2;} if(ReflName == "0U1"){fNoU0 +=1;SelectionName=1;ambiguity =3;} if(ReflName == "1U1"){fNoU1 +=1;SelectionName=1;ambiguity =4;} if(ReflName == "2U1"){fNoU2 +=1;SelectionName=1;ambiguity =5;} if(ReflName == "3U1"){fNoU3 +=1;SelectionName=1;ambiguity =6;} if(ReflName == "0BU2"){fNoBU0 +=1;SelectionName=1;ambiguity =7;} if(ReflName == "1BU2"){fNoBU1 +=1;SelectionName=1;ambiguity =8;} if(ReflName == "2BU2"){fNoBU2 +=1;SelectionName=1;ambiguity =9;} if(ReflName == "0UB2"){fNoUB +=1; SelectionName=1;ambiguity =10;} if(ReflName == "0UU2"){fNoUU0 +=1; SelectionName=1;ambiguity =11;} if(ReflName == "1UU2"){fNoUU1 +=1;SelectionName=1;ambiguity =12;} if(ReflName == "2UU2"){fNoUU2 +=1;SelectionName=1;ambiguity =13;} if(ReflName == "3UU2"){fNoUU3 +=1; SelectionName=1;ambiguity =14;} if(ReflName == "0UUU3"){fNoUUU0 +=1; SelectionName=1;ambiguity =15;} if(ReflName == "1UUU3"){fNoUUU1 +=1; SelectionName=1;ambiguity =16;} if(ReflName == "2UUU3"){fNoUUU2 +=1; SelectionName=1;ambiguity =17;} if(ReflName == "3UUU3"){fNoUUU3 +=1; SelectionName=1;ambiguity =18;} if(ReflName == "4UUU3"){fNoUUU4 +=1; SelectionName=1;ambiguity =19;} if(ReflName == "0BUU3"){fNoBUU0 +=1; SelectionName=1;ambiguity =20;} if(ReflName == "1BUU3"){fNoBUU1 +=1; SelectionName=1;ambiguity =21;} if(ReflName == "2BUU3"){fNoBUU2 +=1; SelectionName=1;ambiguity =22;} if(ReflName == "BUB3"){fNoBUB +=1; SelectionName=1;ambiguity =23;} if(ReflName == "UBU3"){fNoUBU +=1; SelectionName=1;ambiguity =24;} if(ReflName == ""){ambiguity =-99;} if(SelectionName==0.){continue;} fPixIndex = fDigi->GetSensorId(); // fPixIndex = pdhit->GetDetectorID(); ftime = Ppt->GetTime();//pdhit->GetTime(); // Photon initial momentum in the bar coord. syst. fPphoInit = tr->GetMomentum(); //fPphoB = (fGeoH->MasterToLocalShortId(fPphoInit, fBarId) - fGeoH->MasterToLocalShortId((0.,0.,0.),fBarId)).Unit(); // fPphoB.Print(); // Photon initial momentum in the bar coord. syst. fPphoB = (tr->GetMomentum()).Unit(); fPphoB.RotateZ(-fPhiRot); // fkxBar = -fPphoB.Y(); // fkyBar = fPphoB.X(); // fkzBar = fPphoB.Z(); fkxBar = fPphoB.X(); fkyBar = fPphoB.Y(); fkzBar = fPphoB.Z(); fPphoB.SetXYZ(fkxBar,fkyBar,fkzBar); ((PndDrcLutNode*)(fLut[fBarId]->At(fPixIndex)))->AddEntry(fDigi->GetDetectorId(), fPphoB,ambiguity,ftime,pdhit->GetPosition()); // ((PndDrcLutNodeH*)(fLut->At(fPixIndex)))->AddEntry(fPphoB,ambiguity,ftime); // ((PndDrcLutNodeH*)(fLut->At(fPixIndex)))->SetPos(pdhit->GetPosition()); // Double_t rrr = sqrt(pow(pdhit->GetX(),2) + pow(pdhit->GetY(),2)); //if(ambiguity>2){ // cout<<"pix "< -0.02 && determint1 < 0.02)ReflectionType="B"; fmatrixdata.Reset(0); fmatrixdata[0]=xev-PlanU[0]; fmatrixdata[1]=yev-PlanU[1]; fmatrixdata[2]=zev-PlanU[2]; fmatrixdata[3]=PlanU[3]-PlanU[0]; fmatrixdata[4]=PlanU[4]-PlanU[1]; fmatrixdata[5]=PlanU[5]-PlanU[2]; fmatrixdata[6]=PlanU[6]-PlanU[0]; fmatrixdata[7]=PlanU[7]-PlanU[1]; fmatrixdata[8]=PlanU[8]-PlanU[2]; matrix1.Use(3,3,fmatrixdata.GetArray()); determint2 = matrix1.Determinant(); if(determint2 > -0.02 && determint2 < 0.02)ReflectionType="U"; //cout<<"determinants: "<