void BrowseHistograms(const char* histname) {

    fHistName=histname;

  TSystemDirectory dir(".",".");
  TList *files = dir.GetListOfFiles();
  if (!files) {
    cerr << "Error: No files found in " << fFileDir << endl;
    return;
  }
  files->Sort();


  histograms = new TList();
  saved = new TList();

  c = new TCanvas("canvas","Browse Histograms");

  TSystemFile *file;
  TIter next(files);
  Int_t n=0;
  TString fname;
  while ((file=(TSystemFile*)next())) {
    fname = file->GetName();
    if (!file->IsDirectory() && fname.EndsWith(".root")) {

      histograms->Add(new TObjString(fname));
      n++;
      //if(n>10)
      //	break;
    }
  }

  DrawCurrHistogram();

  TControlBar *bar = new TControlBar("vertical", "Control", 10, 10);
  bar->AddButton("Next","ProcessClick(1);", "Show next run");
  bar->AddButton("Next And Save","NextAndSave();", "Show previous run");
  bar->AddButton("Next And Forget","NextAndForget();", "Show previous run");
  bar->AddButton("Prev","ProcessClick(-1);", "Show previous run");
  bar->AddButton("Print saved","PrintSaved();", "Show previous run");
  bar->SetButtonWidth(90);
  bar->Show();
}
Beispiel #2
0
TList* KVASGroup::GetTelescopesWithAngles(Float_t theta, Float_t phi) const
{
   //Create and fill list of telescopes in group at position (theta,phi),
   //sorted according to distance from target (smallest layer number i.e. closest first).
   //User must delete list after use.

   TIter next(GetTelescopes());
   KVTelescope* t;
   TList* list = 0;
   while ((t = (KVTelescope*) next())) {
      if (t->IsInPolarRange(theta) && t->IsInPhiRange(phi)) {
         if (!list)
            list = new TList;
         list->Add(t);
      }
   }
   if (list)
      list->Sort();
   return list;
}
void SetSelectedNodesValue(TcxDBTreeList *ATreeList, int AItemIndex,
  Variant AValue)
{
  TList *AList = new TList();
  ATreeList->BeginUpdate();
  __try{
    ATreeList->GetSelections(AList);
    AList->Sort(cxCompareNodes);
    for (int I = 0; I < AList->Count; I++)
      if (((TcxTreeListNode*)AList->Items[I])->Values[AItemIndex] != AValue){
        ((TcxTreeListNode*)AList->Items[I])->Focused = true;
        ATreeList->DataController->Edit();
        ((TcxTreeListNode*)AList->Items[I])->Values[AItemIndex] = AValue;
        ATreeList->DataController->Post();
      }
    }
  __finally{
    delete AList;
    ATreeList->EndUpdate();
  }
}
Beispiel #4
0
///
/// 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();
      h->Draw();
      c_h1->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 c_h1->SaveAs(path + "/" + key->GetName() + ".gif");

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

  ///
  /// Done!
  ///

  html << "</body></html>" << endl;
  html.close();
}
Beispiel #5
0
void qaitsAddMetadata(TTree*tree, Int_t verbose){
  //
  // Set metadata infomation 
  //
  if (tree==NULL) {
    ::Error("qaitsAddMetadata","Start processing. Emtpy tree");
    return;
  }
  ::Info("qaitsAddMetadata","Start processing Tree %s",tree->GetName());
  TObjArray * branches=tree->GetListOfBranches();
  // Clasigication of variables
  //   regular expression to defined automaticaly some variables following naming conventions - used to define classes/Axis/legends 
  //           default description
  //   regular expression used can be tested on site https://regex101.com/
  //           hovewer root (perl)  regular expression looks to be in some cases different - in some case double escape had to be used
  //           e.g to math c.  expression c\\. has to be used
  //   variables
  const TString kineVariableClass[11]={"X", "Y","Z", "Phi", "Theta", "Pt", "QOverPt"};
  const TString kineVariableAxisTitle[11]={"x(cm)", "y(cm)","z(cm)", "#phi", "#Theta", "p_{T}", "q/p_{T}(c/GeV)"};
  const TString kineVariableLegend[11]={"x", "y","z", "#phi", "#Theta", "p_{T}", "q/p_{T}"};
  const TString kineVariableTitle[11]={"x", "y","z", "#phi", "#Theta", "p_{T}", "q/p_{T}"};
  TPRegexp regKineVariables[11];
  regKineVariables[0]=TPRegexp("^x|x$");               // X - varaible begining on X
  regKineVariables[1]=TPRegexp("(^y|^infoy|y$)");      // Y - 
  regKineVariables[2]=TPRegexp("(^z|^infoz|z$)");      // Z
  regKineVariables[3]=TPRegexp("(phi|infophi)");              // phi
  regKineVariables[4]=TPRegexp("(theta|lambda|infolambda)");   // theta
  regKineVariables[5]=TPRegexp("(^pt)");           // pt
  regKineVariables[6]=TPRegexp("qoverpt");          // qoverPt
  //
  //   QA variables  
  const TString qaVariableClass[11]={"Frac", "$","dEdx","ChargeRatio"};
  const TString qaVariableAxisTitle[11]={"Frac","$","dEdx","ChargeRatio"};
  const TString qaVariableLegend[11]={"Frac","$","dEdx","ChargeRatio"};
  const TString qaVariableTitle[11]={"Frac","$","dEdx","ChargeRatio"};
  TPRegexp regQAVariable[11];
  regQAVariable[0]=TPRegexp("frac");              // Frac
  regQAVariable[1]=TPRegexp("(eff[0-9]|effone|^eff)");          // eff layer?
  regQAVariable[2]=TPRegexp("(mpv|dedx)");         // dEdx 
  regQAVariable[3]=TPRegexp("chargeratio");        // ChargeRatio

 
  //
  // statistic
  //
  const TString statClass[10]={"Constrain", "Mean","Delta","Median", "RMS","Pull", "Err","Chi2", "StatInfo[]","FitInfo[]"};
  const TString statAxisTitle[10]={"Constrain", "mean","#Delta","med.", "rms","pull", "#sigma"," #chi2","stat[]","fit[]"};
  const TString statTitle[10]={"Constrain", "mean","#Delta","med.", "rms","pull", "#sigma"," #chi2","stat[]","fit[]" };
  TPRegexp regStat[10];
  regStat[0]=TPRegexp("constrain");        // constrain
  regStat[1]=TPRegexp("^mean");            // mean
  regStat[2]=TPRegexp("^delta");           // delta
  regStat[3]=TPRegexp("^median");          // median variable
  regStat[4]=TPRegexp("(^rms|resolution|sigma)");// rms resolution        
  regStat[5]=TPRegexp("pull");             // pull
  regStat[6]=TPRegexp("err");              // error
  regStat[7]=TPRegexp("chi2");             // chi2
  regStat[8]=TPRegexp("^info");            // stat info array 
  regStat[9]=TPRegexp("^fit");             // fit info  array
  //
  // 
  const TString categoryClass[10]={"Vertex","$1","$1"};
  const TString categoryLegend[10]={"Vertex","$1","$1"};
  const TString categoryTitle[10]={"Vertex","$1","$1"};
  TPRegexp regCategory[10];   // proper parsing of layer numbers to be added
  regCategory[0]=TPRegexp("(vertex|vtx)");             //
  regCategory[1]=TPRegexp("s(p|d|d)d[0-2]?");    // reg.exp match silical layers+number 
  regCategory[2]=TPRegexp("pt[0-9]+");         // pt bin
  


  for (Int_t ibr=0; ibr<branches->GetEntriesFast(); ibr++){
    TBranch * branch = (TBranch*)branches->At(ibr);
    TString matchClass="";   // class match
    TString brClass="";
    TString brAxisTitle="";
    TString brTitle="";
    TString brLegend="";
    //
    TString brNameCase(branches->At(ibr)->GetName());
    brNameCase.ToLower();
    //
    // define met
    brClass="ITS";
    brAxisTitle="";
    // stat
    for (Int_t ivar=0; ivar<11; ivar++) if  (brNameCase.Contains( regStat[ivar])) { 
      brClass+=" "+statClass[ivar];
      brTitle+=statTitle[ivar];
    }
    // kine variables
    for (Int_t ivar=0; ivar<7; ivar++) if  (brNameCase.Contains( regKineVariables[ivar])) {
      brClass+=" "+kineVariableClass[ivar];      
      brAxisTitle+=" "+kineVariableAxisTitle[ivar];
      brTitle+=" "+kineVariableTitle[ivar];
      brLegend+=" "+kineVariableLegend[ivar];
    }
    // QA variables
    for (Int_t ivar=0; ivar<5; ivar++) if  (brNameCase.Contains( regQAVariable[ivar])) {
      if ( qaVariableClass[ivar].Contains("$")==kFALSE){
	brClass+=" "+ qaVariableClass[ivar];
	brLegend+=" "+ qaVariableLegend[ivar];
	brTitle+=" "+ qaVariableTitle[ivar];
      }else{
	TObjArray *amatch=regQAVariable[ivar].MatchS(brNameCase);
	if (amatch){
	  TString match=amatch->At(0)->GetName();
	  brClass+=" "+match;
	  brLegend+=" "+match;
	  brTitle+=" "+match;
	}
      }
    }
    // category
    for (Int_t ivar=0; ivar<3; ivar++) if  (brNameCase.Contains(regCategory[ivar])) {
      if (categoryClass[ivar].Contains("$")==kFALSE){
	brClass+=" "+categoryClass[ivar];
	brLegend+=" "+categoryLegend[ivar];
	brTitle+=" "+categoryTitle[ivar];
      }else{
	TObjArray *amatch=regCategory[ivar].MatchS(brNameCase);
	if (amatch){
	  TString match=amatch->At(0)->GetName();
	  brClass+=" "+match;
	  brLegend+=" "+match;
	  brTitle+=" "+match;
	}
      }
    }
    if (branch!=NULL && branch->GetClassName()!=NULL && strlen(branch->GetClassName())>0){
      brClass+=" Class:";
      brClass+=branch->GetClassName();
    }
    
    //
    TStatToolkit::AddMetadata(tree,TString::Format("%s.Description",branches->At(ibr)->GetName()).Data(),
			      TString::Format("ITS standard QA variables.  Class %s", brClass.Data()).Data());
    TStatToolkit::AddMetadata(tree,TString::Format("%s.class",branches->At(ibr)->GetName()).Data(),brClass.Data());    
    TStatToolkit::AddMetadata(tree,TString::Format("%s.AxisTitle",branches->At(ibr)->GetName()).Data(),brAxisTitle.Data());    
    TStatToolkit::AddMetadata(tree,TString::Format("%s.Title",branches->At(ibr)->GetName()).Data(),brTitle.Data());    
    TStatToolkit::AddMetadata(tree,TString::Format("%s.Legend",branches->At(ibr)->GetName()).Data(),brLegend.Data());    
    if (verbose&4) printf("Class %s: \t%s\n", branches->At(ibr)->GetName(),brClass.Data());
    if (verbose&8) printf("Axis title %s: \t%s\n", branches->At(ibr)->GetName(),brAxisTitle.Data());
    if (verbose&16) printf("Title %s: \t%s\n", branches->At(ibr)->GetName(),brTitle.Data());
    if (verbose&32) printf("Legend %s: \t%s\n", branches->At(ibr)->GetName(),brLegend.Data());

    
  }

  // Fill Based and  custom metadata
  //
  // Index
  TStatToolkit::AddMetadata(tree,"run.class","Base Index");
  TStatToolkit::AddMetadata(tree,"run.Title","run");
  TStatToolkit::AddMetadata(tree,"run.AxisTitle","run");
  //
  TList * mlist = (TList*)(tree->GetUserInfo()->FindObject("metaTable"));
  mlist->Sort();
  if ((verbose&1)>0){
    mlist->Print();
  }
  if ((verbose&2)>0){
    AliTreePlayer::selectMetadata(tree, "[class==\"\"]",0)->Print();
  }
  ::Info("qaitsAddMetadata","End");

}
Beispiel #6
0
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);
}