60 #include "StEvent/StFmsCluster.h"
61 #include "StMuDSTMaker/COMMON/StMuFmsCluster.h"
62 #include "StMuDSTMaker/COMMON/StMuFmsHit.h"
63 #include "StMuDSTMaker/COMMON/StMuFmsPoint.h"
64 #include "StMuDSTMaker/COMMON/StMuFmsUtil.h"
65 #include "StMuDSTMaker/COMMON/StMuFmsCollection.h"
66 #include "StMuDSTMaker/COMMON/StMuDst.h"
67 #include "StMuDSTMaker/COMMON/StMuEvent.h"
68 #include "StEvent/StEvent.h"
69 #include "St_base/StMessMgr.h"
70 #include "StEvent/StEventTypes.h"
71 #include "StEvent/StTriggerData.h"
72 #include "StFmsDbMaker/StFmsDbMaker.h"
77 #include "TCollection.h"
78 #include "TRefArray.h"
91 template<
class StPtrVec,
class Element>
92 int findElementIndex(
const StPtrVec& array,
const Element* element) {
97 typedef Element*
const * ElementConstIter;
99 ElementConstIter location = std::find(array.begin(), array.end(), element);
103 if (location == array.end()) {
106 return std::distance(array.begin(), location);
111 StMuFmsUtil::StMuFmsUtil()
114 StMuFmsUtil::~StMuFmsUtil()
120 LOG_DEBUG <<
"StMuFmsUtil::getMuFms" << endm;
121 if(!fmscol)
return NULL;
123 fillMuFms(muFms,fmscol);
129 if(!muFms)
return NULL;
146 muFms->setFmsReconstructionFlag(fmscol->fmsReconstructionFlag());
149 fillMuFmsPoints(muFms, fmscol);
150 fillMuFmsClusters(muFms, fmscol);
154 setMuFmsPointParentClusters(muFms, fmscol);
161 fmscol->setFmsReconstructionFlag(muFms->fmsReconstructionFlag());
162 fillFmsHits(fmscol, muFms);
163 fillFmsPoints(fmscol, muFms);
164 fillFmsClusters(fmscol, muFms);
168 setFmsPointParentClusters(fmscol, muFms);
173 StSPtrVecFmsHit vecHit = fmscol->hits();
174 for(
unsigned int i=0; i<fmscol->numberOfHits(); i++){
175 unsigned short detId = vecHit[i]->detectorId();
176 unsigned short ch = vecHit[i]->channel();
177 unsigned short crate = vecHit[i]->qtCrate();
178 unsigned short slot = vecHit[i]->qtSlot();
179 unsigned short qtch = vecHit[i]->qtChannel();
180 unsigned short adc = vecHit[i]->adc();
181 unsigned short tdc = vecHit[i]->tdc();
182 float ene = vecHit[i]->energy();
185 muFmsHit->setDetectorId(detId);
186 muFmsHit->setChannel(ch);
187 muFmsHit->setQtCrate(crate);
188 muFmsHit->setQtSlot(slot);
189 muFmsHit->setQtChannel(qtch);
190 muFmsHit->setAdc(adc);
191 muFmsHit->setTdc(tdc);
192 muFmsHit->setEnergy(ene);
210 for(
unsigned short crate=1; crate<=4; crate++)
212 for(
unsigned short slot=1; slot<=16; slot++)
214 for(
unsigned short ch=0; ch<32; ch++)
216 unsigned short adc = triggerData.fmsADC(crate,slot-1,ch);
217 unsigned short tdc = triggerData.fmsTDC(crate,slot-1,ch);
219 if (adc <= 0 && tdc <= 0)
continue;
221 StMuFmsHit* muFmsHit = muFmsCollection.addHit();
223 muFmsHit->setQtCrate(crate);
224 muFmsHit->setQtSlot(slot);
225 muFmsHit->setQtChannel(ch);
226 muFmsHit->setAdc(adc);
227 muFmsHit->setTdc(tdc);
230 if ( !fmsDbMaker )
continue;
232 int detectorId, channelId;
234 fmsDbMaker->getReverseMap(crate, slot, ch, &detectorId, &channelId);
237 if ( detectorId <= 0 && channelId <= 0)
continue;
239 float g1 = fmsDbMaker->getGain(detectorId, channelId);
241 float energy = adc*g1*g2;
243 muFmsHit->setDetectorId(detectorId);
244 muFmsHit->setChannel(channelId);
245 muFmsHit->setEnergy(energy);
265 const Int_t runNumber = muDst.
event()->runId();
267 if ( triggerData && muFmsHits && runNumber < 18000000 ){
268 if ( muFmsHits->GetEntriesFast()>0 ) {
280 for (
unsigned i(0); i < fmscol->numberOfClusters(); ++i) {
284 muCluster->setDetectorId(cluster->detectorId());
285 muCluster->setCategory(cluster->category());
286 muCluster->setEnergy(cluster->energy());
287 muCluster->setX(cluster->x());
288 muCluster->setY(cluster->y());
289 muCluster->setSigmaMin(cluster->sigmaMin());
290 muCluster->setSigmaMax(cluster->sigmaMax());
291 muCluster->setChi2Ndf1Photon(cluster->chi2Ndf1Photon());
292 muCluster->setChi2Ndf2Photon(cluster->chi2Ndf2Photon());
293 muCluster->setId(cluster->id());
300 StPtrVecFmsHitConstIterator
hit;
301 for (hit = cluster->hits().begin(); hit != cluster->hits().end(); ++hit) {
302 const int index = findElementIndex(fmscol->hits(), *hit);
304 muCluster->hits()->Add(muFms->getHit(index));
308 StPtrVecFmsPointConstIterator p;
309 for (p = cluster->points().begin(); p != cluster->points().end(); ++p) {
310 const int index = findElementIndex(fmscol->points(), *p);
312 muCluster->photons()->Add(muFms->getPoint(index));
320 for (
unsigned i(0); i < fmscol->numberOfPoints(); ++i) {
321 const StFmsPoint* point = fmscol->points()[i];
323 if (point && muPoint) {
324 muPoint->set(*point);
331 LOG_DEBUG <<
"setMuFmsPointParentClusters" << endm;
332 for (
unsigned i(0); i < muFms->numberOfPoints(); ++i) {
335 const StFmsPoint* point = fmscol->points().at(i);
341 const int index = findElementIndex(fmscol->clusters(), point->cluster());
347 muPoint->setCluster(muFms->getCluster(index));
356 TIter next(muFms->getHitArray());
358 while ((muHit = static_cast<StMuFmsHit*>(next()))) {
360 StFmsHit* hit = fmscol->hits().back();
361 hit->setDetectorId(muHit->detectorId());
362 hit->setChannel(muHit->channel());
363 hit->setQtCrate(muHit->qtCrate());
364 hit->setQtSlot(muHit->qtSlot());
365 hit->setQtChannel(muHit->qtChannel());
366 hit->setAdc(muHit->adc());
367 hit->setTdc(muHit->tdc());
368 hit->setEnergy(muHit->energy());
375 TIter next(muFms->getClusterArray());
377 while ((muCluster = static_cast<StMuFmsCluster*>(next()))) {
381 cluster->setDetectorId(muCluster->detectorId());
382 cluster->setCategory(muCluster->category());
383 cluster->setNTowers(muCluster->hits()->GetEntries());
384 cluster->setEnergy(muCluster->energy());
385 cluster->setX(muCluster->x());
386 cluster->setY(muCluster->y());
387 cluster->setSigmaMin(muCluster->sigmaMin());
388 cluster->setSigmaMax(muCluster->sigmaMax());
389 cluster->setChi2Ndf1Photon(muCluster->chi2Ndf1Photon());
390 cluster->setChi2Ndf2Photon(muCluster->chi2Ndf2Photon());
391 cluster->setId(muCluster->id());
394 TIter next(muCluster->photons());
396 while ((muPoint = static_cast<StMuFmsPoint*>(next()))) {
397 const int index = muFms->getPointArray()->IndexOf(muPoint);
399 StFmsPoint* point = fmscol->points().at(index);
400 cluster->points().push_back(point);
411 TIter next(muFms->getPointArray());
413 while ((muPoint = static_cast<StMuFmsPoint*>(next()))) {
417 float energy=muPoint->energy();
418 point->setDetectorId(muPoint->detectorId());
419 point->setEnergy(energy);
420 point->setX(muPoint->x());
421 point->setY(muPoint->y());
422 point->setId(muPoint->id());
423 point->setXYZ(muPoint->xyz());
434 for (
unsigned i(0); i < muFms->numberOfClusters(); ++i) {
439 const int index = muFms->getClusterArray()->IndexOf(muPoint->cluster());
444 point->setCluster(cluster);
445 point->setParentClusterId(cluster->id());
446 point->setNParentClusterPhotons(cluster->nPhotons());
static StMuFmsCollection * muFmsCollection()
returns pointer to current StMuFmsCollection
Float_t getGainCorrection(Int_t detectorId, Int_t ch) const
get the gain for the channel
static void recoverMuFmsCollection(StMuDst &muDst, const StFmsDbMaker *=nullptr)
static void fillMuFmsHits(StMuFmsCollection &, const StTriggerData &, const StFmsDbMaker *=nullptr)
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)