Exemplo n.º 1
0
int main(){
	char collectString[LEN_MAX+1];
	gets(collectString);
	for(int i=0;i<strlen(collectString);i++)
		collect[collectString[i]-'a']++;
	while(true){
		gets(dictionary[wordNum]);
		if(dictionary[wordNum][0]=='.')
			break;
		if(Legal(dictionary[wordNum])){
			score[wordNum]=Score(dictionary[wordNum]);
			if(scoreMax<score[wordNum])
				scoreMax=score[wordNum];
			for(int i=0;i<wordNum;i++){
				char temp[2*LEN_MAX+1];
				strcpy(temp,dictionary[i]);
				strcat(temp,dictionary[wordNum]);
				if(Legal(temp) && scoreMax<score[i]+score[wordNum])
					scoreMax=score[i]+score[wordNum];
			}
			wordNum++;
		}
	}
	printf("%d\n",scoreMax);
	return 0;
}
Exemplo n.º 2
0
void PrintCopyright(void)
{
  Legal("%s %s Copyright 1994,95 O.Montanuy, Copyright 1999-2000 A.Majorel\n",
      DEUTEXNAME,deutex_version);
  Legal("  Ported to DOS, Unix, OS/2, Linux, SGiX, DEC Alpha.\n");
  Legal("  Thanx to M.Mathews, P.Allansson, C.Rossi, J.Bonfield, U.Munk.\n");
  Legal("  This program is freeware.\n");
  Legal("Type \"%s --help\" to get the list of commands.\n",COMMANDNAME);
  return;
}
Exemplo n.º 3
0
int GameOver(board state)
{
    int X,Y;

    for (X=0; X<8; X++)
        for (Y=0; Y<8; Y++) {
            if (Legal(state, 1, X, Y)) return FALSE;
            if (Legal(state, -1, X, Y)) return FALSE;
        }
    return TRUE;
}
Exemplo n.º 4
0
void Exit(Point p)//计算下一步
{
	Point temp;
	Point p1;
	int j=0;
	Point ap[8]={0};
	for (int i=0;i<8;i++)
	{
		p1.x=p.x+HTry1[i];
		p1.y=p.y+HTry2[i];
		if (Legal(p1))
		{
			ap[j]=p1;
			j++;
		}
	}//将下一步的可能位置存储在ap[]中
	for (int count=0; count<Number(p)-1;count++)
	{
		for (int k=0;k<Number(p)-1;k++)
		{
			if (Number(ap[k])<Number(ap[k+1])) //从大到小排列
			{
				temp=ap[k+1];
				ap[k+1]=ap[k];
				ap[k]=temp;
			}
		}
	}
	for (int t=0; t<Number(p);t++)
	{ 
		Push(s[step],ap[t]); //从大到小压入s[step]栈中,pop的时候就是从小到大
	}
} 
Exemplo n.º 5
0
int Number(Point p) //找出当前位置下一步的各种可能位置,计算可能之和
{
	Point p1;
	int j=0;
	for (int i=0;i<8;i++)
	{
		p1.x=p.x+HTry1[i];
		p1.y=p.y+HTry2[i];
		if (Legal(p1))
		{
			j++;
		}
	}
	return j;
}
Exemplo n.º 6
0
int Number(Point p)
{
	Point p1;
	int j = 0;
	for (int i = 0; i < 8; i++)
	{
		p1.x = p.x + HTry1[i];
		p1.y = p.y + HTry2[i];
		if (Legal(p1))
		{
			j++;
		}
	}
	return j;
}
Exemplo n.º 7
0
//determines the set of moves that a particular player can make
int Actions(board state, int player, int Xacts[], int Yacts[])
{
    int X, Y, n;
    n = 0;
    for (X=0; X<8; X++)
        for (Y=0; Y<8; Y++)
            if (Legal(state, player, X, Y)){
                Xacts[n] = X; Yacts[n] = Y;
                n++;
            }
    if (n==0){
        Xacts[n] = -1; Yacts[n] = -1;
        n=1;
    }
    return n;
}
Exemplo n.º 8
0
  Int_t GetRateXY( Int_t fillnum = 15419 ,const char* sl = "small" ){
	
	gSystem->Load("../lib/libMyCellMgr.so");
        gROOT->LoadMacro("/home/yuxip/FMS/CellScan/macros/Legal.C");
	Char_t runlist[20];
	sprintf(runlist,"fill%d.list",fillnum);
	fstream inlist(runlist,ios::in);
	if(!inlist){
		cout<<runlist<<" does not exist!!"<<endl;
		return -1;
	}	

	TH2F* 	fcmp;
	TFile* 	fcell	= 0;
	Int_t	n1 	= 0;
	Int_t	n2	= 0;
	
	Char_t outfilename[30];
	if(!strcmp(sl,"large")){
		sprintf(outfilename,"largeRateVsGcor_fill%d_n2.ps",fillnum);
		n1 = 2;
		n2 = 2;         //analysis each nstb separately
	}
	else if(!strcmp(sl,"small")){
		sprintf(outfilename,"smallRateVsGcor_fill%d_n4.ps",fillnum);
		n1 = 4;
		n2 = 4;
	}
	else{
		cout<<"invalid 2nd argument"<<endl;
		return -1;
	}
	TString outfile(outfilename);
	TString headout = outfile + "[";
	TString endout  = outfile + "]";
//	TCanvas* c1 	= new TCanvas("c1","c1",1100,1100);
	TCanvas* c1 	= new TCanvas("c1","c1",700,700);
//	c1->Divide(3,3);
//	c1->Print(headout);
	
	fstream inGcor("FmsCorr_sh.txt",ios::in);
	Int_t	iew;
	Int_t	instb;
	Int_t	ich;
	Float_t	gcorsh;
	
	Int_t	cnt	= 1;
	Int_t	cellcnt	= 0;
	Int_t	rch	= 0;
	Long_t 	runnum 	= 0;
	Char_t	cellname[30];
	Char_t	cellfile[30];
	Char_t  title[20];
	Int_t	bit	= 0;
	UChar_t status	= 0;
	Int_t	rate	= 0;
	Int_t 	Trgth	= 100;
	MyCell*	mcell	= 0;
	Float_t mycor;
	Float_t	gdiff;
//	while(inlist>>runnum){
	
	sprintf(title,"RateVsGcor_fill%d_n2",fillnum);
//	fcmp[cnt-1] = new TH2F(title,title,100,-1,1,100,0,10000);
	fcmp = new TH2F(title,title,100,-1,1,100,0,10000);
	while(inGcor>>iew>>instb>>ich>>gcorsh){
		if(instb==n1&&iew==2)break;
	}
	
	for(Int_t nstb = n1; nstb <= n2; nstb++){
		for(Int_t row0 = 0; row0 < 34; row0++){
			for(Int_t col0 = 0; col0 < 17; col0++){

				if(cellcnt)inGcor>>iew>>instb>>ich>>gcorsh;
				cellcnt++;	
				if(!Legal(2,nstb,row0,col0)){
					continue;
				}
				sprintf(cellname,"Cellr%d_c%d_n%d",row0,col0,nstb);
				cout<<"processing "<<cellname<<endl;
				if(col0==0){
					if(nstb<3){
						rch = 17*row0+col0+1;
					}
					else if(nstb<5){
						rch = 12*row0+col0+1;
					}
					cout<<"debug instb: "<<instb<<" nstb: "<<nstb<<" ich: "<<ich<<" rch: "<<rch<<" gcorsh: "<<gcorsh<<endl;
				}

				sprintf(cellfile,"../cells/Cellr%d_c%d_n%d.root",row0,col0,nstb);
					
				fcell = new TFile(cellfile,"read");
				if(!fcell){
					cout<<cellfile<<" does not exist!!"<<endl;
					return -1;
				}
				mcell = (MyCell*)fcell->Get(cellname);
				if(!mcell){
					cout<<"ERROR reading "<<cellname<<" object"<<endl;
					return -1;
				}
				mycor = mcell->GetGainCor();
				if(col0==0)cout<<"mycor: "<<mycor<<endl;
				gdiff = mycor - gcorsh;
//					status = mcell->GetStatusBit(runnum);
//					bit = (Int_t)(status&0x03); //can not be 0011
				inlist.clear();
				inlist.seekg(0,ios::beg);
				while(inlist>>runnum){
					if(col0==0)cout<<"run :"<<runnum<<endl;
					rate = mcell->GetNth(runnum,Trgth);
					fcmp->Fill(gdiff,rate);
				}
				mcell	= 0;
				status 	= 0;
				bit	= 0;
				gdiff	= 0;
				fcell->Close();
				fcell	= 0;
			}
		}
	}
//	c1->cd(cnt);
	fcmp->Draw("COLZ");
//	if(cnt%9==0){
//		c1->Print(outfile);
//		c1->Clear();
//		c1->Divide(3,3);
//		cnt = 0;
//	}
//		cnt++;
//		cout<<"============================"<<runnum<<" done.."<<endl;
//		cellcnt = 0;
//	}
	c1->Print(outfile);	
//	c1->Print(endout);
		
	return 1;
  }
