// File: hthreseval.cc // // Author: Laura Fabbietti // Last update by Laura Fabbietti: 03/02/05 15:11:01 // using namespace std; #include "hthreseval.h" #include "hevent.h" #include "hruntimedb.h" #include "hrichhit.h" #include "hmdcseg.h" #include "hkicktrack.h" #include "hades.h" #include "hhitmatch.h" #include "hhitmatchsim.h" #include "hrichutilfunc.h" #include #include "TMath.h" #include "TString.h" #include "TF1.h" #include "hspectrometer.h" #include "hdetector.h" #include "hrichdetector.h" #include "richdef.h" #include "hiterator.h" #include "hrichgeometrypar.h" #include "hrichcal.h" #include "hrichanalysis.h" #include "hlocation.h" #include "hmatrixcategory.h" ClassImp(HThreseval); HThreseval::HThreseval(const Text_t *name,const Text_t *title,const Option_t *opt,const Option_t *opt1): HReconstructor(name,title) { isLepton = opt1; whichData =opt; maxPadCharge = 0.; pHistArray = new TObjArray(30); thetaDiffPM = new TH1F**[50]; thetaDiffHT = new TH1F**[50]; for (Int_t i =0; i< 50 ; i++){ thetaDiffPM[i] = new TH1F*[8]; thetaDiffHT[i] = new TH1F*[8]; } Int_t histoBin = 100; Float_t xMin = -45.; Float_t xMax = 45.; Char_t hname0[40]; Char_t hname1[40]; Char_t hname2[40]; Char_t hname3[40]; Char_t hname4[40]; Char_t hname5[40]; Char_t hname6[40]; Char_t hname7[40]; //cout<<"before loop "<Add(thetaDiffPM[i][0]); } for (Int_t i =0; i< 11; i++){ sprintf(hname0,"thetaDiffHT_0_GT_%d",i*10); sprintf(hname1,"thetaDiffHT_1_GT_%d",i*10); sprintf(hname2,"thetaDiffHT_3_GT_%d",i*10); sprintf(hname3,"thetaDiffHT_4_GT_%d",i*10); sprintf(hname4,"thetaDiffHT_5_GT_%d",i*10); sprintf(hname5,"thetaDiffHT_6_GT_%d",i*10); sprintf(hname6,"thetaDiffHT_7_GT_%d",i*10); sprintf(hname7,"thetaDiffHT_8_GT_%d",i*10); thetaDiffHT[i][0]=new TH1F(hname0,hname0,histoBin,xMin,xMax); thetaDiffHT[i][1]=new TH1F(hname1,hname1,histoBin,xMin,xMax); thetaDiffHT[i][2]=new TH1F(hname2,hname2,histoBin,xMin,xMax); thetaDiffHT[i][3]=new TH1F(hname3,hname3,histoBin,xMin,xMax); thetaDiffHT[i][4]=new TH1F(hname4,hname4,histoBin,xMin,xMax); thetaDiffHT[i][5]=new TH1F(hname5,hname5,histoBin,xMin,xMax); thetaDiffHT[i][6]=new TH1F(hname6,hname6,histoBin,xMin,xMax); thetaDiffHT[i][7]=new TH1F(hname7,hname7,histoBin,xMin,xMax); pHistArray->Add(thetaDiffHT[i][0]); } for (Int_t i =11; i< 50; i++){ sprintf(hname0,"thetaDiffHT_0_GT_%d",i*20); sprintf(hname1,"thetaDiffHT_1_GT_%d",i*20); sprintf(hname2,"thetaDiffHT_3_GT_%d",i*20); sprintf(hname3,"thetaDiffHT_4_GT_%d",i*20); sprintf(hname4,"thetaDiffHT_5_GT_%d",i*20); sprintf(hname5,"thetaDiffHT_6_GT_%d",i*20); sprintf(hname6,"thetaDiffHT_7_GT_%d",i*20); sprintf(hname7,"thetaDiffHT_8_GT_%d",i*20); thetaDiffHT[i][0]=new TH1F(hname0,hname0,histoBin,xMin,xMax); thetaDiffHT[i][1]=new TH1F(hname1,hname1,histoBin,xMin,xMax); thetaDiffHT[i][2]=new TH1F(hname2,hname2,histoBin,xMin,xMax); thetaDiffHT[i][3]=new TH1F(hname3,hname3,histoBin,xMin,xMax); thetaDiffHT[i][4]=new TH1F(hname4,hname4,histoBin,xMin,xMax); thetaDiffHT[i][5]=new TH1F(hname5,hname5,histoBin,xMin,xMax); thetaDiffHT[i][6]=new TH1F(hname6,hname6,histoBin,xMin,xMax); thetaDiffHT[i][7]=new TH1F(hname7,hname7,histoBin,xMin,xMax); pHistArray->Add(thetaDiffHT[i][0]); } effPM = new TH2F("effPM","effPM",500,0,1000,1000,0,120000); pHistArray->Add(effPM); effHT = new TH2F("effHT","effHT",500,0,1000,1000,0,120000); pHistArray->Add(effHT); // here come all the efficiency histogramms for the diffrent cuts effPM1 = new TH2F("effPMDens","effPMDens",500,0,1000,1000,0,120000); pHistArray->Add(effPM1); effHT1 = new TH2F("effHTDens","effHTDens",500,0,1000,1000,0,120000); pHistArray->Add(effHT1); effPM2 = new TH2F("effPMBoard","effPMDensBoard",500,0,1000,1000,0,120000); pHistArray->Add(effPM2); effHT2 = new TH2F("effHTBoard","effHTBoard",500,0,1000,1000,0,120000); pHistArray->Add(effHT2); effPM3 = new TH2F("effPMDyn","effPMDyn",500,0,1000,1000,0,120000); pHistArray->Add(effPM3); effHT3 = new TH2F("effHTDyn","effHTDyn",500,0,1000,1000,0,120000); pHistArray->Add(effHT3); effPM4 = new TH2F("effPMRatio","effPMRatio",500,0,1000,1000,0,120000); pHistArray->Add(effPM4); effHT4 = new TH2F("effHTRatio","effHTRatio",500,0,1000,1000,0,120000); pHistArray->Add(effHT4); effPM5 = new TH2F("effPMAssym","effPMAssym",500,0,1000,1000,0,120000); pHistArray->Add(effPM5); effHT5 = new TH2F("effHTAssym","effHTAssym",500,0,1000,1000,0,120000); pHistArray->Add(effHT5); effPM6 = new TH2F("effPMCharge","effPMCharge",500,0,1000,1000,0,120000); pHistArray->Add(effPM6); effHT6 = new TH2F("effHTCharge","effHTCharge",500,0,1000,1000,0,120000); pHistArray->Add(effHT6); effPM7 = new TH2F("effPMClose","effPMClose",500,0,1000,1000,0,120000); pHistArray->Add(effPM7); effHT7 = new TH2F("effHTClose","effHTClose",500,0,1000,1000,0,120000); pHistArray->Add(effHT7); hTestBorder =new TH2F("fracVSQual","fracVSQual",500,0,1000,100,0,1); hTestBorderCorr=new TH2F("fracVSQualCorr","fracVSQualCorr",500,0,1000,100,0,1); pHistArray->Add(hTestBorder); pHistArray->Add(hTestBorderCorr); hTestRatio =new TH1F("inOutDivAll","inOutDivAll",100,0,1); hTestRatioCorr =new TH1F("inOutDivAllCorr","inOutDivAllCorr",100,0,1); pHistArray->Add(hTestRatio); pHistArray->Add(hTestRatioCorr); hTestRadius = new TH1F("radius","radius",20,0,10); hTestRadiusCorr = new TH1F("radiusCorr","radiusCorr",20,0,10); pHistArray->Add(hTestRadius); pHistArray->Add(hTestRadiusCorr); hTestCentroid = new TH1F("centroid","centroid",50,0,10); hTestCentroidCorr = new TH1F("centroidCorr","centroidCorr",50,0,10); pHistArray->Add(hTestCentroid); pHistArray->Add(hTestCentroidCorr); hTestCharge = new TH1F("charge","charge",200,0,200); hTestChargeCorr = new TH1F("chargeCorr","chargeCorr",200,0,200); pHistArray->Add(hTestCharge); pHistArray->Add(hTestChargeCorr); hTestClose =new TH2F("dQVScentroid","dQVScentroid",50,0,10,50,0,1); hTestCloseCorr =new TH2F("dQVScentroidCorr","dQVScentroidCorr",50,0,10,50,0,1); pHistArray->Add(hTestClose); pHistArray->Add(hTestCloseCorr); pMhT = new TH2F("pMhT","pMhT",500,0,1000,500,0,1000); pHistArray->Add(pMhT); isLepton.ToLower(); whichData.ToLower(); TString s ="simul"; TString l ="lepton"; TString l1 ="fake"; if(whichData.CompareTo(s)==0){ if(isLepton.CompareTo(l)==0){ out = new TFile("thresholdLepSim.root","recreate"); } else if(isLepton.CompareTo(l1)==0){ out = new TFile("thresholdFakeSim.root","recreate"); } else{ out = new TFile("thresholdSim.root","recreate"); } } else{ out = new TFile("thresholdExp.root","recreate"); } allRingPar = new TNtuple("allRingPar","allRingPar","padNr:pmQual:avCharge:radius:centroid:dThetaMdc:dPhiMdc:localMax:deltaQual:fracInSec:totalCharge:maxCharge"); ; corrRingPar= new TNtuple("corrRingPar","corrRingPar","padNr:pmQual:avCharge:radius:centroid:dThetaMdc:dPhiMdc:localMax:deltaQual:fracInSec:totalCharge:maxCharge");; } HThreseval::HThreseval(){ } HThreseval::~HThreseval(){ delete out; for (Int_t i =0; i< 50; i++){ for (Int_t j =0; j< 8; j++){ delete thetaDiffPM[i][j]; delete thetaDiffHT[i][j]; } } for (Int_t i =0; i< 8; i++){ delete thetaDiffPM[i]; delete thetaDiffHT[i]; } delete thetaDiffPM; delete thetaDiffHT; delete effPM; delete effHT; } Bool_t HThreseval::init(){ TString s ="simul"; if (gHades) { HEvent *event=gHades->getCurrentEvent(); HRuntimeDb *rtdb=gHades->getRuntimeDb(); HSpectrometer *spec=gHades->getSetup(); HDetector *rich = spec->getDetector("Rich"); if (event && rtdb) { // Setup output category if(whichData.CompareTo(s)==0){ pRichCalCat=event->getCategory(catRichCal); if (!pRichCalCat) { pRichCalCat=rich->buildCategory(catRichCal); if (!pRichCalCat) return kFALSE; else gHades->getCurrentEvent() ->addCategory(catRichCal, pRichCalCat, "Rich"); } pIterRichCal = (HIterator*)pRichCalCat->MakeIterator("native"); //cout<<" cal category "<< pRichCalCat<getCategory(catRichHit); if (!pRichHitCat) { pRichHitCat=rich->buildCategory(catRichHit); if (!pRichHitCat) return kFALSE; else gHades->getCurrentEvent() ->addCategory(catRichHit, pRichHitCat, "Rich"); } pIterRichHit1 = (HIterator*)pRichHitCat->MakeIterator("native"); pIterRichHit2 = (HIterator*)pRichHitCat->MakeIterator("native"); } pHitMatchCat=event->getCategory(catMatchHit); if (!pHitMatchCat) { pHitMatchCat=rich->buildCategory(catMatchHit); if (!pHitMatchCat) { Error("init","No HIT MATCH category defined"); return kFALSE; } else event->addCategory(catMatchHit, pHitMatchCat, "Rich"); } pIterMatchHit = (HIterator*)getHitMatchCat()->MakeIterator("native"); pIterMatchHit1 = (HIterator*)getHitMatchCat()->MakeIterator("native"); HRichGeometryPar *pGeomPar = (HRichGeometryPar*)rtdb-> getContainer("RichGeometryParameters"); setGeomPar(pGeomPar); if (pGeomPar == NULL) return kFALSE; HRichAnalysisPar *pAnalysisPar = (HRichAnalysisPar*)rtdb-> getContainer("RichAnalysisParameters"); setAnalysisPar(pAnalysisPar); if (pAnalysisPar == NULL) return kFALSE; } } return kTRUE; } Bool_t HThreseval::reinit() { Int_t maxRows = 96; Int_t maxCols = 96; iPadActive.Set(maxCols*maxRows); for (Int_t i=0 ; igetPadsPar()->getPad(i)->getPadActive() >0) iPadActive[i] = 1; else iPadActive[i] = 0; Int_t iMatrixSurface=0, iPartSurface=0; Int_t iMaskSize = ((HRichAnalysisPar*)fpAnalysisPar)->iRingMaskSize; Int_t iMaskSizeSquared = iMaskSize*iMaskSize; Int_t k,j,i,m,n; HRichAnalysis ana; for (k = 0; k < iMaskSizeSquared; k++) if (((HRichAnalysisPar*)fpAnalysisPar)->iRingMask[k] == 1) iMatrixSurface++; for (j = 0; j < maxRows; j++) for (i = 0; i < maxCols; i++) { iPartSurface = 0; for (k = 0; k < iMaskSizeSquared; k++) { m = (k % iMaskSize) - iMaskSize/2; n = (k / iMaskSize) - iMaskSize/2; if (!IsOut(i,j,m,n)) if (((HRichAnalysisPar*)fpAnalysisPar)->iRingMask[k] == 1) iPartSurface++; } ((HRichGeometryPar*)fpGeomPar)->getPadsPar()-> getPad(i,j)->setAmplitFraction((Float_t)iPartSurface/(Float_t)iMatrixSurface); } return kTRUE; } Int_t HThreseval::IsOut(Int_t x, Int_t y, Int_t dx, Int_t dy) { if ((x+dx) >= 0 && (x+dx) < 96 && (y+dy) >= 0 && (y+dy) < 96 && (x+dx + 96*(y+dy)) <96*96 && (x+dx + 96*(y+dy))>0){ if(iPadActive[x+dx + 96*(y+dy)]) { return 0; } else { return 1; } } else return 1; } Int_t HThreseval::execute(){ // cout<<" new event "<Reset(); HHitMatchSim * pMatch = NULL; HHitMatchSim * pMatch1 = NULL; Float_t ringPM = 0; Float_t ringHT = 0; Float_t dThetaRM = 0; Float_t dPhiRM = 0; Float_t dPhiRM1 = 0; TString s = "0"; for(Int_t j =0;j<100;j++){ richIndArray[j] = 0; } countHitMatchObj = 0; HRichHit *pHit = NULL; TString l ="lepton"; TString l1 ="fake"; TString l2 =""; while((pMatch= (HHitMatchSim *)pIterMatchHit->Next())){ dPhiRM = (pMatch->getRichPhi() - pMatch->getMdcPhi())* TMath::Sin(pMatch->getMdcTheta()/57.3); pIterMatchHit1->Reset(); while((pMatch1= (HHitMatchSim *)pIterMatchHit1->Next())){ dPhiRM1 = (pMatch1->getRichPhi() - pMatch1->getMdcPhi())* TMath::Sin(pMatch1->getMdcTheta()/57.3); // cout<<" rich ind 1 : "<getRichInd()<<" rich ind 2 : "<< // pMatch1->getRichInd()<<" dPhi 1 : "<getRichInd()==pMatch1->getRichInd()) && (TMath::Abs(dPhiRM))<(TMath::Abs(dPhiRM1))) { pMatch1 ->setMatchedRichMdc(0); // break; } } } pIterMatchHit->Reset(); while((pMatch= (HHitMatchSim *)pIterMatchHit->Next())){ if(pMatch->getMatchedRichMdc()&& !isRingInArray(pMatch)){ if((isLepton.CompareTo(l)==0 && (pMatch->getNumPhot1()>0) && (pMatch->getGLepInMDC()>0) && (pMatch->isGCLepRing()>0)) || // a lepton is selected if the number of photons on the mirror // is greater than 0 and if the lepton has reached the mdc. // The first condition is satisfied if the ring candidate // passes the tests done in the function // HRichCorrelatorSim::isLepOnMirror(HHitMatchSim *h) // Additionally the geant track number of the ring // must be matched with at least another subdetector // hgeant track number(flag isGCLepRing in HHitMatchSim). (isLepton.CompareTo(l1)==0 && (pMatch->getNumPhot1()<0)) || // A fake is selected if the ring doesnt match any lepton // contained in the HGeantRichMirror container. // The conditions that must be satisfied for the matching // are set in the function // HRichCorrelatorSim::isLepOnMirror(HHitMatchSim *h). (isLepton.CompareTo(l2)==0)){ // cout<<" countHitMatchObj "<getNumPhot()<getRichInd(); countHitMatchObj++; // cout<<" ring index "<getRichInd()<getRingPatMat(); ringHT = pMatch->getRingHouTra(); dThetaRM = pMatch->getRichTheta() - pMatch->getMdcTheta(); dPhiRM = (pMatch->getRichPhi() - pMatch->getMdcPhi())* TMath::Sin(pMatch->getMdcTheta()/57.3); // cout<<" dPhiRM "<Fill(ringPM,ringHT,1); //filling the dTheta dPhi histos for rings correlated // in phi with a kicktrack and fullfilling the tests conditions. s = "0"; Int_t iTest = pMatch->getRingTestFlags(); // cout<<" intial value "<getRingTestFlags()< getObject(pMatch->getRichInd()); pHit->setLabXYZ(5,dThetaRM,dPhiRM); } else{ //for the experimental data only the entuple is filled corrRingPar->Fill(pMatch->getRingPadNr(),pMatch->getRingPatMat(),pMatch->getRingAmplitude()/pMatch->getRingPadNr(),pMatch->getRadius(),pMatch->getCentroid(),dThetaRM,dPhiRM,pMatch->getRingLocalMax4(),pMatch->getRichTheta(),pMatch->getRichPhi(),pMatch->getRingAmplitude(),maxPadCharge); } } } } if(whichData.CompareTo("simul")==0){ pIterRichHit1->Reset(); HRichHit * pHit2= NULL; Float_t qual= 0; Float_t deltaQual =0; Float_t ratio = 0; Float_t flagCorr,dP,dT; flagCorr = dP = dT = 0; Float_t frac = 0; //if the option "lepton" is selected in while((pHit2= (HRichHit *)pIterRichHit1->Next())){ // if((isLepton.CompareTo(l)==0 && pIterMatchHit->isLepRing())|| // (isLepton.CompareTo(l1)==0 && !pIterMatchHit->isLepRing())|| // (isLepton.CompareTo(l2)==0)){ //cout<<" new hrichhit "<getRingPatMat(); //cout<<" qual "<Fill(qual,frac); ratio = testRatio(pHit2); hTestRatio->Fill(ratio); hTestRadius->Fill(pHit2->getRadius()); hTestCentroid->Fill(pHit2->getCentroid()); hTestCharge->Fill(pHit2->getRingAmplitude()/pHit2->getRingPadNr()); testCloseRej(pHit2,deltaQual); hTestClose->Fill(pHit2->getCentroid(),deltaQual); allRingPar->Fill(pHit2->getRingPadNr(),qual,pHit2->getRingAmplitude()/pHit2->getRingPadNr(),pHit2->getRadius(),pHit2->getCentroid(),0,0,pHit2->getRingLocalMax4(),deltaQual,frac,pHit2->getRingAmplitude(),maxPadCharge); pHit2->getLabXYZ(&flagCorr,&dT,&dP); //cout<<" ring flag "<4.99&&flagCorr<5.01){ corrRingPar->Fill(pHit2->getRingPadNr(),qual,pHit2->getRingAmplitude()/pHit2->getRingPadNr(),pHit2->getRadius(),pHit2->getCentroid(),dT,dP,pHit2->getRingLocalMax4(),deltaQual,frac,pHit2->getRingAmplitude(),maxPadCharge); // cout<<" correlated ring "<Fill(qual,frac); hTestRatioCorr->Fill(ratio); hTestRadiusCorr->Fill(pHit2->getRadius()); hTestCentroidCorr->Fill(pHit2->getCentroid()); hTestChargeCorr->Fill(pHit2->getRingAmplitude()/pHit2->getRingPadNr()); hTestCloseCorr->Fill(pHit2->getCentroid(),deltaQual); } // } } } return 0; } Bool_t HThreseval::isTestDensityTrue(TString st){ Int_t iLength = st.Length(); //cout<<" length "<< iLength<0){ //cout<<" Dense values "<1){ //cout<<" Board value "<2){ //cout<<" Dynamic value "<3){ //cout<<" Ratio value "<4){ //cout<<" Assymetry value "<5){ //cout<<" Charge value "<6){ //cout<<" Close value "<getRichInd() "<getRichInd()<getRichInd()==richIndArray[j]) return kTRUE; } return kFALSE; } Float_t HThreseval::testBorder(HRichHit *pHit){ // cout<<" X "<getRingCenterX()<<" Y "<getRingCenterY()<getPadsPar()-> getPad(pHit->getRingCenterX(),pHit->getRingCenterY())->getAmplitFraction(); // cout<<" fraction "<getRingPadNr()<iRingX<<" center Y "<iRingY<getSector(); HRichCal *cal = NULL; HRichAnalysis ana; HLocation locat; Int_t k,m,n; Int_t iMatrixSurface; Float_t iOutRing = 0., iOnRing = 0., iInRing = 0., iAllRing = 0.; maxPadCharge = 0; Float_t chargeMax = 0; Float_t chargeTemp = 0; iMatrixSurface = getAnalysisParams()->iRingMaskSize * getAnalysisParams()->iRingMaskSize; for (k = 0; k < iMatrixSurface; k++) { m = (k % getAnalysisParams()->iRingMaskSize) - getAnalysisParams()->iRingMaskSize/2; n = (k / getAnalysisParams()->iRingMaskSize) - getAnalysisParams()->iRingMaskSize/2; //cout<<" col "<iRingX+m<<" row "<iRingY+n<iRingY +n, pHit->iRingX +m); //cout<<" cal category "<<(HMatrixCategory*)getRichCalCat()<getObject(locat)); //cout<<" cal object "<getCharge() "<getCharge()<getCharge(); if(chargeMaxiRingX+m <<" y+dy "<< pHit->iRingY + n<<" iPadActive[x+dx + 92*(y+dy) "<iRingX+m + 96*(pHit->iRingY + n)]<iRingX,pHit->iRingY,m,n) && cal->getCharge() > 0){ //cout<<" in the loop "<iRingMask[k] == 0) iOutRing++; else if (getAnalysisParams()->iRingMask[k] == 1) iOnRing++; else if (getAnalysisParams()->iRingMask[k] == 2) iInRing++; } } } maxPadCharge = chargeMax; iAllRing = iOutRing + iOnRing + iInRing; // cout<<" ALl "<Reset(); Float_t dQTemp = 0; Float_t dQ = 0; while((pHit2= (HRichHit *)pIterRichHit2->Next())){ Int_t dx = pHit1->getRingCenterX() - pHit2->getRingCenterX(); Int_t dy = pHit1->getRingCenterY()- pHit2->getRingCenterY(); Float_t distSquared=dx*dx+dy*dy; //cout<<" distSquared "<iRingPatMat<<" qual2 "<iRingPatMat<getAddress()!=pHit2->getAddress()) { if (pHit1->iRingPatMat+pHit2->iRingPatMat==0) Error("HRichRingFind::CloseMaxRejection","possible division by zero"); // cout<<" division "<< pHit2->iRingPatMat+pHit1->iRingPatMat<iRingPatMat-pHit1->iRingPatMat) /(Float_t)(pHit2->iRingPatMat+pHit1->iRingPatMat); //cout <<" dQ "<dQ){ dQ = dQTemp; } else{ dQTemp = dQ; } } } dq= TMath::Abs(dQ); } void HThreseval::fillHistoPM(Float_t pm,Float_t dt,Int_t histoInd){ Int_t x1,y1; x1 = y1 =0; if(pm<1000){ x1 = TMath::Nint(pm/20.); //cout<<"Integer 1) rings "<< x1 <Fill(dt); } } } void HThreseval::fillHistoHt(Float_t ht,Float_t dt,Int_t histoInd){ Int_t x1,y1; x1 = y1 =0; if(ht<101){ x1 = TMath::Nint(ht/10.); // cout<<"Integer 1) rings "<< x1 <Fill(dt); } } else if(ht<1200){ x1 = TMath::Nint(ht/20.); // cout<<"Integer 2) fakes"<< x1 <Fill(dt); } } } Float_t HThreseval::fitAndSubtractBG(TH1F* histo){ Float_t back1LowLim = -40.; Float_t back1UpLim = -10.; TF1 *f1 = new TF1("f1","gaus",back1LowLim,back1UpLim); Double_t par[18]; histo->Fit("f1","R0"); f1->GetParameters(&par[0]); Float_t xMin = -45.; TF1 *f5 = new TF1("f5","gaus",xMin,0); par[9] = par[0]; par[10] = par[1]; par[11] = par[2]; f5->SetParameter(0,par[9]); f5->SetParameter(1,par[10]); f5->SetParameter(2,par[11]); f5->SetLineColor(4); Float_t xMax = 45.; TF1 *f10 = new TF1("f10","gaus",0,xMax); par[6] = par[0]; par[7] = -par[1]; par[8] = par[2]; f10->SetParameter(0,par[6]); f10->SetParameter(1,par[7]); f10->SetParameter(2,par[8]); f10->SetLineColor(2);//RED f10->Draw("same"); Double_t diff = 0; TH1F *htemp = (TH1F*)histo->Clone(); htemp->Reset(); for (Int_t bin=1;bin<=histo->GetNbinsX();bin++) { Float_t x = histo->GetBinCenter(bin); Double_t fval = f5->Eval(x);Double_t fval2 = f10->Eval(x); if(x<=0) diff = (histo->GetBinContent(bin) - fval); else diff = (histo->GetBinContent(bin) - fval2); if(diff<0) diff =0; htemp->Fill(x,diff); } htemp->SetLineColor(4); pHistArray->Add(htemp); return htemp->Integral(42,53); } Bool_t HThreseval::finalize(){ out->cd(); allRingPar->Write(); corrRingPar->Write(); for(Int_t j = 0;j<50;j++) { effPM->Fill(j*20,fitAndSubtractBG(thetaDiffPM[j][0])); effPM1->Fill(j*20,fitAndSubtractBG(thetaDiffPM[j][1])); effPM2->Fill(j*20,fitAndSubtractBG(thetaDiffPM[j][2])); effPM3->Fill(j*20,fitAndSubtractBG(thetaDiffPM[j][3])); effPM4->Fill(j*20,fitAndSubtractBG(thetaDiffPM[j][4])); effPM5->Fill(j*20,fitAndSubtractBG(thetaDiffPM[j][5])); effPM6->Fill(j*20,fitAndSubtractBG(thetaDiffPM[j][6])); effPM7->Fill(j*20,fitAndSubtractBG(thetaDiffPM[j][7])); if(j<11) { effHT->Fill(j*10,fitAndSubtractBG(thetaDiffHT[j][0])); effHT1->Fill(j*10,fitAndSubtractBG(thetaDiffHT[j][1])); effHT2->Fill(j*10,fitAndSubtractBG(thetaDiffHT[j][2])); effHT3->Fill(j*10,fitAndSubtractBG(thetaDiffHT[j][3])); effHT4->Fill(j*10,fitAndSubtractBG(thetaDiffHT[j][4])); effHT5->Fill(j*10,fitAndSubtractBG(thetaDiffHT[j][5])); effHT6->Fill(j*10,fitAndSubtractBG(thetaDiffHT[j][6])); effHT7->Fill(j*10,fitAndSubtractBG(thetaDiffHT[j][7])); } else { effHT->Fill(j*20,fitAndSubtractBG(thetaDiffHT[j][0])); effHT1->Fill(j*20,fitAndSubtractBG(thetaDiffHT[j][1])); effHT2->Fill(j*20,fitAndSubtractBG(thetaDiffHT[j][2])); effHT3->Fill(j*20,fitAndSubtractBG(thetaDiffHT[j][3])); effHT4->Fill(j*20,fitAndSubtractBG(thetaDiffHT[j][4])); effHT5->Fill(j*20,fitAndSubtractBG(thetaDiffHT[j][5])); effHT6->Fill(j*20,fitAndSubtractBG(thetaDiffHT[j][6])); effHT7->Fill(j*20,fitAndSubtractBG(thetaDiffHT[j][7])); } } HRichUtilFunc::saveHistos(out,pHistArray); out->Close(); return kTRUE; }