// $Id: hrichcorrcounter.cc,v 1.10 2009-07-15 11:39:21 halo Exp $ // Last update by Thomas Eberl: 02/09/25 17:30:18 // using namespace std; #include "hrichcorrcounter.h" #include "hruntimedb.h" #include "hevent.h" #include "hspectrometer.h" #include "hdetector.h" #include "hcategory.h" #include "hiterator.h" #include #include #include "hdebug.h" #include "hades.h" #include "richdef.h" #include "hhitmatchheader.h" #include "hhitmatch.h" #include "hlinearcategory.h" #include "hrichutilfunc.h" #include "hkicktrack.h" #include "kickdef.h" ClassImp(HRichCorrCounter) HRichCorrCounter::HRichCorrCounter(const Text_t *name,const Text_t *title) : HReconstructor(name,title) { } HRichCorrCounter::HRichCorrCounter() { } HRichCorrCounter::HRichCorrCounter(const Text_t *name,const Text_t *title,const Char_t* filename) : HReconstructor(name,title) { pFileName = filename;// output filename for diagnostic histos } HRichCorrCounter::~HRichCorrCounter(void) { } Bool_t HRichCorrCounter::init() { if (gHades) { HEvent *event=gHades->getCurrentEvent(); HRuntimeDb *rtdb=gHades->getRuntimeDb(); HSpectrometer *spec=gHades->getSetup(); if (event && rtdb) { HDetector *rich = spec->getDetector("Rich"); if (rich) { //Has the user set up a RICH? pHitMatchCat=event->getCategory(catMatchHit); if (!pHitMatchCat) { pHitMatchCat=rich->buildCategory(catMatchHit); if (!pHitMatchCat) { Error("init","No HIT MATCH category defined"); return kFALSE; } else event->addCategory(catMatchHit, pHitMatchCat, "Rich"); } pIterMatchHit = (HIterator*)getHitMatchCat()->MakeIterator("native"); pHitMatchHeaderCat=event->getCategory(catMatchHitHeader); if (!pHitMatchHeaderCat) { pHitMatchHeaderCat=rich->buildCategory(catMatchHitHeader); cout<<"i have built hhitmatchheader"<addCategory(catMatchHitHeader, pHitMatchHeaderCat, "Rich"); } pIterMatchHitHeader = (HIterator*)getHitMatchHeaderCat() ->MakeIterator("native"); } fKickTrackCat = gHades->getCurrentEvent()->getCategory(catKickTrack); if (!fKickTrackCat) { Error("init","KickTrack not found in input file"); return kFALSE; } iterTracks = (HIterator *)fKickTrackCat->MakeIterator("native"); cout<<"itertracks :"<Reset(); while(( pHM= (HHitMatch *)pIterMatchHit->Next())) nNbCorrObjs++; // helper arrays to determine number of diff indexes of hits Int_t *tRind = new Int_t[nNbCorrObjs];//cannot be bigger than nb of corrs Int_t *tRichminRMind = new Int_t[nNbCorrObjs]; Int_t *tRichminRTind = new Int_t[nNbCorrObjs]; Int_t *tRichminRSind = new Int_t[nNbCorrObjs]; Int_t *tRichminRMTind = new Int_t[nNbCorrObjs]; Int_t *tRichminRMSind = new Int_t[nNbCorrObjs]; Int_t *tRcMcTcRind = new Int_t[nNbCorrObjs]; Int_t *tRcMcScRind = new Int_t[nNbCorrObjs]; Int_t *tRcMTcRind = new Int_t[nNbCorrObjs]; Int_t *tRcMScRind = new Int_t[nNbCorrObjs]; Int_t *tRcMcTind = new Int_t[nNbCorrObjs]; Int_t *tRcMcSind = new Int_t[nNbCorrObjs]; Int_t *tRMcTcRind = new Int_t[nNbCorrObjs]; Int_t *tRMcScRind = new Int_t[nNbCorrObjs]; Int_t *tRMind = new Int_t[nNbCorrObjs]; Int_t *tRTind = new Int_t[nNbCorrObjs]; Int_t *tRSind = new Int_t[nNbCorrObjs]; Int_t *tMTind = new Int_t[nNbCorrObjs]; Int_t *tMSind = new Int_t[nNbCorrObjs]; Int_t *tMind = new Int_t[nNbCorrObjs]; Int_t *tTind = new Int_t[nNbCorrObjs]; Int_t *tSind = new Int_t[nNbCorrObjs]; for (Int_t i=0;iReset(); while(( pHM= (HHitMatch *)pIterMatchHit->Next())) { //pHM->dumpToStdout(); //indexes in respective hit cntr //useful to see whether det is in corr indep from specific one Int_t nRInd = pHM->getRichInd(); Int_t nMInd = pHM->getMdcInd(); Int_t nTInd = pHM->getTofInd(); Int_t nSInd = pHM->getShowInd(); Int_t tmp=0; if(nRInd!=-1) tmp=fillUniqueIndex(nRInd,nNbCorrObjs,tRind); if(nMInd!=-1) tmp=fillUniqueIndex(nMInd,nNbCorrObjs,tMind); if(nTInd!=-1) tmp=fillUniqueIndex(nTInd,nNbCorrObjs,tTind); if(nSInd!=-1) tmp=fillUniqueIndex(nSInd,nNbCorrObjs,tSind); //flags indicating a det bi correlation Int_t nRM = pHM->getMatchedRichMdc(); Int_t nRT = pHM->getMatchedRichTof(); Int_t nRS = pHM->getMatchedRichShower(); Int_t nMT = pHM->getMatchedMdcTof(); Int_t nMS = pHM->getMatchedMdcShower(); // ------------------------------------------------- // min a RM correlation in the tracklet if (nRM==1 && nRInd!=-1) tmp=fillUniqueIndex(nRInd,nNbCorrObjs,tRichminRMind); if (nRT==1 && nRInd!=-1) tmp=fillUniqueIndex(nRInd,nNbCorrObjs,tRichminRTind); if (nRS==1 && nRInd!=-1) tmp=fillUniqueIndex(nRInd,nNbCorrObjs,tRichminRSind); //min a tri corr obj if (nRInd!=-1 && nTInd!=-1 && nMInd!=-1) { nRTM++; tmp=fillUniqueIndex(nRInd,nNbCorrObjs,tRichminRMTind); } else if (nRInd!=-1 && nSInd!=-1 && nMInd!=-1) { nRSM++; tmp=fillUniqueIndex(nRInd,nNbCorrObjs,tRichminRMSind); } //sub cases of the two above if (nRInd!=-1 && nTInd!=-1 && nMInd!=-1 && nRM==1 && nRT==1 && nMT==1 ) { nlNb_RcMcTcR++; tmp=fillUniqueIndex(nRInd,nNbCorrObjs,tRcMcTcRind); } else if (nRInd!=-1 && nSInd!=-1 && nMInd!=-1 && nRM==1 && nRS==1 && nMS==1 ) { nlNb_RcMcScR++; tmp=fillUniqueIndex(nRInd,nNbCorrObjs,tRcMcScRind); } else if (nRInd!=-1 && nTInd!=-1 && nMInd!=-1 && nRM==1 && nRT==1) { nlNb_RcMTcR++; tmp=fillUniqueIndex(nRInd,nNbCorrObjs,tRcMTcRind); } else if (nRInd!=-1 && nSInd!=-1 && nMInd!=-1 && nRM==1 && nRS==1) { nlNb_RcMScR++; tmp=fillUniqueIndex(nRInd,nNbCorrObjs,tRcMScRind); } else if (nRInd!=-1 && nTInd!=-1 && nMInd!=-1 && nRM==1 && nMT==1) { nlNb_RcMcT++; tmp=fillUniqueIndex(nRInd,nNbCorrObjs,tRcMcTind); } else if (nRInd!=-1 && nSInd!=-1 && nMInd!=-1 && nRM==1 && nMS==1) { nlNb_RcMcS++; tmp=fillUniqueIndex(nRInd,nNbCorrObjs,tRcMcSind); } else if (nRInd!=-1 && nTInd!=-1 && nMInd!=-1 && nRT==1 && nMT==1) { nlNb_RMcTcR++; tmp=fillUniqueIndex(nRInd,nNbCorrObjs,tRMcTcRind); } else if (nRInd!=-1 && nSInd!=-1 && nMInd!=-1 && nRS==1 && nMS==1) { nlNb_RMcScR++; tmp=fillUniqueIndex(nRInd,nNbCorrObjs,tRMcScRind); } // only a bi corr object ----------------------------------- if (nRInd!=-1 && nMInd!=-1 && nTInd==-1 && nSInd==-1 && nRM==1) { nlNb_RM++; tmp=fillUniqueIndex(nRInd,nNbCorrObjs,tRMind); } else if (nRInd!=-1 && nTInd!=-1 && nMInd==-1 && nSInd==-1 && nRT==1) { nlNb_RT++; tmp=fillUniqueIndex(nRInd,nNbCorrObjs,tRTind); } else if (nRInd!=-1 && nSInd!=-1 && nMInd==-1 && nTInd==-1 && nRS==1) { nlNb_RS++; tmp=fillUniqueIndex(nRInd,nNbCorrObjs,tRSind); } else if (nMInd!=-1 && nTInd!=-1 && nRInd==-1 && nSInd==-1 && nMT==1) { nlNb_MT++; tmp=fillUniqueIndex(nMInd,nNbCorrObjs,tMTind); } else if (nMInd!=-1 && nSInd!=-1 && nRInd==-1 && nTInd==-1 && nMS==1) { nlNb_MS++; tmp=fillUniqueIndex(nMInd,nNbCorrObjs,tMSind); } }// end while over HHitMatch // increment resp var for the whole run // and fill evt wise value in HHitMatchHeader obj // (there are n (Rich) hits in nNbCorrObjs tracklets // in this evt, but only mReset(); while(( pHMH= (HHitMatchHeader *)pIterMatchHitHeader->Next())) { pHMH->setNbCorrObjs(nNbCorrObjs); pHMH->setNbDiscreteRichHits(nDRind); pHMH->setNbDiscreteRichRMHits(nDRichminRMind);//at least a RM corr pHMH->setNbDiscreteRichonlyRMHits(nDRMind);//only RM, nothing more pHMH->setNbDiscreteMdcSegHits(nDMind); pHMH->setNbDiscreteShowerHits(nDSind); pHMH->setNbDiscreteTofHits(nDTind); ngNb_RM+=nlNb_RM;//only these two are matched pHMH->setNb_RM(nlNb_RM); ngNb_RT+=nlNb_RT; pHMH->setNb_RT(nlNb_RT); ngNb_RS+=nlNb_RS; pHMH->setNb_RS(nlNb_RS); ngNb_MT+=nlNb_MT; pHMH->setNb_MT(nlNb_MT); ngNb_MS+=nlNb_MS; pHMH->setNb_MS(nlNb_MS); // three diff dets contrib ngNb_RcMcT+=nlNb_RcMcT;// RM MT pHMH->setNb_RcMcT(nlNb_RcMcT); ngNb_RcMcTcR+=nlNb_RcMcTcR;// RM MT RT pHMH->setNb_RcMcTcR(nlNb_RcMcTcR); ngNb_RMcTcR+=nlNb_RMcTcR;// MT RT pHMH->setNb_RMcTcR(nlNb_RMcTcR); ngNb_RcMTcR+=nlNb_RcMTcR;// RM RT pHMH->setNb_RcMTcR(nlNb_RcMTcR); ngNb_RcMcS+=nlNb_RcMcS;// RM MS pHMH->setNb_RcMcS(nlNb_RcMcS); ngNb_RcMcScR+=nlNb_RcMcScR;// RM MS RS pHMH->setNb_RcMcScR(nlNb_RcMcScR); ngNb_RMcScR+=nlNb_RMcScR;// MS RS pHMH->setNb_RMcScR(nlNb_RMcScR); ngNb_RcMScR+=nlNb_RcMScR;// RM RS pHMH->setNb_RcMScR(nlNb_RcMScR); ngRTM+=nRTM;//min 3 indexes in obj indep of corr pHMH->setNb_minRMT(nRTM); ngRSM+=nRSM; pHMH->setNb_minRMS(nRSM); ngRichCnt+=pHMH->getNbRichHits(); ngMdcSegCnt+=pHMH->getNbMdcSegHits(); ngShowerCnt+=pHMH->getNbShowerHits(); ngTofCnt+=pHMH->getNbTofHits(); } //end while HHitMatchheader //*********************************************************************** // this section is supposed to determine how many // rings are correlated with 1, 2, 3, ... n MDC segments and/or META hits Int_t nHM = ((HLinearCategory*)getHitMatchCat())->getEntries(); if (nHM==0) return 0; // nothing to be done Int_t *nRInd = new Int_t[nHM]; // arrays to store hit cat indexes Int_t *nMInd = new Int_t[nHM]; Int_t *nTInd = new Int_t[nHM]; Int_t *nSInd = new Int_t[nHM]; Int_t *nHInd = new Int_t[nHM]; // initialization needed for function like fillUniqueIndexes for (Int_t i=0;iReset(); while(( pHM= (HHitMatch *)pIterMatchHit->Next())) { nRInd[ntc] = pHM->getRichInd(); nMInd[ntc] = pHM->getMdcInd(); nTInd[ntc] = pHM->getTofInd(); nSInd[ntc] = pHM->getShowInd(); nHInd[ntc] = ((HLinearCategory*)getHitMatchCat())->getIndex(pHM); ntc++; } Int_t *six = new Int_t[nHM]; // sorted indexes TMath::Sort(nHM,nRInd,six); // descending // example how to retrieve obj from cat knowing idx //((HHitMatch*)getHitMatchCat()->getObject(nHMInd[idx])) Int_t ni, ne; // first and last index of the same ring in the sorted arr Int_t swt = 0; // a switch with the decision to count the ring or not ni=ne=0; Int_t nRichRingCnt=0; Int_t nMdcSegCnt=0; while(nigetObject(nHMInd[idx])) //->dumpToStdout(); } else { swt = 2; // next tracklet has different or no RICH ring break; } //cout<<"for 2 ni "< impossible ne-ni = 0 && swt=1 --> not a tracklet with a ring --> skip it ne-ni = 0 && swt=2 --> it was the last one --> check it for MDC corr ne-ni = 0 && swt=2 --> the ring of this tracklet doesn't occur twice in evt */ Int_t submax=ne-ni; if (submax==0) { switch(swt) { case 0: { cout<<"ERROR: ne-ni == 0 && swt == 0"<getObject(nHInd[idx])); Int_t rm=hm->getMatchedRichMdc(); Int_t rt=hm->getMatchedRichTof(); Int_t rs=hm->getMatchedRichShower(); if (nMInd[idx]>-1 && rm==1) fillUniqueIndex(nMInd[idx],submax,m); if (nTInd[idx]>-1 && rt==1) fillUniqueIndex(nTInd[idx],submax,t); if (nSInd[idx]>-1 && rs==1) fillUniqueIndex(nSInd[idx],submax,s); } nRichRingCnt++; if (countDiscreteIndexes(m,submax)>1) cout<<"Error Error"<getObject(nHInd[idx])); Int_t rm=hm->getMatchedRichMdc(); Int_t rt=hm->getMatchedRichTof(); Int_t rs=hm->getMatchedRichShower(); if (nMInd[idx]>-1 && rm==1) fillUniqueIndex(nMInd[idx],submax,m); if (nTInd[idx]>-1 && rt==1) fillUniqueIndex(nTInd[idx],submax,t); if (nSInd[idx]>-1 && rs==1) fillUniqueIndex(nSInd[idx],submax,s); if (hlp !=-1 && hlp!=nRInd[idx]) cout<<"Error !!!!!!!!!"<-1 && rm==1) cout<<"k "<-1 && rm==1) cout<<"k "<cd(); HRichUtilFunc::saveHistos(pFileOut,pHistArray); // pFileOut->Close(); return kTRUE; } void HRichCorrCounter::iniHistos() { //Int_t dTl=-20; // unused //Int_t dTh= 20; // unused //Int_t dTn= 40; // unused Int_t opl= 0; Int_t oph= 50; Int_t opn= 200; pHistArray = new TObjArray(5); pH_MdcTofThetadTheta=new TH2F("pH_MdcTofThetadTheta","pH_MdcTofThetadTheta", 80,10,90,40,-20,20); pHistArray->Add(pH_MdcTofThetadTheta); pH_MdcShowerThetadTheta=new TH2F("pH_MdcShowerThetadTheta","pH_MdcShowerThetadTheta", 80,10,90,40,-20,20); pHistArray->Add(pH_MdcShowerThetadTheta); pH_RichMdcThetadTheta=new TH2F("pH_RichMdcThetadTheta","pH_RichMdcThetadTheta", 80,10,90,80,-10,10); pHistArray->Add(pH_RichMdcThetadTheta); pH_RichMdcdTheta=new TH1F("pH_RichMdcdTheta","pH_RichMdcdTheta",200,-10,10); pHistArray->Add(pH_RichMdcdTheta); pH_MdcTofToftofdTheta=new TH2F("pH_MdcTofToftofdTheta","pH_MdcTofToftofdTheta", 80,1,40,40,-20,20); pHistArray->Add(pH_MdcTofToftofdTheta); pH_MdcShowerTofinotofdTheta=new TH2F("pH_MdcShowerTofinotofdTheta","pH_MdcShowerTofinotofdTheta", 80,1,40,40,-20,20); pHistArray->Add(pH_MdcShowerTofinotofdTheta); // opangle ---------------------- pH_opangleMDC = new TH1F("pH_opangleMDC","pH_opangleMDC",opn,opl,oph); pHistArray->Add(pH_opangleMDC); pH_opangleTOF = new TH1F("pH_opangleTOF","pH_opangleTOF",opn,opl,oph); pHistArray->Add(pH_opangleTOF); pH_opangleMETA = new TH1F("pH_opangleMETA","pH_opangleMETA",opn,opl,oph); pHistArray->Add(pH_opangleMETA); pH_opangleMETAdThetaMDCMETA = new TH2F("pH_opangleMETAdThetaMDCMETA","pH_opangleMETAdThetaMDCMETA",opn,opl,oph,200,-2,2); pHistArray->Add(pH_opangleMETAdThetaMDCMETA); // pH_opangleMETAdPhiMDCMETA = new TH2F("pH_opangleMETAdPhiMDCMETA","pH_opangleMETAdPhiMDCMETA",opn,opl,oph,10,-5,5); // pHistArray->Add(pH_opangleMETAdPhiMDCMETA); // pH_opangleMETAdPhiMDCMETA = new TH2F("pH_opangleMETAdPhiMDCMETA","pH_opangleMETAdPhiMDCMETA",50,0,1,50,0,1); //pHistArray->Add(pH_opangleMETAdPhiMDCMETA); pH_opangleMETAdPhiMDCMETA = new TH2F("pH_opangleMETAdPhiMDCMETA","pH_opangleMETAdPhiMDCMETA",50,0,500,50,0,500); pHistArray->Add(pH_opangleMETAdPhiMDCMETA); //--------------------- pH_MdcTofdTheta = new TH1F("pH_MdcTofdTheta","pH_MdcTofdTheta",20,-10,10); pHistArray->Add(pH_MdcTofdTheta); pH_MdcShowerdTheta = new TH1F("pH_MdcShowerdTheta","pH_MdcShowerdTheta",200,-10,10); pHistArray->Add(pH_MdcShowerdTheta); pH_MdcMETAdTheta = new TH1F("pH_MdcMETAdTheta","pH_MdcMETAdTheta",200,-10,10); pHistArray->Add(pH_MdcMETAdTheta); // ------------- RINGS ------------- pH_opangleTrksinRing = new TH2F("pH_opangleTrksinRing","pH_opangleTrksinRing",5,0,4,80,0,20); pHistArray->Add(pH_opangleTrksinRing); pH_RichDblPadNr = new TH1D("pH_RichDblPadNr","pH_RichDblPadNr",50,0,50); pHistArray->Add(pH_RichDblPadNr); pH_RichDblAmpl = new TH1D("pH_RichDblAmpl","pH_RichDblAmpl",150,0,1500); pHistArray->Add(pH_RichDblAmpl); pH_RichDblPatMat = new TH1D("pH_RichDblPatMat","pH_RichDblPatMat",90,100,1000); pHistArray->Add(pH_RichDblPatMat); pH_RichDblHouTra = new TH1D("pH_RichDblHouTra","pH_RichDblHouTra",60,0,500); pHistArray->Add(pH_RichDblHouTra); pH_RichSnglPadNr = new TH1D("pH_RichSnglPadNr","pH_RichSnglPadNr",50,0,50); pHistArray->Add(pH_RichSnglPadNr); pH_RichSnglAmpl = new TH1D("pH_RichSnglAmpl","pH_RichSnglAmpl",150,0,1500); pHistArray->Add(pH_RichSnglAmpl); pH_RichSnglPatMat = new TH1D("pH_RichSnglPatMat","pH_RichSnglPatMat",90,100,1000); pHistArray->Add(pH_RichSnglPatMat); pH_RichSnglHouTra = new TH1D("pH_RichSnglHouTra","pH_RichSnglHouTra",60,0,500); pHistArray->Add(pH_RichSnglHouTra); } Int_t HRichCorrCounter::fillHistos() { Int_t nHM = ((HLinearCategory*)getHitMatchCat())->getEntries(); //cout<<"fill Histos in EXP "<Reset(); HHitMatch* pHM=0; Int_t *MdcTof_MdcIndex=new Int_t[nHM];//store indexes used in MDC-TOF combinations Int_t *MdcTof_TofIndex=new Int_t[nHM]; Int_t *RichMdc_MdcIndex=new Int_t[nHM];//store indexes used in MDC-TOF combinations Int_t *RichMdc_RichIndex=new Int_t[nHM]; Int_t *MdcShower_MdcIndex=new Int_t[nHM];//store indexes used in MDC-TOF combinations Int_t *MdcShower_ShowerIndex=new Int_t[nHM]; TObjArray *so = new TObjArray(5); for (Int_t i=0;iNext())) { fillMdcTofThetadTheta(pHM,nHM, MdcTof_MdcIndex,MdcTof_TofIndex); fillMdcShowerThetadTheta(pHM,nHM, MdcShower_MdcIndex,MdcShower_ShowerIndex); fillRichMdcThetadTheta(pHM,nHM, RichMdc_MdcIndex,RichMdc_RichIndex); // select objs for opening angle distribution selectObj(so,pHM); } calcOpeningAngleMDC(so,pH_opangleMDC); calcOpeningAngleTOF(so,pH_opangleTOF); calcOpeningAngleMETA(so,pH_opangleMETA,pH_opangleMETAdThetaMDCMETA,pH_opangleMETAdPhiMDCMETA); delete so; delete [] MdcTof_MdcIndex; delete [] MdcTof_TofIndex; delete [] RichMdc_MdcIndex; delete [] RichMdc_RichIndex; delete [] MdcShower_MdcIndex; delete [] MdcShower_ShowerIndex; return 1; } Int_t HRichCorrCounter::selectObj(TObjArray* pRTM,HHitMatch* pHM) { Int_t c=0; Int_t nRInd = pHM->getRichInd(); Int_t nMInd = pHM->getMdcInd(); Int_t nTInd = pHM->getTofInd(); Int_t nSInd = pHM->getShowInd(); Int_t nRM = pHM->getMatchedRichMdc(); Int_t nRT = pHM->getMatchedRichTof(); Int_t nMT = pHM->getMatchedMdcTof(); Int_t nRS = pHM->getMatchedRichShower(); Int_t nMS = pHM->getMatchedMdcShower(); Float_t dThetaRM = TMath::Abs(pHM->getRichTheta()-pHM->getMdcTheta()); // check if it is in TOF if (nRInd!=-1 && nTInd!=-1 && nMInd!=-1 && nRM==1 && nRT==1 && nMT==1 ) { c++; if (dThetaRM<2.) pRTM->Add(pHM); } // check if it is in SHOWER else if (nRInd!=-1 && nSInd!=-1 && nMInd!=-1 && nRM==1 && nRS==1 && nMS==1 ) { c++; if (dThetaRM<2.) pRTM->Add(pHM); } return c; } void HRichCorrCounter::calcOpeningAngleMDC(TObjArray *pArr,TH1F* hist) { // make all combinations of correlated objs and call // calcopeningangles from hrichutilfunc Int_t nCnt=0; Int_t nMaxArr = pArr->GetLast()+1; if (nMaxArr==0) return; //cout<<" nMaxArr: "<getMdcInd(); if (ind1>-1) { for (Int_t j=nCnt;jgetMdcInd(); // if (ind2>-1 && checkCombinationSameCat(ind1,ind2,Mdc1,Mdc2,arrsize)==1) if (ind2>-1) { // cout<<"calc opangle !!! ind 1: "<getMdcTheta(); Float_t p1 = ((HHitMatch*)(*pArr)[i])->getMdcPhi(); Float_t t2 = ((HHitMatch*)(*pArr)[j])->getMdcTheta(); Float_t p2 = ((HHitMatch*)(*pArr)[j])->getMdcPhi(); //cout<<"t1: "<0.) hist->Fill(opangle); if (opangle>0.) { // check for unlike sign pair Float_t metat1,metap1,metat2,metap2; metat1=metap1=metat2=metap2=-2.; // first particle if ( ((HHitMatch*)(*pArr)[i])->getShowInd() > -1 ) { metat1=((HHitMatch*)(*pArr)[i])->getShowerTheta(); metap1=((HHitMatch*)(*pArr)[i])->getShowerPhi(); } else if ( ((HHitMatch*)(*pArr)[i])->getTofInd() > -1 ) { metat1=((HHitMatch*)(*pArr)[i])->getTofTheta(); metap1=((HHitMatch*)(*pArr)[i])->getTofPhi(); } // second particle if ( ((HHitMatch*)(*pArr)[j])->getShowInd() > -1 ) { metat2=((HHitMatch*)(*pArr)[j])->getShowerTheta(); metap2=((HHitMatch*)(*pArr)[j])->getShowerPhi(); } else if ( ((HHitMatch*)(*pArr)[j])->getTofInd() > -1 ) { metat2=((HHitMatch*)(*pArr)[j])->getTofTheta(); metap2=((HHitMatch*)(*pArr)[j])->getTofPhi(); } if ( ((t1-metat1)*(t2-metat2)) < 0. && opangle>0.) // it is an unlike sign pair { //cout<GetName()<<" --- "<Fill(opangle); // opangle with MDC for unlike sign pair. // check if rich hit is the same or different // if different : open pair // if the same : unresolved pair in rich, resolved by mdc Int_t rind1 = ((HHitMatch*)(*pArr)[i])->getRichInd(); Int_t rind2 = ((HHitMatch*)(*pArr)[j])->getRichInd(); if (rind1>-1 && rind2>-1 && rind1==rind2) // it is the same ring, a Double_t ring { pH_opangleTrksinRing->Fill(2,opangle); //2 tracks per 1 ring with opening angle opangle if (opangle<3.5) { pH_RichDblPadNr->Fill( ((HHitMatch*)(*pArr)[i])->getRingPadNr() ); pH_RichDblAmpl->Fill( ((HHitMatch*)(*pArr)[i])->getRingAmplitude() ); pH_RichDblPatMat->Fill( ((HHitMatch*)(*pArr)[i])->getRingPatMat() ); pH_RichDblHouTra->Fill( ((HHitMatch*)(*pArr)[i])->getRingHouTra() ); } } else if (rind1>-1 && rind2>-1 && rind1!=rind2) // it is not the same ring, most likely two singles { pH_opangleTrksinRing->Fill(1,opangle); if (opangle>5.) { pH_RichSnglPadNr->Fill( ((HHitMatch*)(*pArr)[i])->getRingPadNr() ); pH_RichSnglAmpl->Fill( ((HHitMatch*)(*pArr)[i])->getRingAmplitude() ); pH_RichSnglPatMat->Fill( ((HHitMatch*)(*pArr)[i])->getRingPatMat() ); pH_RichSnglHouTra->Fill( ((HHitMatch*)(*pArr)[i])->getRingHouTra() ); pH_RichSnglPadNr->Fill( ((HHitMatch*)(*pArr)[j])->getRingPadNr() ); pH_RichSnglAmpl->Fill( ((HHitMatch*)(*pArr)[j])->getRingAmplitude() ); pH_RichSnglPatMat->Fill( ((HHitMatch*)(*pArr)[j])->getRingPatMat() ); pH_RichSnglHouTra->Fill( ((HHitMatch*)(*pArr)[j])->getRingHouTra() ); } } } }//opangle>0 } } } } delete [] Mdc1; delete [] Mdc2; } void HRichCorrCounter::calcOpeningAngleTOF(TObjArray *pArr,TH1F* hist) { // make all combinations of correlated objs and call // calcopeningangles from hrichutilfunc Int_t nCnt=0; Int_t nMaxArr = pArr->GetLast()+1; //cout<<" nMaxArr: "<getTofInd(); if (ind1>-1) { for (Int_t j=nCnt;jgetTofInd(); if (ind2>-1 && checkCombinationSameCat(ind1,ind2,Tof1,Tof2,arrsize)==1) { // cout<<"calc opangle !!! ind 1: "<getTofTheta(); Float_t p1 = ((HHitMatch*)(*pArr)[i])->getTofPhi(); Float_t t2 = ((HHitMatch*)(*pArr)[j])->getTofTheta(); Float_t p2 = ((HHitMatch*)(*pArr)[j])->getTofPhi(); //cout<<"t1: "<0.) hist->Fill(opangle); } } } } delete [] Tof1; delete [] Tof2; } void HRichCorrCounter::calcOpeningAngleMETA(TObjArray *pArr,TH1F* hist,TH2F* hist2, TH2F* hist3) { // find all hits in TOF and SHOWER from the selected tracklets // store the angles in META of all different hits // calc the opening angle for all possible combinations Int_t nCnt=0; Int_t nMaxArr = pArr->GetLast()+1; Int_t nMaxArr2 = nMaxArr*nMaxArr; Int_t *TofU = new Int_t[nMaxArr]; Int_t *ShowerU = new Int_t[nMaxArr]; Float_t *Theta = new Float_t[nMaxArr2]; Float_t *Phi = new Float_t[nMaxArr2]; Float_t *DMdcMetaT = new Float_t[nMaxArr2]; Float_t *DMdcMetaP = new Float_t[nMaxArr2]; Float_t *KickMom = new Float_t[nMaxArr2]; for (Int_t i=0;igetTofInd(); Int_t inds=((HHitMatch*)(*pArr)[i])->getShowInd(); if (indt>-1)//TOF hit { Int_t tof_ret=fillUniqueIndex(indt,nMaxArr,TofU); tof_ret=-2; if (tof_ret==-1) Error("HRichCorrCounter::calcOpeningAngleMETA", "no unique tof index"); else if (tof_ret==-2) //not yet found tof { //HKickTrack* ktrack = getKickTrack(((HHitMatch*)(*pArr)[i])); //HKickTrack* ktrack = getKickTrack(((HHitMatch*)(*pArr)[i])->getMdcTheta(),((HHitMatch*)(*pArr)[i])->getMdcPhi(),((HHitMatch*)(*pArr)[i])->getSector()); //if (ktrack) //{ //remember the angles Int_t nb_ind=countDiscreteIndexesF(Theta,nMaxArr2); Theta[nb_ind]=((HHitMatch*)(*pArr)[i])->getTofTheta(); Phi[nb_ind] =((HHitMatch*)(*pArr)[i])->getTofPhi(); DMdcMetaT[nb_ind] = ((HHitMatch*)(*pArr)[i])->getMdcTheta() - ((HHitMatch*)(*pArr)[i])->getTofTheta(); DMdcMetaP[nb_ind] = ((HHitMatch*)(*pArr)[i])->getMdcPhi() - ((HHitMatch*)(*pArr)[i])->getTofPhi(); //KickMom[nb_ind] = ktrack->getP(); //} } else if (tof_ret>-1) {//the hit was stored before, do nothing } } else if (inds>-1)//SHOWER hit { Int_t shower_ret=fillUniqueIndex(inds,nMaxArr,ShowerU); shower_ret=-2; if (shower_ret==-1) Error("HRichCorrCounter::calcOpeningAngleMETA", "no unique shower index"); else if (shower_ret==-2) //not yet found shower { //HKickTrack* ktrack = getKickTrack(((HHitMatch*)(*pArr)[i])); //HKickTrack* ktrack = getKickTrack(((HHitMatch*)(*pArr)[i])->getMdcTheta(),((HHitMatch*)(*pArr)[i])->getMdcPhi(),((HHitMatch*)(*pArr)[i])->getSector()); //if (ktrack) //{ //remember the angles Int_t nb_ind=countDiscreteIndexesF(Theta,nMaxArr2); Theta[nb_ind]=((HHitMatch*)(*pArr)[i])->getShowerTheta(); Phi[nb_ind] =((HHitMatch*)(*pArr)[i])->getShowerPhi(); DMdcMetaT[nb_ind] = ((HHitMatch*)(*pArr)[i])->getMdcTheta() - ((HHitMatch*)(*pArr)[i])->getShowerTheta(); DMdcMetaP[nb_ind] = ((HHitMatch*)(*pArr)[i])->getMdcPhi() - ((HHitMatch*)(*pArr)[i])->getShowerPhi(); //KickMom[nb_ind] = ktrack->getP(); //} } else if (shower_ret>-1) {//the hit was stored before, do nothing } } else Error("calcOpeningAngleMETA","it's neither a TOF nor Shower hit"); } //cout<<"*********************"<0.) hist->Fill(opangle); // unlike sign pairs if (opangle>0. && DMdcMetaT[i]*DMdcMetaT[j]<0.) hist->Fill(opangle); // all pairs //if (opangle>0.) hist2->Fill(opangle,DMdcMetaT[i]); //if (opangle>0.) hist2->Fill(opangle,DMdcMetaT[j]); // unlike sign pairs if (opangle>0. && DMdcMetaT[i]*DMdcMetaT[j]<0.) hist2->Fill(opangle,1./DMdcMetaT[i] ); if (opangle>0. && DMdcMetaT[i]*DMdcMetaT[j]<0.) hist2->Fill(opangle,1./DMdcMetaT[j] ); // dT:dT for unlike sign //if (opangle>0. && DMdcMetaT[i]*DMdcMetaT[j]<0.) hist3->Fill(DMdcMetaT[j],DMdcMetaT[i]); //if (opangle>0. && DMdcMetaT[i]*DMdcMetaT[j]<0.) hist3->Fill(1./(TMath::Abs(DMdcMetaT[j])),1./(TMath::Abs(DMdcMetaT[i]))); // if (opangle>0. && DMdcMetaT[i]*DMdcMetaT[j]<0.) hist3->Fill(opangle,DMdcMetaP[j]); if (opangle>0. && DMdcMetaT[i]*DMdcMetaT[j]<0.) { //if (DMdcMetaT[i]<0. && DMdcMetaT[j]>0.) hist3->Fill(KickMom[i],KickMom[j]);// e- corresponds neg deflection //else if (DMdcMetaT[i]>0. && DMdcMetaT[j]<0.) hist3->Fill(KickMom[j],KickMom[i]); } } } //cout<evtsize) Error("HRichCorrCounter::checkCombination", "too many stored indexes"); jarr[i_ind-1]=j;//remember the sec index } else //index i used before, check whether j was also used before { if (jarr[i_ret]==j) return 0;//combination was used before Int_t i_ind=countDiscreteIndexes(iarr,evtsize); iarr[i_ind]=i;// new index comb with same i and new j jarr[i_ind]=j;// store these indexes in new pair } return 1;//it is a new combination } Int_t HRichCorrCounter::checkCombinationSameCat(Int_t i,Int_t j,Int_t *iarr,Int_t *jarr,Int_t evtsize) { Int_t maxUsed = countDiscreteIndexes(iarr,evtsize);//symm for both arrays // cout<<"in checkCombiSameCat: "<getMdcInd() > -1 && h->getRichInd() > -1 && h->getMatchedRichMdc() == 1 ) { mi = h->getMdcInd(); ri = h->getRichInd(); } else return 0; // check whether this bi-corr was used before to fill histo if (checkCombination(mi,ri,m,r,evtsize)==0) return 0; Float_t mt,rt; mt=rt=0.; mt=h->getMdcTheta(); rt=h->getRichTheta(); Float_t dTheta=mt-rt;//MDC-RICH theta pH_RichMdcThetadTheta->Fill(mt,dTheta); pH_RichMdcdTheta->Fill(dTheta); return 1; } Int_t HRichCorrCounter::fillMdcShowerThetadTheta(HHitMatch* h,Int_t evtsize,Int_t* m,Int_t* s) { Int_t mi,si; mi=si=-1; //check if it is a valid MDC-TOF matched tracklet if (h->getMdcInd() > -1 && h->getShowInd() > -1 && h->getMatchedMdcShower() == 1 && h->getMatchedRichMdc() == 1 && h->getMatchedRichShower() == 1) { mi = h->getMdcInd(); si = h->getShowInd(); } else return 0; // check whether this bi-corr was used before to fill histo if (checkCombination(mi,si,m,s,evtsize)==0) return 0; // calculate values and fill them in histo Float_t mt,st,rt; mt=st=rt=0.; mt=h->getMdcTheta(); st=h->getShowerTheta(); rt=h->getRichTheta(); Float_t tof=h->getTofinoTof(); Float_t dTheta=mt-st;//MDC-TOF theta Float_t dThetaRM=TMath::Abs(mt-rt);//RICH-MDC theta //cout<2.) return 0; pH_MdcMETAdTheta->Fill(dTheta); pH_MdcShowerdTheta->Fill(dTheta); pH_MdcShowerThetadTheta->Fill(mt,dTheta); pH_MdcShowerTofinotofdTheta->Fill(tof,dTheta); return 1; } Int_t HRichCorrCounter::fillMdcTofThetadTheta(HHitMatch* h,Int_t evtsize,Int_t* m,Int_t* t) { Int_t mi,ti; mi=ti=-1; //check if it is a valid MDC-TOF matched tracklet if (h->getMdcInd() > -1 && h->getTofInd() > -1 && h->getMatchedMdcTof() == 1 && h->getMatchedRichMdc() == 1 && h->getMatchedRichTof() == 1) { mi = h->getMdcInd(); ti = h->getTofInd(); } else return 0; // check whether this bi-corr was used before to fill histo if (checkCombination(mi,ti,m,t,evtsize)==0) return 0; // calculate values and fill them in histo Float_t mt,tt,rt; mt=tt=rt=0.; mt=h->getMdcTheta(); tt=h->getTofTheta(); rt=h->getRichTheta(); Float_t tof=h->getTofTof(); Float_t dTheta=mt-tt;//MDC-TOF theta Float_t dThetaRM=TMath::Abs(mt-rt);//RICH-MDC theta //cout<2.) return 0; pH_MdcMETAdTheta->Fill(dTheta); pH_MdcTofdTheta->Fill(dTheta); pH_MdcTofThetadTheta->Fill(mt,dTheta); pH_MdcTofToftofdTheta->Fill(tof,dTheta); return 1; } Int_t HRichCorrCounter::fillUniqueIndex(Int_t i,Int_t max,Int_t* iarr) { // check if value i is already stored in iarr // if not then store it // iarr is initialized to -2 // if already stored returns index // if newly stored returns index of new slot Int_t n=0; do{ if(i==iarr[n]) return n;//i already stored else if(iarr[n]==-2) //new slot { iarr[n]=i;//store value i in new slot return -2; } n++; } while(n -2. ) n++; else break; } return n; } void HRichCorrCounter::dumpCorrelationStatus() { cout<<"*******************************************"<0) cout<<"Tot Nb of RICH hits : "<0) cout<<"Tot Nb of MDCSEG hits : "<0) cout<<"Tot Nb of TOF hits : "<0) cout<<"Tot Nb of SHOWER hits : "<0) cout<<"Nb of diff Rich hits : "<0) cout<<"Nb of diff Mdc hits : "<0) cout<<"Nb of diff Tof hits : "<0) cout<<"Nb of diff Shower hits : "<0) cout<<"Nb of diff Rich hits in min RM corr : "<0) cout<<"Nb of diff Rich hits in min RT corr : "<0) cout<<"Nb of diff Rich hits in min RS corr : "<0) cout<<"Nb of diff Rich hits in min RMT index : "<0) cout<<"Nb of diff Rich hits in min RMS index : "<0) cout<<"Nb of diff Rich hits in RM MT RT : "<0) cout<<"Nb of diff Rich hits in RM MS RS : "<0) cout<<"Nb of diff Rich hits in RM RT : "<0) cout<<"Nb of diff Rich hits in RM RS : "<0) cout<<"Nb of diff Rich hits in RM MT : "<0) cout<<"Nb of diff Rich hits in RM MS : "<0) cout<<"Nb of diff Rich hits in MT RT : "<0) cout<<"Nb of diff Rich hits in MS RS : "<0) cout<<"Nb of diff Rich hits in only RM : "<0) cout<<"Nb of diff Rich hits in only RT : "<0) cout<<"Nb of diff Rich hits in only RS : "<0) cout<<"Nb of diff Mdc hits in only MT : "<0) cout<<"Nb of diff Mdc hits in only MS : "<0) cout<<"Nb of exact RM corr : "<0) cout<<"Nb of exact RT corr : "<0) cout<<"Nb of exact RS corr : "<0) cout<<"Nb of exact MT corr : "<0) cout<<"Nb of exact MS corr : "<0) cout<<"Nb of min RMT indexes in tracklet : " <0) cout<<"Nb of min RMS indexes in tracklet : " <0) cout<<"Nb of exact RM MT corr : "<0) cout<<"Nb of exact RM MT RT corr : "<0) cout<<"Nb of exact MT RT corr : "<0) cout<<"Nb of exact RM RT corr : "<0) cout<<"Nb of exact RM MS corr : "<0) cout<<"Nb of exact RM MS RS corr : "<0) cout<<"Nb of exact MS RS corr : "<0) cout<<"Nb of exact RM RS corr : "<getSector(); if (h->getMdcInd() > -1) { mt = h->getMdcTheta(); mp = h->getMdcPhi(); } else return 0; Float_t tof=-2.; if (h->getTofInd() > -1) tof=h->getTofTof(); else if (h->getShowInd() > -1) tof=h->getTofinoTof(); Float_t fMinThetaDiff=0.001; Float_t fMinPhiDiff=0.001; Float_t tofdiff=0.001; Float_t r2d = 57.29578; HKickTrack *track = 0; iterTracks->Reset(); while ((track=(HKickTrack*) iterTracks->Next())!=0) { Float_t trackTheta = track->getTheta()*r2d; Float_t trackPhi = track->getPhi()*r2d + (track->getSector()*60.); if(trackPhi > 360.) trackPhi-= 360.; if (sec==track->getSector()) { if( TMath::Abs(tof-track->getTof()) < tofdiff && TMath::Abs(trackTheta-mt) < fMinThetaDiff && TMath::Abs(trackPhi-mp) < fMinPhiDiff ) { //cout<getP()<<"/"<getTof()<<"/"<