2008 run preparation

Timinng curves for ETOW & ESMD

Timing Scan 11/23/2007

Timing Scan 11/23/2007

EEMC timing scan was taken on11/23/2007.

To generate the curves, log into your favorite rcas node and

$ cvs co -D 11/27/2007 StRoot/StEEmcPool/StEEmcTimingMaker

and follow the instructions in the HOWTO

$ cat StRoot/StEEmcPool/StEEmcTimingMaker/HOWTO.l2ped

(tried to post code, but drupal wouldn't accept it...)

Will's notes on crate configuration:

FYI here are some (old) notes on how I set up config files
for EEMC tower timing scans that were taken a few days back (BTW,
these configs are still loaded).

1) Old running settings -- config files are on eemc-sc in directory
/home/online/mini/tcl with symbolic links:
tower-"n"-current_beam_config.dat ->
dir/tower-"n"-current_beam_config.dat
We had (I believe) been using directory 04.04.07 for the run with
ETOW TCD phase of 19; crate fifo (RHIC tic) 0x13. Those crate delay
settings are:
1 -> 0x12; 2 -> 0x8; 3 -> 0x56; 4 -> 0x50; 5 -> 0x2b; 6 -> 0x1f

2) new scan settings ... for time scans using only TCD phase
we usually create special config files with approprieate box delay and
TCD values.

nominal (ns) for (eff RHIC tic
run 7 scan ns)

1 -> 0x12 (18) 0x5a (-17) fifo 0x14 (e.g., 107-90)
2 -> 0x8 ( 8) 0x50 (-27) fifo 0x14 (e.g., 107-80)
3 -> 0x56 (86) 0x42 ( 66) fifo 0x13
4 -> 0x50 (80) 0x3c ( 60) fifo 0x13
5 -> 0x2b (43) 0x17 ( 23) fifo 0x13
6 -> 0x1f (31) 0xb ( 11) fifo 0x13

Here we have shifted crates "earlier" in time: 1&2 by 35 ns and
rest by 20 ns.Starting TCD scan at 5 then should start things
~ 34 (49) ns earlier than nominal with ~ 70 ns for scan to run
(suggested TCD: 5,10,15,25,35,45,55,65,75,70,60,50,40,30,20,10)

Run
ETOW tcd phase delay
N events
8327013 5 136k
8327014 15 20k
8327015 25 20k
8327016 35 20k
8327017 45 20k
8327018 55 20k
8327019 65 20k
8327020 75 20k
8327021 70 20k
8327022 60 20k
8327023 50 20k
8327024 40 20k
8327025 30 20k
8327026 20 20k
8327027 10 20k














Figure 1 --Integral from ped+25 to ped+75, normalized to total number of events, versus TCD phase delay.

Channel-by-channel plots are attached below.

Timing Scan 11/27/2007 (MuDst)

 

            Posted results are from MuDst data of 17 runs with 50K events in each run.

           

              1,     ShiftLog Entry   

              2,    Run Summary

                      Run                    ETOW & ESMD phase (ns)                # of Events (K)  

                      8331091                               5                                             200

                             1092                            15                                              200

                             1094                            25                                              200

                             1097                            35                                              200

                             1098                            45                                              200

                             1102                            65                                              200

                            1103                             75                                              200

                            1104                             70                                              200

                            1105                             60                                              200

                            1106                             50                                              200

                            1107                             40                                              200

                            1108                             35                                              200

                            1109                             30                                              200

                            1110                             25                                              200

                            1111                             20                                              200

                            2001                             10                                              109 

              

               3,   Crate Timing Curves  

 

Fig. 1 Tower Crate. It agrees with results from L2 Data

Fig. 2 Crate 64-67

Fig. 3 Crate 68-71

Fig. 4 Crate 72_75

Fig. 5 Crate 76-79

Fig. 6 Crate 80_83

Fig. 7 Crate 84-87

Fig. 8 Crate 88-91

Fig. 9 Crate 92-95

Fig. 10 Crate 96-99

Fig. 11 Crate 100-103

Fig. 12 Crate 104-107

