Example #1
0
cmsListDir( const TObjString * firstdirname, const TDirectory * firstDir )
 {
  TObjArray * dirs = new TObjArray ;
  dirs->AddLast(new TPair(firstdirname,firstDir)) ;
  TList * keys ;
  TKey * key ;
  TH1 * histo ;
  TIter nextDir(dirs) ;
  TPair * pair ;
  const TObjString * dirname ;
  const TDirectory * dir ;
  while (pair = (TPair *)nextDir())
   {
    dirname = (TObjString *)pair->Key() ;
    dir = (TDirectory *)pair->Value() ;
    keys = dir->GetListOfKeys() ;
    TIter nextKey(keys) ;
    while (key = (TKey *)nextKey())
     {
      obj = key->ReadObj() ;
      if (obj->IsA()->InheritsFrom("TDirectory"))
       {
        dirs->AddLast(new TPair(new TObjString(dirname->String()+"/"+obj->GetName()),obj)) ;
       }
      else if (obj->IsA()->InheritsFrom("TH1"))
       {
        histo = (TH1 *)obj ;
        std::cout
          <<"Histo "<<dirname->String()<<"/"<<histo->GetName()
          <<" has "<<histo->GetEffectiveEntries()<<" entries"
          <<" of mean value "<<histo->GetMean()
          <<std::endl ;
       }
      else
       { std::cout<<"What is "<<obj->GetName()<<" ?"<<std::endl ; }
     }
   }
 }
