Example #1
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 #2
0
//______________________________________________________________________________
void DrawHighlightFragments(const TRsnGroup *rsng, const char *whichtag = "")
{
  if (!rsng || !rsng->GetListOfFragments()) return;
  tagname = whichtag;

  group = rsng;
  TObjArray *fragments = group->GetListOfFragments();
  gr = new TGraph(fragments->GetEntriesFast());
  for (Int_t i = 0; i < fragments->GetEntriesFast(); i++) {
    TRsnFragment *frag = group->FragmentAt(i);
    if (frag) gr->SetPoint(i, frag->GetMean(), 0.91);
  }
  //  TString cmd = TString::Format("(TGraph *)0x%lx", (ULong_t)g);
  //  Printf("cmd = %s", cmd.Data());
  //  cmd = TString::Format("((TRsnGroup *)0x%lx)->HighlightFragment(%s)",
  //                        (ULong_t)this, cmd.Data());
  //  Printf("cmd = %s", cmd.Data());
  //  TExec *ex = new TExec("ex", cmd.Data());

  TExec *ex = new TExec("ex", "HighlightFragment()");
  gr->GetListOfFunctions()->Add(ex);
  gr->SetHighlight(kTRUE);

  gr->SetTitle();
  gr->SetMarkerStyle(20);
  gr->GetYaxis()->SetTickLength(0.0);
  gr->SetBit(kCanDelete);
  gr->Draw("AP");
  gr->GetXaxis()->SetTitle("bla_bla");
}
Example #3
0
//________________________________________________________
void GFOverlay::CreateFillMeanRms(const TObjArray &hists, Int_t layer, const char *dirName,
				  std::vector<TH1*> &meanHists, std::vector<TH1*> &rmsHists) const
{
  // fill mean/rms from hists into the corresponding meanHists/rmsHists
  // if these are empty, create one hist for each slot of hists (even for empty ones!)
  if (hists.IsEmpty()) return;
  TH1 *h1 = 0;
  for (Int_t iH = 0; !h1 && iH < hists.GetEntriesFast(); ++iH) {
    h1 = static_cast<TH1*>(hists[iH]);
  }
  if (!h1 || h1->GetDimension() > 1) return; // only for 1D hists
  
  if (meanHists.empty()) { // create mean/RMS hists if not yet done
    const Float_t min = h1->GetXaxis()->GetXmin()/3.;
    const Float_t max = h1->GetXaxis()->GetXmax()/3.;
    const Int_t nBins = h1->GetNbinsX()/2;
    for (Int_t iHist = 0; iHist < hists.GetEntriesFast(); ++iHist) {
      TH1 *hMean = new TH1F(Form("mean%d_%d", layer, iHist), Form("%s: mean", dirName),
			    nBins, min, max);
      meanHists.push_back(hMean);
      TH1 *hRms = new TH1F(Form("rms%d_%d", layer, iHist), Form("%s: RMS", dirName),
			   nBins, 0., max);
      rmsHists.push_back(hRms);
    }
  }

  // now fill mean and rms hists
  for (Int_t iHist = 0; iHist < hists.GetEntriesFast(); ++iHist) {
    TH1 *h = static_cast<TH1*>(hists[iHist]);
    if (!h) continue;
    meanHists[iHist]->Fill(h->GetMean());
    rmsHists[iHist]->Fill(h->GetRMS());
  }
}
void Output::fixLeafOffsets( TBranch * b)
{
  // recalculates the addresses for all the leaves.
  // 
  // when constructing a branch with containing a variable length array with the index
  // variable in the same branch it is not possible to specify the span of the index variable
  // This span defaults to zero. When the addresses are asigned to the various leaves in the branch
  // it calculates the size of the particular leaf (variable length array) in the buffer by looking 
  // at the span of the index variable - 0 in this case! using the method TLeaf::GetLen(). 
  // The following code shoudl be applied to the branch after the spans of the index variables have been
  // specified manually using the TLeaf::SetMaximum method. This time the GetLen method calculates the correct offset.

  TObjArray * leaves = b->GetListOfLeaves();
  char * addr = b->GetAddress();
  int offset = 0;
  int nleaves = leaves->GetEntriesFast();
  
  // loop over the leaves:
  for( int i =0; i < nleaves; ++i) {
    TLeaf * leaf = (TLeaf *)leaves->UncheckedAt(i);
    leaf->SetAddress( addr + offset );
    int oldOffset = leaf->GetOffset();
    leaf->SetOffset( offset );
    //std::cout << " offset changed from : " << oldOffset << " to " << offset << std::endl;
    TLeaf * index = leaf->GetLeafCount();
    int nelements = 1;
    if( index ) {
      nelements = index->GetMaximum(); // deal with variable length arrays
    } else {
      nelements = leaf->GetLenStatic(); // deal with single variables and fixed length arrays
    }
    offset += leaf->GetLenType() * nelements;
  }
}
Example #5
0
Bool_t
RecoParamWithTPCDistortions(AliCDBManager *man) {

  // check methods exist
  if (!AliRecoParam::Class()->GetMethodAny("SuggestRunEventSpecie"))
    return kFALSE;
  if (!AliTPCRecoParam::Class()->GetMethodAny("GetUseCorrectionMap"))
    return kFALSE;
  
  // get event specie from GRP
  AliCDBEntry *grpe = man->Get("GRP/GRP/Data");
  if (!grpe) return kFALSE;
  AliGRPObject *grp = (AliGRPObject *)grpe->GetObject();
  AliRecoParam::EventSpecie_t evs = AliRecoParam::SuggestRunEventSpecie(grp->GetRunType(),
									grp->GetBeamType(),
									grp->GetLHCState());

  // get TPC RecoParam for event specie
  AliCDBEntry *pare = man->Get("TPC/Calib/RecoParam");
  if (!pare) return kFALSE;
  TObjArray *parl = (TObjArray *)pare->GetObject();
  AliTPCRecoParam *par = NULL;
  for (Int_t i = parl->GetEntriesFast(); i--;) {
    AliTPCRecoParam *p = (AliTPCRecoParam *)parl->UncheckedAt(i);
    if (!p || !(p->GetEventSpecie() & evs)) continue;
    par = p;
    break;
  }
  // check if use correction map
  if (!par->GetUseCorrectionMap())
    return kFALSE;

  return kTRUE;
  
}
// ______________________________________________________________________________________
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()));
    }
  }
}
Int_t CountChargedinScint()
{
  Int_t ncharged = 0;

  TObjArray* tracks = gGeoManager->GetListOfTracks();

  for(Int_t i=0,l=tracks->GetEntriesFast();i<l;++i) {
    TVirtualGeoTrack* track = (TVirtualGeoTrack*)tracks->At(i);
    //track->Print();
    
    Int_t pdg = track->GetPDG();
    Double_t charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
    if( charge == 0 ) continue;
    
    Double_t x,y,z,t;
    TGeoNode* lastnode = NULL;
    for(Int_t j=0,lp=track->GetNpoints();j<lp;++j) {
      track->GetPoint(j,x,y,z,t);
      TGeoNode* node = gGeoManager->FindNode(x,y,z);
      if(! node ) continue;
      //node->Print();
      
      if( lastnode == node ) continue;
      lastnode = node;
      //is scintillator ?
      //std::cout << node->GetMedium()->GetMaterial()->GetZ() << std::endl;
      
      if(node->GetMedium()->GetMaterial()->GetZ() == 1)
	++ncharged;
    }
    //std::cout << "charge:" << ncharged << std::endl;
  }
  //std::cout << ncharged << std::endl;
  return ncharged;
}
Example #8
0
//________________________________________________________
Int_t GFHistManager::GetNumHistsOf(Int_t layer)
{
  if(!this->CheckDepth("GetNumHistsOf", layer, kFALSE)) return 0;
  TObjArray* layerHists = static_cast<TObjArray*>(fHistArrays->At(layer));
  if(layerHists) return layerHists->GetEntriesFast();
  return 0;
}
Example #9
0
void PublicationHisto(TString config=""){
    //gROOT->SetStyle("Plain"); gROOT->ForceStyle();
    gROOT->ProcessLine(".x /home/aran/.rootlogon.C");
    gStyle->SetPadBottomMargin(.160); // Need this for subscripts
    gStyle->SetPadTopMargin(.08);
    
    TEnv *params = new TEnv("PubHisto");
    params->ReadFile (config, kEnvChange);

    TString type=params->GetValue("Histo.Type", "PublicationHisto");
    if (type != "PublicationHisto"){
	printf(" Must have Histo.Type: PublicationHisto in config file");
	return;
    }
    // Fetch the histos from the different files:
    TString hname=params->GetValue("Histo.Name", "BOGUSNAME");
    TObjArray sameHistos;
    if (hname == "3"){// ok this means we want to add 3 histos
	TString h1=params->GetValue("Histo.1.Name", "BOGUS_H1");
	TString h2=params->GetValue("Histo.2.Name", "BOGUS_H2");
	TString h3=params->GetValue("Histo.3.Name", "BOGUS_H3");
	printf("Adding histos: %s, %s, %s \n",h1.Data(),h2.Data(), h3.Data());
	TObjArray sameHistos = GetThreeSameHistos(h1,h2,h3,params);
    } else {// normal case
	TObjArray sameHistos = GetSameHistos(hname,params);    
    }

    // Plot them:
    printf (" Found %3i histos \n",sameHistos.GetEntriesFast());
    TCanvas *c1 = new TCanvas("c1","PubHist");
    PlotPubHisto(sameHistos,params);
    TString outfile=params->GetValue("Output.File", "dummy.eps");
    c1->SaveAs(outfile.Data());
}
Example #10
0
int compareFileAges(const char* newestCandidate, const char* filesToCompare) {

  Long_t dummy = 0;
  Long_t candidateTime = 0;
  Long_t comparisonTime = 0;
  int found = !gSystem->GetPathInfo(newestCandidate, &dummy, &dummy, &dummy,
                                   &candidateTime);
  //cout << newestCandidate << ": " << candidateTime << endl;
  // If the first file is not found, return 1
  if(!found)
    return 1;

  // Separate files in the list into an array
  TObjArray* compareList = TString(filesToCompare).Tokenize(" ");

  // Go through the array
  for (Int_t iFile = 0; iFile < compareList->GetEntriesFast(); ++iFile) {
    found = !gSystem->GetPathInfo(compareList->At(iFile)->GetName(), &dummy,
                                 &dummy, &dummy, &comparisonTime);
    //cout << compareList->At(iFile)->GetName() << ": " << comparisonTime << endl;
    // If the first file doesn't have the biggest modification time, return 1
    if(found && candidateTime <= comparisonTime)
      return 1;
  }

  // The first file had the biggest modification time: return 0
  return 0;
}
Example #11
0
// This piece of code is borrowed from Argo written by Nathaniel Tagg
std::vector<std::string> DataFetcher::FindLeavesOfType(std::string pattern) {
  /// Look in the tree and try to find a leaf element that matches 'pattern'.
  /// Return the full name of that leaf.
  std::vector<std::string> leaf_names;

  // Strip whitespace from pattern.
  pattern.erase(std::remove_if(pattern.begin(), pattern.end(), ::isspace),
      pattern.end());

  TObjArray * list = tree_->GetListOfLeaves();
  for (int i = 0; i < list->GetEntriesFast(); ++i) {
    TObject * o = list->At(i);
    TLeaf * leaf = (TLeaf *) o;
    std::string name = leaf->GetTypeName();
    // Strip whitespace from pattern.
    name.erase(std::remove_if(name.begin(), name.end(), ::isspace),
        name.end());
    size_t found = name.find(pattern);
    if (found != std::string::npos) {
      // Return this match.
      leaf_names.push_back(leaf->GetName());
    }
  }
  return leaf_names;
}
Example #12
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 #13
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;
}
Example #14
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 #15
0
//________________________________________________________
bool GFOverlay::KeyContainsListMember(const TString &key, const TObjArray &list) const
{
  for (Int_t i = 0; i < list.GetEntriesFast(); ++i) {
    if (key.Contains(list[i]->GetName())) return true; 
  }

  return false;
}
Example #16
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);
    }
  }
}
void read_trigger_thresholds()
{
  // Load libraries
  gROOT->Macro("loadMuDst.C");
  gROOT->Macro("LoadLogger.C");

  gSystem->Load("StTpcDb");
  gSystem->Load("StDetectorDbMaker");
  gSystem->Load("StDbUtilities");
  gSystem->Load("StMcEvent");
  gSystem->Load("StMcEventMaker");
  gSystem->Load("StDaqLib");
  gSystem->Load("StEmcRawMaker");
  gSystem->Load("StEmcADCtoEMaker");
  gSystem->Load("StEpcMaker");
  gSystem->Load("StEmcSimulatorMaker");
  gSystem->Load("StDbBroker");
  gSystem->Load("St_db_Maker");
  gSystem->Load("StEEmcUtil");
  gSystem->Load("StEEmcDbMaker");
  gSystem->Load("StTriggerUtilities");

  ifstream in("test.out");
  assert(in);
  in.seekg(0,ios::end);
  streampos length = in.tellg();
  in.seekg(0,ios::beg);
  char* buffer = new char[length];
  in.read(buffer,length);
  in.close();
  TBufferFile buf(TBuffer::kRead);
  buf.SetBuffer(buffer,length,kFALSE);

  TObjArray* a = 0;
  buf >> a;
  a->Print();

  cout << "Total entries: " << a->GetEntriesFast() << endl;

  for (int i = 0; i < a->GetEntriesFast(); ++i) {
    StTriggerThreshold* th = (StTriggerThreshold*)a->At(i);
    th->print();
  }
}
void collectContours(map<string,TGraph2D *>& m_graphs,
		     const vector<string>&  keys,
		     map<string,double>& m_contourlevels,
		     map<string,TList *>& m_contours)
{
  cout << "CollectContours" << endl;

  TCanvas *canv = new TCanvas("dummy","dummy",100,100);
  //canv->Divide(3,2);

  std::cout << "keys.size() = " << keys.size() << std::endl;

  //process TGraph2Ds into contours at levels m_contourlevels
  for (size_t i=0; i<keys.size(); i++) {
    double clev = m_contourlevels[keys[i]];
    TGraph2D *gr2d = m_graphs[keys[i]];
    std::cout << "gr2d = " << gr2d << std::endl;
    std::cout << "gr2d->GetN() = " << gr2d->GetN() << std::endl;


    if (gr2d && (gr2d->GetN() > 0)) {
      gr2d->GetHistogram()->SetContour(1, &clev);
      //canv->cd(i+1);
      cout << "drawing... " << endl;

      gr2d->Draw("CONT LIST"); // it's stupid, but only "CONT" will generate the list
      gPad->Update();

      TObjArray *contours = (TObjArray *)gROOT->GetListOfSpecials()->FindObject("contours");
      assert(contours);

      TList *newlist = 0;
      for (int ci=0; ci<contours->GetEntriesFast(); ci++) {
	TList *contLevel = (TList*)contours->At(ci);
	printf("%s: Contour %d has %d Graphs\n", keys[i].c_str(), ci, contLevel->GetSize());

	if (contLevel->GetSize()) {
	  assert(contLevel->First());
	  if (!newlist) newlist = new TList();
	  TGraph *curv = (TGraph*)(contLevel->First());

	  for (int j=0; j<contLevel->GetSize(); j++) {
	    newlist->Add((TGraph *)(curv->Clone()));
	    curv=(TGraph *)(contLevel->After(curv));
	  }
	}
      } // contour loop

      cout << "Inserting contour list for "<< keys[i] << " newlist="<<newlist<<endl;
      m_contours[keys[i]] = newlist;

    } // if (gr2d)
  } // key loop

  //delete canv;
}                                                     // collectContours
Example #19
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++;
  }
}
Example #20
0
//________________________________________________________
TCanvas*  GFHistManager::GetCanvas(Int_t layer, Int_t number)
{
  // after draw!!
  if(!fCanArrays || fCanArrays->GetEntriesFast() <= layer) return NULL;
  TObjArray* cans = static_cast<TObjArray*>(fCanArrays->At(layer));
  if(cans && cans->GetEntriesFast() > number){
    return static_cast<TCanvas*>(cans->At(number));
  }
  return NULL;
}
Example #21
0
void ResetDeleteBranches(TTree* tree) {
    TObjArray* branches = tree->GetListOfBranches();
    Int_t nb = branches->GetEntriesFast();
    for (Int_t i = 0; i < nb; ++i) {
        TBranch* br = (TBranch*) branches->UncheckedAt(i);
        if (br->InheritsFrom(TBranchElement::Class())) {
            ((TBranchElement*) br)->ResetDeleteObject();
        }
    }
}
Example #22
0
  /** 
   * Add distributions from other experiments to stacks 
   * 
   * @param name     Name of current bin 
   * @param i        Index of current bin
   * @param sNN      Center of mass energy 
   * @param allALICE Stack of ALICE data 
   * @param allCMS   Stack of CMS data 
   * @param alice    Possible ALICE result on return
   * @param cms      Possible CMS result on return
   */
  void Other2Stack(const TString& name, Int_t i,
		   UShort_t sNN, TMultiGraph* allALICE, TMultiGraph* allCMS,
		   TGraph*& alice, TGraph*& cms) 
  {
    if (!allALICE && !allCMS) return;

    TString tmp(name);
    tmp.ReplaceAll("p", "+");
    tmp.ReplaceAll("m", "-");
    tmp.ReplaceAll("_", " ");
    tmp.ReplaceAll("d", ".");
    TObjArray* tokens = tmp.Tokenize(" ");
    if (!tokens || tokens->GetEntriesFast() < 2) { 
      Error("Other2Stack", "Failed to decode eta range from %s", name.Data());
      if (tokens) tokens->Delete();
      return;
    }
    Double_t eta1 = static_cast<TObjString*>(tokens->At(0))->String().Atof();
    Double_t eta2 = static_cast<TObjString*>(tokens->At(1))->String().Atof();
    tokens->Delete();
    
    if (TMath::Abs(eta2+eta1) > 1e-3) {
      // Not symmetric bin 
      // Info("Other2Stack", "bin [%f,%f] is not symmetric (%f)",
      //      eta1, eta2, TMath::Abs(eta2-eta1));
      return;
    }
    Double_t aEta = TMath::Abs(eta1);

    Int_t open, closed;
    Double_t factor; 
    Float_t  size;
    BinAttributes(i, open, closed, size, factor);

    if (allALICE) {
      TGraphAsymmErrors* g = GetOther(1, aEta, sNN, factor);
      if (g) {
	g->SetMarkerStyle(closed);
	g->SetMarkerColor(kColorALICE);
	g->SetMarkerSize(size);
	allALICE->Add(g, "p same");
	alice = g;
      }
    }
    if (allCMS) {
      TGraphAsymmErrors* g = GetOther(0, aEta, sNN, factor);
      if (g) {
	g->SetMarkerStyle(closed);
	g->SetMarkerColor(kColorCMS);
	g->SetMarkerSize(size);
	allCMS->Add(g, "p same");
	cms = g;
      }
    }
  }
