// ------------------------------------------------------------------------- // ----- PndMvdStripClusterTask source file ----- // ------------------------------------------------------------------------- #include #include "TClonesArray.h" #include "TArrayD.h" #include "TGeoManager.h" #include "TGeoMatrix.h" #include "FairRootManager.h" #include "FairRunAna.h" #include "FairRuntimeDb.h" #include "FairGeoNode.h" #include "FairGeoVector.h" //#include "PndStringVector.h" #include "PndGeoHypPar.h" #include "PndHypStripDigiPar.h" #include "PndHypStripClusterTask.h" #include "PndHypPoint.h" #include "PndHypCalcStrip.h" #include "PndHypDigiStrip.h" //#include "PndHypStripCluster.h" //#include "PndHypClusterCand.h" #include "PndHypCluster.h" #include "PndHypGeoHandling.h" #include "FairHit.h" #include "PndHypStripClusterBuilder.h" #include // enum SensorSide { kTOP, kBOTTOM }; // ----- Default constructor ------------------------------------------- PndHypStripClusterTask::PndHypStripClusterTask() : FairTask("HYP Strip Clustertisation Task") { fChargeCut = 1.e6; // this ist really large and shall have no effect fGeoFile = ""; } // ------------------------------------------------------------------------- // ----- constructor ------------------------------------------- PndHypStripClusterTask::PndHypStripClusterTask(Double_t chargecut,TString geoFile) : FairTask("HYP Strip Clustertisation Task") { fChargeCut = chargecut; fGeoFile = geoFile; } // ------------------------------------------------------------------------- // ----- Destructor ---------------------------------------------------- PndHypStripClusterTask::~PndHypStripClusterTask() { if(0!=fGeoH)delete fGeoH; } // ------------------------------------------------------------------------- // ----- Initialization of Parameter Containers ------------------------- void PndHypStripClusterTask::SetParContainers() { // Get Base Container FairRunAna* ana = FairRunAna::Instance(); FairRuntimeDb* rtdb=ana->GetRuntimeDb(); //fGeoPar = (PndGeoHypPar*)(rtdb->getContainer("PndGeoHypPar")); fDigiPar = (PndHypStripDigiPar*)(rtdb->getContainer("PndHypStripDigiPar")); } InitStatus PndHypStripClusterTask::ReInit() { InitStatus stat=kERROR; return stat; /*FairRunAna* ana = FairRunAna::Instance(); FairRuntimeDb* rtdb=ana->GetRuntimeDb(); fGeoPar=(PndGeoHypPar*)(rtdb->getContainer("PndGeoHypPar")); return kSUCCESS;*/ /* return kSUCCESS; */ } // ----- Public method Init -------------------------------------------- InitStatus PndHypStripClusterTask::Init() { FairRootManager* ioman = FairRootManager::Instance(); if ( ! ioman ) { std::cout << "-E- PndHypStripClusterTask::Init: " << "RootManager not instantiated!" << std::endl; return kFATAL; } // Get input array fDigiArray = (TClonesArray*) ioman->GetObject("HypStripDigis"); if ( ! fDigiArray ) { std::cout << "-W- PndHypStripClusterTask::Init: " << "No HYPDigi array!" << std::endl; return kERROR; } // set output arrays fHitArray = new TClonesArray("PndHypHit"); //ioman->Register("HYPStripClusterHit", "HYP", fHitArray, kTRUE); ioman->Register("HYPHit", "HYP", fHitArray, kTRUE); fClusterArray = new TClonesArray("PndHypCluster"); ioman->Register("HYPStripClusterCand","HYP",fClusterArray,kTRUE); SetParContainers(); // geo name handling if (fGeoFile=="") fGeoFile = ioman->GetInFile()->GetName(); fGeoH = new PndHypGeoHandling(fGeoFile.Data()); if ( ! fDigiPar ) { std::cout << "-W- PndMvdStripClusterTask::Init: " << "No fDigiParTrap!" << std::endl; return kERROR; } fstripcalcTOP = new PndHypCalcStrip (fDigiPar, kTOP); fstripcalcBOT = new PndHypCalcStrip (fDigiPar, kBOTTOM); std::cout << "-I- PndHypStripClusterTask: Initialisation successfull" << std::endl; return kSUCCESS; } // ------------------------------------------------------------------------- // ----- Public method Exec -------------------------------------------- void PndHypStripClusterTask::Exec(Option_t*) { if (fVerbose > 2) std::cout<<"Sarting PndHypStripClusterTask::Exec()"< digiStripArray; // std::vector clusters; // Reset output array if ( ! fClusterArray ) Fatal("Exec", "No ClusterArray"); fClusterArray->Clear(); if ( ! fHitArray ) Fatal("Exec", "No HitArray"); fHitArray->Clear(); //Int_t nPoints = fDigiArray->GetEntriesFast(); //[R.K. 01/2017] unused variable // load the Clusterfinder PndHypStripClusterBuilder clusterbuilder; // PndHypCalcStrip stripcalcTOP(fDigiPar, kTOP); // PndHypCalcStrip stripcalcBOT(fDigiPar, kBOTTOM); if(fVerbose>1) fDigiPar->Print(); TVector2 topDirection, botDirection ; //TGeoVolume* actVolume; //[R.K. 01/2017] unused variable //TGeoBBox* actBox; //[R.K. 01/2017] unused variable TVector3 sensorDim,localpos, localDpos; TString detName;//std::string detName; Int_t detID, clindex, botIndex;//;iDigi, mcindex,topIndex, //[R.K. 01/2017] unused variable Double_t mycharge; TVector2 meantopPoint, meanbotPoint, onsensorPoint; TVector3 hitPos,hitErr; Double_t t, b; //local[3], master[3], //[R.K. 01/2017] unused variable //std::map firedSensors; Int_t strip; SensorSide side; PndHypDigiStrip* myDigi=0; //PndHypCluster* myCandTop=0; //[R.K. 01/2017] unused variable //PndHypCluster* myCandBot=0; //[R.K. 01/2017] unused variable for (Int_t iPoint = 0; iPoint < fDigiArray->GetEntriesFast(); iPoint++) { // sort digis by sensor name and stripnumber myDigi = (PndHypDigiStrip*)(fDigiArray->At(iPoint)); detName = myDigi->GetDetName().Data(); fstripcalcTOP->CalcFeChToStrip(myDigi->GetFE(), myDigi->GetChannel(), strip, side); std::cout<<" strip "<< strip<<" side "<GetFE(), myDigi->GetChannel(), stripB, sideB); clusterbuilder.AddDigi(detName.Data(),side,strip,iPoint); //if(firedSensors[detName.Data()]) firedSensors[detName.Data()] = myDigi->GetDetID(); } std::vector< PndHypCluster > clusters; std::vector< Int_t > topclusters;// contains index to fClusterArray std::vector< Int_t > botclusters;// contains index to fClusterArray std::vector< Int_t > oneclustertop; std::vector< Int_t > oneclusterbot; // ----- search for clusters ----- clusters = clusterbuilder.SearchClusters(); topclusters = clusterbuilder.GetTopClusterIDs(); botclusters = clusterbuilder.GetBotClusterIDs(); for(std::vector< PndHypCluster >::iterator clit= clusters.begin(); clit!=clusters.end(); ++clit) { /// Muss ich den copy construktor selbst schreiben? /// fehlt was im linkdef? clindex = fClusterArray->GetEntriesFast(); //std::cout<<" clindex "< 2) { std::cout<<"Top Clusters: "; for (std::vector< Int_t>::iterator itTop = topclusters.begin(); itTop!=topclusters.end(); ++itTop) { std::cout<<*itTop<<" | "; } std::cout<::iterator itBot = botclusters.begin(); itBot!=botclusters.end(); ++itBot) { std::cout<<*itBot<<" | "; } std::cout<::iterator itTop = topclusters.begin(); itTop!=topclusters.end(); ++itTop) { // prepare values for the top side Double_t topcharge = 0., meantopstrip=0.; oneclustertop = clusters[*itTop].GetClusterList(); TString detnametop = ((PndHypDigiStrip*)fDigiArray->At(oneclustertop[0]))->GetDetName(); //std::cout<<"det id top "<GetStripDirection(); botDirection = fstripcalcBOT->GetStripDirection(); detID = ((PndHypDigiStrip*)fDigiArray->At(oneclustertop[0]))->GetDetID(); //Double_t lastcharge=0; //[R.K. 01/2017] unused variable for (std::vector::iterator itTopDigi = oneclustertop.begin(); itTopDigi != oneclustertop.end(); ++itTopDigi) {// I use the temp. variables from the top of this method again // calculate the mean charge and stripnumber myDigi = (PndHypDigiStrip*)fDigiArray->At(*itTopDigi); fstripcalcTOP->CalcFeChToStrip(myDigi->GetFE(), myDigi->GetChannel(), strip, side); topcharge += myDigi->GetCharge(); meantopstrip += myDigi->GetCharge() * strip; if(fVerbose > 2)std::cout<<"FE no: "<GetFE()<<" | channel no: " <GetChannel()<<" | topstrip no: " <GetDetID()<0) { meantopstrip = meantopstrip/topcharge; fstripcalcTOP->CalcStripPointOnLine(meantopstrip, meantopPoint); // loop on bottom side for (std::vector< Int_t>::iterator itBot = botclusters.begin(); itBot!=botclusters.end(); ++itBot) { botIndex = *itBot; Double_t botcharge = 0., meanbotstrip=0.; oneclusterbot =( clusters[*itBot]).GetClusterList(); //std::cout<<" size bot "<At(oneclusterbot[0]))->GetDetName(); //std::cout<<" bot name "<::iterator itBotDigi = oneclusterbot.begin(); itBotDigi != oneclusterbot.end(); ++itBotDigi) {// I use the temp. variables from the top of this method again myDigi = (PndHypDigiStrip*)fDigiArray->At(*itBotDigi); fstripcalcTOP->CalcFeChToStrip(myDigi->GetFE(), myDigi->GetChannel(), strip, side); botcharge += myDigi->GetCharge(); meanbotstrip += myDigi->GetCharge() * strip; if(fVerbose > 2)std::cout<<"FE no: "<GetFE()<<" | channel no: " <GetChannel()<<" | botstrip no: "<0) { meanbotstrip = meanbotstrip/botcharge; // look if the charges are not too differently if(fVerbose > 2) { std::cout<<"Charges: Ctop = "<LocalToMasterId(localpos,detnametop.Data()); //gGeoManager->LocalToMaster(local,master); //hitPos.SetXYZ(master[0],master[1],master[2]); // calculate the errors corresponding to a skewed system! t = fDigiPar->GetTopPitch()*cos(fDigiPar->GetOrient()); b = fDigiPar->GetBotPitch()*cos(fDigiPar->GetOrient()+fDigiPar->GetSkew()); localDpos.SetX(sqrt((t*t+b*b)/12.)); t = fDigiPar->GetTopPitch()*sin(fDigiPar->GetOrient()); b = fDigiPar->GetBotPitch()*sin(fDigiPar->GetOrient()+fDigiPar->GetSkew()); localDpos.SetY(sqrt((t*t+b*b)/12.)); localDpos.SetZ(0.); //x-z c.s local[2]=sqrt((t*t+b*b)/12.); //local[1]=sqrt((t*t+b*b)/12.);//x-z cs.0. //local[2]=0.; //hitErr.SetXYZ(local[0],local[1],0.); hitErr = fGeoH->LocalToMasterErrorsId(localDpos,detnametop.Data()); //gGeoManager->LocalToMaster(local,master); //hitErr.SetXYZ(master[0],master[1],master[2]); Int_t i = fHitArray->GetEntriesFast(); new((*fHitArray)[i])PndHypHit(detID,detnametop.Data(), hitPos,hitErr,*itTop,mycharge, oneclusterbot.size()+oneclustertop.size()); ((PndHypHit*)((*fHitArray)[i]))->SetBotIndex(*itBot); }else if (fVerbose > 2) std::cout<<"Strip charge contents too differently"< 1) std::cout << "ClusterArraySize: " << fClusterArray->GetEntriesFast() << " | HitArraySize: " << fHitArray->GetEntriesFast() << " Hits calculated." << " out of " <GetEntriesFast()<< " Digis"<