00001 #include "StEvent.h"
00002 #include "StTrack.h"
00003 #include "StTofCollection.h"
00004 #include "StMuTofUtil.h"
00005 #include "StMuTofHitCollection.h"
00006
00007 ClassImp(StMuTofUtil)
00008
00009 StMuTofUtil::StMuTofUtil()
00010 { }
00011
00012 StMuTofUtil::~StMuTofUtil()
00013 { }
00014
00015 StMuTofHitCollection* StMuTofUtil::getMuTofHit(StTofCollection *tofcol)
00016 {
00017 if(!tofcol) return NULL;
00018 StMuTofHitCollection* muTofHit = new StMuTofHitCollection();
00019 fillMuTofHit(muTofHit, tofcol);
00020 return muTofHit;
00021 }
00022
00023 void StMuTofUtil::fillMuTofHit(StMuTofHitCollection* muTofHit, StTofCollection* tofcol)
00024 {
00025
00026 if(!tofcol || (!tofcol->dataPresent()&&!tofcol->rawdataPresent())) return;
00027 if(!muTofHit) return;
00028
00029
00030 if( ( tofcol->cellsPresent() || tofcol->slatsPresent() ) &&
00031 tofcol->hitsPresent() ) {
00032 StSPtrVecTofHit &tofHits = tofcol->tofHits();
00033 StSPtrVecTofCell &tofCell = tofcol->tofCells();
00034 StSPtrVecTofSlat &tofSlat = tofcol->tofSlats();
00035
00036 for(size_t i=0; i < tofHits.size(); i++) {
00037 StMuTofHit* tofMuHit = new StMuTofHit();
00038 tofMuHit->setIconf(1);
00039 tofMuHit->setTrayIndex(tofHits[i]->trayIndex());
00040 tofMuHit->setModuleIndex(tofHits[i]->moduleIndex());
00041 tofMuHit->setCellIndex(tofHits[i]->cellIndex());
00042 tofMuHit->setDaqIndex(tofHits[i]->daqIndex());
00043 tofMuHit->setTimeOfFlight(tofHits[i]->timeOfFlight());
00044 tofMuHit->setPathLength(tofHits[i]->pathLength());
00045 tofMuHit->setBeta(tofHits[i]->beta());
00046 tofMuHit->setAssociatedTrackId(tofHits[i]->associatedTrack()->key());
00047 if(tofHits[i]->trayIndex()!=0&&tofHits[i]->moduleIndex()!=0) {
00048 tofMuHit->setADC((int)tofCell[tofHits[i]->cellCollIndex()]->adc());
00049 StThreeVectorD hitpos = tofCell[tofHits[i]->cellCollIndex()]->position();
00050 StThreeVectorF hitpos1((Float_t)(hitpos.x()),(Float_t)(hitpos.y()),(Float_t)(hitpos.z()));
00051 tofMuHit->setProjectedPoint(hitpos1);
00052
00053 } else {
00054 tofMuHit->setADC((int)tofSlat[tofHits[i]->cellCollIndex()]->adc());
00055 tofMuHit->setProjectedPoint((StThreeVectorF&)tofSlat[tofHits[i]->cellCollIndex()]->position());
00056 }
00057 tofMuHit->settofExpectedAsElectron(tofHits[i]->tofExpectedAsElectron());
00058 tofMuHit->settofExpectedAsPion(tofHits[i]->tofExpectedAsPion());
00059 tofMuHit->settofExpectedAsKaon(tofHits[i]->tofExpectedAsKaon());
00060 tofMuHit->settofExpectedAsProton(tofHits[i]->tofExpectedAsProton());
00061 tofMuHit->setsigmaElectron(tofHits[i]->sigmaElectron());
00062 tofMuHit->setsigmaPion(tofHits[i]->sigmaPion());
00063 tofMuHit->setsigmaKaon(tofHits[i]->sigmaKaon());
00064 tofMuHit->setsigmaProton(tofHits[i]->sigmaProton());
00065
00066
00067 muTofHit->push_back(tofMuHit);
00068 }
00069
00070 }
00071 return;
00072 }