Exemple #1
0
void annotation(Float_t a=10, Float_t d=5, Float_t x=0, Float_t y=0, Float_t z=0)
{
   TEveManager::Create();

   // add a box in scene
   TEveBox* b = new TEveBox("Box", "Test Title");
   b->SetMainColor(kCyan);
   b->SetMainTransparency(0);
   b->SetVertex(0, x - a, y - a, z - a);
   b->SetVertex(1, x - a, y + a, z - a);
   b->SetVertex(2, x + a, y + a, z - a);
   b->SetVertex(3, x + a, y - a, z - a);
   b->SetVertex(4, x - a, y - a, z + a);
   b->SetVertex(5, x - a, y + a, z + a);
   b->SetVertex(6, x + a, y + a, z + a);
   b->SetVertex(7, x + a, y - a, z + a);
   gEve->AddElement(b);
   gEve->Redraw3D(kTRUE);
  
   // add overlay text
   TGLViewer* v = gEve->GetDefaultGLViewer();
   TDatime time;
   TGLAnnotation* ann = new TGLAnnotation(v, time.AsString(), 0.1, 0.9);
   ann->SetTextSize(0.1);// % of window diagonal

   // set timer to update text every second
   MyTimer* timer = new MyTimer(ann); 
   timer->SetTime(1000);
   timer->Reset();
   timer->TurnOn();
}
Exemple #2
0
void seism() {

   TStopwatch sw; sw.Start();
   //set time offset
   TDatime dtime;
   gStyle->SetTimeOffset(dtime.Convert());

   TCanvas *c1 = new TCanvas("c1","Time on axis",10,10,1000,500);
   c1->SetFillColor(42);
   c1->SetFrameFillColor(33);
   c1->SetGrid();

   Float_t bintime = 1; //one bin = 1 second. change it to set the time scale
   TH1F *ht = new TH1F("ht","The ROOT seism",10,0,10*bintime);
   Float_t signal = 1000;
   ht->SetMaximum( signal);
   ht->SetMinimum(-signal);
   ht->SetStats(0);
   ht->SetLineColor(2);
   ht->GetXaxis()->SetTimeDisplay(1);
   ht->GetYaxis()->SetNdivisions(520);
   ht->Draw();

   for (Int_t i=1;i<2300;i++) {
      //======= Build a signal : noisy damped sine ======
      Float_t noise  = gRandom->Gaus(0,120);
      if (i > 700) noise += signal*sin((i-700.)*6.28/30)*exp((700.-i)/300.);
      ht->SetBinContent(i,noise);
      c1->Modified();
      c1->Update();
      gSystem->ProcessEvents(); //canvas can be edited during the loop
   }
   printf("Real Time = %8.3fs, Cpu Time = %8.3fs\n",sw.RealTime(),sw.CpuTime());
}
Exemple #3
0
bool CreateTrainDir(AliAnalysisAlien *plugin, const TMap &lookup){
        //
        // Make train data dir name and JDL, C and sh file names
        //
        TObjArray infos;
        bool found = FindDataSample(lookup, infos);
        if(!found){
                printf("sample %s not found\n", g_sample.Data());
                return false;
        }
        TString type; GetData(infos, type, 2);

        // check whether the train dir is already provided or needs to be specified
        if(!g_train_dir.Length()){
                // Query number of train runs before
                const char *gridhome = gGrid->GetHomeDirectory();
                const char gridoutdir[256];
                sprintf(gridoutdir, "%sAnalysis_pPb/%s", gridhome, type.Data());
                TGridResult *trainruns = gGrid->Ls(gridoutdir);
                int nruns = trainruns->GetEntries();
                // Get Date and time
                TDatime time;
                g_train_dir = Form("%d_%d%02d%02d_%02d%02d", nruns, time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute());
        }
        
        plugin->SetGridWorkingDir(Form("Analysis_pPb/%s/%s", type.Data(), g_train_dir.Data()));
        plugin->SetJDLName(Form("TPCTOFanalysispPb_%s_%s.jdl", type.Data(), g_train_dir.Data()));
        plugin->SetExecutable(Form("TPCTOFanalysispPb_%s_%s.sh", type.Data(), g_train_dir.Data()));
        plugin->SetAnalysisMacro(Form("TPCTOFanalysispPb_%s_%s.C", type.Data(), g_train_dir.Data()));
        return true;
}
Exemple #4
0
Bool_t KVDataSetManager::CheckCacheStatus()
{
   //We check the status of the available datasets cache file.
   //We return kTRUE if the file exists & was last modified
   //less than fMaxCacheTime seconds ago.
   
   TString fullpath;
   Info("KVDataSetManager::CheckCacheStatus", "Checking for available datasets cache file...");
   if( KVBase::SearchKVFile( KVBase::GetWORKDIRFilePath(fCacheFileName), fullpath ) ){
      
      // file exists - how old is it ?
      FileStat_t file_info;
      gSystem->GetPathInfo( fullpath.Data(), file_info );
      TDatime file_date( file_info.fMtime );
      TDatime now;
      UInt_t file_age = now.Convert() - file_date.Convert();
      Info("KVDataSetManager::CheckCacheStatus", "...file found. It is %u seconds old", file_age);
      if( file_age < fMaxCacheTime ) {
         Info("KVDataSetManager::CheckCacheStatus", "Using cached file");
         return kTRUE;
      }
      else
         Info("KVDataSetManager::CheckCacheStatus", "File is too old (max time=%u). Update will be performed.", fMaxCacheTime);         
   }
   else
      Info("KVDataSetManager::CheckCacheStatus", "...no file found");
   return kFALSE;
}
Exemple #5
0
void drawDist(const char* infilename, const char* system, Int_t rWrite, Int_t rPerformance) {

        myOptions(0);

        gROOT->ForceStyle();
        gStyle->SetPalette(1.0);

        TDatime now;
        int iDate = now.GetDate();
        int iYear=iDate/10000;
        int iMonth=(iDate%10000)/100;
        int iDay=iDate%100;
        char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun",
                          "Jul","Aug","Sep","Oct","Nov","Dec"};
        char cStamp1[25],cStamp2[25];
        sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear);
        sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear);

        TFile *f = new TFile(infilename, "read");
        // TList *list = (TList*)f->Get("femtolist");

        // pseudorapidity vs pt
        TH2D* ypt =(TH2D*)f->Get(Form("EtaPtcutPass1%stpcM%i",system,0));

        int minMultBin = 0;
        int maxMultBin = 6;
        double EvMultall = 0;

        for(int i = minMultBin; i < maxMultBin; i++) {
                TH1D* yptN =(TH1D*)f->Get(Form("EtaPtcutPass1%stpcM%i",system,i));
                ypt->Add(yptN);
                //delete hEvMult;
        }

        TCanvas *c2 = new TCanvas("pseudorapidity vs pt", "pseudorapidity vs pt");
        c2->SetGridx();
        c2->SetGridy();
        c2->SetFillColor(10);
        ypt->GetXaxis()->SetTitle("#eta");
        ypt->GetYaxis()->SetTitle("p_{T}");
        ypt->GetXaxis()->SetTitleOffset(1.3);
        ypt->GetYaxis()->SetTitleOffset(1.3);
        ypt->GetXaxis()->SetRangeUser(-0.8,0.8);
        ypt->GetYaxis()->SetRangeUser(0.1,8.);
        ypt->Draw("colz");

        // https://wiki.bnl.gov/eic/index.php/ROOT#Moving_and_resizing_the_palette_axis_of_a_2D_histogram
        gPad->SetRightMargin( 0.12 ); // The default right margin is 0.1 i.e. 10% of the image width
