当前位置: 首页>>代码示例>>C++>>正文


C++ TObjString类代码示例

本文整理汇总了C++中TObjString的典型用法代码示例。如果您正苦于以下问题:C++ TObjString类的具体用法?C++ TObjString怎么用?C++ TObjString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TObjString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetAliEnSettings

void SetAliEnSettings()
{
   // Routine to load settings from an AliEn environment file.

   ifstream fileIn;
   fileIn.open(Form("/tmp/gclient_env_%d", gSystem->GetUid()));
   if (gDebug>0) {printf("P010_TAlien.C: parsing /tmp/gclient_env_$UID\n");}
   TString lineS,tmp;
   char line[4096];

   while (fileIn.good()){
      fileIn.getline(line,4096,'\n');
      lineS = line;
      if (lineS.IsNull()) continue;
      if (lineS.Contains("export ")) {
         lineS.ReplaceAll("export ","");

         TObjArray* array = lineS.Tokenize("=");

         if (array->GetEntries() == 2) {
            TObjString *strVar = (TObjString *) array->At(0);
            TObjString *strVal = (TObjString *) array->At(1);

            if ((strVar)&&(strVal)) {
               tmp = strVal->GetString();
               tmp.ReplaceAll("\"","");
               tmp.ReplaceAll("$LD_LIBRARY_PATH",gSystem->Getenv("LD_LIBRARY_PATH"));
               tmp.ReplaceAll("$DYLD_LIBRARY_PATH",gSystem->Getenv("DYLD_LIBRARY_PATH"));
               tmp.ReplaceAll(" ","");
               gSystem->Unsetenv(strVar->GetString());
               gSystem->Setenv(strVar->GetString(), tmp);
               if (gDebug>0) {
                  Info("P010_TAlien", "setting environment %s=\"%s\"", strVar->GetString().Data(), tmp.Data());
               }
               if (!strVar->GetString().CompareTo("GCLIENT_SERVER_LIST")) {
                  gSystem->Unsetenv("alien_API_SERVER_LIST");
                  gSystem->Setenv("alien_API_SERVER_LIST", tmp);
               }
            }
            if (array) {
               delete array;
               array = 0 ;
            }
         } else {
            // parse the MONA_ stuff
            TObjArray* array = lineS.Tokenize("\" ");
            TString key="";
            TString val="";
            for (int i=0; i< array->GetEntries(); i++) {
               if ( ((TObjString*) array->At(i))->GetString().Contains("=")) {
                  if (key.Length() && val.Length()) {
                     val.Resize(val.Length()-1);
                     if (gDebug>0) {
                        Info("P010_TAlien", "setting environment %s=\"%s\"", key.Data(), val.Data());
                     }
                     gSystem->Unsetenv(key);
                     gSystem->Setenv(key, val);
                     key="";
                     val="";
                  }
                  key = ((TObjString*) array->At(i))->GetString();
                  key.ReplaceAll("=","");
               } else {
                  val+=((TObjString*) array->At(i))->GetString();
                  val+=" ";
               }
            }
            if (key.Length() && val.Length()) {
               if (gDebug>0) {
                  Info("P010_TAlien", "setting environment %s=\"%s\"", key.Data(), val.Data());
               }
               gSystem->Unsetenv(key);
               gSystem->Setenv(key, val);
            }
         }
      }
   }
}
开发者ID:0x0all,项目名称:ROOT,代码行数:78,代码来源:P010_TAlien.C

示例2: TMVAGui

