#include "hparticletool.h" #include "hcategorymanager.h" #include "hlinearcategory.h" //--------category definitions--------- #include "hparticledef.h" #include "haddef.h" #include "hmdcdef.h" #include "hmdctrackddef.h" #include "hmdctrackgdef.h" #include "richdef.h" #include "rpcdef.h" #include "showerdef.h" #include "tofdef.h" #include "walldef.h" //------------------------------------- //-------objects----------------------- #include "hgeantkine.h" #include "hgeanttof.h" #include "hgeantshower.h" #include "hgeantrpc.h" #include "hparticlecand.h" #include "hmetamatch2.h" #include "hrichhit.h" #include "htofhit.h" #include "htofcluster.h" #include "hrpccluster.h" #include "hshowerhit.h" #include "hmdctrkcand.h" #include "hmdcseg.h" #include "hmdchit.h" #include "hmdcclusinf.h" #include "hmdcclusfit.h" #include "hmdcwirefit.h" #include "hmdccal1.h" #include "hmdcclus.h" //------------------------------------- #include "TMath.h" #include "TAxis.h" #include "TVector3.h" //_HADES_CLASS_DESCRIPTION /////////////////////////////////////////////////////////// // HParticleTool // // library of static functions // look here for auxiliary functions for: // physics analysis, simulation analysis, ... /////////////////////////////////////////////////////////// ClassImp(HParticleTool) HParticleTool::HParticleTool() { } HParticleTool::~HParticleTool() { } Float_t HParticleTool::phiSecToLabDeg(Int_t sec, Float_t phiRad) { // Convert phi (rad) angle from sec to Lab phi in deg phiRad *= TMath::RadToDeg(); switch(sec) { case 0: break; case 1: case 2: case 3: case 4: phiRad += 60.0f * sec; break; default: phiRad -= 60.0f; break; } return phiRad; } Float_t HParticleTool::thetaToLabDeg(Float_t thetaRad) { // Convert theta angle (rad) to the coordinate lab system return TMath::RadToDeg() * thetaRad; } Float_t HParticleTool::phiLabToPhiSecDeg(Float_t phiLabDeg) { // Convert phi angle (deg,lab: 0-360) to the coordinate sector system (60,120) return fmod(phiLabDeg,60.F) + 60; } Int_t HParticleTool::phiLabToSec(Float_t phiLabDeg) { // Convert phi angle (deg,lab: 0-360) to the sector number Int_t sec; if(phiLabDeg >= 60) sec = ((Int_t) phiLabDeg/60) - 1; else sec = 5; return sec; } Float_t HParticleTool::calcRichQA(HMdcSeg* seg, HRichHit* richHit) { // return -1 if fails. if(!seg || ! richHit) return -1; Float_t rphi = fmod(richHit->getPhi(),60.F) + 60; Float_t dTheta = richHit->getTheta() - seg->getTheta()*TMath::RadToDeg(); Float_t dPhi = ( rphi - seg->getPhi()*TMath::RadToDeg() ) * TMath::Sin(seg->getTheta()); return sqrt(dPhi*dPhi + dTheta*dTheta); } Float_t HParticleTool::calcRichQA(HMdcSeg* seg,Float_t richTheta,Float_t richPhi) { // return -1 if fails. richTheta and richPhi in deg in lab system // if(!seg ) return -1; Float_t rphi = fmod(richPhi,60.F) + 60; Float_t dTheta = richTheta - seg->getTheta()*TMath::RadToDeg(); Float_t dPhi = ( rphi - seg->getPhi()*TMath::RadToDeg() ) * TMath::Sin(seg->getTheta()); return sqrt(dPhi*dPhi + dTheta*dTheta); } Float_t HParticleTool::getOpeningAngle(Float_t phi1,Float_t theta1,Float_t phi2,Float_t theta2) { // phi and theta angles of particle 1 and 2 in lab coordinates [deg] // returns opening angle [deg] //Temporary vector objects for scalar product computation TVector3 vec1; TVector3 vec2; // convert angles to radians phi1 *= TMath::DegToRad() ; theta1 *= TMath::DegToRad() ; phi2 *= TMath::DegToRad() ; theta2 *= TMath::DegToRad() ; //Above all angles are in degree! We need them in radians! vec1.SetMagThetaPhi(1.0,theta1,phi1); vec2.SetMagThetaPhi(1.0,theta2,phi2); return TMath::RadToDeg() * vec1.Angle(vec2); } void HParticleTool::getTLorentzVector(HGeantKine* kine, TLorentzVector& vec) { // fills TLorentzVector vec from HGeantKine. // CAUTION : vec.Phi() will be -pi to pi (-180 to +180 deg) // To be compatibel with the HADES lab system phi (0-360 deg) // one has to use // HParticleTool::getLabPhiDeg(TLorentzVector& vec) if(kine == NULL) { vec.SetXYZM(-1000,-1000,-1000,-1); return; } Float_t mass = HPhysicsConstants::mass(kine->getID()); Float_t xmom,ymom,zmom; kine->getMomentum(xmom,ymom,zmom); vec.SetPxPyPzE(xmom,ymom,zmom,TMath::Sqrt(mass*mass + xmom*xmom + ymom*ymom + zmom*zmom)); } Float_t HParticleTool::getLabPhiDeg(TLorentzVector& vec) { // CAUTION : vec.Phi() will be -pi to pi (-180 to +180 deg) // To be compatibel with the HADES lab system phi (0-360 deg) // one has to use shift negative values by 360deg return vec.Phi() < 0 ? vec.Phi()*TMath::RadToDeg()+360 : vec.Phi()*TMath::RadToDeg(); } Int_t HParticleTool::findFirstHitInTof(Int_t trackID,Int_t modeTrack) { //------------------------------------------------- // find the first track ID entering the TOF // Used to suppress the secondaries created in the // TOF itself. // 0 = realistic (secondaries included) // 1 primary particle is stored // 2 (default) the first track number entering the tof in SAME SECTOR is stored // 3 as 2 but condition on SAME SECTOR && MOD // 4 as 2 but SAME SECTOR && MOD && ROD Int_t numTrack = trackID; if(numTrack <= 0) return numTrack; // nothing to do for negative track numbers //------------------------------------------ // getting categories HLinearCategory* fGeantKineCat = (HLinearCategory*)HCategoryManager::getCategory(catGeantKine, kFALSE); if(!fGeantKineCat){ return trackID; } HLinearCategory* fGeantCat = (HLinearCategory*) HCategoryManager::getCategory(catTofGeantRaw,kFALSE); if(!fGeantCat){ return trackID; } //------------------------------------------ HGeantTof *poldTof; Int_t first = 0; HGeantKine* kine = 0; kine = HCategoryManager::getObject(kine,fGeantKineCat,numTrack - 1); if(kine){ first=kine->getFirstTofHit(); if(first != -1){ poldTof = (HGeantTof*)fGeantCat->getObject(first); } else { ::Error("findFirstHitInTof()","No first tof hit!"); return numTrack; } } else { ::Error("findFirstHitInTof()","Received Zero pointer for kine index = %i !",numTrack); return numTrack; } if(numTrack != poldTof->getTrack()){ ::Error("findFirstHitInTof()","First tof hit not same trackID!"); return numTrack; } //-------------------------------------------------------- // return the track number for // the selected option storeFirstTrack //-------------------------------------- // case 0 if(modeTrack == 0) return numTrack; //-------------------------------------- // case 1 if(modeTrack == 1) { // return track number of primary particle // of the given track kine = (HGeantKine*)fGeantKineCat->getObject(numTrack-1); kine = HGeantKine::getPrimary(numTrack,fGeantKineCat); return kine->getTrack(); } //-------------------------------------- // case 2 and 3 kine = (HGeantKine*)fGeantKineCat->getObject(numTrack - 1); if(kine->getParentTrack() == 0){return numTrack;} // nothing to do Int_t s,m,c; s = poldTof->getSector(); // GEANT 15-22 (TOF), 23-26 (TOFINO) // numbering reverse ! m = 21-poldTof->getModule(); c = 7 -poldTof->getCell(); first = 0; Int_t tempTrack = numTrack; while((kine = kine->getParent(tempTrack,fGeantKineCat)) != 0) { first = kine->getFirstTofHit(); if(first != -1) { // track is still in TOF // now we have to check if it is in TOF or TOFINO HGeantTof* gtof = (HGeantTof*)fGeantCat->getObject(first); Int_t s1,m1,c1; s1 = m1 = c1 = 0; m1 = 21 - gtof->getModule(); if(m1 >= 0) { // inside TOF s1 = gtof->getSector(); c1 = 7-gtof->getCell(); if(modeTrack == 2 && s == s1) { // case 2 :: check only sector tempTrack = kine->getTrack(); } if(modeTrack == 3 && s == s1 && m == m1) { // case 3 :: check only sector,module tempTrack = kine->getTrack(); } else if(modeTrack == 4 && s == s1 && m == m1 && c == c1) { // case 4 :: check for same rod tempTrack = kine->getTrack(); } else { // track has no TOF hit any longer // which fulfills the condition break; } } else { // track is in TOFINO break; } } else { // track has no TOF hit any longer, // so the previous object was the one we // searched for break; } } return tempTrack; } Int_t HParticleTool::findFirstHitShowerInTofino(Int_t trackID, Int_t modeTrack) { //------------------------------------------------- // Used to suppress the secondaries created in the // SHOWER itself. // 0 = realistic (secondaries included) // 1 primary particle is stored // 2 the first track number entering the SHOWER in SAME SECTOR is stored // 3 the first track number entering the TOFINO in SAME SECTOR is stored // or the primary track if no TOFINO was found // 4 (default) the first track number entering the TOFINO in SAME SECTOR is stored // or the first track in SHOWER if no TOFINO was found Int_t numTrack = trackID; if(numTrack <= 0) return numTrack; // nothing to do for negative track numbers //-------------------------------------- // case 0 : in = out if(modeTrack == 0) { return numTrack; } HGeantShower *poldShower; Int_t first = 0; Int_t parent= 0; //------------------------------------------ // getting categories HLinearCategory* fGeantKineCat = (HLinearCategory*)HCategoryManager::getCategory(catGeantKine, kFALSE); if(!fGeantKineCat){ return trackID; } HLinearCategory* fGeantShowerCat = (HLinearCategory*) HCategoryManager::getCategory(catShowerGeantRaw,kFALSE); if(!fGeantShowerCat){ return trackID; } HLinearCategory* fGeantTofCat = (HLinearCategory*) HCategoryManager::getCategory(catTofGeantRaw,kFALSE); if(!fGeantTofCat){ return trackID; } //------------------------------------------ HGeantKine* kine = (HGeantKine*)fGeantKineCat->getObject(numTrack - 1); if(kine){ parent = kine->getParentTrack(); if( parent == 0) { return numTrack; } // nothing todo first = kine->getFirstShowerHit(); if(first != -1){ poldShower = (HGeantShower*)fGeantShowerCat->getObject(first); } else { ::Error("findFirstHitShowerInTofino()","No first shower hit!"); return numTrack; } } else { ::Error("findFirstHitShowerInTofino()","Received Zero pointer for kine!"); return numTrack; } if(numTrack != poldShower->getTrack()){ ::Error("findFirstHitShowerInTofino()","First shower hit not same trackID!"); return numTrack; } //-------------------------------------------------------- // return the track number for // the selected option modeTrack Int_t s = poldShower->getSector(); //-------------------------------------- // case 1 : in -> primary if(modeTrack == 1) { // return track number of primary particle // of the given track kine = HGeantKine::getPrimary(numTrack,fGeantKineCat); return kine->getTrack(); } //-------------------------------------- // case 2 and 3 : entering SHOWER/TOF Int_t tempTrack = numTrack; first = 0; //-------------------------------------- // case 2 : entering SHOWER if(modeTrack == 2) { while((kine = kine->getParent(tempTrack,fGeantKineCat)) != 0) { first = kine->getFirstShowerHit(); if(first != -1) { // track is still in SHOWER HGeantShower* gshower = (HGeantShower*)fGeantShowerCat->getObject(first); Int_t s1 = gshower->getSector(); if(s == s1) { // check only sector tempTrack = kine->getTrack(); } else { // track has no SHOWER hit any longer // which fulfills the condition break; } } else { // track has no SHOWER hit any longer, // so the previous object was the one we // searched for break; } } return tempTrack; } //-------------------------------------- //-------------------------------------- // case 3 : entering TOFINO if(modeTrack >= 3) { Bool_t foundTof = kFALSE; Int_t tempTrack2 = tempTrack; do { first = kine->getFirstTofHit(); if(first != -1) { // we are in TOF HGeantTof* gtof = (HGeantTof*)fGeantTofCat->getObject(first); Int_t s1 = gtof->getSector(); Int_t m = gtof->getModule(); if(s == s1 && m > 21 ) { // check only sector + TOFINO foundTof = kTRUE; tempTrack = tempTrack2; } } tempTrack2 = kine->getParentTrack(); } while( tempTrack2 > 0 && (kine = (HGeantKine*)fGeantKineCat->getObject(tempTrack2 - 1)) != 0); if(foundTof) { tempTrack += 10000; } else { kine = (HGeantKine*)fGeantKineCat->getObject(numTrack - 1); if( modeTrack == 3 ){ // store primaries if no TOFino was found kine = HGeantKine::getPrimary(numTrack,fGeantKineCat); tempTrack = kine->getTrack() + 100000000; } else if (modeTrack == 4){ //-------------------------------------- // recover first particle entering SHOWER while((kine = kine->getParent(tempTrack,fGeantKineCat)) != 0) { first = kine->getFirstShowerHit(); if(first != -1) { // track is still in SHOWER HGeantShower* gshower = (HGeantShower*)fGeantShowerCat->getObject(first); Int_t s1 = gshower->getSector(); if(s == s1) { // check only sector tempTrack = kine->getTrack(); } else { // track has no SHOWER hit any longer // which fulfills the condition break; } } else { // track has no SHOWER hit any longer, // so the previous object was the one we // searched for break; } } tempTrack += 100000000; //-------------------------------------- } } } //-------------------------------------- return tempTrack; } Int_t HParticleTool::findFirstHitShowerInRpc(Int_t trackID,Int_t modeTrack) { //------------------------------------------------- // Used to suppress the secondaries created in the // SHOWER itself. // 0 = realistic (secondaries included) // 1 primary particle is stored // 2 the first track number entering the SHOWER in SAME SECTOR is stored // 3 the first track number entering the RPC in SAME SECTOR is stored // or the primary track if no RPC was found // 4 (default) the first track number entering the RPC in SAME SECTOR is stored // or the first track in SHOWER if no RPC was found Int_t numTrack = trackID; if(numTrack <= 0) return numTrack; // nothing to do for negative track numbers //-------------------------------------- // case 0 : in = out if(modeTrack == 0) { return numTrack; } HGeantShower *poldShower; Int_t first = 0; Int_t parent= 0; //------------------------------------------ // getting categories HLinearCategory* fGeantKineCat = (HLinearCategory*)HCategoryManager::getCategory(catGeantKine, kFALSE); if(!fGeantKineCat){ return trackID; } HLinearCategory* fGeantShowerCat = (HLinearCategory*) HCategoryManager::getCategory(catShowerGeantRaw,kFALSE); if(!fGeantShowerCat){ return trackID; } HLinearCategory* fGeantRpcCat = (HLinearCategory*) HCategoryManager::getCategory(catRpcGeantRaw,kFALSE); if(!fGeantRpcCat){ return trackID; } //------------------------------------------ HGeantKine* kine = (HGeantKine*)fGeantKineCat->getObject(numTrack - 1); if(kine){ parent = kine->getParentTrack(); if( parent == 0) { return numTrack; } // nothing todo first = kine->getFirstShowerHit(); if(first != -1){ poldShower = (HGeantShower*)fGeantShowerCat->getObject(first); } else { ::Error("findFirstHitShowerInRpc()","No first shower hit!"); return numTrack; } } else { ::Error("findFirstHitShowerInRpc()","Received Zero pointer for kine!"); return numTrack; } if(numTrack != poldShower->getTrack()){ ::Error("findFirstHitShowerInRpc()","First shower hit not same trackID!"); return numTrack; } //-------------------------------------------------------- // return the track number for // the selected option modeTrack Int_t s = poldShower->getSector(); //-------------------------------------- // case 1 : in -> primary if(modeTrack == 1) { // return track number of primary particle // of the given track kine = HGeantKine::getPrimary(numTrack,fGeantKineCat); return kine->getTrack(); } //-------------------------------------- // case 2 and 3 : entering SHOWER/RPC Int_t tempTrack = numTrack; first = 0; //-------------------------------------- // case 2 : entering SHOWER if(modeTrack == 2) { while((kine = kine->getParent(tempTrack,fGeantKineCat)) != 0) { first = kine->getFirstShowerHit(); if(first != -1) { // track is still in SHOWER HGeantShower* gshower = (HGeantShower*)fGeantShowerCat->getObject(first); Int_t s1 = gshower->getSector(); if(s == s1) { // check only sector tempTrack = kine->getTrack(); } else { // track has no SHOWER hit any longer // which fulfills the condition break; } } else { // track has no SHOWER hit any longer, // so the previous object was the one we // searched for break; } } return tempTrack; } //-------------------------------------- //-------------------------------------- // case 3 : entering RPC if(modeTrack >= 3) { Bool_t foundRPC = kFALSE; Int_t tempTrack2 = tempTrack; do { first = kine->getFirstRpcHit(); if(first != -1) { // we are in TOF HGeantRpc* grpc = (HGeantRpc*)fGeantRpcCat->getObject(first); Int_t s1 = grpc->getSector(); if(s == s1) { // check only sector + RPC foundRPC = kTRUE; tempTrack = tempTrack2; } } tempTrack2 = kine->getParentTrack(); } while( tempTrack2 > 0 && (kine = (HGeantKine*)fGeantKineCat->getObject(tempTrack2 - 1)) != 0); if(foundRPC) { tempTrack += 10000; } else { kine = (HGeantKine*)fGeantKineCat->getObject(numTrack - 1); if( modeTrack == 3 ){ // store primaries if no RPC was found kine = HGeantKine::getPrimary(numTrack,fGeantKineCat); tempTrack = kine->getTrack() + 100000000; } else if (modeTrack == 4){ //-------------------------------------- // recover first particle entering SHOWER while((kine = kine->getParent(tempTrack,fGeantKineCat)) != 0) { first = kine->getFirstShowerHit(); if(first != -1) { // track is still in SHOWER HGeantShower* gshower = (HGeantShower*)fGeantShowerCat->getObject(first); Int_t s1 = gshower->getSector(); if(s == s1) { // check only sector tempTrack = kine->getTrack(); } else { // track has no SHOWER hit any longer // which fulfills the condition break; } } else { // track has no SHOWER hit any longer, // so the previous object was the one we // searched for break; } } tempTrack += 100000000; //-------------------------------------- } } } //-------------------------------------- return tempTrack; } Float_t HParticleTool::getInterpolatedValue(TH1* h, Float_t xVal, Bool_t warn) { // retrieve content of 1-dim Hist corresponding to x val. // The values will be linear interpolated. If warn == kTRUE // warning will be emitted if the xval is out of the range // of the hist. In case the value is out of range the value // of first or last bin will be returned respectively. if(!h) return 0; TAxis *pA = h->GetXaxis(); Int_t binX = pA->FindBin(xVal); // We need to start interpolation from the next-lower bin boundary if(binX > 1 && binX <= pA->GetNbins()) { // only here it make sense to interpolate Int_t binXLower = binX - 1; Float_t startVal = h->GetBinContent(binXLower); Float_t endVal = h->GetBinContent(binX); Float_t startx = pA->GetBinUpEdge(binXLower); Float_t slope = (endVal - startVal)/pA->GetBinWidth(binX); Float_t calc = startVal + slope * (xVal - startx); return calc; } else { // noting to interpolate.... if(binX == 1) { return h->GetBinContent(1); } else if(binX < 1) { // lower boundary violation ...return lowest bin if(warn) ::Warning("HParticleTool::getInterpolatedValue()","Non-intercepted bin-out-of-range-situation (bin too low)"); return h->GetBinContent(1); } else { // upper boundary violation ...return highest bin if(warn) ::Warning("HParticleTool::getInterpolatedValue()","Non-intercepted bin-out-of-range-situation (bin too high)"); return h->GetBinContent(pA->GetNbins()); } } } Stat_t HParticleTool::getValue(TH1* h,Float_t xVal, Float_t yVal, Float_t zVal) { // retrieve value from Histogram (1,2 and 3 dim) corresponding // to x val, y val and z val. If the values are out of range of // the histogram axis the lowest/highest bin of the axis will be // used. No interpolation performed. if(!h) return 0; TAxis *pA = h->GetXaxis(); Int_t binX, binY, binZ; binY = binZ = 0; pA = h->GetXaxis(); binX = pA->FindBin(xVal); if(binX <= 0) { binX = 1; } else { if(binX > pA->GetNbins()) binX = pA->GetNbins(); } pA = h ->GetYaxis(); binY = pA->FindBin(yVal); if(binY <= 0) { binY = 1; } else { if(binY > pA->GetNbins()) binY = pA->GetNbins(); } pA = h ->GetZaxis(); binZ = pA->FindBin(zVal); if(binZ <= 0) { binZ = 1; } else { if(binZ > pA->GetNbins()) binZ = pA->GetNbins(); } return h->GetBinContent(h->GetBin(binX, binY, binZ)); } HRichHit* HParticleTool::getRichHit(Int_t richind) { // return HRichHit pointer from the object index // in the category. In case of no success returns NULL HRichHit* richhit = 0; richhit = HCategoryManager::getObject(richhit,catRichHit,richind,kTRUE); return richhit; } HTofHit* HParticleTool::getTofHit(Int_t tofind) { // return HTofHit pointer from the object index // in the category. In case of no success returns NULL HTofHit* tofhit=0; tofhit = HCategoryManager::getObject(tofhit,catTofHit,tofind,kTRUE); return tofhit; } HTofCluster* HParticleTool::getTofCluster(Int_t tofind) { // return HTofCluster pointer from the object index // in the category. In case of no success returns NULL HTofCluster* tofclst=0; tofclst = HCategoryManager::getObject(tofclst,catTofCluster,tofind,kTRUE); return tofclst; } HRpcCluster* HParticleTool::getRpcCluster(Int_t rpcind) { // return HRpcCluster pointer from the object index // in the category. In case of no success returns NULL HRpcCluster* rpcclst=0; rpcclst = HCategoryManager::getObject(rpcclst,catRpcCluster,rpcind,kTRUE); return rpcclst; } HShowerHit* HParticleTool::getShowerHit(Int_t showerind) { // return HShowerHit pointer from the object index // in the category. In case of no success returns NULL HShowerHit* showerhit=0; showerhit = HCategoryManager::getObject(showerhit,catShowerHit,showerind,kTRUE); return showerhit; } HMetaMatch2* HParticleTool::getMetaMatch(Int_t metaind) { // return HMetaMatch2 pointer from the object index // in the category. In case of no success returns NULL HMetaMatch2* meta = 0; meta = HCategoryManager::getObject(meta,catMetaMatch,metaind,kTRUE); return meta; } HMdcTrkCand* HParticleTool::getMdcTrkCand(Int_t metaind) { // return HMdcTrkCand pointer from the object index of MetaMatch2 // in the category (indMeta->HMetaMatch2->HMdcTrkCand). In case of // no success returns NULL HMetaMatch2* meta = 0; HMdcTrkCand* trk = 0; meta = HCategoryManager::getObject(meta,catMetaMatch,metaind); if(meta){ Int_t mdctrkInd = meta->getTrkCandInd(); if(mdctrkInd >= 0){ trk = HCategoryManager::getObject(trk,catMdcTrkCand,mdctrkInd,kTRUE); } } return trk; } HMdcSeg* HParticleTool::getMdcSeg(Int_t segind) { // return HMdcSeg pointer from the object index // in the category. In case of no success returns NULL HMdcSeg* seg = 0; seg = HCategoryManager::getObject(seg,catMdcSeg,segind,kTRUE); return seg; } HMdcHit* HParticleTool::getMdcHit(Int_t segind,Int_t nhit ) { // return HMdcHit pointer from the object index of HMdcSeg // in the category (indSeg->HMdcSeg->HMdcHit). nhit (0 or 1) // is the number of the hit inside the segment which should // be retrived. In case of no success returns NULL HMdcSeg* seg = 0; HMdcHit* hit = 0; seg = HCategoryManager::getObject(seg,catMdcSeg,segind,kTRUE); if(seg){ Int_t hitind = seg->getHitInd(nhit); if(hitind != -1) { hit = HCategoryManager::getObject(hit,catMdcHit,hitind,kTRUE); } } return hit; } HMdcClusInf* HParticleTool::getMdcClusInf(Int_t segind,Int_t nhit) { // return HMdcClusInf pointer from the object index of HMdcSeg // in the category (indSeg->HMdcSeg->HMdcClusInf). nhit (0 or 1) // is the number of the hit inside the segment which should // be retrived. In case of no success returns NULL HMdcSeg* seg = 0; HMdcClusInf* clusinf = 0; seg = HCategoryManager::getObject(seg,catMdcSeg,segind,kTRUE); if(seg){ Int_t hitind = seg->getHitInd(nhit); if(hitind != -1) { clusinf = HCategoryManager::getObject(clusinf,catMdcClusInf,hitind,kTRUE); } } return clusinf; } HMdcClusFit* HParticleTool::getMdcClusFit(Int_t segind) { // return HMdcClusFit pointer from the object index of HMdcSeg // in the category (indSeg->HMdcSeg->HMdcClsuInf->HMdcClusFit). // In case of no success returns NULL HMdcSeg* seg = 0; HMdcClusInf* clusinf = 0; HMdcClusFit* clusfit = 0; seg = HCategoryManager::getObject(seg,catMdcSeg,segind,kTRUE); if(seg){ Int_t hitind = seg->getHitInd(0); if(hitind != -1) { clusinf = HCategoryManager::getObject(clusinf,catMdcClusInf,hitind,kTRUE); } else { hitind = seg->getHitInd(1); clusinf = HCategoryManager::getObject(clusinf,catMdcClusInf,hitind,kTRUE); } if(clusinf){ Int_t clusfitind = clusinf ->getClusFitIndex(); if(clusfitind !=-1){ clusfit = HCategoryManager::getObject(clusfit,catMdcClusFit,clusfitind,kTRUE); } } } return clusfit; } HMdcClus* HParticleTool::getMdcClus(Int_t segind) { // return HMdcClus pointer from the object index of HMdcSeg // in the category (indSeg->HMdcSeg->HMdcClus). // In case of no success returns NULL HMdcSeg* seg = 0; HMdcClus* clus = 0; seg = HCategoryManager::getObject(seg,catMdcSeg,segind,kTRUE); if(seg){ Int_t clusind = seg->getClusIndex(); if(clusind != -1) { clus = HCategoryManager::getObject(clus,catMdcClus,clusind,kTRUE); } } return clus; } TObjArray* HParticleTool::getMdcWireFitSeg(Int_t segind) { // return TObjArray pointer to an array of HMdcWireFit // pointer from the object index of HMdcSeg // in the category (indSeg->HMdcSeg->HMdcClusInf->HMdcClusFit->HMdcWireFit). // The user has to delete the TObjArray object // (not the content) by himself. TObjArray* ar = new TObjArray(); HMdcClusFit* clusfit = HParticleTool::getMdcClusFit(segind); if(clusfit){ Int_t first = clusfit->getFirstWireFitInd(); Int_t last = clusfit->getLastWireFitInd(); HCategory *wirefitcat = HCategoryManager::getCategory(catMdcWireFit,2);// silent if(wirefitcat){ for(Int_t i = first; i<= last; i++){ HMdcWireFit* wf = 0; wf = HCategoryManager::getObject(wf,wirefitcat,i,kTRUE); if(wf) ar->Add(wf); } } } return ar; } TObjArray* HParticleTool::getMdcCal1Seg(Int_t segind) { // return TObjArray pointer to an array of HMdcCal1 // pointer from the object index of HMdcSeg // in the category (indSeg->HMdcSeg->HMdcCal1). // user has to delete the TObjArray object // (not the content) by himself. TObjArray* ar = new TObjArray(); HMdcSeg* seg = HParticleTool::getMdcSeg(segind); HCategory *cal1cat = HCategoryManager::getCategory(catMdcCal1,2);// silent if(seg && cal1cat){ HLocation loccal; loccal.set(4,0,0,0,0); // t2-t1 from segment for(Int_t l = 0; l < 12; l ++) // loop over layers in segment { Int_t nCell = seg->getNCells(l); loccal[0] = seg->getSec(); Int_t io = seg->getIOSeg(); for(Int_t ic = 0; ic < nCell; ic ++) { //--------------------------------------------- // find cal1 coordinates // find module if(io == 0){ (l < 6)? loccal[1] = 0 : loccal[1] = 1; } else if(io == 1) { (l < 6)? loccal[1] = 2 : loccal[1] = 3; } // find layer (l < 6)? loccal[2] = l : loccal[2] = l - 6; // find cell number loccal[3] = seg->getCell(l,ic); //--------------------------------------------- HMdcCal1* cal1 = (HMdcCal1*)cal1cat->getObject(loccal); if(cal1) { ar->Add(cal1); } } } } return ar; } TObjArray* HParticleTool::getMdcCal1Cluster(Int_t segind) { // return TObjArray pointer to an array of HMdcCal1 // pointer from the object index of HMdcSeg // in the category (indSeg->HMdcSeg->HMdcClus->HMdcCal1). // user has to delete the TObjArray object // (not the content) by himself. TObjArray* ar = new TObjArray(); HMdcClus* clus = HParticleTool::getMdcClus(segind); HCategory *cal1cat = HCategoryManager::getCategory(catMdcCal1,2);// silent if(clus && cal1cat){ HLocation loccal; loccal.set(4,0,0,0,0); // t2-t1 from segment for(Int_t l = 0; l < 12; l ++) // loop over layers in segment { Int_t nCell = clus->getNCells(l); loccal[0] = clus->getSec(); Int_t io = clus->getIOSeg(); for(Int_t ic = 0; ic < nCell; ic ++) { //--------------------------------------------- // find cal1 coordinates // find module if(io == 0){ (l < 6)? loccal[1] = 0 : loccal[1] = 1; } else if(io == 1) { (l < 6)? loccal[1] = 2 : loccal[1] = 3; } // find layer (l < 6)? loccal[2] = l : loccal[2] = l - 6; // find cell number loccal[3] = clus->getCell(l,ic); //--------------------------------------------- HMdcCal1* cal1 = (HMdcCal1*)cal1cat->getObject(loccal); if(cal1) { ar->Add(cal1); } } } } return ar; }