#include "TpcPrelimCluster.h" #include #include #include "TpcDigiMapper.h" #include "TpcPadPlane.h" #include "TpcCluster.h" #include "McId.h" #include "McIdCollection.h" TpcPrelimCluster::TpcPrelimCluster(TpcPadPlane* p, double t, int id, double G, double C) : famp(0.), fcogT(0.), fpadplane(p), ftimeslice(t), fid(id), fG(G), fC(C), fnUnsharedDigis(0) { } TpcPrelimCluster::TpcPrelimCluster(TpcPadPlane* p, int id, double G, double C) : famp(0.), fcogT(0.), fpadplane(p), ftimeslice(0), fid(id), fG(G), fC(C), fnUnsharedDigis(0) { } TpcPrelimCluster::~TpcPrelimCluster() { } void TpcPrelimCluster::addHit(TpcDigi* digi, bool noXclust, double share, bool check) { // check if digi is already there if (check && std::find(fdigis.begin(), fdigis.end(), digi) != fdigis.end()){ fdigiShares[digi] += share; } else { fdigis.push_back(digi); fdigiShares[digi] = share; } // update amp and cogT double sharedAmp = digi->amp()*fdigiShares[digi]; fcogT += sharedAmp * digi->t(); // not normalized! famp += sharedAmp; //fcogT*=1./famp; if (fdigiShares[digi] > 0.9999) ++fnUnsharedDigis; if (check) return; // we are in the second cluster merging pass - no updating of neighbours necessary! // update neighbours fpossiblePads.insert(digi->padId()); TpcPad* pad = fpadplane->GetPad(digi->padId()); // only add neighbors to possible pads if digi is not shared! for(unsigned int ineigh=0; ineighnNeighbours(); ++ineigh){ if(noXclust){ TpcPad* neigh = fpadplane->GetPad( pad->getNeighbour(ineigh) ); if(fabs(pad->x()-neigh->x())>0.01) continue; //gt 0.1mm } if (share > 0.9999) fpossiblePads.insert(pad->getNeighbour(ineigh)); else fpossiblePadsShared.insert(pad->getNeighbour(ineigh)); } } bool TpcPrelimCluster::isInTimeWindow(const TpcDigi* const digi){ if( fabs(digi->t() - fcogT/famp) <= ftimeslice ) // fcogT has to be normalized with famp return true; return false; } int TpcPrelimCluster::isInCluster(const TpcDigi* const digi) { if(!isInTimeWindow(digi)) return 0; // not a neighbour int padID = digi->padId(); if(fpossiblePads.find(padID) == fpossiblePads.end()) { // not a neighbour to any unshared digi if(fpossiblePadsShared.find(padID) == fpossiblePadsShared.end()) return 0; // not a neighbour to any shared digi return 2; // neighbour to a shared digi } return 1; // neighbour to an unshared digi } TpcCluster* TpcPrelimCluster::convTpcCluster(unsigned int sectorId, double zJitter, bool saveRaw) { cog(zJitter); // also error is calculated here TpcCluster* c = new TpcCluster(fpos,ferr,famp,fid); c->SetMcId(fmcidCol); //always store digis inside the cluster, only index and weight is copied for(unsigned int i=0;iisSaturated()){ c->setSaturation(true); } c->addDigi(fdigis[i], fdigiShares[fdigis[i]]); } c->SetSector(sectorId); return c; } void TpcPrelimCluster::cog(double zJitter){ bool DEBUG=false; fpos.SetXYZ(0,0,0); famp=0; McIdCollection mcid; unsigned int ndigis=fdigis.size(); // loop over digis to calculate cog TpcDigi* adigi; TVector3 thispos; for(unsigned int id=0;idamp()*fdigiShares[adigi]; mcid.AddIDCollection(adigi->mcId(),a); try{ TpcDigiMapper::getInstance()->map(adigi,thispos); } catch(const std::exception& ex) { std::cout<getGas()->Dl(); double Dt = TpcDigiMapper::getInstance()->getGas()->Dt(); double driftl = fabs(fpos.z() - TpcDigiMapper::getInstance()->zGem()); //if(DEBUG) { // std::cout<<"TpcSectorProcessor: Gas DiffL: "<
zGem()<padsize(fdigis[0]->padId(),dx,dy); //std::cout<<"dx, dy = "<amp()*fdigiShares[adigi]; try { TpcDigiMapper::getInstance()->map(adigi,thispos); } catch(const std::exception& ex) { std::cout<::iterator it = fSharedClusters[d].begin(); for (unsigned int j=0; j