Fig. 13 Crate 108-111

              4, PDF Files of MAPMT Channel Timing Curve

   tower-crate-1.pdf  tower-crate-2.pdf  tower-crate-3.pdf  tower-crate-4.pdf  tower-crate-5.pdf  tower-crate-6.pdf

   mapmt-crate-64.pdf  mapmt-crate-65.pdf  mapmt-crate-66.pdf  mapmt-crate-67.pdf  mapmt-crate-68.pdf  mapmt-crate-69.pdf
   mapmt-crate-70.pdf  mapmt-crate-71.pdf  mapmt-crate-72.pdf  mapmt-crate-73.pdf  mapmt-crate-74.pdf  mapmt-crate-75.pdf
   mapmt-crate-76.pdf  mapmt-crate-77.pdf  mapmt-crate-78.pdf  mapmt-crate-79.pdf  mapmt-crate-80.pdf  mapmt-crate-81.pdf
   mapmt-crate-82.pdf  mapmt-crate-83.pdf  mapmt-crate-84.pdf  mapmt-crate-85.pdf  mapmt-crate-86.pdf  mapmt-crate-87.pdf
   mapmt-crate-88.pdf  mapmt-crate-89.pdf  mapmt-crate-90.pdf  mapmt-crate-91.pdf  mapmt-crate-92.pdf  mapmt-crate-93.pdf
   mapmt-crate-94.pdf  mapmt-crate-95.pdf  mapmt-crate-96.pdf  mapmt-crate-97.pdf  mapmt-crate-98.pdf  mapmt-crate-99.pdf
   mapmt-crate-100.pdf  mapmt-crate-101.pdf  mapmt-crate-102.pdf  mapmt-crate-103.pdf  mapmt-crate-104.pdf  mapmt-crate-105.pdf
   mapmt-crate-106.pdf  mapmt-crate-107.pdf  mapmt-crate-108.pdf  mapmt-crate-109.pdf  mapmt-crate-110.pdf  mapmt-crate-111.pdf
   

 

Timing Scan 11/29/2007

Timing Scan 11/29/2007

posted 11/30/2007 Shiftlog entry
      run     btow   etow
8333113 12 5
115 17 15
116 22 25
117 27 35
118 32 45
120 37 55
121 42 65
123 52 70
124 57 60
125 62 50
126 36 40
127 36 30
128 36 20
129 36 10

Figure 1 -- Tower crates


Email from Will setting tower timing for this year
     Below in the forwarded message you will see a link to the 
analysis (thanks Jason) of the more recent (much better statistics) 
EEMC tower timing scan. Based on these I set the timing for this year
as follows (from my shift log entry)

                          *************

> 11/30/07
> 19:49
> 
> General
> new timing configuration files loaded for EEMC towers
> crate 1 delay 0x12 (no change from last year nominal)
> crate 2 delay 0x8 (no change)
> crate 3 delay 0x57 ( + 1 ns)
> crate 4 delay 0x52 (+ 2 ns)
> crate 5 delay 0x2b (no change)
> crate 6 delay 0x1f (no change)
> change ETOW phase to 21 (saved in all configs)
> above phase represents overall shift of + 2 ns

makeL2TimingFiles.pl

#!/opt/star/sl44_gcc346/bin/perl -w

# specify which macro to run
my $macro="runEEmcL2Timing.C";

# run numbers
my @runs = ( 8333113, 8333115, 8333116, 8333117, 8333118, 8333120,
8333121, 8333123, 8333124, 8333125, 8333126, 8333127,
8333128, 8333129
);


# number of events per run
my @nevents = ( 200000, 200000, 200000, 200000, 200000, 200000,
200000, 200000, 200000, 200000, 200000, 200000,
200000, 200000 );



# tower delays in each run
@tower_delays = (
5, 15, 25, 35, 45, 55,
65, 70, 60, 50, 40, 30,
20, 10,
);


# mapmt delays in each run (junk in this scan );
@mapmt_delays = (
5, 15, 25, 35, 45, 55,
65, 75, 70, 60, 50, 40,
30, 20, 10, 19
);


# loop over the runs
$i = 0;
foreach $run ( @runs )
{

# command to run
$cmd = "root4star -q -b $macro\\\($nevents[$i],\\\"$run.list\\\",\\\"$run.root\\\",$tower_delays[$i],$mapmt_delays[$i]\\\)\n";

# run root4star
open RUNIT, "$cmd|";
while ( <RUNIT> ) { print; }

$i++;

}

