#include "CbmMuchClusterFinder.h" #include "CbmRootManager.h" #include "CbmMuchPoint.h" #include "CbmMuchHit.h" #include "CbmMuchDigi.h" #include "CbmMuchStation.h" #include "CbmMuchSector.h" #include "CbmMuchDigiScheme.h" #include "CbmMuchStation.h" #include "CbmMuchSector.h" #include "CbmRunAna.h" #include "CbmRuntimeDb.h" #include "CbmGeoMuchPar.h" #include "CbmMuchDigiPar.h" #include "CbmMuchPad.h" #include "TCanvas.h" #include "TPolyLine.h" #include "TColor.h" ClassImp(CbmMuchClusterFinder) // ---- Constructor ---------------------------------------------------- CbmMuchClusterFinder::CbmMuchClusterFinder(const char *name, Int_t verbose) :CbmTask(name,verbose) { fDigiScheme = new CbmMuchDigiScheme(); fPads = new TClonesArray("CbmMuchPad",100); } // -------------------------------------------------------------------- // ---- Destructor ---------------------------------------------------- CbmMuchClusterFinder::~CbmMuchClusterFinder(){ } // -------------------------------------------------------------------- // ----- Private method SetParContainers ------------------------------- void CbmMuchClusterFinder::SetParContainers() { CbmRunAna* fRun = CbmRunAna::Instance(); CbmRuntimeDb* db = fRun->GetRuntimeDb(); fGeoPar = (CbmGeoMuchPar*) db->getContainer("CbmGeoMuchPar"); fDigiPar = (CbmMuchDigiPar*) db->getContainer("CbmMuchDigiPar"); } // ------------------------------------------------------------------------- // ---- Init ---------------------------------------------------------- InitStatus CbmMuchClusterFinder::Init(){ printf("CbmMuchClusterFinder::Init() ...\n"); CbmRootManager* fManager = CbmRootManager::Instance(); fPoints = (TClonesArray *) fManager->GetObject("MuchPoint"); fDigis = (TClonesArray *) fManager->GetObject("MuchDigi"); fDigiScheme->Init(fGeoPar, fDigiPar); return kSUCCESS; } // -------------------------------------------------------------------- // ---- Exec ---------------------------------------------------------- void CbmMuchClusterFinder::Exec(Option_t * option){ if (fVerbose) printf("CbmMuchClusterFinder::Exec() ...\n"); if (fVerbose>1) printf("nDigis=%i\n",fDigis->GetEntriesFast()); fPads->Clear(); Double_t x[5], y[5]; // pad corner coordinates CbmMuchStation* station = fDigiScheme->GetStation(1); Int_t iPad = 0; for (Int_t iSec=0; iSecGetNSectors(); iSec++){ CbmMuchSector* sector = station->GetSector(iSec); printf(" sector: %i\n",iSec); for (Int_t channel=0; channelGetNChannels();channel++){ sector->GetPadVertices(channel,x,y); new ((*fPads)[iPad++]) CbmMuchPad(x,y,channel); } } printf("pads:%i\n",fPads->GetEntriesFast()); for (Int_t i=0;iGetEntriesFast();i++){ CbmMuchDigi* digi = (CbmMuchDigi*) fDigis->At(i); Int_t stationNr = digi->GetStationNr(); if (stationNr!=1) continue; Int_t sector = digi->GetSectorNr(); Int_t channel = digi->GetChannelNr(); printf(" sector = %3i channel = %3i\n",sector,channel); // printf("%i ",128*(sector-1)+channel); ((CbmMuchPad*)fPads->At(128*(sector-1)+channel))->SetCharge(digi->GetCharge()); } TCanvas* c1 = new TCanvas("c1","c1",800,800); c1->Draw(); c1->Range(-80,-80,80,80); for (Int_t i=0;iGetEntriesFast();i++){ CbmMuchPad* pad = (CbmMuchPad*) fPads->At(i); Double_t x[5], y[5]; for (Int_t ix=0;ix<4;ix++) x[ix]=pad->GetX(ix); for (Int_t iy=0;iy<4;iy++) y[iy]=pad->GetY(iy); x[4]=x[0]; y[4]=y[0]; // printf(" x=%4.2f %4.2f %4.2f %4.2f y=%4.2f %4.2f %4.2f %4.2f\n",x[0],x[1],x[2],x[3],y[0],y[1],y[2],y[3]); TPolyLine* visPad = new TPolyLine(5,x,y); Int_t ch = pad->GetCharge(); ch = ch/1000; if (ch>511) ch = 255; visPad->SetFillColor(TColor::GetColor(255-ch,255-ch,255)); visPad->SetLineColor(34); visPad->Draw("f"); visPad->Draw(); } c1->Update(); } // -------------------------------------------------------------------- // -------------------------------------------------------------------- void CbmMuchClusterFinder::Finish(){ printf("CbmMuchClusterFinder::Finish() ...\n"); } // --------------------------------------------------------------------