Example #2
0
//____________________________________________________
TObjArray* CreateRecoParamObject()
{
  TObjArray *recos = new TObjArray(4);

  AliTRDrecoParam *rec = 0x0;
  recos->AddLast(rec = AliTRDrecoParam::GetLowFluxParam());
  rec->SetEventSpecie(AliRecoParam::kLowMult);
  rec->SetNameTitle("LOW", "TRD Low Flux Reco Param");
  rec->SetStreamLevel(AliTRDrecoParam::kTracker, 1);
  rec->SetAsDefault();
  // further settings for low flux reco param
  // reco->SetThisAndThat()

  recos->AddLast(rec = AliTRDrecoParam::GetHighFluxParam());
  rec->SetEventSpecie(AliRecoParam::kHighMult);
  rec->SetNameTitle("HIGH", "TRD High Flux Reco Param");
  rec->SetStreamLevel(AliTRDrecoParam::kTracker, 1);

  recos->AddLast(rec = AliTRDrecoParam::GetCosmicTestParam());
  rec->SetEventSpecie(AliRecoParam::kCosmic);
  rec->SetNameTitle("COSMIC", "TRD Cosmic Reco Param");
  rec->SetStreamLevel(AliTRDrecoParam::kTracker, 1);
  rec->SetRawStreamVersion("FAST");

  recos->AddLast(rec = AliTRDrecoParam::GetCosmicTestParam());
  rec->SetEventSpecie(AliRecoParam::kCalib);
  rec->SetNameTitle("CALIBRATION", "TRD Calibration Reco Param");
  rec->SetStreamLevel(AliTRDrecoParam::kTracker, 1);
  rec->SetRawStreamVersion("FAST");

//  recos->AddLast(rec = AliTRDrecoParam::GetLowFluxParam());
//  rec->SetNameTitle("HLT", "TRD HLT Reco Param");
//  rec->SetChi2Y(.1);
//  rec->SetChi2Z(5.);

  return recos;
}
Example #3
0
void ilceve_init_import_macros()
{
  // Put macros in the list of browsables, add a macro browser to
  // top-level GUI.

  TString macdir("$(ILC_ROOT)/EVE/ilc-macros");
  gSystem->ExpandPathName(macdir);

  TFolder* f = gEve->GetMacroFolder();
  void* dirhandle = gSystem->OpenDirectory(macdir.Data());
  if (dirhandle != 0)
  {
    char* filename;
    TPMERegexp re("\\.C$");
    TObjArray names;
    while ((filename = gSystem->GetDirEntry(dirhandle)) != 0)
    {
      if (re.Match(filename))
	names.AddLast(new TObjString(filename));
    }
    names.Sort();

    for (Int_t ii=0; ii<names.GetEntries(); ++ii)
    {
      TObjString * si = (TObjString*) names.At(ii);
       f->Add(new TEveMacro(Form("%s/%s", macdir.Data(), (si->GetString()).Data())));
    }
  }
  gSystem->FreeDirectory(dirhandle);

  gROOT->GetListOfBrowsables()->Add(new TSystemDirectory(macdir.Data(), macdir.Data()));

  {
    TEveBrowser   *br = gEve->GetBrowser();
    TGFileBrowser *fb = 0;
    fb = br->GetFileBrowser();
    fb->GotoDir(macdir);
    {
      br->StartEmbedding(0);
      fb = br->MakeFileBrowser();
      fb->BrowseObj(f);
      fb->Show();
      br->StopEmbedding();
      br->SetTabTitle("Macros", 0);
      br->SetTab(0, 0);
    }
  }
}
Example #4
0
void Example_tags(TString topDir = "/star/rcf/GC/daq/tags")
{
//////////////////////////////////////////////////////////////////////////
//                                                                      //
// Example_tags.C                                                       //
//                                                                      //
// shows how to use the STAR tags files                                 //
// Input: top level directory                                           //
//                                                                      //
// what it does:                                                        //
// 1. creates TChain from all tags files down from the topDir           //
// 2. loops over all events in the chain                                //
//                                                                      //
// owner: Alexandre V. Vaniachine <*****@*****.**>                //
//////////////////////////////////////////////////////////////////////////

  gSystem->Load("libTable");
  gSystem->Load("St_base");
  // start benchmarks
  gBenchmark = new TBenchmark();
  gBenchmark->Start("total");
   
  // set loop optimization level
  gROOT->ProcessLine(".O4");
  // gather all files from the same top directory into one chain
  // topDir must end with "/"
  topDir +='/';
  St_FileSet dirs(topDir);
  St_DataSetIter next(&dirs,0);
  St_DataSet *set = 0; 
  TChain chain("Tag");
  while ( (set = next()) ) {           
    if (strcmp(set->GetTitle(),"file") || 
	!(strstr(set->GetName(),".tags.root"))) continue;
    chain.Add(gSystem->ConcatFileName(topDir,set->Path()));
  }
  UInt_t nEvents = chain->GetEntries();
  cout<<"chained "<<nEvents<<" events "<<endl;

  TObjArray *files = chain.GetListOfFiles();
  UInt_t nFiles = files->GetEntriesFast();
  cout << "chained " << nFiles << " files from " << topDir << endl;

  TObjArray *leaves = chain.GetListOfLeaves();
  Int_t nleaves = leaves->GetEntriesFast();

  TString tableName = " ";
  TObjArray *tagTable = new TObjArray;

  Int_t tableCount = 0;
  Int_t *tableIndex = new Int_t[nleaves];
  Int_t tagCount = 0;

  // decode tag table names
  for (Int_t l=0;l<nleaves;l++) {
    TLeaf *leaf = (TLeaf*)leaves->UncheckedAt(l);
    tagCount+=leaf->GetNdata();
    TBranch *branch = leaf->GetBranch();
    // new tag table name
    if ( strstr(branch->GetName(), tableName.Data()) == 0 ) {
      tableName = branch->GetName();
      // the tableName is encoded in the branch Name before the "."
      tableName.Resize(tableName->Last('.'));
      tagTable->AddLast(new TObjString(tableName.Data()));
      tableCount++;
    }
    tableIndex[l]=tableCount-1;
  }
  cout << " tot num tables, tags = " << tableCount << "   " 
       << tagCount << endl << endl;

  //EXAMPLE 1: how to print out names of all tags and values for first event
  for (l=0;l<nleaves;l++) {
    leaf = (TLeaf*)leaves->UncheckedAt(l);
    branch = leaf->GetBranch();
    branch->GetEntry();
    // tag comment is in the title
    TString Title = leaf->GetTitle();
    Int_t dim = leaf->GetNdata();
    if (dim==1) {
      Title.ReplaceAll('['," '"); 
      Title.ReplaceAll(']',"'"); 
    }
    cout << "\n Table: ";
    cout.width(10);
    cout << ((TObjString*)tagTable->UncheckedAt(tableIndex[l]))->GetString()
	 <<" -- has tag: " << Title << endl;
    for (Int_t i=0;i<dim;i++) {
      cout <<"                               "<< leaf->GetName();
      if (dim>1) cout << '['<<i<<']';
      cout << " = " << leaf->GetValue(i) << endl; 
    }
  }

  // EXAMPLE 2: how to make a plot
  c1 = new TCanvas("c1","Beam-Gas Rejection",600,1000);
  gStyle->SetMarkerStyle(8);
  chain->Draw("n_trk_tpc[0]:n_trk_tpc[1]");

  // EXAMPLE 3: how to make a selection (write selected event numbers on the plot)
  Int_t ncoll=0;
  char aevent[10];
  TText t(0,0,"a");
  t.SetTextFont(52);
  t.SetTextSize(0.02);
  Float_t cut = 0.35;
  cout <<"\n Events with ntrk>400 and |asim|<"<<cut<<endl;
  //loop over all events: READ ONLY n_trk_tpc AND mEventNumber BRANCHES!
  gBenchmark->Start("loop");
  for (Int_t i=0;i<nFiles;i++) {
    chain.LoadTree(*(chain.GetTreeOffset()+i));
    TTree *T = chain.GetTree();
    //must renew leaf pointer for each tree
    TLeaf *ntrk = T->GetLeaf("n_trk_tpc");
    TLeaf *run = T->GetLeaf("mRunNumber");
    TLeaf *event = T->GetLeaf("mEventNumber");
    for (Int_t j=0; j<T->GetEntries(); j++){
      ntrk->GetBranch()->GetEntry(j);
      event->GetBranch()->GetEntry(j);
      run->GetBranch()->GetEntry(j);
      Int_t Nm=ntrk->GetValue(0);
      Int_t Np=ntrk->GetValue(1);
      Int_t Ntrk = Np+Nm;
      // avoid division by 0
      Float_t asim = Np-Nm;
      if (Ntrk>0) asim /= Ntrk;
      if (-cut < asim&&asim < cut && Ntrk>400) {
	cout<<"   Run "<<(UInt_t)run->GetValue()
	    <<", Event "<<event->GetValue() <<endl;
	ncoll++;
	sprintf(aevent,"%d",event->GetValue());
	t.DrawText(Np+10,Nm+10,aevent);
      }
    }
  }
  gBenchmark->Stop("loop");
  t.SetTextSize(0.05);
  t.DrawText(50,2550,"ntrk>400 and |(Np-Nm)/(Np+Nm)| < 0.35 ");
  t.DrawText(500,-300,"Ntrk with tanl<0 ");
  cout << " Selected " << ncoll << " collision candidates out of "
       << nEvents << " events" << endl;
  // stop timer and print benchmarks
  gBenchmark->Print("loop");  
  gBenchmark->Stop("total");
  gBenchmark->Print("total");  
}
AliCFTaskVertexingHF *AddTaskCFVertexingHF3Prong(TString suffixName="", const char* cutFile = "./DplustoKpipiCuts.root", Int_t configuration = AliCFTaskVertexingHF::kCheetah, Bool_t isKeepDfromB=kFALSE, Bool_t isKeepDfromBOnly=kFALSE, Int_t pdgCode = 411, Char_t isSign = 2, Bool_t useWeight=kFALSE, TString multFile="", Bool_t useNchWeight=kFALSE, Bool_t useNtrkWeight=kFALSE, TString estimatorFilename="", Int_t multiplicityEstimator = AliCFTaskVertexingHF::kNtrk10, Bool_t isPPbData = kFALSE, Double_t refMult=9.26, Bool_t isFineNtrkBin=kFALSE, TString multweighthistoname = "hNtrUnCorrEvWithCandWeight")
//AliCFContainer *AddTaskCFVertexingHF3Prong(const char* cutFile = "./DplustoKpipiCuts.root", Int_t configuration = AliCFTaskVertexingHF::kSnail, Bool_t isKeepDfromB=kFALSE, Bool_t isKeepDfromBOnly=kFALSE, Int_t pdgCode = 411, Char_t isSign = 2)
{
	printf("Addig CF task using cuts from file %s\n",cutFile);
	if (configuration == AliCFTaskVertexingHF::kSnail){
		printf("The configuration is set to be SLOW --> all the variables will be used to fill the CF\n");
	}
	else if (configuration == AliCFTaskVertexingHF::kCheetah){
		printf("The configuration is set to be FAST --> using only pt, y, ct, phi, zvtx, centrality, fake, multiplicity to fill the CF\n");
	}
	else if (configuration == AliCFTaskVertexingHF::kFalcon){
		printf("The configuration is set to be FAST --> using only pt, y, centrality, multiplicity to fill the CF\n");
	}
	else{
		printf("The configuration is not defined! returning\n");
		return;
	}

	gSystem->Sleep(2000);

	// isSign = 0 --> D+ only
	// isSign = 1 --> D- only
	// isSign = 2 --> both

	TString expected;
	if (isSign == 0 && pdgCode < 0){
		AliError(Form("Error setting PDG code (%d) and sign (0 --> particle (%d) only): they are not compatible, returning",pdgCode));
		return 0x0;
	}
	else if (isSign == 1 && pdgCode > 0){
		AliError(Form("Error setting PDG code (%d) and sign (1 --> antiparticle (%d) only): they are not compatible, returning",pdgCode));
		return 0x0;
	}
	else if (isSign > 2 || isSign < 0){
		AliError(Form("Sign not valid (%d, possible values are 0, 1, 2), returning"));
		return 0x0;
	}

	TFile* fileCuts = TFile::Open(cutFile);
	if(!fileCuts || (fileCuts && !fileCuts->IsOpen())){
	  AliFatal(" Cut file not found");
	  return 0x0;
	}
	AliRDHFCutsDplustoKpipi *cutsDplustoKpipi = (AliRDHFCutsDplustoKpipi*)fileCuts->Get("AnalysisCuts");
	TH1F *hMult=0x0;
	if(multFile.EqualTo("") ) {
	  printf("Will not be corrected with weights \n");
	}else{
	  TFile *fileMult = TFile::Open(multFile.Data());
	  if(isPPbData && multweighthistoname=="") {
			hMult = (TH1F*)fileMult->Get("hNtrUnCorrEvWithCandWeight");
		}
	  else if(!isPPbData && multweighthistoname==""){
	    hMult=(TH1F*)fileMult->Get("hGenPrimaryParticlesInelGt0");
	  }
		else {
			hMult=(TH1F*)fileMult->Get(multweighthistoname.Data());
		}
	}

	// check that the fKeepD0fromB flag is set to true when the fKeepD0fromBOnly flag is true
	//  for now the binning is the same than for all D's
	if(isKeepDfromBOnly) isKeepDfromB = true;

	/*
	  Double_t ptmin_0_4;
	  Double_t ptmax_0_4;
	  Double_t ptmin_4_8;
	  Double_t ptmax_4_8;
	  Double_t ptmin_8_10;
	  Double_t ptmax_8_10;

	  if(!isKeepDfromB){
	  ptmin_0_4 =  0.0 ;
	  ptmax_0_4 =  4.0 ;
	  ptmin_4_8 =  4.0 ;
	  ptmax_4_8 =  8.0 ;
	  ptmin_8_10 =  8.0 ;
	  ptmax_8_10 =  10.0 ;
	  } else{
	  ptmin_0_4 =  0.0 ;
	  ptmax_0_4 =  3.0 ;
	  ptmin_4_8 =  3.0 ;
	  ptmax_4_8 =  5.0 ;
	  ptmin_8_10 =  5.0 ;
	  ptmax_8_10 =  10.0 ;
	  }
	*/

	//CONTAINER DEFINITION
	Info("AliCFTaskVertexingHF","SETUP CONTAINER");

	const Double_t phimax = 2*TMath::Pi();

	//Setting up the container grid...
	UInt_t nstep = 10; //number of selection steps: MC with limited acceptance, MC, Acceptance, Vertex, Refit, Reco (no cuts), RecoAcceptance, RecoITSClusters (RecoAcceptance included), RecoPPR (RecoAcceptance+RecoITSCluster included), RecoPID
// 	const Int_t nbinpt_0_4  = 8 ; //bins in pt from 0 to 4 GeV
// 	const Int_t nbinpt_4_8  = 4 ; //bins in pt from 4 to 8 GeV
// 	const Int_t nbinpt_8_10  = 1 ; //bins in pt from 8 to 10 GeV

/*
	Int_t nbinpt_0_4;
	Int_t nbinpt_4_8;
	Int_t nbinpt_8_10;
	if (!isKeepDfromB){
	  nbinpt_0_4  = 8 ; //bins in pt from 0 to 4 GeV
	  nbinpt_4_8  = 4 ; //bins in pt from 4 to 8 GeV
	  nbinpt_8_10  = 1 ; //bins in pt from 8 to 10 GeV
	}else{
	  nbinpt_0_4  = 3 ; //bins in pt from 0 to 3 GeV
	  nbinpt_4_8  = 1 ; //bins in pt from 3 to 5 GeV
	  nbinpt_8_10  = 1 ; //bins in pt from 5 to 10 GeV
	}
*/
	const Int_t nbinpt = cutsDplustoKpipi->GetNPtBins(); // bins in pT
	printf("pT: nbin (from cuts file) = %d\n",nbinpt);
	const Int_t nbiny  = 24 ; //bins in y
	const Int_t nbinphi  = 18 ; //bins in phi
	const Int_t nbincT  = 2 ; //bins in cT
	const Int_t nbinpointing  = 35 ; //bins in cosPointingAngle
	const Int_t nbinpTpi_0_4  = 8 ; //bins in ptPi from 0 to 4 GeV
	const Int_t nbinpTpi_4_8  = 4 ; //bins in ptPi from 4 to 8 GeV
	const Int_t nbinpTpi_8_10  = 1 ; //bins in ptPi from 8 to 10 GeV
	const Int_t nbinpTk_0_4  = 8 ; //bins in ptKa from 0 to 4 GeV
	const Int_t nbinpTk_4_8  = 4 ; //bins in ptKa from 4 to 8 GeV
	const Int_t nbinpTk_8_10  = 1 ; //bins in ptKa from 8 to 10 GeV
	const Int_t nbinpTpi2_0_4  = 8 ; //bins in ptpi2 from 0 to 4 GeV
	const Int_t nbinpTpi2_4_8  = 4 ; //bins in ptpi2 from 4 to 8 GeV
	const Int_t nbinpTpi2_8_10  = 1 ; //bins in ptpi2 from 8 to 10 GeV
	const Int_t nbinzvtx  = 30 ; //bins in z vertex
	const Int_t nbincent = 18; //bins in centrality
	const Int_t nbincent_0_10 = 4;  //bins in centrality between 0 and 10
	const Int_t nbincent_10_60 = 10;  //bins in centrality between 10 and 60
	const Int_t nbincent_60_100 = 4;  //bins in centrality between 60 and 100
	const Int_t nbinfake = 3;  //bins in fake
	const Int_t nbinpointingXY = 50;  //bins in cosPointingAngleXY
	const Int_t nbinnormDecayLXY = 20;  //bins in NormDecayLengthXY
	const Int_t nbinmult = 49;  //bins in multiplicity (total number)
	const Int_t nbinmult_0_20 = 20; //bins in multiplicity between 0 and 20
	const Int_t nbinmult_20_50 = 15; //bins in multiplicity between 20 and 50
	const Int_t nbinmult_50_80 = 10; //bins in multiplicity between 50 and 80
	const Int_t nbinmult_80_100 = 4; //bins in multiplicity between 80 and 100
	const Int_t nbinmult_100_400 = 3; //bins in multiplicity between 100 and 400
	if(isPPbData) nbinmult += nbinmult_100_400;

	// Fine Ntrk bining setting
	Double_t *binLimmultFine;
	Int_t nbinmultTmp=nbinmult;
	if(isFineNtrkBin){
	  Int_t nbinLimmultFine=100;
	  if(isPPbData) nbinLimmultFine = 200;
	  const UInt_t nbinMultFine = nbinLimmultFine;
	  binLimmultFine = new Double_t[nbinMultFine+1];
	  for (Int_t ibin0 = 0 ; ibin0<nbinMultFine+1; ibin0++){
	    binLimmultFine[ibin0] = ibin0;
	  }
	  nbinmultTmp=nbinLimmultFine;
	}
	const Int_t nbinmultTot=nbinmultTmp;


	//the sensitive variables, their indices
	const UInt_t ipT = 0;
	const UInt_t iy  = 1;
	const UInt_t iphi  = 2;
	const UInt_t icT  = 3;
	const UInt_t ipointing  = 4;
	const UInt_t ipTpi  = 5;
	const UInt_t ipTk  = 6;
	const UInt_t ipTpi2  = 7;
	const UInt_t izvtx  = 8;
	const UInt_t icent = 9;
	const UInt_t ifake = 10;
	const UInt_t ipointingXY = 11;
	const UInt_t inormDecayLXY = 12;
	const UInt_t imult = 13;

	const Int_t nvarTot   = 14 ; //number of variables on the grid:pt, y, cosThetaStar, pTpi, pTk, cT, dca, d0pi, d0K, d0xd0, cosPointingAngle, phi, zvtx, centrality, fake, cosPointingAngleXY, normDecayLengthXY, multiplicity

	//arrays for the number of bins in each dimension
	Int_t iBin[nvarTot];
 	//iBin[ipT]=nbinpt_0_4+nbinpt_4_8+nbinpt_8_10;
	iBin[ipT]=nbinpt;
	iBin[iy]=nbiny;
	iBin[iphi]=nbinphi;
	// 	iBin[icT]=nbincT_0_4+nbincT_4_8+nbincT_8_10;
 	//iBin[4]=nbinpointing_0_4+nbinpointing_4_8+nbinpointing_8_10;
 	iBin[icT]=nbincT;
 	iBin[ipointing]=nbinpointing;
	iBin[ipTpi]=nbinpt;
	iBin[ipTk]=nbinpt;
	iBin[ipTpi2]=nbinpt;
	iBin[izvtx]=nbinzvtx;
	iBin[icent]=nbincent;
	iBin[ifake]=nbinfake;
	iBin[ipointingXY]=nbinpointingXY;
	iBin[inormDecayLXY]=nbinnormDecayLXY;
	iBin[imult]=nbinmultTot;

	//arrays for lower bounds :
	Double_t *binLimpT=new Double_t[iBin[ipT]+1];
	Double_t *binLimy=new Double_t[iBin[iy]+1];
	Double_t *binLimphi=new Double_t[iBin[iphi]+1];
	Double_t *binLimcT=new Double_t[iBin[icT]+1];
	Double_t *binLimpointing=new Double_t[iBin[ipointing]+1];
	Double_t *binLimpTpi=new Double_t[iBin[ipTpi]+1];
	Double_t *binLimpTk=new Double_t[iBin[ipTk]+1];
	Double_t *binLimpTpi2=new Double_t[iBin[ipTpi2]+1];
	Double_t *binLimzvtx=new Double_t[iBin[izvtx]+1];
	Double_t *binLimcent=new Double_t[iBin[icent]+1];
	Double_t *binLimfake=new Double_t[iBin[ifake]+1];
	Double_t *binLimpointingXY=new Double_t[iBin[ipointingXY]+1];
	Double_t *binLimnormDecayLXY=new Double_t[iBin[inormDecayLXY]+1];
	Double_t *binLimmult=new Double_t[iBin[imult]+1];

	// checking limits
	/*
	  if (ptmax_0_4 != ptmin_4_8) {
	  Error("AliCFHeavyFlavourTaskMultiVarMultiStep","max lim 1st range != min lim 2nd range, please check!");
	  }
	  if (ptmax_4_8 != ptmin_8_10) {
	  Error("AliCFHeavyFlavourTaskMultiVarMultiStep","max lim 2nd range != min lim 3rd range, please check!");
	  }
	*/
	// values for bin lower bounds
	// pt
	Float_t* floatbinLimpT = cutsDplustoKpipi->GetPtBinLimits();
	for (Int_t ibinpT = 0 ; ibinpT<iBin[ipT]+1; ibinpT++){
		binLimpT[ibinpT] = (Double_t)floatbinLimpT[ibinpT];
		binLimpTpi[ibinpT] = (Double_t)floatbinLimpT[ibinpT];
		binLimpTk[ibinpT] = (Double_t)floatbinLimpT[ibinpT];
		binLimpTpi2[ibinpT] = (Double_t)floatbinLimpT[ibinpT];
	}
	for(Int_t i=0; i<=nbinpt; i++) printf("binLimpT[%d]=%f\n",i,binLimpT[i]);

	/*
	  for(Int_t i=0; i<=nbinpt_0_4; i++) binLimpT[i]=(Double_t)ptmin_0_4 + (ptmax_0_4-ptmin_0_4)/nbinpt_0_4*(Double_t)i ;
	  if (binLimpT[nbinpt_0_4] != ptmin_4_8)  {
	  Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 1st range - differs from expected!\n");
	  }
	  for(Int_t i=0; i<=nbinpt_4_8; i++) binLimpT[i+nbinpt_0_4]=(Double_t)ptmin_4_8 + (ptmax_4_8-ptmin_4_8)/nbinpt_4_8*(Double_t)i ;
	  if (binLimpT[nbinpt_0_4+nbinpt_4_8] != ptmin_8_10)  {
	  Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 2nd range - differs from expected!\n");
	  }
	  for(Int_t i=0; i<=nbinpt_8_10; i++) binLimpT[i+nbinpt_0_4+nbinpt_4_8]=(Double_t)ptmin_8_10 + (ptmax_8_10-ptmin_8_10)/nbinpt_8_10*(Double_t)i ;
	*/

	// y
	for(Int_t i=0; i<=nbiny; i++) binLimy[i]=(Double_t)ymin  + (ymax-ymin)  /nbiny*(Double_t)i ;

	// Phi
	for(Int_t i=0; i<=nbinphi; i++) binLimphi[i]=(Double_t)phimin  + (phimax-phimin)  /nbinphi*(Double_t)i ;

	// cT
	for(Int_t i=0; i<=nbincT; i++) binLimcT[i]=(Double_t)cTmin  + (cTmax-cTmin)  /nbincT*(Double_t)i ;

	// cosPointingAngle
	for(Int_t i=0; i<=nbinpointing; i++) binLimpointing[i]=(Double_t)cosmin  + (cosmax-cosmin)  /nbinpointing*(Double_t)i ;

	/*
	// ptPi
	for(Int_t i=0; i<=nbincT_0_4; i++) binLimcT[i]=(Double_t)ptmin_0_4 + (ptmax_0_4-ptmin_0_4)/nbincT_0_4*(Double_t)i ;
	if (binLimcT[nbincT_0_4] != ptmin_4_8)  {
	Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptPi - 1st range - differs from expected!");
	}
	for(Int_t i=0; i<=nbincT_4_8; i++) binLimcT[i+nbincT_0_4]=(Double_t)ptmin_4_8 + (ptmax_4_8-ptmin_4_8)/nbincT_4_8*(Double_t)i ;
	if (binLimcT[nbincT_0_4+nbincT_4_8] != ptmin_8_10)  {
	Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptPi - 2nd range - differs from expected!\n");
	}
	for(Int_t i=0; i<=nbincT_8_10; i++) binLimcT[i+nbincT_0_4+nbincT_4_8]=(Double_t)ptmin_8_10 + (ptmax_8_10-ptmin_8_10)/nbincT_8_10*(Double_t)i ;

	// ptKa
	for(Int_t i=0; i<=nbinpointing_0_4; i++) binLimpointing[i]=(Double_t)ptmin_0_4 + (ptmax_0_4-ptmin_0_4)/nbinpointing_0_4*(Double_t)i ;
	if (binLimpointing[nbinpointing_0_4] != ptmin_4_8)  {
	Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptKa - 1st range - differs from expected!");
	}
	for(Int_t i=0; i<=nbinpointing_4_8; i++) binLimpointing[i+nbinpointing_0_4]=(Double_t)ptmin_4_8 + (ptmax_4_8-ptmin_4_8)/nbinpointing_4_8*(Double_t)i ;
	if (binLimpointing[nbinpointing_0_4+nbinpointing_4_8] != ptmin_8_10)  {
	Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptKa - 2nd range - differs from expected!\n");
	}
	for(Int_t i=0; i<=nbinpointing_8_10; i++) binLimpointing[i+nbinpointing_0_4+nbinpointing_4_8]=(Double_t)ptmin_8_10 + (ptmax_8_10-ptmin_8_10)/nbinpointing_8_10*(Double_t)i ;
	*/

	// z Primary Vertex
	for(Int_t i=0; i<=nbinzvtx; i++) {
		binLimzvtx[i]=(Double_t)zvtxmin  + (zvtxmax-zvtxmin)  /nbinzvtx*(Double_t)i ;
	}

	// centrality

	for(Int_t i=0; i<=nbincent_0_10; i++) binLimcent[i]=(Double_t)centmin_0_10 + (centmax_0_10-centmin_0_10)/nbincent_0_10*(Double_t)i ;
	if (binLimcent[nbincent_0_10] != centmin_10_60)  {
	  Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for cent - 1st range - differs from expected!\n");
	}
	for(Int_t i=0; i<=nbincent_10_60; i++) binLimcent[i+nbincent_0_10]=(Double_t)centmin_10_60 + (centmax_10_60-centmin_10_60)/nbincent_10_60*(Double_t)i ;
	if (binLimcent[nbincent_0_10+nbincent_10_60] != centmin_60_100)  {
	  Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for cent - 2st range - differs from expected!\n");
	}
	for(Int_t i=0; i<=nbincent_60_100; i++) binLimcent[i+nbincent_0_10+nbincent_10_60]=(Double_t)centmin_60_100 + (centmax_60_100-centmin_60_100)/nbincent_60_100*(Double_t)i ;

	// fake
	for(Int_t i=0; i<=nbinfake; i++) {
	  binLimfake[i]=(Double_t)fakemin  + (fakemax-fakemin)/nbinfake * (Double_t)i;
	}

	// cosPointingAngleXY
	for(Int_t i=0; i<=nbinpointingXY; i++) binLimpointingXY[i]=(Double_t)cosminXY  + (cosmaxXY-cosminXY)  /nbinpointingXY*(Double_t)i ;

	// normDecayLXY
	for(Int_t i=0; i<=nbinnormDecayLXY; i++) binLimnormDecayLXY[i]=(Double_t)normDecLXYmin  + (normDecLXYmax-normDecLXYmin)  /nbinnormDecayLXY*(Double_t)i ;

	// multiplicity
      for(Int_t i=0; i<=nbinmult_0_20; i++) binLimmult[i]=(Double_t)multmin_0_20 + (multmax_0_20-multmin_0_20)/nbinmult_0_20*(Double_t)i ;
      if (binLimmult[nbinmult_0_20] != multmin_20_50)  {
               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for mult - 1st range - differs from expected!\n");
      }
      for(Int_t i=0; i<=nbinmult_20_50; i++) binLimmult[i+nbinmult_0_20]=(Double_t)multmin_20_50 + (multmax_20_50-multmin_20_50)/nbinmult_20_50*(Double_t)i ;
      if (binLimmult[nbinmult_0_20+nbinmult_20_50] != multmin_50_80)  {
               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for mult - 2nd range - differs from expected!\n");
      }
      for(Int_t i=0; i<=nbinmult_50_80; i++) binLimmult[i+nbinmult_0_20+nbinmult_20_50]=(Double_t)multmin_50_80 + (multmax_50_80-multmin_50_80)/nbinmult_50_80*(Double_t)i ;
      if (binLimmult[nbinmult_0_20+nbinmult_20_50+nbinmult_50_80] != multmin_80_100)  {
               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for mult - 3rd range - differs from expected!\n");
      }
      for(Int_t i=0; i<=nbinmult_80_100; i++) binLimmult[i+nbinmult_0_20+nbinmult_20_50+nbinmult_50_80]=(Double_t)multmin_80_100 + (multmax_80_100-multmin_80_100)/nbinmult_80_100*(Double_t)i ;
      if (binLimmult[nbinmult_0_20+nbinmult_20_50+nbinmult_50_80+nbinmult_80_100] != multmin_100_400) {
               Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for mult - 4th range - differs from expected!\n");
      }
      if(isPPbData){
	for (Int_t i = 0; i<=nbinmult_100_400; i++) binLimmult[i+nbinmult_0_20+nbinmult_20_50+nbinmult_50_80+nbinmult_80_100]= (Double_t)multmin_100_400 + (multmax_100_400-multmin_100_400)/nbinmult_100_400*(Double_t)i ;
      }

	//one "container" for MC
	TString nameContainer="";
	if(!isKeepDfromB) {
		nameContainer="CFHFcontainer_DplustoKpipi_Prompt";

	}
	else  if(isKeepDfromBOnly){
		nameContainer="CFHFcontainer_DplustoKpipi_FromB";

	}
	else  {
	  nameContainer="CFHFcontainer_DplustoKpipi_All";
	}
	nameContainer += suffixName.Data();


	AliCFContainer* container;
	if (configuration == AliCFTaskVertexingHF::kSnail){
		container = new AliCFContainer(nameContainer,"container for tracks",nstep,nvarTot,iBin);
		//setting the bin limits
		printf("pt\n");
		container -> SetBinLimits(ipT,binLimpT);
		printf("y\n");
		container -> SetBinLimits(iy,binLimy);
		printf("Phi\n");
		container -> SetBinLimits(iphi,binLimphi);
		printf("cT\n");
		container -> SetBinLimits(icT,binLimcT);
		printf("pointing angle\n");
		container -> SetBinLimits(ipointing,binLimpointing);
		printf("ptpi\n");
		container -> SetBinLimits(ipTpi,binLimpTpi);
		printf("ptK\n");
		container -> SetBinLimits(ipTk,binLimpTk);
		printf("ptpi2\n");
		container -> SetBinLimits(ipTpi2,binLimpTpi2);
		printf("zvtx \n");
		container -> SetBinLimits(izvtx,binLimzvtx);
		printf("cent\n");
		container -> SetBinLimits(icent,binLimcent);
		printf("fake\n");
		container -> SetBinLimits(ifake,binLimfake);
		printf("pointingXY\n");
		container -> SetBinLimits(ipointingXY,binLimpointingXY);
		printf("normDecayLXY\n");
		container -> SetBinLimits(inormDecayLXY,binLimnormDecayLXY);
		printf("multiplicity\n");
		if(isFineNtrkBin) container -> SetBinLimits(imult,binLimmultFine);
		else container -> SetBinLimits(imult,binLimmult);

		container -> SetVarTitle(ipT,"pt");
		container -> SetVarTitle(iy,"y");
		container -> SetVarTitle(iphi, "phi");
		container -> SetVarTitle(icT, "ct");
		container -> SetVarTitle(ipointing, "pointing");
		container -> SetVarTitle(ipTpi, "ptpi");
		container -> SetVarTitle(ipTk, "ptK");
		container -> SetVarTitle(ipTpi2, "ptpi2");
		container -> SetVarTitle(izvtx, "zvtx");
		container -> SetVarTitle(icent, "centrality");
		container -> SetVarTitle(ifake, "fake");
		container -> SetVarTitle(ipointingXY, "piointingXY");
		container -> SetVarTitle(inormDecayLXY, "normDecayLXY");
		container -> SetVarTitle(imult, "multiplicity");
	}
	else if (configuration == AliCFTaskVertexingHF::kCheetah){
		//arrays for the number of bins in each dimension
		const Int_t nvar = 8;

		const UInt_t ipTFast = 0;
		const UInt_t iyFast = 1;
		const UInt_t icTFast = 2;
		const UInt_t iphiFast = 3;
		const UInt_t izvtxFast = 4;
		const UInt_t icentFast = 5;
		const UInt_t ifakeFast = 6;
		const UInt_t imultFast = 7;

		Int_t iBinFast[nvar];
		iBinFast[ipTFast] = iBin[ipT];
		iBinFast[iyFast] = iBin[iy];
		iBinFast[icTFast] = iBin[icT];
		iBinFast[iphiFast] = iBin[iphi];
		iBinFast[izvtxFast] = iBin[izvtx];
		iBinFast[icentFast] = iBin[icent];
		iBinFast[ifakeFast] = iBin[ifake];
		iBinFast[imultFast] = iBin[imult];

		container = new AliCFContainer(nameContainer,"container for tracks",nstep,nvar,iBinFast);
		printf("pt\n");
		container -> SetBinLimits(ipTFast,binLimpT);
		printf("y\n");
		container -> SetBinLimits(iyFast,binLimy);
		printf("ct\n");
		container -> SetBinLimits(icTFast,binLimcT);
		printf("phi\n");
		container -> SetBinLimits(iphiFast,binLimphi);
		printf("zvtx\n");
		container -> SetBinLimits(izvtxFast,binLimzvtx);
		printf("centrality\n");
		container -> SetBinLimits(icentFast,binLimcent);
		printf("fake\n");
		container -> SetBinLimits(ifakeFast,binLimfake);
		printf("multiplicity\n");
		if(isFineNtrkBin) container -> SetBinLimits(imultFast,binLimmultFine);
		else container -> SetBinLimits(imultFast,binLimmult);

		container -> SetVarTitle(ipTFast,"pt");
		container -> SetVarTitle(iyFast,"y");
		container -> SetVarTitle(icTFast, "ct");
		container -> SetVarTitle(iphiFast, "phi");
		container -> SetVarTitle(izvtxFast, "zvtx");
		container -> SetVarTitle(icentFast, "centrality");
		container -> SetVarTitle(ifakeFast, "fake");
		container -> SetVarTitle(imultFast, "multiplicity");
	}
	else if (configuration == AliCFTaskVertexingHF::kFalcon){
		//arrays for the number of bins in each dimension
		const Int_t nvar = 4;

		const UInt_t ipTSuperFast = 0;
		const UInt_t iySuperFast = 1;
		const UInt_t icentSuperFast = 2;
		const UInt_t imultSuperFast = 3;

		Int_t iBinSuperFast[nvar];
		iBinSuperFast[ipTSuperFast] = iBin[ipT];
		iBinSuperFast[iySuperFast] = iBin[iy];
		iBinSuperFast[icentSuperFast] = iBin[icent];
		iBinSuperFast[imultSuperFast] = iBin[imult];

		container = new AliCFContainer(nameContainer,"container for tracks",nstep,nvar,iBinSuperFast);
		printf("pt\n");
		container -> SetBinLimits(ipTSuperFast,binLimpT);
		printf("y\n");
		container -> SetBinLimits(iySuperFast,binLimy);
		printf("centrality\n");
		container -> SetBinLimits(icentSuperFast,binLimcent);
		printf("multiplicity\n");
		if(isFineNtrkBin) container -> SetBinLimits(imultSuperFast,binLimmultFine);
		else container -> SetBinLimits(imultSuperFast,binLimmult);

		container -> SetVarTitle(ipTSuperFast,"pt");
		container -> SetVarTitle(iySuperFast,"y");
		container -> SetVarTitle(icentSuperFast, "centrality");
		container -> SetVarTitle(imultSuperFast, "multiplicity");
	}

	//return container;

	container -> SetStepTitle(0, "MCLimAcc");
	container -> SetStepTitle(1, "MC");
        container -> SetStepTitle(2, "MCAcc");
        container -> SetStepTitle(3, "RecoVertex");
        container -> SetStepTitle(4, "RecoRefit");
        container -> SetStepTitle(5, "Reco");
        container -> SetStepTitle(6, "RecoAcc");
	container -> SetStepTitle(7, "RecoITSCluster");
	container -> SetStepTitle(8, "RecoCuts");
	container -> SetStepTitle(9, "RecoPID");


	//CREATE THE  CUTS -----------------------------------------------

	// Gen-Level kinematic cuts
	AliCFTrackKineCuts *mcKineCuts = new AliCFTrackKineCuts("mcKineCuts","MC-level kinematic cuts");

	//Particle-Level cuts:
	AliCFParticleGenCuts* mcGenCuts = new AliCFParticleGenCuts("mcGenCuts","MC particle generation cuts");
	Bool_t useAbsolute = kTRUE;
	if (isSign != 2){
		useAbsolute = kFALSE;
	}
	mcGenCuts->SetRequirePdgCode(pdgCode, useAbsolute);  // kTRUE set in order to include antiparticle
	mcGenCuts->SetAODMC(1); //special flag for reading MC in AOD tree (important)

	// Acceptance cuts:
	AliCFAcceptanceCuts* accCuts = new AliCFAcceptanceCuts("accCuts", "Acceptance cuts");
	AliCFTrackKineCuts *kineAccCuts = new AliCFTrackKineCuts("kineAccCuts","Kine-Acceptance cuts");
	kineAccCuts->SetPtRange(ptmin,ptmax);
	kineAccCuts->SetEtaRange(etamin,etamax);

	// Rec-Level kinematic cuts
	AliCFTrackKineCuts *recKineCuts = new AliCFTrackKineCuts("recKineCuts","rec-level kine cuts");

	AliCFTrackQualityCuts *recQualityCuts = new AliCFTrackQualityCuts("recQualityCuts","rec-level quality cuts");

	AliCFTrackIsPrimaryCuts *recIsPrimaryCuts = new AliCFTrackIsPrimaryCuts("recIsPrimaryCuts","rec-level isPrimary cuts");

	printf("CREATE MC KINE CUTS\n");
	TObjArray* mcList = new TObjArray(0) ;
	mcList->AddLast(mcKineCuts);
	mcList->AddLast(mcGenCuts);

	printf("CREATE ACCEPTANCE CUTS\n");
	TObjArray* accList = new TObjArray(0) ;
	accList->AddLast(kineAccCuts);

	printf("CREATE RECONSTRUCTION CUTS\n");
	TObjArray* recList = new TObjArray(0) ;   // not used!!
	recList->AddLast(recKineCuts);
	recList->AddLast(recQualityCuts);
	recList->AddLast(recIsPrimaryCuts);

	TObjArray* emptyList = new TObjArray(0);

	//CREATE THE INTERFACE TO CORRECTION FRAMEWORK USED IN THE TASK
	printf("CREATE INTERFACE AND CUTS\n");
	AliCFManager* man = new AliCFManager() ;
	man->SetParticleContainer(container);
	man->SetParticleCutsList(0 , mcList); // MC, Limited Acceptance
	man->SetParticleCutsList(1 , mcList); // MC
	man->SetParticleCutsList(2 , accList); // Acceptance
	man->SetParticleCutsList(3 , emptyList); // Vertex
	man->SetParticleCutsList(4 , emptyList); // Refit
	man->SetParticleCutsList(5 , emptyList); // AOD
	man->SetParticleCutsList(6 , emptyList); // AOD in Acceptance
	man->SetParticleCutsList(7 , emptyList); // AOD with required n. of ITS clusters
	man->SetParticleCutsList(8 , emptyList); // AOD Reco (PPR cuts implemented in Task)
	man->SetParticleCutsList(9 , emptyList); // AOD Reco PID

	// Get the pointer to the existing analysis manager via the static access method.
	//==============================================================================
	AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
	if (!mgr) {
	  ::Error("AddTaskCompareHF", "No analysis manager to connect to.");
	  return NULL;
	}
	//CREATE THE TASK
	printf("CREATE TASK\n");

	// create the task
	AliCFTaskVertexingHF *task = new AliCFTaskVertexingHF("AliCFTaskVertexingHF",cutsDplustoKpipi);
	task->SetConfiguration(configuration);
	task->SetFillFromGenerated(kFALSE);
	task->SetDecayChannel(31);
	task->SetUseWeight(useWeight);
	task->SetCFManager(man); //here is set the CF manager
	task->SetSign(isSign);
	task->SetCentralitySelection(kFALSE);
	task->SetFakeSelection(0);
	task->SetRejectCandidateIfNotFromQuark(kTRUE); // put to false if you want to keep HIJING D0!!
	task->SetUseMCVertex(kFALSE); // put to true if you want to do studies on pp
	task->SetUseNchWeight(useNchWeight); //correction with mult weight
	if(useNchWeight || useNtrkWeight){
	  if(hMult) task->SetMCNchHisto(hMult);
	  else{
	    AliFatal("Histogram for multiplicity weights not found");
	    return 0x0;
	  }
	  task->SetUseNchWeight(kTRUE);
	  if(useNtrkWeight) task->SetUseNchTrackletsWeight();
	}
	if(isPPbData) {
	  task->SetIsPPbData(kTRUE);
	}
	if (isKeepDfromB && !isKeepDfromBOnly) task->SetDselection(2);
	if (isKeepDfromB && isKeepDfromBOnly) task->SetDselection(1);

	TF1* funcWeight = 0x0;
	if (task->GetUseWeight()) {
		funcWeight = (TF1*)fileCuts->Get("funcWeight");
		if (funcWeight == 0x0){
			Printf("FONLL Weights will be used");
		}
		else {
			task->SetWeightFunction(funcWeight);
			Printf("User-defined Weights will be used. The function being:");
			task->GetWeightFunction()->Print();
		}
	}

   task->SetMultiplicityEstimator(multiplicityEstimator);
   if(estimatorFilename.EqualTo("") ) {
     printf("Estimator file not provided, multiplicity corrected histograms will not be filled\n");
     task->SetUseZvtxCorrectedNtrkEstimator(kFALSE);
   } else{
     TFile* fileEstimator=TFile::Open(estimatorFilename.Data());
     if(!fileEstimator)  {
       AliFatal("File with multiplicity estimator not found");
       return;
     }
     task->SetUseZvtxCorrectedNtrkEstimator(kTRUE);
     task->SetReferenceMultiplcity(refMult);

      if (isPPbData) {  //load multiplicity estimators for pPb
         const Char_t* periodNames[2] = {"LHC13b", "LHC13c"};
         TProfile *multEstimatorAvg[2];
         for (Int_t ip=0; ip < 2; ip++) {
            multEstimatorAvg[ip] = (TProfile*)(fileEstimator->Get(Form("SPDmult10_%s",periodNames[ip]))->Clone(Form("SPDmult10_%s_clone",periodNames[ip])));
            if (!multEstimatorAvg[ip]) {
               AliFatal(Form("Multiplicity estimator for %s not found! Please check your estimator file",periodNames[ip]));
               return;
            }
         }
         task->SetMultiplVsZProfileLHC13b(multEstimatorAvg[0]);
         task->SetMultiplVsZProfileLHC13c(multEstimatorAvg[1]);

      } else {    //load multiplicity estimators for pp
         const Char_t* periodNames[4] = {"LHC10b", "LHC10c", "LHC10d", "LHC10e"};
         TProfile* multEstimatorAvg[4];

         for(Int_t ip=0; ip<4; ip++) {
            multEstimatorAvg[ip] = (TProfile*)(fileEstimator->Get(Form("SPDmult10_%s",periodNames[ip]))->Clone(Form("SPDmult10_%s_clone",periodNames[ip])));
            if (!multEstimatorAvg[ip]) {
               AliFatal(Form("Multiplicity estimator for %s not found! Please check your estimator file",periodNames[ip]));
               return;
            }
         }
         task->SetMultiplVsZProfileLHC10b(multEstimatorAvg[0]);
         task->SetMultiplVsZProfileLHC10c(multEstimatorAvg[1]);
         task->SetMultiplVsZProfileLHC10d(multEstimatorAvg[2]);
         task->SetMultiplVsZProfileLHC10e(multEstimatorAvg[3]);
     }
   }

	Printf("***************** CONTAINER SETTINGS *****************");
	Printf("decay channel = %d",(Int_t)task->GetDecayChannel());
	Printf("FillFromGenerated = %d",(Int_t)task->GetFillFromGenerated());
	Printf("Dselection = %d",(Int_t)task->GetDselection());
	Printf("Sign = %d",(Int_t)task->GetSign());
	Printf("Centrality selection = %d",(Int_t)task->GetCentralitySelection());
	Printf("Fake selection = %d",(Int_t)task->GetFakeSelection());
	Printf("RejectCandidateIfNotFromQuark selection = %d",(Int_t)task->GetRejectCandidateIfNotFromQuark());
	Printf("UseMCVertex selection = %d",(Int_t)task->GetUseMCVertex());
	Printf("***************END CONTAINER SETTINGS *****************\n");

        //-----------------------------------------------------------//
        //   create correlation matrix for unfolding - only eta-pt   //
        //-----------------------------------------------------------//

        Bool_t AcceptanceUnf = kTRUE; // unfold at acceptance level, otherwise PPR

        Int_t thnDim[4];

        //first half  : reconstructed
        //second half : MC

        thnDim[0] = iBin[ipT];
        thnDim[2] = iBin[ipT];
        thnDim[1] = iBin[iy];
        thnDim[3] = iBin[iy];

	TString nameCorr="";
	if(!isKeepDfromB) {
		nameCorr="CFHFcorr_DplustoKpipi_Prompt";
	}
	else  if(isKeepDfromBOnly){
		nameCorr="CFHFcorr_DplustoKpipi_FromB";
	}
	else  {
	        nameCorr="CFHFcorr_DplustoKpipi_All";
	}
	nameCorr += suffixName.Data();


        THnSparseD* correlation = new THnSparseD(nameCorr,"THnSparse with correlations",4,thnDim);
        Double_t** binEdges = new Double_t[2];

        // set bin limits

        binEdges[0]= binLimpT;
        binEdges[1]= binLimy;

        correlation->SetBinEdges(0,binEdges[0]);
        correlation->SetBinEdges(2,binEdges[0]);

        correlation->SetBinEdges(1,binEdges[1]);
        correlation->SetBinEdges(3,binEdges[1]);

        correlation->Sumw2();

        // correlation matrix ready
        //------------------------------------------------//

        task->SetCorrelationMatrix(correlation); // correlation matrix for unfolding

	// Create and connect containers for input/output

	// ------ input data ------
	AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer();

	// ----- output data -----

	TString outputfile = AliAnalysisManager::GetCommonFileName();
	TString output1name="", output2name="", output3name="", output4name="", output5name="";
	output2name=nameContainer;
	output3name=nameCorr;
	output5name= "coutProfDp";
	if(!isKeepDfromB) {
		outputfile += ":PWG3_D2H_CFtaskDplustoKpipi_Prompt";
		output1name="CFHFhist_DplustoKpipi_Prompt";
		output3name+="_Prompt";
		output4name= "Cuts_DplustoKpipi_Prompt";
		output5name+="_Prompt";
	}
	else  if(isKeepDfromBOnly){
   	        outputfile += ":PWG3_D2H_CFtaskDplustoKpipi_FromB";
	        output1name="CFHFhist_DplustoKpipi_FromB";
		output3name+="_FromB";
		output4name= "Cuts_DplustoKpipi_FromB";
		output5name+="_FromB";
	}
	else{
        	outputfile += ":PWG3_D2H_CFtaskDplustoKpipi_All";
		output1name="CFHFhist_DplustoKpipi_All";
		output3name+="_All";
		output4name= "Cuts_DplustoKpipi_All";
		output5name+="_All";
	}
	outputfile += suffixName.Data();
	output1name += suffixName.Data();
	output4name += suffixName.Data();
	output5name += suffixName.Data();

	//now comes user's output objects :
	// output TH1I for event counting
	AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(output1name, TH1I::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
	// output Correction Framework Container (for acceptance & efficiency calculations)
	AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(output2name, AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
	// Unfolding - correlation matrix
        AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(output3name, THnSparseD::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
	AliAnalysisDataContainer *coutput4 = mgr->CreateContainer(output4name, AliRDHFCuts::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data());
	// estimators list
	AliAnalysisDataContainer *coutput5 = mgr->CreateContainer(output5name, TList::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data());

	mgr->AddTask(task);

	mgr->ConnectInput(task,0,mgr->GetCommonInputContainer());
	mgr->ConnectOutput(task,1,coutput1);
	mgr->ConnectOutput(task,2,coutput2);
        mgr->ConnectOutput(task,3,coutput3);
	mgr->ConnectOutput(task,4,coutput4);
	mgr->ConnectOutput(task,5,coutput5);

	return task;
}
void composeTrackAnalysisbyAssociator(string FileListName, int FileNumber) {

    if(debug) cout << FileListName << endl;
    string theFileName;
    ifstream composeFileList;
    composeFileList.open(FileListName.c_str());

    string OutputPlotNamepreFix = FileListName + "_";
    string OutputPlotNameFix = ".png";

    unsigned int EventNumber;
    unsigned int trackingParticleMatch;
    double recTrackPurity;
    double recTrackrefMomentum;
    double recTrackrefPhi;
    double recTrackrefEta;
    double recTrackinnerMomentum;
    double recTrackinnerPhi;
    double recTrackinnerEta;
    unsigned int recTrackinnerValid;
    double recTrackouterMomentum;
    double recTrackouterPhi;
    double recTrackouterEta;
    unsigned int recTrackouterValid;
    double simTrackinnerMomentum;
    double simTrackinnerPhi;
    double simTrackinnerEta;
    unsigned int simTrackinnerMatch;
    double simTrackouterMomentum;
    double simTrackouterPhi;
    double simTrackouterEta;
    unsigned int simTrackouterMatch;
    double recTrackinnerMomentumofTSOS;
    double recTrackinnerPhiofTSOS;
    double recTrackinnerEtaofTSOS;
    unsigned int recTrackinnerValidofTSOS;
    double recTrackouterMomentumofTSOS;
    double recTrackouterPhiofTSOS;
    double recTrackouterEtaofTSOS;
    unsigned int recTrackouterValidofTSOS;
    double recTrackimpactMomentumofTSOS;
    double recTrackimpactPhiofTSOS;
    double recTrackimpactEtaofTSOS;
    unsigned int recTrackimpactValidofTSOS;
    int recTrackCharge;
    double simTrackMomentumPt;
    double simTrackPhi;
    double simTrackEta;
    int simTrackCharge;

    TObjArray* myEfficiencyHist = new TObjArray();
    TObjArray* myParticleHist = new TObjArray();
    TObjArray* mySTAHist = new TObjArray();
    TObjArray* myChargeCheckHist = new TObjArray();
    TObjArray* myDeltaPtHist = new TObjArray();
    TObjArray* myDeltaPhiHist = new TObjArray();
    TObjArray* myDeltaEtaHist = new TObjArray();
    vector<string> TypeName;
    TypeName.clear();

    for(int Index = 0; Index < FileNumber; Index++) {
        getline(composeFileList, theFileName);
        TypeName.push_back(theFileName);
        string fullFileName = "data/"+ theFileName + ".root";
        if(debug) cout << theFileName << endl;
        TFile* RootFile = TFile::Open(fullFileName.c_str());

        TTree* T1 = (TTree*)RootFile->Get("ExTree");
        T1->SetBranchAddress("EventNumber", &EventNumber);
        T1->SetBranchAddress("trackingParticleMatch", &trackingParticleMatch);
        T1->SetBranchAddress("recTrackPurity", &recTrackPurity);
        T1->SetBranchAddress("recTrackrefMomentum", &recTrackrefMomentum);
        T1->SetBranchAddress("recTrackrefPhi", &recTrackrefPhi);
        T1->SetBranchAddress("recTrackrefEta", &recTrackrefEta);
        T1->SetBranchAddress("recTrackinnerMomentum", &recTrackinnerMomentum);
        T1->SetBranchAddress("recTrackinnerPhi", &recTrackinnerPhi);
        T1->SetBranchAddress("recTrackinnerEta", &recTrackinnerEta);
        T1->SetBranchAddress("recTrackinnerValid", &recTrackinnerValid);
        T1->SetBranchAddress("recTrackouterMomentum", &recTrackouterMomentum);
        T1->SetBranchAddress("recTrackouterPhi", &recTrackouterPhi);
        T1->SetBranchAddress("recTrackouterEta", &recTrackouterEta);
        T1->SetBranchAddress("recTrackouterValid", &recTrackouterValid);
        T1->SetBranchAddress("simTrackinnerMomentum", &simTrackinnerMomentum);
        T1->SetBranchAddress("simTrackinnerPhi", &simTrackinnerPhi);
        T1->SetBranchAddress("simTrackinnerEta", &simTrackinnerEta);
        T1->SetBranchAddress("simTrackinnerMatch", &simTrackinnerMatch);
        T1->SetBranchAddress("simTrackouterMomentum", &simTrackouterMomentum);
        T1->SetBranchAddress("simTrackouterPhi", &simTrackouterPhi);
        T1->SetBranchAddress("simTrackouterEta", &simTrackouterEta);
        T1->SetBranchAddress("simTrackouterMatch", &simTrackouterMatch);
        T1->SetBranchAddress("recTrackinnerMomentumofTSOS", &recTrackinnerMomentumofTSOS);
        T1->SetBranchAddress("recTrackinnerPhiofTSOS", &recTrackinnerPhiofTSOS);
        T1->SetBranchAddress("recTrackinnerEtaofTSOS", &recTrackinnerEtaofTSOS);
        T1->SetBranchAddress("recTrackinnerValidofTSOS", &recTrackinnerValidofTSOS);
        T1->SetBranchAddress("recTrackouterMomentumofTSOS", &recTrackouterMomentumofTSOS);
        T1->SetBranchAddress("recTrackouterPhiofTSOS", &recTrackouterPhiofTSOS);
        T1->SetBranchAddress("recTrackouterEtaofTSOS", &recTrackouterEtaofTSOS);
        T1->SetBranchAddress("recTrackouterValidofTSOS", &recTrackouterValidofTSOS);
        T1->SetBranchAddress("recTrackimpactMomentumofTSOS", &recTrackimpactMomentumofTSOS);
        T1->SetBranchAddress("recTrackimpactPhiofTSOS", &recTrackimpactPhiofTSOS);
        T1->SetBranchAddress("recTrackimpactEtaofTSOS", &recTrackimpactEtaofTSOS);
        T1->SetBranchAddress("recTrackimpactValidofTSOS", &recTrackimpactValidofTSOS);
        T1->SetBranchAddress("recTrackCharge", &recTrackCharge);
        T1->SetBranchAddress("simTrackMomentumPt", &simTrackMomentumPt);
        T1->SetBranchAddress("simTrackPhi", &simTrackPhi);
        T1->SetBranchAddress("simTrackEta", &simTrackEta);
        T1->SetBranchAddress("simTrackCharge", &simTrackCharge);

        string TempHistName;
        TempHistName = theFileName + "_Efficiency2simPt";
        TH1D* Efficiency2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale);
        TempHistName = theFileName + "_Particle2simPt";
        TH1D* Particle2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale);
        TempHistName = theFileName + "_STA2simPt";
        TH1D* STA2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale);
        TempHistName = theFileName + "_InverseChargeRato2simPt";
        TH1D* InverseChargeRato2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale);
        TempHistName = theFileName + "_DeltaPt2simPt";
        TH1D* DeltaPt2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale);
        TempHistName = theFileName + "_DeltaPhi2simPt";
        TH1D* DeltaPhi2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale);
        TempHistName = theFileName + "_DeltaEta2simPt";
        TH1D* DeltaEta2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale);
        TempHistName = theFileName + "_MaxPurity2simPt";
        TH2D* MaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 6, 0., 1.2);
        TempHistName = theFileName + "_Multiplicity2simPt";
        TH2D* Multiplicity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 10, 0., 10.);
        TempHistName = theFileName + "_ChargeCheck2simPt";
        TH2D* ChargeCheck2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 5, -2.5, 2.5);
        TempHistName = theFileName + "_simTrackMomentumPtmaxPurity2simPt";
        TH2D* simTrackMomentumPtmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, (int)5*PtScale, 0, PtScale);
        TempHistName = theFileName + "_simTrackPhimaxPurity2simPt";
        TH2D* simTrackPhimaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 314, -PI, PI);
        TempHistName = theFileName + "_simTrackEtamaxPurity2simPt";
        TH2D* simTrackEtamaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 400, -2.0, 2.0);
        TempHistName = theFileName + "_recTrackimpactMomentumofTSOSmaxPurity2simPt";
        TH2D* recTrackimpactMomentumofTSOSmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, (int)5*PtScale, 0, PtScale);
        TempHistName = theFileName + "_recTrackimpactPhiofTSOSmaxPurity2simPt";
        TH2D* recTrackimpactPhiofTSOSmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 314, -PI, PI);
        TempHistName = theFileName + "_recTrackimpactEtaofTSOSmaxPurity2simPt";
        TH2D* recTrackimpactEtaofTSOSmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 600, -3.0, 3.0);
        TempHistName = theFileName + "_recTrackimpactValidofTSOSmaxPurity2simPt";
        TH2D* recTrackimpactValidofTSOSmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 2, 0., 2.);
        TempHistName = theFileName + "_DeltaPtmaxPurity2simPt";
        TH2D* DeltaPtmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(),  (int)(PtScale/2), 0, PtScale, (int)5*PtScale, -1.*PtScale, PtScale);
        TempHistName = theFileName + "_DeltaPhimaxPurity2simPt";
        TH2D* DeltaPhimaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(),  (int)(PtScale/2), 0, PtScale, 314, -PI, PI);
        TempHistName = theFileName + "_DeltaEtamaxPurity2simPt";
        TH2D* DeltaEtamaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(),  (int)(PtScale/2), 0, PtScale, 400, -2.0, 2.0);

        unsigned int trackingParticleMatch_temp;
        unsigned int efficiency_temp;
        double recTrackPurity_temp;
        double recTrackrefMomentum_temp;
        double recTrackrefPhi_temp;
        double recTrackrefEta_temp;
        double recTrackinnerMomentum_temp;
        double recTrackinnerPhi_temp;
        double recTrackinnerEta_temp;
        unsigned int recTrackinnerValid_temp;
        double recTrackouterMomentum_temp;
        double recTrackouterPhi_temp;
        double recTrackouterEta_temp;
        unsigned int recTrackouterValid_temp;
        double simTrackinnerMomentum_temp;
        double simTrackinnerPhi_temp;
        double simTrackinnerEta_temp;
        unsigned int simTrackinnerMatch_temp;
        double simTrackouterMomentum_temp;
        double simTrackouterPhi_temp;
        double simTrackouterEta_temp;
        unsigned int simTrackouterMatch_temp;
        double recTrackinnerMomentumofTSOS_temp;
        double recTrackinnerPhiofTSOS_temp;
        double recTrackinnerEtaofTSOS_temp;
        unsigned int recTrackinnerValidofTSOS_temp;
        double recTrackouterMomentumofTSOS_temp;
        double recTrackouterPhiofTSOS_temp;
        double recTrackouterEtaofTSOS_temp;
        unsigned int recTrackouterValidofTSOS_temp;
        double recTrackimpactMomentumofTSOS_temp;
        double recTrackimpactPhiofTSOS_temp;
        double recTrackimpactEtaofTSOS_temp;
        unsigned int recTrackimpactValidofTSOS_temp;
        int recTrackCharge_temp;
        double simTrackMomentumPt_temp;
        double simTrackPhi_temp;
        double simTrackEta_temp;
        int simTrackCharge_temp;

        int Nentries = T1->GetEntries(); 
        for(int i = 0; i < Nentries; i++) { 
            T1->GetEntry(i);
            if(trackingParticleMatch == 0) {
                MaxPurity2simPtHist->Fill(simTrackMomentumPt, 0);
                Multiplicity2simPtHist->Fill(simTrackMomentumPt, 0);
                int tempParticleBinNumber = Particle2simPtHist->FindBin(simTrackMomentumPt);
                double tempParticleBinValue = Particle2simPtHist->GetBinContent(tempParticleBinNumber);
                tempParticleBinValue += 1.;
                Particle2simPtHist->SetBinContent(tempParticleBinNumber, tempParticleBinValue);
            }
            else {
                efficiency_temp = 1;
                trackingParticleMatch_temp = trackingParticleMatch;
                recTrackPurity_temp = recTrackPurity;
                recTrackrefMomentum_temp = recTrackrefMomentum;
                recTrackrefPhi_temp = recTrackrefPhi;
                recTrackrefEta_temp = recTrackrefEta;
                recTrackinnerMomentum_temp = recTrackinnerMomentum;
                recTrackinnerPhi_temp = recTrackinnerPhi;
                recTrackinnerEta_temp = recTrackinnerEta;
                recTrackinnerValid_temp = recTrackinnerValid;
                recTrackouterMomentum_temp = recTrackouterMomentum;
                recTrackouterPhi_temp = recTrackouterPhi;
                recTrackouterEta_temp = recTrackouterEta;
                recTrackouterValid_temp = recTrackouterValid;
                simTrackinnerMomentum_temp = simTrackinnerMomentum;
                simTrackinnerPhi_temp = simTrackinnerPhi;
                simTrackinnerEta_temp = simTrackinnerEta;
                simTrackinnerMatch_temp = simTrackinnerMatch;
                simTrackouterMomentum_temp = simTrackouterMomentum;
                simTrackouterPhi_temp = simTrackouterPhi;
                simTrackouterEta_temp = simTrackouterEta;
                simTrackouterMatch_temp = simTrackouterMatch;
                recTrackinnerMomentumofTSOS_temp = recTrackinnerMomentumofTSOS;
                recTrackinnerPhiofTSOS_temp = recTrackinnerPhiofTSOS;
                recTrackinnerEtaofTSOS_temp = recTrackinnerEtaofTSOS;
                recTrackinnerValidofTSOS_temp = recTrackinnerValidofTSOS;
                recTrackouterMomentumofTSOS_temp = recTrackouterMomentumofTSOS;
                recTrackouterPhiofTSOS_temp = recTrackouterPhiofTSOS;
                recTrackouterEtaofTSOS_temp = recTrackouterEtaofTSOS;
                recTrackouterValidofTSOS_temp = recTrackouterValidofTSOS;
                recTrackimpactMomentumofTSOS_temp = recTrackimpactMomentumofTSOS;
                recTrackimpactPhiofTSOS_temp = recTrackimpactPhiofTSOS;
                recTrackimpactEtaofTSOS_temp = recTrackimpactEtaofTSOS;
                recTrackimpactValidofTSOS_temp = recTrackimpactValidofTSOS;
                recTrackCharge_temp = recTrackCharge;
                simTrackMomentumPt_temp = simTrackMomentumPt;
                simTrackPhi_temp = simTrackPhi;
                simTrackEta_temp = simTrackEta;
                simTrackCharge_temp = simTrackCharge;

                bool nextStep = true;
                while(nextStep) {
                    i++;
                    T1->GetEntry(i);
                    if(trackingParticleMatch <= trackingParticleMatch_temp)
                        nextStep = false;
                    else
                        trackingParticleMatch_temp = trackingParticleMatch;
                    if(nextStep == true && recTrackPurity_temp < recTrackPurity) {
                        if(debug) cout << "step another match, trackingParticleMatch_temp: " << trackingParticleMatch_temp << endl;
                        //trackingParticleMatch_temp = trackingParticleMatch;
                        recTrackPurity_temp = recTrackPurity;
                        recTrackrefMomentum_temp = recTrackrefMomentum;
                        recTrackrefPhi_temp = recTrackrefPhi;
                        recTrackrefEta_temp = recTrackrefEta;
                        recTrackinnerMomentum_temp = recTrackinnerMomentum;
                        recTrackinnerPhi_temp = recTrackinnerPhi;
                        recTrackinnerEta_temp = recTrackinnerEta;
                        recTrackinnerValid_temp = recTrackinnerValid;
                        recTrackouterMomentum_temp = recTrackouterMomentum;
                        recTrackouterPhi_temp = recTrackouterPhi;
                        recTrackouterEta_temp = recTrackouterEta;
                        recTrackouterValid_temp = recTrackouterValid;
                        simTrackinnerMomentum_temp = simTrackinnerMomentum;
                        simTrackinnerPhi_temp = simTrackinnerPhi;
                        simTrackinnerEta_temp = simTrackinnerEta;
                        simTrackinnerMatch_temp = simTrackinnerMatch;
                        simTrackouterMomentum_temp = simTrackouterMomentum;
                        simTrackouterPhi_temp = simTrackouterPhi;
                        simTrackouterEta_temp = simTrackouterEta;
                        simTrackouterMatch_temp = simTrackouterMatch;
                        recTrackinnerMomentumofTSOS_temp = recTrackinnerMomentumofTSOS;
                        recTrackinnerPhiofTSOS_temp = recTrackinnerPhiofTSOS;
                        recTrackinnerEtaofTSOS_temp = recTrackinnerEtaofTSOS;
                        recTrackinnerValidofTSOS_temp = recTrackinnerValidofTSOS;
                        recTrackouterMomentumofTSOS_temp = recTrackouterMomentumofTSOS;
                        recTrackouterPhiofTSOS_temp = recTrackouterPhiofTSOS;
                        recTrackouterEtaofTSOS_temp = recTrackouterEtaofTSOS;
                        recTrackouterValidofTSOS_temp = recTrackouterValidofTSOS;
                        recTrackimpactMomentumofTSOS_temp = recTrackimpactMomentumofTSOS;
                        recTrackimpactPhiofTSOS_temp = recTrackimpactPhiofTSOS;
                        recTrackimpactEtaofTSOS_temp = recTrackimpactEtaofTSOS;
                        recTrackimpactValidofTSOS_temp = recTrackimpactValidofTSOS;
                        recTrackCharge_temp = recTrackCharge;
                        simTrackMomentumPt_temp = simTrackMomentumPt;
                        simTrackPhi_temp = simTrackPhi;
                        simTrackEta_temp = simTrackEta;
                        simTrackCharge_temp = simTrackCharge;
                    }
                }
                i--;
                //if(debug) cout << "Filling Multiplicity " << trackingParticleMatch_temp << endl;
                MaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackPurity_temp);
                Multiplicity2simPtHist->Fill(simTrackMomentumPt_temp, trackingParticleMatch_temp);
                ChargeCheck2simPtHist->Fill(simTrackMomentumPt_temp, simTrackCharge_temp*recTrackCharge_temp);
                simTrackMomentumPtmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, simTrackMomentumPt_temp);
                simTrackPhimaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, simTrackPhi_temp);
                simTrackEtamaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, simTrackEta_temp);
                recTrackimpactMomentumofTSOSmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactMomentumofTSOS_temp);
                recTrackimpactPhiofTSOSmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactPhiofTSOS_temp);
                recTrackimpactEtaofTSOSmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactEtaofTSOS_temp);
                recTrackimpactValidofTSOSmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactValidofTSOS_temp);
                DeltaPtmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, (recTrackimpactMomentumofTSOS_temp-simTrackMomentumPt_temp)/simTrackMomentumPt_temp);
                DeltaPhimaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactPhiofTSOS_temp-simTrackPhi_temp);
                DeltaEtamaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactEtaofTSOS_temp-simTrackEta_temp);


                int tempParticleBinNumber = STA2simPtHist->FindBin(simTrackMomentumPt_temp);
                double tempParticleBinValue = Particle2simPtHist->GetBinContent(tempParticleBinNumber);
                tempParticleBinValue += 1.;
                Particle2simPtHist->SetBinContent(tempParticleBinNumber, tempParticleBinValue);
                double tempSTABinValue = STA2simPtHist->GetBinContent(tempParticleBinNumber);
                tempSTABinValue += 1.;                        
                STA2simPtHist->SetBinContent(tempParticleBinNumber, tempSTABinValue);
            }
        }

        
        for(int PtIndex = 1; PtIndex <= (int)(PtScale/2); PtIndex++) {
            double ParticleBinValue = Particle2simPtHist->GetBinContent(PtIndex);
            double STABinValue = STA2simPtHist->GetBinContent(PtIndex);
            if(ParticleBinValue == 0.)
                ParticleBinValue += 1.;
            double EfficiencyBinValue = STABinValue / ParticleBinValue * 100.;
            double EfficiencyBinError = sqrt(EfficiencyBinValue * (100. - EfficiencyBinValue) / ParticleBinValue);
            cout << ParticleBinValue << ", " << STABinValue << ", " << EfficiencyBinValue << endl;
            Efficiency2simPtHist->SetBinContent(PtIndex, EfficiencyBinValue);
            Efficiency2simPtHist->SetBinError(PtIndex, EfficiencyBinError);

            TH1D* ChargeCheckHist = ChargeCheck2simPtHist->ProjectionY("ChargeCheck", PtIndex, PtIndex, "o");
            double ReverseChargeBinValue = ChargeCheckHist->GetBinContent(2);
            double CoverseChargeBinValue = ChargeCheckHist->GetBinContent(4);
            double TotalChargeBinValue = ReverseChargeBinValue + CoverseChargeBinValue;
            if(TotalChargeBinValue == 0.);
                TotalChargeBinValue += 1.;
            double ReverseChargeRato = ReverseChargeBinValue / TotalChargeBinValue;
            InverseChargeRato2simPtHist->SetBinContent(PtIndex, ReverseChargeRato);

            TH1D* DeltaPtHist = DeltaPtmaxPurity2simPtHist->ProjectionY("DeltaPt", PtIndex, PtIndex, "o");
            double DeltaPtMean = DeltaPtHist->GetMean();
            double DeltaPtRMS = DeltaPtHist->GetRMS();
            DeltaPt2simPtHist->SetBinContent(PtIndex, DeltaPtMean);
            DeltaPt2simPtHist->SetBinError(PtIndex, DeltaPtRMS);

            TH1D* DeltaPhiHist = DeltaPhimaxPurity2simPtHist->ProjectionY("DeltaPhi", PtIndex, PtIndex, "o");
            double DeltaPhiMean = DeltaPhiHist->GetMean();
            double DeltaPhiRMS = DeltaPhiHist->GetRMS();
            DeltaPhi2simPtHist->SetBinContent(PtIndex, DeltaPhiMean);
            DeltaPhi2simPtHist->SetBinError(PtIndex, DeltaPhiRMS);

            TH1D* DeltaEtaHist = DeltaEtamaxPurity2simPtHist->ProjectionY("DeltaEta", PtIndex, PtIndex, "o");
            double DeltaEtaMean = DeltaEtaHist->GetMean();
            double DeltaEtaRMS = DeltaEtaHist->GetRMS();
            DeltaEta2simPtHist->SetBinContent(PtIndex, DeltaEtaMean);
            DeltaEta2simPtHist->SetBinError(PtIndex, DeltaEtaRMS);
        }
        myEfficiencyHist->AddLast(Efficiency2simPtHist);
        myParticleHist->AddLast(Particle2simPtHist);
        mySTAHist->AddLast(STA2simPtHist);
        myChargeCheckHist->AddLast(InverseChargeRato2simPtHist);
        myDeltaPtHist->AddLast(DeltaPt2simPtHist);
    }
    double minX = 0;
    double minY = 0;
    double maxX = 110;
    double maxY = 40;

    TCanvas* myCanvas = new TCanvas("Canvas", "Canvas", 800, 600);
    myCanvas->cd();
    TPad* myPad = new TPad("Pad", "Pad", 0, 0, 1, 1);
    myPad->Draw();
    myPad->cd();

    ((TH1D*)(myParticleHist->At(0)))->SetStats(0);
    ((TH1D*)(myParticleHist->At(0)))->GetXaxis()->SetTitle("simPt/Gev");
    ((TH1D*)(myParticleHist->At(0)))->GetXaxis()->CenterTitle(1);
    ((TH1D*)(myParticleHist->At(0)))->Draw();
    for(int Index = 0; Index < FileNumber; Index++) {
	((TH1D*)(mySTAHist->At(Index)))->SetStats(0);
        ((TH1D*)(mySTAHist->At(Index)))->SetLineColor(kRed+Index);
        ((TH1D*)(mySTAHist->At(Index)))->Draw("same");
    }
    TLegend *STALeg = new TLegend(0.6,0.1,0.9,0.3);
    STALeg->SetBorderSize(1);
    TString LegKey = "ParticleTrack";
    STALeg->AddEntry(myParticleHist->At(0), LegKey, "lpf");
    for(int Index = 0; Index < FileNumber; Index++) {
        LegKey = TypeName[Index];
        STALeg->AddEntry(mySTAHist->At(Index), LegKey, "lpf");
    }
    STALeg->Draw();
    string SaveName = OutputPlotNamepreFix + "_STA2simPt" + OutputPlotNameFix;
    myCanvas->SaveAs(SaveName.c_str());

    myPad->Clear();
    myPad->Update();
    double YScale = myPad->GetUymax() / 110.;
    ((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->SetTitle("simPt/Gev");
    ((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->CenterTitle(1);
    ((TH1D*)(myEfficiencyHist->At(0)))->SetStats(0);
    ((TH1D*)(myEfficiencyHist->At(0)))->Scale(YScale);
    ((TH1D*)(myEfficiencyHist->At(0)))->SetLineColor(kRed);
    ((TH1D*)(myEfficiencyHist->At(0)))->Draw("same,ah");
    for(int Index = 1; Index < FileNumber; Index++) {
	((TH1D*)(myEfficiencyHist->At(Index)))->SetStats(0);
        ((TH1D*)(myEfficiencyHist->At(Index)))->Scale(YScale);
        ((TH1D*)(myEfficiencyHist->At(Index)))->SetLineColor(kRed+Index);
        ((TH1D*)(myEfficiencyHist->At(Index)))->Draw("same,ah");
    }
    myPad->Update();
    if(debug) cout << "Y: " << myPad->GetUymax() << endl;
    double YAxisMinValue=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetXmin();
    double YAxisMaxValue=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetXmax();
    int YAxisNBins=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetNbins();
    TGaxis* YAxis = new TGaxis(myPad->GetUxmin(), myPad->GetUymin(), myPad->GetUxmin(), myPad->GetUymax(), 0, 110, 510, "-R");
    YAxis->SetLineColor(kGreen);
    YAxis->SetLabelColor(kGreen);
    YAxis->SetTitle("Efficiency of STA for simPts");
    YAxis->CenterTitle(1);
    YAxis->Draw();
    double XAxisMinValue=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetXmin();
    double XAxisMaxValue=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetXmax();
    int XAxisNBins=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetNbins();
    TGaxis* XAxis = new TGaxis(myPad->GetUxmin(), myPad->GetUymin(), myPad->GetUxmax(), myPad->GetUymin(), XAxisMinValue, XAxisMaxValue, 510, "+L");
    XAxis->SetTitle("simPt/Gev");
    XAxis->CenterTitle(1);
    XAxis->Draw();
    TLegend *EffLeg = new TLegend(0.1,0.9,0.4,1.0);
    EffLeg->SetBorderSize(1);
    for(int Index = 0; Index < FileNumber; Index++) {
        TString LegKey = TypeName[Index];
        EffLeg->AddEntry(myEfficiencyHist->At(Index), LegKey, "lpf");
    }
    EffLeg->Draw();
    string SaveName = OutputPlotNamepreFix + "_Eff2simPt" + OutputPlotNameFix;
    myCanvas->SaveAs(SaveName.c_str());

    ((TH1D*)(myDeltaPtHist->At(0)))->SetStats(0);
    ((TH1D*)(myDeltaPtHist->At(0)))->GetXaxis()->SetTitle("simPt/Gev");
    ((TH1D*)(myDeltaPtHist->At(0)))->GetXaxis()->CenterTitle(1);
    ((TH1D*)(myDeltaPtHist->At(0)))->GetYaxis()->SetTitle("deltPt/simPt");
    ((TH1D*)(myDeltaPtHist->At(0)))->GetYaxis()->CenterTitle(1);
    ((TH1D*)(myDeltaPtHist->At(0)))->SetLineColor(kRed);
    ((TH1D*)(myDeltaPtHist->At(0)))->Draw("");
    for(int Index = 1; Index < FileNumber; Index++) {
	    ((TH1D*)(myDeltaPtHist->At(Index)))->SetStats(0);
	    //((TH1D*)(myDeltaPtHist->At(Index)))->GetXaxis()->SetTitle("simPt/Gev");
	    //((TH1D*)(myDeltaPtHist->At(Index)))->GetXaxis()->CenterTitle(1);
	    //((TH1D*)(myDeltaPtHist->At(Index)))->GetYaxis()->SetTitle("deltPt/simPt");
	    //((TH1D*)(myDeltaPtHist->At(Index)))->GetYaxis()->CenterTitle(1);
        ((TH1D*)(myDeltaPtHist->At(Index)))->SetLineColor(kRed+Index);
        ((TH1D*)(myDeltaPtHist->At(Index)))->Draw("same");
        //SaveName = OutputPlotNamepreFix + TypeName[Index] + "DeltaPt" + OutputPlotNameFix;
        //myCanvas->SaveAs(SaveName.c_str());
    }
    TLegend *PtLeg = new TLegend(0.6,0.8,0.9,0.9);
    PtLeg->SetBorderSize(1);
    for(int Index = 0; Index < FileNumber; Index++) {
        TString LegKey = TypeName[Index];
        PtLeg->AddEntry(myDeltaPtHist->At(Index), LegKey, "lpf");
    }
    PtLeg->Draw();
    SaveName = OutputPlotNamepreFix + "_DeltaPt" + OutputPlotNameFix;
    myCanvas->SaveAs(SaveName.c_str());
}
void TBDataParser::OnStartElement(const char *element, const TList *attributes)
{
	TXMLAttr *attr;
	TIter next(attributes);

	char *name = element;
	_currentElement = new TString(element);
	
	char *method = NULL;

	while ((attr = (TXMLAttr*) next())) {
		char *attrName = attr->GetName();
		char *attrValue = attr->GetValue();

		if(!strcmp(attrName, "name")) {
			name = attrValue; 
		}
		
		if(!strcmp(attrName, "method")) {
			method = attrValue;	
			_currentMethod = new TString(method);
		}
		
	}

	TFolder *currentFolder = _foldersStack->Last();

	if(!strcmp(element, "vector")) {
		TString *nameString = new TString(name);
		vector<float> *values = new vector<float>;
		_values = values;

		nameString->ReplaceAll(" ","_");

		TObjString *currentVector = new TObjString(nameString->Data());

		TObjArray *vectorsStack = _vectorsStack;
		vectorsStack->AddLast(currentVector);

		TString *joinedName = new TString(((TObjString *) vectorsStack->First())->GetString().Data());

		for(Int_t i = 1; i < vectorsStack->GetEntries(); i++) {
			joinedName->Append("_");
			joinedName->Append(((TObjString *) vectorsStack->At(i))->GetString().Data());
		}
		
		TObjString *joinedNameObj = new TObjString(joinedName->Data());
		TObjArray *joinedNameStack = _joinedNameStack;
		
		TNtuple *vector = new TNtuple(joinedName->Data(),joinedName->Data(),"values");
		_vector = vector;
		currentFolder->Add(vector);

		if(joinedNameStack->Contains(joinedName->Data()))
			cout << joinedName->Data() << "Error: " << "vector already exists. Be sure that in your XML file every vector has a unique path + name combination" << endl;
			
		joinedNameStack->Add(joinedNameObj);
			
			
		return;
	}

	_foldersStack->AddLast(currentFolder->AddFolder(name, name));
}
Example #8
0
void getHistosFromRE(const string&   mhid,
		     const string&   filepath,
		     const string&   sre,
		     vector<std::pair<string,wTH1*> >&  v_wth1)
{
  if (gl_verbose)
    cout<<"Searching for regexp "<<sre<<" in "<<filepath;

  // allow for multiple regexes in OR combination
  //
  vector<string> v_regexes;
  Tokenize(sre,v_regexes,"|");
  if (!v_regexes.size())
    v_regexes.push_back(sre);

  // Build validated TRegexp arguments in preparation for directory recursion
  //
  TObjArray *Args = new TObjArray();
  for (size_t i=0; i<v_regexes.size(); i++) {
    TRegexp re(v_regexes[i].c_str(),kTRUE);
    if (re.Status() != TRegexp::kOK) {
      cerr << "The regexp " << v_regexes[i] << " is invalid, Status() = ";
      cerr << re.Status() << endl;
      exit(-1);
    }
    else {
      Args->AddLast(new TObjString(v_regexes[i].c_str()));
    }
  }

  // Get the root file
  //
  TFile *rootfile = openRootFile(filepath);

  if (!rootfile) {
    cerr << "File failed to open, " << filepath << endl;
    Args->Delete();
    delete Args;
    return;
  }

  // Do the recursion, collect matches
  //
  TObjArray *Matches = new TObjArray();
  recurseDirs(rootfile, &regexMatchHisto, Args, Matches);
  Args->Delete();
  delete Args;

  // Returns two objects per match: 
  // 1. the (string) path that was matched and
  // 2. the object whose path matched
  //
  int nx2matches = Matches->GetEntriesFast();
  if (gl_verbose) cout << "... " << nx2matches/2 << " match(es) found.";

  // Add the matches to the global map of histos
  //
  int istart = v_wth1.size();

  for (int i=0; i<nx2matches; i+=2) {
    TString fullspec = ((TObjString *)(*Matches)[i])->GetString();
    wTH1 *wth1 = new wTH1((TH1 *)((*Matches)[i+1]));
    wth1->histo()->UseCurrentStyle();
    wth1->histo()->SetLineColor(((i/2)%9)+1);
    wth1->histo()->SetLineStyle((i/18)+1);
    wth1->histo()->SetLineWidth(2);
    wth1->SetLegendEntry(wth1->histo()->GetName());
    string hidi= mhid+"_"+int2str(istart+(i/2));
    v_wth1.push_back(std::pair<string,wTH1 *>(hidi,wth1));

    //glmap_objpath2id.insert(pair<string,string>(fullspec,hidi));
    glmap_id2histo.insert(pair<string,wTH1 *>(hidi,wth1));
    glmap_id2objpath.insert(pair<string,string>(hidi,string(fullspec.Data())));
  }

  //Matches->Delete(); // need the histos!
  delete Matches;

  if (gl_verbose) cout << endl;
}                                                     // getHistosFromRE
Example #9
0
void RPCSeedValidator(string FileName) {

    gStyle->SetOptStat("");
    gStyle->SetOptTitle(0);
    if(debug) cout << FileName << endl;
    string theFileName = "../" + FileName;
    TFile* RootFile = TFile::Open(theFileName.c_str());
    string OutputPlotNameFix = ".eps";
    string FinalOutput = FileName + "_";

    unsigned int EventNumber;
    int SimTrackId;
    int SimTrackType;
    double SimTrackMomentum;
    double SimTrackDirectionPhi;
    int SimTrackCharge;
    int SimTrackvalid;
    bool PassSegmentFilter;
    double SimMomentumPtatRef;
    double SimDirectionPhiatRef;
    double SimDirectionEtaatRef;
    double SimBendingPhi;
    double SimBendingEntryPositionX;
    double SimBendingEntryPositionY;
    double SimBendingEntryPositionZ;
    double SimBendingLeavePositionX;
    double SimBendingLeavePositionY;
    double SimBendingLeavePositionZ;
    unsigned int SeedNumber;
    int SeedCharge;
    double SeedPurity;
    double SeedQuality;
    double RecMomentumPtatRef;
    double RecDirectionPhiatRef;
    double RecDirectionEtaatRef;
    double RecBendingPhi;
    double RecBendingEntryPositionX;
    double RecBendingEntryPositionY;
    double RecBendingEntryPositionZ;
    double RecBendingLeavePositionX;
    double RecBendingLeavePositionY;
    double RecBendingLeavePositionZ;
    double RecBendingLastPhi;

    TTree* T0 = (TTree*)RootFile->Get("ExTree");
    T0->SetBranchAddress("EventNumber", &EventNumber);
    T0->SetBranchAddress("SimTrackId", &SimTrackId);
    T0->SetBranchAddress("SimTrackType", &SimTrackType);
    T0->SetBranchAddress("SimTrackMomentum", &SimTrackMomentum);
    T0->SetBranchAddress("SimTrackDirectionPhi", &SimTrackDirectionPhi);
    T0->SetBranchAddress("SimTrackCharge", &SimTrackCharge);
    T0->SetBranchAddress("SimTrackValid", &SimTrackvalid);
    T0->SetBranchAddress("PassSegmentFilter", &PassSegmentFilter);
    T0->SetBranchAddress("SimMomentumPtatRef", &SimMomentumPtatRef);
    T0->SetBranchAddress("SimDirectionPhiatRef", &SimDirectionPhiatRef);
    T0->SetBranchAddress("SimDirectionEtaatRef", &SimDirectionEtaatRef);
    T0->SetBranchAddress("SimBendingPhi", &SimBendingPhi);
    T0->SetBranchAddress("SimBendingEntryPositionX", &SimBendingEntryPositionX);
    T0->SetBranchAddress("SimBendingEntryPositionY", &SimBendingEntryPositionY);
    T0->SetBranchAddress("SimBendingEntryPositionZ", &SimBendingEntryPositionZ);
    T0->SetBranchAddress("SimBendingLeavePositionX", &SimBendingLeavePositionX);
    T0->SetBranchAddress("SimBendingLeavePositionY", &SimBendingLeavePositionY);
    T0->SetBranchAddress("SimBendingLeavePositionZ", &SimBendingLeavePositionZ);
    T0->SetBranchAddress("SeedNumber", &SeedNumber);
    T0->SetBranchAddress("SeedCharge", &SeedCharge);
    T0->SetBranchAddress("SeedPurity", &SeedPurity);
    T0->SetBranchAddress("SeedQuality", &SeedQuality);
    T0->SetBranchAddress("RecMomentumPtatRef", &RecMomentumPtatRef);
    T0->SetBranchAddress("RecDirectionPhiatRef", &RecDirectionPhiatRef);
    T0->SetBranchAddress("RecDirectionEtaatRef", &RecDirectionEtaatRef);
    T0->SetBranchAddress("RecBendingPhi", &RecBendingPhi);
    T0->SetBranchAddress("RecBendingEntryPositionX", &RecBendingEntryPositionX);
    T0->SetBranchAddress("RecBendingEntryPositionY", &RecBendingEntryPositionY);
    T0->SetBranchAddress("RecBendingEntryPositionZ", &RecBendingEntryPositionZ);
    T0->SetBranchAddress("RecBendingLeavePositionX", &RecBendingLeavePositionX);
    T0->SetBranchAddress("RecBendingLeavePositionY", &RecBendingLeavePositionY);
    T0->SetBranchAddress("RecBendingLeavePositionZ", &RecBendingLeavePositionZ);
    T0->SetBranchAddress("RecBendingLastPhi", &RecBendingLastPhi);

    TH1D* SimTrackvalidHist = (TH1D*) new TH1D("SimTrackvalidHist", "SimTrackvalidHist", 2, 0, 2);
    TH1D* SeedPtforSimTrackvalidHist = (TH1D*) new TH1D("SeedPtforSimTrackvalidHist", "SeedPtforSimTrackvalidHist", 100, 0, 100);
    TH1D* SeeddeltaPtforSimTrackvalidHist = (TH1D*) new TH1D("SeeddeltaPtforSimTrackvalidHist", "SeeddeltaPtforSimTrackvalidHist", 150, -3., 3.);
    TH1D* SeeddeltaPhiforSimTrackvalidHist = (TH1D*) new TH1D("SeeddeltaPhiforSimTrackvalidHist", "SeeddeltaPhiforSimTrackvalidHist", 628, -3.14/6, 3.14/6);
    TH1D* SeeddeltaEtaforSimTrackvalidHist = (TH1D*) new TH1D("SeeddeltaEtaforSimTrackvalidHist", "SeeddeltaEtaforSimTrackvalidHist", 200, -1., 1.);
    TH1D* SeedPurityforSimTrackvalidHist = (TH1D*) new TH1D("SeedPurityforSimTrackvalidHist", "SeedPurityforSimTrackvalidHist", 20, 0, 2);
    TH1D* ChargeCheckforSimTrackvalidHist = (TH1D*) new TH1D("ChargeCheckforSimTrackvalidHist", "ChargeCheckforSimTrackvalidHist", 5, -2.5, 2.5);
    TH1D* SeedNumberforSimTrackvalidHist = (TH1D*) new TH1D("SeedNumberforSimTrackvalidHist", "SeedNumberforSimTrackvalidHist", 30, 0, 30);
    TH1D* SeedEfficiencyforSimTrackvalidHist = (TH1D*) new TH1D("SeedEfficiencyforSimTrackvalidHist", "SeedEfficiencyforSimTrackvalidHist", 2, 0, 2);
    TH1D* SeedNumberforSimTrackinvalidHist = (TH1D*) new TH1D("SeedNumberforSimTrackinvalidHist", "SeedNumberforSimTrackinvalidHist", 20, 0, 20);
    TH1D* SeedEfficiencyforSimTrackinvalidHist = (TH1D*) new TH1D("SeedEfficiencyforSimTrackinvalidHist", "SeedEfficiencyforSimTrackinvalidHist", 2, 0, 2);
    TH1D* RecBendingLastPhiHist = (TH1D*) new TH1D("RecBendingLastPhiHist", "RecBendingLastPhiHist", 628, -3.14/2, 3.14/2);
    TH1D* SeedEfficiencyHist = (TH1D*) new TH1D("SeedEfficiency", "SeedEfficiency", 2, 0, 2);
    TH2D* RecBendingPhi2PtHist = new TH2D("RecBendingPhi2PtHist", "RecBendingPhi2PtHist", 2000, -100, 100, 628, -3.14/4, 3.14/4);
    TH2D* PtRatoofRecBendingPhiHist = new TH2D("", "", 628, -3.14/4, 3.14/4, 2000, -100, 100);
    TObjArray* SimReverseBending = (TObjArray*) new TObjArray();

    unsigned int LastSeedNumber = -1;
    unsigned int LastSimTrackvalid = 0;
    bool LastPassSegmentFilter = false;
    bool LastPurityFull = false;
    int Nentries = T0->GetEntries();
    for(int i = 0; i < Nentries; i++) {
        T0->GetEntry(i);

        if(debug) cout << "SimTrackId: " << SimTrackId << ", SimTrackType: " << SimTrackType << ", PassSegmentFilter: " << PassSegmentFilter << ", SeedNumber: " << SeedNumber << ", SeedPurity: " << SeedPurity << ", SeedCharge: " << SeedCharge << ", SimTrackCharge: " << SimTrackCharge << ", SimBendingPhi: " << SimBendingPhi << ", RecBendingPhi: " << RecBendingPhi << ", RecBendingLastPhi: " << RecBendingLastPhi << ", RecMomentumPtatRef: " << RecMomentumPtatRef << ", SimMomentumPtatRef: " << SimMomentumPtatRef << ", LastSeedNumber: " << LastSeedNumber << endl;

        //if(SimTrackMomentum > 20.0)
            //continue;

        if(SeedNumber != 0) {
            if(SimTrackvalid == 1 && SeedPurity == 1. && PassSegmentFilter == true) {
                SeedPtforSimTrackvalidHist->Fill(RecMomentumPtatRef);
                SeeddeltaPtforSimTrackvalidHist->Fill((RecMomentumPtatRef-SimMomentumPtatRef)/SimMomentumPtatRef);
                SeeddeltaPhiforSimTrackvalidHist->Fill(RecDirectionPhiatRef-SimDirectionPhiatRef);
                SeeddeltaEtaforSimTrackvalidHist->Fill(RecDirectionEtaatRef-SimDirectionEtaatRef);
                RecBendingPhi2PtHist->Fill(SimMomentumPtatRef*SimTrackCharge, RecBendingPhi);
                double PtRato = SimMomentumPtatRef / RecMomentumPtatRef;
                if(debug) cout << "PtRato: " << PtRato << ", at RecBendingPhi: " << RecBendingPhi << endl;
                PtRatoofRecBendingPhiHist->Fill(RecBendingPhi, PtRato);
                RecBendingLastPhiHist->Fill((RecBendingLastPhi == 0. ? 0 : RecBendingLastPhi/fabs(RecBendingLastPhi))*SimTrackCharge);
                SeedPurityforSimTrackvalidHist->Fill(SeedPurity);
                ChargeCheckforSimTrackvalidHist->Fill(SeedCharge*SimTrackCharge);
                /*
                if(SeedPurity == 1) {
                    //SeedPtforSimTrackvalidHist->Fill(RecMomentumPtatRef);
                    //SeeddeltaPtforSimTrackvalidHist->Fill(RecMomentumPtatRef-SimMomentumPtatRef);
                    RecBendingPhi2PtHist->Fill(SimMomentumPtatRef*SimTrackCharge, RecBendingPhi);
                    double PtRato = SimMomentumPtatRef / RecMomentumPtatRef;
                    if(debug) cout << "PtRato: " << PtRato << ", at RecBendingPhi: " << RecBendingPhi << endl;
                    PtRatoofRecBendingPhiHist->Fill(RecBendingPhi, PtRato);
                    RecBendingLastPhiHist->Fill((RecBendingLastPhi == 0. ? 0 : RecBendingLastPhi/fabs(RecBendingLastPhi))*SimTrackCharge);
                }
                */
                if(SeedCharge*SimTrackCharge == -1) {
                    if(debug) cout << "R1: " << sqrt(SimBendingEntryPositionX*SimBendingEntryPositionX+SimBendingEntryPositionY*SimBendingEntryPositionY) << ", R2: " << sqrt(SimBendingLeavePositionX*SimBendingLeavePositionX+SimBendingLeavePositionY*SimBendingLeavePositionY) << endl;
                    TLine* SimSegment = new TLine(SimBendingEntryPositionX, SimBendingEntryPositionY, SimBendingLeavePositionX, SimBendingLeavePositionY);
                    SimReverseBending->AddLast(SimSegment);
                }
                LastPurityFull = true;
            }
        }
        else {
            if(LastSeedNumber != -1) {
                if(LastSimTrackvalid == 1 && LastPassSegmentFilter == true) {
                    if(debug) cout << "Filling valid track efficiency " << LastSeedNumber << endl;
                    SeedNumberforSimTrackvalidHist->Fill(LastSeedNumber);
                    SeedEfficiencyforSimTrackvalidHist->Fill(LastPurityFull==true?1:0);
                }
                else {
                    SeedNumberforSimTrackinvalidHist->Fill(LastSeedNumber);
                    SeedEfficiencyforSimTrackinvalidHist->Fill(LastPurityFull==true?1:0);
                }
                LastPurityFull = false;
            }
        }
        LastPassSegmentFilter = PassSegmentFilter;
        LastSeedNumber = SeedNumber;
        LastSimTrackvalid = SimTrackvalid;
    }
    if(LastSeedNumber != -1) {
        if(LastSimTrackvalid == 1 && LastPassSegmentFilter == true) {
            SeedNumberforSimTrackvalidHist->Fill(LastSeedNumber);
            SeedEfficiencyforSimTrackvalidHist->Fill(LastPurityFull==true?1:0);
        }
        else {
            SeedNumberforSimTrackinvalidHist->Fill(LastSeedNumber);
            SeedEfficiencyforSimTrackinvalidHist->Fill(LastPurityFull == true?1:0);
        }
    }

    TCanvas* SimTrackvalidCanvas = new TCanvas("SimTrackvalidCanvas", "SimTrackvalidCanvas", 800, 600);
    SimTrackvalidCanvas->cd();
    SimTrackvalidHist->Draw();
    string SimTrackvalidCanvasName = FinalOutput + "SimTrackvalid" + OutputPlotNameFix;
    SimTrackvalidCanvas->SaveAs(SimTrackvalidCanvasName.c_str());

    TCanvas* SeedPtforSimTrackvalidCanvas = new TCanvas("SeedPtforSimTrackvalidCanvas", "SeedPtforSimTrackvalidCanvas", 800, 600);
    SeedPtforSimTrackvalidCanvas->cd();
    SeedPtforSimTrackvalidHist->Draw();
    string SeedPtforSimTrackvalidCanvasName = FinalOutput + "SeedPtforSimTrackvalid" + OutputPlotNameFix;
    SeedPtforSimTrackvalidCanvas->SaveAs(SeedPtforSimTrackvalidCanvasName.c_str());

    TCanvas* SeeddeltaPtforSimTrackvalidCanvas = new TCanvas("SeeddeltaPtforSimTrackvalidCanvas", "SeeddeltaPtforSimTrackvalidCanvas", 800, 600);
    SeeddeltaPtforSimTrackvalidCanvas->cd();
    SeeddeltaPtforSimTrackvalidHist->SetStats(1);
    gStyle->SetOptFit(0111);
    //SeeddeltaPtforSimTrackvalidHist->Fit("gaus", "", "", -1., 1.);
    SeeddeltaPtforSimTrackvalidHist->GetXaxis()->SetTitle("(recPt-simPt)/simPt");
    SeeddeltaPtforSimTrackvalidHist->GetXaxis()->CenterTitle();
    SeeddeltaPtforSimTrackvalidHist->Draw();
    string SeeddeltaPtforSimTrackvalidCanvasName = FinalOutput + "SeeddeltaPtforSimTrackvalid" + OutputPlotNameFix;
    SeeddeltaPtforSimTrackvalidCanvas->SaveAs(SeeddeltaPtforSimTrackvalidCanvasName.c_str());

    TCanvas* SeeddeltaPhiforSimTrackvalidCanvas = new TCanvas("SeeddeltaPhiforSimTrackvalidCanvas", "SeeddeltaPhiforSimTrackvalidCanvas", 800, 600);
    SeeddeltaPhiforSimTrackvalidCanvas->cd();
    SeeddeltaPhiforSimTrackvalidHist->SetStats(1);
    SeeddeltaPhiforSimTrackvalidHist->GetXaxis()->SetTitle("(recPhi-simPhi)");
    SeeddeltaPhiforSimTrackvalidHist->GetXaxis()->CenterTitle();
    SeeddeltaPhiforSimTrackvalidHist->Draw();
    string SeeddeltaPhiforSimTrackvalidCanvasName = FinalOutput + "SeeddeltaPhiforSimTrackvalid" + OutputPlotNameFix;
    SeeddeltaPhiforSimTrackvalidCanvas->SaveAs(SeeddeltaPhiforSimTrackvalidCanvasName.c_str());

    TCanvas* SeeddeltaEtaforSimTrackvalidCanvas = new TCanvas("SeeddeltaEtaforSimTrackvalidCanvas", "SeeddeltaEtaforSimTrackvalidCanvas", 800, 600);
    SeeddeltaEtaforSimTrackvalidCanvas->cd();
    SeeddeltaEtaforSimTrackvalidHist->SetStats(1);
    SeeddeltaEtaforSimTrackvalidHist->GetXaxis()->SetTitle("(recEta-simEta)");
    SeeddeltaEtaforSimTrackvalidHist->GetXaxis()->CenterTitle();
    SeeddeltaEtaforSimTrackvalidHist->Draw();
    string SeeddeltaEtaforSimTrackvalidCanvasName = FinalOutput + "SeeddeltaEtaforSimTrackvalid" + OutputPlotNameFix;
    SeeddeltaEtaforSimTrackvalidCanvas->SaveAs(SeeddeltaEtaforSimTrackvalidCanvasName.c_str());


    TCanvas* SeedPurityforSimTrackvalidCanvas = new TCanvas("SeedPurityforSimTrackvalidCanvas", "SeedPurityforSimTrackvalidCanvas", 800, 600);
    SeedPurityforSimTrackvalidCanvas->cd();
    SeedPurityforSimTrackvalidHist->Draw();
    string SeedPurityforSimTrackvalidCanvasName = FinalOutput + "SeedPurityforSimTrackvalid" + OutputPlotNameFix;
    SeedPurityforSimTrackvalidCanvas->SaveAs(SeedPurityforSimTrackvalidCanvasName.c_str());

    TCanvas* ChargeCheckforSimTrackvalidCanvas = new TCanvas("ChargeCheckforSimTrackvalidCanvas", "ChargeCheckforSimTrackvalidCanvas", 800, 600);
    ChargeCheckforSimTrackvalidCanvas->cd();
    double HistEntries = ChargeCheckforSimTrackvalidHist->GetEntries() / 100.;
    ChargeCheckforSimTrackvalidHist->Scale(1./HistEntries);
    ChargeCheckforSimTrackvalidHist->GetXaxis()->SetTitle("simCharge*recCharge");
    ChargeCheckforSimTrackvalidHist->GetXaxis()->CenterTitle(1);
    ChargeCheckforSimTrackvalidHist->GetYaxis()->SetTitle("fraction %");
    ChargeCheckforSimTrackvalidHist->GetYaxis()->CenterTitle(1);
    ChargeCheckforSimTrackvalidHist->Draw();
    string ChargeCheckforSimTrackvalidCanvasName = FinalOutput + "ChargeCheckforSimTrackvalid" + OutputPlotNameFix;
    ChargeCheckforSimTrackvalidCanvas->SaveAs(ChargeCheckforSimTrackvalidCanvasName.c_str());

    TCanvas* SeedNumberforSimTrackvalidCanvas = new TCanvas("SeedNumberforSimTrackvalidCanvas", "SeedNumberforSimTrackvalidCanvas", 800, 600);
    SeedNumberforSimTrackvalidCanvas->cd();
    SeedNumberforSimTrackvalidHist->Draw();
    string SeedNumberforSimTrackvalidCanvasName = FinalOutput + "SeedNumberforSimTrackvalid" + OutputPlotNameFix;
    SeedNumberforSimTrackvalidCanvas->SaveAs(SeedNumberforSimTrackvalidCanvasName.c_str());

    TCanvas* SeedEfficiencyforSimTrackvalidCanvas = new TCanvas("SeedEfficiencyforSimTrackvalidCanvas", "SeedEfficiencyforSimTrackvalidCanvas", 800, 600);
    SeedEfficiencyforSimTrackvalidCanvas->cd();
    SeedEfficiencyforSimTrackvalidHist->Draw();
    string SeedEfficiencyforSimTrackvalidCanvasName = FinalOutput + "SeedEfficiencyforSimTrackvalid" + OutputPlotNameFix;
    SeedEfficiencyforSimTrackvalidCanvas->SaveAs(SeedEfficiencyforSimTrackvalidCanvasName.c_str());

    TCanvas* SeedNumberforSimTrackinvalidCanvas = new TCanvas("SeedNumberforSimTrackinvalidCanvas", "SeedNumberforSimTrackinvalidCanvas", 800, 600);
    SeedNumberforSimTrackinvalidCanvas->cd();
    SeedNumberforSimTrackinvalidHist->Draw();
    string SeedNumberforSimTrackinvalidCanvasName = FinalOutput + "SeedNumberforSimTrackinvalid" + OutputPlotNameFix;
    SeedNumberforSimTrackinvalidCanvas->SaveAs(SeedNumberforSimTrackinvalidCanvasName.c_str());

    TCanvas* SeedEfficiencyforSimTrackinvalidCanvas = new TCanvas("SeedEfficiencyforSimTrackinvalidCanvas", "SeedEfficiencyforSimTrackinvalidCanvas", 800, 600);
    SeedEfficiencyforSimTrackinvalidCanvas->cd();
    SeedEfficiencyforSimTrackinvalidHist->Draw();
    string SeedEfficiencyforSimTrackinvalidCanvasName = FinalOutput + "SeedEfficiencyforSimTrackinvalid" + OutputPlotNameFix;
    SeedEfficiencyforSimTrackinvalidCanvas->SaveAs(SeedEfficiencyforSimTrackinvalidCanvasName.c_str());

    double SeedEfficiencyforSimTrackinvalid = 100. * SeedEfficiencyforSimTrackinvalidHist->GetMean();
    double SeedEfficiencyforSimTrackvalid = 100. * SeedEfficiencyforSimTrackvalidHist->GetMean();
    SeedEfficiencyHist->SetBinContent(1, SeedEfficiencyforSimTrackinvalid);
    SeedEfficiencyHist->SetBinContent(2, SeedEfficiencyforSimTrackvalid);
    SeedEfficiencyHist->GetXaxis()->SetBinLabel(1, "for invalid simTrack");
    SeedEfficiencyHist->GetXaxis()->SetBinLabel(2, "for valid simTrack");
    TCanvas* SeedEfficiencyCanvas = new TCanvas("SeedEfficiencyCanvas", "SeedEfficiencyCanvas", 800, 600);
    SeedEfficiencyCanvas->cd();
    SeedEfficiencyHist->GetYaxis()->SetTitle("Efficiency %");
    SeedEfficiencyHist->GetYaxis()->CenterTitle(1);
    SeedEfficiencyHist->SetMarkerStyle(3);
    SeedEfficiencyHist->SetMarkerSize(3);
    SeedEfficiencyHist->Draw("P");
    string SeedEfficiencyCanvasName = FinalOutput + "SeedEfficiency" + OutputPlotNameFix;
    SeedEfficiencyCanvas->SaveAs(SeedEfficiencyCanvasName.c_str());

    TCanvas* RecBendingPhi2PtCanvas = new TCanvas("RecBendingPhi2PtCanvas", "RecBendingPhi2PtCanvas", 800, 600);
    RecBendingPhi2PtCanvas->cd();
    RecBendingPhi2PtHist->Draw();
    string RecBendingPhi2PtCanvasName = FinalOutput + "RecBendingPhi2Pt" + OutputPlotNameFix;
    RecBendingPhi2PtCanvas->SaveAs(RecBendingPhi2PtCanvasName.c_str());

    TCanvas* PtRatoofRecBendingPhiCanvas = new TCanvas("PtRatoofRecBendingPhiCanvas", "PtRatoofRecBendingPhiCanvas", 800, 600);
    PtRatoofRecBendingPhiCanvas->cd();
    PtRatoofRecBendingPhiHist->Draw();
    string PtRatoofRecBendingPhiCanvasName = FinalOutput + "PtRatoofRecBendingPhi" + OutputPlotNameFix;
    PtRatoofRecBendingPhiCanvas->SaveAs(PtRatoofRecBendingPhiCanvasName.c_str());

    TCanvas* RecBendingLastPhiCanvas = new TCanvas("RecBendingLastPhiCanvas", "RecBendingLastPhiCanvas", 800, 600);
    RecBendingLastPhiCanvas->cd();
    RecBendingLastPhiHist->Draw();
    string RecBendingLastPhiCanvasName = FinalOutput + "RecBendingLastPhi" + OutputPlotNameFix;
    RecBendingLastPhiCanvas->SaveAs(RecBendingLastPhiCanvasName.c_str());

    Int_t linsav = gStyle->GetLineWidth();
    gStyle->SetLineWidth(2);
    TCanvas* SimReverseBendingCanvas = new TCanvas("SimReverseBendingCanvas", "SimReverseBendingCanvas", 800, 800);
    SimReverseBendingCanvas->cd();
    TPad* SimReverseBendingPad = new TPad("SimReverseBendingPad", "SimReverseBendingPad", 0, 0, 1, 1);
    SimReverseBendingPad->Draw();
    SimReverseBendingPad->cd();
    SimReverseBendingPad->Range(-800, -800, 800, 800);
    unsigned int segmentNumber = SimReverseBending->GetEntries();
    cout << "Number of segments: " << segmentNumber << endl;
    for(unsigned int j = 0; j < segmentNumber; j++) {
        ((TLine*)(SimReverseBending->At(j)))->Print();
        ((TLine*)(SimReverseBending->At(j)))->Draw("SAME");
    }
    string SimReverseBendingCanvasName = FinalOutput + "SimReverseBending" + OutputPlotNameFix;
    SimReverseBendingCanvas->SaveAs(SimReverseBendingCanvasName.c_str());
}
void limit() {
//This program demonstrates the computation of 95 % C.L. limits.
//It uses a set of randomly created histograms.
//
//Author:  [email protected] on 21.08.02

// Create a new canvas.
  TCanvas *c1 = new TCanvas("c1","Dynamic Filling Example",200,10,700,500);
  c1->SetFillColor(42);
  
// Create some histograms
  TH1D* background = new TH1D("background","The expected background",30,-4,4);
  TH1D* signal     = new TH1D("signal","the expected signal",30,-4,4);
  TH1D* data       = new TH1D("data","some fake data points",30,-4,4);
  background->SetFillColor(48);
  signal->SetFillColor(41);
  data->SetMarkerStyle(21);
  data->SetMarkerColor(kBlue);
  background->Sumw2(); // needed for stat uncertainty
  signal->Sumw2(); // needed for stat uncertainty
  
// Fill histograms randomly
  TRandom2 r;
  Float_t bg,sig,dt;
  for (Int_t i = 0; i < 25000; i++) {
     bg  = r.Gaus(0,1);
     sig = r.Gaus(1,.2);
     background->Fill(bg,0.02);
     signal->Fill(sig,0.001);
  }
  for (Int_t i = 0; i < 500; i++) {
     dt = r.Gaus(0,1);
     data->Fill(dt);
  }
  THStack *hs = new THStack("hs","Signal and background compared to data...");
  hs->Add(background);
  hs->Add(signal);
  hs->Draw("hist");
  data->Draw("PE1,Same");
  c1->Modified();
  c1->Update();
  c1->GetFrame()->SetFillColor(21);
  c1->GetFrame()->SetBorderSize(6);
  c1->GetFrame()->SetBorderMode(-1);
  c1->Modified();
  c1->Update();
  gSystem->ProcessEvents();

// Compute the limits
  cout << "Computing limits... " << endl;
  TLimitDataSource* mydatasource = new TLimitDataSource(signal,background,data);
  TConfidenceLevel *myconfidence = TLimit::ComputeLimit(mydatasource,50000);
  cout << "CLs    : "   << myconfidence->CLs()  << endl;
  cout << "CLsb   : "   << myconfidence->CLsb() << endl;
  cout << "CLb    : "   << myconfidence->CLb()  << endl;
  cout << "< CLs >  : " << myconfidence->GetExpectedCLs_b()  << endl;
  cout << "< CLsb > : " << myconfidence->GetExpectedCLsb_b() << endl;
  cout << "< CLb >  : " << myconfidence->GetExpectedCLb_b()  << endl;

// Add stat uncertainty
  cout << endl << "Computing limits with stat systematics... " << endl;
  TConfidenceLevel *mystatconfidence = TLimit::ComputeLimit(mydatasource,50000,true);
  cout << "CLs    : "   << mystatconfidence->CLs()  << endl;
  cout << "CLsb   : "   << mystatconfidence->CLsb() << endl;
  cout << "CLb    : "   << mystatconfidence->CLb()  << endl;
  cout << "< CLs >  : " << mystatconfidence->GetExpectedCLs_b()  << endl;
  cout << "< CLsb > : " << mystatconfidence->GetExpectedCLsb_b() << endl;
  cout << "< CLb >  : " << mystatconfidence->GetExpectedCLb_b()  << endl;

// Add some systematics
  cout << endl << "Computing limits with systematics... " << endl;
  TVectorD errorb(2);
  TVectorD errors(2);
  TObjArray* names = new TObjArray();
  TObjString name1("bg uncertainty");
  TObjString name2("sig uncertainty");
  names->AddLast(&name1);
  names->AddLast(&name2);
  errorb[0]=0.05; // error source 1: 5%
  errorb[1]=0;    // error source 2: 0%
  errors[0]=0;    // error source 1: 0%
  errors[1]=0.01; // error source 2: 1%
  TLimitDataSource* mynewdatasource  = new TLimitDataSource();
  mynewdatasource->AddChannel(signal,background,data,&errors,&errorb,names);
  TConfidenceLevel *mynewconfidence = TLimit::ComputeLimit(mynewdatasource,50000,true);
  cout << "CLs    : " << mynewconfidence->CLs()  << endl;
  cout << "CLsb   : " << mynewconfidence->CLsb() << endl;
  cout << "CLb    : " << mynewconfidence->CLb()  << endl;
  cout << "< CLs >  : " << mynewconfidence->GetExpectedCLs_b()  << endl;
  cout << "< CLsb > : " << mynewconfidence->GetExpectedCLsb_b() << endl;
  cout << "< CLb >  : " << mynewconfidence->GetExpectedCLb_b()  << endl;

// show canonical -2lnQ plots in a new canvas
// - The histogram of -2lnQ for background hypothesis (full)
// - The histogram of -2lnQ for signal and background hypothesis (dashed)
  TCanvas *c2 = new TCanvas("c2");
  myconfidence->Draw();
  
// clean up (except histograms and canvas)
  delete myconfidence;
  delete mydatasource;
  delete mystatconfidence;
  delete mynewconfidence;
  delete mynewdatasource;
}
Example #11
0
void MakeADRecoParamEntry(AliRecoParam::EventSpecie_t defaultEventSpecie=AliRecoParam::kLowMult, const char *outputCDB = "local://$ALICE_ROOT/OCDB") {
//========================================================================
//
// Steering macro for AD reconstruction parameters
//
// Author: Michal Broz
//
//========================================================================

  const char* macroname = "MakeADRecoParam.C";

  // Activate CDB storage and load geometry from CDB
  AliCDBManager* cdb = AliCDBManager::Instance();
  cdb->SetDefaultStorage(outputCDB);
  cdb->SetRun(0);
  
  TObjArray *recoParamArray = new TObjArray();

  {
    AliADRecoParam * ADRecoParam = new AliADRecoParam;
    ADRecoParam->SetEventSpecie(AliRecoParam::kCosmic);
    ADRecoParam->SetStartClock(0);
    ADRecoParam->SetEndClock(20);
    ADRecoParam->SetNPreClocks(1);
    ADRecoParam->SetNPostClocks(10);
    ADRecoParam->SetTimeWindowBBALow(-2.5);
    ADRecoParam->SetTimeWindowBBAUp(2.5);
    ADRecoParam->SetTimeWindowBGALow(-4.0);
    ADRecoParam->SetTimeWindowBGAUp(4.0);
    ADRecoParam->SetTimeWindowBBCLow(-1.5);
    ADRecoParam->SetTimeWindowBBCUp(1.5);
    ADRecoParam->SetTimeWindowBGCLow(-2.0);
    ADRecoParam->SetTimeWindowBGCUp(2.0);
    ADRecoParam->SetAdcThresHold(5);
    ADRecoParam->SetMaxResid(1.5);
    ADRecoParam->SetResidRise(0.02);
    recoParamArray->AddLast(ADRecoParam);
  }
  {
    AliADRecoParam * ADRecoParam = new AliADRecoParam;
    ADRecoParam->SetStartClock(0);
    ADRecoParam->SetEndClock(20);
    ADRecoParam->SetNPreClocks(1);
    ADRecoParam->SetNPostClocks(10);
    ADRecoParam->SetTimeWindowBBALow(-2.5);
    ADRecoParam->SetTimeWindowBBAUp(2.5);
    ADRecoParam->SetTimeWindowBGALow(-4.0);
    ADRecoParam->SetTimeWindowBGAUp(4.0);
    ADRecoParam->SetTimeWindowBBCLow(-1.5);
    ADRecoParam->SetTimeWindowBBCUp(1.5);
    ADRecoParam->SetTimeWindowBGCLow(-2.0);
    ADRecoParam->SetTimeWindowBGCUp(2.0);
    ADRecoParam->SetAdcThresHold(5);
    ADRecoParam->SetMaxResid(1.5);
    ADRecoParam->SetResidRise(0.02);
    ADRecoParam->SetEventSpecie(AliRecoParam::kLowMult);
    recoParamArray->AddLast(ADRecoParam);
  }
  {
    AliADRecoParam * ADRecoParam = new AliADRecoParam;
    ADRecoParam->SetStartClock(9);
    ADRecoParam->SetEndClock(11);
    ADRecoParam->SetNPostClocks(6);
    ADRecoParam->SetTimeWindowBBALow(-2.5);
    ADRecoParam->SetTimeWindowBBAUp(2.5);
    ADRecoParam->SetTimeWindowBGALow(-4.0);
    ADRecoParam->SetTimeWindowBGAUp(4.0);
    ADRecoParam->SetTimeWindowBBCLow(-1.5);
    ADRecoParam->SetTimeWindowBBCUp(1.5);
    ADRecoParam->SetTimeWindowBGCLow(-2.0);
    ADRecoParam->SetTimeWindowBGCUp(2.0);
    ADRecoParam->SetAdcThresHold(5);
    ADRecoParam->SetMaxResid(1.5);
    ADRecoParam->SetResidRise(0.02);
    ADRecoParam->SetEventSpecie(AliRecoParam::kHighMult);
    recoParamArray->AddLast(ADRecoParam);
  }

  // Set the defaultEventSpecie
  Bool_t defaultIsSet = kFALSE;
  for(Int_t i =0; i < recoParamArray->GetEntriesFast(); i++) {
    AliDetectorRecoParam *param = (AliDetectorRecoParam *)recoParamArray->UncheckedAt(i);
    if (!param) continue;
    if (defaultEventSpecie & param->GetEventSpecie()) {
      param->SetAsDefault();
      defaultIsSet = kTRUE;
    }
  }

  if (!defaultIsSet) {
    Error(macroname,"The default reconstruction parameters are not set! Exiting...");
    return;
  }

  // save in CDB storage
  AliCDBMetaData *md= new AliCDBMetaData();
  md->SetResponsible("Michal Broz");
  md->SetComment("Reconstruction parameters for AD");
  md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
  md->SetBeamPeriod(0);
  AliCDBId id("AD/Calib/RecoParam", 0, AliCDBRunRange::Infinity());
  cdb->Put(recoParamArray, id, md);

  return;
}
Example #12
0
Bool_t AliCFSingleTrackTask(
			    const Bool_t useGrid = 1,
			    const Bool_t readAOD = 0,
			    const Bool_t readTPCTracks = 0,
			    const char * kTagXMLFile="wn.xml" // XML file containing tags
			    )
{
  
  TBenchmark benchmark;
  benchmark.Start("AliSingleTrackTask");

  AliLog::SetGlobalDebugLevel(0);

  Load() ; //load the required libraries

  TChain * analysisChain ;

  if (useGrid) { //data located on AliEn
    TGrid::Connect("alien://") ;    //  Create an AliRunTagCuts and an AliEventTagCuts Object 
                                    //  and impose some selection criteria
    AliRunTagCuts      *runCuts   = new AliRunTagCuts(); 
    AliEventTagCuts    *eventCuts = new AliEventTagCuts(); 
    AliLHCTagCuts      *lhcCuts   = new AliLHCTagCuts(); 
    AliDetectorTagCuts *detCuts   = new AliDetectorTagCuts(); 
    eventCuts->SetMultiplicityRange(0,2000);

    //  Create an AliTagAnalysis Object and chain the tags
    AliTagAnalysis   *tagAna = new AliTagAnalysis(); 
    if (readAOD) tagAna->SetType("AOD");  //for aliroot > v4-05
    else         tagAna->SetType("ESD");  //for aliroot > v4-05
    TAlienCollection *coll   = TAlienCollection::Open(kTagXMLFile); 
    TGridResult      *tagResult = coll->GetGridResult("",0,0);
    tagResult->Print();
    tagAna->ChainGridTags(tagResult);

    //  Create a new esd chain and assign the chain that is returned by querying the tags
    analysisChain = tagAna->QueryTags(runCuts,lhcCuts,detCuts,eventCuts); 
  }

  else {// local data
    //here put your input data path
    printf("\n\nRunning on local file, please check the path\n\n");

    if (readAOD) {
      analysisChain = new TChain("aodTree");
      analysisChain->Add("your_data_path/001/AliAOD.root");
      analysisChain->Add("your_data_path/002/AliAOD.root");
    }
    else {
      analysisChain = new TChain("esdTree");
      analysisChain->Add("your_data_path/001/AliESDs.root");
      analysisChain->Add("your_data_path/002/AliESDs.root");
    }
  }
  

  Info("AliCFSingleTrackTask",Form("CHAIN HAS %d ENTRIES",(Int_t)analysisChain->GetEntries()));

  //CONTAINER DEFINITION
  Info("AliCFSingleTrackTask","SETUP CONTAINER");
  //the sensitive variables (2 in this example), their indices
  UInt_t ipt = 0;
  UInt_t iy  = 1;
  //Setting up the container grid... 
  UInt_t nstep = 4 ; //number of selection steps MC 
  const Int_t nvar   = 2 ; //number of variables on the grid:pt,y
  const Int_t nbin1  = 8 ; //bins in pt
  const Int_t nbin2  = 8 ; //bins in y 

  //arrays for the number of bins in each dimension
  Int_t iBin[nvar];
  iBin[0]=nbin1;
  iBin[1]=nbin2;

  //arrays for lower bounds :
  Double_t *binLim1=new Double_t[nbin1+1];
  Double_t *binLim2=new Double_t[nbin2+1];

  //values for bin lower bounds
  for(Int_t i=0; i<=nbin1; i++) binLim1[i]=(Double_t)ptmin + (ptmax-ptmin)/nbin1*(Double_t)i ; 
  for(Int_t i=0; i<=nbin2; i++) binLim2[i]=(Double_t)ymin  + (ymax-ymin)  /nbin2*(Double_t)i ;
  //one "container" for MC
  AliCFContainer* container = new AliCFContainer("container","container for tracks",nstep,nvar,iBin);
  //setting the bin limits
  container -> SetBinLimits(ipt,binLim1);
  container -> SetBinLimits(iy,binLim2);
  container -> SetVarTitle(ipt,"pt");
  container -> SetVarTitle(iy, "y");
  container -> SetStepTitle(0, "generated");
  container -> SetStepTitle(1, "in acceptance");
  container -> SetStepTitle(2, "reconstructed");
  container -> SetStepTitle(3, "after PID");

  // SET TLIST FOR QA HISTOS
  TList* qaList = new TList();

  //CREATE THE  CUTS -----------------------------------------------

  //Event-level cuts:
  AliCFEventRecCuts* evtRecCuts = new AliCFEventRecCuts("evtRecCuts","Rec-event cuts");
//   evtRecCuts->SetUseTPCVertex();
//   evtRecCuts->SetRequireVtxCuts(kTRUE);
//   evtRecCuts->SetVertexNContributors(-2,5);
  evtRecCuts->SetQAOn(qaList);

  // Gen-Level kinematic cuts
  AliCFTrackKineCuts *mcKineCuts = new AliCFTrackKineCuts("mcKineCuts","MC-level kinematic cuts");
  mcKineCuts->SetPtRange(ptmin,ptmax);
  mcKineCuts->SetRapidityRange(ymin,ymax);
  mcKineCuts->SetChargeMC(charge);
  mcKineCuts->SetQAOn(qaList);

  //Particle-Level cuts:  
  AliCFParticleGenCuts* mcGenCuts = new AliCFParticleGenCuts("mcGenCuts","MC particle generation cuts");
  mcGenCuts->SetRequireIsPrimary();
  mcGenCuts->SetRequirePdgCode(PDG,/*absolute=*/kTRUE);
  mcGenCuts->SetQAOn(qaList);

  //Acceptance Cuts
  AliCFAcceptanceCuts *mcAccCuts = new AliCFAcceptanceCuts("mcAccCuts","MC acceptance cuts");
  mcAccCuts->SetMinNHitITS(mintrackrefsITS);
  mcAccCuts->SetMinNHitTPC(mintrackrefsTPC);
  mcAccCuts->SetQAOn(qaList);

  // Rec-Level kinematic cuts
  AliCFTrackKineCuts *recKineCuts = new AliCFTrackKineCuts("recKineCuts","rec-level kine cuts");
  recKineCuts->SetPtRange(ptmin,ptmax);
  recKineCuts->SetRapidityRange(ymin,ymax);
  recKineCuts->SetChargeRec(charge);
  recKineCuts->SetQAOn(qaList);

  AliCFTrackQualityCuts *recQualityCuts = new AliCFTrackQualityCuts("recQualityCuts","rec-level quality cuts");
  if (!readAOD)       {
//     recQualityCuts->SetMinNClusterTRD(0);
//     recQualityCuts->SetMaxChi2PerClusterTRD(10.);
  }
  recQualityCuts->SetStatus(AliESDtrack::kTPCrefit);
  recQualityCuts->SetQAOn(qaList);

  AliCFTrackIsPrimaryCuts *recIsPrimaryCuts = new AliCFTrackIsPrimaryCuts("recIsPrimaryCuts","rec-level isPrimary cuts");
  if (readAOD) recIsPrimaryCuts->SetAODType(AliAODTrack::kPrimary);
  else         recIsPrimaryCuts->SetMaxNSigmaToVertex(3);
  recIsPrimaryCuts->SetQAOn(qaList);

  AliCFTrackCutPid* cutPID = new AliCFTrackCutPid("cutPID","ESD_PID") ;
  int n_species = AliPID::kSPECIES ;
  Double_t* prior = new Double_t[n_species];
  
  prior[0] = 0.0244519 ;
  prior[1] = 0.0143988 ;
  prior[2] = 0.805747  ;
  prior[3] = 0.0928785 ;
  prior[4] = 0.0625243 ;
  
  cutPID->SetPriors(prior);
  cutPID->SetProbabilityCut(0.0);
  if (readTPCTracks) cutPID->SetDetectors("TPC");
  else               cutPID->SetDetectors("ALL");
  if (readAOD) cutPID->SetAODmode(kTRUE );
  else         cutPID->SetAODmode(kFALSE);
  switch(TMath::Abs(PDG)) {
  case 11   : cutPID->SetParticleType(AliPID::kElectron, kTRUE); break;
  case 13   : cutPID->SetParticleType(AliPID::kMuon    , kTRUE); break;
  case 211  : cutPID->SetParticleType(AliPID::kPion    , kTRUE); break;
  case 321  : cutPID->SetParticleType(AliPID::kKaon    , kTRUE); break;
  case 2212 : cutPID->SetParticleType(AliPID::kProton  , kTRUE); break;
  default   : printf("UNDEFINED PID\n"); break;
  }
  cutPID->SetQAOn(qaList);

  printf("CREATE EVENT LEVEL CUTS\n");
  TObjArray* evtList = new TObjArray(0) ;
//   evtList->AddLast(evtRecCuts);
  
  printf("CREATE MC KINE CUTS\n");
  TObjArray* mcList = new TObjArray(0) ;
  mcList->AddLast(mcKineCuts);
  mcList->AddLast(mcGenCuts);

  printf("CREATE ACCEPTANCE CUTS\n");
  TObjArray* accList = new TObjArray(0) ;
  accList->AddLast(mcAccCuts);

  printf("CREATE RECONSTRUCTION CUTS\n");
  TObjArray* recList = new TObjArray(0) ;
  recList->AddLast(recKineCuts);
  recList->AddLast(recQualityCuts);
  recList->AddLast(recIsPrimaryCuts);

  printf("CREATE PID CUTS\n");
  TObjArray* fPIDCutList = new TObjArray(0) ;
  fPIDCutList->AddLast(cutPID);

  //CREATE THE INTERFACE TO CORRECTION FRAMEWORK USED IN THE TASK
  printf("CREATE INTERFACE AND CUTS\n");
  AliCFManager* man = new AliCFManager() ;

  man->SetNStepEvent(1);
  man->SetEventCutsList(0,evtList);

  man->SetParticleContainer(container);
  man->SetParticleCutsList(0,mcList);
  man->SetParticleCutsList(1,accList);
  man->SetParticleCutsList(2,recList);
  man->SetParticleCutsList(3,fPIDCutList);


  //CREATE THE TASK
  printf("CREATE TASK\n");
  // create the task
  AliCFSingleTrackTask *task = new AliCFSingleTrackTask("AliSingleTrackTask");
  task->SetCFManager(man); //here is set the CF manager
  task->SetQAList(qaList);
  if (readAOD)       task->SetReadAODData() ;
  if (readTPCTracks) task->SetReadTPCTracks();

  //SETUP THE ANALYSIS MANAGER TO READ INPUT CHAIN AND WRITE DESIRED OUTPUTS
  printf("CREATE ANALYSIS MANAGER\n");
  // Make the analysis manager
  AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");

  if (useGrid) mgr->SetAnalysisType(AliAnalysisManager::kGridAnalysis);
  else mgr->SetAnalysisType(AliAnalysisManager::kLocalAnalysis);


  AliMCEventHandler*  mcHandler = new AliMCEventHandler();
  mgr->SetMCtruthEventHandler(mcHandler);
 
  AliInputEventHandler* dataHandler ;
  
  if   (readAOD) dataHandler = new AliAODInputHandler();
  else           dataHandler = new AliESDInputHandler();
  mgr->SetInputEventHandler(dataHandler);

  // Create and connect containers for input/output

  //------ input data ------
  AliAnalysisDataContainer *cinput0  = mgr->CreateContainer("cchain0",TChain::Class(),AliAnalysisManager::kInputContainer);

  // ----- output data -----
  
  //slot 0 : default output tree (by default handled by AliAnalysisTaskSE)
  AliAnalysisDataContainer *coutput0 = mgr->CreateContainer("ctree0", TTree::Class(),AliAnalysisManager::kOutputContainer,"output.root");

  //now comes user's output objects :
  
  // output TH1I for event counting
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("chist0", TH1I::Class(),AliAnalysisManager::kOutputContainer,"output.root");
  // output Correction Framework Container (for acceptance & efficiency calculations)
  AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("ccontainer0", AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,"output.root");
  // output QA histograms 
  AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("clist0", TList::Class(),AliAnalysisManager::kOutputContainer,"output.root");

  cinput0->SetData(analysisChain);

  mgr->AddTask(task);
  mgr->ConnectInput(task,0,mgr->GetCommonInputContainer());
  mgr->ConnectOutput(task,0,coutput0);
  mgr->ConnectOutput(task,1,coutput1);
  mgr->ConnectOutput(task,2,coutput2);
  mgr->ConnectOutput(task,3,coutput3);
 
  printf("READY TO RUN\n");
  //RUN !!!
  if (mgr->InitAnalysis()) {
    mgr->PrintStatus();
    mgr->StartAnalysis("local",analysisChain);
  }

  benchmark.Stop("AliSingleTrackTask");
  benchmark.Show("AliSingleTrackTask");

  return kTRUE ;
}
Example #13
0
void bfcread_tagsBranch( 
  const char *MainFile="/afs/rhic.bnl.gov/star/data/samples/gstar.tags.root",
  Int_t printEvent=1,
  const char *fname="qa_tags.out",
  Int_t fullPrint=0) 
{
  // start timer
  TStopwatch timer;
  timer.Start();

  cout << endl << endl;
  cout << " bfcread_tagsBranch.C: input file  = " << MainFile << endl;
  cout << " bfcread_tagsBranch.C: print event # " << printEvent << endl;
  cout << " bfcread_tagsBranch.C: output file = " << fname << endl;
  cout << " bfcread_tagsBranch.C: full printout = " << fullPrint << endl;
  cout << endl;

  ofstream fout(fname);

  fout << endl << endl;
  fout << " bfcread_tagsBranch.C: input file  = " << MainFile << endl;
  fout << " bfcread_tagsBranch.C: print evt#  = " << printEvent << endl;
  fout << " bfcread_tagsBranch.C: output file = " << fname << endl;
  fout << " bfcread_tagsBranch.C: full printout = " << fullPrint << endl;
  fout << endl;

  TFile *file = TFile::Open(MainFile);
  TTree *tree = (TTree*)file->Get("Tag");

  cout <<" read file: " << file->GetName() << endl << endl;

  Int_t nEntries = tree->GetEntries();
  cout << " Total # events  = " << nEntries << endl;

  TObjArray *leaves = tree->GetListOfLeaves();
  Int_t nLeaves = leaves->GetEntriesFast();

  cout << "  Total # leaves  = " << nLeaves << endl;

  TString *tName = new TString(" ");
  TNamed *tableName=0;
  TObjArray *tagTable = new TObjArray;
  Int_t tableCount = 0;
  Int_t *tableIndex = new Int_t[nLeaves];
  Int_t tagCount = 0;

  TBranch *branch=0;
  TLeaf *leaf=0;
  Int_t ndim =0;

//count number of tag tables encoded in the TTree branch names
  for (Int_t l=0;l<nLeaves;l++) {
    leaf = (TLeaf*)leaves->UncheckedAt(l);
    tagCount+=leaf->GetNdata();
    branch = leaf->GetBranch();
      cout << "leaf #  " << l << "  br name = " <<  
                                     branch->GetName() << endl;
    //new tag table name
    if ( strstr(branch->GetName(), tName->Data()) == 0 ) {
      tName = new TString(branch->GetName());
      tName->Resize(tName->Index("."));
      //the tableName is encoded in the branch Name before the "."
      tableName = new TNamed(tName->Data(),"Tag");
      tagTable->AddLast(tableName);
      tableCount++;
    }
    tableIndex[l]=tableCount-1;
  }

  cout << endl << "  Total num tables(branches),tags = " 
              << tableCount << "   " << tagCount << endl << endl;

  Int_t *countTagsTable = new Int_t[tableCount];
  Int_t *countLeavesTable = new Int_t[tableCount];
  Float_t *sumTagsLeaf = new Float_t[nLeaves];
  Int_t *countTagsLeaf = new Int_t[nLeaves];

// Now loop over leaves (to get values of tags)

   Int_t setBranch = -1;
   Int_t nowBranch = -1;

   for (Int_t l=0;l<nLeaves;l++) {

      leaf = (TLeaf*)leaves->UncheckedAt(l);
      branch = leaf->GetBranch();
      ndim = leaf->GetNdata();

      nowBranch = tableIndex[l];

      //cout << " nowbranch, setBranch = " << 
      //  nowBranch << ", "<< setBranch << endl;

      Float_t RtableIndex=tableIndex[l];

      if (nowBranch !=  setBranch){ 
          setBranch=nowBranch;
          cout << " QAInfo: branch ";
            cout.width(2);
            cout << tableIndex[l] << " = ";
            cout.width(10);
            cout << ((TNamed*)tagTable->UncheckedAt(tableIndex[l]))->GetName();
            cout << endl;
          fout << " QAInfo: branch ";
            fout.width(2);
            fout << RtableIndex << " = ";
            fout.width(10);
            fout << ((TNamed*)tagTable->UncheckedAt(tableIndex[l]))->GetName();
            fout << endl;
      }

      countTagsTable[tableIndex[l]]+=leaf->GetNdata();
      countLeavesTable[tableIndex[l]]++;
      countTagsLeaf[l]+=ndim;

      Float_t Rl=l;
      Float_t Rndim=ndim;
      cout << " QAInfo:     leaf ";
        cout.width(3);
        cout << l << " has ";
        cout.width(1);
        cout << ndim << " tags:";
        cout << endl;
      fout << " QAInfo:     leaf ";
        fout.width(3);
        fout << Rl << " has ";
        fout.width(1);
        fout << Rndim << " tags:";
        fout << endl;

//  loop over all events in each leaf

      for (Int_t nev=0; nev<nEntries; nev++) {
	branch->GetEntry(nev);

//  loop over all tags in each leaf for each event

	for (Int_t itag=0;itag<ndim;itag++) {

          Int_t ik = nev+1;
	  if (ik==printEvent) {

	     cout << " QAInfo:         " << leaf->GetName();
	     if (ndim>1) cout << '['<<itag<<']';
             cout << " = " << leaf->GetValue(itag) << endl; 	

	     fout << " QAInfo:         " << leaf->GetName();
	     if (ndim>1) fout << '['<<itag<<']';
             fout << " = " << leaf->GetValue(itag) << endl; 	  
	  }

          sumTagsLeaf[l]+=leaf->GetValue(itag);

	} 	
      }
    }
    cout << endl  << endl;
    fout << endl  << endl;


    if (fullPrint == 1){
// loop over leaves again for printout at end
     for (Int_t m=0; m<nLeaves; m++){

       leaf = (TLeaf*)leaves->UncheckedAt(m);
       branch = leaf->GetBranch();
       ndim = leaf->GetNdata();

      cout << " QAInfo: branch ";
        cout.width(2);
        cout << tableIndex[m] << " = ";
        cout.width(10);
        cout << ((TNamed*)tagTable->UncheckedAt(tableIndex[m]))->GetName();
        cout << ", leaf ";
        cout.width(3);
        cout << m << " = ";
        cout.width(24);
        cout << leaf->GetName();
        cout << ", #tags = ";     
        cout.width(1);
        cout << ndim;
        cout << endl;

	Float_t RtableIndex=tableIndex[m];
        Float_t Rm=m;
        Float_t Rndim=ndim;
      fout << " QAInfo: branch ";
        fout.width(2);
        fout << RtableIndex << " = ";
        fout.width(10);
        fout << ((TNamed*)tagTable->UncheckedAt(tableIndex[m]))->GetName();
        fout << ", leaf ";
        fout.width(3);
        fout << Rm << " = ";
        fout.width(24);
        fout << leaf->GetName();
        fout << ", #tags = ";     
        fout.width(1);
        fout << Rndim;
        fout << endl;

     }
    }
     cout << endl  << endl;
     fout << endl  << endl;



// loop over leaves again for printout at end of averages
     cout << " QAInfo: each leaf's avg over all tags,evts: " << endl;
     fout << " QAInfo: each leaf's avg over all tags,evts: " << endl;

     for (Int_t m=0; m<nLeaves; m++){

      leaf = (TLeaf*)leaves->UncheckedAt(m);

      sumTagsLeaf[m]/=countTagsLeaf[m]*nEntries;

      cout << " QAInfo: avg leaf #";
        cout.width(2);
        cout << m << ", ";
        cout.width(23);
        cout << leaf->GetName() << " = ";
        cout.width(12);
        cout << sumTagsLeaf[m];
        cout << endl;

	Float_t Rm=m;
      fout << " QAInfo: avg leaf #";
        fout.width(2);
        fout << Rm << ", ";
        fout.width(23);
        fout << leaf->GetName() << " = ";
        fout.width(12);
        fout << sumTagsLeaf[m];
        fout << endl;

     }
     cout << endl  << endl;
     fout << endl  << endl;



// loop over all tables
     for (Int_t m=0; m<tableCount; m++){

        cout << " QAInfo: branch(table) ";
	  cout.width(10);
	  cout << ((TNamed*)tagTable->UncheckedAt(m))->GetName() << " has ";
	  cout.width(4);
	  cout << countLeavesTable[m] << " leaves,";
	  cout.width(4);
	  cout << countTagsTable[m] << " tags" << endl;

	  Float_t RcountLeavesTable=countLeavesTable[m];
          Float_t RcountTagsTable=countTagsTable[m];
        fout << " QAInfo: branch(table) ";
	  fout.width(10);
	  fout << ((TNamed*)tagTable->UncheckedAt(m))->GetName() << " has ";
	  fout.width(4);
	  fout << RcountLeavesTable << " leaves,";
	  fout.width(4);
	  fout << RcountTagsTable << " tags" << endl;

     }
     cout << endl  << endl;
     fout << endl  << endl;


     Float_t RnEntries=nEntries;
     Float_t RtableCount=tableCount; 
     Float_t RnLeaves=nLeaves; 
     Float_t RtagCount=tagCount; 

     cout << " QAInfo:  tot num events = " << nEntries << endl;
     fout << " QAInfo:  tot num events = " << RnEntries << endl;

     cout << " QAInfo:   tot num branches = " << tableCount << endl;
     fout << " QAInfo:   tot num branches = " << RtableCount << endl;

     cout << " QAInfo:   tot num leaves = " << nLeaves << endl;
     fout << " QAInfo:   tot num leaves = " << RnLeaves << endl;

     cout << " QAInfo:   tot num tags = " << tagCount << endl;
     fout << " QAInfo:   tot num tags = " << RtagCount << endl;


  // stop timer and print results
  timer.Stop();
  cout<< endl << endl <<"RealTime="<<timer.RealTime()<<
       " seconds, CpuTime="<<timer.CpuTime()<<" seconds"<<endl;

  //cleanup
  file->Close();
  fout.close();
}