Exemplo n.º 9
0
  Int_t AnalyzeCells_Fill( const char* runlist = "/home/yuxip/FMS/CellScan/macros/fill15419.list",const char* ls = "small" ){
	
	gStyle->SetPalette(1);
	gSystem->Load("../lib/libMyCellMgr.so");
	gROOT->LoadMacro("/home/yuxip/FMS/CellScan/macros/Legal.C");
	gROOT->LoadMacro("/home/yuxip/FMS/CellScan/macros/ConvertTH2Bin.C");
	mGeom = new Geom("./","geom.txt");
	cout<<"runlist: "<<runlist<<endl;
	
	Int_t fillnum = 0;
	Int_t runtoshow = 1;
	Long_t runnum = 0;
	Int_t rcnt = 0;
	sscanf(runlist,"/home/yuxip/FMS/CellScan/macros/fill%d.list",&fillnum);
	fstream infill(runlist,ios::in);
	if(!infill){
		cout<<"ERROR! "<<runlist<<" does not exist!!"<<endl;
		return -1;
	}
	while(infill>>runnum){
		rcnt++;
		if(rcnt==runtoshow)break;
	}
	cout<<"runtoshow: "<<runnum<<endl;
		
	
	Char_t outfilename[30];
	if(!strcmp(ls,"large")){
		sprintf(outfilename,"LargeCells_fill%d_run%ld_n2.ps",fillnum,runnum);
	}
	else if(!strcmp(ls,"small")){
		sprintf(outfilename,"SmallCells_fill%d_run%ld_n4.ps",fillnum,runnum);
	}
	else{
		cout<<"invalid 2nd argument!!"<<endl;
		return -1;
	}
	

	TString outfile(outfilename);
	TString headout = outfile + "[";
	TString endout = outfile + "]";
	
	TCanvas* c1 = new TCanvas("c1","c1",700,1100);
	c1->Divide(2,3);
	c1->Print(headout);
	
	Int_t ncell = 1000;		//for test only
	Int_t cellcnt  = 0;
	Char_t cellname[30];
	Char_t cellfile[30];
	TDirectory* h1where = gDirectory;
	TH1F* hmass 	= new TH1F("hmass","hmass",50,0,1);
	TH2F* hxy1	= new TH2F("hxy1","hxy1",34,-98.6,98.6,34,-98.6,98.6);
	TH2F* hxy2	= new TH2F("hxy2","hxy2",34,-98.6,98.6,34,-98.6,98.6);
	TH2F* smallxy1	= new TH2F("smallxy1","smallxy1",52,-98.6,98.6,52,-98.6,98.6);
	TH2F* smallxy2	= new TH2F("smallxy2","smallxy2",52,-98.6,98.6,52,-98.6,98.6);
	Float_t wbox 	= 12.0*3.8;

	Int_t nentries;
	Int_t 	maxy 	= 0;
	Int_t 	maxx 	= 0;
	UChar_t Status = 0x00;
	Char_t  text[30];
	MyCell* mcell 	= new MyCell();
	TTree* Trpi;
	Float_t	x2, y2;
	Int_t cnt = 1;
	Int_t n1  = 0;
        Int_t n2  = 0;

        if(!strcmp(ls,"large")){
                n1 = 2;
                n2 = 2;		//analysis each nstb separately
        }
        else if(!strcmp(ls,"small")){
                n1 = 4;
                n2 = 4;
        }
        else{
                cout<<"invalid 2nd argument"<<endl;
                return -1;
        }
	Int_t largeN1 = 0;
	Int_t smallN1 = 0;
	Int_t largeN2 = 0;
	Int_t smallN2 = 0;
	TFile* 	fcell = 0;
	MyCellEvt* mcevt = new MyCellEvt();
	
	for(Int_t nstb = n1; nstb <= n2; nstb++){
		for(Int_t row0 = 0; row0 < 34; row0++){
			for(Int_t col0 = 0; col0 < 17; col0++){

				cout<<"row0: "<<row0<<" col0: "<<col0<<" nstb: "<<nstb<<endl;
				if(!Legal(2,nstb,row0,col0)){
					continue;
				}
				cellcnt++;
				sprintf(cellname,"Cellr%d_c%d_n%d",row0,col0,nstb);
				cout<<"processing "<<cellname<<endl;
				sprintf(cellfile,"../cells/Cellr%d_c%d_n%d.root",row0,col0,nstb);
				
				fcell = new TFile(cellfile,"read");
				mcell = (MyCell*)fcell->Get(cellname);
				mcell->SetGeom(mGeom);
				mcell->Print();
				if(!mcell){
					cout<<"ERROR getting "<<cellname<<endl;
					return 0;
				}
				c1->cd(cnt);
				c1->GetPad(cnt)->SetLogy();
				c1->GetPad(cnt)->SetLogx();
				mcell->GetAdcSpectrum(runnum)->Draw();
				cnt++;
				c1->cd(cnt);
				c1->GetPad(cnt)->SetLogy();
				c1->GetPad(cnt)->SetLogx();
				mcell->GetLEDSpectrum(runnum)->Draw();
				mcell->GetLEDSpectrum(runnum)->SetLineColor(kBlue);
				Status = mcell->GetStatusBit(runnum);
				sprintf(text,"0x%x",Status);
				TLatex l(0.5,0.5,text);
				l.SetNDC();
				l.SetTextColor(2);
				l.Draw();
				cnt++;
				c1->cd(cnt);
//				c1->GetPad(cnt)->SetLogy();
				c1->GetPad(cnt)->SetFillColor(37);
				maxy = mcell->GetLEDvsEvt(runnum)->FindLastBinAbove(0,2);
				maxx = mcell->GetLEDvsEvt(runnum)->FindLastBinAbove(0,1);
				cout<<"maxx: "<<maxx<<endl;
				if(maxy < 2000){
					mcell->GetLEDvsEvt(runnum)->GetYaxis()->SetRange(0,2*maxy);
				}
				if(maxx < 2000){
					mcell->GetLEDvsEvt(runnum)->GetXaxis()->SetRange(0,(maxx+100));
				}
				
				mcell->GetLEDvsEvt(runnum)->Draw("COLZ");
				
				Trpi = mcell->GetPionSample("all",runlist);
				nentries = Trpi->GetEntries();
			//	Trpi->Print();
				cout<<"Trpi nentries: "<<nentries<<endl;
				

				if(nentries!=0){
/*
*/					
//					h1where->cd();
//					cnt++;
//					c1->cd(cnt);
//					Trpi->Project("hmass","M","");
//					hmass->Draw();
//					cnt++;
//					c1->cd(cnt);
					Float_t x1;
                                        Float_t x2;
                                        Float_t y1;
                                        Float_t y2;
					Float_t m;
					Trpi->ResetBranchAddresses();	//the orginal MergedTr was hooked up with transient member MyCellEvt of MyCell
                                        Trpi->SetBranchAddress("mycevt",&mcevt);
//                                        Trpi->SetBranchAddress("Y2",&y2);
//					Trpi->SetBranchAddress("M",&m);
                                        Trpi->SetBranchStatus("*",0);
                                        Trpi->SetBranchStatus("X2",1);
                                        Trpi->SetBranchStatus("Y2",1);
                                        Trpi->SetBranchStatus("M",1);
//					Trpi->GetEntry(0);
//					Trpi->Show(0);
//					cout<<"X2: "<<(mcevt->X2)<<", Y2: "<<(mcevt->Y2)<<", M: "<<(mcevt->M)<<endl;

					Int_t binx;
					Int_t biny;
					TString partner;
					Int_t pnstb = 0;
					Int_t prow0 = 0;
					Int_t pcol0 = 0;
					Long_t prun = 0;
					for(Int_t i = 0; i < nentries; i++){
						
						if(nstb<3){		//large cells
							if(!ConvertTH2Bin(nstb,row0,col0,binx,biny,hxy1)){
								cout<<"ERROR in ConvertTH2Bin()!"<<endl;
								return -1;
							}
							hxy1->SetBinContent(binx,biny,(hxy1->GetBinContent(binx,biny)+1));
						}

						if(nstb>2){		//small cells
							if(!ConvertTH2Bin(nstb,row0,col0,binx,biny,smallxy1)){
                                                                cout<<"ERROR in ConvertTH2Bin()!"<<endl;
                                                                return -1;
                                                        }
							smallxy1->SetBinContent(binx,biny,(smallxy1->GetBinContent(binx,biny)+1));
						}
//						cout<<"binx: "<<binx<<", biny: "<<biny<<endl;
						
						Trpi->GetEntry(i);
//						Trpi->Show(i);
						x2 = mcevt->X2;
						y2 = mcevt->Y2;
						 m = mcevt->M; 
//						cout<<"X2: "<<x2<<", Y2: "<<y2<<", M: "<<m<<endl;
						hmass->Fill(m);
						if(!mGeom->getNSTB(x2,y2))continue;	//bypass abnormal nstb
						partner = mcell->GetPartnerByXY(x2,y2,runnum);
						if(col0==0){
							cout<<"debug: partner: "<<partner<<endl;
						}
						sscanf((const char*)partner,"Cellr%d_c%d_n%d_run%ld",&prow0,&pcol0,&pnstb,&prun);
						if(col0==0){
                                                        cout<<"debug: partner (nstb,row0,col0): ("<<pnstb<<", "<<prow0<<", "<<pcol0<<") "<<endl;
                                                }

						if(!Legal(2,pnstb,prow0,pcol0)){
							cout<<"invalid partner id"<<endl;
							continue;
						}
						if(pnstb<3){             //large cells
							if(!ConvertTH2Bin(pnstb,prow0,pcol0,binx,biny,hxy2)){
                                                                cout<<"ERROR in ConvertTH2Bin()!"<<endl;
                                                                return -1;
                                                        }
							hxy2->SetBinContent(binx,biny,(hxy2->GetBinContent(binx,biny)+1));
						}
						if(pnstb>2){		//small cells
							if(!ConvertTH2Bin(pnstb,prow0,pcol0,binx,biny,smallxy2)){
                                                                cout<<"ERROR in ConvertTH2Bin()!"<<endl;
                                                                return -1;
                                                        }
							smallxy2->SetBinContent(binx,biny,(smallxy2->GetBinContent(binx,biny)+1));
						}
					}
					
					smallN1 = smallxy1->GetBinContent(smallxy1->GetMaximumBin());
					largeN1 = hxy1->GetBinContent(hxy1->GetMaximumBin());
					if(smallN1>=largeN1){
						cout<<"smallN1: "<<smallN1<<endl;
						hxy1->GetZaxis()->SetRangeUser(0,smallN1);
						smallxy1->GetZaxis()->SetRangeUser(0,smallN1);
					}
					else{
						cout<<"largeN1: "<<largeN1<<endl;
						hxy1->GetZaxis()->SetRangeUser(0,largeN1);
                                                smallxy1->GetZaxis()->SetRangeUser(0,largeN1);
					}
	
					cnt++;
                                        c1->cd(cnt);	
					hmass->Draw();

					cnt++;
                                        c1->cd(cnt);
					hxy1->SetStats(0);
					hxy1->Draw("COLZ");
					TBox bx(-wbox,-wbox,wbox,wbox);
					bx.SetFillColor(18);
					bx.Draw("same");
					smallxy1->SetStats(0);
					smallxy1->Draw("zcolsame");
				
					cnt++;
					c1->cd(cnt);
					
					largeN2 = hxy2->GetBinContent(hxy2->GetMaximumBin());
					smallN2 = smallxy2->GetBinContent(smallxy2->GetMaximumBin());
					if(smallN2>=largeN2){
						cout<<"smallN2: "<<smallN2<<endl;
                                                hxy2->GetZaxis()->SetRangeUser(0,smallN2);
                                                smallxy2->GetZaxis()->SetRangeUser(0,smallN2);
                                        }
                                        else{
						cout<<"largeN2: "<<largeN2<<endl;
                                                hxy2->GetZaxis()->SetRangeUser(0,largeN2);
                                                smallxy2->GetZaxis()->SetRangeUser(0,largeN2);
                                        }
					hxy2->SetStats(0);
					hxy2->Draw("COLZ");
					bx.Draw("same");
					smallxy2->SetStats(0);
					smallxy2->Draw("zcolsame");
				}
				largeN1 = largeN2 = 0;
				smallN1 = smallN2 = 0;
				Trpi = 0;
				c1->Print(outfile);
				mcell = 0;
				hmass->Reset();
                                hxy1->Reset();
                                hxy2->Reset();
                                smallxy1->Reset();
                                smallxy2->Reset();
				fcell->Close();
				fcell = 0;
				c1->Clear();
				c1->Divide(2,3);
				cnt = 1;
				if(cellcnt == ncell)break;
				
			}
			if(cellcnt == ncell)break;
		}
		if(cellcnt == ncell)break;
	}
	c1->Print(endout);
  	return 1;
  }
