コード例 #1
0
ファイル: CtauErrModel.C プロジェクト: knuenz/ChicPol
void Plot2DHisto(TH2D* plothist, char xTitle[200], char yTitle[200], char savename[200], char tex[200]) {

    TGaxis::SetMaxDigits(3);

    TCanvas *c1 = new TCanvas("", "", 1200, 1000);
    gStyle->SetPalette(1);
    gStyle->SetOptStat(0);
    gPad->SetFillColor(kWhite);
    gPad->SetLeftMargin(0.15);
    gPad->SetRightMargin(0.2);
    gPad->SetTopMargin(0.1);

    double yOffset=1.4;
    plothist->GetYaxis()->SetTitleOffset(yOffset);
    plothist->SetStats(0);
    plothist->SetTitle(0);
    plothist->GetYaxis()->SetTitle(yTitle);
    plothist->GetXaxis()->SetTitle(xTitle);
    plothist->SetMinimum(0.);

    plothist->Draw("colz");

    double left=0.25, top=0.935, textSize=0.04;
    TLatex *latex=new TLatex();
    latex->SetTextFont(42);
    latex->SetNDC(kTRUE);
    latex->SetTextSize(textSize);
    latex->DrawLatex(left,top,tex);



    char linlog_savename[200];
    c1->SetLogz(false);
    sprintf(linlog_savename,"%s_lin.pdf",savename);
    c1->SaveAs(linlog_savename);
    c1->SetLogz(true);
    sprintf(linlog_savename,"%s_log.pdf",savename);
    c1->SaveAs(linlog_savename);

    TProfile* profileX = plothist->ProfileX("", 1, -1, "so");
    TProfile* profileY = plothist->ProfileY("", 1, -1, "so");

    profileX->Draw("same");

    sprintf(linlog_savename,"%s_log_AddProfile.pdf",savename);
    c1->SaveAs(linlog_savename);

    profileX->Draw();
    latex->DrawLatex(left,top,tex);
    sprintf(linlog_savename,"%s_log_ProfileX.pdf",savename);
    c1->SaveAs(linlog_savename);
    profileY->Draw();
    latex->DrawLatex(left,top,tex);
    sprintf(linlog_savename,"%s_log_ProfileY.pdf",savename);
    c1->SaveAs(linlog_savename);

    delete c1;
    delete latex;

}
コード例 #2
0
ファイル: rotateN.C プロジェクト: tking53/root-macros
void rotate2DN(const char* filename,int detNum){


  TFile *f = new TFile(filename);

  TCanvas* cnew= new TCanvas("cnew","",800.,500.);
  cnew->cd();
   

  stringstream sss;
  sss<<"Transposed-"<<filename;
  TFile f1(sss.str().c_str(),"RECREATE");

  for (int i=0;i<detNum;i++){
    stringstream orig ;
    orig<<"hNc"<<i ;
    TH2D* h1=(TH2D*)f->Get(orig.str().c_str());
    
    string gname = h1->GetTitle();
    stringstream hname ;
    hname<<"hN"<<i;
    TH2D* Hnew = new TH2D(hname.str().c_str(),gname.c_str(),1700.,0.,1700.,8000.,0.,8000.);
    for (int x=0;x<8000;x++){
      for (int y=0;y<1600;y++){
 	int bin = h1->GetBinContent(x,y);
	Hnew->Fill(y,x,bin);
      }
    }
    cout<<"Histogram Number "<<i<<" transpose completed"<<endl; 
    cnew->cd();
    
    Hnew->SetMinimum(7);
    Hnew->GetYaxis()->SetRangeUser(1300,1600);
    Hnew->GetYaxis()->SetTitle("Energy (keV)");
    Hnew->GetXaxis()->SetTitle("Cycle Number");
    Hnew->Draw("COLZ");

    TCutG *cutg = new TCutG("NaIcut1",5);
    cutg->SetVarX("y");
    cutg->SetVarY("x");
    cutg->SetPoint(0,0,1350);
    cutg->SetPoint(1,1500,1350);
    cutg->SetPoint(2,1500,1500);
    cutg->SetPoint(3,0,1500);
    cutg->SetPoint(4,0,1350);
     
    TProfile *profx = Hnew->ProfileX(Form("profx_%d",i),1,-1,"[NaIcut1]");

    profx->SetLineColor(kRed);   
    profx->Draw("same");
    cnew->Update();

    gname = gname + ".pdf";
    cnew->SaveAs(gname.c_str());

  }
    f1.Write();
 
}
コード例 #3
0
void explore_zmass_boost()
{
  // Tell root not to draw everything to the screen.
  gROOT->SetBatch();

  //    TString dyfilename         = TString("/home/acarnes/h2mumu/samples/stage1/monte_carlo/bg/stage_1_dy_jetsToLL_asympt50_ALL.root");
  TString dyfilename         = TString("/home/acarnes/h2mumu/samples/stage1/monte_carlo/bg/stage_1_dy_ZToMuMu_asympt50_ALL.root");
  TString datafilename         = TString("/home/acarnes/h2mumu/samples/stage1/data_from_json/Cert_246908-251883_13TeV_PromptReco_Collisions15_JSON_v2/stage_1_doubleMuon_RunBPrompt_MINIAOD.root");

  TString savedir = TString("../png/dy_vs_data/run1cuts_v2_golden_json/dyzmumu/");

  // Initialize the DiMuPlottingSystems for MC and data
  DiMuPlottingSystem* dpsdata = new DiMuPlottingSystem(datafilename);
  DiMuPlottingSystem* dpsdy = new DiMuPlottingSystem(dyfilename);
  addDiMuMassPrimeBranch(dpsdata);
  dpsdata->applyRun1Cuts();
  dpsdy->applyRun1Cuts();

  // Get the 2D histos
  TH2F* hdataZPt = ZMassVsZPtHist2D("data_zpt", "recoCandMassPrime", "(14,0,60,30,87,95)", dpsdata);
  TH2F* hdyZPt = ZMassVsZPtHist2D("dy_zpt", "recoCandMass", "(14,0,60,30,87,95)", dpsdy);

  //overlayTProfiles(TH2F* hdata, TH2F* hdy, TString bininfo, TString savename)
  TProfile* p = overlayTProfiles(hdataZPt, hdyZPt, 90, 92, savedir+"z_mass_vs_z_pt.png");
  gStyle->SetOptFit(0011);
  fitTProfileCustom(p);
  TCanvas* c = new TCanvas();
  c->cd();
  p->Draw("hist c");
  p->Draw("E0 X0 same");
  dpsdata->arrangeStatBox(c);
  c->Draw();
  c->Print("blah2.png");

  // Look at RMS
  c->Clear();
  c->cd();
  c->SetGridx(kTRUE);
  c->SetGridy(kTRUE);
  c->cd();
  TH1F* h = dpsdata->hist1D("recoCandMass", "(100,87,95)", "");
  TH1F* h2 = dpsdata->hist1D("recoCandMassPrime", "(100,87,95)", "");
  h2->SetLineColor(2);
  h->Draw("");
  h2->Draw("same");

  std::cout << "mass  rms: " << h->GetRMS() << std::endl;
  std::cout << "mass' rms: " << h2->GetRMS() << std::endl;
  std::cout << "mass  mean: " << h->GetMean() << std::endl;
  std::cout << "mass' mean: " << h2->GetMean() << std::endl;
  std::cout << "mass  num: " << h->Integral() << std::endl;
  std::cout << "mass' num: " << h2->Integral() << std::endl;

  DiMuPlottingSystem* dps = new DiMuPlottingSystem();
  dps->arrangeStatBox(c);
  c->Draw();
  c->Print("newfit.png");
}
コード例 #4
0
TProfile* getPlot(TProfile *h1, char *var, TCut cut, char *filename, char* treeName)
{
  TFile *inf = new TFile(filename);
  TTree *t = (TTree*)inf->FindObjectAny(treeName);
  TProfile * tmp = (TProfile*)h1->Clone();
  tmp->SetName("tmp");
  t->Draw(Form("%s>>tmp",var),cut);  
  return tmp;
}
コード例 #5
0
ファイル: classSimulation.C プロジェクト: sethhirsh/Mu2e
 void ElectronSimulation::plotTProfile(TTree* treeData )
 {
     TProfile* hprof = new TProfile("hprof", "hprof", 7, -0.5, 9.5);
   
     for (int i = 0; i < 7; ++i)
     { 
         char chargeValueString[100];
         snprintf(chargeValueString,100,"qChargeValues[%i]:%i",i,i);
         treeData->Project("+hprof",chargeValueString);
     }
     hprof->Draw();
 }