plotEEmcL2Timing.C


TFile *file = 0;
TChain *chain = 0;

#include <vector>

#include "/afs/rhic.bnl.gov/star/packages/DEV/StRoot/StEEmcUtil/EEfeeRaw/EEdims.h"

// summary TTree branches created by StEEmcTimingMaker
Int_t mRunNumber;
Float_t mTowerDelay;
Float_t mMapmtDelay;
Int_t mTotalYield;
Int_t mTowerCrateYield[MaxTwCrates];
Int_t mMapmtCrateYield[MaxMapmtCrates];
Int_t mTowerChanYield[MaxTwCrates][MaxTwCrateCh];
Int_t mMapmtChanYield[MaxMapmtCrates][MaxMapmtCrateCh];
Int_t mTowerMin;
Int_t mTowerMax;
Int_t mMapmtMin;
Int_t mMapmtMax;

// vectors to hold TGraphs for tower and mapmt crates
Int_t npoints = 0;

TGraphErrors *towerCrateCurves[MaxTwCrates];
TGraphErrors *mapmtCrateCurves[MaxMapmtCrates];

TGraphErrors *towerChanCurves[MaxTwCrates][MaxTwCrateCh];
TGraphErrors *mapmtChanCurves[MaxMapmtCrates][MaxMapmtCrateCh];

// enables printing of output files (gif) for documentation
// figures will appear in same subdirector as input files,
// specified below.
//Bool_t doprint = true;
Bool_t doprint = false;

void plotEEmcL2Timing( const Char_t *input_dir="timing_files/")
{

// chain files
chainFiles(input_dir);

// setup branches
setBranches(input_dir);

// get total number of points
Long64_t nruns = chain -> GetEntries();
npoints=(Int_t)nruns;

// setup the graphs for each crate and each channel
initGraphs();

// loop over all runs
for ( Long64_t i = 0; i < nruns; i++ )
{
chain->GetEntry(i);

fillCrates((int)i);
fillChannels((int)i);

}

// draw timing scan curves for tower crates
drawCrates();
// for ( Int_t ii=0;ii<MaxTwCrates;ii++ ) towerChannels(ii);
// for ( Int_t ii=0;ii<MaxMapmtCrates;ii++ ) mapmtChannels(ii);

std::cout << "--------------------------------------------------------" << std::endl;
std::cout << "to view timing curves for any crate" << std::endl;
std::cout << std::endl;
std::cout << "towerChannels(icrate) -- icrate = 0-5 for tower crates 1-6"<<std::endl;
// std::cout << "mapmtChannels(icrate) -- icrate = 0-47 for mapmt crates 1-48"<<std::endl;
std::cout << "print() -- make gif/pdf files for all crates and channels"<<std::endl;

}
// ----------------------------------------------------------------------------
void print()
{
doprint=true;
drawCrates();
for ( Int_t ii=0;ii<MaxTwCrates;ii++ ) towerChannels(ii);
//for ( Int_t ii=0;ii<MaxMapmtCrates;ii++ ) drawMapmt(ii);
}

