///
/// Copied from TColor::GetColorDark(Int_t n), but customized
/// the 'darkness'.
///
int ColorBuilder::darklightcolor(int n, float scale)
{
	if (n < 0) return -1;

	// Get list of all defined colors
	TObjArray *colors = (TObjArray*) gROOT->GetListOfColors();
	Int_t ncolors = colors->GetSize();
	// Get existing color at index n
	TColor *color = 0;
	if (n < ncolors) color = (TColor*)colors->At(n);
	if (!color) return -1;

	// Get the rgb of the the new dark color corresponding to color n
	Float_t r,g,b;
	TColor::HLStoRGB(color->GetHue(), scale*color->GetLight(), color->GetSaturation(), r, g, b);

	// Build the dark color (unless the slot nd is already used)
	Int_t nd = scale<1. ? n+100 : n+150;
	TColor *colord = 0;
	if (nd < ncolors) colord = (TColor*)colors->At(nd);
	if (colord) return nd;
	colord = new TColor(nd,r,g,b);
	colord->SetName(scale<1. ? Form("%s_dark",color->GetName()) : Form("%s_light",color->GetName()));
	colors->AddAtAndExpand(colord,nd);
	return nd;
}
Example #2
0
/// Open new data file
bool DDG4EventHandler::Open(const std::string&, const std::string& name)   {
    if ( m_file.first ) m_file.first->Close();
    m_hasFile = false;
    m_hasEvent = false;
    TFile* f = TFile::Open(name.c_str());
    if ( f && !f->IsZombie() )  {
        m_file.first = f;
        TTree* t = (TTree*)f->Get("EVENT");
        if ( t )   {
            TObjArray* br = t->GetListOfBranches();
            m_file.second = t;
            m_entry = -1;
            m_branches.clear();
            for(Int_t i=0; i<br->GetSize(); ++i)  {
                TBranch* b = (TBranch*)br->At(i);
                if ( !b ) continue;
                m_branches[b->GetName()] = make_pair(b,(void*)0);
                printout(INFO,"DDG4EventHandler::open","+++ Branch %s has %ld entries.",b->GetName(),b->GetEntries());
            }
            for(Int_t i=0; i<br->GetSize(); ++i)  {
                TBranch* b = (TBranch*)br->At(i);
                if ( !b ) continue;
                b->SetAddress(&m_branches[b->GetName()].second);
            }
            m_hasFile = true;
            return true;
        }
        throw runtime_error("+++ Failed to access tree EVENT in ROOT file:"+name);
    }
    throw runtime_error("+++ Failed to open ROOT file:"+name);
}
Example #3
0
void GetHitsCoor(TObject *its, Int_t mod, TObjArray & histos, Int_t subd,Bool_t verb){
  TH2F *h2=(TH2F*)histos.At(1+subd*9);
  TH1F *h1=(TH1F*)histos.At(4+subd*9);
  TH1F *ener=(TH1F*)histos.At(8+subd*9);
  IlcTARGET *TARGET= (IlcTARGET*)its;
  IlcTARGETmodule *modu = TARGET->GetModule(mod);
  TObjArray *fHits = modu->GetHits();
  Int_t nhits = fHits->GetEntriesFast();
  if(nhits>0){
    if(verb){
      cout<<"-------------------------------------------------------"<<endl;
      cout<<"Number of HTARGET for module "<<mod<<": "<<nhits<<endl;
    }
    for (Int_t hit=0;hit<nhits;hit++) {
      IlcTARGEThit *iHit = (IlcTARGEThit*) fHits->At(hit);
      if(!iHit->StatusEntering()){
        Float_t x=iHit->GetXG();
        Float_t y=iHit->GetYG();
        Float_t z=iHit->GetZG();
        Float_t edep=iHit->GetIonization()*1000000;
        h2->Fill(x,y);
        h1->Fill(z);
        ener->Fill(edep);
        if(verb){
          cout<<"hit # "<<hit<<" Global coordinates "<<x<<" "<<y<<" "<<z<<endl;
          cout<<"track # "<<iHit->GetTrack()<<" energy deposition (KeV)= ";
          cout<<edep<<endl;
        }
      }
    }
  }
}
Example #4
0
File: QA.C Project: ktf/AliPhysics
void QA(TString fdata = "trmult.data.root",
   TString fmc   = "trmult.mc.root")
{


  // The following code assumes that we have a filenme with the format
  // "../output/LHC15f_pass2/226062/AnalysisResults.226062.root
  // and uses this assumption to extract MC and Data taks + runname
  TObjArray * tokensData = fdata.Tokenize("/");
  TObjArray * tokensMC   = fmc.Tokenize("/");
  
  // Check assuptions on data and MC formats, the second token should be "output"
  if (((TObjString*)tokensData->At(1))->String() == "output" && 
      ((TObjString*)tokensMC  ->At(1))->String() == "output"
      ) {
    
    canvasPrefix =
      canvasPrefix +
      ((TObjString*)tokensData->At(2))->String() + "_" +// period data
      ((TObjString*)tokensMC  ->At(2))->String() + "_" +// period mc
      ((TObjString*)tokensData->At(3))->String() + "_" ;// run number
      
      
  }
  std::cout << "Prefix: " << canvasPrefix.Data() << std::endl;
  
  //  qacentrality(fdata);
  QAoccupancy(fdata, fmc);
  QAtracklets(fdata, fmc);
  QAvertex(fdata, fmc);
  
}
Example #5
0
void TGo4LoadedLibraries::RefreshLibs()
{
   LoadedLibsD->clear();

   TObjArray* libs = TString(gInterpreter->GetSharedLibs()).Tokenize(" ,\t\n");

   if (libs!=0)
      for (int n=0; n<=libs->GetLast(); n++) {
         QFileInfo fi(libs->At(n)->GetName());

         QStringList columns;

         columns << fi.fileName() << QString::number(fi.size()) << fi.lastModified().toString() << fi.owner() << fi.group();

         LoadedLibsD->addTopLevelItem(new QTreeWidgetItem(columns));
      }

   delete libs;

   LoadedLibsS->clear();

   libs = TString(gSystem->GetLinkedLibs()).Tokenize(" ,\t\n");

   if (libs!=0)
      for (int n=0; n<=libs->GetLast(); n++) {
         QStringList columns;
         columns << libs->At(n)->GetName();
         LoadedLibsS->addTopLevelItem(new QTreeWidgetItem(columns));
      }
   delete libs;
}
Example #6
0
//___________________________________________________________________________________________
void KVIntegerList::SetPartition(const Char_t* par)
{
//protected method, utilisée par le Streamer qui utilise le champ fName de la classe TNamed
//voir également KVIntegerList::DeducePartitionFromTNamed
   KVString st(par);
   st.Begin(" ");
   TObjArray* toks = 0;
   while (!st.End()) {
      KVString tamp = st.Next();
      Int_t val;
      Int_t freq;
      if (tamp.Contains("(")) {
         if (!tamp.Contains(")")) {
            Warning("SetPartition", "%s ->pb de coherence dans les parentheses", tamp.Data());
            return;
         } else {
            toks = tamp.Tokenize("(");
            val = ((TObjString*)toks->At(0))->GetString().Atoi();
            freq = ((TObjString*)toks->At(1))->GetString().Atoi();
            delete toks;
         }
      } else {
         val = tamp.Atoi();
         freq = 1;
      }
      Add(val, freq);
   }

}
Example #7
0
//_____________________________________________________
TLegendEntry* GFHistManager::AddHistSame(TH1* hist, Int_t layer, Int_t histNum,
					 const char* legendTitle, const char* legOpt)
{
  // adds hist to layer to draw it in the same pad as histNum's histo of that layer 
  if(!hist){
    this->Warning("AddHistSame", "adding NULL pointer will be ignored!");
    return NULL;
  }
  if (histNum > 0 && this->CheckDepth("AddHistSame", layer, kTRUE) //maybe added layer?
      && !this->GetHistsOf(layer, histNum-1)) {
    this->Error("AddHistSame", "usage as AddHist only for next free histNum, not %d", histNum);
    return NULL;
  }
  GFHistArray *histsArray = this->GetHistsOf(layer, histNum, kTRUE);// expand!
  TLegendEntry* result = NULL;
  if(histsArray) {
    histsArray->Add(hist); 
    if(legendTitle && strlen(legendTitle)){
      TObjArray* legends = this->MakeLegends(layer);
      TLegend* legend = NULL;
      if(legends->GetLast() >= histNum
	 && legends->At(histNum)){
	legend = static_cast<TLegend*>(legends->At(histNum));
      } else {
	legend = new TLegend(fLegendX1, fLegendY1, fLegendX2, fLegendY2);
#if ROOT_VERSION_CODE < ROOT_VERSION(5,6,0)
	if (TString(gStyle->GetName()) == "Plain") legend->SetBorderSize(1);
#endif
	legends->AddAtAndExpand(legend, histNum);
      }
      result = legend->AddEntry(hist,legendTitle, legOpt ? legOpt : fgLegendEntryOption.Data());
    }
  }
  return result;
}
int main() {

  TGeoNode *node =  NULL;
  TGeoVolume *vol = NULL;
  
  LMCgeomN *g = new LMCgeomN("Telescope");
  TObjArray *oa = g->GetGeoManager()->GetListOfNodes();
  for (int i=0; i<oa->GetEntries(); i++) {
    node =  (TGeoNode*)oa->At(i);
    vol = node->GetVolume();
    cout << "= " << node->GetName() << "  " << vol->GetName()  <<endl;
    TObjArray *vnodes = vol->GetNodes();
    cout << vnodes->GetEntries() << endl;
    for (int j=0; j<vnodes->GetEntries(); j++) {
      node = (TGeoNode*)vnodes->At(j);
      cout << "== " << node->GetName() << endl;
      vol = node->GetVolume();
      TObjArray *vnodes1 = vol->GetNodes();
      for (int k=0; k<vnodes1->GetEntries(); k++) {
	node = (TGeoNode*)vnodes1->At(k);
	cout << "=== " << node->GetName() << endl;
	vol = node->GetVolume();
	TObjArray *vnodes2 = vol->GetNodes();
	if(!vnodes2) continue;
	for (int q=0; q<vnodes2->GetEntries(); q++) {
	   node = (TGeoNode*)vnodes2->At(q);
	   cout << "==== " << node->GetName() << endl;
	 }
	
      }
    }
  }

  return 0;
}
void GetTreeSize(TString FileName, TString TreeName)
{
  TFile *inf          = TFile::Open(FileName);
  TTree *tr           = (TTree*)inf->Get(TreeName);
  TObjArray *branches = (TObjArray*)tr->GetListOfBranches();
  int size(0);
  cout.setf(ios::right);
  int N(branches->GetEntries());
  TH1F *hSize = new TH1F("size","size",N,0,N);
  for(int ib=0;ib<N;ib++) {
    TString name(branches->At(ib)->GetName());
    TBranch *br = (TBranch*)tr->GetBranch(name);
    hSize->Fill(name,br->GetZipBytes()/1e+3); 
    size += br->GetZipBytes();
  } 
  cout<<"Total size: "<<size<<endl;
  for(int ib=0;ib<N;ib++) {
    TString name(branches->At(ib)->GetName());
    TBranch *br = (TBranch*)tr->GetBranch(name);
    float percent = TMath::Ceil(1000*float(br->GetZipBytes())/float(size))/10;
    cout<<ib<<setw(20)<<name<<setw(15)<<br->GetZipBytes()<<" "<<percent<<"%"<<endl;
  }

  TCanvas *can = new TCanvas("TreeSize","TreeSize",1000,400);
  hSize->GetXaxis()->SetTitle("Branch Name");
  hSize->GetXaxis()->SetLabelSize(0.04);
  hSize->GetYaxis()->SetTitle("Size (KB)");
  hSize->SetFillColor(kGray);
  hSize->Draw();
}
Example #10
0
//________________________________________________________
bool GFOverlay::OpenFilesLegends(const char *fileLegendList)
{
  bool allOk = true;
  
  TObjArray *fileLegPairs = TString(fileLegendList).Tokenize(",");
  for (Int_t iF = 0; iF < fileLegPairs->GetEntriesFast(); ++iF) {
    TObjArray *aFileLegPair = TString(fileLegPairs->At(iF)->GetName()).Tokenize("=");

    const char *legend = "";
    if (aFileLegPair->GetEntriesFast() >= 2) {
      if (aFileLegPair->GetEntriesFast() > 2) {
	::Error("GFOverlay::OpenFilesLegends", "File-legend pair %s: %d (>2) '=' separated parts!",
		fileLegPairs->At(iF)->GetName(), aFileLegPair->GetEntriesFast());
      }
      legend = aFileLegPair->At(1)->GetName();
    } else if (aFileLegPair->GetEntriesFast() < 1) {
      continue; // empty: should report error?
    } // else if (aFileLegPair->GetEntriesFast() == 1): That's OK, use empty legend.

    TFile *file = TFile::Open(aFileLegPair->At(0)->GetName());
    if (!file) {
      ::Error("GFOverlay::OpenFilesLegends", "Skip file-legend pair %s due to opening problems!",
	      fileLegPairs->At(iF)->GetName());
      allOk = false;
    } else {
      fFiles.Add(file);
      fLegends.Add(new TObjString(legend));
    }
    delete aFileLegPair;
  }

  delete fileLegPairs;
  return allOk;
}
Example #11
0
void KVAvailableRunsFile::GetRunInfos(Int_t run, KVList * dates,
                                      KVList * files)
{
   //Look for a given run number in the file, and read the file's modification date/time and filename
   //These informations are stored in the two TList as TObjString objects (these objects belong to the
   //lists and will be deleted by them).
   //We do not stop at the first run found, but continue until the end of the file, adding
   //informations for every occurence of the run in the file.
   //If available runs file does not exist, Update() is called to create it.

   //does runlist exist ?
   if (!OpenAvailableRunsFile()) {
      Error("GetRunInfos", "Error opening available runs file");
      return;
   }
   //clear lists - delete objects
   dates->Delete();
   files->Delete();

   //loop over lines in fRunlist file
   //look for line beginning with 'run|'
   TString line;
   line.ReadLine(fRunlist);
   while (fRunlist.good()) {
      if (line.BeginsWith(Form("%d|", run))) {

         //found it
         TObjArray *toks = line.Tokenize('|');  // split into fields
         // check date is not identical to a previous entry
         // i.e. there are spurious duplicate entries
         TObjString* rundate = (TObjString*)toks->At(1)->Clone();
         if(dates->FindObject(rundate->GetName())){
             delete toks;
             delete rundate;
             line.ReadLine(fRunlist);
             continue;
         }
         //add date string
         dates->Add(toks->At(1)->Clone());

         //backwards compatibility
         //an old available_runs file will not have the filename field
         //in this case we assume that the name of the file is given by the
         //dataset's base file name (i.e. with no date/time suffix)
         if (toks->GetEntries() > 2) {
            files->Add(toks->At(2)->Clone());
         } else {
            files->
                Add(new
                    TObjString(fDataSet->
                               GetBaseFileName(GetDataType(), run)));
         }
         delete toks;

      }
      line.ReadLine(fRunlist);
   }
   CloseAvailableRunsFile();
}
Example #12
0
vector<int> inputEMAP(vector<int> compVar, vector<int> compIdx){
  
  vector<string> lines;
  std::string line;
  lines.clear();
  std::ifstream infile(gl_emap, std::ios_base::in);
  if (!infile) {
    cout<<"Cannot open file "<<gl_emap<<endl;
    return false;
  }
  
  while(getline(infile, line, '\n')) {
    
    /*
    string dummy;     //0
    string crate;     //1
    string slot;      //2
    string tb;        //3
    string dcc;       //4
    string spigot;    //5
    string fiber;     //6
    string fiberchan; //7
    string subdet;    //8
    string ieta;      //9
    string iphi;      //10
    string depth;     //11
    */

    TString conv = TString(line.c_str());
    TObjArray* aline = conv.Tokenize(" ");
    bool foundIt = true;
    for(int idx=0; idx<compVar.size() && foundIt; idx++){
      TString s = ((TObjString*)(aline->At(compIdx[idx])))->GetString();
      if( compVar[idx] != atoi(s.Data())) foundIt = false;
    }
    if(foundIt){
      vector<int> found;
      for(int l=0; l<aline->GetEntriesFast(); l++){
	TString s = ((TObjString*)(aline->At(l)))->GetString();
	if(l!=3 && l!=8) found.push_back(atoi(s.Data()));
	else{
	  if(l==3){
	    if(s==TString("t")) found.push_back(0);
	    else if(s==TString("b")) found.push_back(1);
	  }
	  if(l==8){
	    if(s==TString("HB")) found.push_back(0);
	    else if(s==TString("HE")) found.push_back(1);
	    else if(s==TString("HF")) found.push_back(2);
	    else if(s==TString("HO")) found.push_back(3);
	  }
	}
      }
      return found;
    }
  }
  vector<int> notFound;
  return notFound;
}
Example #13
0
//________________________________________________________
void GFHistManager::Print(const char* filename, Bool_t add)
{
  // print all layers of histograms to ps-file 'filename'
  // if 'add == true' puts '(' or ')' only if 'filename' ends with it, 
  // e.g. if i is loop variable 
  //   GFHistManager *man = ...;
  //   TString name("XXX.ps");
  //   if(i == 0) man->Print(name + '(');
  //   else if(i == last) man->Print(name + ')');
  //   else man->Print(name, kTRUE);


  const Bool_t rootIsBatch = gROOT->IsBatch();
  if(fBatch){
    gROOT->SetBatch();
    for(Int_t i = 0; i < fDepth; ++i){
      this->DrawReally(i);
    }
  }
  gROOT->SetBatch(rootIsBatch);

  TObjArray cans;
  TIter canArrayIter(fCanArrays);
  while(TObjArray* canArray = static_cast<TObjArray*>(canArrayIter.Next())){
    cans.AddAll(canArray);
  }

  const Int_t nCans = cans.GetEntriesFast();
  if(nCans == 1) {
    cans.At(0)->Print(filename);
    return;
  }

  TString plainName(filename);
  const Bool_t starting = plainName.EndsWith("(");
  if(starting) {
    const Ssiz_t ind = plainName.Last('(');
    plainName.Remove(ind);
    //    plainName.ReplaceAll("(", "");
  }
  const Bool_t ending = plainName.EndsWith(")");
  if(ending) {
    const Ssiz_t ind = plainName.Last(')');
    plainName.Remove(ind);
//     plainName.ReplaceAll(")", "");
  }

  for(Int_t i = 0; i < nCans; ++i){
    if(i == 0 && !ending && (!add || starting)) {
      cans.At(i)->Print(plainName + "(");
    } else if(i == nCans - 1 && !starting && (!add || ending)) {
      cans.At(i)->Print(plainName + ")");
    } else {
      cans.At(i)->Print(plainName);
    }
  }
}
Example #14
0
void InitSummaryTrending(TTree * tree){
  //
  // Init drawing for the <detector> QA
  // Detector specific qaConfig() has to be called before invoking this function
  //    0.) Make descriptor 
  //    1.) Make default canvas - addopt canvas width to the number of entries to draw
  //    3.) compute detector  status graphs

  //
  //   0.) Make descriptor 
  //
  TLatex *latex= new TLatex;
  latex->SetX(0.11);
  latex->SetY(0.8);
  latex->SetTextSize(0.03);
  descriptionQA = GetTexDescription(latex);
  //
  //   1.) Make default canvas - addopt canvas width to the number of entries to draw
  //
  TGraphErrors *gr = (TGraphErrors*) TStatToolkit::MakeGraphSparse(tree,"resolution:tagID","");
  Int_t numberOfTags = gr->GetN();
  cout<<"number of graph entries: "<<numberOfTags<<endl;
  double SpaceForLegend = 0.;
  Int_t canvas_width  = SpaceForLegend + (numberOfTags+5)*30;
  Int_t canvas_height = 600; 
  if ( canvas_width>kMaxCanvasWidth)   canvas_width=kMaxCanvasWidth;
  canvasQA = new TCanvas("canvasQA","canvasQA",canvas_width,canvas_height);
  canvasQA->SetGrid(3);
  canvasQA->cd();
  gPad->SetTicks(1,2);
  // canvasQA->SetRightMargin(SpaceForLegend/canvas_width);
  double leftlegend  = 1 - 180./canvasQA->GetWw();
  double rightlegend = 1 - 10./canvasQA->GetWw();
  //
  // 2.) process config file qaConfig.C to initialize status aliases (outliers etc.), status bar criteria, status lines, ...
  //
  TString sStatusbarVars  = statusDescription[0];
  TString sStatusbarNames = statusDescription[1];
  TString sCriteria       = statusDescription[2];
  cout << "sStatusbarVars = " << sStatusbarVars.Data() << endl;
  cout << "sCriteria      = " << sCriteria.Data() << endl;
  //
  // 3.) compute detector status graphs
  //
  TObjArray* oaStatusbarVars = sStatusbarVars.Tokenize(";");
  TObjArray* oaStatusbarNames = sStatusbarNames.Tokenize(";");
  oaMultGr = new TObjArray();
  int igr=0;
  for (Int_t vari=oaStatusbarVars->GetEntriesFast()-1; vari>=0; vari--){ // invert the order of the status graphs
    TString sVar = Form("%s:tagID", oaStatusbarVars->At(vari)->GetName()); //e.g. -> dcar:run
    oaMultGr->Add( TStatToolkit::MakeStatusMultGr(tree, sVar.Data(),  "", sCriteria.Data(), igr) );
    TString sYtitle = oaStatusbarNames->At(vari)->GetName(); // set better name for y axis of statuspad
    ((TMultiGraph*) oaMultGr->At(igr))->SetTitle(sYtitle.Data());
    igr++;
  }
}
//_______________________________________
Bool_t SetMuonTerminate ( AliVAnalysisMuon* muonTask, Bool_t isMC, TString taskOptions )
{
  TObjArray* terminateList = GetTerminateOptions(taskOptions,isMC);
  
  if ( !  terminateList ) return kFALSE;
  
  muonTask->SetTerminateOptions(terminateList->At(0)->GetName(),terminateList->At(1)->GetName(),terminateList->At(2)->GetName(),terminateList->At(3)->GetName());
  
  return kTRUE;
}
Example #16
0
//______________________________________________________________________________
ROMETree::ROMETree(TTree *tree, ROMEString fileName, ROMEString configInputFileName,
                   ROMEString configOutputFileName, TFile *file, Int_t fileOption,
                   Bool_t read, Bool_t write, Bool_t fill, Bool_t saveConfig, Int_t compressionLevel,
                   Long64_t maxEntries, Int_t compressionAlgorithm)
