/** CbmMuchDigiMatch.cxx **@author M.Ryzhinskiy **@since 23.03.07 **@version 1.0 ** ** Data class for matching CbmMuchDigi with CbmMuchPoint. ** The indices of CbmMuchDigi and CbmMuchDigiMatch correspond in their ** respective arrays. ** The class holds the indices of all MuchPoints corresponding to ** the MuchDigi. **/ #include "CbmMuchDigiMatch.h" #include "CbmMuchPoint.h" #include "TClonesArray.h" #include #include #include #include using std::cout; using std::endl; using std::numeric_limits; using std::map; using std::pair; // ----- Default constructor ------------------------------------------ CbmMuchDigiMatch::CbmMuchDigiMatch() : TObject(), fRefIndex(0), fCharge(0), fRefIndexPerPrimaryElectron(0), fChargePerPrimaryElectron(0), fDriftTimePerPrimaryElectron(0), fSignalShape(0) { }; // ------------------------------------------------------------------------- // ----- Standard constructor ------------------------------------------ CbmMuchDigiMatch::CbmMuchDigiMatch(CbmMuchDigiMatch* match) : TObject(*match), fRefIndex(match->fRefIndex), fCharge(match->fCharge), fRefIndexPerPrimaryElectron(match->fRefIndexPerPrimaryElectron), fChargePerPrimaryElectron(match->fChargePerPrimaryElectron), fDriftTimePerPrimaryElectron(match->fDriftTimePerPrimaryElectron), fSignalShape(match->fSignalShape) { /* if(!match){ cout << "-W- CbmMuchDigiMatch: NULL CbmMuchDigiMatch object " << endl; } else { fRefIndex.Set(match->GetNPoints()); fCharge.Set(match->GetNPoints()); for(Int_t i=0; iGetRefIndex(i), i); fCharge.AddAt(match->GetCharge(i), i); } Int_t nEl = match->GetNoPrimaryElectrons(); fRefIndexPerPrimaryElectron.Set(nEl); fChargePerPrimaryElectron.Set(nEl); fDriftTimePerPrimaryElectron.Set(nEl); for(Int_t i=0; iGetRefIndexPerPrimaryElectron(i),i); fChargePerPrimaryElectron.AddAt(match->GetChargePerPrimaryElectron(i),i); fDriftTimePerPrimaryElectron.AddAt(match->GetDriftTimePerPrimaryElectron(i),i); } } */ } // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- CbmMuchDigiMatch::~CbmMuchDigiMatch() { }; // ------------------------------------------------------------------------- // ----- Public method AddPoint ---------------------------------------- Int_t CbmMuchDigiMatch::AddPoint(Int_t iPoint) { if ( iPoint < 0 ) { cout << "-W- CbmMuchDigiMatch::AddPoint: Illegal MuchPoint index " << iPoint << endl; return 0; } Int_t n = fRefIndex.GetSize(); fRefIndex.Set(n+1); fRefIndex.AddAt(iPoint, n); return n+1; } // ------------------------------------------------------------------------- // ----- Public method GetRefIndex ------------------------------------- Int_t CbmMuchDigiMatch::GetRefIndex(Int_t i) const { if ( i<0 || i>GetNPoints()-1 ) { cout << "-W- CbmMuchDigiMatch::GetRefIndex: Illegal index number " << i << endl; return -1; } return fRefIndex.At(i); } // ------------------------------------------------------------------------- // ----- Public method AddCharge ---------------------------------------- UInt_t CbmMuchDigiMatch::AddCharge(UInt_t iCharge) { if ( iCharge < 0 ) { cout << "-W- CbmMuchDigiMatch::AddCharge: Illegal charge value " << iCharge << endl; return 0; } Int_t n = fCharge.GetSize(); fCharge.Set(n+1); fCharge.AddAt(iCharge, n); assert(fCharge.At(n) == iCharge); return n+1; } // ------------------------------------------------------------------------- // ----- Public method AddCharge ---------------------------------------- UInt_t CbmMuchDigiMatch::AddCharge(Int_t iPoint, UInt_t iCharge) { for (Int_t i=0;iGetNPoints()-1 ) { cout << "-W- CbmMuchDigiMatch::GetCharge: Illegal index number " << i << endl; return 0; } return fCharge.At(i); } // ------------------------------------------------------------------------- // ----- Public method GetTotalCharge ----------------------------------- UInt_t CbmMuchDigiMatch::GetTotalCharge() const { UInt_t totCharge = 0; for(Int_t iRef=0; iRef::max(); } return totCharge; } // ------------------------------------------------------------------------- void CbmMuchDigiMatch::SortPointsInTime(TClonesArray* points) { map time_vs_index; map time_vs_charge; map::iterator it; assert(points); for (Int_t i=0;iGetEntriesFast()); CbmMuchPoint* point = (CbmMuchPoint*) points->At(fRefIndex[i]); assert(point); Double_t time = point->GetTime(); time_vs_index.insert(pair(time,fRefIndex[i])); time_vs_charge.insert(pair(time,fCharge[i])); } Int_t i=0; for (it=time_vs_index.begin();it!=time_vs_index.end();++it) fRefIndex[i++] = it->second; i=0; for (it=time_vs_charge.begin();it!=time_vs_charge.end();++it) fCharge[i++] = it->second; time_vs_index.clear(); time_vs_charge.clear(); } // ------------------------------------------------------------------------- void CbmMuchDigiMatch::Reset() { fRefIndex.Reset(); fCharge.Reset(); fRefIndexPerPrimaryElectron.Reset(0); fChargePerPrimaryElectron.Reset(0); fDriftTimePerPrimaryElectron.Reset(0); fSignalShape.Reset(0); fRefIndex.Set(0); fCharge.Set(0); fRefIndexPerPrimaryElectron.Set(0); fChargePerPrimaryElectron.Set(0); fDriftTimePerPrimaryElectron.Set(0); fSignalShape.Set(0); } UInt_t CbmMuchDigiMatch::AddCharge(Int_t iPoint, UInt_t iCharge, Double_t driftTime) { AddCharge(iPoint,iCharge); // printf("Add...\n"); Int_t n = fRefIndexPerPrimaryElectron.GetSize(); fRefIndexPerPrimaryElectron.Set(n+1); fChargePerPrimaryElectron.Set(n+1); fDriftTimePerPrimaryElectron.Set(n+1); fRefIndexPerPrimaryElectron.AddAt(iPoint, n); fChargePerPrimaryElectron.AddAt(iCharge, n); fDriftTimePerPrimaryElectron.AddAt(driftTime, n); } ClassImp(CbmMuchDigiMatch)