// ----------------------------------------------------------------------------
void drawCrates()
{

// tower crates first
TCanvas *towers=new TCanvas("towers","towers",500,400);
const Char_t *opt[]={"ALP","LP","LP","LP","LP","LP"};

TLegend *legend=new TLegend(0.125,0.6,0.325,0.85);

Float_t ymax=0.;
for ( Int_t icr=0;icr<MaxTwCrates;icr++ )
{
towerCrateCurves[icr]->Sort();
towerCrateCurves[icr]->Draw(opt[icr]);
TString crname="tw crate ";crname+=icr+1;
legend->AddEntry( towerCrateCurves[icr], crname, "lp" );
if ( towerCrateCurves[icr]->GetYaxis()->GetXmax() > ymax )
ymax=towerCrateCurves[icr]->GetYaxis()->GetXmax();
}
towerCrateCurves[0]->SetTitle("EEMC Tower Crate Timing Curves");
towerCrateCurves[0]->GetXaxis()->SetTitle("TCD phase[ns]");
TString ytitle=Form("Integral [ped+%i,ped+%i] / N_{events}",mTowerMin,mTowerMax);
towerCrateCurves[0]->GetYaxis()->SetTitle(ytitle);
towerCrateCurves[0]->GetYaxis()->SetRangeUser(0.,ymax);
legend->Draw();

if(doprint)towers->Print("tower_crates.gif");

}
// ----------------------------------------------------------------------------
void mapmtChannels( Int_t crate )
{

static const Int_t stride=16;
Int_t crateid = MinMapmtCrateID+crate;

TString fname="mapmt-crate-";fname+=crate+MinMapmtCrateID;fname+=".ps";
TCanvas *canvas=new TCanvas("canvas","canvas",850/2,1100/2);
canvas->Divide(1,2);
Int_t icanvas=0;

for ( Int_t ich=0;ich<192;ich+=stride )
{

canvas->cd(1+icanvas%2);
icanvas++;

TString pname="crate";
pname+=crateid;
pname+="_ch";
pname+=ich;
pname+="-";
pname+=ich+stride-1;

const Char_t *opts[]={"ALP","LP","LP","LP","LP","LP","LP","LP","LP","LP","LP","LP","LP","LP","LP","LP","LP","LP","LP","LP","LP"};

// normalize
Float_t ymax=0.0;
Double_t sum[stride];for ( Int_t jj=0;jj<stride;jj++ )sum[jj]=0.;
Double_t max=0.;
for ( Int_t jch=0;jch<stride;jch++ ) // loop over channels in this one graph
{
Int_t index=ich+jch;
Double_t *Y=mapmtChanCurves[crate][index]->GetY();
for ( Int_t ipoint=0;ipoint<npoints;ipoint++ ) {
if ( Y[ipoint]>ymax ) ymax=Y[ipoint];
sum[jch]+=Y[ipoint];
}
if ( sum[jch]>max ) max=sum[jch];
}
if ( max <= 0. ) continue; // meh?

TLegend *legend=new TLegend(0.55,0.11,0.85,0.525);
for ( Int_t jch=0;jch<stride;jch++ )
{
Int_t index=ich+jch;
mapmtChanCurves[crate][index]->SetMarkerSize(0.75);
// offset X axis of each of these
Double_t *X=mapmtChanCurves[crate][index]->GetX();
Double_t *Y=mapmtChanCurves[crate][index]->GetY();
Double_t *EY=mapmtChanCurves[crate][index]->GetEY();
if ( sum[jch]<= 0. ) continue;
// std::cout<<"before"<<std::endl;
for ( Int_t ip=0;ip<npoints;ip++ ){
Float_t shift = 0.5+ ((float)jch) - ((float)stride)/2.0;
Double_t yy=Y[ip];
X[ip]-= 0.1*shift;
Y[ip]*=max/sum[jch];
EY[ip]*=max/sum[jch];
// std::cout << "ip="<<ip<<" y="<<yy<<" y'="<<Y[ip]<<std::endl;
}
mapmtChanCurves[crate][index]->Sort();
if ( !jch )
mapmtChanCurves[crate][index]->GetXaxis()->SetRangeUser(0.,ymax*1.05);
mapmtChanCurves[crate][index]->SetMarkerColor(38+jch);
mapmtChanCurves[crate][index]->SetLineColor(38+jch);
mapmtChanCurves[crate][index]->SetMinimum(0.);
mapmtChanCurves[crate][index]->Draw(opts[jch]);

TString label="crate ";label+=crate+1;label+=" chan ";label+=index;
legend->AddEntry(mapmtChanCurves[crate][index],label,"lp");

}
legend->Draw();
canvas->Update();

// if(doprint)c->Print(pname+".gif");
if ( !(icanvas%2) ){
canvas->Print(fname+"(");
canvas->Clear();
canvas->Divide(1,2);
}
// if(doprint)c->Print(pname+".gif");

}
canvas->Print(fname+")");
gSystem->Exec(TString("ps2pdf ")+fname);

}
// ----------------------------------------------------------------------------
void towerChannels( Int_t crate )
{

static const Int_t stride=12;

TString fname="tower-crate-";fname+=crate+1;fname+=".ps";
TCanvas *canvas=0;
canvas = new TCanvas("canvas","canvas",850/2,1100/2);

canvas->Divide(1,2);
Int_t icanvas=0;

for ( Int_t ich=0;ich<120;ich+=stride )
{

canvas->cd(1+icanvas%2);
icanvas++;

// TString aname="crate";aname+=crate;aname+=" channels ";aname+=ich;aname+=" to ";aname+=ich+stride-1;
// TCanvas *c = new TCanvas(aname,aname,400,300);

TString pname="crate";
pname+=crate+1;
pname+="_ch";
pname+=ich;
pname+="-";
pname+=ich+stride-1;

const Char_t *opts[]={"ALP","LP","LP","LP","LP","LP","LP","LP","LP","LP","LP","LP","LP","LP","LP","LP"};

// normalize
Double_t sum[stride];for ( Int_t jj=0;jj<stride;jj++ )sum[jj]=0.;
Double_t max=0.;
for ( Int_t jch=0;jch<stride;jch++ ) // loop over channels in this one graph
{

Int_t index=ich+jch;
Double_t *Y=towerChanCurves[crate][index]->GetY();
for ( Int_t ipoint=0;ipoint<npoints;ipoint++ ) sum[jch]+=Y[ipoint];
if ( sum[jch]>max ) max=sum[jch];
}
if ( max <= 0. ) continue; // meh?

TLegend *legend=new TLegend(0.125,0.15,0.325,0.45);
for ( Int_t jch=0;jch<stride;jch++ )
{

Int_t index=ich+jch;
towerChanCurves[crate][index]->SetMarkerSize(0.75);
// offset X axis of each of these
Double_t *X=towerChanCurves[crate][index]->GetX();
Double_t *Y=towerChanCurves[crate][index]->GetY();
Double_t *EY=towerChanCurves[crate][index]->GetEY();
if ( sum[jch]<= 0. ) continue;
// std::cout<<"before"<<std::endl;
for ( Int_t ip=0;ip<npoints;ip++ ){
Float_t shift = 0.5+ ((float)jch) - ((float)stride)/2.0;
Double_t yy=Y[ip];
X[ip]-= 0.1*shift;
Y[ip]*=max/sum[jch];
EY[ip]*=max/sum[jch];
// std::cout << "ip="<<ip<<" y="<<yy<<" y'="<<Y[ip]<<std::endl;
}

towerChanCurves[crate][index]->Sort();
towerChanCurves[crate][index]->SetMinimum(0.);
towerChanCurves[crate][index]->SetMarkerColor(38+jch);
towerChanCurves[crate][index]->SetLineColor(38+jch);
towerChanCurves[crate][index]->Draw(opts[jch]);

TString label="crate ";label+=crate+1;label+=" chan ";label+=index;
legend->AddEntry(towerChanCurves[crate][index],label,"lp");

}
legend->Draw();
canvas->Update();

// if(doprint)c->Print(pname+".gif");
if ( !(icanvas%2) ){
if ( doprint ) canvas->Print(fname+"(");
canvas->Clear();
canvas->Divide(1,2);
}

}
if ( doprint ) {
canvas->Print(fname+")");
gSystem->Exec(TString("ps2pdf ")+fname);
}

}