:TNamed()
,fSwitches()
,fSwitchesString("Read = BOOL : 0\n"
                 "Write = BOOL : 0\n"
                 "Fill = BOOL : 0\n"
                 "Save Config = BOOL : 0\n"
                 "Compression Level = INT : 1\n"
                 "Max Entries = INT : 0\n")
#if (ROOT_VERSION_CODE >= ROOT_VERSION(5,26,0))
,fAutoSaveSize(300000000)
,fLastSaveSize(0)
,fAutoFlushSize(-30000000)
,fCacheSize(-1)
#else
,fAutoSaveSize(100000000)
,fLastSaveSize(0)
,fAutoFlushSize(-30000000)
,fCacheSize(10000000)
#endif
,fBranchActive(0)
,fNBranchActive(0)
,fBranchRead(0)
,fNBranchRead(0)
,fTree(tree)
,fFileName(fileName)
,fConfigInputFileName(configInputFileName)
,fConfigOutputFileName(configOutputFileName)
,fFile(file)
,fFileOption(fileOption)
,fCompressionAlgorithm(compressionAlgorithm)
{
   fSwitches.fRead = read;
   fSwitches.fWrite = write;
   fSwitches.fFill = fill;
   fSwitches.fSaveConfig = saveConfig;
   fSwitches.fCompressionLevel = compressionLevel;
   fSwitches.fMaxEntries = static_cast<Int_t>(maxEntries);
   /* note: use 4byte integer for odb */
   if (maxEntries > 0) {
      fTree->SetCircular(maxEntries);
   }
   TObjArray *branches = fTree->GetListOfBranches();
   for (Int_t i = 0; i < branches->GetEntriesFast(); i++) {
      static_cast <TBranch*>(branches->At(i))->SetCompressionLevel(compressionLevel);
#if (ROOT_VERSION_CODE >= ROOT_VERSION(5,30,0))
      static_cast <TBranch*>(branches->At(i))->SetCompressionAlgorithm(compressionAlgorithm);
#endif
   }
}
Example #17
0
//________________________________________________________
TList* GFHistManager::GetObjectsOf(Int_t layer, Int_t histNo)
{
  if(!this->CheckHistNum("GetObjectsOf", layer, histNo, kFALSE)) return NULL;

  if(fObjLists && layer <= fObjLists->GetLast() && fObjLists->At(layer)){
    TObjArray* layerLists = static_cast<TObjArray*>(fObjLists->At(layer));
    if(histNo <= layerLists->GetLast() && layerLists->At(histNo)){
      return static_cast<TList*>(layerLists->At(histNo));
    }
  }

  return NULL;
}
Example #18
0
/// \brief Cache  MC production trees, store summary information in formated text files -> root trees
/// \param dataType  -
/// \param fileList
void CacheTestMCProductions(TString dataType, const char *fileList=NULL){
  AliExternalInfo info;
  info.fLoadMetadata=kFALSE;
  TObjArray* periodList = NULL;
  TArrayI nRuns;
  if (fileList!=NULL) {
    periodList=(gSystem->GetFromPipe(TString::Format("cat %s", fileList).Data())).Tokenize("\n");
    nRuns.Set(periodList->GetEntries());

  }else{
    TTree * tree = info.GetTree("MonALISA.ProductionMC","","");
    Int_t nProd=tree->GetEntries();
    periodList = new TObjArray(nProd);
    nRuns.Set(nProd);
    TLeaf *leaf = tree->GetLeaf("Tag");
    TLeaf *leafRuns = tree->GetLeaf("Number_of_runs");
    for (Int_t iProd=0; iProd<nProd; iProd++){
      tree->GetEntry(iProd);
      TString prodName=((char*)leaf->GetValuePointer());
      if (prodName.Contains("LHC")==0) continue;
      periodList->AddAt(new TObjString(((char*)leaf->GetValuePointer())),iProd);
      nRuns[iProd]=leafRuns->GetValue();
    }
    delete tree;
  }
  for (Int_t iPeriod=0; iPeriod<periodList->GetEntriesFast(); iPeriod++){
    TObjString * pName= (TObjString*)periodList->At(iPeriod);
    if (pName==NULL) continue;
    TTree* tree = info.GetTree(dataType.Data(),periodList->At(iPeriod)->GetName(),"passMC");
    if (tree){
      Int_t entries=tree->Draw("run","1","goff");
      TString sInfo=periodList->At(iPeriod)->GetName();
      sInfo+="\t";
      sInfo+=dataType;
      sInfo+="\t";
      sInfo+=TString::Format("%d\t",entries);
      sInfo+=TString::Format("%d\t",nRuns[iPeriod]);
      for (Int_t j=0; j<entries; j++) {
        sInfo+=TString::Format("%2.0f,",tree->GetV1()[j]);
        ::Info("CacheTestMCProductionsRun:","%s\t%s\t%d\t%d\t%d\t%2.0f",periodList->At(iPeriod)->GetName(),dataType.Data(),entries,nRuns[iPeriod],j, tree->GetV1()[j]);
      }
      sInfo+="0";
      ::Info("CacheTestMCProductionsPeriod:","%s\n",sInfo.Data());
      delete tree;
    }else{
      ::Error("CacheTestMCProductionsPeriod:","%s\t%s\t-1\t%d\t0",periodList->At(iPeriod)->GetName(), dataType.Data(),nRuns[iPeriod]);
    }
  }
}
Example #19
0
// Helper function to avoid code mess with TString's Tokenize
inline vector<TString> tokenize(TString line, const char* delim=" ") {
  vector<TString> retvec;
  line = line.Strip();
  // Tokenize the string, use blank as delimiter
  TObjArray* tokens = line.Tokenize(delim);
  for (int i=0; i<tokens->GetSize(); i++) {
    // For some reasons Tokenize produces an awfull lot of Null-pointers  
    if (tokens->At(i)!=0) {
      // We need to explicitly cast the array contents to TObjString  
      TString t = dynamic_cast<TObjString *>(tokens->At(i))->GetString();
      retvec.push_back(t);
    }
  }
  return retvec;
}
Example #20
0
//________________________________________________________
TList* GFHistManager::MakeObjList(Int_t layer, Int_t histoNum)
{
  // return list of objects to be drawn upon hists in pad histoNum of 'layer' 
  // (to be called if 'layer' really exist!)
  if(!fObjLists) fObjLists = new TObjArray(fDepth);
  if(layer > fObjLists->GetLast() || !fObjLists->At(layer)){
    fObjLists->AddAtAndExpand(new TObjArray(this->GetNumHistsOf(layer)),layer);
  }
  TObjArray* layerLists = static_cast<TObjArray*>(fObjLists->At(layer));
  if(histoNum > layerLists->GetLast() || !layerLists->At(histoNum)){
    layerLists->AddAtAndExpand(new TList, histoNum); 
  }

  return static_cast<TList*>(layerLists->At(histoNum));
}
Example #21
0
void formatForCmsPublic(TPad * c, TLegend *leg, TString title, int nsamp, float legx, float legy, float legw, float legh, TString legopt)
{
    if(title.Length()!=0)
    {
        TPaveText *pave = new TPaveText(0.5,0.96,0.94,0.99,"NDC");
        pave->SetBorderSize(0);
        pave->SetFillStyle(0);
        pave->SetTextAlign(32);
        pave->SetTextFont(42);

        TObjArray * tokens = title.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");
    }

    float legx1=legx, legx2=legx+legw;
    float legy1 = legy, legy2 = legy-legh*(float)(nsamp);
    if(leg==0) leg = ((TPad *)c)->BuildLegend(legx1,legy1,legx2,legy2);
    leg->SetBorderSize(0);
    leg->SetFillColor(0);
    leg->SetFillStyle(0);
    leg->SetLineWidth(1);
    leg->SetTextFont(42);
    leg->SetEntryOption(legopt);
    leg->SetX1NDC(legx1);
    leg->SetY1NDC(legy1);//-nsamp*legh);
    leg->SetX2NDC(legx2);
    leg->SetY2NDC(legy2);
}
TGraph* getContourFilledX(TH2D* inputHisto, TCanvas* goodCanvas, int Width, int Style, int FillStyle, double X){
       TCanvas* c1 = new TCanvas("temp", "temp",600,600);

       TH2D* histo = (TH2D*)inputHisto->Clone("temp");

       double levels[] = {X};
       histo->SetContour(1, levels);
       histo->Draw("CONT LIST");
       c1->Update();
       TObjArray* contours = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
       Int_t ncontours     = contours->GetSize();
       TList *list         = (TList*)contours->At(0);
       delete c1;

       goodCanvas->cd();
       printf("list size = %i\n", (int)list->GetSize());
       if(list->GetSize()<=0)return new TGraph(0);

       for(unsigned int i=0;i<list->GetSize();i++){
       TGraph* EXCLUSION   = (TGraph*)(list->At(i)->Clone("copy"));
       EXCLUSION->SetLineColor(1);
       EXCLUSION->SetLineWidth(Width);
       EXCLUSION->SetLineStyle(Style);
       EXCLUSION->SetFillColor(kBlack);
       EXCLUSION->SetFillStyle(FillStyle);
       //EXCLUSION->Draw("CL F same");
       }

       return EXCLUSION;
}
Example #23
0
TGraph *getWaveFromTxt(char *fileName)
{
  ifstream TxtFile(fileName);  
  int numLines=0;
  int numLines2=0;
  TString line;
  Double_t xVals[100000];
  Double_t yVals[100000];
  Double_t xVals2[100000];
  Double_t yVals2[100000];
  while(line.ReadLine(TxtFile)) {

    //    cout << line.Data() << endl;
    TObjArray *vals = (TObjArray*) line.Tokenize(" ");
    //    vals.Dump();
    TObjString *x=vals->At(0);
    TObjString *y=vals->At(1);
    //    cout << vals[0].Data() << "\t" << vals[1].Data() << endl;
    //    cout << x->GetString()->Data() << "\t" << y->GetString()->Data() << endl;
    xVals[numLines]=x->GetString().Atof();
    yVals[numLines]=y->GetString().Atof();
    //    yVals[numLines]=TMath::Sin(TMath::TwoPi()*500e6*xVals[numLines]);
    if(numLines%2==0) {
      xVals2[numLines2]=xVals[numLines];
      yVals2[numLines2]=yVals[numLines];
      numLines2++;
    }
    numLines++;
    
  }
  TGraph *grWave = new TGraph(numLines,xVals,yVals);
  return grWave;
}
void TBDataParser::OnCharacters(const char *characters)
{	
	if(_currentElement != NULL && !strcmp(_currentElement->Data(),"vector")) {
		TString *string = new TString(characters);
		TObjArray *values = string->Tokenize(", ");

		for(Int_t i = 0; i < values->GetEntries(); i++) {
			TObjString *object = (TObjString *) values->At(i);
			TString value = object->GetString().ReplaceAll("\n", "").ReplaceAll("\t", "").ReplaceAll(" ", "").ReplaceAll("\0", "");
			if(value.IsFloat()) {
				_vector->Fill(value.Atof());
			}
		}

		if(_vectorsStack->GetEntries() == 1) {
			_motherVecEntries = _vector->GetEntries();
		} else if(_currentMethod != NULL && !strcmp(_currentMethod->Data(),"all")) {
			for(Int_t i = 1; i < _motherVecEntries; i++) {
				TObjString *object = (TObjString *) values->First();
				TString value = object->GetString().ReplaceAll("\n", "").ReplaceAll("\t", "").ReplaceAll(" ", "").ReplaceAll("\0", "");
				if(value.IsFloat())
					_vector->Fill(value.Atof());
			}
		} 

		values->Delete();

	}

}
Example #25
0
void OCDBDefault(Int_t mode)
{

  Int_t run  = atoi(gSystem->Getenv("CONFIG_RUN"));  
  AliCDBManager* man = AliCDBManager::Instance();
  man->SetDefaultStorage("raw://");
  
  if(gSystem->Getenv("CONFIG_OCDBTIMESTAMP"))
  {
    TString t = gSystem->Getenv("CONFIG_OCDBTIMESTAMP");
    TObjArray* list =t.Tokenize("_");
    UInt_t tU[6];
    for(Int_t i=0; i<list->GetEntries(); i++)
    {
      TString st = ((TObjString*)list->At(i))->GetString();
      tU[i] =(UInt_t)atoi(st.Data());
    }
    man->SetMaxDate(TTimeStamp(tU[0], tU[1], tU[2], tU[3], tU[4], tU[5]));
    printf("*** Setting custom OCDB time stamp %s ***\n", t.Data());
  }
  
  man->SetRun(run);
  
  // set detector specific paths
  DefaultSpecificStorage(man, mode);

}
Example #26
0
   TLegend* legend(THStack* stack, Option_t* option = "lp", Bool_t addColor = kFALSE, Int_t token = -1,
                   Float_t xmin = 0.50, Float_t ymin = 0.51, Float_t xmax = 0.85, Float_t ymax = 0.92) {
      if(! stack) return 0;

      TLegend* leg = new TLegend(xmin, ymin, xmax, ymax);
      TList* list = stack->GetHists();
      TIterator* iter = list->MakeIterator();

      TObject* obj = 0;

      //Hist color iterator
      Int_t colorIt = 1;

      while (obj = iter->Next()) {
         if (! obj->InheritsFrom(TH1::Class())) continue;

         if (addColor) {
            hist::color(obj->GetName(), colorIt);
            ++colorIt;
         }

         if (token == -1)
            leg->AddEntry(obj, obj->GetTitle(), option);
         else {
            TString name(obj->GetName());
            TObjArray* a = name.Tokenize("_");
            if (a->GetEntries() <= token)
               leg->AddEntry(obj, obj->GetName(), option);
            else
               leg->AddEntry(obj, a->At(token)->GetName(), option);
         }
      }

      return leg;
   }