//   TPaletteAxis* palette
//       = dynamic_cast<TPaletteAxis*>( myHistogram.GetListOfFunctions()->FindObject( "palette" ) );
//   if( palette ) {
//     palette->SetX1NDC( 0.86 ); // Start the palette 86 % of the way across the image
//     palette->SetX1NDC( 0.91 ); // End the palette 91% of the way across the image
//     gPad->Modified(); // Update with the new position
//   } // if

        postprocess(c2,Form("ypt%s",system),rWrite,rPerformance);

}
Exemple #6
0
void TT_generator::Report_progress()
{
  if (f_total_accepted==f_event_display || !f_keep_going) {
    TDatime dt;
    std::cout << "(" << dt.AsString() << ") total accepted: " << f_total_accepted << std::endl;
    f_event_display*=2;
  }
}   
Exemple #7
0
void TExpenser::calculate_balance() {

    fBalanceXMLParser -> selectMainNode();
    fBalanceXMLParser -> selectNode("entry");
    TString balance = fBalanceXMLParser -> getNodeContent("amount");
    fBalanceXMLParser -> selectNode("date");
    TString balance_year = fBalanceXMLParser -> getNodeContent("year");
    TString balance_month = fBalanceXMLParser -> getNodeContent("month");

    fLastStatusLabel -> SetText(balance_month+"/"+balance_year+": " + balance + " eur");

    // now calculate the current balance (last - expenses since the last)
    TDatime time;

    fXMLParser->selectMainNode();
    fXMLParser->selectNode("expense");
    Double_t expenses_since_last_status = 0;
    while (fXMLParser->getCurrentNode() != 0) {
        XMLNodePointer_t current_node = fXMLParser->getCurrentNode();

        fXMLParser -> selectNode("date");
        TString year = fXMLParser -> getNodeContent("year");
        TString month = fXMLParser -> getNodeContent("month");
        fXMLParser -> setCurrentNode(current_node);

        bool year_more_recent = (year.Atoi() > balance_year.Atoi());
        bool year_same = (year.Atoi() == balance_year.Atoi());
        bool month_more_recent = (month.Atoi()>=balance_month.Atoi());
        bool expense_more_recent_than_balance = (year_more_recent || (year_same && month_more_recent));
        if (  expense_more_recent_than_balance && fXMLParser -> getNodeContent("withdrawn") == "Yes" ) {
            expenses_since_last_status += fXMLParser -> getNodeContent("amount").Atof();
        }

        fXMLParser->selectNextNode("expense");
    }

    // calculate total income since last balance
    fIncomeXMLParser->selectMainNode();
    fIncomeXMLParser->selectNode("entry");
    Double_t income_since_last_status = 0;
    while (fIncomeXMLParser->getCurrentNode() != 0) {
        XMLNodePointer_t current_node = fIncomeXMLParser->getCurrentNode();

        fIncomeXMLParser -> selectNode("date");
        TString year = fIncomeXMLParser -> getNodeContent("year");
        TString month = fIncomeXMLParser -> getNodeContent("month");
        fIncomeXMLParser -> setCurrentNode(current_node);

        if ( ( (month.Atoi()>=balance_month.Atoi()) && (year.Atoi()==balance_year.Atoi()) ) || (year.Atoi()>balance_year.Atoi()) ) {
            income_since_last_status += fIncomeXMLParser -> getNodeContent("amount").Atof();
        }

        fIncomeXMLParser->selectNextNode("entry");
    }

    Double_t new_balance = balance.Atof() - expenses_since_last_status + income_since_last_status;
    fCurrentStatusLabel -> SetText(toStr(time.GetDay())+"/"+toStr(time.GetMonth())+"/"+toStr(time.GetYear())+": " + toStr(new_balance,2) + " eur");
}
Exemple #8
0
void DefaultSpecificStorage(AliCDBManager *man, Int_t mode)
{

  AliCDBEntry *cdbe = man->Get("GRP/GRP/Data");
  if (!cdbe) return NULL;
  AliGRPObject *grp = (AliGRPObject *)cdbe->GetObject();
  TDatime date = grp->GetTimeStart();
  Int_t year = date.GetYear();

  const Char_t *Raw      = Form("alien://Folder=/alice/data/%d/OCDB", year);
  const Char_t *Ideal    = "alien://Folder=/alice/simulation/2008/v4-15-Release/Ideal/";
  const Char_t *Residual = "alien://Folder=/alice/simulation/2008/v4-15-Release/Residual/";
  const Char_t *Full     = "alien://Folder=/alice/simulation/2008/v4-15-Release/Full/";
  // for AD hack 
  const Char_t *Raw2015  = "alien://Folder=/alice/data/2015/OCDB";
  
  // DEFAULT SPECIFIC OBJECTS 
  const Char_t *SpecificStorageList[][3] = {
    // path                    sim       rec
    //
    // ITS
    "ITS/Align/Data",          Ideal,    Residual, // ok
    "ITS/Calib/SPDSparseDead", Full,     Residual, // ok ?
    // TPC
    "TPC/Calib/ClusterParam",  Ideal,    Residual, // ok!
    "TPC/Calib/RecoParam",     Residual, Residual, // ok!
    "TPC/Calib/TimeGain",      Ideal,    Residual, // ok!
    "TPC/Calib/Correction",    Ideal,    Residual, // ok!
    // MUON
    "MUON/Align/Data",         Full,     NULL,     // ok!
    // ZDC
    "ZDC/Align/Data",          Ideal,    Ideal,    // ok
    "ZDC/Calib/Pedestals",     Ideal,    Ideal     // added (11.12.2017)
  };
  const Int_t nSpecificStorages = sizeof(SpecificStorageList) / (3 * sizeof(Char_t *));

  // set specific storages
  for (Int_t isto = 0; isto < nSpecificStorages; isto++) {
    if (SpecificStorageList[isto][mode+1]) {
      printf("Setting specific storage: %s -> %s\n", SpecificStorageList[isto][0], SpecificStorageList[isto][mode+1]);
      man->SetSpecificStorage(SpecificStorageList[isto][0], SpecificStorageList[isto][mode+1]);
    }
  }

  // EXTRA SPECIFIC OBJECTS IF NO DISTORTIONS
  if (!RecoParamWithTPCDistortions(man)) {
    printf("Not using TPC distortions, need extra specific storages\n");
    NoDistortionSpecificStorage(man, mode);
  }
  
  // Run-1 settings
  if (year < 2015) {
    man->SetSpecificStorage("AD/Calib/QAParam", Raw2015);
    const Char_t *muonHack[2] = {Ideal, Residual};
    man->SetSpecificStorage("MUON/Align/Data", muonHack[mode]);
  }

}
void mySelector::SlaveTerminate()
{
   // The SlaveTerminate() function is called after all entries or objects
   // have been processed. When running with PROOF SlaveTerminate() is called
   // on each slave server.
  cout<<"-------------End of Slave Job----------------"<<endl;
  tNow.Set();tNow.Print();
  cout<<"Number of Event: "<<fNumberOfEvents<<", elapsed time: "<<tNow.Convert()-tBegin.Convert()<<"seconds,rate: "<<float(fNumberOfEvents)/(tNow.Convert()-tBegin.Convert())<<endl;
}
Exemple #10
0
void MySelector::Begin(TTree * /*tree*/)
{
   // The Begin() function is called at the start of the query.
   // When running with PROOF Begin() is only called on the client.
   // The tree argument is deprecated (on PROOF 0 is passed).

   TString option = GetOption();

   // some time measurement
   tBegin.Set(); printf("*==* ---------- Begin of Job ----------");
   tBegin.Print();
}
//--------------------------------------------------------------------------------------------------
void plotSmartCacheRequests()
{
  TDatime  date;
  TString  dateTime = date.AsSQLString();
  TString  text;
  TString  save;
  long int durationHour  =              3600;
  long int durationDay   =         24 * 3600;
  long int durationWeek  =     7 * 24 * 3600;
  long int durationMonth = 4 * 7 * 24 * 3600;
  long int xStart, xStop;

  time_t t;
  time(&t);   
  long int time = (long int) t;

  // Access the database just once
  TString timeSeriesFile("requests.txt");
  TString dbAccess("/home/cmsprod/DynamicData/SmartCache/Client/dumpSmartCacheHistoryDb.py");
  // remove potentially existing old file
  TString rmDbInfo = TString(".! rm -f ")+timeSeriesFile;
  gROOT->ProcessLine(rmDbInfo.Data());
  // create fresh input file
  TString getDbInfo = TString(".! ") + dbAccess + TString(" -q");
  gROOT->ProcessLine(getDbInfo.Data());

  // All time
  xStart = 0;
  xStop  = time;
  plot(xStart, xStop, "All time at "+dateTime, "AllTime");

  // Month
  xStart = time - durationMonth;
  xStop  = time;
  plot(xStart, xStop, "Last month at "+dateTime, "LastMonth");

  // Week
  xStart = time - durationWeek;
  xStop  = time;
  plot(xStart, xStop, "Last week at "+dateTime, "LastWeek");

  // Day
  xStart = time - durationDay;
  xStop  = time;
  plot(xStart, xStop, "Last day at "+dateTime, "LastDay");

  // Hour
  xStart = time - durationHour;
  xStop = time;
  plot(xStart, xStop, "Last hour at "+dateTime, "LastHour");

  return;
}
void mySelector::Begin(TTree * /*tree*/)
{
   // The Begin() function is called at the start of the query.
   // When running with PROOF Begin() is only called on the client.
   // The tree argument is deprecated (on PROOF 0 is passed).

   TString option = GetOption();
   tBegin.Set();
   fNumberOfEvents = 0;
   cout<<"-------Begin of job-------"<<endl;
   tBegin.Print();
}
Exemple #13
0
//================================================
void toyMC_Cent()
{
  gStyle->SetOptStat(0);
  gStyle->SetOptFit(1);
  gStyle->SetStatY(0.9);                
  gStyle->SetStatX(0.9);  
  gStyle->SetStatW(0.2);                
  gStyle->SetStatH(0.2);

  myRandom = new TRandom3();
  TDatime *clock = new TDatime();
  myRandom->SetSeed(clock->GetTime());


  // Get true refMult vs Ncoll distribution
  TH2F *hRefMultVsNcoll = 0x0;

  // Get different efficiency curve vs. refMult
  const int nEff = 2;
  const int nMult = 2;
  TF1 *funcEff[nEff];
  funcEff[0] = new TF1("funcEff_0", "pol1",0,1000);
  funcEff[0]->SetParameters(0.9, -2e-4);
  funcEff[1] = new TF1("funcEff_1", "pol0",0,1000);
  funcEff[1]->SetParameter(0,0.6);
  TCanvas *c = new TCanvas("cEff","cEff",800,600);
  TH1F *hplot = new TH1F("hplot",";Mult;",100,0,1000);
  hplot->SetYTitle("Efficiency");
  hplot->DrawCopy();
  for(int i=0; i<2; i++)
    {
      funcEff[i]->SetLineColor(i+1);
      funcEff[i]->SetLineWidth(1.5);
      funcEff[i]->Draw("sames");
    }
  TPaveText *title = GetTitleText("TPC tracking efficiency");
  title->Draw();
  TLegend *leg = new TLegend(0.4,0.2,0.7,0.4);
  leg->SetBorderSize(0);
  leg->SetFillColor(0);
  leg->SetTextSize(0.04);
  leg->AddEntry(funcEff[0], "Efficiency 1", "L");
  leg->AddEntry(funcEff[1], "Efficiency 2", "L");
  leg->Draw();

  // Get ngTrack distribution to mimic efficiency distribution
  
  TH1F *hMcMult[nMult];
  
}
void mySelector::Terminate()
{
   // The Terminate() function is the last function to be called during
   // a query. It always runs on the client, it can be used to present
   // the results graphically or save the results to file.
  TString option = GetOption();
  TString output = "gr_";
  output += option;
  output += ".root";
  TFile *hfile = new TFile(output,"RECREATE","FONLL CCbar cross section");
  
  hfile->cd();
  const Int_t npoint = eventnumber;
  Float_t x[npoint];
  Float_t y[npoint];
  Float_t ylow[npoint];
  Float_t yup[npoint];
  for(int i=0;i<npoint;i++)
    {
      x[i] = Pt[i];
      y[i] = Central[i];
      ylow[i] = Down[i];
      yup[i] = Up[i];
    }
  //TGraph *grFONLLD0 = new TGraph(npoint,Pt,Central);
  TDirectoryFile *ratioErr = new TDirectoryFile(option,"ratio error of scale pp500 to pp200 ");
  ratioErr->SetName(option);
  ratioErr->Add(hRatio);
  TGraph *grFONLLRatio = new TGraph(npoint,x,y);
  grFONLLRatio->SetName("grFONLLRatio");
  TGraph *grFONLLRatio_u = new TGraph(npoint,x,yup);
  grFONLLRatio_u->SetName("grFONLLRatio_u");
  TGraph *grFONLLRatio_d = new TGraph(npoint,x,ylow);
  grFONLLRatio_d->SetName("grFONLLRatio_d");
  grFONLLRatio->Print();
  ///grFONLLRatio->Write();
  ratioErr->Add(grFONLLRatio);
  grFONLLRatio_u->Print();
  //grFONLLRatio_u->Write();
  ratioErr->Add(grFONLLRatio_u);
  grFONLLRatio_d->Print();
  //grFONLLRatio_d->Write();
  ratioErr->Add(grFONLLRatio_d);
  ratioErr->Write();
  hfile->Print();
  hfile->Close();
  tNow.Set();
  cout<<"----------End of job----------"<<endl;
  tNow.Print();
}
void ALICEWorkInProgress(TCanvas *c,TString today){
 //date must be in the form: 04/05/2010
 if(today=="today"){
   TDatime startt;                                                                                                                                                        
   int date=startt.GetDate();

   int y=date/10000;
   int m=(date%10000)/100;
   int d=date%100;


   today="";
   today+=d;
   if(m<10)
     today.Append("/0");
   else today.Append("/");
   today+=m;
   today.Append("/");
   today+=y;  

 }
 TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",0.67,0.65,0.82,0.89);
 //  myPadLogo->SetFillColor(2); 
 myPadLogo->SetBorderMode(0);
 myPadLogo->SetBorderSize(2);
 myPadLogo->SetFrameBorderMode(0);
 myPadLogo->SetLeftMargin(0.0);
 myPadLogo->SetTopMargin(0.0);
 myPadLogo->SetBottomMargin(0.0);
 myPadLogo->SetRightMargin(0.0);
 myPadLogo->Draw();
 myPadLogo->cd();
 TASImage *myAliceLogo = new TASImage("/u/mfasel/work/electron/Spectrum/alice_logo.png");
 myAliceLogo->Draw();
 c->cd();
 TPaveText* t1=new TPaveText(0.59,0.59,0.89,0.66,"NDC");
 t1->SetFillStyle(0);
 t1->SetBorderSize(0);
 t1->AddText(0.,0.,"ALICE Performance");
 t1->SetTextColor(kRed);
 t1->SetTextFont(42);
 t1->Draw();
 TPaveText* t2=new TPaveText(0.59,0.54,0.89,0.60,"NDC");
 t2->SetFillStyle(0);
 t2->SetBorderSize(0);
 t2->SetTextColor(kRed);
 t2->SetTextFont(52);
 t2->AddText(0.,0.,today.Data());
 t2->Draw();
}
Exemple #16
0
//==========================
//==========================
void plPanitkin(TString fname="./wrk/hist/run7067154.1.hist.root", int flag=0) {
  gROOT -> LoadMacro("StRoot/StEEmcPool/muEztPanitkin/EEqaPresenter.h");
  gROOT -> LoadMacro("StRoot/StEEmcPool/muEztPanitkin/EEqaPresenter.cxx");
 

  gStyle->SetPalette(1,0);

  eemcTwMaskFile = gEnv->GetValue("OnLine.eemcMask","eemcTwMask.dat");

  printf("input Histo=%s=\n",fname.Data());  
  fd=new TFile(fname);
  if(!fd->IsOpen()) {
    printf(" faild to open file=%s=, exit\n",fname.Data()); 
    return;  
  }
  assert(fd->IsOpen());

  // j1(); return;

  cc=new TCanvas("pani","pani",500,510);
  // cc=new TCanvas("pani","pani",700,710);
  cc->Range(0,0,1,1);
  TPad *pad0 = new TPad("pad0", "apd0",0.0,0.95,1.,1.);
  pad0->Draw();
  pad0->cd();

 TPaveText *pt = new TPaveText(0,0.,1,1);
  pt->Draw();
  TDatime dt;
  TString txt2="P-plot,  ";
  txt2+=fname+"  ";
  txt2+=dt.AsString();
  pt->AddText(txt2);
  txt2="--";
  pt->AddText(txt2);

  cc->cd();
  pd1 = new TPad("pad1", "apd1",0.0,0.0,1,.95);
  pd1->Draw();

  printf(" Ready. Type: plTw(1) ,...  plSmd(1) ,... plDSM(1) ,...  plAllps()  flag=%d\n",flag);

  if(flag==1) plTw(1);

  //plSummary();
  //  plTw(1);
  //  pd1->Print("tw.ps");
  // pd1->Print("tw.gif");
}
Exemple #17
0
void TExpenser::drawStatisticsMonthTab() {

    fStatisticsTab = fTab->AddTab("Statistics (Month)");
    fStatisticsTab -> SetLayoutManager(new TGHorizontalLayout(fStatisticsTab));

    TRootEmbeddedCanvas * fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fStatisticsTab, CANVAS_WIDTH, CANVAS_HEIGHT);
    fStatisticsTab -> AddFrame(fEcanvas, new TGLayoutHints(kLHintsCenterX, 10,10,10,1));
    fCanvas = fEcanvas->GetCanvas();
    fCategoriesHistogram = new TH1F("fCategoriesHistogram", "Expenses for each category for a given month", NCATEGORIES, 0, NCATEGORIES);
    fCategoriesHistogram -> SetStats(0);

    TGVerticalFrame *vframe = new TGVerticalFrame(fStatisticsTab, 60, 40);
    fStatisticsTab -> AddFrame(vframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));

    // month selector
    fStatisticsMonth = new TGComboBox(vframe);
    for (unsigned i = 0; i < 12; i++) {
        fStatisticsMonth->AddEntry(MONTHS[i], i+1);
    }
    fStatisticsMonth->Resize(DROPDOWN_MENU_WIDTH, DROPDOWN_MENU_HEIGHT);
    TDatime time;
    fStatisticsMonth->Select(time.GetMonth());
    vframe->AddFrame(fStatisticsMonth, new TGLayoutHints(kLHintsLeft,5,10,5,5));

    // year selector
    fStatisticsYear = new TGComboBox(vframe);
    for (unsigned i = FIRST_YEAR; i <= LAST_YEAR; i++) {
        fStatisticsYear->AddEntry(toStr(i), i+1-FIRST_YEAR);
    }
    fStatisticsYear->Resize(DROPDOWN_MENU_WIDTH, DROPDOWN_MENU_HEIGHT);
    fStatisticsYear->Select(time.GetYear()-FIRST_YEAR+1);
    vframe->AddFrame(fStatisticsYear, new TGLayoutHints(kLHintsLeft,5,10,5,5));

    // update-button
    TGTextButton * update_button = new TGTextButton(vframe,"&Apply");
    update_button -> SetFont("-*-times-bold-r-*-*-28-*-*-*-*-*-*-*");
    update_button -> Connect("Clicked()", "TExpenser", this, "calculate_monthly()");
    vframe -> AddFrame(update_button, new TGLayoutHints(kLHintsLeft,5,5,3,4));

    // monthly sum
    TColor *color = gROOT->GetColor(kBlue);
    TGFont *font = gClient->GetFont("-*-times-bold-r-*-*-22-*-*-*-*-*-*-*");
    fTotalMonthlyExpenses = new TGLabel(vframe, "");
    vframe->AddFrame(fTotalMonthlyExpenses, new TGLayoutHints(kLHintsNormal, 5, 5, 3, 4));
    fTotalMonthlyExpenses->SetTextColor(color);
    fTotalMonthlyExpenses -> SetTextFont(font);

    calculate_monthly();
}
Exemple #18
0
Pulse::Pulse(const double bx, const double ratio): _bx(bx), _ratio(ratio) {

  TDatime now;
  char fname[300];
  sprintf(fname,"%s_peak",now.AsString());
  _peakfunc = new TF1(fname,this,&Pulse::peakpulse,-200e-9,500e-9,2);
  sprintf(fname,"%s_deco",now.AsString());
  _decofunc = new TF1(fname,this,&Pulse::decopulse,-200e-9,500e-9,2);

  _peakfunc->SetParameter(0,bx*ratio);
  _decofunc->SetParameter(0,bx*ratio);

  _peakfunc->SetNpx(50000);
  _decofunc->SetNpx(50000);
}
Exemple #19
0
//_____________________________________________________________________________
void THaRunBase::SetDate( UInt_t tloc )
{
  // Set timestamp of this run to 'tloc' which is in Unix time
  // format (number of seconds since 01 Jan 1970).

#if ROOT_VERSION_CODE >= ROOT_VERSION(3,1,6)
  TDatime date( tloc );
#else
  time_t t = tloc;
  struct tm* tp = localtime(&t);
  TDatime date;
  date.Set( tp->tm_year, tp->tm_mon+1, tp->tm_mday,
	    tp->tm_hour, tp->tm_min, tp->tm_sec );
#endif
  SetDate( date );
}
Exemple #20
0
   virtual Bool_t Notify()
   {
      // stop timer
      TurnOff();

      // so some action here
      TDatime d;
      m_label->SetText(d.AsString());
      gEve->GetDefaultGLViewer()->RequestDraw();

      // start timer
      SetTime(1000);
      Reset();
      TurnOn();
      return true;
   }