// ----------------------------------------------------------------------------
void fillCrates(Int_t ipoint)
{
#if 1
// loop over tower crates
for ( Int_t icr=0;icr<MaxTwCrates;icr++ )
{
Float_t yield = (Float_t)mTowerCrateYield[icr];
Float_t total = (Float_t)mTotalYield;
if ( total > 10.0 ) {
Float_t eyield = TMath::Sqrt(yield);
Float_t etotal = TMath::Sqrt(total);
Float_t r = yield / total;
Float_t e1 = (yield>0)? eyield/yield : 0.0;
Float_t e2 = etotal/total;
Float_t er = r * TMath::Sqrt( e1*e1 + e2*e2 );
towerCrateCurves[icr]->SetPoint(ipoint, mTowerDelay, r );
towerCrateCurves[icr]->SetPointError( ipoint, 0., er );
}
else {
towerCrateCurves[icr]->SetPoint(ipoint, mTowerDelay, -1.0 );
towerCrateCurves[icr]->SetPointError( ipoint, 0., 0. );
}
}
// loop over mapmt crates
for ( Int_t icr=0;icr<MaxMapmtCrates;icr++ )
{
Float_t yield = (Float_t)mMapmtCrateYield[icr];
Float_t total = (Float_t)mTotalYield;
if ( total > 10.0 ) {
Float_t eyield = TMath::Sqrt(yield);
Float_t etotal = TMath::Sqrt(total);
Float_t r = yield / total;
Float_t e1 = (yield>0)? eyield/yield : 0.0;
Float_t e2 = etotal/total;
Float_t er = r * TMath::Sqrt( e1*e1 + e2*e2 );
mapmtCrateCurves[icr]->SetPoint(ipoint, mMapmtDelay, r );
mapmtCrateCurves[icr]->SetPointError( ipoint, 0., er );
}
else {
mapmtCrateCurves[icr]->SetPoint(ipoint, mMapmtDelay, -1. );
mapmtCrateCurves[icr]->SetPointError( ipoint, 0., 0. );
}
}
#endif
}
// ----------------------------------------------------------------------------
void fillChannels(Int_t ipoint)
{

#if 1
// loop over tower crates
for ( Int_t icr=0;icr<MaxTwCrates;icr++ )
{
for ( Int_t ich=0;ich<MaxTwCrateCh;ich++ )
{

Float_t yield = (Float_t)mTowerChanYield[icr][ich];
Float_t total = (Float_t)mTotalYield;
if ( total > 10.0 ) {
Float_t eyield = TMath::Sqrt(yield);
Float_t etotal = TMath::Sqrt(total);
Float_t r = yield / total;
Float_t e1 = (yield>0)? eyield/yield : 0.0;
Float_t e2 = etotal/total;
Float_t er = r * TMath::Sqrt( e1*e1 + e2*e2 );
towerChanCurves[icr][ich]->SetPoint(ipoint, mTowerDelay, r );
towerChanCurves[icr][ich]->SetPointError( ipoint, 0., er );
}
else {
towerChanCurves[icr][ich]->SetPoint(ipoint, mTowerDelay, -1.0 );
towerChanCurves[icr][ich]->SetPointError( ipoint, 0., 0. );
}
}
}
#endif
#if 1
// loop over mapmt crates
for ( Int_t icr=0;icr<MaxMapmtCrates;icr++ )
{
for ( Int_t ich=0;ich<MaxMapmtCrateCh;ich++ )
{

Float_t yield = (Float_t)mMapmtChanYield[icr][ich];
Float_t total = (Float_t)mTotalYield;
if ( total > 10.0 ) {
Float_t eyield = TMath::Sqrt(yield);
Float_t etotal = TMath::Sqrt(total);
Float_t r = yield / total;
Float_t e1 = (yield>0)? eyield/yield : 0.0;
Float_t e2 = etotal/total;
Float_t er = r * TMath::Sqrt( e1*e1 + e2*e2 );
mapmtChanCurves[icr][ich]->SetPoint(ipoint, mMapmtDelay, r );
mapmtChanCurves[icr][ich]->SetPointError( ipoint, 0., er );
}
else {
mapmtChanCurves[icr][ich]->SetPoint(ipoint, mMapmtDelay, -1.0 );
mapmtChanCurves[icr][ich]->SetPointError( ipoint, 0., 0. );
}
}
}
#endif
}
// ----------------------------------------------------------------------------
void initGraphs()
{

for ( Int_t i=0;i<MaxTwCrates;i++ ){
towerCrateCurves[i] = new TGraphErrors(npoints);
towerCrateCurves[i]->SetMarkerStyle(20+i);
towerCrateCurves[i]->SetMarkerColor(i+1);
towerCrateCurves[i]->SetLineColor(i+1);

for ( Int_t j=0;j<MaxTwCrateCh;j++ )
towerChanCurves[i][j]=(TGraphErrors*)towerCrateCurves[i]->Clone();

}
for ( Int_t i=0;i<MaxMapmtCrates;i++ ){
mapmtCrateCurves[i]= new TGraphErrors(npoints);
mapmtCrateCurves[i]->SetMarkerStyle(20+i%4);
mapmtCrateCurves[i]->SetMarkerColor(1+i%4);
mapmtCrateCurves[i]->SetLineColor(1+i%4);

for ( Int_t j=0;j<MaxMapmtCrateCh;j++ )
mapmtChanCurves[i][j]=(TGraphErrors*)mapmtCrateCurves[i]->Clone();

}

}
// ----------------------------------------------------------------------------
void chainFiles(const Char_t *path)
{
chain=new TChain("timing","Timing summary");

TFile *tfile = 0;
std::cout << "chaining files in " << path << std::endl;
TSystemDirectory *dir = new TSystemDirectory("dir",path);

TIter next( dir->GetListOfFiles() );
TObject *file = 0;
while ( file = (TObject*)next() )
{
TString name=file->GetName();

// sum the event counter histogram
if ( name.Contains(".root") ) {
// open the TFile and
std::cout << " + " << name << std::endl;
// tfile = TFile::Open(name);
chain->Add(name);
}
}

}
// ----------------------------------------------------------------------------
void setBranches(const Char_t *dir)
{

chain->SetBranchAddress("mRunNumber", &mRunNumber );
chain->SetBranchAddress("mTowerDelay", &mTowerDelay );
chain->SetBranchAddress("mMapmtDelay", &mMapmtDelay );

chain->SetBranchAddress("mTotalYield", &mTotalYield );
chain->SetBranchAddress("mTowerCrateYield", &mTowerCrateYield );
chain->SetBranchAddress("mMapmtCrateYield", &mMapmtCrateYield );
chain->SetBranchAddress("mTowerChanYield", &mTowerChanYield );
chain->SetBranchAddress("mMapmtChanYield", &mMapmtChanYield );

chain->SetBranchAddress("mTowerMin",&mTowerMin);
chain->SetBranchAddress("mTowerMax",&mTowerMax);
chain->SetBranchAddress("mMapmtMin",&mMapmtMin);
chain->SetBranchAddress("mMapmtMax",&mMapmtMax);

}

