00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "StMuPmdUtil.h"
00027 #include "StEvent.h"
00028 #include "StEventTypes.h"
00029 #include "StMuPmdCluster.h"
00030 #include "StMuPmdHit.h"
00031 #include "StMuPmdCollection.h"
00032
00033 #include "StPhmdDetector.h"
00034 #include "StPhmdClusterCollection.h"
00035 #include "StPhmdCluster.h"
00036 #include "StPhmdModule.h"
00037 #include "StPhmdHit.h"
00038
00039 ClassImp(StMuPmdUtil)
00040
00041 StMuPmdUtil::StMuPmdUtil()
00042 {
00043 }
00044
00045 StMuPmdUtil::~StMuPmdUtil()
00046 {
00047 }
00048
00049 StMuPmdCollection* StMuPmdUtil::getMuPmd(StPhmdCollection *phmdColl)
00050 {
00051 if(!phmdColl) return NULL;
00052 StMuPmdCollection* muPmd = new StMuPmdCollection();
00053 fillMuPmd(phmdColl,muPmd);
00054 return muPmd;
00055 }
00056
00057 StPhmdCollection* StMuPmdUtil::getPmd(StMuPmdCollection* muPmd)
00058 {
00059 if(!muPmd) return NULL;
00060
00061 StPhmdCollection *phmdColl=new StPhmdCollection();
00062 fillPmd(muPmd,phmdColl);
00063 return phmdColl;
00064 }
00065
00066 void StMuPmdUtil::fillMuPmd(StPhmdCollection *phmdColl, StMuPmdCollection *muPmd)
00067 {
00068 if(!muPmd)return;
00069 if(!phmdColl)return;
00070
00071 for(Int_t d=0; d<2; d++){
00072 Int_t PmdDet=d+1;
00073
00074 Int_t totalHit=0;
00075 StDetectorId pdet = static_cast<StDetectorId>(kPhmdId-d);
00076 StPhmdDetector* detector = (StPhmdDetector*)phmdColl->detector(StDetectorId(pdet));
00077
00078 if(detector) {
00079
00080 for(UInt_t j=0;j<12;j++) {
00081 StPhmdModule* module = detector->module(j);
00082
00083 if(module) {
00084
00085 StSPtrVecPhmdHit& rawHit=module->hits();
00086 if(rawHit.size()>0) {
00087
00088 totalHit+=rawHit.size();
00089
00090 for(Int_t k=0;k<(Int_t)rawHit.size();k++) {
00091
00092 muPmd->addHit(PmdDet);
00093
00094 StPhmdHit *pmdhit = (StPhmdHit*)rawHit[k];
00095 Int_t sm=pmdhit->superModule();
00096 Int_t det=pmdhit->subDetector();
00097 Int_t row=pmdhit->row();
00098 Int_t col=pmdhit->column();
00099 Float_t energy=pmdhit->energy();
00100 Int_t adc=pmdhit->adc();
00101
00102
00103 StMuPmdHit *mupmdhit = muPmd->getHit(muPmd->getNHits(PmdDet)-1,PmdDet);
00104
00105 mupmdhit->setEnergy(energy);
00106 mupmdhit->setADC(adc);
00107 mupmdhit->setSuperModule((Short_t)sm);
00108 mupmdhit->setSubDetector((Short_t)det);
00109 mupmdhit->setRow((Short_t)row);
00110 mupmdhit->setColumn((Short_t)col);
00111 }
00112 }
00113 }
00114 }
00115
00116
00117 StPhmdClusterCollection* cluscol = detector->cluster();
00118
00119
00120 if(cluscol)
00121 {
00122 Int_t Ncluster0 = cluscol->numberOfclusters();
00123
00124 if(Ncluster0 > 0)
00125 {
00126 const StSPtrVecPhmdCluster& pmdclusters = cluscol->clusters();
00127
00128 for(UInt_t i=0; i<pmdclusters.size(); i++)
00129 {
00130 muPmd->addCluster(PmdDet);
00131
00132 StPhmdCluster *pmdcl = (StPhmdCluster*)pmdclusters[i];
00133 Int_t sm = pmdcl->module();
00134 Int_t ncell = pmdcl->numberOfCells();
00135 Float_t eta = pmdcl->eta();
00136 Float_t phi = pmdcl->phi();
00137 Float_t sigma = pmdcl->sigma();
00138 Float_t energy = pmdcl->energy();
00139 Int_t energyPID = pmdcl->energyPid();
00140 Int_t PID = pmdcl->pid();
00141 Int_t mcPID = pmdcl->mcPid();
00142
00143 StMuPmdCluster *mupmdcl=muPmd->getCluster(muPmd->getNClusters(PmdDet)-1,PmdDet);
00144
00145
00146 mupmdcl->setSuperModule(Int_t(sm));
00147 mupmdcl->setNcell(Int_t(ncell));
00148 mupmdcl->setEta(Float_t(eta));
00149 mupmdcl->setPhi(Float_t(phi));
00150 mupmdcl->setSigma(Float_t(sigma));
00151 mupmdcl->setEnergy(Float_t(energy));
00152 mupmdcl->setEnergyPID(Int_t(energyPID));
00153 mupmdcl->setPID(Int_t(PID));
00154 mupmdcl->setMcPID(Int_t(mcPID));
00155
00156 }
00157 }
00158 }
00159 }
00160 }
00161
00162 return;
00163 }
00164
00165 void StMuPmdUtil::fillPmd(StMuPmdCollection* muPmd, StPhmdCollection* phmdColl)
00166 {
00167 if(!muPmd) return;
00168 if(!phmdColl) return;
00169
00170 for(Int_t d=0; d<2; d++) {
00171 StDetectorId pdet = static_cast<StDetectorId>(kPhmdId-d);
00172 StPhmdDetector* detector = (StPhmdDetector*)phmdColl->detector(StDetectorId(pdet));
00173
00174
00175 Int_t PmdDet=d+1;
00176
00177
00178 Int_t nClusters = muPmd->getNClusters(PmdDet);
00179
00180 if(nClusters>0)
00181 {
00182 StPhmdClusterCollection* phmdClusColl = new StPhmdClusterCollection();
00183
00184
00185 detector->setCluster(phmdClusColl);
00186
00187
00188 for(Int_t n=0; n<nClusters; n++)
00189 {
00190 StMuPmdCluster *muPmdCl = muPmd->getCluster(n,PmdDet);
00191 if(muPmdCl)
00192 {
00193 Int_t sm = muPmdCl->superModule();
00194 Int_t nCell = muPmdCl->ncell();
00195 Float_t eta = muPmdCl->eta();
00196 Float_t phi = muPmdCl->phi();
00197 Float_t energy = muPmdCl->energy();
00198 Int_t energyPID = muPmdCl->energyPID();
00199 Int_t PID = muPmdCl->PID();
00200 Int_t McPID = muPmdCl->mcPID();
00201
00202 StPhmdCluster* phmdCl = new StPhmdCluster();
00203
00204 phmdCl->setModule(sm);
00205 phmdCl->setNumberOfCells(nCell);
00206 phmdCl->setEta(eta);
00207 phmdCl->setPhi(phi);
00208 phmdCl->setEnergy(energy);
00209 phmdCl->setEnergyPid(energyPID);
00210 phmdCl->setPid(PID);
00211 phmdCl->setMcPid(McPID);
00212
00213 phmdClusColl->addCluster(phmdCl);
00214 }
00215 }
00216 }
00217
00218
00219
00220 Int_t nHits = muPmd->getNHits(PmdDet);
00221
00222 if (nHits>0) {
00223 for(Int_t nh=0; nh<nHits; nh++) {
00224
00225 StMuPmdHit *muPmdHit = muPmd->getHit(nh,PmdDet);
00226
00227 if(muPmdHit) {
00228 Float_t energy= muPmdHit->energy();
00229 Int_t ADC= muPmdHit->adc();
00230 Int_t sm= muPmdHit->superModule();
00231 Int_t subDet= muPmdHit->subDetector();
00232 Int_t row= muPmdHit->row();
00233 Int_t col= muPmdHit->column();
00234 StPhmdHit* phmdHit = new StPhmdHit();
00235
00236 phmdHit->setSuperModule(sm);
00237 phmdHit->setEnergy(energy);
00238 phmdHit->setAdc(ADC);
00239 phmdHit->setSubDetector(subDet);
00240 phmdHit->setRow(row);
00241 phmdHit->setColumn(col);
00242 detector->addHit(phmdHit);
00243 }
00244 }
00245 }
00246 }
00247 return;
00248 }
00249
00250
00251
00252