Example #1
0
Bool_t
RecoParamWithTPCDistortions(AliCDBManager *man) {

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

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

  return kTRUE;
  
}
void Output::fixLeafOffsets( TBranch * b)
{
  // recalculates the addresses for all the leaves.
  // 
  // when constructing a branch with containing a variable length array with the index
  // variable in the same branch it is not possible to specify the span of the index variable
  // This span defaults to zero. When the addresses are asigned to the various leaves in the branch
  // it calculates the size of the particular leaf (variable length array) in the buffer by looking 
  // at the span of the index variable - 0 in this case! using the method TLeaf::GetLen(). 
  // The following code shoudl be applied to the branch after the spans of the index variables have been
  // specified manually using the TLeaf::SetMaximum method. This time the GetLen method calculates the correct offset.

  TObjArray * leaves = b->GetListOfLeaves();
  char * addr = b->GetAddress();
  int offset = 0;
  int nleaves = leaves->GetEntriesFast();
  
  // loop over the leaves:
  for( int i =0; i < nleaves; ++i) {
    TLeaf * leaf = (TLeaf *)leaves->UncheckedAt(i);
    leaf->SetAddress( addr + offset );
    int oldOffset = leaf->GetOffset();
    leaf->SetOffset( offset );
    //std::cout << " offset changed from : " << oldOffset << " to " << offset << std::endl;
    TLeaf * index = leaf->GetLeafCount();
    int nelements = 1;
    if( index ) {
      nelements = index->GetMaximum(); // deal with variable length arrays
    } else {
      nelements = leaf->GetLenStatic(); // deal with single variables and fixed length arrays
    }
    offset += leaf->GetLenType() * nelements;
  }
}
Example #3
0
void ResetDeleteBranches(TTree* tree) {
    TObjArray* branches = tree->GetListOfBranches();
    Int_t nb = branches->GetEntriesFast();
    for (Int_t i = 0; i < nb; ++i) {
        TBranch* br = (TBranch*) branches->UncheckedAt(i);
        if (br->InheritsFrom(TBranchElement::Class())) {
            ((TBranchElement*) br)->ResetDeleteObject();
        }
    }
}
Example #4
0
void D3PDSelector::loadBranch(std::string key )
{
   //std::cout << "Getting List Of Leaves" << std::endl;
   TObjArray* leaves = fChain->GetListOfLeaves();
   //std::cout << "Got List Of Leaves" << std::endl;
   //std::cout << "key " << key << std::endl;
   
   for (int c=0; c<leaves->GetSize(); c++)
   {
      TLeaf* leaf = (TLeaf*)leaves->UncheckedAt(c);
      TLeafObject* leafobj = (TLeafObject*)leaf;

      const char* curbraname = leafobj->GetName();

      //std::cout << "Got Leave " <<  curbraname << std::endl;

      if (strcmp(curbraname, key.c_str()) == 0)
      {
        const char* curtitle = leafobj->GetTypeName();
        std::string classtype(leafobj->ClassName());
        m_types[key] = std::string(curtitle);

        void* address;
 
        //if (m_types[key].find("<") == std::string::npos) //vector type? //old check
        //TLeafElement means it's a pointer to an obect
        //Else its a more primitve type (int, float etc)
        if (classtype.find("TLeafElement") == std::string::npos)
        {
          void* tmpfl = (void* )(new double(0.)); //make sure enough space, so make doube
          address = tmpfl;
        }
        else
        {
          void** tmp = new void*; //works   1
          *tmp = 0;      
          address=tmp;
        }
      
        m_data[key] = (void**)address;
        TBranch* cur_branch = 0;
        m_branches[key] = cur_branch;
        fChain->SetBranchAddress(key.c_str(), m_data[key] , &m_branches[key] );
        //m_branches[key]->GetEntry(m_curentry); //Entry is loaded in loadData method

        return;
      }
   }
   //std::cout << "Got All List Of Leaves" << std::endl;
   //std::cout << "key " << key << std::endl;
   std::cout << "WARNING: Requested variable " << key << " not found. The program might crash now." << std::endl;

}
Example #5
0
void D3PDSelector::Init(TTree *tree)
{

   // The Init() function is called when the selector needs to initialize
   // a new tree or chain. Typically here the branch addresses and branch
   // pointers of the tree will be set.
   // It is normally not necessary to make changes to the generated
   // code, but the routine can be extended by the user if needed.
   // Init() will be called many times when running on PROOF
   // (once per file to be processed).

   // Set object pointer
  // Set branch addresses and branch pointers


  std::cout << "INIT" << std::endl;

  SetElectronContainerPrefix("el");
  SetMuonContainerPrefix("mu_staco");
  SetJetContainerPrefix("jet_AntiKt4TopoNewEM");
//  SetJetContainerPrefix("jet_AntiKt4TopoEM");
  //SetPhotonContainerPrefix("ph");

  //Reset intenral data structure to Branch Addresses  
  m_data.clear();
  m_branches.clear();
  m_types.clear();

  if (!tree) return;
  fChain = tree;
  fChain->SetMakeClass(1);
  
  TObjArray* leaves =  tree->GetListOfLeaves();

  for (int c=0; c<leaves->GetSize(); c++)
  {
    TLeaf* leaf = (TLeaf*)leaves->UncheckedAt(c);
    TLeafObject* leafobj = (TLeafObject*)leaf;
  
  
    //TLeafObject* curbra = (TLeafObject*)tor->At(c);
    const char* curbraname = leafobj->GetName();
    const char* curtitle = leafobj->GetTypeName();
    //const char* classn = leafobj->ClassName();
  
    if (m_verbose) 
      std::cout << curbraname << "    " << /*curbraclassName <<"    " << */curtitle << std::endl;
  }

}
////////////////////////////////////////////////////////////
// names -- get the names of the branches and their details
SEXP RootChainManager::names() const {
	
  // Advance to the first entry
  //m_chain->GetEntry(0);
  // Above commented out 20090616 - for TMBTrees this crashed root 
	// on an unresolved symbol for allocator<char>. 
	
  // Get the branches
  TObjArray* branches = m_chain->GetListOfBranches();
	
  // How many?
  unsigned int nBranches = branches->GetEntriesFast();
	
  // Make the R list for returning the list of branch and detail names
  SEXP rBranchList, rBranchListNames;
  PROTECT(rBranchList = NEW_LIST(nBranches));
  PROTECT(rBranchListNames = NEW_CHARACTER(nBranches));
	
  // Loop over the branches in the tree
  for ( unsigned int branchIter = 0; branchIter < nBranches; ++branchIter ) {
		
    // Get the branch
    TBranch* branch = (TBranch*) branches->UncheckedAt(branchIter);
		
    // Save away the name of this branch for use as an attribute
    SET_STRING_ELT(rBranchListNames, branchIter, mkChar(branch->GetName()));
		
    SEXP details = NEW_CHARACTER(1);
    SET_ELEMENT(rBranchList, branchIter, details);
    
    SET_STRING_ELT(details, 0, mkChar( branch->GetTitle() ) );

  } // for over branches
	
  // Set the names attribute
  SET_NAMES(rBranchList, rBranchListNames);
	
  // Release rBranchList and rBranchListNames
  UNPROTECT(2);
	
  return rBranchList;
}
Example #7
0
void getT0RecoParam(Int_t run)
{
  
  // Read calibration coefficients into the Calibration DB
  // Arguments:
  AliCDBManager* man = AliCDBManager::Instance();
   man->SetDefaultStorage("raw://");
  //  man->SetDefaultStorage("local:///home/alla/alice/Jul14/OCDB/");
  man->SetRun(run);
  AliCDBEntry *entry = AliCDBManager::Instance()->Get("T0/Calib/RecoParam");
  AliT0RecoParam* recoParam = 0x0;
  cout<<" entry "<< entry<<endl;
  if(entry) {
    // load recoParam according OCDB content (single or array)
    //    if (!(recoParam = dynamic_cast<AliT0RecoParam*>(entry->GetObject()))) {
    
    TObjArray* recoParamArray = static_cast<TObjArray*>(entry->GetObject());     
    cout<<" TObjArray* recoParamArray "<<recoParamArray->GetEntriesFast()<<endl;
    for(Int_t ie = 0; ie < recoParamArray->GetEntriesFast()-1; ie++) {
      
      recoParam = static_cast<AliT0RecoParam*>(recoParamArray->UncheckedAt(ie));	
      cout<<ie<<endl;
      cout<<" eq "<<recoParam->GetEq()<<endl;
      //	 recoParam->Dump();
      cout<<" cfd range "<<recoParam->GetLow(300)<<" amplitude "<<recoParam->GetLow(200)<<" "<<recoParam->GetHigh(200)<<endl;
      
      for (int i=0; i<500; i++) 
	if( recoParam->GetLow(i) !=0) cout<<i<<" low "<<recoParam->GetLow(i)<<"   "<<endl;
      for (int i=0; i<500; i++) 
	if( recoParam->GetHigh(i) !=50000)  cout<<i<<" high "<<recoParam->GetHigh(i)<<endl;
      recoParam = 0x0;
    }
  }
  else 
    cout<<" no entry "<<endl;
  
  
}
Example #8
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");  
}
Example #9
0
void clusters()
{
  IlcEveEventManager::AssertGeometry();

  IlcRunLoader *rl        = IlcEveEventManager::AssertRunLoader();
  IlcESDEvent  *esd       = IlcEveEventManager::AssertESD();
  IlcEveEventManager::AssertESDfriend();
  IlcEveEventManager::AssertMagField();

  const char* detNames[] = { "ITS", "TPC", /*"TRD",*/ "TOF", "HMPID" };
  const Int_t detIds[]   = {   0,     1,   /*  2,  */   3,     5   };
  const Int_t detN       = sizeof(detNames)/sizeof(char*);

  // Hack - IlcReconstruction does wonders with gGeoManager.
  TGeoManager* xxx = gGeoManager; gGeoManager = 0;
  IlcReconstruction* reco = new IlcReconstruction;
  gGeoManager = xxx;

  // Hack for ITS - it requires RecoParams outside event-loop!
  reco->SetRecoParam("ITS", IlcITSRecoParam::GetLowFluxParam());

  reco->ImportRunLoader(rl);
  {
    TString alldets;
    for (Int_t i = 0; i < detN; ++i) {
      alldets += detNames[i];
      alldets += " ";
    }
    reco->CreateTrackers(alldets);
  }

  TObjArray* clarr = new TObjArray();

  // Load clusters, fill them into clarr.

  for (Int_t i = 0; i < detN; ++i)
  {
    Int_t det = detIds[i];
    rl->LoadRecPoints(detNames[i]);

    TTree *cTree = rl->GetTreeR(detNames[i], false);
    if (cTree == 0)
      continue;

    IlcTracker* tracker = reco->GetTracker(det);
    if (tracker == 0) continue;
    tracker->LoadClusters(cTree);
    tracker->FillClusterArray(clarr);
  }

  // Loop over tracks and friends, tag used clusters.

  for (Int_t n = 0; n < esd->GetNumberOfTracks(); ++n)
  {
    IlcESDtrack* at = esd->GetTrack(n);

    Int_t idx[200];
    for (Int_t i = 0; i < detN; ++i)
    {
      Int_t det = detIds[i];
      IlcTracker* tracker = reco->GetTracker(det);
      if (tracker == 0) continue;
      Int_t nclusters = at->GetClusters(det, idx);
      Int_t p=0;
      for (Int_t c = 0; c < nclusters; )
      {
        Int_t index = idx[p++];
        if (index < 0) continue;
        c++;
        IlcCluster* cluster = tracker->GetCluster(index);
        if (cluster) cluster->IncreaseClusterUsage();
        //else printf("Zero cluster pointer for detector: %s\n",detNames[i]);
      }
    }
  }

  for (Int_t i = 0; i < detN; ++i)
    rl->UnloadRecPoints(detNames[i]);

  // Fill visualization structs

  TEveElementList* list = new TEveElementList("Clusters");
  gEve->AddElement(list);

  TEvePointSet* shared = new TEvePointSet("Shared Clusters");
  shared->SetMainColor(2);
  shared->SetMarkerSize(0.4);
  shared->SetMarkerStyle(2);
  list->AddElement(shared);

  TEvePointSet* used = new TEvePointSet("Single-used Clusters");
  used->SetMainColor(3);
  used->SetMarkerSize(0.4);
  used->SetMarkerStyle(2);
  list->AddElement(used);

  TEvePointSet* nonused = new TEvePointSet("Not-used Clusters");
  nonused->SetMainColor(4);
  nonused->SetMarkerSize(0.4);
  nonused->SetMarkerStyle(2);
  list->AddElement(nonused);

  // Loop over all clusters, fill appropriate container based
  // on shared/used information.

  Int_t ncl = clarr->GetEntriesFast();
  for (Int_t i = 0; i < ncl; ++i)
  {
    IlcCluster   *cluster = (IlcCluster*) clarr->UncheckedAt(i);
    TEvePointSet *dest    = 0;
    if (cluster->IsClusterShared())
      dest = shared;
    else if (cluster->IsClusterUsed())
      dest = used;
    else
      dest = nonused;

    Float_t g[3]; //global coordinates
    cluster->GetGlobalXYZ(g);
    dest->SetNextPoint(g[0], g[1], g[2]);
    dest->SetPointId(cluster);
  }

  delete clarr;

  // ??? What to do with trackers ???
  // I'd propose: have global reconstruction that owns them.
  // IlcEveEventManager::AssertIlcReconstruction();
  // do we have bit-field for detectors, like
  // enum IlcDetectors_e {
  //    kITS = BIT(0),
  //    kTPC = BIT(1),
  //    ...
  //    kCentralTracking = kITS | kTPC | kTRD | kTOF,
  //    ...
  //  };

  gEve->Redraw3D();
}
Example #10
0
//_________________________________________________________
void UserAnalysis()
{
  // Debug a particular event.
  
  Int_t eventToDebug = -1;
  if (jsf->GetEventNumber() == eventToDebug) {
  	gDEBUG = kTRUE;
        cerr << "------------------------------------------" << endl;
        cerr << "Event " << jsf->GetEventNumber();
        cerr << endl;
  } else {
  	gDEBUG = kFALSE;
  }

  Char_t msg[60];

  // Analysis starts here.
  
  Float_t selid = -0.5;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) strcpy(&cutName[(Int_t)selid][0],"No cut");

  // Get event buffer and make combined tracks accessible.

  JSFSIMDST     *sds     = (JSFSIMDST*)jsf->FindModule("JSFSIMDST");
  JSFSIMDSTBuf  *evt     = (JSFSIMDSTBuf*)sds->EventBuf();
  Int_t          ntrks   = evt->GetNLTKCLTracks(); 	// No. of tracks 
  TObjArray     *trks    = evt->GetLTKCLTracks(); 	// combined tracks
  
  ANL4DVector qsum;
  TObjArray tracks(500);
  tracks.SetOwner();
   
  // Select good tracks

  fNtracks = 0;
  for ( Int_t i = 0; i < ntrks; i++ ) {
    JSFLTKCLTrack *t = (JSFLTKCLTrack*)trks->UncheckedAt(i);
    if ( t->GetE() > xEtrack ) {
      ANL4DVector *qt = new ANL4DVector(t->GetPV());
      tracks.Add(qt); 		// track 4-momentum
      qsum += *qt;		// total 4-momentum
      fNtracks++;
    }				// *qt stays.
  }

  // Cut on No. of tracks.
  
  hNtracks->Fill(fNtracks);
  if ( fNtracks < xNtracks ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"N_tracks > %g",xNtracks);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }

  fEvis = qsum.E();		// E_vis
  fPt   = qsum.GetPt();		// P_t
  fPl   = qsum.Pz();		// P_l

  // Cut on Evis.

  hEvis->Fill(fEvis);
  if ( fEvis < xEvis ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"E_vis > %g",xEvis);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }
 
  // Cut on Pt.

  hPt->Fill(fPt);
  if ( fPt < xPt ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"Pt > %g",xPt);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }
 
  // Cut on Pl.

  if ( TMath::Abs(fPl) > xPl ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"|Pl| <= %g",xPl);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }

  // Find jets.

  fYcut = xYcut;
  ANLJadeEJetFinder jclust(fYcut);
  jclust.Initialize(tracks);
  jclust.FindJets();
  fYcut  = jclust.GetYcut();
  fNjets = jclust.GetNjets();

  // Cut on No. of jets.
    
  hNjets->Fill(fNjets);
  if ( fNjets < xNjets ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"Njets >= %i for Ycut = %g",xNjets,xYcut);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }
  
  // Now force the event to be xNjets.
  
  jclust.ForceNJets(xNjets);
  fNjets = jclust.GetNjets();
  fYcut  = jclust.GetYcut();

  // Make sure that No. of jets is xNjets.
    
  if ( fNjets != xNjets ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"Njets = %i",xNjets);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }
  
  // Loop over jets and decide Ejet_min and |cos(theta_j)|_max.
  
  TObjArray &jets = jclust.GetJets();	// jets is an array of ANLJet's
  TIter nextjet(&jets);			// and nextjet is an iterator for it
  ANLJet *jetp;
  Double_t ejetmin = 999999.;
  Double_t cosjmax = 0.;
  while ((jetp = (ANLJet *)nextjet())) {
    ANLJet &jet = *jetp;
    if (gDEBUG && kFALSE) jet.DebugPrint();
    Double_t ejet = jet().E();
    if (ejet < ejetmin) ejetmin = ejet;
    hEjet->Fill(ejet);			// Ejet
    Double_t cosj = jet.CosTheta();
    if (TMath::Abs(cosj) > TMath::Abs(cosjmax)) cosjmax = cosj;
    hCosjet->Fill(cosj);		// cos(theta_jet)
  }

  // Cut on Ejet_min.
  
  if ( ejetmin < xEjet ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"Ejet > %g",xEjet);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }

  // Cut on |cos(theta_j)|_max.
    
  if ( TMath::Abs(cosjmax) > xCosjet ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"|cos(theta_j)| <= %g",xCosjet);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }

  // Find W candidates in given mass windows.
  // Avoid using indices since there might be empty slots.
  
  TObjArray solutions(10);
  solutions.SetOwner();

  ANLPairCombiner w1candidates(jets,jets);
  ANLPairCombiner *w2candidp = 0;
  if (gDEBUG) {
    cerr << "------------------------------------------" << endl;
    cerr << "- w1candidates:" << endl;
    w1candidates.DebugPrint();
  }
  ANLPair *w1p, *w2p;
  while ((w1p = (ANLPair *)w1candidates())) {
    w2candidp   = 0;
    ANLPair &w1 = *w1p;
    Double_t w1mass = w1().GetMass();
    if (TMath::Abs(w1mass - kMassW) > xM2j) continue;	// w1 candidate found
    w1.LockChildren();					// now lock w1 daughters
    w2candidp = new ANLPairCombiner(w1candidates);	// w2 after w1
    ANLPairCombiner &w2candidates = *w2candidp;
    while ((w2p = (ANLPair *)w2candidates())) {
      ANLPair &w2 = *w2p;
      if (w2.IsLocked()) continue;			// skip if locked
      Double_t w2mass = w2().GetMass();
      if (TMath::Abs(w2mass - kMassW) > xM2j) continue;	// w2 candidate found
      Double_t chi2 = TMath::Power((w1mass - kMassW)/kSigmaMw,2.)
                    + TMath::Power((w2mass - kMassW)/kSigmaMw,2.);
      solutions.Add(new ANLPair(w1p,w2p,chi2));
      // hMw1Mw2->Fill(w1mass,w2mass,1.0);
    }
    if (w2candidp) delete w2candidp;
    w1.UnlockChildren();
  }
  
  // Cut on No. of solutions.

  if ( !solutions.GetEntries() ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"|m_jj - m_W| <= %g",xM2j);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }

  if (gDEBUG) {
    cerr << "------------------------------------------" << endl;
    cerr << "- w1candidates after 1:" << endl;
    w1candidates.DebugPrint();
  }

  // Cut on cos(theta_W).

  TIter nextsol(&solutions);
  ANLPair *sol;
  while ((sol = (ANLPair *)nextsol())) {
    ANL4DVector  &ww1 = *(ANL4DVector *)(*sol)[0];
    ANL4DVector  &ww2 = *(ANL4DVector *)(*sol)[1];
    Double_t ew1 = ww1.E();
    Double_t ew2 = ww2.E();
    hEw1Ew2->Fill(ew1,ew2,1.0);
    Double_t cosw1 = ww1.CosTheta();
    Double_t cosw2 = ww2.CosTheta();
    hCosw1Cosw2->Fill(cosw1,cosw2,1.0);
    if (TMath::Abs(cosw1) > xCosw || TMath::Abs(cosw2) > xCosw) {
      solutions.Remove(sol);
      delete sol;
    }
  }
  if ( !solutions.GetEntries() ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"|cos(theta_w)| <= %g",xCosw);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }

  if (gDEBUG) {
    cerr << "------------------------------------------" << endl;
    cerr << "- w1candidates after 2:" << endl;
    w1candidates.DebugPrint();
  }
  
  // Cut on Acop.

  nextsol.Reset();
  while ((sol = (ANLPair *)nextsol())) {
    ANL4DVector  &www1 = *(ANL4DVector *)(*sol)[0];
    ANL4DVector  &www2 = *(ANL4DVector *)(*sol)[1];
    Double_t acop = www1.Acop(www2);
    hAcop->Fill(acop);
    if (acop < xAcop) {
      solutions.Remove(sol);
      delete sol;
    }
  }
  if ( !solutions.GetEntries() ) return;
  hStat->Fill(++selid);
  if ( Ngoods == 0 ) {
    sprintf(msg,"Acop > %g",xAcop);
    strcpy(&cutName[(Int_t)selid][0],msg);
  }

  if (gDEBUG) {
    cerr << "------------------------------------------" << endl;
    cerr << "- w1candidates after 3:" << endl;
    w1candidates.DebugPrint();
  }

  // ------------------------
  //  End of event selection
  // ------------------------

  if ( Ngoods == 0 ) {
    selid++;
    sprintf(msg,"END");
    strcpy(&cutName[(Int_t)selid][0],msg);
  }
  Ngoods++;
 
  cerr << "------------------------------------------" << endl
       << "Event " << jsf->GetEventNumber() 
       << ": Number of solutions = " << solutions.GetEntries() << endl
       << "------------------------------------------" << endl;

  // Sort the solutions in the ascending order of chi2 vlues.
  
  solutions.Sort();

  // Hists and plots for selected events.

  if (gDEBUG && kFALSE) {
    Int_t nj = 0;
    nextjet.Reset();
    while ((jetp = (ANLJet *)nextjet())) {
       cerr << "------" << endl
            << "Jet " << ++nj << endl
            << "------" << endl;
       jetp->DebugPrint();
    }
  }

  hNsols->Fill(solutions.GetEntries());
  hEvisPl->Fill(fEvis,fPl,1.);
  
  nextsol.Reset();
  Int_t nsols = 0;
  while ((sol = (ANLPair *)nextsol())) {
    if ( nsols++ ) break;				// choose the best
    ANL4DVector  &wwww1 = *(ANL4DVector *)(*sol)[0];
    ANL4DVector  &wwww2 = *(ANL4DVector *)(*sol)[1];
    Double_t chi2   = sol->GetQuality();
    Double_t w1mass = wwww1.GetMass();
    Double_t w2mass = wwww2.GetMass();
          hChi2->Fill(chi2);
          hMw1Mw2->Fill(w1mass,w2mass,1.0);
  }
  
  return;
 }
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
void AliTRDdisplayTracks(Int_t track=157) 
{

  c1 = new TCanvas( "RecPoints", "RecPoints Display", 10, 10, 710, 740);
  c1->SetFillColor(1);
  TView *v=new TView(1);
  
      v->SetRange(-350.,-350.,-400.,350.,350.,400.); // full
  //  v->SetRange(0.,0.,0.,350.,350.,400.);  // top right
  //  v->SetRange(-350.,0.,0.,0.,350.,400.); // top left
  //  v->SetRange(0.,-350.,0.,350.,0.,400.); // bottom right 
  //  v->SetRange(-350.,-350.,0.,0.,0.,400.); // bottom left
  //  v->Side();
  v->Top();
  cerr<<"psi = "<<v->GetPsi()<<endl;

  // Dynamically link some shared libs
  if (gClassTable->GetID("AliRun") < 0) {
    gROOT->LoadMacro("loadlibs.C");
    loadlibs();
    cout << "Loaded shared libraries" << endl;
  }       


// Load tracks

   TFile *tf=TFile::Open("AliTRDtracks.root");
   if (!tf->IsOpen()) {cerr<<"Can't open AliTRDtracks.root !\n"; return 3;}
   TObjArray tarray(2000);
   //  tf->ls();
   TTree *tracktree=(TTree*)tf->Get("TreeT0_TRD");
   //   tracktree->ls();
   TBranch *tbranch=tracktree->GetBranch("tracks");
   Int_t nentr=tracktree->GetEntries();
   cerr<<"Found "<<nentr<<" entries in the track tree"<<endl;
   for (Int_t i=0; i<nentr; i++) {
       AliTRDtrack *iotrack=new AliTRDtrack;
       tbranch->SetAddress(&iotrack);
       tracktree->GetEvent(i);
       tarray.AddLast(iotrack);
       cerr<<"got track "<<i<<": index ="<<iotrack->GetLabel()<<endl;
   }
   tf->Close();                 


  // Load clusters
  Char_t *alifile = "TRDclusters.root";
  Int_t   nEvent  = 0;
  TObjArray rparray(2000);
  TObjArray *RecPointsArray = &rparray;
  const TFile *geofile =TFile::Open(alifile);
  //  AliTRDtracker *Tracker = new AliTRDtracker("dummy","dummy");
  AliTRDtracker *Tracker = new AliTRDtracker(geofile);
   Tracker->ReadClusters(RecPointsArray,alifile); 
  Int_t nRecPoints = RecPointsArray->GetEntriesFast();
  cerr<<"Found "<<nRecPoints<<" rec. points"<<endl;


  // Connect the AliRoot file containing Geometry, Kine, Hits, and Digits
      alifile = "galice.root";

   TFile *gafl = (TFile*) gROOT->GetListOfFiles()->FindObject(alifile);
  if (!gafl) {
    cout << "Open the ALIROOT-file " << alifile << endl;
    gafl = new TFile(alifile);
  }
  else {
    cout << alifile << " is already open" << endl;
  }
  

  // Get AliRun object from file or create it if not on file
  gAlice = (AliRun*) gafl->Get("gAlice");
  if (gAlice)
    cout << "AliRun object found on file" << endl;
  else
    gAlice = new AliRun("gAlice","Alice test program");
	

       AliTRDparameter *par =  ( AliTRDparameter *par) gafl->Get("TRDparameter");
       AliTRDv1       *TRD           = (AliTRDv1*) gAlice->GetDetector("TRD");
       AliTRDgeometry *fGeom   = TRD->GetGeometry();   
       
  Int_t i,j,index,det,sector, ti[3];
  Double_t x,y,z, cs,sn,tmp;
  Float_t global[3], local[3];

  // Display all TRD RecPoints
  TPolyMarker3D *pm = new TPolyMarker3D(nRecPoints);

  for (Int_t i = 0; i < nRecPoints; i++) {
    printf("\r point %d out of %d",i,nRecPoints);
    AliTRDcluster *rp = (AliTRDcluster *) RecPointsArray->UncheckedAt(i);    
  
   Int_t  idet=rp->GetDetector();
   Int_t iplan = fGeom->GetPlane(idet);    
   Int_t itt=rp->GetLocalTimeBin();
   Float_t  timeSlice = itt+0.5; 
   Float_t  time0     = par->GetTime0(iplan);

  // calculate (x,y,z) position in rotated chamber
   local[0] = time0 - (timeSlice - par->GetTimeBefore()) 
         * par->GetTimeBinSize();
   local[1]=rp->GetY();
   local[2]=rp->GetZ(); 

    for (j = 0; j < 3; j++) { ti[j] = rp->GetTrackIndex(j); }

    if((track < 0) ||
       ((ti[0]==track)||(ti[1]==track)||(ti[2]==track))) {

        if(fGeom->RotateBack(idet,local,global)) {     
       	x=global[0]; y=global[1]; z=global[2];
       	pm->SetPoint(i,x,y,z);
         }

    }
  }

  pm->SetMarkerSize(1); pm->SetMarkerColor(10); pm->SetMarkerStyle(1);
  pm->Draw();
  
   AliTRDparameter *par =  ( AliTRDparameter *par) gafl->Get("TRDparameter");

  Int_t ntracks = tarray.GetEntriesFast();

  for (i = 0; i < ntracks; i++) {
    AliTRDtrack *pt = (AliTRDtrack *) tarray.UncheckedAt(i), &t=*pt;
    Int_t nclusters = t.GetNumberOfClusters();
    cerr<<"in track "<<i<<" found "<<nclusters<<" clusters"<<endl;
   
    TPolyMarker3D *pm = new TPolyMarker3D(nclusters);
    for(j = 0; j < nclusters; j++) {
      index = t.GetClusterIndex(j);
      AliTRDcluster *rp = (AliTRDcluster *) RecPointsArray->UncheckedAt(index); 

   Int_t  idet=rp->GetDetector();
   Int_t iplan = fGeom->GetPlane(idet);    
   Int_t itt=rp->GetLocalTimeBin();
   Float_t  timeSlice = itt+0.5; 
   Float_t  time0     = par->GetTime0(iplan);


  // calculate (x,y,z) position in rotated chamber
       local[0] = time0 - (timeSlice - par->GetTimeBefore()) 
         * par->GetTimeBinSize();
       local[1]=rp->GetY(); 
       local[2]=rp->GetZ();

            if(fGeom->RotateBack(idet,local,global)) {     
      	x=global[0]; y=global[1]; z=global[2];
      	pm->SetPoint(j,x,y,z);
       }
    } 
    pm->SetMarkerSize(1); pm->SetMarkerColor(i%6+3); pm->SetMarkerStyle(1);
    //    pm->Draw();
  }
  
  TGeometry *geom=(TGeometry*)gafl->Get("AliceGeom");
  geom->Draw("same");

  c1->Modified(); 
  
  c1->Update();
  
  gafl->Close();

}
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();
}