コード例 #6
0
ファイル: profile.C プロジェクト: Zepeng/od_badch
void profile()
{
  TCanvas* c1 = new TCanvas("canvas","nhitac",1200,600);
  c1->Divide(2,1);
  c1->cd(1);
  TFile *file1 = new TFile("test_nhitac_modified.root");
  //TH1F  *histo1 = new TH1F("nhitac1","nhitac1",60,0,300);
  TProfile *profile1 = new TProfile("profile","nhitac profile",100,0,100,0,300);

  TFile *file2 = new TFile("test_nhitac_unmodified.root");
  //TH1F  *histo2 = new TH1F("nhitac","nhitac",60,0,300);
  TProfile *profile2 = new TProfile("profile2","nhitac profile2",100,0,100,0,300);
  TProfile *ratio = new TProfile("ratio","nhitac ratio", 100,0,100,0,2);
  //histo2->SetMarkerStyle(31);
  TLegend *l1 = new TLegend(0.20, 0.60, 0.3, 0.7);
  l1->SetBorderSize(0);

  TTree* nhitac_modified = (TTree*)file1->Get("testnhitac");
  TTree* nhitac_unmodified = (TTree*)file2->Get("testnhitac");
  int testnhitac1, testnhitac2;
  nhitac_modified->SetBranchAddress("nhitac",&testnhitac1);
  nhitac_unmodified->SetBranchAddress("nhitac",&testnhitac2);
  for(int i= 0; i < nhitac_modified->GetEntries(); i++)
  {
    nhitac_modified->GetEntry(i);
    nhitac_unmodified->GetEntry(i);
    profile1->Fill(i,testnhitac1);
    profile2->Fill(i,testnhitac2);
    double temp = testnhitac2;
    ratio->Fill(i,testnhitac1/temp);
    //histo1->Fill(testnhitac1);
    //histo2->Fill(testnhitac2);
  }
  //histo1->SetMarkerColor(kRed);
  //histo1->SetLineColor(kRed);
  profile1->SetMarkerColor(kRed);
  profile1->SetMarkerStyle(5);
  profile2->SetMarkerColor(kBlue);
  l1->AddEntry(profile1,"modified od bad channel","P");
  l1->AddEntry(profile2,"old od bad channel","l");
  l1->SetTextSize(0.04);
  profile1->Draw("e1p");
  profile1->GetXaxis()->SetTitle("event #");
  profile1->GetYaxis()->SetTitle("nhitac");
  profile2->Draw("same");
  l1->Draw();
  c1->cd(2);
  ratio->GetXaxis()->SetTitle("event #");
  ratio->GetYaxis()->SetTitle("new/old");
  //ratio->SetMarkerStyle(5);
  //ratio->SetMarkerColor(kRed);
  ratio->Draw();
}
コード例 #7
0
ファイル: MillePedeTrees.C プロジェクト: ANSH0712/cmssw
TProfile *MillePedeTrees::CreateHistProf(const char *expX, const char *expY, const char *selection,
                                         const char *hDef, Option_t* opt)
{

  const TString combExpr(Form("%s:%s", expY, expX));
  TH1 *h = this->Draw(combExpr, selection, hDef, "goff prof");

  TProfile *hResult = static_cast<TProfile*>(h->Clone(Form("%sClone", h->GetName())));
  if (opt) hResult->SetOption(opt);

  return hResult;
}
コード例 #8
0
// Report cut flow findings to screen
void DileptonAnalyzer::reportCutFlow( TFile & outputFile ) {

  // Store in a TProfile
  TProfile *cutFlow = new TProfile("cutFlow","Cut flow for final set of analysis cuts",20,0.5,20.5,-9.9e9,9.9e9);
  TAxis *cutFlowAxis = cutFlow->GetXaxis();

  for ( unsigned int iCut = 0; iCut < cutNamesInOrder_.size(); iCut++ ) {
    cutFlow->Fill( iCut+1, cutFlowMap_[cutNamesInOrder_[iCut]]);
    cutFlowAxis->SetBinLabel( iCut+1, cutNamesInOrder_[iCut]);
  }

  outputFile.cd();
  cutFlow->Write();
}
コード例 #9
0
ファイル: drawPtEta.C プロジェクト: yenjie/usercode
void drawPtEta(char *inf){
TFile a(inf);
a.cd("ana");
TProfile *h = new TProfile("h","",100,-3,3);
TCanvas *c = new TCanvas("c","",400,400);
hi->Draw("(pt):eta>>h","evtType!=92&&evtType!=93&&(abs(eta)<2.4&&chg!=0&&abs(pdg)!=11&&abs(pdg)!=13)","prof",10000);
double nevt = hi->GetEntries("evtType!=92&&evtType!=93");
h->Sumw2();
//h->Scale(2./nevt);
h->SetXTitle("#eta");
h->SetYTitle("Average P_{T}");
h->Draw();
c->SaveAs(Form("%s-PtEta-2.4.gif",inf));
c->SaveAs(Form("%s-PtEta-2.4.C",inf));
}
コード例 #10
0
ファイル: KVCanvas.cpp プロジェクト: GiuseppePast/kaliveda
void KVCanvas::ProfileY(TH2* hh)
{
   TObject* obj = 0;
   if ((obj = gROOT->FindObject(Form("%s_pfy", hh->GetName())))) obj->Delete();
   TProfile* pfy = hh->ProfileY("_pfy", 1, -1, "i");
   TGraphErrors* gr = gHistoManipulator->MakeGraphFrom(pfy);
   pfy->Delete();
   TGraph* gg = gHistoManipulator->PermuteAxis(gr);
   gr->Delete();
   gg->SetName(Form("%s_pfy", hh->GetName()));
   gg->SetLineColor(kBlack);
   gg->Draw("PEZ");
   Modified();
   Update();
}
コード例 #11
0
ファイル: HistoXML.cpp プロジェクト: atlas-org/gaudi
// ============================================================================
StatusCode Gaudi::Utils::Histos::fromXml
( TProfile& result , const std::string& input )
{
  //
  result.Reset() ;                                 // RESET old histogram
  //
  _Xml<TProfile> _xml ;
  std::auto_ptr<TProfile> histo = _xml ( input ) ;
  if ( 0 == histo.get() ) { return StatusCode::FAILURE ; }        // RETURN
  //
  result.Reset() ;
  histo->Copy ( result ) ;
  //
  return StatusCode::SUCCESS ;
}
コード例 #12
0
ファイル: macros.C プロジェクト: cerminar/UserCode
void plotAndProfileX (TH2* h2, float min, float max, bool profile) {
  setStyle(h2);
  gPad->SetGrid(1,1);
  gStyle->SetGridColor(15);
  h2->GetYaxis()->SetRangeUser(min,max);
  h2->Draw();
  if (profile) {
    TProfile* prof = h2->ProfileX();
    prof->SetMarkerColor(2);
    prof->SetLineColor(2);
    prof->Draw("same");
  }
  TLine * l = new TLine(h2->GetXaxis()->GetXmin(),0,h2->GetXaxis()->GetXmax(),0);
  l->SetLineColor(3);
  l->Draw();
}
コード例 #13
0
ファイル: MECompare.C プロジェクト: DesyTau/cmssw
void
HistoCompare::PVCompute(TProfile * oldHisto , TProfile * newHisto , TText * te )
{

  myoldProfile = oldHisto;
  mynewProfile = newHisto;
  myte = te;

  Double_t *res ;

  Double_t mypv = myoldProfile->Chi2Test(mynewProfile,"WW",res);
  TString title = myoldProfile->GetName();
  printRes(title, mypv, myte);
  return;

}
コード例 #14
0
ファイル: EE_EnScale.cpp プロジェクト: amassiro/usercode
TH1D * smartGausProfileXSQRTN (TH2F * strip, double width){
 TProfile * stripProfile = strip->ProfileX () ;
 
 // (from FitSlices of TH2.h)
 
 double xmin = stripProfile->GetXaxis ()->GetXmin () ;
 double xmax = stripProfile->GetXaxis ()->GetXmax () ;
 int profileBins = stripProfile->GetNbinsX () ;
 
 std::string name = strip->GetName () ;
 name += "_smartGaus_X" ; 
 TH1D * prof = new TH1D(name.c_str (),strip->GetTitle (),profileBins,xmin,xmax) ;
 
 int cut = 0 ; // minimum number of entries per fitted bin
 int nbins = strip->GetXaxis ()->GetNbins () ;
 int binmin = 1 ;
 int ngroup = 1 ; // bins per step
 int binmax = nbins ;
 
 // loop over the strip bins
 for (int bin=binmin ; bin<=binmax ; bin += ngroup) 
 {
  TH1D *hpy = strip->ProjectionY ("_temp",bin,bin+ngroup-1,"e") ;
  if (hpy == 0) continue ;
  int nentries = Int_t (hpy->GetEntries ()) ;
  if (nentries == 0 || nentries < cut) {delete hpy ; continue ;} 
  
  Int_t biny = bin + ngroup/2 ;
  
  TF1 * gaussian = new TF1 ("gaussian","gaus", hpy->GetMean () - width * hpy->GetRMS (), hpy->GetMean () + width * hpy->GetRMS ()) ; 
  gaussian->SetParameter (1,hpy->GetMean ()) ;
  gaussian->SetParameter (2,hpy->GetRMS ()) ;
  hpy->Fit ("gaussian","RQL") ;           
  
  //       hpy->GetXaxis ()->SetRangeUser ( hpy->GetMean () - width * hpy->GetRMS (), hpy->GetMean () + width * hpy->GetRMS ()) ;         
  prof->Fill (strip->GetXaxis ()->GetBinCenter (biny), gaussian->GetParameter (1)) ;       
  prof->SetBinError (biny,gaussian->GetParameter (2) / sqrt(hpy->GetEntries())) ;
//   prof->SetBinError (biny,gaussian->GetParError (1)) ;
  
  delete gaussian ;
  delete hpy ;
 } // loop over the bins
 
 delete stripProfile ;
 return prof ;
}
コード例 #15
0
void show_mass_dist()
{
    TFile *file_f = new TFile("particle_mass_dist.root");

    TH2F *hm = (TH2F *) file_f->Get("mass_dist");
    TProfile *pm = (TProfile *) file_f->Get("mass_dist_p");

    TCanvas *cm = new TCanvas("cm", "Mass", 1000, 500);
    cm->Divide(2, 1);

    pm->SetLineColor(4);

    cm->cd(1);
    hm->Draw();
    cm->cd(2)->SetBorderMode(0);
    pm->Draw();
}
コード例 #16
0
ファイル: macros.C プロジェクト: aashaqshah/cmssw-1
// Draw a 2-D plot within the specified Y range and superimpose its X profile,
// setting as sigmas that of the fit (and not the error of the mean)
void plotAndProfileXSpread (TH2* h2, float min, float max, bool profile=false, float ymin=-5., float ymax=5.) {
  setStyle(h2);
  gPad->SetGrid(1,1);
  gStyle->SetGridColor(15);
  gStyle->SetOptStat(0);
  // h2->RebinX(3);
  // h2->RebinY(2);
  // h2->SetXTitle("distance from anode (cm)");
  // h2->SetYTitle("(d_{reco}-d_{sim})/#sigma_{reco}");
  h2->SetMarkerColor(2);
  h2->SetLineColor(2);
  h2->GetYaxis()->SetTitleOffset(1.4);
  h2->GetXaxis()->SetRangeUser(min,max);
  h2->GetYaxis()->SetRangeUser(ymin,ymax);
  h2->DrawCopy("box");
  if (profile) {
    TProfile* prof = h2->ProfileX("profile",-1,-1,"s");
    prof->SetMarkerStyle(20);
    prof->SetMarkerSize(1.2);
    prof->SetMarkerColor(1);
    prof->SetLineColor(1);
    prof->SetLineWidth(2);
    prof->DrawCopy("same e1");
    delete prof;
  }
  TLine * l = new TLine(h2->GetXaxis()->GetXmin(),0,h2->GetXaxis()->GetXmax(),0);
  l->SetLineColor(3);
  l->Draw();
}
コード例 #17
0
ファイル: doPlots.C プロジェクト: magania/CMS2
TProfile* plotIsoPerformance( TFile* ftt, 
			      const char* signal,     // histogram name
			      const char* background, // histogram name
			      const char* name,       // unique name
			      bool reverse = false,   // normally signal near zero bin, reverse means signal is around max bin
			      double bkg_eff_min = 0,
			      double bkg_eff_max = 1,
			      double sig_eff_min = 0,
			      double sig_eff_max = 0
			      )
{ 
  TH1F* S = dynamic_cast<TH1F*>(ftt->Get(signal));
  if ( ! S ) {
    std::cout << "Error: histogram not found " << signal << std::endl;
    return 0;
  }
  TH1F* B = dynamic_cast<TH1F*>(ftt->Get(background));
  if ( ! B ) {
    std::cout << "Error: histogram not found " << background << std::endl;
    return 0;
  }
  char buf[1024];
  sprintf(buf,"c_%s",name);
  // TCanvas* c = new TCanvas(buf,buf,500,500);
  sprintf(buf,"p_%s",name);
  TProfile* p = new TProfile(buf,buf,50,bkg_eff_min,bkg_eff_max,sig_eff_min,sig_eff_max);
  p->SetLineColor(kBlue);
  p->SetLineWidth(2);
  p->SetMarkerStyle(20);
  p->SetMarkerSize(1);
  p->GetXaxis()->SetTitle("Background Efficiency");
  p->GetYaxis()->SetTitle("Signal Efficiency");
  p->SetStats(kFALSE);
  for( int i=0;i<=S->GetNbinsX()+1; ++i )
    if ( reverse ) 
      p->Fill(B->Integral(i,B->GetNbinsX()+1)/B->Integral(0,B->GetNbinsX()+1),
	      S->Integral(i,S->GetNbinsX()+1)/S->Integral(0,S->GetNbinsX()+1));
    else
      p->Fill(B->Integral(0,i)/B->Integral(0,B->GetNbinsX()+1),
	      S->Integral(0,i)/S->Integral(0,S->GetNbinsX()+1));
  // p->Draw();
  return p;
}
コード例 #18
0
ファイル: t.C プロジェクト: schuetzepaul/testbeam-analysis
//------------------------------------------------------------------------------
double meanY( char* hs ) // for profiles only
{
  TObject* obj = gDirectory->Get(hs);
  if( !obj->InheritsFrom( "TProfile" ) ) {
    cout << hs << " is not profile plot" << endl;
    return 0;
  }
  TProfile* p = (TProfile*)obj;
  double sumw = 0;
  double sumy = 0;
  for( int i = 1; i <= p->GetNbinsX(); ++i ) { // bin 0 is underflow
    double w = p->GetBinEntries(i);
    sumw += w;
    sumy += w * p->GetBinContent(i);
  }
  if( sumw > 0.1 )
    return sumy/sumw;
  else
    return 0;
}
コード例 #19
0
void
NavigationTree_DisplayProfilesToogle()
	{
	TProfile * pProfileSelected = g_oConfiguration.m_pProfileSelected;
	if (pProfileSelected != NULL)
		{
		if (pProfileSelected->m_paTreeItemW_YZ == NULL)
			{
			pProfileSelected->TreeItemProfile_DisplayProfileInfoWithinNavigationTree();
			pProfileSelected->TreeItemW_Expand();
			pProfileSelected->TreeItemLayout_SetFocus();
			return;
			}
		pProfileSelected->TreeItemW_ToggleVisibilityAndSetFocus();
		}
	else if (g_pTreeItemProfiles != NULL)
		{
		g_pTreeItemProfiles->TreeItemW_ToggleVisibilityAndSetFocus();
		}
	}
