Пример #1
0
void
TestSPD(const TString& which, Double_t nVar=2)
{
  TFile* file = TFile::Open("forward.root", "READ");
  if (!file) return;

  Bool_t spd = which.EqualTo("spd", TString::kIgnoreCase);
  
  TList* l = 0;
  if (spd) l = static_cast<TList*>(file->Get("CentralSums"));
  else     l = static_cast<TList*>(file->Get("ForwardSums"));
  if (!l) { 
    Warning("", "%sSums not found", spd ? "Central" : "Forward");
    return;
  }

  TList* ei = static_cast<TList*>(l->FindObject("fmdEventInspector"));
  if (!l) { 
    Warning("", "fmdEventInspector not found");
    return;
  }
  
  TObject* run = ei->FindObject("runNo");
  if (!run) 
    Warning("", "No run number found");
  ULong_t runNo = run ? run->GetUniqueID() : 0;

  TH2* h = 0;
  if (spd) h = static_cast<TH2*>(l->FindObject("nClusterVsnTracklet"));
  else { 
    TList* den = static_cast<TList*>(l->FindObject("fmdDensityCalculator"));
    if (!den) { 
      Error("", "fmdDensityCalculator not found");
      return;
    }
    TList* rng = static_cast<TList*>(den->FindObject(which));
    if (!rng) { 
      Error("", "%s not found", which.Data());
      return;
    }
    h = static_cast<TH2*>(rng->FindObject("elossVsPoisson"));
  }
  if (!h) { 
    Warning("", "%s not found", spd ? nClusterVsnTracklet : "elossVsPoisson");
    return;
  }

  gStyle->SetOptFit(1111);
  gStyle->SetOptStat(0);
  TCanvas* c = new TCanvas("c", Form("Run %u", runNo));
  c->Divide(2,2);
  
  TVirtualPad* p = c->cd(1);
  if (spd) {
    p->SetLogx();
    p->SetLogy();
  }
  p->SetLogz();
  h->Draw("colz");

  TObjArray* fits = new TObjArray;
  h->FitSlicesY(0, 1, -1, 0, "QN", fits);

  TF1* mean = new TF1("mean", "pol1");
  TF1* var  = new TF1("var", "pol1");
  // mean->FixParameter(0, 0);
  // var->FixParameter(0, 0);
  for (Int_t i = 0; i < 3; i++) { 
    p = c->cd(2+i);
    if (spd) { 
      p->SetLogx();
      p->SetLogy();
    }
    TH1* hh = static_cast<TH1*>(fits->At(i));
    hh->Draw();

    if (i == 0) continue;
    
    hh->Fit((i == 1? mean : var), "+Q");
    
  }

  TGraphErrors* g1 = new TGraphErrors(h->GetNbinsX());
  g1->SetFillColor(kBlue-10);
  g1->SetFillStyle(3001);
  g1->SetLineStyle(1);
  TGraph* u1 = new TGraph(h->GetNbinsX());
  TGraph* l1 = new TGraph(h->GetNbinsX());
  u1->SetLineColor(kBlue+1);
  l1->SetLineColor(kBlue+1);
  u1->SetName("u1");
  l1->SetName("l1");
  TGraphErrors* g2 = new TGraphErrors(h->GetNbinsX());
  g2->SetFillColor(kRed-10);
  g2->SetFillStyle(3001);
  g2->SetLineStyle(2);
  TGraph* u2 = new TGraph(h->GetNbinsX());
  TGraph* l2 = new TGraph(h->GetNbinsX());
  u2->SetLineColor(kRed+1);
  l2->SetLineColor(kRed+1);
  u2->SetName("u2");
  l2->SetName("l2");
  for (Int_t i = 1; i <= h->GetNbinsX(); i++) {
    Double_t x  = hh->GetXaxis()->GetBinCenter(i);
    Double_t y  = mean->Eval(x);
    Double_t e  = var->Eval(y);
    Double_t e1 = nVar * e;
    if (spd) e1 *= TMath::Log10(e);
    // Printf("%10e -> %10e +/- %10e", x, y, ee);
    g1->SetPoint(i-1, x, y);
    g1->SetPointError(i-1, 0, e1);
    u1->SetPoint(i-1, x, y+e1);
    l1->SetPoint(i-1, x, y-e1);
    // Printf("%3d: %f -> %f +/- %f", i, x, y, ee);

    Double_t e2 = nVar*0.05*x;
    g2->SetPoint(i-1, x, x);
    g2->SetPointError(i-1, 0, e2);
    u2->SetPoint(i-1, x, x+e2);
    l2->SetPoint(i-1, x, x-e2);
  }

  p = c->cd(1);
  c->Clear();
  c->cd();
  c->SetLogz();
  h->Draw("colz");
  g1->Draw("3 same");
  u1->Draw("l same");
  l1->Draw("l same");
  g2->Draw("3 same");
  u2->Draw("l same");
  l2->Draw("l same");

  Double_t ly = 0.9;
  Double_t dy = 0.06;
  TLatex* ltx = new TLatex(0.15, ly, Form("#LTy#GT = %f + %f x",
					   mean->GetParameter(0),
					   mean->GetParameter(1)));
  ltx->SetNDC();
  ltx->SetTextSize(dy);
  ltx->SetTextAlign(13);
  ltx->Draw();

  ly -= dy + 0.01;
  ltx->DrawLatex(0.15, ly, Form("#sigma_{y} = %f + %f x", 
				var->GetParameter(0),
				var->GetParameter(1)));
  
  ly -= dy + 0.01;
  ltx->DrawLatex(0.15, ly, Form("#delta = %f #sigma %s", 
				nVar, (spd ? "log_{10}(#sigma" : "")));
	    
					   
}
void TriggerInputsForMuonEventCuts ( TString runListFilename, TString selectedInputs="", TString defaultStorage = "raw://" )
{
  AliCDBManager::Instance()->SetDefaultStorage(defaultStorage.Data());
  TObjArray inputsList;
  inputsList.SetOwner();
  
  TObjArray* selectedInputsList = selectedInputs.Tokenize(",");

  // Read input run list
  ifstream inFile(runListFilename.Data());
  TString srun = "";
  if ( inFile.is_open() ) {
    while ( ! inFile.eof() ) {
      srun.ReadLine(inFile,kFALSE);
      if ( ! srun.IsDigit() ) continue;
      
      // For each run, read trigger inputs from OCDB
      Int_t runNumber = srun.Atoi();
      AliCDBManager::Instance()->SetRun(runNumber);
      
      // Get trigger class configuration
      AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/CTP/Config");
      if ( ! entry ) continue;
      
      THashList* runInputs = new THashList();
      runInputs->SetOwner();
      runInputs->SetUniqueID((UInt_t)runNumber);
      AliTriggerConfiguration* trigConf = (AliTriggerConfiguration*)entry->GetObject();
      const TObjArray& trigInputsArray = trigConf->GetInputs();
      AliTriggerInput* trigInput = 0x0;
      TIter next(&trigInputsArray);
      while ( ( trigInput = static_cast<AliTriggerInput*>(next()) ) ) {
        if ( selectedInputsList->GetEntriesFast() > 0 && ! selectedInputsList->FindObject(trigInput->GetName()) ) continue;
        Int_t inputId = (Int_t)TMath::Log2(trigInput->GetMask());
        TObjString* currInput = new TObjString(trigInput->GetName());
        currInput->SetUniqueID(inputId);
        runInputs->Add(currInput);
      }
      inputsList.Add(runInputs);
    }
    inFile.close();
  }
  delete selectedInputsList;
  
  // Loop on the trigger inputs
  // and group runs with an equal list of inputs
  Int_t nentries = inputsList.GetEntries();
  TArrayI checkMask(nentries);
  checkMask.Reset(1);
  for ( Int_t irun=0; irun<nentries; irun++ ) {
    if ( checkMask[irun] == 0 ) continue;
    THashList* currList = static_cast<THashList*>(inputsList.At(irun));
    TString runRange = Form("Run range: %u", currList->GetUniqueID());
    for ( Int_t jrun=irun+1; jrun<nentries; jrun++ ) {
      if ( checkMask[jrun] == 0 ) continue;
      THashList* checkList = static_cast<THashList*>(inputsList.At(jrun));
      Bool_t isDifferent = kFALSE;
      for ( Int_t itrig=0; itrig<currList->GetEntries(); itrig++ ) {
        TObjString* currInput = static_cast<TObjString*>(currList->At(itrig));
        TObject* checkInput = checkList->FindObject(currInput->GetName());
        if ( ! checkInput || checkInput->GetUniqueID() != currInput->GetUniqueID() ) {
          isDifferent = kTRUE;
          break;
        }
      } // loop on trigger inputs
      if ( isDifferent ) continue;
      checkMask[jrun] = 0;
      runRange += Form(",%u", checkList->GetUniqueID());
    } // loop on runs
    
    TString outString = "\nSetTrigInputsMap(\"";
    for ( Int_t itrig=0; itrig<currList->GetEntries(); itrig++ ) {
      TObjString* currInput = static_cast<TObjString*>(currList->At(itrig));
      outString += Form("%s:%u,",currInput->GetString().Data(), currInput->GetUniqueID());
    }
    outString.Append("\");\n");
    outString.ReplaceAll(",\"","\"");
    outString += runRange;
    printf("%s\n", outString.Data());
  } // loop on runs
}
Пример #3
0
 /** 
  * Get an unsigned short parameter from the collection 
  * 
  * @param c    Collection
  * @param name Parameter name 
  * @param v    Value
  * 
  * @return Value 
  */
 static void GetParameter(TCollection* c, const TString& name, ULong_t& v)
 {
   TObject* o = GetObject(c, name, TParameter<long>::Class(), true);
   v = (!o ? 0 : o->GetUniqueID());
 }
