예제 #1
0
파일: UnitTest.C 프로젝트: alisw/AliRoot
void UnitTestAliTPCcalibAlignStreamer(const char *fname="/hera/alice/local/benchmark/vAN-20140518/000128503/cpass1/CalibObjects.root"){
  //
  // test streamer of the AliTPCcalibAlign::Streamer
  //   0.) Read old data part
  //   1.) Fill part 
  //   2.) Write part
  //   3.) Read back - consistency check
  //   4.) Destructor check
  //   5.) Memory usage print
  //
  AliLog::SetClassDebugLevel("AliTPCcalibAlign",1);
  AliTPCcalibAlign * align=0;
  Int_t nPoints=1000000;
  //
  //  0.) Read old data part
  //
  TFile *fin= TFile::Open(fname);
  if (fin){
    AliSysInfo::AddStamp("LoadFile");
    align = (AliTPCcalibAlign * )fin->Get("TPCAlign/alignTPC");
    AliSysInfo::AddStamp("LoadAlign");
    fin->Close();
    delete fin;
    if (align->GetClusterDelta(0)==NULL){
      ::Error("UnitTestAliTPCcalibAlignStreamer","Not back compatible class- GetClusterDelta");
      align->MakeResidualHistos();    
    }
    if (align->GetTrackletDelta(0)==NULL){
      ::Error("UnitTestAliTPCcalibAlignStreamer","Not back compatible class- GetTrackletDelta");
      align->MakeResidualHistosTracklet();
    }
  }else{
  }


  //
  // 1.) Fill part test
  //
  for (Int_t ipoint=0; ipoint<nPoints; ipoint++){
    Double_t xxx[10]={0};
    for (Int_t ihis=0; ihis<2; ihis++){
      THn* his = align->GetClusterDelta(ihis);
      for (Int_t iaxis=0; iaxis<his->GetNdimensions(); iaxis++) {
	xxx[iaxis]=his->GetAxis(iaxis)->GetXmin()+gRandom->Rndm()*(his->GetAxis(iaxis)->GetXmax()-his->GetAxis(iaxis)->GetXmin());
      }
      his->Fill(xxx);
    }
    for (Int_t ihis=0; ihis<4; ihis++){
      THnSparse* his = align->GetTrackletDelta(ihis);
      for (Int_t iaxis=0; iaxis<his->GetNdimensions(); iaxis++) {
	xxx[iaxis]=his->GetAxis(iaxis)->GetXmin()+gRandom->Rndm()*(his->GetAxis(iaxis)->GetXmax()-his->GetAxis(iaxis)->GetXmin());
      }
      his->Fill(xxx);
    }
  } 
  AliSysInfo::AddStamp("FillTrees");
  //
  // 2.) Write part
  //
  TFile * fout=new TFile("testAliTPCcalibAlignStreamer.root","recreate");
  AliSysInfo::AddStamp("WriteAlignStart");
  align->Write("alignTPC"); 
  AliSysInfo::AddStamp("WriteAlignEnd");
  fout->ls();
  fout->Close();
  delete fout;
  //
  // 3.) Read back - consistency check
  //
  fin=new TFile("testAliTPCcalibAlignStreamer.root");
  AliTPCcalibAlign * align2 = (AliTPCcalibAlign *)fin->Get("alignTPC");  
  AliSysInfo::AddStamp("ReadAlign2");
  if (align2==NULL){
    ::Fatal("UnitTestAliTPCcalibAlignStreamer","Alignemnt not read");
  }else{
    ::Info("UnitTestAliTPCcalibAlignStreamer","Alignemnt read-OK");
  }
  if (align2->GetClusterDelta(0)==NULL){
    ::Fatal("UnitTestAliTPCcalibAlignStreamer","histogram GetClusterDelta(0) not read");
  }else{
    ::Info("UnitTestAliTPCcalibAlignStreamer","histogram read GetClusterDelta(0) -OK");
  }
  if (align2->GetTrackletDelta(0)==NULL){
    ::Fatal("UnitTestAliTPCcalibAlignStreamer","histogram GetTrackletDelta(0)not read");
  }else{
    ::Info("UnitTestAliTPCcalibAlignStreamer","histogram read GetTrackletDelta(0) -OK");
  }

  if (align2->GetClusterDelta(0)->GetEntries()!=align->GetClusterDelta(0)->GetEntries()){
    ::Fatal("UnitTestAliTPCcalibAlignStreamer","histogram with different entries");
  }else{
    ::Info("UnitTestAliTPCcalibAlignStreamer","histogram cont. GettrackletDelta(0) -OK");
  }
  if (align2->GetTrackletDelta(0)->GetEntries()!=align->GetTrackletDelta(0)->GetEntries()){
    ::Fatal("UnitTestAliTPCcalibAlignStreamer","histogram with different entries");
  }
  //
  // 4.) Destructor check
  //
  delete align2;
  AliSysInfo::AddStamp("deleteAlign2");
  delete align;
  AliSysInfo::AddStamp("deleteAlign");
  //
  // 5.) Memory usage print
  //
  TTree * treeSys =AliSysInfo::MakeTree("syswatch.log");
  treeSys->Scan("sname:deltaVM:VM:pI.fMemResident","","colsize=30:15:15:20");

}
예제 #2
0
파일: Draw.C 프로젝트: dicakova/emt-switch
void Draw(Int_t projection = 2, Int_t cut = 3,Double_t *cuts=0, Bool_t is2D = kFALSE,
		Bool_t save = kFALSE,const char *inputFileName="histogram.root") {
	gROOT->LoadMacro("EmtMatrix.cxx+");

	TFile *f = TFile::Open(inputFileName,"READ");
	if (!f) return;

	THn *hs = (THn*) f->Get("hs");
	if (!hs) return;

	if (!cuts) {
		cuts = new Double_t[hs->GetNdimensions()-1];
		cuts[0] = 0.0; // r0x
		cuts[1] = 0.0; // r0y
		cuts[2] = 0.0; // nu01
		cuts[3] = 0.0; // nu10
		cuts[4] = 0.0; // mxy
		cuts[5] = 0.0; // myx
	}

	TH1::AddDirectory(kFALSE);

	// Setting up fixed parameters
	for (Int_t iCut =0; iCut < hs->GetNdimensions()-1; iCut++) {
		if (iCut == projection) continue;
		if (iCut == cut) continue;
		if (hs->GetAxis(iCut)->GetNbins()<2) continue;
		Printf("Cutting at cuts[%d]=%f",iCut,cuts[iCut]);
		Int_t mybin = hs->GetAxis(iCut)->FindBin(cuts[iCut]);
		hs->GetAxis(iCut)->SetRange(mybin, mybin);
	}


	if (!is2D) {
		// REAL
		hs->GetAxis(6)->SetRange(1, 1);
		// IMAGINARY
        // hs->GetAxis(6)->SetRange(2, 2);

		TCanvas *c1 = new TCanvas();
		for (Int_t i = 1; i <= hs->GetAxis(cut)->GetNbins(); i++) {
			hs->GetAxis(cut)->SetRange(i, i);

			TH1 * histNu01 = hs->Projection(projection);
			histNu01->SetStats(0);
			histNu01->SetTitle(
					TString::Format("%s for %s=%f",
							hs->GetAxis(projection)->GetTitle(),
							hs->GetAxis(cut)->GetTitle(),
							hs->GetAxis(cut)->GetBinUpEdge(i)).Data());
			;
			histNu01->GetXaxis()->SetTitle(hs->GetAxis(projection)->GetTitle());
			histNu01->GetXaxis()->CenterTitle();
			histNu01->GetYaxis()->SetTitle("eigen value");
			histNu01->GetYaxis()->CenterTitle();
			histNu01->GetYaxis()->SetRangeUser(0.0, 1.5);
			histNu01->Draw();
			if (save)
				c1->SaveAs(
						TString::Format("/tmp/%s-%s_%f.pdf",
								hs->GetAxis(projection)->GetName(),
								hs->GetAxis(cut)->GetName(),
								hs->GetAxis(cut)->GetBinUpEdge(i)).Data());
			else {
				c1->Update();
			}
		}
	} else {
		hs->GetAxis(2)->SetRange(1, 0);
		hs->GetAxis(3)->SetRange(1, 0);
		TCanvas *c3 = new TCanvas();
		TH2D * histNu01Nu10 = hs->Projection(3, 2);
		histNu01Nu10->SetStats(0);
		histNu01Nu10->GetXaxis()->SetTitle(hs->GetAxis(projection)->GetTitle());
		histNu01Nu10->GetXaxis()->CenterTitle();
		histNu01Nu10->GetYaxis()->SetTitle("eigen value");
		histNu01Nu10->GetYaxis()->CenterTitle();
		hs->GetAxis(6)->SetRange(1, 1);
		histNu01Nu10->Draw("CONT COL");
		if (save)
			c3->SaveAs(TString::Format("/tmp/%s-%s_2D.pdf",
					hs->GetAxis(projection)->GetName(),
					hs->GetAxis(cut)->GetName()).Data());
		else {
			c3->Update();
		}
	}
}