コード例 #20
0
IXmlExchange *
IApplication::S_PaAllocateApplication_YZ(POBJECT poProfileParent, const CXmlNode * pXmlNodeElement)
    {
    Assert(pXmlNodeElement != NULL);
    TProfile * pProfileParent = (TProfile *)poProfileParent;
    Assert(pProfileParent->EGetRuntimeClass() == RTI(TProfile));
    // Find the type of application to allocate
    PSZUC pszClass = pXmlNodeElement->PszuFindAttributeValue_NZ(c_szaApplicationClass_);
    const SApplicationAllocator * pApplicationAllocator = c_rgzApplicationAllocators;
    while (TRUE)
        {
        if (pApplicationAllocator->pszClass == NULL)
            break;
        Assert(pApplicationAllocator->pfnAllocator != NULL);
        if (FCompareStrings(pApplicationAllocator->pszClass, pszClass))
            return pApplicationAllocator->pfnAllocator(pProfileParent);
        pApplicationAllocator++;	// Search the next application
        } // while
    MessageLog_AppendTextFormatSev(eSeverityErrorWarning, "Unable to find application of class '$s'\n", pszClass);
    return NULL;
    }
コード例 #21
0
int main(int argc,  char * argv[]){
  if(argc < 3){cout<<" Usage: executable input_file.root outfile.txt"<<endl; return -4;}
  int sm_ = 18;
  TFile f(argv[1]);
  TProfile* pr = 0;
  pr = (TProfile*) f.Get("rel_timing_prof_conv_blu");
  if( !pr ){cout<<" timing profile not found in the root file"<<endl; return -1;}
  
  float time[1701]; for(int i=0;i<1701;i++){time[i]=-100;}
  float half_mean  = 0;

  for(int ch=1;ch<1701;ch++){ 
    if ( ch<101 || (ch-1)%20 > 9){half_mean=137.4/25.;}// half1
    else {half_mean=137.1/25.;}
    time[ch] = pr->GetBinContent(ch)+half_mean;
    if( fabs(pr->GetBinContent(ch))>0.2 || pr->GetBinEntries(ch)<500 ){
      cout<<"cry: "<<ch<<" entries: "<<pr->GetBinEntries(ch)<<" rel timing: "<<pr->GetBinContent(ch)<<endl;
    }
  }
  f.Close();
  
  ofstream txt_channels;
  txt_channels.open(argv[2],ios::out);
  for(int i=1;i<1701;i++){
    txt_channels <<sm_<<"   "<<setw(4)<<i<<" \t "<<setw(8)<<setprecision(7)<<time[i]<< endl;
  }
  txt_channels.close();
  
  return 0;
}
コード例 #22
0
ファイル: myHist.C プロジェクト: mrelich/IceBlockAna
//------------------------------------------------------------//
// Get TProfile
//------------------------------------------------------------//
TProfile* getProfile(TFile* file, TString pname, TString xtitle,
		     TString ytitle, int color, int marker)
{
  
  TProfile* prof = (TProfile*) (file->Get(pname.Data())->Clone(Form("%s_%i",pname.Data(),color)));
  prof->GetXaxis()->SetTitle(xtitle.Data());
  prof->GetYaxis()->SetTitle(ytitle.Data());
  prof->SetMarkerStyle(marker);
  prof->SetMarkerColor(color);
  //prof->SetMarkerSize(0.5);
  prof->SetLineColor(color);
  prof->SetTitle("");
  prof->SetStats(0);
  prof->GetYaxis()->SetTitleOffset(1.5);
  
  return prof;

}
コード例 #23
0
ファイル: simplePlots.C プロジェクト: chwissing/psi46expert
// ----------------------------------------------------------------------
void nmod(const int offset = 400) {
  
  c0.Clear();
  c0.Divide(2,8);

  tl->SetTextSize(0.2);
  tl->SetNDC(kTRUE);
  tl->SetTextAngle(90); 
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gROOT->ForceStyle();

  double min(-1), max(-1);
  if (offset == 600) {
    min = 120; 
    max = 200;
  }


  TProfile *p;
  for (int i = 0; i < 16; ++i) {
    c0.cd(i+1);
    p = (TProfile*)gFile->Get(Form("p%i", offset+i));
    if (min > -1) {
      p->SetMinimum(min);
      p->SetMaximum(max);
    }
    p->Draw();
    
    tl->DrawLatex(0.2, 0.11, Form("Chip %i", i)); 
  }

  if (offset == 400) c0.SaveAs("ped-nmod.ps");
  if (offset == 500) c0.SaveAs("gain-nmod.ps");
  if (offset == 600) c0.SaveAs("noise-nmod.ps");
  if (offset == 700) c0.SaveAs("pedgain-nmod.ps");

  
}
コード例 #24
0
ファイル: plotweight.C プロジェクト: XuQiao/phenix
void plotweight(int isub){
    TFile *f = TFile::Open("/phenix/plhf/xuq/taxi/Run15pAl200MBPro104/10241/data/438026_0.root");
    //TFile *f = TFile::Open("/phenix/u/xuq/xuq/phenix/flow/PP/work/Run15pp200MinBias/output_fvtxclus.root");
    int ivz = 0;
    if(isub!=4){
    TH1F* h = (TH1F*)f->Get(Form("phiweight_0_0_0_%d_0_%d",ivz,isub));
    //TH1F* h = (TH1F*)f->Get(Form("fvtxphi_%d_%d",ivz,isub));
    TH1F* hc = (TH1F*)h->Clone("hc");
    for(int ibin=0;ibin<=h->GetNbinsX();ibin++){
        if(h->GetBinContent(ibin)!=0)
        hc->SetBinContent(ibin,h->Integral()/h->GetNbinsX()/h->GetBinContent(ibin));
        else 
        hc->SetBinContent(ibin,1.);
    }
    }
    else{
    TProfile* h = (TProfile*)f->Get(Form("phiweightbbc_0_0_0_%d_0_%d",ivz,isub));
    TProfile* hc = (TProfile*)h->Clone("hc");
    }
    TCanvas *c1 = new TCanvas("c1");
    hc->GetYaxis()->SetRangeUser(0,2);
    hc->Draw();
    TLine *l1 = new TLine(-3.14,0.8,3.14,0.8);
    l1->SetLineStyle(2);
    l1->SetLineColor(2);
 //   l1->Draw();
    TLine *l2 = new TLine(-3.14,1.2,3.14,1.2);
    l2->SetLineStyle(2);
    l2->SetLineColor(2);
 //   l2->Draw();
    if(isub!=4)
    c1->Print(Form("FVTXweight%d.png",isub));
    TCanvas *c2 = new TCanvas("c2");
    h->GetXaxis()->SetRangeUser(0,64);
    h->GetYaxis()->SetRangeUser(0.5,3);
    h->Draw();
    if(isub==4)
    c2->Print(Form("BBCweight%d.png",isub));
}
コード例 #25
0
void PlotAlignmentValidation::modifySSHistAndLegend(THStack* hs, TLegend* legend)
{
  // Add mean-y-values to the legend and scale the histograms.

  Double_t legendY = 0.80;
  if (hs->GetHists()->GetSize() > 3)
    legendY -= 0.01 * (hs->GetHists()->GetSize() - 3);
  if (legendY < 0.6) {
    std::cerr << "Warning: Huge legend!" << std::endl;
    legendY = 0.6;
  }
  legend->SetY1(legendY);

  // Loop over all profiles
  TProfile* prof = 0;
  TIter next(hs->GetHists());
  Int_t index = 0;
  while ((prof = (TProfile*)next())) {
    //Scaling: from cm to um
    Double_t scale = 10000;
    prof->Scale(scale);

    Double_t stats[6] = {0};
    prof->GetStats(stats);

    std::ostringstream legendtext;
    legendtext.precision(3);
    legendtext << fixed; // to always show 3 decimals
    legendtext << ": y mean = " << stats[4]/stats[0]*scale << " #mum";

    TLegendEntry* entry = (TLegendEntry*)legend->GetListOfPrimitives()->At(index);
    if (entry == 0)
      cout << "PlotAlignmentValidation::PlotAlignmentValidation::modifySSLegend: Bad legend!" << endl;
    else
      entry->SetLabel((entry->GetLabel() + legendtext.str()).c_str());
    index++;
  }

}
コード例 #26
0
ファイル: AnalysisBase.C プロジェクト: yabezsh/Tb
void AnalysisBase::getTDC(){
  TProfile *hb = new TProfile("hb","Cluster Charge vs TDC time",12,0,12,100,1000);
  Long64_t nentries = fChain->GetEntriesFast();
  float lo = 0, hi = 0;
  int istrip;

  Long64_t nbytes = 0, nb = 0;
  std::cout << "============================================" << std::endl;
  std::cout << "getTDC(): Determining Optimal TDC time range" << std::endl;
  std::cout << "============================================" << std::endl;   
  for (Long64_t jentry=0; jentry<max(50000,(int)nentries);jentry++) {
    Long64_t ientry = LoadTree(jentry);
    if (ientry < 0) break;
    nb = fChain->GetEntry(jentry);   nbytes += nb;

    for(int j=0; j<min((int)clusterNumberPerEvent,10); j++){
      //std::cout << "j: " << ", clustersTDC: " << clustersTDC << ", clustersCharge[j]: " << clustersCharge[j] << ", clustersPosition[j]: " << clustersPosition[j] << std::endl; 
      istrip = clustersSeedPosition[j];
      if(badStrips[istrip]==0) continue; // exclude bad strips
      if(clustersPosition[j] < 0.1) continue;
      if(polarity*clustersCharge[j] < kClusterChargeMin) continue;
      if(clustersPosition[j]>=iLo && clustersPosition[j]<=iHi && clustersTDC>1.0 && 
         polarity*clustersCharge[j]>150 && polarity*clustersCharge[j]<500) hb->Fill(clustersTDC+0.1,polarity*clustersCharge[j]);
    }
  }

  getTDCBins(hb,lo,hi);
  tdcLo = lo;
  tdcHi = hi;
  std::cout << "====> TDC Range determined to be from " << tdcLo << " -- " << tdcHi << std::endl;
  hb->Draw();
  //delete hb;
  

  return;
}
コード例 #27
0
ファイル: makePlots.C プロジェクト: rovere/tracking-tests
void makePlots(char * file, char * suffix) {
    //Get rid of stat-box
    gROOT->GetStyle("Plain")->SetOptStat(0);
    // AXIS LABELS STYLE
    gROOT->GetStyle("Plain")->SetLabelColor(kBlack, "XYZ");
    gROOT->GetStyle("Plain")->SetLabelFont(43, "XYZ");
    gROOT->GetStyle("Plain")->SetLabelSize(20, "XYZ");
    gROOT->SetStyle("Plain");
    gROOT->ForceStyle(kTRUE);

    const char * folder = "demo";
    const char * to_plot[] = {"TrackerClusterMap", "TrackerClusterOntrackMap", "TrackerSameClusterOntrackMap", "TrackerOccupancyOntrackMap", "TrackerOccupancySameClusterOntrackMap", 0};
    TFile * f = new TFile(file);
    TCanvas * c = new TCanvas("C", "C", 1024, 1024);
    for (const char **profile = to_plot; *profile; ++profile) {
        TString obj_name(folder);
        obj_name.Append("/").Append(*profile);
        TProfile * p = (TProfile*)f->Get(obj_name.Data());
        p->Draw("colz");
        TString filename(*profile);
        filename.Append("_").Append(suffix).Append(".png");
        c->SaveAs(filename.Data());
    }
}
コード例 #28
0
ファイル: extractFlowVZERO.C プロジェクト: ktf/AliPhysics
void compareTPCTOF(Int_t icentr,Int_t spec,Int_t arm,Float_t pTh,Int_t addbin){
  LoadLib();
  Float_t ptMaxFit[8] = {20,0.7,0.55,1.2,2,2,2,2};

  TProfile *pTPC = extractFlowVZEROsingle(icentr,spec,arm,0,pTh,addbin,"TPC",0,0,-1,-1+2*(spec!=3)); // TPC && !TOF (TPC PID)
  TProfile *pTPC2 = extractFlowVZEROsingle(icentr,spec,arm,0,pTh,addbin,"TPCextra",2,2,-1,-1+2*(spec!=3)); //TPC && TOF (TPC PID)

  TProfile *pTOF = extractFlowVZEROsingle(icentr,spec,arm,0,pTh,addbin,"TOF",1,1,-1,-1+2*(spec!=3)); //TPC && TOF (TPC&TOF PID)

  if(spec > 0) pTPC->Add(pTPC2);
  else pTPC->Add(pTOF);

  char name[100];
  snprintf(name,100,"NUO_%i",spec);

  hNUO[spec] = pTPC->ProjectionX(name);
  hNUO[spec]->Add(pTOF,-1);

  if(spec && hNUO[0]) hNUO[spec]->Add(hNUO[0],-1);

  if(! kCleanMemory){
    new TCanvas();
    pTPC->Draw();
    pTOF->Draw("SAME");

    new TCanvas();  
    pTPC->SetLineColor(1);
    pTOF->SetLineColor(2);
  }

  hNUO[spec]->Draw();

  if(kCleanMemory){
    if(pTPC) delete pTPC;
    if(pTPC2) delete pTPC2;
    if(pTOF) delete pTOF;
  }
}
コード例 #29
0
ファイル: Fake100PeVShower.C プロジェクト: mrelich/EField
void Fake100PeVShower(int opt)
{

  // opt == 0 implies save to root file
  // opt == 1 implies plot and save to canvas
  TFile* file = NULL;
  TCanvas* c  = NULL;

  if(opt == 0)
    file = new TFile("fake100PeVShower.root","recreate");
  if(opt == 1)
    c = makeCanvas("c");

  TString gaus = "1.5e7*TMath::Exp(-(pow(x-10,2)/9))";
  TString bump = "5e6*TMath::Exp(-(pow(x-17,2)/20))";
  TF1* f = new TF1("f",(gaus+"+"+bump).Data(),0,30);

  int nbins = 3000;
  float xmin  = 0;
  float xmax  = 30;
  TProfile* prof = new TProfile("prof","",nbins,xmin,xmax);
  prof->SetStats(0);
  prof->SetTitle("");
  prof->GetYaxis()->SetTitle("Charge excess / 1e7");
  prof->GetXaxis()->SetTitle("z [m]");

  float step = xmax / nbins;
  for(int i =0; i<nbins; ++i){
    float x = step * i;
    if(opt == 1 ) prof->Fill(x, f->Eval(x)/1e7);
    else          prof->Fill(x, f->Eval(x));
  }
    
  if(opt == 1){
    prof->Draw();
    c->SaveAs("JaimeCheck/FakeProfile100PeV.png");
  }
  if(opt == 0){
    file->Write();
    file->Close();
  }
}
コード例 #30
0
ファイル: deviationBosonPt.C プロジェクト: arapyan/MitHtt
void deviationBosonPtOld() { 
  TFile *lFile = new TFile("ZTPMC.root");
  TTree *lTree = (TTree*) lFile->FindObjectAny("WNtupleIdEffNT");
  //lTree->Print();
  //lTree->Draw("mt");
  std::string lZPt = "sqrt((abs(pt)*cos(phi)+abs(jetpt)*cos(jetphi))*(abs(pt)*cos(phi)+abs(jetpt)*cos(jetphi)) + (abs(pt)*sin(phi)+abs(jetpt)*sin(jetphi))*(abs(pt)*sin(phi)+abs(jetpt)*sin(jetphi)))";
  TProfile *lPProf = new TProfile("A","A",8,0,40); lPProf->SetMarkerColor(kBlue); lPProf->SetMarkerStyle(21); lPProf->SetLineColor(kBlue);
  TProfile *lMProf = new TProfile("B","B",8,0,40); lMProf->SetMarkerColor(kRed);  lMProf->SetMarkerStyle(21); lMProf->SetLineColor(kRed);
  lTree->Draw(std::string("mt:"+lZPt+">>A").c_str(),std::string("mt > 80 && charge > 0 ").c_str());
  lTree->Draw(std::string("mt:"+lZPt+">>B").c_str(),std::string("mt > 80 && charge < 0 ").c_str());
  //lTree->Draw(std::string("mt>>A").c_str(),"mt > 80 && charge > 0");
  //lTree->Draw(std::string("mt>>B").c_str(),"mt > 80 && charge < 0");
  
  TLegend *lL = new TLegend(0.6,0.6,0.9,0.9);
  lL->SetFillColor(0);
  lL->AddEntry(lPProf,"Plus","lp");
  lL->AddEntry(lMProf,"Minus","lp");
  lPProf->Draw();
  lMProf->Draw("same");
  lL->Draw();
}