//-------------------------------------------------------------------------- // File and Version Information: // $Id:$ // // Description: // Class PndEmcMakeCorr // Do an energy and theta corrections // (at the moment for photons, 4.02.2010) // // Author List: // A. Biegun // M. Babai //------------------------------------------------------------------------ // //----------------------- // This Class's Header -- //----------------------- #include "PndEmcMakeCorr.h" #include "PndEmcCorrection.h" //------------------------------- // Collaborating Class Headers -- //------------------------------- #include "PndEmcStructure.h" #include "PndEmcDataTypes.h" #include "PndEmcMapper.h" #include "PndEmcDigiPar.h" #include "PndEmcRecoPar.h" #include "PndEmcDigi.h" #include "PndEmcCluster.h" #include "PndEmcBump.h" #include "FairRootManager.h" #include "FairRunAna.h" #include "FairRuntimeDb.h" //#include "TClonesArray.h" //#include "TObject.h" //#include "TH2.h" //#include "TVector3.h" #include #include using std::cout; using std::endl; //---------------- // Constructors -- //---------------- PndEmcMakeCorr::PndEmcMakeCorr(Int_t verbose, TString transportModel, TString clusterType): f(new TFile()), f0(new TFile()), f1(new TFile()), f2(new TFile()), f3(new TFile()), fClusterIndex(-1), fClusterArray(0), fClusterArrayCorr(0), fDigiPar(new PndEmcDigiPar()), fRecoPar(new PndEmcRecoPar()), fStoreClustersCorr(kTRUE), fModel(transportModel), fClusterType(clusterType), fVerbose(0) { cout<<"PndEmcMakeCorr constructor: "<Close(); f0->Close(); f1->Close(); f2->Close(); f3->Close(); delete f; delete f0; delete f1; delete f2; delete f3; } // ----- Public method Intialize --------------------------------------- InitStatus PndEmcMakeCorr::Init() { // Get RootManager FairRootManager* ioman = FairRootManager::Instance(); if ( ! ioman ){ cout << "-E- PndEmcMakeCorr::Init: " << "RootManager not instantiated!" << endl; return kFATAL; } // Get input array - Clusters fClusterArray = dynamic_cast (ioman->GetObject(fClusterType)); cout<<""< fClusterType is: ***** "<Register(corName,"Emc",fClusterArrayCorr,kTRUE); // Read 2-dim histograms with shifts: GetMean() // of reconstructed clusters compared to MC clusters cout<<"Used transportModel is " <GetName() << " is read"<Get(nameEn[i]); hTh[i] = (TH2F*) f->Get(nameTh[i]); // Shashlyk nameEn5[i] = "hisEnergy5Delta"; nameTh5[i] = "hisTheta5Diff"; hEn5[i] = (TH2F*) f->Get(nameEn5[i]); hTh5[i] = (TH2F*) f->Get(nameTh5[i]); //cout<<"hists: Target EMC "<GetName()<<"\t"<GetName()<GetName()<<"\t"<GetName()<GetXaxis()->FindBin(value_x); bin_y = lookup_table->GetYaxis()->FindBin(value_y); if ((bin_x < 1) || (bin_x > lookup_table->GetXaxis()->GetNbins())) { bin_x = -1; bin_y = -1; return -1; } if ((bin_y < 1) || (bin_y > lookup_table->GetYaxis()->GetNbins())) { bin_x = -1; bin_y = -1; return -2; } return 0; // Success } Double_t PndEmcMakeCorr::GetValueInZ(TH2 *lookup_table, Float_t value_x, Float_t value_y, Bool_t use_interpolation) { // We own the EmcLocMaxInfo objects. Delete from last time. // Clean-up res, We need an empty set to store the results. if (use_interpolation) { //cout<<"use_interpolation = kTRUE "< Error in FindTheBin, check your table and input values!!!!: " << retval << endl; return 0; } return (lookup_table->GetBinContent(binx,biny)); } return 0; } void PndEmcMakeCorr::Exec(Option_t* opt) { // Reset output array(s) if ( ! fClusterArrayCorr ) Fatal("Exec", "No Corrected Cluster Array"); fClusterArrayCorr->Delete(); // Variables for Energy & Theta Cluster's Corrections Bool_t use_interpolation=kTRUE; Double_t valzEn[4], valzTh[4], ThCorr[4], ThCorrRad[4], EnCorr[4]; Int_t ndigi; Int_t particle[5]; Int_t chosenModule =0; // Loop over Clusters to make the energy and theta correction // by dividing and adding the GetMean() values from lookup table Int_t clustLength = fClusterArray->GetEntriesFast(); //cout <<"clustLength " <At(iCluster); //cout<<"Cluster was taken from ---> "< "<energy()<At(iCluster); //cout<<"Cluster was taken from ---> "< "<energy()< digiMap=theCluster->MemberDigiMap(); std::map::iterator iter; ndigi=digiMap.size(); Int_t ID, module; std::map counting; std::map::iterator iCounting; Int_t oldCounting = 0; if(digiMap.size() != 0) { for(iter=digiMap.begin(); iter != digiMap.end(); ++iter) { ID = iter->first; module = ID/100000000; counting[module]++; } } // Get an EMC module in which most of the digits are for(iCounting=counting.begin(); iCounting!=counting.end(); iCounting++) { if((*iCounting).second > oldCounting) { chosenModule = (*iCounting).first; oldCounting = (*iCounting).second; } } Double_t energy=theCluster->energy(); TVector3 position=theCluster->where(); Double_t theta=position.Theta()*(180./TMath::Pi()); //cout << " "<GetRuntimeDb(); if ( ! db ) Fatal("SetParContainers", "No runtime database"); // Get Emc digitisation parameter container fDigiPar = (PndEmcDigiPar*) db->getContainer("PndEmcDigiPar"); // Get Emc reconstruction parameter container fRecoPar = (PndEmcRecoPar*) db->getContainer("PndEmcRecoPar"); } void PndEmcMakeCorr::SetStorageOfData(Bool_t val) { fStoreClustersCorr=val; return; } ClassImp(PndEmcMakeCorr)