Exemplo n.º 10
0
int NextMove(MOVES *m, int *flag) {

  int move;

  switch (m->phase) {
  case 0: // return transposition table move, if legal
    move = m->trans_move;
    if (move 
    && Legal(m->p, move)) {
      m->phase = 1;
      *flag = MV_HASH;
      return move;
    }

  case 1: // helper phase: generate captures
    m->last = GenerateCaptures(m->p, m->move);
    ScoreCaptures(m);
    m->next = m->move;
    m->badp = m->bad;
    m->phase = 2;

  case 2: // return good captures, save bad ones on the separate list
    while (m->next < m->last) {
      move = SelectBest(m);

      if (move == m->trans_move)
        continue;

      if (BadCapture(m->p, move)) {
        *m->badp++ = move;
        continue;
      }
      *flag = MV_CAPTURE;
      return move;
    }

  case 3:  // first killer move
    move = m->killer1;
    if (move 
    && move != m->trans_move 
    && m->p->pc[Tsq(move)] == NO_PC 
    && Legal(m->p, move)) {
      m->phase = 4;
      *flag = MV_KILLER;
      return move;
    }

  case 4:  // second killer move
    move = m->killer2;
    if (move 
    && move != m->trans_move 
    && m->p->pc[Tsq(move)] == NO_PC 
    && Legal(m->p, move)) {
      m->phase = 5;
      *flag = MV_KILLER;
      return move;
    }

  case 5: // refutation move
    move = m->ref_move;
    if (move && move != m->trans_move 
    &&  m->p->pc[Tsq(move)] == NO_PC 
    &&  move != m->killer1
    &&  move != m->killer2
    && Legal(m->p, move)) {
      m->phase = 6;
      *flag = MV_NORMAL;
      return move;
    }

  case 6:  // helper phase: generate quiet moves
    m->last = GenerateQuiet(m->p, m->move);
    ScoreQuiet(m);
    m->next = m->move;
    m->phase = 7;

  case 7:  // return quiet moves
    while (m->next < m->last) {
      move = SelectBest(m);
      if (move == m->trans_move
      ||  move == m->killer1
      ||  move == m->killer2
      ||  move == m->ref_move)
        continue;
      *flag = MV_NORMAL;
      return move;
    }

    m->next = m->bad;
    m->phase = 8;

  case 8: // return bad captures
    if (m->next < m->badp) {
      *flag = MV_BADCAPT;
      return *m->next++;
    }
  }
  return 0;
}
Exemplo n.º 11
0
//correlations between count rate( # over threshold ) vs LED corrected gcorr, to check outliers
//--Yuxi Pan 04/03/2012
  Int_t RateVsEta(Long_t run = 12098007){

	gSystem->Load("/home/yuxip/FMS/CellScan/lib/libMyCellMgr.so");
	gROOT->LoadMacro("/home/yuxip/FMS/CellScan/macros/Legal.C");
	const char* celldir = "/home/yuxip/FMS/CellScan/cells/psu";

	TGraph*	greta[2];	//small/large
	Char_t	gname[50];
	TCanvas* c1 = new TCanvas("c1","c1",800,400);
	c1->Divide(2,1);
	Char_t 	outfilename[40];
	sprintf(outfilename,"gRateVsEta_run%ld.ps",run);
	TString outfile(outfilename);

	TFile*	fdata;
	Char_t	fdatafile[80];
	Char_t	cellname[50];
	MyCell* fcell;
	Int_t	AdcTh = 100;	//adc threshold
	Int_t	icell[2] = {0,0};

	for(Int_t sl = 0; sl < 2; sl++){
		if(sl==0){
			sprintf(gname,"RateVsEta_run%ld_LargeCells",run);
			greta[sl] = new TGraph(0);
			greta[sl]->SetTitle(gname);
		}
		else {
			sprintf(gname,"RateVsEta_run%ld_SmallCells",run);
                        greta[1] = new TGraph(0);
                        greta[1]->SetTitle(gname);
		}
	}
	
	for(Int_t nstb = 1; nstb < 5; nstb++){
					
		Int_t ls = nstb/3;
		Int_t nrow,ncol;
		if(nstb<3){
			nrow = 34;
			ncol = 17;
		}
		else{
			nrow = 24;
			ncol = 12;
		}
		for(Int_t row = 0; row < nrow; row++){
			for(Int_t col = 0; col < ncol; col++){
				if(!Legal(2,nstb,row,col))continue;
					
					sprintf(cellname,"Cellr%d_c%d_n%d",row,col,nstb);
					sprintf(fdatafile,"%s/%s.root",celldir,cellname);
					fdata = new TFile(fdatafile,"read");
					if(!fdata){
						cout<<fdatafile<<" does not exist!!"<<endl;
						return 0;
					}
					fcell = (MyCell*)fdata->Get(cellname);
					if(!fcell){
						cout<<"ERROR!! "<<cellname<<" object does not exist!!"<<endl;
						return 0;
					}	
					
					Float_t Ntriggers = fcell->GetNth(run,AdcTh);
					Float_t Eta	  = fcell->GetEta();
					if(Ntriggers>8000){
						cout<<"hot cell: "<<cellname<<endl;
						cout<<"Ntriggers	= "<<Ntriggers<<endl;
						cout<<"Eta		= "<<Eta<<endl;
					}
					//if(Eta<1||Ntriggers==0)continue;
					/*if(icell[ls]%50==0){
						cout<<"debug "<<cellname<<endl;
						cout<<"Ntriggers	= "<<Ntriggers<<endl;
						cout<<"Eta		= "<<Eta<<endl;
					}*/
					greta[ls]->SetPoint(icell[ls],Eta,Ntriggers);
					icell[ls]++;
					fdata->Close();
					delete fdata;
					fdata = 0;
				}
			}
		}
		cout<<"# large cells: "<<icell[0]<<endl;
		cout<<"# small cells: "<<icell[1]<<endl;
		for(Int_t i = 0; i < 2; i++){
			c1->cd(i+1);
			cout<<"greta["<<i<<"] Npoints: "<<greta[i]->GetN()<<endl;
			greta[i]->SetMarkerStyle(2);
			greta[i]->SetMarkerColor(i+1);
			greta[i]->Draw("Ap");
		}
	c1->Print(outfile);	
	return 1;
  }