Example #23
0
//________________________________________________________
TObjArray GFOverlay::GetTypeWithNameFromDirs(const TClass *aType, const char *name,
					     const TObjArray &dirs) const
{
  // dirs must contain TDirectory only!
  // do Get(name) for all dirs and adds result to return value if type fits, otherwise Add(NULL)
  // result has length of dirs

  TObjArray result(dirs.GetEntriesFast()); // default length
  for (Int_t iDir = 0; iDir < dirs.GetEntriesFast(); ++iDir) {
    TDirectory *aDir = static_cast<TDirectory*>(dirs[iDir]);
    TObject *obj = (aDir ? aDir->Get(name) : 0);
    if (obj && !obj->InheritsFrom(aType)) {
      // delete obj; NO! deletes things found in previous calls...
      obj = 0;
    }
    result.Add(obj); // might be NULL
  }

  return result;
}
Example #24
0
void PublishCanvas(TList *qaList, const char* det, const char* name, TString nadd)
{
  //
  // draw all nSigma + signal histo
  //


  TObjArray arrHistos;

  TPaveText pt(.1,.1,.9,.9,"NDC");
  pt.SetBorderSize(1);
  pt.SetFillColor(0);
  pt.SetTextSizePixels(16);
  pt.AddText(Form("%s PID QA",det));
  if (!nadd.IsNull()){
    pt.AddText(nadd.Data());
    nadd.Prepend("_");
  }
  arrHistos.Add(&pt);

  TH2 *hSig=Get2DHistogramfromList(qaList,det,Form("hSigP_%s",det));
  if (hSig){
    hSig->SetOption("colz");
    arrHistos.Add(hSig);
  }

  for (Int_t i=0;i<AliPID::kSPECIESC;++i){
    //     for (Int_t i=0;i<AliPID::kSPECIES;++i){
    if (i==(Int_t)AliPID::kMuon) continue;
    TH2 *h=Get2DHistogramfromList(qaList,det,Form(name,AliPID::ParticleName(i)));
    if (!h) continue;
    h->SetOption("colz");
    AddFit(h);
    arrHistos.Add(h);
  }

  Int_t nPads=arrHistos.GetEntriesFast();
  Int_t nCols = (Int_t)TMath::Ceil( TMath::Sqrt(nPads) );
  Int_t nRows = (Int_t)TMath::Ceil( (Double_t)nPads/(Double_t)nCols );

  
  fCanvas->Divide(nCols,nRows);


  for (Int_t i=0; i<nPads;++i) {
    fCanvas->cd(i+1);
    SetupPadStyle();
    arrHistos.At(i)->Draw();
  }

  fCanvas->Update();
  fCanvas->Clear();

}
Example #25
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 #26
0
void getT0RecoParam(Int_t run)
{
  
  // Read calibration coefficients into the Calibration DB
  // Arguments:
  AliCDBManager* man = AliCDBManager::Instance();
   man->SetDefaultStorage("raw://");
  //  man->SetDefaultStorage("local:///home/alla/alice/Jul14/OCDB/");
  man->SetRun(run);
  AliCDBEntry *entry = AliCDBManager::Instance()->Get("T0/Calib/RecoParam");
  AliT0RecoParam* recoParam = 0x0;
  cout<<" entry "<< entry<<endl;
  if(entry) {
    // load recoParam according OCDB content (single or array)
    //    if (!(recoParam = dynamic_cast<AliT0RecoParam*>(entry->GetObject()))) {
    
    TObjArray* recoParamArray = static_cast<TObjArray*>(entry->GetObject());     
    cout<<" TObjArray* recoParamArray "<<recoParamArray->GetEntriesFast()<<endl;
    for(Int_t ie = 0; ie < recoParamArray->GetEntriesFast()-1; ie++) {
      
      recoParam = static_cast<AliT0RecoParam*>(recoParamArray->UncheckedAt(ie));	
      cout<<ie<<endl;
      cout<<" eq "<<recoParam->GetEq()<<endl;
      //	 recoParam->Dump();
      cout<<" cfd range "<<recoParam->GetLow(300)<<" amplitude "<<recoParam->GetLow(200)<<" "<<recoParam->GetHigh(200)<<endl;
      
      for (int i=0; i<500; i++) 
	if( recoParam->GetLow(i) !=0) cout<<i<<" low "<<recoParam->GetLow(i)<<"   "<<endl;
      for (int i=0; i<500; i++) 
	if( recoParam->GetHigh(i) !=50000)  cout<<i<<" high "<<recoParam->GetHigh(i)<<endl;
      recoParam = 0x0;
    }
  }
  else 
    cout<<" no entry "<<endl;
  
  
}
Example #27
0
//------------------------------
TCut m(TTree *tree, TString var1, TString var2){
  Double_t min= tree->GetMinimum("nll_MarkovChain_local_");
  TString selMin="nll_MarkovChain_local_ == "; selMin+=min;
  
  tree->Draw(">>entrylist",selMin,"entrylist");
  TEntryList *entrylist=(TEntryList*) gROOT->FindObject("entrylist");
  if(entrylist->GetN()!=1){
    std::cout << "Entrylist N=" << entrylist->GetN() << std::endl;
    return "";
  }
  Long64_t minEntry = entrylist->GetEntry(0);

  TObjArray *branchArray = tree->GetListOfBranches();
  branchArray->GetEntries();

  std::vector<TString> minSel_vec;

  for(int i=0; i < branchArray->GetEntriesFast(); i++){
    TBranch *b= (TBranch *) branchArray->At(i);
    TString name=b->GetName();
    Double_t address;
    b->SetAddress(&address);
    b->GetEntry(minEntry);
    name+="==";name+=address;
    minSel_vec.push_back(name);
  }

  TCut cut;
  for(int i=0; i < branchArray->GetEntriesFast(); i++){
    TBranch *b= (TBranch *) branchArray->At(i);
    TString name=b->GetName();
    if(name.Contains("nll")) continue;
    if(name.Contains(var1)) continue;
    if(name.Contains(var2)) continue;
    cut+=minSel_vec[i];
  }
  return cut;
}
Example #28
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 #29
0
//________________________________________________________
Bool_t GFHistManager::CheckHistNum(const char* method, Int_t layer, 
				 Int_t histNum, Bool_t mayExpand)
{
  // true if hist 'histNum' exists in 'layer' 
  // if(mayExpand == kTRUE) expands to this size if necessary! (default: kFALSE)
  if(!this->CheckDepth(method, layer, mayExpand)) return kFALSE; 
  

  TObjArray * layerArr = static_cast<TObjArray*>(fHistArrays->At(layer));
  if(histNum < 0) {
    this->Warning("CheckHistNum", "histogram number %d requested!", histNum);
    return kFALSE;
  }
  while(histNum >= layerArr->GetEntriesFast()){
    if(mayExpand){
      layerArr->AddAtAndExpand(new GFHistArray, layerArr->GetEntriesFast());
    } else {
      this->Warning("CheckHistNum", "layer %d has only %d histograms, number %d requested!",
		    layer, layerArr->GetEntriesFast(), histNum);
      return kFALSE;
    }
  }
  return kTRUE;
}
void selector::Begin(TTree *) {
//  Can pass a string option which is 4th argument of runselector.C
//  You can retrieve the option in any function in this file.
  TString option = GetOption();
  printf("Begin: The option is %s\n",option.Data());
//  This code parses the options and finds options separated by white space
  TObjArray *Strings = option.Tokenize(" "); 
  if(Strings->GetEntriesFast()) {
    TIter iString(Strings);
    TObjString* os=0;
    Int_t j=0;
    while ((os=(TObjString*)iString())) {
      printf("token #%d ='%s'\n",j++,  os->GetString().Data());
    }
  }
  delete Strings;

//  Print help message to users
  if( option == "-h" ) {
    printf("selector_null: sample selector function\n");
    printf("    Edward Diehl  3/29/09\n");
    exit(0);    //Abort job
  }

//Book histograms
//  histlist = new TList();
  raw_adc = new TH1F("raw_adc","ADC",100,0.,500.);
  raw_tdc = new TH1F("raw_tdc","TDC",100,0.,3000.);
  raw_adc_ntube = new TH2F("raw_adc_ntube","ADC",100,0.,500.,1,0.,MAXCHAMBERS);
  rawMdt_gposX_gposY = new TH2F("rawMdt_gposX_gposY","rawMdt XvY",100,-15,15,100,-15,15);
  rawMdt_gposY_gposZ = new TH2F("rawMdt_gposY_gposZ","rawMdt YvZ",100,-15,15,100,-15,15);
//Loop over chambers
/*  for(int i=0;1<MAXCHAMBERS;i++){
     rawadc_chamber[i] = new TH1F(Form("rawADC_%s",chlist[i].calname),Form("%s raw ADC",chlist[i].calname),100,0,500); //chlist is array in chamberlist that contains detector names e.g BEE_1_2
 //  }

//loop over multilayer and chambers
  for(int j=0; j<MAXCHAMBERS; j++ ) {   //Chambers
    for( int i=0; i<2; i++ ) {           //ML
       int ml = i + 1 ;
       raw_adc[j][i] = 
       raw_tdc[j][i] =          
*/


   
  
}