// main GUI
void TMVAGui( const char* fName = "~/cern/ntuples/TMVA.root" ) 
{   
   // Use this script in order to run the various individual macros
   // that plot the output of TMVA (e.g. running TMVAClassification.C),
   // stored in the file "TMVA.root"

   TString curMacroPath(gROOT->GetMacroPath());
   //std::cout << curMacroPath << std::endl;

   // uncomment next line for macros submitted to next root version
   gROOT->SetMacroPath(curMacroPath+".:/:$ROOTSYS/tmva/test/:");
   
   // for the sourceforge version, including $ROOTSYS/tmva/test in the
   // macro path is a mistake, especially if "./" was not part of path
   // add ../macros to the path (comment out next line for the ROOT version of TMVA)
   // gROOT->SetMacroPath(curMacroPath+":../macros:");

   TString curIncludePath=gSystem->GetIncludePath();
   TString newIncludePath=TString("-I../ ")+curIncludePath;
   gSystem->SetIncludePath(newIncludePath);
  
   cout << "--- Launch TMVA GUI to view input file: " << fName << endl;
   // init
   TMVAGui_inactiveButtons.clear();

   // check if file exist
   TFile* file = TFile::Open( fName );
   if (!file) {
      cout << "==> Abort TMVAGui, please verify filename" << endl;
      return;
   }
   // find all references   
   TMVAGui_keyContent = (TList*)file->GetListOfKeys()->Clone();

   // close file
   file->Close();

   TString defaultRequiredClassifier = "";

   //   gROOT->Reset();
   //   gStyle->SetScreenFactor(2); // if you have a large screen, select 1,2 or 1.4

   // create the control bar
   TControlBar* cbar = new TControlBar( "vertical", "TMVA Plotting Macros for Classification", 0, 0 );

   const TString buttonType( "button" );

   // configure buttons   
   Int_t ic = 1;

   // find all input variables types
   TList* keylist = GetKeyList( "InputVariables" );
   TListIter it( keylist );
   TObjString* str = 0;
   char ch = 'a';
   while ((str = (TObjString*)it())) {
      TString tmp   = str->GetString();
      TString title = Form( "Input variables '%s'-transformed (training sample)", 
                            tmp.ReplaceAll("InputVariables_","").Data() );
      if (tmp.Contains( "Id" )) title = "Input variables (training sample)";
      ActionButton( cbar, 
                    Form( "(%i%c) %s", ic, ch++, title.Data() ),
                    Form( ".x variables.C+(\"%s\",\"%s\",\"%s\")", fName, str->GetString().Data(), title.Data() ),
                    Form( "Plots all '%s'-transformed input variables (macro variables.C(...))", str->GetString().Data() ),
                    buttonType, str->GetString() );
   }      
   ic++;

   // correlation scatter plots 
   it.Reset(); ch = 'a';
   while ((str = (TObjString*)it())) {
      TString tmp   = str->GetString();
      TString title = Form( "Input variable correlations '%s'-transformed (scatter profiles)", 
                            tmp.ReplaceAll("InputVariables_","").Data() );
      if (tmp.Contains( "Id" )) title = "Input variable correlations (scatter profiles)";
      ActionButton( cbar, 
                    Form( "(%i%c) %s", ic, ch++, title.Data() ),
                    Form( ".x CorrGui.C+(\"%s\",\"%s\",\"%s\")", fName, str->GetString().Data(), title.Data() ),
                    Form( "Plots all correlation profiles between '%s'-transformed input variables (macro CorrGui.C(...))", 
                          str->GetString().Data() ),
                    buttonType, str->GetString() );
   }      
  
   TString title;
   // coefficients
   title =Form( "(%i) Input Variable Linear Correlation Coefficients", ++ic );
   ActionButton( cbar,  
                 title,
                 Form( ".x correlations.C+(\"%s\")", fName ),
                 "Plots signal and background correlation summaries for all input variables (macro correlations.C)", 
                 buttonType );

   title =Form( "(%ia) Classifier Output Distributions (test sample)", ++ic );
   ActionButton( cbar,  
                 title,
                 Form( ".x mvas.C+(\"%s\",0)", fName ),
                 "Plots the output of each classifier for the test data (macro mvas.C(...,0))",
                 buttonType, defaultRequiredClassifier );

//.........这里部分代码省略.........
开发者ID:apmorris,项目名称:scripts,代码行数:101,代码来源:TMVAGui.C

示例3: draw_syst_hists

   void draw_syst_hists( const char* inwsfile, const char* syst_name, int sig_mass = 0, float max_msig_evts = 8., float max_msb_evts = 16. ) {

      gStyle -> SetOptStat(0) ;
      gStyle -> SetPadLeftMargin(0.15) ;
      gStyle -> SetTitleW( 0.9 ) ;


      gDirectory -> Delete( "h*" ) ;

      loadHist( inwsfile ) ;

      TLine* line = new TLine() ;
      line -> SetLineStyle(2) ;

     //----

      gSystem -> Exec( "mkdir -p outputfiles/syst-plots" ) ;

      TString infile_ts( inwsfile ) ;
      TObjArray* tokens = infile_ts.Tokenize("/") ;

      TObjString* tos = (TObjString*) (tokens -> At( tokens->GetEntries() - 1 ) ) ;
      TString fname( tos->GetString() ) ;
      printf( "ws file name : %s\n", fname.Data() ) ;

      TString pdfbasename = fname.ReplaceAll(".root","") ;
      printf(" pdf base name : %s\n", pdfbasename.Data() ) ;


      char sigsb_str[2][10] = { "msig", "msb" } ;

      for ( int ssbi=0; ssbi<2; ssbi++ ) {

         char cname[100] ;

         sprintf( cname, "can_evts_%s", sigsb_str[ssbi] ) ;
         TCanvas* can_evts = (TCanvas*) gDirectory -> FindObject( cname ) ;
         if ( can_evts == 0x0 ) {
            if ( ssbi == 0 ) {
               can_evts = new TCanvas( cname, "SIG observables", 1100, 300 ) ;
            } else {
               can_evts = new TCanvas( cname, "SB observables", 1100, 300 ) ;
            }
         }

         sprintf( cname, "can_frac_%s", sigsb_str[ssbi] ) ;
         TCanvas* can_frac = (TCanvas*) gDirectory -> FindObject( cname ) ;
         if ( can_frac == 0x0 ) {
            if ( ssbi == 0 ) {
               can_frac = new TCanvas( cname, "SIG observables, syst (%)", 1100, 300 ) ;
            } else {
               can_frac = new TCanvas( cname, "SB observables, syst (%)", 1100, 300 ) ;
            }
         }


         can_evts -> Clear() ;
         can_evts -> Divide(4,1) ;

         can_frac -> Clear() ;
         can_frac -> Divide(4,1) ;

         for ( int ci=1; ci<=4; ci++ ) {


            char hname[1000] ;
            char hnamev[1000] ;
            char hnamenf[1000] ;

            sprintf( hname, "h_syst_%s_%s_met%d_nom", syst_name, sigsb_str[ssbi], ci ) ;
            TH1F* hist_nom = (TH1F*) gDirectory -> FindObject( hname ) ;
            if ( hist_nom == 0x0 ) { printf("\n\n *** Can't find %s\n\n", hname ) ; return ; }
            sprintf( hnamenf, "%s_nf", hname ) ;
            TH1F* hist_nom_nf = (TH1F*) hist_nom -> Clone( hnamenf ) ;

            sprintf( hname, "h_syst_%s_%s_met%d_m1s", syst_name, sigsb_str[ssbi], ci ) ;
            TH1F* hist_m1s = (TH1F*) gDirectory -> FindObject( hname ) ;
            if ( hist_m1s == 0x0 ) { printf("\n\n *** Can't find %s\n\n", hname ) ; return ; }
            sprintf( hnamev, "%s_var", hname ) ;
            TH1F* hist_m1s_var = (TH1F*) hist_m1s -> Clone( hnamev ) ;

            sprintf( hname, "h_syst_%s_%s_met%d_p1s", syst_name, sigsb_str[ssbi], ci ) ;
            TH1F* hist_p1s = (TH1F*) gDirectory -> FindObject( hname ) ;
            if ( hist_p1s == 0x0 ) { printf("\n\n *** Can't find %s\n\n", hname ) ; return ; }
            sprintf( hnamev, "%s_var", hname ) ;
            TH1F* hist_p1s_var = (TH1F*) hist_p1s -> Clone( hnamev ) ;

            TString htitle ;

            htitle = hist_nom -> GetTitle() ;
            if ( sig_mass > 0 ) {
               char sigmassstr[1000] ;
               sprintf( sigmassstr, ", higgsino mass = %d", sig_mass ) ;
               htitle.ReplaceAll( ", nominal", sigmassstr ) ;
            } else {
               htitle.ReplaceAll( ", nominal", "" ) ;
            }
            hist_nom -> SetTitle( htitle ) ;

            htitle = hist_m1s_var -> GetTitle() ;
//.........这里部分代码省略.........
开发者ID:owen234,项目名称:hbb-stats,代码行数:101,代码来源:draw_syst_hists.c

示例4: run_reco

/********************************************************************************
 *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
 *                                                                              *
 *              This software is distributed under the terms of the             *
 *              GNU Lesser General Public Licence (LGPL) version 3,             *
 *                  copied verbatim in the file "LICENSE"                       *
 ********************************************************************************/
void run_reco( TString mcEngine="TGeant3", Bool_t AlignDone=true )
{
   // ----  Load libraries   -------------------------------------------------
  FairLogger *logger = FairLogger::GetLogger();
//  logger->SetLogFileName("MyLog.log");
  logger->SetLogToScreen(kTRUE);
//  logger->SetLogToFile(kTRUE);
//  logger->SetLogVerbosityLevel("HIGH");
//  logger->SetLogFileLevel("DEBUG4");
  logger->SetLogScreenLevel("INFO");

  // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug)
  Int_t iVerbose = 0; // just forget about it, for the moment

  TString Align= "";
  if (AlignDone) {
    Align= "align_";
  }
  TString InDir = "./data/";
  // Input file (MC Events)
  TString  inFile     ="testrun_";
  inFile = InDir +inFile + Align + mcEngine + ".root";

  // Output file name
  TString  outFile     ="testreco_";
  outFile = InDir + outFile + Align + mcEngine + ".root";

  // Parameter file
  TString  parFile     ="testparams_";
  parFile = InDir + parFile + Align + mcEngine + ".root";

  // Millepede file name
  TString  milleFile     ="testmille_";
  milleFile = InDir + milleFile + Align + mcEngine;

  TList *parFileList = new TList();

  TString workDir = gSystem->Getenv("VMCWORKDIR");
  TString paramDir = workDir + "/simulation/Tutorial4/parameters/";
  TString paramFile = paramDir + "example.par";

  TObjString tutDetDigiFile;
  tutDetDigiFile.SetString(paramFile);
  parFileList->Add(&tutDetDigiFile);

  // -----   Timer   --------------------------------------------------------
  TStopwatch timer;

  // -----   Reconstruction run   -------------------------------------------
  FairRunAna *fRun= new FairRunAna();
  FairFileSource *fFileSource = new FairFileSource(inFile);
  fRun->SetSource(fFileSource);
  fRun->SetSink(new FairRootFileSink(outFile));

  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
  FairParRootFileIo* parInput1 = new FairParRootFileIo();
  FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo();
  parIo2->open(parFileList, "in");
  parInput1->open(parFile.Data());
  parIo2->open(parFileList, "in");
  rtdb->setFirstInput(parInput1);
  rtdb->setSecondInput(parIo2);
  rtdb->setOutput(parInput1);
  rtdb->saveOutput();

  // -----   TorinoDetector hit  producers   ---------------------------------
  FairTutorialDet4HitProducerIdealMisalign* hitProducer = new FairTutorialDet4HitProducerIdealMisalign();
  hitProducer->DoMisalignment(kFALSE);
  fRun->AddTask(hitProducer);

  FairTutorialDet4StraightLineFitter* fitter = new FairTutorialDet4StraightLineFitter();
  fitter->SetVersion(2);
  fRun->AddTask(fitter);

  FairTutorialDet4MilleWriter* writer = new FairTutorialDet4MilleWriter();
//  writer->SetWriteAscii(kTRUE);
  writer->SetVersion(2);
  writer->SetFileName(milleFile);
  fRun->AddTask(writer);


  fRun->Init();

  timer.Start();
  fRun->Run();

  // -----   Finish   -------------------------------------------------------

  cout << endl << endl;

  // Extract the maximal used memory an add is as Dart measurement
  // This line is filtered by CTest and the value send to CDash
  FairSystemInfo sysInfo;
//.........这里部分代码省略.........
开发者ID:FairRootGroup,项目名称:FairRoot,代码行数:101,代码来源:run_reco.C

示例5: FnormMacro

//_____________________________________________________________________________
void FnormMacro(
              const char* filename="../LHC15g.MuMu.1.root",
              const char* associatedSimFileName="",
              const char* associatedSimFileName2="",
              const char* beamYear="PbPb2011",const int DebugLevel =0)
{


  // //_____ FNorm
    // analysis.ComputeIntFnormFromCounters("",kFALSE);
    // //_____ 


  AliAnalysisMuMu ana(filename,associatedSimFileName,associatedSimFileName2,beamYear);
  AliLog::SetGlobalDebugLevel(DebugLevel);


  if (!ana.OC() || !ana.CC())
  {
    AliError("No mergeable/counter collection. Consider Upgrade()");
    return ;
  }
  else
  {
    cout <<      " ================================================================ " << endl;
    cout <<      "                  Compute Mean Fnorm From Counters                " << endl;
    cout <<      " ================================================================ " << endl;
  }


  // Get configuration settings
  TObjArray* eventTypeArray   = ana.Config()->GetListElements(AliAnalysisMuMuConfig::kEventSelectionList,IsSimulation());
  TObjArray* triggerMuonArray = ana.Config()->GetListElements(AliAnalysisMuMuConfig::kDimuonTriggerList,IsSimulation());
  TObjArray* triggerMBArray   = ana.Config()->GetListElements(AliAnalysisMuMuConfig::kMinbiasTriggerList,IsSimulation());
  TObjArray* centralityArray  = ana.Config()->GetListElements(AliAnalysisMuMuConfig::kCentralitySelectionList, IsSimulation());

  // Iterator for loops
  TIter nextTriggerMuon(triggerMuonArray);
  TIter nextTriggerMB(triggerMBArray);
  TIter nextEventType(eventTypeArray);
  TIter nextCentrality(centralityArray);

  // Strings
  TObjString* striggerMuon;
  TObjString* striggerMB;
  TObjString* seventType;
  TObjString* scentrality;

  //Pointers on histo
  TH1*h(0x0);
  TH1*h1(0x0);
  TH1*h2(0x0);
  
  Double_t FNormOverStat(0.);
  Double_t FNormTotError(0.);
  Double_t FNormTotErrorInverse(0.);
  Double_t FNormTotErrorSys(0.);
  Double_t Norm(1.);

  Int_t n =0; //counter

  nextEventType.Reset();
  // Loop on each envenType (see MuMuConfig)
  //==============================================================================
  while ( ( seventType = static_cast<TObjString*>(nextEventType())) )
  {
    AliDebug(1,Form("EVENTTYPE %s",seventType->String().Data()));
    nextTriggerMuon.Reset();
    // Loop on each Muon trigger (see MuMuConfig)
    //==============================================================================
    while ( ( striggerMuon = static_cast<TObjString*>(nextTriggerMuon())) )
    {
      AliDebug(1,Form("-MUON TRIGGER %s",striggerMuon->String().Data()));
      nextTriggerMB.Reset();
      // Loop on each MB trigger (not the ones in MuMuConfig but the ones set)
      //==============================================================================
      while ( ( striggerMB = static_cast<TObjString*>(nextTriggerMB())) )
      {
        AliDebug(1,Form("-- MB PAIRCUT %s",striggerMB->String().Data()));
        nextCentrality.Reset();
        // Loop on each centrality
        //==============================================================================
        while ( ( scentrality = static_cast<TObjString*>(nextCentrality()) ) )
        {
          TString id(Form("/FNORM-%s/%s/%s/PbPb",striggerMuon->String().Data(),seventType->String().Data(),scentrality->String().Data())); // Path where are saved histos in the mergeable collection

          h = OC()->Histo(id.Data(),Form("hFNormIntVSrun_%s",striggerMB->String().Data()));
          if (!h)
          {
            AliDebug(1,Form("Can't get histo %s/hFNormIntVSrun_%s",id.Data(),striggerMB->String().Data()));
            continue;
          }

          h1 = OC()->Histo(id.Data(),Form("hFNormInt_%s",striggerMB->String().Data()));
          if (!h1)
          {
            AliDebug(1,Form("Can't get histo %s/hFNormInt_%s",id.Data(),striggerMB->String().Data()));
            continue;
          }
//.........这里部分代码省略.........
开发者ID:benjaminaudurier,项目名称:Macro,代码行数:101,代码来源:MeanFnorm.C

示例6: TGMainFrame

//______________________________________________________________________________
ButtonWindow::ButtonWindow() 
    : TGMainFrame(gClient->GetRoot(), 600, 500)
{
    // Main test window.
    SetWindowName("CaLib Control Panel");
    
    // ---------------------------------------------------------------------------------
    TGGroupFrame* config_frame = new TGGroupFrame(this, "Calibration and set configuration", kHorizontalFrame);
    config_frame->SetTitlePos(TGGroupFrame::kLeft);
    
    TGVerticalFrame* ver_frame_1 = new TGVerticalFrame(config_frame);
    
    // calibration selection
    fCBox_Calibration = new TGComboBox(ver_frame_1, "Choose calibration");
    fCBox_Calibration->Resize(260, 25);
    ver_frame_1->AddFrame(fCBox_Calibration, new TGLayoutHints(kLHintsLeft, 0, 5, 10, 0));
      
    // fill calibrations
    gCalibrations = TCMySQLManager::GetManager()->GetAllCalibrations();
    for (Int_t i = 0; i < gCalibrations->GetSize(); i++)
    {
        TObjString* s = (TObjString*) gCalibrations->At(i);
        fCBox_Calibration->AddEntry(s->GetString().Data(), i);
    }
    
    fCBox_Calibration->Connect("Selected(Int_t)", "ButtonWindow", this, "EnableModuleSelection(Int_t)");

    // calibration module selection
    fCBox_Module = new TGComboBox(ver_frame_1, "Choose calibration module");
    fCBox_Module->Resize(260, 25);
    ver_frame_1->AddFrame(fCBox_Module, new TGLayoutHints(kLHintsLeft, 0, 5, 10, 0));
  
    // fill modules
    for (Int_t i = 0; i < gCaLibModules->GetSize(); i++)
    {
        TCCalib* cmod = (TCCalib*) gCaLibModules->At(i);
        fCBox_Module->AddEntry(cmod->GetTitle(), i);
    }

    fCBox_Module->Connect("Selected(Int_t)", "ButtonWindow", this, "ReadRunsets(Int_t)");
    
    config_frame->AddFrame(ver_frame_1, new TGLayoutHints(kLHintsFillX));
    
    TGVerticalFrame* ver_frame_2 = new TGVerticalFrame(config_frame);
    
    // runset selection
    fLB_RunSet = new TGListBox(ver_frame_2);
    fLB_RunSet->SetMultipleSelections(kTRUE);
    fLB_RunSet->Resize(120, 60);
    ver_frame_2->AddFrame(fLB_RunSet, new TGLayoutHints(kLHintsLeft | kLHintsExpandY | kLHintsExpandX, 5, 0, 10, 0));
    
    config_frame->AddFrame(ver_frame_2, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
    AddFrame(config_frame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));

    // ---------------------------------------------------------------------------------
    
    // control buttons
    TGGroupFrame* control_frame = new TGGroupFrame(this, "Calibration control", kHorizontalFrame);
    control_frame->SetTitlePos(TGGroupFrame::kLeft);
    
    fTB_Init = new TGTextButton(control_frame, "Start module");
    ResizeFrame(fTB_Init);
    fTB_Init->Connect("Clicked()", "ButtonWindow", this, "StartModule()");
    control_frame->AddFrame(fTB_Init, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));

    fTB_Write = new TGTextButton(control_frame, "Write to DB");
    ResizeFrame(fTB_Write);
    fTB_Write->Connect("Clicked()", "ButtonWindow", this, "DoWrite()");
    control_frame->AddFrame(fTB_Write, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));

    fTB_Print = new TGTextButton(control_frame, "Print values");
    ResizeFrame(fTB_Print);
    fTB_Print->Connect("Clicked()", "ButtonWindow", this, "Print()");
    control_frame->AddFrame(fTB_Print, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));

    fTB_PrintChanges = new TGTextButton(control_frame, "Print changes");
    ResizeFrame(fTB_PrintChanges);
    fTB_PrintChanges->Connect("Clicked()", "ButtonWindow", this, "PrintChanges()");
    control_frame->AddFrame(fTB_PrintChanges, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));

    fTB_Quit = new TGTextButton(control_frame, "Quit");
    ResizeFrame(fTB_Quit);
    fTB_Quit->Connect("Clicked()", "ButtonWindow", this, "Quit()");
    control_frame->AddFrame(fTB_Quit, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
    
    AddFrame(control_frame, new TGLayoutHints(kLHintsExpandX, 5, 5, 0, 5));

    // ---------------------------------------------------------------------------------
    
    TGHorizontalFrame* nav_main_frame = new TGHorizontalFrame(this);
    
    // manual navigation
    TGGroupFrame* nav_man_frame = new TGGroupFrame(nav_main_frame, "Manual navigation", kHorizontalFrame);
    nav_man_frame->SetTitlePos(TGGroupFrame::kLeft);

    fTB_Prev = new TGTextButton(nav_man_frame, "Previous");
    ResizeFrame(fTB_Prev);
    fTB_Prev->SetToolTipText("Go to previous element", 200);
    fTB_Prev->Connect("Clicked()", "ButtonWindow", this, "DoPrev()");
//.........这里部分代码省略.........
开发者ID:Physott,项目名称:acqu,代码行数:101,代码来源:CalibrateGUI.C

示例7: html_a_directory

///
/// Process a directory recursively.
///
void html_a_directory(TDirectory *f, TString path, TEnv *params)
{
  TCanvas *c_h1 = 0;
  if (c_h1 == 0) {
    int x = params->GetValue("H1.XSize", 150);
    int y = params->GetValue("H1.YSize", 100);
    c_h1 = new TCanvas ("c_h1", "1d plots", x, y);
  }

  ///
  /// Check how to make gif plots
  ///

  char command[512];
  sprintf(command, "which pstoimg &> /dev/null");
  bool UsePstoimg = ! system(command);

  ///
  /// Generate the output directory
  ///

  gSystem->MakeDirectory (path);

  ///
  /// Get the html started
  ///

  ofstream html (path + "/index.html");
  html << "<html><head><title>" << f->GetName() << "</title></head>" << endl;
  html << "<body>" << endl;
  html << "<h1>" << f->GetName() << "</h1>" << endl;
  cout << "Processing directory " << f->GetName() << endl;

  ///
  /// Now loop over all the keys in the directory
  ///

  f->cd();
  TList *objlist = f->GetListOfKeys();
  objlist->Sort(); // order alphabetically, instead of order in which they were written
  TIterator *itr = objlist->MakeIterator();
  TKey *key;
  while ((key = static_cast<TKey*>(itr->Next())) != 0) {
    TObject *obj = key->ReadObj();

    if (obj->IsA()->InheritsFrom("TDirectory")) {
      TDirectory *d = static_cast<TDirectory*>(obj);
      html << "<br><a href=\"" << d->GetName() << "/\">" << d->GetName() << "</a>" << endl;
      html_a_directory(d, path + "/" + d->GetName(), params);
    }

    else if (obj->IsA()->InheritsFrom("TObjString")) {
      TObjString *s = static_cast<TObjString*>(obj);
      html << "<p><h2>" << key->GetName() << "</h2>" << endl;
      //html << "<blockquote><pre>" << static_cast<char*>(s->GetString())
	  // << "</pre></blockquote></p>"
	  // << endl;
      html << "<blockquote><pre>" << (s->GetString()).Data() << "</pre></blockquote></p>"<< endl;
      

    }

    //    else if (obj->IsA()->InheritsFrom("CutFlowTable")) {
    //      CutFlowTable *c = static_cast<CutFlowTable*> (obj);
    //      
    //      html << "<p><h2>" << key->GetName() << "</h2>" << endl;
    //
    //      CFTPrinterHTML txt (html);
    //      f->cd();
    //      c->PrintGlobal (txt, "All Events", "");
    //      html << "</p>" << endl;
    //    }

    else if (obj->IsA()->InheritsFrom("TCanvas")) {
      TCanvas *cnv = static_cast<TCanvas*>(obj);

      cnv->Draw();
      cnv->SaveAs(path + "/" + key->GetName() + ".eps");
      if (UsePstoimg) {
	sprintf(command, "pstoimg -type=gif %s &> /dev/null",(path + "/" + key->GetName() + ".eps").Data());
	if (system(command) != 0) {
	  cout<<"Could not convert to gif: "<<path + "/" + key->GetName() + ".eps"<<endl;
	  abort();
	}
      } else cnv->SaveAs(path + "/" + key->GetName() + ".gif");

      cnv->Close();

      html << "<p><a href=\"" << key->GetName() << ".eps\">";
      html << "<img src=\"" << key->GetName() << ".gif\">";
      html << "</a> <br> " << key->GetName() << ".gif </p>" << endl;								   
    }

    else if (obj->IsA()->InheritsFrom("TH1") && !(obj->IsA()->InheritsFrom("TH2"))) {
      TH1 *h = static_cast<TH1*> (obj);

      c_h1->cd();
//.........这里部分代码省略.........
开发者ID:arangb,项目名称:usercode,代码行数:101,代码来源:make_all_plot_html.C

示例8: Draweff

void Draweff(){
	int sth=0, Gth=0;
	TFile *f = TFile::Open(outG);
	if(sth==0){TString dirname = "std";}
        else if(sth==1){TString dirname ="Gri055";}
        else {TString dirname ="Gri101";}
	gStyle->SetErrorX(0);
	TString name;
        TObjString* dataname = (TObjString*)f->Get(Form("dataname"));
        TObjString* histoname = (TObjString*)f->Get(Form("histoname"));
        if(Gth==0)
                name = "G0";
        else if(Gth<nGlau)
                name = Form("Glau_%d",Gth);
        else
                name = Form("bin_%d",Gth-nGlau+1);
        TObjString* Glaubername = (TObjString*)f->Get(Form("%s/%s/Glaubername",dirname.Data(),name.Data()));
        TVectorD* xmin = (TVectorD*)f->Get(Form("%s/%s/xmin",dirname.Data(),name.Data()));
        TVectorD* xmax = (TVectorD*)f->Get(Form("%s/%s/xmax",dirname.Data(),name.Data()));
        TVectorD* mubest = (TVectorD*)f->Get(Form("%s/%s/mubest",dirname.Data(),name.Data()));
        TVectorD* kbest = (TVectorD*)f->Get(Form("%s/%s/kbest",dirname.Data(),name.Data()));
        TVectorD* Ndf = (TVectorD*)f->Get(Form("%s/%s/Ndf",dirname.Data(),name.Data()));
        TVectorD* chis = (TVectorD*)f->Get(Form("%s/%s/chis",dirname.Data(),name.Data()));
	TVectorD *kpoint = (TVectorD*)f->Get(Form("%s/%s/kpoint",dirname.Data(),name.Data()));
	TFile *fdata = TFile::Open(dataname->GetString());
	TH1D *histo_obs = (TH1D*)fdata->Get(histoname->GetString());
	histo_obs->Sumw2();
	TFile *fGlauber = TFile::Open(Glaubername->GetString());
        int binnum = histo_obs->GetNbinsX();
        double Minx = histo_obs->GetXaxis()->GetXmin();
        double Maxx = histo_obs->GetXaxis()->GetXmax();
	double binsize = (Double_t)(Maxx-Minx)/binnum;
        int xbinmin=(int)(((*xmin)[0]-Minx)/binsize);
        int xbinmax=(int)(((*xmax)[0]-Minx)/binsize);
	TH1D *histo_exp = new TH1D("histo_exp","Simulated distribution;Multiplicity;Event Fraction",binnum,Minx,Maxx);
	histo_exp->Sumw2();
	Int_t ibin;
		
	TH1D *histo_obs_norm = (TH1D*)histo_obs->Clone();
        histo_obs_norm->Scale(1/histo_obs->Integral(xbinmin,xbinmax));

	TF1 *NBD_fun = new 
	TF1("NBD_fun","[0]*TMath::Gamma(x+[1])/(TMath::Gamma(x+1)*TMath::Gamma([1]))*TMath::Power([2]/[1],x)/TMath::Power([2]/[1]+1,x+[1])",0,100);
	NBD_fun->SetParameter(0,1);	//[0]: Normalized constant
	NBD_fun->SetParameter(1,(*kbest)[0]);	//[1]: k value
	NBD_fun->SetParameter(2,(*mubest)[0]);	//[2]: mu value
		
	TTree *t = (TTree*) fGlauber->Get("nt_Pb_Pb");
	Long_t Nevent;

	Nevent = (Long_t) t->GetEntries();

	Long_t Ev;	Int_t Bino;	Double_t Para, Bi_Para, Mult;
	Float_t Ncoll;
	t->SetBranchAddress("Ncoll",&Ncoll);

	for(Ev=0; Ev<Nevent; Ev++){
		if(Ev%100000==0)	 cout<<"Have run "<<Ev<<" events"<<endl;
		t->GetEntry(Ev);
		Para = 0; //make sure that Para doesn't accumulate through loops
		for(Bino=0; Bino<Ncoll; Bino++){
                         Bi_Para = NBD_fun->GetRandom();
                         Para += Bi_Para;
		}	
		histo_exp->Fill(Para);
	}
	Double_t SumEvent, scale;
	SumEvent = histo_exp->Integral(xbinmin,xbinmax);
	scale = 1/SumEvent;
	TH1D *histo_exp_norm = (TH1D*) histo_exp->Clone();
	histo_exp_norm->Scale(scale);

	TCanvas *c1 = new TCanvas();
        gStyle->SetOptStat(kFALSE);

	double hfbin[]={0,1,2,3,4,6,8,10,13,16,20,25,30,40,55,70,90};
	int nhfbin = 16;
	rehisto_obs_norm = (TH1D*)histo_obs_norm->Rebin(nhfbin,"rehisto_obs_norm",hfbin);
	normalizeByBinWidth(rehisto_obs_norm);
	rehisto_exp_norm = (TH1D*)histo_exp_norm->Rebin(nhfbin,"rehisto_exp_norm",hfbin);
	normalizeByBinWidth(rehisto_exp_norm);
	TH1D* ratio = (TH1D*)rehisto_obs_norm->Clone("ratio");
	ratio->Divide(rehisto_exp_norm);
        ratio->SetMaximum(1.2);
        ratio->SetMinimum(0);
        ratio->GetXaxis()->SetTitle("HF #Sigma E_{T}");
       	ratio->GetYaxis()->SetTitle("ratio");
/*
开发者ID:XuQiao,项目名称:HI,代码行数:88,代码来源:Draweff.C

示例9: scanDirectory

void scanDirectory(const char *dirname) 
{
   TDirectoryIter iter(dirname);
   const char *filename = 0;
   TString ent;
   TString file;
   TString html;
   html.Form(gPreamble,dirname,dirname);
   
   TList dirList;
   TList fileList;
 
   while( (filename=iter.Next()) )
   {
      if (filename[0]!='.') {
         ent.Form("%s/%s", dirname, filename);
         FileStat_t st;
         gSystem->GetPathInfo(ent.Data(), st);
         if (R_ISDIR(st.fMode)) {
            //fprintf(stderr,"Seeing directory %s\n",ent.Data());
            scanDirectory(ent.Data());
            dirList.Add(new TObjString(filename));
         } else {
            size_t len = strlen(filename);
            if (len > 8 && strncmp(filename,"pt_",3)==0 && strncmp(filename+len-5,".root",5)==0) {
               //fprintf(stderr,"Seeing file %s\n",ent.Data());
               file = filename;
               file[len-5]='\0';
               fileList.Add(new TObjString(file));
            }
         }
      }
   }
   dirList.Sort();
   fileList.Sort();
   TIter next(&dirList);
   TObjString *obj;
   html += "<table width=\"500\">\n";
   html += gLine;
   html += gParentDir;
   while ( (obj = (TObjString*)next()) ) {
      html += TString::Format(gDirFmt,obj->GetName(),obj->GetName());
   }
   html += gLine;
   
   if (!fileList.IsEmpty()) {

      next = &fileList;
      while ( (obj = (TObjString*)next()) ) {
         html += "<tr>";
         html += TString::Format(gFiles,obj->GetName(),obj->GetName(),obj->GetName(),obj->GetName());
         obj = (TObjString*)next();
         if (obj) {
            html += TString::Format(gFiles,obj->GetName(),obj->GetName(),obj->GetName(),obj->GetName());
         } else {
            html += "<td></td></tr>";
            break;
         }
      }
      html += gLine;
   }
   html += "</table>\n";
   dirList.Delete();
   fileList.Delete();
   html += "</body>\n";
   html += "</html>\n";
   ent.Form("%s/pt_index.html",dirname);
   FILE *output = fopen(ent.Data(),"w");
   fprintf(output,"%s",html.Data());
   fclose(output);
}
开发者ID:asmagina1995,项目名称:roottest,代码行数:71,代码来源:pt_createIndex.C

示例10: TriggerInputsForMuonEventCuts

void TriggerInputsForMuonEventCuts ( TString runListFilename, TString selectedInputs="", TString defaultStorage = "raw://" )
{
  AliCDBManager::Instance()->SetDefaultStorage(defaultStorage.Data());
  TObjArray inputsList;
  inputsList.SetOwner();
  
  TObjArray* selectedInputsList = selectedInputs.Tokenize(",");

  // Read input run list
  ifstream inFile(runListFilename.Data());
  TString srun = "";
  if ( inFile.is_open() ) {
    while ( ! inFile.eof() ) {
      srun.ReadLine(inFile,kFALSE);
      if ( ! srun.IsDigit() ) continue;
      
      // For each run, read trigger inputs from OCDB
      Int_t runNumber = srun.Atoi();
      AliCDBManager::Instance()->SetRun(runNumber);
      
      // Get trigger class configuration
      AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/CTP/Config");
      if ( ! entry ) continue;
      
      THashList* runInputs = new THashList();
      runInputs->SetOwner();
      runInputs->SetUniqueID((UInt_t)runNumber);
      AliTriggerConfiguration* trigConf = (AliTriggerConfiguration*)entry->GetObject();
      const TObjArray& trigInputsArray = trigConf->GetInputs();
      AliTriggerInput* trigInput = 0x0;
      TIter next(&trigInputsArray);
      while ( ( trigInput = static_cast<AliTriggerInput*>(next()) ) ) {
        if ( selectedInputsList->GetEntriesFast() > 0 && ! selectedInputsList->FindObject(trigInput->GetName()) ) continue;
        Int_t inputId = (Int_t)TMath::Log2(trigInput->GetMask());
        TObjString* currInput = new TObjString(trigInput->GetName());
        currInput->SetUniqueID(inputId);
        runInputs->Add(currInput);
      }
      inputsList.Add(runInputs);
    }
    inFile.close();
  }
  delete selectedInputsList;
  
  // Loop on the trigger inputs
  // and group runs with an equal list of inputs
  Int_t nentries = inputsList.GetEntries();
  TArrayI checkMask(nentries);
  checkMask.Reset(1);
  for ( Int_t irun=0; irun<nentries; irun++ ) {
    if ( checkMask[irun] == 0 ) continue;
    THashList* currList = static_cast<THashList*>(inputsList.At(irun));
    TString runRange = Form("Run range: %u", currList->GetUniqueID());
    for ( Int_t jrun=irun+1; jrun<nentries; jrun++ ) {
      if ( checkMask[jrun] == 0 ) continue;
      THashList* checkList = static_cast<THashList*>(inputsList.At(jrun));
      Bool_t isDifferent = kFALSE;
      for ( Int_t itrig=0; itrig<currList->GetEntries(); itrig++ ) {
        TObjString* currInput = static_cast<TObjString*>(currList->At(itrig));
        TObject* checkInput = checkList->FindObject(currInput->GetName());
        if ( ! checkInput || checkInput->GetUniqueID() != currInput->GetUniqueID() ) {
          isDifferent = kTRUE;
          break;
        }
      } // loop on trigger inputs
      if ( isDifferent ) continue;
      checkMask[jrun] = 0;
      runRange += Form(",%u", checkList->GetUniqueID());
    } // loop on runs
    
    TString outString = "\nSetTrigInputsMap(\"";
    for ( Int_t itrig=0; itrig<currList->GetEntries(); itrig++ ) {
      TObjString* currInput = static_cast<TObjString*>(currList->At(itrig));
      outString += Form("%s:%u,",currInput->GetString().Data(), currInput->GetUniqueID());
    }
    outString.Append("\");\n");
    outString.ReplaceAll(",\"","\"");
    outString += runRange;
    printf("%s\n", outString.Data());
  } // loop on runs
}
开发者ID:benjaminaudurier,项目名称:Macro,代码行数:81,代码来源:TriggerInputsForMuonEventCuts.C

示例11: MakeSnapshot

void MakeSnapshot(Int_t run, const char* defStorage, TMap* specStorages, const char* snapshotFileName)
{
    AliCDBManager *cdb = AliCDBManager::Instance();
    cdb->SetDefaultStorage(defStorage);
    cdb->SetRun(run);

    TIter iter(specStorages->GetTable());
    TPair *pair = 0;
    while((pair = dynamic_cast<TPair*> (iter.Next()))){
	TObjString* caltype = dynamic_cast<TObjString*> (pair->Key());
	TObjString* specstor= dynamic_cast<TObjString*> (pair->Value());
	if (caltype && specstor)
	    //TString calType = caltype->GetString();
	    //TString specStor = specstor->GetString();
	    //cdb->SetSpecificStorage(calType.Data(),specStor.Data());
	    cdb->SetSpecificStorage(caltype->GetString().Data(),specstor->GetString().Data());
	else
	    //AliFatal("Error reading info for specific storage")
	    Printf("Error reading info for specific storage");
    }

    // ********************************** GRP ******************************************
    cdb->Get("GRP/CTP/Config");
    cdb->Get("GRP/Calib/LHCClockPhase");
    cdb->Get("GRP/GRP/Data");
    cdb->Get("GRP/Align/Data");
    cdb->Get("GRP/Calib/MeanVertexSPD");
    cdb->Get("GRP/Calib/MeanVertex");
    cdb->Get("GRP/Calib/MeanVertexTPC");
    cdb->Get("GRP/Calib/CosmicTriggers");
    cdb->Get("GRP/CTP/Scalers");
    cdb->Get("GRP/CTP/CTPtiming");
    cdb->Get("GRP/CTP/TimeAlign");
    cdb->Get("GRP/GRP/LHCData");
    cdb->Get("GRP/Calib/RecoParam");

    // ********************************** ALL ******************************************
    TString detStr = ("ITS TPC TRD TOF PHOS HMPID EMCAL MUON ZDC PMD T0 VZERO");
    //TString detStr = ("ITS MUON TPC");
    TObjArray *arr = detStr.Tokenize(' ');
    for (Int_t iDet=0; iDet<arr->GetEntries(); iDet++) {
	TObjString *detOStr = dynamic_cast<TObjString*>(arr->At(iDet));
	AliCDBManager::Instance()->GetAll(Form("%s/Calib/*",detOStr->GetString().Data()));
	AliCDBManager::Instance()->Get(Form("%s/Align/Data",detOStr->GetString().Data()));
    }

    // ******************************** TRIGGER ****************************************
    // Temporary fix - one has to define the correct policy in order
    // to load the trigger OCDB entries only for the detectors that
    // in the trigger or that are needed in order to put correct
    // information in ESD
    AliCDBManager::Instance()->GetAll("TRIGGER/*/*");

    // ********************************** HLT ******************************************
    // cdb->Get("HLT/ConfigHLT/esdLayout");
    // cdb->Get("HLT/Calib/StreamerInfo");

    TMap* entriesMap = const_cast<TMap*>(cdb->GetEntryCache());
    Printf("\nentriesMap has %d entries!\n", entriesMap->GetEntries());

    TList* entriesList = const_cast<TList*>(cdb->GetRetrievedIds());
    Printf("\nentriesList has %d entries!\n", entriesList->GetEntries());

    //TString filename(TString::Format("CDBsnapshot_Run%d.root",run));
    TString filename(snapshotFileName);
    TFile *f = new TFile(filename.Data(),"recreate");
    f->cd();
    f->WriteObject(entriesMap,"entriesMap");
    f->WriteObject(entriesList,"entriesList");
    f->Close();
    entriesMap->SetOwnerKeyValue(kFALSE,kFALSE);
    entriesList->SetOwner(kFALSE);
}
开发者ID:alisw,项目名称:AliRoot,代码行数:73,代码来源:MakeCDBSnapshot.C

示例12: build

void build(const char *filename,const char *lib = 0, const char *obj = 0) 
{
   if (obj!=0 && strlen(obj) ) {
      TString s = gSystem->GetMakeSharedLib();
      TString r(" $ObjectFiles ");
      r.Append(obj);
      s.ReplaceAll(" $ObjectFiles",r);
      //gDebug = 5;
      gSystem->SetMakeSharedLib(s);
   }
   if (lib && strlen(lib)) {
      TString liblist(lib);
      TObjArray *libs = liblist.Tokenize(" ");
      TIter iter(libs);
      TObjString *objstr;

      TString s = gSystem->GetMakeSharedLib();
      TString what("..nothing..");
      if (s.Contains("$DepLibs")) {
         what = " $DepLibs";
      } else {
         what = " $LinkedLibs";
      }
      TString libstolink(" ");
      while ( (objstr=(TObjString*)iter.Next()) ) {
         gSystem->Load(objstr->String());
         TString libfile( gSystem->GetLibraries(objstr->String(),"DSL",kFALSE));
         libstolink.Append(libfile);
         libstolink.Append(" ");
      }
      libstolink.Append(what);
      s.ReplaceAll(what,libstolink);
      gSystem->SetMakeSharedLib(s);
   }
#ifdef __CLING__
   TString r;
#ifdef  ClingWorkAroundCallfuncAndInline
   r.Append(" -DClingWorkAroundCallfuncAndInline ");
#endif
#ifdef  ClingWorkAroundCallfuncAndVirtual
   r.Append(" -DClingWorkAroundCallfuncAndVirtual ");
#endif
#ifdef ClingWorkAroundJITandInline
   r.Append(" -DClingWorkAroundJITandInline ");
#endif
#ifdef ClingWorkAroundCallfuncAndReturnByValue
   r.Append(" -DClingWorkAroundCallfuncAndReturnByValue ");
#endif
#ifdef ClingWorkAroundNoPrivateClassIO
   r.Append(" -DClingWorkAroundNoPrivateClassIO ");
#endif
   if (r.Length()) {
      r.Append(" $IncludePath");
      TString s = gSystem->GetMakeSharedLib();
      s.ReplaceAll(" $IncludePath",r);
      gSystem->SetMakeSharedLib(s);
   }
#endif
      
#if defined(_WIN32) && !defined(__CYGWIN__)
   TString fname(filename);
   if (filename[0]=='/') {
     // full path name we need to turn it into a windows path
     fname = gSystem->GetFromPipe(TString::Format("cygpath -w %s",filename));
   }
   fprintf(stderr,"from %s to %s\n",filename,fname.Data());
   int result = gSystem->CompileMacro(fname,"kc");
#else
   int result = gSystem->CompileMacro(filename,"kc");
#endif
   if (!result) gApplication->Terminate(1);
}
开发者ID:jlsalmon,项目名称:roottest,代码行数:72,代码来源:build.C

示例13: main

int main(int argc, char* argv[]){
	if (argc != 6){
    		std::cout << "wrong number of arguments: usage ./topDataClass_doAnalysis <file name> <mod #> <row #> <col #> <ch #>" << std::endl;
    		return 0;
  	}

	//define application object
	theApp = new TApplication("App", &argc, argv);
	TString inputFileName = theApp->Argv()[1];
	std::cout << "Input file name "  << inputFileName << std::endl;

	//create target6 interface object
	topDataClass *data = new topDataClass();

	//specify channel of interest
	int inMod = atoi(theApp->Argv()[2]);
	int inRow = atoi(theApp->Argv()[3]);
	int inCol = atoi(theApp->Argv()[4]);
	int inCh = atoi(theApp->Argv()[5]);
	data->setAnalysisChannel( inMod, inRow, inCol, inCh );

	//specify timing marker channel
	data->setTimingMarkerChannel( 0, 0, 1, 2 );

	//specify time window
	data->windowTime = windowTime;

	//open summary tree file
	data->openSummaryTree(inputFileName);

	//create output file
  	TObjArray* strings = inputFileName.Tokenize("/");
  	TObjString* objstring = (TObjString*) strings->At(strings->GetLast());
  	TString inputFileNameBase(objstring->GetString());
	TString outputFileName = "output_topDataClass_doAnalysis_doublePulseSampleDTFit_";
  	outputFileName += inMod;
  	outputFileName += "_";
  	outputFileName += inRow;
  	outputFileName += "_";
  	outputFileName += inCol;
  	outputFileName += "_";
  	outputFileName += inCh;
  	outputFileName += "_";
  	outputFileName += inputFileNameBase;
  	//outputFileName += ".root";
  	std::cout << " outputFileName " << outputFileName << std::endl;
  	outputFile = new TFile( outputFileName , "RECREATE");

	//initialize histograms
	initializeGlobalHistograms();

	//initialize tree branches
	data->setTreeBranches();

	//load pulse info into arrays
	data->selectPulsesForArray();

	//loop over selected events, apply corrections histogram pulse time distributions
	//monitor pulse time vs event #
  	gPulseTimeVsEventNum = new TGraphErrors();
  	for(int entry = 0; entry < data->numUsed; entry++) {
		//skip events not in arrays
  		if( entry >= maxNumEvt )
			continue;

		double pulseTime = data->measurePulseTimeArrayEntry(entry,1);
		double pulseHeight = data->adc_0_A[entry];
		int smpBinNumIn128Array = data->getSmpBinNumIn128Array(entry);
		double smpPos =	data->getSmpPos(entry);

		//apply analysis cuts
		//if( smpBinNumIn128Array >= 127 )
		//	continue;
		//measure pulse time vs event #
		gPulseTimeVsEventNum->SetPoint( gPulseTimeVsEventNum->GetN() , data->eventNum_A[entry],  pulseTime );
		//cut on event #
		if( data->eventNum_A[entry] < 0 )
			continue;

		//histogram selected pulse distributions
		hPulseHeightInitial->Fill( data->adc_0_A[entry] );
		hPulseTimeInitial->Fill( pulseTime );
		hPulseSampleInitial->Fill(data->smp_0_A[entry]);
       		hPulseSmp128Initial->Fill(smpBinNumIn128Array);
		hPulseTimeVsSmp128Initial->Fill(smpBinNumIn128Array, pulseTime );
		hPulseTimeVsSmp128PosInitial->Fill(smpBinNumIn128Array + smpPos, pulseTime );
		hPulseTimeVsHeightInitial->Fill(pulseHeight, pulseTime );
		hPulseTimeVsFTSWInitial->Fill(data->ftsw_A[entry], pulseTime );
   		hFTSWVsSmp128Initial->Fill(smpBinNumIn128Array, data->ftsw_A[entry]);
	}
	
	//loop over selected events, measure time difference between timing marker and selected channel pulses
	gTest = new TGraphErrors();
	data->measurePulseMarkerTimeDifferenceDistribution(hPulseTimeMarkTimeDiffInitial,hPulseTimeMarkTimeDiffVsMarkSmpBinNumInitial );

	//run fit analysis
	doDoublePulseFit(data);

	//write output file
	writeOutputFile();
//.........这里部分代码省略.........
开发者ID:everil456,项目名称:idlab-scrod,代码行数:101,代码来源:topDataClass_doAnalysis_doublePulseSampleDTFit.cpp

示例14: m0_vs_m12_nofloat

const char*
m0_vs_m12_nofloat(const char* textfile = 0, TH2D* inputHist = 0, const char* rootfile = "m0m12_nofloat.root", TString id1="m0",TString id2="m12", int   nbinsX=21,int nbinsY=17, float minX=20,float maxX=860, float minY=92.5, float maxY=347.5)
{
   // set combination style and remove existing canvas'
   CombinationGlob::Initialize();

   initialize();

   // get the harvested tree
   TTree* tree = harvesttree( textfile!=0 ? textfile : 0 );
   if (tree==0) {
     cout << "Cannot open list file. Exit." << endl;
     return "";
   }

   // store histograms to output file
   const char* outfile(0);
   if (textfile!=0) {
     TObjArray* arr = TString(textfile).Tokenize("/");
     TObjString* objstring = (TObjString*)arr->At( arr->GetEntries()-1 );
     outfile = Form("%s%s",objstring->GetString().Data(),".root");
     delete arr;
   } else {
     outfile = rootfile;
   }

   cout << "Histograms being written to : " << outfile << endl;
   TFile* output = TFile::Open(outfile,"RECREATE");
   output->cd();

   TH2D* hist = nullptr;
   if (inputHist!=NULL){
     TH2D *clonehclPmin2=(TH2D*)inputHist->Clone();
     hist = DrawUtil::triwsmooth( tree, "p1:m12:m0", "hclPmin2" , "Observed CLsplusb", "p1>=0 && p1<=1", clonehclPmin2 );}
   else{
     hist = DrawUtil::triwsmooth( tree, "p1:m12:m0", "hclPmin2" , "Observed CLsplusb", "p1>=0 && p1<=1", inputHist);}


   if (hist!=0) {
     hist->Smooth();
     hist->Write();
     delete hist; hist=0;
   } else {
     cout << "Cannot make smoothed significance histogram. Exit." << endl;
   }



   TH2D* sigp1 = nullptr;
   if (inputHist!=NULL){
     TH2D *clonesigp1=(TH2D*)inputHist->Clone();
     sigp1 = DrawUtil::triwsmooth( tree, "StatTools::GetSigma(p1):m12:m0", "sigp1" , "One-sided significance of CLsplusb", "(p1>0 && p1<=1)", clonesigp1 );}
   else{
     sigp1 = DrawUtil::triwsmooth( tree, "StatTools::GetSigma(p1):m12:m0", "sigp1" , "One-sided significance of CLsplusb", "(p1>0 && p1<=1)", inputHist );}

   if (sigp1!=0) {
     sigp1->Smooth();
     sigp1->Write();
     delete sigp1; sigp1=0;
   } else {
     cout << "Cannot make smoothed significance histogram. Exit." << endl;
   }

   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   TH2D* p0exp = nullptr;
   if (inputHist!=NULL){
      TH2D *clonep0exp=(TH2D*)inputHist->Clone();
      p0exp = DrawUtil::triwsmooth( tree, "StatTools::GetSigma(p0exp):m12:m0", "p0exp" , "One-sided significance p0 (exp)", "(p0exp>0 && p0exp<=1)", clonep0exp );}
   else{
      p0exp = DrawUtil::triwsmooth( tree, "StatTools::GetSigma(p0exp):m12:m0", "p0exp" , "One-sided significance p0 (exp)", "(p0exp>0 && p0exp<=1)", inputHist );}

   if (p0exp!=0) {
      p0exp->Smooth();
      p0exp->Write();
      delete p0exp; p0exp=0;
   } else {
      cout << "Cannot make smoothed significance histogram. Exit." << endl;
   }
   TH2D* p0expraw = nullptr;
   if (inputHist!=NULL){
      TH2D *clonep0expraw=(TH2D*)inputHist->Clone();
      p0expraw = DrawUtil::triwsmooth( tree, "p0exp:m12:m0", "p0expraw" , "One-sided significance p0 (exp)", "(p0exp>0 && p0exp<=1)", clonep0expraw );}
   else{
      p0expraw = DrawUtil::triwsmooth( tree, "p0exp:m12:m0", "p0expraw" , "One-sided significance p0 (exp)", "(p0exp>0 && p0exp<=1)", inputHist );}

   if (p0expraw!=0) {
      p0expraw->Smooth();
      p0expraw->Write();
      delete p0expraw; p0expraw=0;
   } else {
      cout << "Cannot make smoothed significance histogram. Exit." << endl;
   }

   // cls:clsexp:clsu1s:clsd1
   TH2D* p1clsf = nullptr;

   if (inputHist!=NULL){
     TH2D *clonep1clsf=(TH2D*)inputHist->Clone();
     p1clsf = DrawUtil::triwsmooth( tree, "CLs:m12:m0", "sigp1clsf" , "Observed CLs", "p1>0 && p1<=1", clonep1clsf );}
   else{
//.........这里部分代码省略.........
开发者ID:lawrenceleejr,项目名称:ZeroLeptonAnalysis,代码行数:101,代码来源:m0_vs_m12_nofloat.C

示例15: plotLimit


//.........这里部分代码省略.........
    ExpLimitm1[i]/= XSecScaleFactor;
    ExpLimit  [i]/= XSecScaleFactor;
    ExpLimitp1[i]/= XSecScaleFactor;
    ExpLimitp2[i]/= XSecScaleFactor;
    }
    ThXSec[i]    *= XSecScaleFactor;
  }

    
  //limits in terms of signal strength
  TCanvas* c = new TCanvas("c", "c",600,600);
  TH1F* framework = new TH1F("Graph","Graph",1,15,70);
  framework->SetStats(false);
  framework->SetTitle("");
  framework->GetXaxis()->SetTitle("A boson mass [GeV]");
  framework->GetYaxis()->SetTitleOffset(1.70);
  if(strengthLimit){
  framework->GetYaxis()->SetTitle("#mu = #sigma_{95%} / #sigma_{th}");
  framework->GetYaxis()->SetRangeUser(5E-2,5E1);
  c->SetLogy(true);
  }else{
  framework->GetYaxis()->SetTitle("#sigma_{95%} (fb)");
  framework->GetYaxis()->SetRangeUser(1E-1,1E3);
  c->SetLogy(true);
  }
  framework->Draw();

  TGraph* TGObsLimit   = new TGraph(N,MassAxis,ObsLimit);  TGObsLimit->SetLineWidth(2);
  TGraph* TGExpLimit   = new TGraph(N,MassAxis,ExpLimit);  TGExpLimit->SetLineWidth(2); TGExpLimit->SetLineStyle(2);
  TCutG* TGExpLimit1S  = GetErrorBand("1S", N, MassAxis, ExpLimitm1, ExpLimitp1);  
  TCutG* TGExpLimit2S  = GetErrorBand("2S", N, MassAxis, ExpLimitm2, ExpLimitp2);  TGExpLimit2S->SetFillColor(5);
  TGraph* THXSec        = new TGraph(N,MassAxis,ThXSec); THXSec->SetLineWidth(2); THXSec->SetLineStyle(1); THXSec->SetLineColor(4);


  TGExpLimit->SetLineColor(2);  TGExpLimit->SetLineStyle(1);
  TGObsLimit->SetLineWidth(2);  TGObsLimit->SetMarkerStyle(20);
  TGExpLimit2S->Draw("fc same");
  TGExpLimit1S->Draw("fc same");
  if(!blind) TGObsLimit->Draw("same CP");
  TGExpLimit->Draw("same C");

  if(strengthLimit){
     TLine* SMLine = new TLine(framework->GetXaxis()->GetXmin(),1.0,framework->GetXaxis()->GetXmax(),1.0);
     SMLine->SetLineWidth(2); SMLine->SetLineStyle(1); SMLine->SetLineColor(4);      
     SMLine->Draw("same C");
  }else{
     THXSec->Draw("same C");
  }


  TPaveText *pave = new TPaveText(0.1,0.96,0.99,0.99,"NDC");
  char LumiLabel[1024];
  if(energy<9){  sprintf(LumiLabel,"CMS preliminary,  #sqrt{s}=%.0f TeV, #scale[0.5]{#int} L=%6.1ffb^{-1} - %20s",energy, luminosity,legendName.Data());
  }else{         sprintf(LumiLabel,"CMS preliminary,  #sqrt{s}=%.0f TeV #scale[0.5]{#int} L=%6.1ffb^{-1}, #sqrt{s}=%.0f TeV #scale[0.5]{#int} L=%6.1ffb^{-1}",7.0,5.0,8.0,19.7);
  }
  pave->SetBorderSize(0);
  pave->SetFillStyle(0);
  pave->SetTextFont(42);
  TObjArray* tokens = (TString(LumiLabel)).Tokenize("\\\\");
  int nt = tokens->GetEntries();
  for(int it=0; it<nt; ++it){
    TObjString * t = (TObjString *)tokens->At(it);
    pave->AddText(t->GetString());
  }
  pave->Draw("same");


  TLegend* LEG = new TLegend(0.55,0.75,0.85,0.95);
  LEG->SetHeader("Signal XSec x 1000");
  LEG->SetFillColor(0);
  LEG->SetFillStyle(0);
  LEG->SetTextFont(42);
  LEG->SetBorderSize(0);
  LEG->AddEntry(THXSec  , "TH prediction"  ,"L");
  LEG->AddEntry(TGExpLimit  , "median expected"  ,"L");
  LEG->AddEntry(TGExpLimit1S  , "expected #pm 1#sigma"  ,"F");
  LEG->AddEntry(TGExpLimit2S  , "expected #pm 2#sigma"  ,"F");
  if(!blind) LEG->AddEntry(TGObsLimit  , "observed"  ,"LP");
  LEG->Draw();
  c->RedrawAxis();
  c->SaveAs(outputDir+"Limit.png");
  c->SaveAs(outputDir+"Limit.C");
  c->SaveAs(outputDir+"Limit.pdf"); 


  //save a summary of the limits
  FILE* pFileSum = fopen((outputDir+"LimitSummary").Data(),"w");
  for(int i=0;i<N;i++){
    fprintf(pFileSum, "$%8.6E$ & $%8.6E$ & $[%8.6E,%8.6E]$ & $[%8.6E,%8.6E]$ & $%8.6E$ & Th=$%8.6E$\\\\\\hline\n",MassAxis[i], ExpLimit[i], ExpLimitm1[i], ExpLimitp1[i], ExpLimitm2[i],  ExpLimitp2[i], ObsLimit[i], ThXSec[i]);
    if(int(MassAxis[i])%50!=0)continue; printf("%f ",ObsLimit[i]);
  }printf("\n");
  fclose(pFileSum);

  pFileSum = fopen((outputDir+"LimitRange").Data(),"w");
  fprintf(pFileSum, "EXPECTED LIMIT --> ");                   printLimits(pFileSum,TGExpLimit, MassAxis[0], MassAxis[N-1]);
  if(!blind) fprintf(pFileSum, "OBSERVED LIMIT --> ");        printLimits(pFileSum,TGObsLimit, MassAxis[0], MassAxis[N-1]);
  fprintf(pFileSum, "Exp Limits for Model are: ");              for(int i=0;i<N;i++){if(int(MassAxis[i])%50!=0)continue; fprintf(pFileSum, "%f+-%f ",ExpLimit[i], (ExpLimitp1[i]-ExpLimitm1[i]))/2.0;}fprintf(pFileSum,"\n");
  if(!blind) { fprintf(pFileSum, "Obs Limits for Model are: "); for(int i=0;i<N;i++){if(int(MassAxis[i])%50!=0)continue; fprintf(pFileSum, "%f ",ObsLimit[i]);}fprintf(pFileSum,"\n"); }
  fclose(pFileSum);
}
开发者ID:amagitte,项目名称:2l2v_fwk,代码行数:101,代码来源:plotLimit.C


注:本文中的TObjString类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。