Пример #4
0
void combinePreFullTests( string rootFullName, string rootPreTest, string rootOutputName)
{

  // open output file 
  TFile *_fileSave = TFile::Open( rootOutputName.c_str(), "new" );
  // open existing files
  TFile * fileFullTest = TFile::Open( rootFullName.c_str(),"read" );  
  TFile * filePreTest = TFile::Open( rootPreTest.c_str(),"read" );

  fileFullTest->cd();
  if( ! fileFullTest ) continue;
  
  TIter nextkey( gDirectory->GetListOfKeys() );
  TKey * key;

  cout << "Copy Subdirectory/histograms from " << fileFullTest->GetName() << endl;
  cout << "into the file: " << _fileSave->GetName() << endl;

  while( ( key = (TKey*)nextkey() ) ) {
    
    TObject * obj = key->ReadObj();
    if (obj->IsA()->InheritsFrom( "TDirectory" )){
      cout << "----- Subdir " << obj->GetName() <<  "  " << obj->GetUniqueID() << endl;
      // create same structure
      _fileSave->mkdir(obj->GetName());
      
      // loop over all histograms in subdirectory
      fileFullTest->cd(obj->GetName());
      TIter nextkey2( gDirectory->GetListOfKeys() );
      TKey * key2;
       
      string objName = obj->GetName(); 
      if (objName.substr(0,3) == "BB2"){
	cout << "for Subdirectory BB2 in file " << fileFullTest->GetName() << " do nothing"  << endl;
      }
      else{
	while( ( key2 = (TKey*)nextkey2() ) ) {
	  _fileSave->cd();	
	  TObject * obj2 = key2->ReadObj();
	  
	  if( obj2->IsA()->InheritsFrom( "TH2D" )) {
	    //cout << "2d histograms " << obj2->GetName() << endl;
	    TH2D * h2 = (TH2D*)obj2;	  
	    _fileSave->cd(obj->GetName());
	    h2->Write();	  
	  }
	  else if ( obj2->IsA()->InheritsFrom( "TH1D" )) {	  
	    //cout << "1d histograms " << obj2->GetName() << endl;
	    TH1D * h1 = (TH1D*)obj2;
	    _fileSave->cd(obj->GetName());
	    h1->Write();	  
	  }	
	}
      } // do not save BB2 from Fulltest but from next file
      // here please save BB2 to final file

    }
    else{
      // store Histograms which are not in a subdirectory HA and HD
      _fileSave->cd();
      if ( obj->IsA()->InheritsFrom( "TH1D" )) {	  
	//cout << "1d histograms " << obj->GetName() << endl;
	TH1D * h1 = (TH1D*)obj;
	_fileSave->cd();
	h1->Write();	  
      }	
      //cout << obj->GetName() <<  " this is a histogram " << endl;
    }

  }

  // Now use BB2 from Pretest and store it in the outputfile _fileSave

  if( ! filePreTest ) continue;

  filePreTest->cd();
  filePreTest->cd("BB2");
  cout << "copy BB2 histograms from file " << filePreTest->GetName() << " into " << _fileSave->GetName() << endl;
 
  TIter nextkey3( gDirectory->GetListOfKeys() );
  TKey * key3;
  while( ( key3 = (TKey*)nextkey3() ) ) {    
    TObject * obj3 = key3->ReadObj();
    if( obj3->IsA()->InheritsFrom( "TH2D" )) {
      //cout << "2d histograms " << obj3->GetName() << endl;
      TH2D * h2 = (TH2D*)obj3;	  
      _fileSave->cd("BB2");
      h2->Write();	  
    }
    else if ( obj3->IsA()->InheritsFrom( "TH1D" )) {	  
      //cout << "1d histograms " << obj3->GetName() << endl;
      TH1D * h1 = (TH1D*)obj3;
      _fileSave->cd("BB2");
      h1->Write();	  
    }
    //cout << "----- " << obj3->GetName() << endl;
  }


  fileFullTest->Close();
  filePreTest->Close();
  _fileSave->Close();

}