// This Class' Header ------------------ #include "PndMvdSimpleHitMaker.h" // C/C++ Headers ---------------------- #include // ROOT Headers ---------------------- #include "TGeoManager.h" #include "TGeoBBox.h" #include "TVector3.h" #include "TString.h" #include "TMath.h" // Collaborating Class Headers -------- #include "PndMvdDetectorDescr.h" /// #include "PndMvdPixelModule.h" /// #include "PndMvdStripModule.h" #include "PndMvdDigiPixel.h" #include "PndMvdDigiStrip.h" #include "PndMvdHit.h" #include "PndMvdCalcFePixel.h" #include "PndMvdCalcStrip.h" // enum SensorSide { kTOP, kBOTTOM }; bool verbose = false; PndMvdSimpleHitMaker::PndMvdSimpleHitMaker(PndMvdDetectorDescr* mvdDetDescr) : PndMvdHitMaker(mvdDetDescr) { /// mvdDetDescr->detector()->getNomModuleParams(fpixelModules, fstripModules); fpixelCellX = mvdDetDescr->pixelCellX(); fpixelCellY = mvdDetDescr->pixelCellY(); fstripX = mvdDetDescr->stripX(); fstripY = mvdDetDescr->stripY(); } bool PndMvdSimpleHitMaker::makeHits( std::vector& pixelarray, std::vector& striparray, std::vector& hitarray) {// TODO digi arrays als const uebergeben? //check consistencies //Every digi will become one hit // PrintParameters(); // TODO read Parameters from Database PndMvdCalcFePixel FeCalc(76, 84, 10); bool once = true; // --- Pixals ---------------------------- for (std::vector::iterator itpixel = pixelarray.begin(); itpixel != pixelarray.end(); itpixel++) { PndMvdDigiPixel* myPixelDigi = *itpixel; // TODO remove this, work only with the iterator if (myPixelDigi==0) { std::cout<<"PndMvdSimpleHitMaker::makeHits(): myPixelDigi does not exist!"<GetDetName(); gGeoManager->cd(detname); TGeoVolume* actVolume = gGeoManager->GetCurrentVolume(); TGeoBBox* actBox = (TGeoBBox*)(actVolume->GetShape()); TVector3 sensorDim; sensorDim.SetX(actBox->GetDX()); sensorDim.SetY(actBox->GetDY()); sensorDim.SetZ(actBox->GetDZ()); Int_t fe = myPixelDigi->GetFE(); Int_t col = myPixelDigi->GetPixelColumn(); Int_t row = myPixelDigi->GetPixelRow(); FeCalc.CalcSensorColRow(col,row,fe); // backmap channel&FE to pixel cell No. Double_t dcol,drow; if (col < 0){ dcol = -0.5; std::cerr<<"######### NEGATIVE COL ("<LocalToMaster(local,master); TVector3 hitPos(master[0],master[1],master[2]); local[0]=fpixelCellX/sqrt(12.); local[1]=fpixelCellY/sqrt(12.); local[2]=0.; gGeoManager->LocalToMaster(local,master); TVector3 hitErr(master[0],master[1],master[2]); // TODO Do we need the views seperated? PndMvdHit* hit = new PndMvdHit(myPixelDigi->GetDetID(), (myPixelDigi->GetDetName()).Data(), hitPos, hitErr, myPixelDigi->GetIndex(),myPixelDigi->GetCharge() , 1); hitarray.push_back(hit); } // end of pixel digiloop // --- Strips ---------------------------- //prepare arrays and variables enum SensorSide side; Int_t nrFeChannels = 128; Int_t nrTopStrips = 10*nrFeChannels; TVector2 topAnchor(0.,0.); TVector2 botAnchor(0.,0.); Double_t orient=TMath::Pi()*(0.5); Double_t skew=TMath::Pi()*(0.5); ///TODO: Get Params from database PndMvdCalcStrip stripcalcTOP(fstripX,orient, nrTopStrips, nrFeChannels,topAnchor,0.,0.); PndMvdCalcStrip stripcalcBOT(fstripY,orient + skew, nrTopStrips, nrFeChannels,botAnchor,0.,0.); /* PndMvdCalcStrip stripcalcTOP(fstripX,TMath::Pi()*(0.5), nrStrips , 128, topAnchor,0.,0.); PndMvdCalcStrip stripcalcBOT(fstripY,TMath::Pi()*(1.0), nrStrips , 128, botAnchor,0.,0.);*/ TVector2 topDirection = stripcalcTOP.GetStripDirection(); TVector2 botDirection = stripcalcBOT.GetStripDirection(); TVector2 point; TString detname; TGeoVolume* actVolume; TGeoBBox* actBox; TVector3 sensorDim; Int_t fe,channel; Int_t strip,index,mcindex; std::map > hitmapTOP; std::map > hitmapBOT; for (std::vector::iterator itstrip = striparray.begin(); itstrip != striparray.end(); itstrip++) { index = distance(striparray.begin(),itstrip) + 1; mcindex = (*itstrip)->GetIndex(); if(verbose) std::cout<<"itstrip = "<<*itstrip <<" this corresponds to index "<GetFE(); channel = (*itstrip)->GetChannel(); stripcalcTOP.CalcFeChToStrip(fe,channel,strip,side); if (side == kTOP) { if(verbose) std::cout<<"\t\t\ttop"< toplist; std::map botlist; Int_t counter = 0; Double_t meanstrip = 0.,meanstriptop = 0.,meanstripbot = 0.; TVector2 meantopPoint, meanbotPoint; for(std::map >::iterator itToplist = hitmapTOP.begin(); itToplist != hitmapTOP.end(); itToplist++) { // mcindex = distance(hitmapTOP.begin(),itToplist); mcindex = itToplist->first; toplist = itToplist->second; botlist = hitmapBOT[mcindex]; // --- kTOP --- counter = 0; meanstrip = 0.; for(std::map::iterator itTop = toplist.begin(); itTop != toplist.end(); itTop++) { counter++; meanstrip+=itTop->second; } if(counter==0){ if(verbose) std::cout<<" *** next step (top)"<::iterator itBot = botlist.begin(); itBot != botlist.end(); itBot++) { counter++; meanstrip+=itBot->second; } if(counter==0){ if(verbose) std::cout<<" *** next step (bot)"<first]; detname = aDigi->GetDetName(); gGeoManager->cd(detname); actVolume = gGeoManager->GetCurrentVolume(); actBox = (TGeoBBox*)(actVolume->GetShape()); sensorDim.SetX(actBox->GetDX()); sensorDim.SetY(actBox->GetDY()); sensorDim.SetZ(actBox->GetDZ()); Double_t local[3], master[3]; local[0]=onsensorPoint.X(); local[1]=onsensorPoint.Y(); local[2]=0; //shift sensor system into middle local[0]-=sensorDim.X(); local[1]-=sensorDim.Y(); local[2]-=sensorDim.Z(); gGeoManager->LocalToMaster(local,master); TVector3 hitPos(master[0],master[1],master[2]); local[0]=fstripX/sqrt(12.); local[1]=fstripY/sqrt(12.); local[2]=0.; gGeoManager->LocalToMaster(local,master); TVector3 hitErr(master[0],master[1],master[2]); // --- add cluster to list --- PndMvdHit* hit = new PndMvdHit(aDigi->GetDetID(), (aDigi->GetDetName()).Data(), hitPos, hitErr, mcindex, aDigi->GetCharge(), 1 ); hitarray.push_back(hit); } // std::cout<<"\t - end of PndMvdSimpleHitMaker::makeHits()."<