void prepareAll() {
        myOptions(0);

        gROOT->ForceStyle();
        gStyle->SetPalette(1.0);

        TDatime now;
        int iDate = now.GetDate();
        int iYear=iDate/10000;
        int iMonth=(iDate%10000)/100;
        int iDay=iDate%100;
        char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun",
                          "Jul","Aug","Sep","Oct","Nov","Dec"};
        char cStamp1[25],cStamp2[25];
        sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear);
        sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear);
}
Exemple #22
0
void SaveCanvas(TCanvas* c, TString dir, TString filename)
{
   TDatime* date = new TDatime();
   c->Print(Form("/net/hisrv0001/home/davidlw/pic/%s/%s_%d.eps",dir.Data(),filename.Data(),date->GetDate()));
   c->Print(Form("/net/hisrv0001/home/davidlw/pic/%s/%s_%d.gif",dir.Data(),filename.Data(),date->GetDate()));
   c->Print(Form("/net/hisrv0001/home/davidlw/pic/%s/%s_%d.pdf",dir.Data(),filename.Data(),date->GetDate()));
   c->Print(Form("/net/hisrv0001/home/davidlw/pic/%s/%s_%d.C",dir.Data(),filename.Data(),date->GetDate()));
}
Exemple #23
0
void KVEventSelector::Terminate()
{
   // The Terminate() function is the last function to be called during
   // a query. It always runs on the client, it can be used to present
   // the results graphically or save the results to file.
	//
	// This method call the user defined EndAnalysis
	// where user can do what she wants
	//

	TDatime now;
    Info("Terminate", "Analysis ends at %s", now.AsString());

   if( fCombinedOutputFile!="" ){
       Info("Terminate", "combine = %s", fCombinedOutputFile.Data());
       // combine histograms and trees from analysis into one file
       TString file1,file2;
       file1.Form("HistoFileFrom%s.root", ClassName());
       file2.Form("TreeFileFrom%s.root", ClassName());
       if(GetOutputList()->FindObject("ThereAreHistos")){
           if(GetOutputList()->FindObject(file2)){
               Info("Terminate", "both");
               SaveHistos();
               KVBase::CombineFiles(file1,file2,fCombinedOutputFile,kFALSE);
           }
           else
           {
               // no trees - just rename histo file
               Info("Terminate", "histo");
               SaveHistos(fCombinedOutputFile);
           }
       }
       else if(GetOutputList()->FindObject(file2)){
           // no histos - just rename tree file
           Info("Terminate", "tree");
           gSystem->Rename(file2, fCombinedOutputFile);
       }
       else  Info("Terminate", "none");
   }


	EndAnalysis();               //user end of analysis routine
	
}
Exemple #24
0
Int_t THaScaler::Init( const TDatime& time ) 
{
  // Initialize scalers for given date/time.
  // Accuracy is 1 day. Only date is used, time is ignored.

  Int_t i = time.GetDate();
  char date[11];
  sprintf( date, "%2.2d-%2.2d-%4.4d",i%100,(i%10000-i%100)/100,i/10000 );
  return Init( date );
};
void KVINDRAOnlineDataAnalyser::PrintControlRate()
{
   TDatime nowtime;
   int time_passed = nowtime.Convert() - fStart.Convert();
   if (time_passed < 1.0) {
      fEventsRefresh *= 2;
      return;
   }
   // check time - we aim for a 5 second refresh
   fEventsRefresh *= 5. / time_passed;
   // minimum 5 events
   fEventsRefresh = TMath::Max(fEventsRefresh, 5);
   Float_t acq_rate = (1.0 * (events - last_events)) / (1.0 * time_passed);
   printf("Events read = %d  <=>  Control rate = %f /sec.\n", events, acq_rate);
   last_events = events;

   fStart.Set();

   if (fDumpEvents) fRunFile->GetFiredDataParameters()->ls();
}
void xrootdTestVanderbilt(const int iOption=0) {

  TDatime *dateTime = new TDatime;
  int iDate = dateTime->GetDate();
  int iTime = dateTime->GetTime();
  cout << "  Begin Vanderbilt access testing " << iDate << " at " << iTime << endl;

  if(iOption == 0 || iOption == 1) {
    TFile *f = TFile::Open("root://cmsxrootd.fnal.gov//store/test/xrootd/T2_US_Vanderbilt//store/mc/SAM/GenericTTbar/GEN-SIM-RECO/CMSSW_5_3_1_START53_V5-v1/0013/CE4D66EB-5AAE-E111-96D6-003048D37524.root");
    if(f) {
      cout << "\n cmsxrootd.fnal.gov successful access to Vanderbilt" << endl;
      f->ls();
      f->Close();
    }
    else {
      cout << "\n cmsxrootd.fnal.gov unsuccessful access to Vanderbilt" << endl;
    }
    dateTime->Set();     // set to system date/time
    iDate = dateTime->GetDate();
    iTime = dateTime->GetTime();
    cout << "  Completed Vanderbilt access test from FNAL on " << iDate << " at " << iTime << endl;
  } // check on iOption = 0 or iOption = 1
  if(iOption == 0 || iOption == 2) {
    TFile *g = TFile::Open("root://cms-xrd-global.cern.ch//store/test/xrootd/T2_US_Vanderbilt//store/mc/SAM/GenericTTbar/GEN-SIM-RECO/CMSSW_5_3_1_START53_V5-v1/0013/CE4D66EB-5AAE-E111-96D6-003048D37524.root");
    if(g) {
      cout << "\n cms-xrd-global.cern.ch successful access to Vanderbilt" << endl;
      g->ls();
      g->Close();
    }
    else {
      cout << "\n cms-xrd-global.cern.ch unsuccessful access to Vanderbilt" << endl;
    }
    dateTime->Set();     // set to system date/time
    iDate = dateTime->GetDate();
    iTime = dateTime->GetTime();
    cout << "  Completed Vanderbilt access test from CERN on " << iDate << " at " << iTime << endl;
  } // check on iOption = 0 or iOption = 2
  dateTime->Set();     // set to system date/time
  cout << "\n  Completed Vanderbilt access testing " << iDate << " at " << iTime << endl;
return;
}
Exemple #27
0
void TExpenser::drawStatisticsYearTab() {

    fStatisticsYearTab = fTab->AddTab("Statistics (Year)");
    fStatisticsYearTab -> SetLayoutManager(new TGHorizontalLayout(fStatisticsYearTab));

    TRootEmbeddedCanvas * StatisticsYearCanvas = new TRootEmbeddedCanvas("StatisticsYearCanvas",fStatisticsYearTab, CANVAS_WIDTH, CANVAS_HEIGHT);
    fStatisticsYearTab -> AddFrame(StatisticsYearCanvas, new TGLayoutHints(kLHintsCenterX, 10,10,10,1));
    fCanvasYear = StatisticsYearCanvas->GetCanvas();
    fMonthsHistogram = new TH1F("fMonthsHistogram", "Expenses for each month for a given category", 12, 0, 12);
    fMonthsHistogram -> SetStats(0);

    TGVerticalFrame *vframe = new TGVerticalFrame(fStatisticsYearTab, 60, 40);
    fStatisticsYearTab -> AddFrame(vframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));

    //  selector
    fStatisticsCategory = new TGComboBox(vframe);
    for (unsigned i = 0; i < NCATEGORIES; i++) {
        fStatisticsCategory->AddEntry(CATEGORIES[i], i+1);
    }
    fStatisticsCategory -> AddEntry("All Categories", NCATEGORIES+1);
    fStatisticsCategory->Resize(DROPDOWN_MENU_WIDTH, DROPDOWN_MENU_HEIGHT);
    fStatisticsCategory->Select(1);
    vframe->AddFrame(fStatisticsCategory, new TGLayoutHints(kLHintsLeft,5,10,5,5));

    // year selector
    TDatime time;
    fStatisticsYear2 = new TGComboBox(vframe);
    for (unsigned i = FIRST_YEAR; i <= LAST_YEAR; i++) {
        fStatisticsYear2->AddEntry(toStr(i), i+1-FIRST_YEAR);
    }
    fStatisticsYear2->Resize(DROPDOWN_MENU_WIDTH, DROPDOWN_MENU_HEIGHT);
    fStatisticsYear2->Select(time.GetYear()-FIRST_YEAR+1);
    vframe->AddFrame(fStatisticsYear2, new TGLayoutHints(kLHintsLeft,5,10,5,5));

    // update-button
    TGTextButton * update_button = new TGTextButton(vframe,"&Update");
    update_button -> Connect("Clicked()", "TExpenser", this, "calculate_yearly()");
    vframe -> AddFrame(update_button, new TGLayoutHints(kLHintsLeft,5,5,3,4));

    calculate_yearly();
}
Exemple #28
0
void MySelector::Terminate()
{
   // The Terminate() function is the last function to be called
   // during a query. It always runs on the client, it can be used
   // to present the results graphically or save the results to
   // file.

   // finally, store all output
   TFile hfile("MySelector_Result.root","RECREATE","MuonResults");
   fOutput->Write();

   //Example to retrieve output from output list
   h_resistance=
      dynamic_cast<TH1F *>(fOutput->FindObject("resistance"));
   TCanvas c_result("cresult","Resistance",100,100,300,300);
   h_resistance->Draw();
   c_result.SaveAs("ResistanceDistribution.png");

   tNow.Set(); printf("*==* ---------- End of Job ---------- ");
   tNow.Print();
}
//--------------------------------------------------------------------------------------------------
void plotSmartCacheTransferRate()
{
  TDatime date;
  TString dateTime = date.AsSQLString();
  TString text;
  long int durationHour  =              3600;
  long int durationDay   =         24 * 3600;
  long int durationWeek  =     7 * 24 * 3600;
  long int durationMonth = 4 * 7 * 24 * 3600;
  long int xStart, xEnd;

  // Plot SmartCache tranfers during the last hour, day, week, month
  time_t t;
  time(&t);   

  long int time = (long int) t;

  // Access the database just once
  TString timeSeriesFile("timeSeriesOfRates.txt");
  TString dbAccess("/home/cmsprod/DynamicData/SmartCache/Client/snapshotSmartCacheHistoryDb.py");
  // remove potentially existing old file
  TString rmDbInfo = TString(".! rm -f ")+timeSeriesFile;
  gROOT->ProcessLine(rmDbInfo.Data());
  // create fresh input file
  TString getDbInfo = TString(".! ") + dbAccess + TString(" -q");
  gROOT->ProcessLine(getDbInfo.Data());

  // hour
  text = TString("Last Hour at ") + dateTime; 
  xStart = time-durationHour;  xEnd = time; plot(xStart,xEnd,text,"transferRateLastHour.png");
  // day
  text = TString("Last Day at ") + dateTime; 
  xStart = time-durationDay;   xEnd = time; plot(xStart,xEnd,text,"transferRateLastDay.png");
  // week
  text = TString("Last Week at ") + dateTime; 
  xStart = time-durationWeek;  xEnd = time; plot(xStart,xEnd,text,"transferRateLastWeek.png");
  // week
  text = TString("Last Month at ") + dateTime; 
  xStart = time-durationMonth; xEnd = time; plot(xStart,xEnd,text,"transferRateLastMonth.png");
}
Exemple #30
0
//------------------------
TPad *makeTitle(TCanvas *c,char *core, int page) {
  c->Range(0,0,1,1);
  TPad *pad0 = new TPad("pad0", "apd0",0.0,0.95,1.,1.);
  pad0->Draw();
  pad0->cd();

  TPaveText *pt = new TPaveText(0,0.,1,1,"br");
  pt->Draw();
  TDatime dt;
  TString txt2=core;
  txt2+=", page=";
  txt2+=page;
  txt2+=",  ";
  txt2+=dt.AsString();
  pt->AddText(txt2);
  txt2="--";
  pt->AddText(txt2);

  c->cd();
  pad = new TPad("pad1", "apd1",0.0,0.0,1,.95);
  pad->Draw();
  return pad;
}