/* * CbmClusteringGeometry.cxx * * Created on: Feb 22, 2012 * Author: kozlov */ #include "CbmClusteringGeometry.h" #include "CbmStsHit.h" #include "CbmStsPoint.h" #include "CbmMuchPixelHit.h" #include "CbmMuchPoint.h" #include "CbmMCTrack.h" #include "CbmMuchGeoScheme.h" #include "CbmMuchLayerSide.h" #include "CbmMuchModuleGem.h" #include "CbmMuchPad.h" #include "CbmMuchDigi.h" #include "CbmMuchStation.h" #include "CbmMuchLayer.h" #include "CbmMuchLayerSide.h" #include "CbmMuchSectorRectangular.h" #include "CbmMuchPadRectangular.h" #include "FairRootManager.h" #include "TClonesArray.h" #include #include using std::cout; using std::endl; CbmClusteringGeometry::CbmClusteringGeometry(): fDetId(), fPadList() { fNofPads = 0; //fStation = 0; //fLayer = 0; //fSide = 0; //fModule = 0; fNofActivePads = 0; } CbmClusteringGeometry::CbmClusteringGeometry(Int_t nStation, Int_t nLayer, Bool_t nSide, Int_t nModule, CbmMuchGeoScheme* scheme) { SetMuchModuleGeometry(nStation, nLayer, nSide, nModule, scheme); } CbmClusteringGeometry::~CbmClusteringGeometry() { delete [] fPadList; } void CbmClusteringGeometry::SetMuchModuleGeometry(Int_t nStation, Int_t nLayer, Bool_t nSide, Int_t nModule, CbmMuchGeoScheme* scheme) { //std::cout<<"\n\nCreating module geometry for clustering..."; //--CbmMuchGeoScheme* scheme = CbmMuchGeoScheme::Instance(); //sch init - name //TString parDir = TString(gSystem->Getenv("VMCWORKDIR")) + TString("/parameters"); //--TString muchDigiFile = "/home/kozlov/cbm/cbmroot_new/cbmroot/parameters/much/much_v11a.digi.root"; //--scheme->Init(muchDigiFile); CbmMuchModuleGem* module = (CbmMuchModuleGem*) scheme->GetModule(nStation, nLayer, nSide, nModule); fNofPads = module->GetNPads(); fDetId = module->GetDetectorId(); fPadList = new PadInformation[fNofPads]; fNofActivePads = 0; Int_t nofSectors = module->GetNSectors(); Int_t padIterator = 0; for(Int_t iSector = 0; iSector < nofSectors; iSector++) { CbmMuchSectorRectangular* sector = (CbmMuchSectorRectangular*) module->GetSector(iSector); //??? Int_t nofPadsInSector = sector->GetNChannels();//(sector->GetNCols())*(sector->GetNRows()); //Double_t padsDx_2 = (sector->GetPadDx())/2; //Double_t padsDy_2 = (sector->GetPadDy())/2; //std::cout<<"DX: "<GetPadNx(); Int_t padNy = sector->GetPadNy(); //for(Int_t iPad = 0; iPad < nofPadsInSector; iPad++) /*for(Int_t i = 0; i < padNx; i++) { for(Int_t j = 0; j < padNy; j++) {*/ for(Int_t iPad = 0; iPad < nofPadsInSector; iPad++) { CbmMuchPadRectangular* pad = (CbmMuchPadRectangular*) sector->GetPadByChannelIndex(iPad); //!!! fPadList[padIterator].fDigiNum = 0; fPadList[padIterator].fCharge = 0; fPadList[padIterator].fX = pad->GetX(); fPadList[padIterator].fY = pad->GetY(); fPadList[padIterator].fDx = sector->GetPadDx(); fPadList[padIterator].fDy = sector->GetPadDy(); fPadList[padIterator].fNeighbors.clear(); //fPadList[padIterator].x1 = fPadList[padIterator].xc - padsDx_2; //fPadList[padIterator].x2 = fPadList[padIterator].xc + padsDx_2; //fPadList[padIterator].y1 = fPadList[padIterator].yc - padsDy_2; //fPadList[padIterator].y2 = fPadList[padIterator].yc + padsDy_2; fPadList[padIterator].channelID = pad->GetChannelId(); fPadByChannelId[pad->GetChannelId()] = padIterator; /*std::cout<<"Pad: "<GetChannelId()<<"\n"; std::cout<<"Xc = "<= (GetMin(yDown_1, yUp_1) - dY)) && ((GetMin(yDown_2, yUp_2) - dY) <= (GetMax(yDown_1, yUp_1) + dY)))) || ((SubEqual(yDown_1, yUp_2, dY) || SubEqual(yUp_1, yDown_2, dY)) && (((GetMax(xLeft_2, xRight_2) + dX) >= (GetMin(xLeft_1, xRight_1) - dX)) && ((GetMin(xLeft_2, xRight_2) - dX) <= (GetMax(xLeft_1, xRight_1) + dX))))) && (iPadMain != iPadNeighbor)) { fSingleLayerGeo[iPadMain].allNeighbors[padIterator] = iPadNeighbor; fSingleLayerGeo[iPadMain].nofNeighbors++; padIterator++; //std::cout<<"Neighbours: P1 = "< (GetMin(yDown_1, yUp_1) + dY)) && ((GetMin(yDown_2, yUp_2) + dY) < (GetMax(yDown_1, yUp_1) - dY)))) || ((SubEqual(yDown_1, yUp_2, dY) || SubEqual(yUp_1, yDown_2, dY)) && (((GetMax(xLeft_2, xRight_2) - dX) > (GetMin(xLeft_1, xRight_1) + dX)) && ((GetMin(xLeft_2, xRight_2) + dX) < (GetMax(xLeft_1, xRight_1) - dX))))) && (iPadMain != iPadNeighbor)) { fPadList[iPadMain].fNeighbors.push_back(iPadNeighbor); //fSingleLayerGeo[iPadMain].goodNeighbors[padIterator2] = iPadNeighbor; fPadList[iPadMain].fNofGoodNeighbors++; //padIterator2++; } }} } //fStation = nStation; //fLayer = nLayer; //fSide = nSide; //fModule = nModule; //std::cout<<" Geometry created:\nStation "< T1 CbmClusteringGeometry::GetMin(T1& a, T1& b) { if(a > b) { return b; } else { return a; } } template T2 CbmClusteringGeometry::GetMax(T2& a, T2& b) { if(a < b) { return b; } else { return a; } } Bool_t CbmClusteringGeometry::SubEqual(Float_t x1, Float_t x2, Float_t l) { //l = l * 0.1; if((x1 < (x2 + l)) && (x1 > (x2 - l))) { return 1; } else { return 0; } } Int_t CbmClusteringGeometry::GetPadByChannelId(Long64_t chId) { return fPadByChannelId[chId]; }