runEEmcL2Timing.C

/******************************************************************************
**
** runEEmcTiming.C
**
** Arguements:
**
** nevents - number of events to process
** name - filename, format = <run>.list, eg 8081048.list, containing
** a list of MuDst's from a single run
** ofile - output histogram filename, suggested <run>.root. Output
** will be saved in subdirectory timing_files/
**
** tower_delay - the TCD phase delay (towers) for this run
** mapmt_delay - the TCD phase delay (mapmt) for this run
**
**/

class StChain;
class St_db_Maker;
class StEEmcDbMaker;
class StMuDstMaker;
class StEEmcA2EMaker;
class StEEmcTimingMaker;

//--
//-- globals
//--
StChain *mChain = 0;
St_db_Maker *mStarDatabase = 0;
StEEmcDbMaker *mEEmcDatabase = 0;
StMuDstMaker *mMuDstMaker = 0;
StEEmcA2EMaker *mEEanalysis = 0;

Int_t count = 0;
Int_t stat = 0;

Int_t nzeros = 0;
Int_t max_zero_count = 100;


void runEEmcL2Timing( Int_t nevents = 30000,
Char_t *name = "8327013.list",
Char_t *ofile= "8327013.root",
Float_t tower_delay=19.,
Float_t mapmt_delay=65.,
Int_t nfiles = 1000
)
{

Char_t *path = "./";
TString pathname = path;
pathname += name;

//--
//-- Load shared libraries
//--
LoadLibs();
gMessMgr -> SwitchOn("I");

gSystem->mkdir("timing_files/");
TString myofile="timing_files/";
myofile += ofile;

TFile *out=new TFile(ofile,"recreate");
StEEmcTimingMaker *timing=new StEEmcTimingMaker("timing");
timing->setRunNumber( atoi( name ) );
timing->setTiming( tower_delay, mapmt_delay );
timing->setTowerCuts( 25, 75 );
timing->setMapmtCuts( 50, 150 );
timing->setOutputFile( myofile );

timing->addTowerMask( 2, 98 ); // crate 2 ch 98 looks hot


ifstream input(name);
Char_t buf[256];
input >> buf;

timing->processFromL2(buf,nevents);
timing->Finish();

return;

}

void LoadLibs()
{
//-- Load muDst shared libraries --
gROOT -> LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
loadSharedLibraries();

gSystem->Load("StDbLib");
gSystem->Load("StDbBroker");
gSystem->Load("St_db_Maker");
gSystem->Load("StEEmcDbMaker");
gSystem->Load("StEEmcUtil");
gSystem->Load("StEEmcSimulatorMaker");

gSystem->Load("StEEmcA2EMaker");
gSystem->Load("StEEmcTimingMaker");

}