Example #27
0
TGraph *getScopePeriodiogram(char *fileName)
{
  ifstream CsvFile(fileName);
  
  int numLines=0;
  int numLines2=0;
  TString line;
  Double_t xVals[100000];
  Double_t yVals[100000];
  while(line.ReadLine(CsvFile)) {

    //    cout << line.Data() << endl;
    TObjArray *vals = (TObjArray*) line.Tokenize(",");
    //    vals.Dump();
    TObjString *x=vals->At(0);
    TObjString *y=vals->At(1);
    //    cout << vals[0].Data() << "\t" << vals[1].Data() << endl;
    //    cout << x->GetString()->Data() << "\t" << y->GetString()->Data() << endl;
    xVals[numLines]=x->GetString().Atof();
    yVals[numLines]=y->GetString().Atof();
    numLines++;
    
  }
  Double_t N=numLines*2;
  Double_t deltaF=(xVals[1]-xVals[0]);
  Double_t deltaT=1./(N*deltaF);
  //  cout << deltaT << endl;
  for(int i=0;i<numLines;i++) {
     xVals[i]=i*deltaF;
  }
  //  cout << xVals[0] << "\t" << xVals[numLines-1] << "\t" << xVals[1]-xVals[0] << "\n";

  TGraph *grWave = new TGraph(numLines,xVals,yVals);
  return grWave;
}
// ______________________________________________________________________________________
void SaveCanvas(const Char_t* name, Bool_t isNice = kTRUE) {
  // -- Write out canvas
  
  gSystem->Exec(Form("mkdir -p results/nice/%s/png",  name));
  gSystem->Exec(Form("mkdir -p results/nice/%s/pdf",  name));
  gSystem->Exec(Form("mkdir -p results/nice/%s/eps",  name));
  gSystem->Exec(Form("mkdir -p results/nice/%s/gif",  name));
  gSystem->Exec(Form("mkdir -p results/nice/%s/root", name));
  if (isNice) {
    gSystem->Exec(Form("mkdir -p results/nice/pdf"));
    gSystem->Exec(Form("mkdir -p results/nice/png"));
  }

  // -----------------------------------------------------
  
  for (Int_t idx = 0; idx < canA.GetEntriesFast() ; ++idx) {
    TCanvas* c = static_cast<TCanvas*>(canA.At(idx));
    if (!c)
      continue;
    
    c->SaveAs(Form("results/nice/%s/png/%s.png",   name, c->GetName()));
    c->SaveAs(Form("results/nice/%s/eps/%s.eps",   name, c->GetName()));
    c->SaveAs(Form("results/nice/%s/gif/%s.gif",   name, c->GetName()));
    c->SaveAs(Form("results/nice/%s/pdf/%s.pdf",   name, c->GetName()));
    c->SaveAs(Form("results/nice/%s/root/%s.C",    name, c->GetName()));
    c->SaveAs(Form("results/nice/%s/root/%s.root", name, c->GetName()));
    if (isNice) {
      c->SaveAs(Form("results/nice/pdf/%s.pdf",            c->GetName()));
      c->SaveAs(Form("results/nice/png/%s.png",            c->GetName()));
    }
  }
}
Example #29
0
GeoHandler& GeoHandler::i_collect(const TGeoNode* current, int level, Region rg, LimitSet ls) {
  TGeoVolume* volume = current->GetVolume();
  TObjArray* nodes = volume->GetNodes();
  int num_children = nodes ? nodes->GetEntriesFast() : 0;
  Volume vol(volume);
  Region   region = vol.region();
  LimitSet limits = vol.limitSet();

  if ( m_propagateRegions )  {
    if ( !region.isValid() && rg.isValid() )   {
      region = rg;
      vol.setRegion(region);
    }
    if ( !limits.isValid() && ls.isValid() )  {
      limits = ls;
      vol.setLimitSet(limits);
    }
  }
  (*m_data)[level].insert(current);
  //printf("GeoHandler: collect level:%d %s\n",level,current->GetName());
  if (num_children > 0) {
    for (int i = 0; i < num_children; ++i) {
      TGeoNode* node = (TGeoNode*) nodes->At(i);
      i_collect(node, level + 1, region, limits);
    }
  }
  return *this;
}
bool JPetReader::loadData(const char* treename)
{
  if (!isOpen()) {
    ERROR("File not open");
    return false;
  }
  if (!treename) {
    ERROR("empty tree name");
    return false;
  }
  fTree = dynamic_cast<TTree*>(fFile->Get(treename));
  if (!fTree) {
    ERROR("in reading tree");
    return false;
  }
  TObjArray* arr = fTree->GetListOfBranches();
  fBranch = (TBranch*)(arr->At(0));
  if (!fBranch) {
    ERROR("in reading branch from tree");
    return false;
  }
  fBranch->SetAddress(&fEntry);
  firstEntry();
  return true;
}