예제 #1
0
Afileexplorer::Afileexplorer()
{
	//Layout/Geometry
	offDown = 12;
	h = 14;
	w = 160;
	
	//Graphical Elements
	TitleText = "File Explorer";
	Title = NULL;
	
	//here make the frame so its behind...
	frame = new Arect(w+2, h+offDown+2);
	frame->position.set(-1,-1,0);
	addChild(frame);
	
	//here make the frame so its behind...
	button = new Arect(h, h);
	button->color.set255(100);
	button->position.set(0,12,0);
	addChild(button);
	
	FilePath = new Atextbox();
	FilePath->color.set(1);
	FilePath->setFont("Arial", 10);
	FilePath->makeTexture( "file_path" );
	FilePath->position.set(h+2,offDown,0);
	addChild(FilePath);
	
	makeTitle();
}
예제 #2
0
void userSettingsLoadForm(struct userSettings *us)
/* Put up controls that let user name and save the current
 * set. */
{
char buf[1024];
struct hashEl *list = cartFindPrefix(us->cart, us->savePrefix);
safef(buf, sizeof(buf), "Load %s", us->formTitle);
makeTitle(buf, NULL);

/* Start form/save session/print title. */
hPrintf("<FORM ACTION=\"../cgi-bin/hgNear\" NAME=\"usForm\" METHOD=GET>\n");
cartSaveSession(us->cart);

hPrintf("<TABLE><TR><TD>\n");
hPrintf("<SELECT NAME=\"%s\" SIZE=%d>",
    us->nameVar, slCount(list));
printLabelList(us, list);
hPrintf("</SELECT>");
hPrintf("</TD><TD>");
cgiMakeButton(us->formVar, "load");
hPrintf(" ");
cgiMakeButton(us->formVar, "cancel");
hPrintf("</TD></TR></TABLE>");

/* Cleanup. */
hPrintf("</FORM>\n");
slFreeList(&list);
}
예제 #3
0
void KGrCanvas::setBaseScale ()
{
    // Synchronise the desktop font size with the initial canvas scale.
    baseScale = scaleStep;
    QString t = title->text();
    makeTitle ();
    setTitle (t);
}
예제 #4
0
void Notifications::setSong(const MPDSong &s) {
	if (m_previousSong.isNull() || m_previousSong == s || !Config::instance()->notificationsEnabled() || Config::instance()->notificationsTimeout() < 1) {
		m_previousSong = s;
		return;
	}
	if(!s.isNull())
	{
		notify(makeTitle(s));
	}
	m_previousSong = s;
}
예제 #5
0
void doAdvFilterListCol(struct sqlConnection *conn, struct column *colList,
	char *colName)
/* List a column for genes matching advanced filter. */
{
struct genePos *gp, *list = NULL, *newList = NULL, *gpNext = NULL;
struct column *col = findNamedColumn(colName);
makeTitle("Current Filters", NULL);

if (col == NULL)
    {
    warn("No name column");
    internalErr();
    }
hPrintf("<TT><PRE>");
if (gotAdvFilter())
    {
    list = advFilterResults(colList, conn);
    }
else
    {
    hPrintf("#No filters activated. List contains all genes.\n");
    list = knownPosAll(conn);
    }

/* Now lookup names and sort. */
for (gp = list; gp != NULL; gp = gpNext)
    {
    char *oldName = gp->name;
    gp->name = col->cellVal(col, gp, conn);
    gpNext = gp->next;
    if (gp->name == NULL)
	{
	warn("Unable to find cellVal for %s -- tables out of sync?",
		 oldName);
	}
    else
	{
	slAddHead(&newList,gp);
	}
    
    }
list = newList;
slSort(&list, genePosCmpName);

/* Display. */
for (gp = list; gp != NULL; gp = gp->next)
    {
    hPrintf("%s\n", gp->name);
    }
hPrintf("</PRE></TT>");
}
예제 #6
0
bool KGrCanvas::changeSize (int d)
{
#ifdef QT3
    if ((d < 0) && (scaleStep <= STEP)) {
	// Note: Smaller scales lose detail (e.g. the joints in brickwork).
	KGrMessage::information (this, i18n("Change Size"),
	i18n("Sorry, you cannot make the play area any smaller."));
	return FALSE;
    }

    if ((d >= 0) && (scaleStep >= 2 * STEP)) {
	// Note: Larger scales go off the edge of the monitor.
	KGrMessage::information (this, i18n("Change Size"),
	i18n("Sorry, you cannot make the play area any larger."));
	return FALSE;
    }

    QWMatrix wm = worldMatrix();
    double   wmScale = 1.0;

    // Set the scale back to 1:1 and calculate the new scale factor.
    wm.reset();
    scaleStep = (d < 0) ? (scaleStep - 1) : (scaleStep + 1);

    // If scale > 1:1, scale up to the new factor (e.g. 1.25:1, 1.5:1, etc.)
    if (scaleStep > STEP) {
	wmScale = (wmScale * scaleStep) / STEP;
	wm.scale (wmScale, wmScale);
    }
    setWorldMatrix (wm);

    // Force the title size and position to be re-calculated.
    QString t = title->text();
    makeTitle ();
    setTitle (t);

    // Fit the QCanvasView and its frame to the canvas.
    int frame = frameWidth()*2;
    setFixedSize ((FIELDWIDTH  + 4) * 4 * scaleStep + frame,
		  (FIELDHEIGHT + 4) * 4 * scaleStep + frame);
    return TRUE;

#else
    KGrMessage::information (this, i18n( "Change Size" ),
    i18n( "Sorry, you cannot change the size of the playing area. "
    "That function requires Qt Library version 3 or later." ));
    return FALSE;
#endif
}
예제 #7
0
void userSettingsSaveForm(struct userSettings *us)
/* Put up controls that let user name and save the current
 * set. */
{
char buf[1024];
struct hashEl *list = cartFindPrefix(us->cart, us->savePrefix);
safef(buf, sizeof(buf), "Save %s", us->formTitle);
makeTitle(buf, NULL);

/* Start form/save session/print title. */
hPrintf("<FORM ACTION=\"../cgi-bin/hgNear\" NAME=\"usForm\" METHOD=GET>\n");
cartSaveSession(us->cart);

/* Put up controls that are always there. */
hPrintf("Please name this setup:\n");
cartMakeTextVar(us->cart, us->nameVar, "", 16);
hPrintf(" ");
cgiMakeButton(us->formVar, "save");
hPrintf(" ");
cgiMakeButton(us->formVar, "cancel");

/* Put up additional controls if have saved settings already. */
if (list != NULL)
    {
    struct dyString *js = newDyString(0);

    htmlHorizontalLine();
    slSort(&list, hashElCmp);
    hPrintf("Existing Setups:");
    dyStringPrintf(js, "document.usForm.%s.value=", us->nameVar);
    dyStringPrintf(js, "document.usForm.%s.options", us->listDisplayVar);
    dyStringPrintf(js, "[document.usForm.%s.selectedIndex].value;", us->listDisplayVar);

    hPrintf("<SELECT NAME=\"%s\" SIZE=%d onchange=\"%s\">",
    	us->listDisplayVar, slCount(list), js->string);
    printLabelList(us, list);
    hPrintf("</SELECT>\n");

    cgiMakeButton(us->formVar, "delete existing setup");
    }

/* Cleanup. */
hPrintf("</FORM>\n");
slFreeList(&list);
}
예제 #8
0
void doAdvFilterKeyPaste(struct sqlConnection *conn, struct column *colList, 
    struct column *col)
/* Handle upload keyword list button press in advanced filter form. */
{
char *varName = NULL;
char buf[1024];
cartRemovePrefix(cart, keyWordPastePrefix);
safef(buf, sizeof(buf), "Paste List : %s - %s", col->shortLabel, col->longLabel);
makeTitle(buf, NULL);
hPrintf("<FORM ACTION=\"../cgi-bin/hgNear\" METHOD=POST>\n");
cartSaveSession(cart);
hPrintf("Paste in a list of items to match. ");
cgiMakeButton("submit", "submit");
hPrintf("<BR>\n");
varName = colVarName(col, keyWordPastedPrefix);
cgiMakeTextArea(varName, "", 10, 60);
hPrintf("</FORM>");
}
예제 #9
0
void doAdvFilterKeyUpload(struct sqlConnection *conn, struct column *colList, 
    struct column *col)
/* Handle upload keyword list button press in advanced filter form. */
{
char *varName = NULL;
char buf[1024];
cartRemovePrefix(cart, keyWordUploadPrefix);
safef(buf, sizeof(buf), "Upload List : %s - %s", col->shortLabel, col->longLabel);
makeTitle(buf, NULL);
hPrintf("<FORM ACTION=\"../cgi-bin/hgNear\" METHOD=POST ENCTYPE=\"multipart/form-data\">\n");
cartSaveSession(cart);
hPrintf("Enter the name of a file from your computer that contains a list");
hPrintf("of items separated by a space, tab or line.<BR>");

varName = colVarName(col, keyWordPastedPrefix);
hPrintf("<INPUT TYPE=FILE NAME=\"%s\"> ", varName);
cgiMakeButton("submit", "submit");
hPrintf("</FORM>");
}
예제 #10
0
void KGrCanvas::changeLandscape (const QString & name)
{
    for (int i = 0; strcmp (colourScheme [i], "") != 0; i++) {
	if (colourScheme [i] == name) {

	    // Change XPM colours and re-draw the tile-pictures used by QCanvas.
	    changeColours (& colourScheme [i]);
	    makeTiles();

	    // Set all cells to same tile-numbers as before, but new colours.
	    int tileNo [FIELDWIDTH] [FIELDHEIGHT];
	    int offset = border / 2;

	    for (int x = 0; x < FIELDWIDTH; x++) {
		for (int y = 0; y < FIELDHEIGHT; y++) {
		    tileNo[x][y] = field->tile (x + offset, y + offset);
		}
	    }

	    field->setTiles (bgPix, (FIELDWIDTH+border), (FIELDHEIGHT+border),
			bgw, bgh);		// Sets all tile-numbers to 0.

	    for (int x = 0; x < FIELDWIDTH; x++) {
		for (int y = 0; y < FIELDHEIGHT; y++) {
		    field->setTile (x + offset, y + offset, tileNo[x][y]);
		}
	    }

	    borderB->setBrush (QBrush (borderColor));
	    borderL->setBrush (QBrush (borderColor));
	    borderR->setBrush (QBrush (borderColor));

	    QString t = title->text();
	    makeTitle ();
	    setTitle (t);

	    // Repaint the playing area.
	    updateCanvas();
	    return;
	}
    }
}
예제 #11
0
static void addToCompilerMenu (const wchar_t *line, FarMenuItemEx *amenu, intptr_t &i, intptr_t j, const wchar_t *path, const wchar_t *fn, FarKey AccelKey)
{
	wcscpy (const_cast<wchar_t*>(amenu[i].Text), makeTitle (line, NM - 1, path, fn));
	amenu[i].UserData = j;
	amenu[i].Flags = 0;
	amenu[i].AccelKey = AccelKey;
	if (amenu[i].Text[0])
	{
		i++;
		sep = false;
	}
	else
	{
		if (!sep)
		{
			amenu[i].Flags = MIF_SEPARATOR;
			i++;
		}

		sep = true;
	}
}
GuiFriendsManagementState::GuiFriendsManagementState(Context& context):
	AbstractState(context),
	GuiAbstractState(context),
	AbstractFriendsManagementState(context),
	_buttons
	{
		{&GuiFriendsManagementState::addFriend, "Add a friend to the list"},
		{&GuiFriendsManagementState::removeFriend, "Remove selected friend"},
		{&GuiFriendsManagementState::treatRequests, "Treat friendship requests"},
		{&GuiFriendsManagementState::startChat, "Chat with selected friend"},
		{&GuiFriendsManagementState::updateFriendListBox, "Refresh list"},
		{&GuiFriendsManagementState::backMainMenu, "Back to main menu"},
	},
	_friendsListBox{std::make_shared<tgui::ListBox>()},
	_buttonsLayout{std::make_shared<tgui::VerticalLayout>()}
{
	// Get a bound version of the window size
	// Passing this to setPosition or setSize will make the widget automatically
	// update when the view of the gui changes
	auto windowWidth(tgui::bindWidth(*_context.gui));
	auto windowHeight(tgui::bindHeight(*_context.gui));

	// Make the label
	makeTitle("Friends management menu");

	// Make the buttons
	_buttonsLayout->setPosition(windowWidth/2.f, windowHeight/5.f);
	_buttonsLayout->setSize(windowWidth*(1.f/2.f - 1.f/5.f), windowHeight*3.f/4.f);
	setupButtons(_buttons, std::static_pointer_cast<tgui::Container>(_buttonsLayout));
	_context.gui->add(_buttonsLayout);

	// Make the friends list box
	_friendsListBox->setPosition(windowWidth/5.f, windowHeight/5.f);
	_friendsListBox->setSize(windowWidth*(1.f/2.f - 1.f/5.f), windowHeight*3.f/4.f);
	updateFriendListBox();
	_context.gui->add(_friendsListBox);

	registerRootWidgets({_friendsListBox, _buttonsLayout});
}
예제 #13
0
GuiLadderState::GuiLadderState(Context& context):
	AbstractState(context),
	GuiAbstractState(context),
	AbstractLadderState(context),
	_buttons
	{
		{&GuiLadderState::backMainMenu, "Back to main menu"}
	},
	_ladderHeader(),
	_panel{std::make_shared<tgui::Panel>()},
	_scrollbar{std::make_shared<tgui::Scrollbar>()},
	_ladderLayout{std::make_shared<tgui::VerticalLayout>()}
{
	auto windowWidth(tgui::bindWidth(*_context.gui));
	auto windowHeight(tgui::bindHeight(*_context.gui));
	float lineHeight = 25;

	// Make the title
	makeTitle("Ladder", 30U, 30.f);

	// Make the button(s)
	setupButtons(_buttons, std::static_pointer_cast<tgui::Container>(_context.gui->getContainer()));
	_buttons[0].button->setPosition(windowWidth/5.f, windowHeight - 30.f);
	_buttons[0].button->setSize(windowWidth * 3.f/5.f, 20.f);

	// Make the panel
	_panel->setPosition(windowWidth/20.f, 70.f);
	_panel->setSize(windowWidth * 18.f/20.f, windowHeight - 110.f);
	_panel->setBackgroundColor(sf::Color::Transparent);
	_context.gui->add(_panel);

	// Make the ladder header
	_ladderHeader.rankLabel->setText("Rank");
	_ladderHeader.playerNameLabel->setText("Player's name");
	_ladderHeader.wonGamesLabel->setText("Won");
	_ladderHeader.playedGamesLabel->setText("Played");
	_ladderHeader.ratioLabel->setText("Ratio");

	_ladderHeader.layout->setPosition(0.f, 0.f);
	_ladderHeader.layout->setSize(tgui::bindWidth(_panel) - 5, lineHeight);
	_panel->add(_ladderHeader.layout);


	// make the layout
	_ladderLayout->setPosition(0.f, lineHeight);
	_ladderLayout->setSize(tgui::bindWidth(_panel) - 5.f, lineHeight * static_cast<float>(_ladder.size()));
	_panel->add(_ladderLayout);

	// Make the scrollbar
	_scrollbar->setPosition(tgui::bindRight(_panel), tgui::bindTop(_panel) + lineHeight);
	_scrollbar->setSize((windowWidth - tgui::bindRight(_panel)) / 2.f, tgui::bindHeight(_panel) - lineHeight);
	_scrollbar->setOpacity(0.3f);
	_scrollbar->setLowValue(static_cast<unsigned int>(_panel->getSize().y));
	_scrollbar->setMaximum(static_cast<unsigned int>(lineHeight) * static_cast<unsigned int>(_ladder.size()));
	_scrollbar->setArrowScrollAmount(30);
	_scrollbar->connect("ValueChanged", &GuiLadderState::scrollGrid, this);
	_scrollbar->setAutoHide(false);
	context.gui->add(_scrollbar);

	// add entries to the layout
	for(std::size_t i{0}; i < _ladder.size(); ++i)
	{
		GuiLadderEntry guiLadderEntry;
		if(i%2 == 0)
			guiLadderEntry.setBackgroundColor({200, 200, 200});

		guiLadderEntry.rankLabel->setText(std::to_string(i + 1) + ".");
		guiLadderEntry.playerNameLabel->setText(_ladder[i].name);
		guiLadderEntry.wonGamesLabel->setText(std::to_string(_ladder[i].victories));
		guiLadderEntry.playedGamesLabel->setText(std::to_string(_ladder[i].victories + _ladder[i].defeats));
		guiLadderEntry.ratioLabel->setText(std::to_string(static_cast<float>(_ladder[i].victories) / static_cast<float>(_ladder[i].defeats+_ladder[i].victories)));
		_ladderLayout->add(guiLadderEntry.layout);
	}
	_ladderLayout->showWithEffect(tgui::ShowAnimationType::SlideFromBottom, sf::milliseconds(500));

	registerRootWidgets({_panel, _buttons[0].button, _scrollbar});
}
예제 #14
0
plFgtSSim( int page=3,char *core="m1",int pl=0){ //1=gif, 2=ps, 3=both
  
  char *path="./";
  //char *path="/star/data05/scratch/balewski/fgtEveGen/";
  // core="Wprod_b";
  core="QCDprod_c_Pt20"; 
  core="pp200_QCDprodMBc";
  TString fullInpName=path;  fullInpName+=core;
  fullInpName+=".fgt.hist.root";

  double seedThres=30; // for pages>100

  fd=new TFile(fullInpName);
  if(! fd->IsOpen()) {
    printf("EROR: input histo file not found, quit\n",fullInpName.Data());
    return;
  }
  // fd->ls();
  gStyle->SetPalette(1,0);

  char *nameA[]={"ss_inDE","ss_inDS","ss_inZ","ss_hitStat","ss_inXY","ss_cTof","ss_inR","ss_cPmag","ss_gXY1"};
  char *nameB[]={"fr_pairEne","fr_nPrimPair", "fr_totEne","fr_nTotPair","fr_pathL","fr_avrTPath"};
  char *nameC[]={"ss_hitStat","cl_Stat1D","ev_Stat1D"};

  
  switch (page) {    
  case 1:{ // general stats from all disks
    can=new TCanvas("aa","aa",800,500);    TPad *c=makeTitle(can,core,page);
    c->Divide(1,2);gStyle->SetOptStat(111111);
    char **nameX=nameC;
    for(int i=0;i<1;i++) { // tmp, w/o clust-finder
      printf("->%s<\n",nameX[i]);
      h=(TH1*)fd->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
    } 
    break;
  }//--------------------------------------



  case 2:{ // g2t track properties
    can=new TCanvas("aa","aa",720,700);   TPad *c=makeTitle(can,core,page);
    c->Divide(3,3);
    char **nameX=nameA;
    int i;
    for(i=0;i<9;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)fd->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      if(i==4|| i==8)  h->Draw("colz"); 
      if(i==3 ||i==6) 	if(h->GetEntries()>0) c->GetPad(1+i)->SetLogz();      
    } 
    break;
  }//--------------------------------------

  case 3: { //  EVENT: 2D digitalization
    can=new TCanvas("aa","aa",800,420);    TPad *c=makeTitle(can,core,page);
    c->Divide(2,1);
    //c->cd(1);ss_inXY->Draw("colz"); //ss_inXY->Rebin2D();
    c->cd(2);digXYAll->Draw("colz"); gPad->SetLogz(); //digXYAll->Rebin2D(4,4);
      

    break;
  }//--------------------------------------

  case 33: { //  testing strip mapping
    can=new TCanvas("aa","aa",600,600);    TPad *c=makeTitle(can,core,page);
    digXY->Draw("colz"); 
    digXY->SetAxisRange(23,30,"y"); digXY->SetAxisRange(23,30,"x"); // zoom-in box 1
    //digXY->SetAxisRange(37,38.5,"y"); digXY->SetAxisRange(0,5,"x"); // zoom-in box 2
    //digXY->SetAxisRange(11,12.5,"y"); digXY->SetAxisRange(0,5,"x"); // zoom-in box 3

    // final plots P-plane - Rmid-zoom
    //digXY->SetAxisRange(1,3,"y"); digXY->SetAxisRange(18,20,"x"); // zoom-in box 3
     //digXY->SetAxisRange(1,3,"x"); digXY->SetAxisRange(18,20,"y"); // zoom-in box 3

    break;
  }//--------------------------------------

  case 4: { //  G-hits accepted per disc
    can=new TCanvas("aa","aa",950,620);    TPad *c=makeTitle(can,core,page);
    gStyle->SetOptStat(1000010);
    c->Divide(3,2);
    for(int id=0; id<6;id++) {
      c->cd(id+1); 
      h=(TH2*)fd->Get(Form("ss_gXY%d",id+1));  assert(h);
      h->Draw("colz"); //h->Scale(2.5);
    }
    // c->cd(2); ss_gXY1->Draw("colz"); c->cd(5); ss_gXY6->Draw("colz"); // tmp change
    //c->cd(2); ss_gXY0->Draw("colz"); c->cd(5); ss_gXY5->Draw("colz"); // tmp change
    break;
  }//--------------------------------------

    
  case 5:{ // properties of Frank's hit distribution generator
    gStyle->SetOptStat(110);
    can=new TCanvas("aa","aa",800,500);    TPad *c=makeTitle(can,core,page);
    c->Divide(3,2);
    char **nameX=nameB;
    for(int i=0;i<6;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)fd->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      if(i==5) { h->SetAxisRange(0,2);} //h->Fit("gaus");
    } 
    break;
  }//--------------------------------------

  case 6: { //  projection  on rad & phi strips
    can=new TCanvas("aa","aa",800,420);    TPad *c=makeTitle(can,core,page);
    c->Divide(1,2);gStyle->SetOptStat(1001111);
    c->cd(1);digRAll->Draw();
    c->cd(2);digPAll->Draw();
    break;
  }//--------------------------------------

  case 7: { //  ADC sums per plane
    can=new TCanvas("aa","aa",800,420);    TPad *c=makeTitle(can,core,page);
    c->Divide(1,2);gStyle->SetOptStat(1001111);
    c->cd(1);dg_Padc->Draw();
    c->cd(2);dg_Radc->Draw();
    break;
  }//--------------------------------------



  case 107: { // R-cluster finder properties
    can=new TCanvas("aa","aa",800,550);    TPad *c=makeTitle(can,core,page);
    c->Divide(3,2);gStyle->SetOptStat(111111);
    c->cd(1);cl_RmxAmp->Draw();
    cl_RmxAmp->Fit("landau","R","",seedThres,99999);
    // c->cd(2);cl_rMul->Draw();
    c->cd(2);cl_Rwid->Draw();
    c->cd(4);cl_Rpf->Draw();
    c->cd(5);//ev_errRad->Fit("gaus","R","",-80,80);//Draw();
    ev_errRad->Rebin(3);
    ev_errRad->Fit("gaus");
    c->cd(6);ev_dRad_R->Draw("colz");
    break;
  }//--------------------------------------


  case 108: { // Phi-cluster finder properties
    can=new TCanvas("aa","aa",800,550);    TPad *c=makeTitle(can,core,page);
    c->Divide(3,2);gStyle->SetOptStat(111111);
    c->cd(1);cl_PmxAmp->Draw();cl_PmxAmp->Fit("landau","R","",seedThres,99999);
    // c->cd(2);cl_pMul->Draw();
    c->cd(2);cl_Pwid->Draw();
    c->cd(4);cl_Ppf->Draw(); // fr_Rdiff->Draw("colz");
    c->cd(5);ev_RerrPhi->Fit("gaus","R","",-100,100);//->Draw();
    c->cd(6);ev_RdPhi_R->Draw("colz");
    break;
  }//--------------------------------------


  case 109: { // Rad vs. Phi-cluster finder properties
   can=new TCanvas("aa","aa",500,280);    TPad *c=makeTitle(can,core,page);
    c->Divide(2,1);gStyle->SetOptStat(111111);
    c->cd(1);cl_rpMul->Draw("colz");
   
     break;
  }//--------------------------------------


  case 110: { // Rad err vs. R
    can=new TCanvas("aa","aa",800,420);    TPad *c=makeTitle(can,core,page);
    c->Divide(2,1);gStyle->SetOptStat(0);gStyle->SetOptFit(1);
    int nReb=4;
    c->cd(1);spreadFit(ev_dRad_R->RebinX(nReb,"dRreb")); 
    c->cd(2);spreadFit(ev_RdPhi_R->RebinX(nReb,"RdPreb"));
     break;
  }//--------------------------------------


  case 101: { // tmp1
    can=new TCanvas("aa","aa",1100,850);    TPad *c=makeTitle(can,core,page);
    c->Divide(3,2);gStyle->SetOptStat(111111);
    c->cd(1);cl_rpMul->Draw("colz");
    c->cd(4);ev_Stat1D->Draw(); ev_Stat1D->SetAxisRange(0,6);
    float yy=ev_Stat1D->GetMaximum();
    ev_Stat1D->SetMinimum(yy*.75);
    c->cd(2);ev_errRad->Fit("gaus","R","",-200,200);//Draw();
    c->cd(3);ev_dRad_R->Draw("colz");

    c->cd(5);ev_RerrPhi->Fit("gaus","R","",-60,60);//->Draw();
    c->cd(6);ev_RdPhi_R->Draw("colz");

    break;
  }//--------------------------------------

  case 102: { // tmp1
    can=new TCanvas("aa","aa",500,280);    TPad *c=makeTitle(can,core,page);
    c->Divide(2,1);
    c->cd(1);cl_RmxAmp->Fit("landau","R","",seedThres,99999);
    c->cd(2);cl_PmxAmp->Fit("landau","R","",seedThres,99999);

    break;
  }//--------------------------------------

  case 103: { // tmp1
    can=new TCanvas("aa","aa",1100,400);    TPad *c=makeTitle(can,core,page);
    c->Divide(3,1);gStyle->SetOptStat(1111);
    c->cd(1);ev_Stat1D->Draw(); ev_Stat1D->SetAxisRange(0,6);
    float yy=ev_Stat1D->GetMaximum();
    ev_Stat1D->SetMinimum(yy*.75);
    c->cd(2);ev_errRad->Fit("gaus","R","",-200,200);//Draw();
    c->cd(3);ev_RerrPhi->Fit("gaus","R","",-60,60);//->Draw();

    break;
  }//--------------------------------------

  case 104: { // tmp1
    can=new TCanvas("aa","aa",900,750);    TPad *c=makeTitle(can,core,page);
    c->Divide(3,2);gStyle->SetOptStat(1111);
    c->cd(1);cl_RmxAmp->Fit("landau","R","",seedThres,99999);
    c->cd(2);cl_Rpf->Draw();
    c->cd(3);ev_errRad->Fit("gaus","R","",-200,200);

    c->cd(4);cl_PmxAmp->Fit("landau","R","",seedThres,99999);
    c->cd(5);cl_Ppf->Draw();
    c->cd(6);ev_RerrPhi->Fit("gaus","R","",-80,80);

    break;
  }//--------------------------------------

  case 105: { // tmp1
    can=new TCanvas("aa","aa",1100,800);    TPad *c=makeTitle(can,core,page);
    c->Divide(3,2);gStyle->SetOptStat(111111);
    c->cd(4);ev_RokXY->Draw("colz"); //  ev_RokXY->Rebin2D(2,2);
 
    c->cd(1);ev_Stat1D->Draw(); ev_Stat1D->SetAxisRange(0,6);
    float yy=ev_Stat1D->GetMaximum();
    ev_Stat1D->SetMinimum(yy*.75);

    int nReb=4;
    c->cd(2);ev_RerrPhi->Fit("gaus","R","",-100,100);//->Draw();
    // ev_RdPhi_R->RebinY(2);
    c->cd(3);spreadFit(ev_RdPhi_R->RebinX(nReb,"RdPreb"),370);

    c->cd(5);ev_errRad->Fit("gaus","R","",-300,300);//Draw();
    c->cd(6);spreadFit(ev_dRad_R->RebinX(nReb,"dRreb"),370); 

    break;
  }//--------------------------------------


  default:
    printf("page=%d NOT defined\n",page);
 
  }

  char text[100];
  sprintf(text,"%s_page%03d",core,page);
  TString tit=text;
  can->SetTitle(tit);
  can->SetName(tit);
  //  c->Clear();
  
  if(pl&1) can->Print(tit+".gif");
  if(pl&2) can->Print(tit+".ps");
  
}
예제 #15
0
void Afileexplorer::makeTitle(std::string T)
{
	TitleText = T;
	makeTitle();
}
예제 #16
0
void KGrCanvas::initView()
{
    changeColours (& colourScheme [0]);		// Set "KGoldrunner" landscape.

    // Set up the pixmaps for the editable objects.
    freebg	= 0;		// Free space.
    nuggetbg	= 1;		// Nugget.
    polebg	= 2;		// Pole or bar.
    ladderbg	= 3;		// Ladder.
    hladderbg	= 4;		// Hidden ladder (for editing).
    edherobg	= 5;		// Static hero (for editing).
    edenemybg	= 6;		// Static enemy (for editing).
    betonbg	= 7;		// Concrete.

    // The bricks have 10 pixmaps (showing various stages of digging).
    brickbg	= 8;		// Solid brick - 1st pixmap.
    fbrickbg	= 15;		// False brick - 8th pixmap (for editing).

    QPixmap pixmap;
    QImage image;

    pixmap = QPixmap (hgbrick_xpm);

    bgw = pixmap.width();	// Save dimensions for "getPixmap".
    bgh = pixmap.height();
    bgd = pixmap.depth();

    // Assemble the background and editing pixmaps into a strip (18 pixmaps).
    bgPix	= QPixmap ((brickbg + 10) * bgw, bgh, bgd);

    makeTiles();		// Fill the strip with 18 tiles.

    // Define the canvas as an array of tiles.  Default tile is 0 (free space).
    int frame = frameWidth()*2;
    field = new QCanvas ((FIELDWIDTH+border) * bgw, (FIELDHEIGHT+border) * bgh);
    field->setTiles (bgPix, (FIELDWIDTH+border), (FIELDHEIGHT+border),
			bgw, bgh);

    // Embed the canvas in the view and make it occupy the whole of the view.
    setCanvas (field);
    setVScrollBarMode (QScrollView::AlwaysOff);
    setHScrollBarMode (QScrollView::AlwaysOff);
    setFixedSize (field->width() + frame, field->height() + frame);

    //////////////////////////////////////////////////////////////////////////
    // The pixmaps for hero and enemies are arranged in strips of 20: walk  //
    // right (4), walk left (4), climb right along bar (4), climb left (4), //
    // climb up ladder (2) and fall (2) --- total 20.                       //
    //////////////////////////////////////////////////////////////////////////

    // Convert the pixmap strip for hero animation into a QCanvasPixmapArray.
    pixmap = QPixmap (hero_xpm);
    image = pixmap.convertToImage ();

#ifdef QT3
    QPixmap   pm;
    QValueList<QPixmap> pmList;

    for (int i = 0; i < 20; i++) {
	pm.convertFromImage (image.copy (i * 16, 0, 16, 16));
	pmList.append (pm);
    }

    heroArray = new QCanvasPixmapArray (pmList);	// Hot spots all (0,0).
#else
    QPixmap * pm;
    QPoint  * pt;
    QList<QPixmap> pmList;
    QList<QPoint>  ptList;

    pt = new QPoint (0, 0);		// "Hot spot" not used in KGoldrunner.

    for (int i = 0; i < 20; i++) {
	pm = new QPixmap ();
	pm->convertFromImage (image.copy (i * 16, 0, 16, 16));
	pmList.append (pm);
	ptList.append (pt);
    }

    heroArray = new QCanvasPixmapArray (pmList, ptList);
#endif

    // Convert pixmap strips for enemy animations into a QCanvasPixmapArray.
    // First convert the pixmaps for enemies with no gold ...
    pixmap = QPixmap (enemy1_xpm);
    image = pixmap.convertToImage ();

    pmList.clear();

#ifdef QT3
    for (int i = 0; i < 20; i++) {
	pm.convertFromImage (image.copy (i * 16, 0, 16, 16));
	pmList.append (pm);
    }
#else
    ptList.clear();

    for (int i = 0; i < 20; i++) {
	pm = new QPixmap ();
	pm->convertFromImage (image.copy (i * 16, 0, 16, 16));
	pmList.append (pm);
	ptList.append (pt);
    }
#endif

    // ... then convert the gold-carrying enemies.
    pixmap = QPixmap (enemy2_xpm);
    image = pixmap.convertToImage ();

#ifdef QT3
    for (int i = 0; i < 20; i++) {
	pm.convertFromImage (image.copy (i * 16, 0, 16, 16));
	pmList.append (pm);
    }

    enemyArray = new QCanvasPixmapArray (pmList);	// Hot spots all (0,0).
#else
    for (int i = 0; i < 20; i++) {
	pm = new QPixmap ();
	pm->convertFromImage (image.copy (i * 16, 0, 16, 16));
	pmList.append (pm);
	ptList.append (pt);
    }

    enemyArray = new QCanvasPixmapArray (pmList, ptList);
#endif

    goldEnemy = 20;			// Offset of gold-carrying frames.

    // Draw the border around the playing area (z = 0).
    makeBorder();

    // Create a title item, in off-white colour, on top of the border.
    title = 0;
    makeTitle();

    // Create an empty list of enemy sprites.
#ifdef QT3
    enemySprites = new QPtrList<QCanvasSprite> ();
#else
    enemySprites = new QList<QCanvasSprite> ();
#endif
    enemySprites->setAutoDelete(TRUE);
}
예제 #17
0
//=================================================
plPubJS(  int page=1,int pl=0, char *core0="R10103042", char *iPath="", char *oPath=""){ //1=gif, 2=ps, 3=both
  //char *iPath="/star/data05/scratch/stevens4/wAnalysisOut/data/";
  //char *iPath="/star/u/stevens4/wAnalysis/out/verB4.3/useEtow2allLT20/";
  //char *iPath="/star/u/stevens4/wAnalysis/out/verB4.3/useEtow1/";
  char *iPath="/star/u/stevens4/wAnalysis/out/verB4.3/enhanceQCD/";
  //char *iPath="/star/u/stevens4/wAnalysis/out/";
  //core0="R10097000";
  core0="run9setABCD";
  //core0="mcSetD1_ppWprod";
  //core0="mcSetD2_ppQCD10_inf_filter";
  //core0="mcSetD1_ppZprod";
  if(page==0) {
    doAll(pl);
    return;
  }
  
  /*
    
  cat run9setABCD*ps | ps2pdf - all.pdf
  mv all.pdf ~/stevens4/tmp/all-run9setABCD-pub.pdf
  
  */
  
  
  char *nameA[]={"JSetowEneZ1","JSetowEneZ2","JSetowEneZ3","JSetowEneZ4"};
  char *nameB[]={"JSetowHighPostTr","JSetowTotPostTr","JSetowHighPreNear","JSetowTotPreNear"};
  char *nameC[]={"JSetowHighPreAway","JSetowTotPreAway"};
  char *nameD[]={"JSawayNTow","JSawayNTr"};
  //char *nameD[]={"JSawayNTow","JSawayNTr","JSnearNTow","JSnearNTr"};
  char *nameE[]={"JSawayCond1","JSawayCond2"};

  gStyle->SetOptFit(1);
  TString fullInpName=iPath;  fullInpName+=core0;
  fullInpName+=".wana.hist.root";  
  fd=new TFile(fullInpName);
  if(! fd->IsOpen()) {
    printf("EROR: input histo file not found, quit\n",fullInpName.Data());
    return;
  } else {
    printf("Opened: %s\n",fullInpName.Data());
  }

  TLine *ln; TList *Lx;

  gStyle->SetPalette(1,0);
  //gStyle->SetOptStat(0);
  char padTit[1000];
  sprintf(padTit,"%s",core0);
  
  switch (page) {
    
  case 1:{ sprintf(padTit,"ETOW Gain Study I, %s",core0);
  can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
  c->Divide(2,2);gStyle->SetOptStat(1);
  char **nameX=nameA;
  for(int i=0;i<4;i++) {
    char txt[100]; int xInt=0;
    printf("->%s<\n",nameX[i]);
    h=(TH1*)fd->Get(nameX[i]);  assert(h);
    TAxis* axX=h->GetXaxis();  int nbX=axX->GetNbins();
    float entries= h->GetEntries();
    for(int j=nbX; j>0; j--){
      xInt += h->GetBinContent(j);
      //if(i==0) cout<<j<<" "<<xInt<<endl;
      if(xInt > 0.0005*entries) 
	{float bin=j; break;}
    }
    cout<<i+1<<" 0.01% of counts in energy = "<<bin/10<<" bin"<<endl;
    Lx=h->GetListOfFunctions();
    ln=new TLine(bin/10,0,bin/10,1.e6);  ln->SetLineColor(kRed);  Lx->Add(ln);

    c->cd(i+1); h->Draw();
    c->GetPad(i+1)->SetLogy();
  }
  
  } break;//--------------------------------------
  
  case 2:{ sprintf(padTit,"ETOW Gain Study II, %s",core0);  
  can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
  gStyle->SetOptStat(0); int entries=0;
  leg = new TLegend(0.6,0.7,.9,.9);
  leg->SetHeader("Z vertex range (cm)");
  char **nameX=nameA;
  for(int i=0;i<4;i++) {
    char txt[100]; string entry;
    printf("->%s<\n",nameX[i]);
    h=(TH1*)fd->Get(nameX[i]);  assert(h);
    h->Rebin(10);
    if(i==0) entry="[-100,-50]"; if(i==1) entry="[-50,0]";
    if(i==2) {entry="[0,50]"; h->SetLineStyle(2);} 
    if(i==3) {entry="[50,100]"; h->SetLineStyle(2);}
    
    if(i==0) {h->Draw(); entries=h->GetEntries(); gPad->SetLogy(); h->SetTitle("Normalized Endcap Tower E");}
    else { h->SetLineColor(i+1); h->DrawNormalized("same",entries);}
    leg->AddEntry(h,Form("%s",entry),"l");
  }
  leg->Draw();
  } break;//--------------------------------------

  case 3:{ sprintf(padTit,"Beam Background I, %s",core0);  
  can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
  c->Divide(2,2); gStyle->SetOptStat(10);
    char **nameX=nameB;
    for(int i=0;i<4;i++) {
      char txt[100];
      printf("->%s<\n",nameX[i]);
      h=(TH1*)fd->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw("colz");
    }
  } break;//--------------------------------------
  
  case 4:{ sprintf(padTit,"Beam Background II, %s",core0);   
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,2); gStyle->SetOptStat(10);
    char **nameX=nameC;
    for(int i=0;i<2;i++) {
      char txt[100];
      printf("->%s<\n",nameX[i]);
      h=(TH1*)fd->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw("colz");
    }  
  } break;//--------------------------------------

  case 5:{ sprintf(padTit,"Away Side Counters, %s",core0);   
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,1);//gStyle->SetOptStat(0);
    char **nameX=nameD;
    for(int i=0;i<2;i++) {
      char txt[100];
      printf("->%s<\n",nameX[i]);
      h=(TH1*)fd->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      c->GetPad(i+1)->SetLogy();
    }  
  } break;//--------------------------------------

  case 6:{ sprintf(padTit,"Away Side Conditions, %s",core0);   
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,2);//gStyle->SetOptStat(0);
    char **nameX=nameE;
    for(int i=0;i<2;i++) {
      char txt[100];
      printf("->%s<\n",nameX[i]);
      h=(TH1*)fd->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
    }  
  } break;//--------------------------------------
    
    
    
  default:
    printf("page=%d NOT defined\n",page);
    return;
  }
  
 char text[100];
 sprintf(text,"%s%s_page%03d",oPath,core0,page);
 TString tit=text;
 can->SetTitle(tit);
 can->SetName(tit);

 
 if(pl&1) can->Print(tit+".gif");
 if(pl&2) can->Print(tit+".ps");
 
}
예제 #18
0
//=================================================
plWjj(  int page=2,int pl=0, char *core0="R10096140", char *iPath="", char *oPath=""){ //1=gif, 2=ps, 3=both
  iPath="./";
  //iPath="/star/data05/scratch/balewski/2009-Wana-SL09g-s1/data/";
  core0="sumRun9_may1";
  //  core0="sumW";
  core0="rcn10017_10_500evts";// Z->any
  //core0="rcm10019_65_1000evts";// QCD ^^^10
  //core0="rcn10020_13_300evts";// QCD ^^^5
  //core0="rcn10017_35_500evts";// W->any

  if(page==0) {
    doAll();
    return;
  }
  

  char *nameA[]={"WjjStatEve"}; //pg 1
  char *nameB[]={"Wjj_J1","Wjj_J2","Wjj_K1","Wjj_K6","Wjj_K5","Wjj_K3"};//pg2
  char *nameC[]={"Wjj_3J","Wjj_K4","Wjj_K2","Wjjphi12"};//pg3
  char *nameD[]={"Wjj_K1","Wjj_P1","Wjj_P2","Wjj_P4","Wjj_P3"};//pg4
  
  
  //C2??


  gStyle->SetOptFit(1);
  TString fullInpName=iPath;  fullInpName+=core0;
  fullInpName+=".wana.hist.root";  
  fd=new TFile(fullInpName);
  if(! fd->IsOpen()) {
    printf("EROR: input histo file not found, quit\n",fullInpName.Data());
    return;
  } else {
    printf("Opened: %s\n",fullInpName.Data());
  }
  if(page==1){ 
   fd->ls(); 
   h0=(TH1*)fd->Get(ver+"WjjStatEve"); assert(h0);
   printf("%s: ",h0->GetName());
   for(int k=1;k<=h0->GetXaxis()->GetNbins();k++) printf("%.0f, ",h0->GetBinContent(k));
   printf("\n");
 }
 gStyle->SetPalette(1,0);
 gStyle->SetOptStat(0);
 char padTit[1000];
 sprintf(padTit,"%s %s",ver.Data(),core0);

 switch (page) {

 case 1:{   
    can=new TCanvas("aa","aa",800,400);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(1,1);gStyle->SetOptStat(0);
    char **nameX=nameA;
    for(int i=0;i<1;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)fd->Get(ver+nameX[i]);  assert(h);
      c->cd(i+1); h->Draw(); gPad->SetTopMargin(0.2);
      if(i==0) h->Draw("h text");
    }
    c->GetPad(1)->SetLogy();
   
 } break;//--------------------------------------

 case 2:{   
    can=new TCanvas("aa","aa",900,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(3,2);gStyle->SetOptStat(1110);
    char **nameX=nameB;
    for(int i=0;i<6;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)fd->Get(ver+nameX[i]);  assert(h);
      c->cd(i+1); h->Draw("colz");
      if(i==2) h->Draw();
      if(i==2){  h->SetAxisRange(0,180); h->SetMinimum(0.9);}// h->Fit("gaus","","RH",60,110);}
      if(i>=4) ((TH2F*)h)->Rebin2D();
      c->GetPad(i+1)->SetRightMargin(0.15);
    }

    if(strstr(core0,"sumR")) c->GetPad(3)->SetLogy();
   
 } break;//--------------------------------------


 case 3:{   
    can=new TCanvas("aa","aa",700,500);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(3,2);gStyle->SetOptStat(1110);
    char **nameX=nameC;
    for(int i=0;i<4;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)fd->Get(ver+nameX[i]);  assert(h);
      c->cd(i+1);
      h->Draw("colz");
      if(i==3) h->Draw();
    }
 } break;//--------------------------------------

   case 4:{   
     can=new TCanvas("aa","aa",700,500);    TPad *c=makeTitle(can,padTit,page);
     c->Divide(3,2);gStyle->SetOptStat(1110);
     char **nameX=nameD;
     for(int i=0;i<5;i++) {
       printf("->%s<\n",nameX[i]);
       h=(TH1*)fd->Get(ver+nameX[i]);  assert(h);
       c->cd(i+1);
       h->Draw();
       if(i==3) h->Draw("colz");
     }
   } break;//--------------------------------------
   



 default:
     printf("page=%d NOT defined\n",page);

 }

 char text[100];
 sprintf(text,"%s%s_page%03d_%s",oPath,core0,page,ver.Data());
 TString tit=text;
 can->SetTitle(tit);
 can->SetName(tit);

 
 if(pl&1) can->Print(tit+".gif");
 if(pl&2) can->Print(tit+".ps");
 
}
예제 #19
0
파일: search.c 프로젝트: elmargb/kentUtils
static void searchAllColumns(struct sqlConnection *conn, 
	struct column *colList, char *search)
/* Call search on each column. */
{
struct column *col;
struct searchResult *srList, *sr;
struct columnSearchResults *csrList = NULL, *csr;
int totalCount = 0;
struct searchResult *srOne = NULL;

for (col = colList; col != NULL; col = col->next)
    {
    if (col->simpleSearch)
	 {
         srList = col->simpleSearch(col, conn, search);
	 if (showOnlyCanonical() && srList != NULL)
	     {
	     transformToCanonical(srList, conn);
	     srList = removeDupes(srList);
	     }
	 if (srList != NULL)
	     {
	     srOne = srList;
	     fillInMissingLabels(conn, colList, srList);
	     AllocVar(csr);
	     csr->label = columnSetting(col, "searchLabel", col->longLabel);
	     csr->results = srList;
	     slAddTail(&csrList, csr);
	     totalCount += slCount(srList);
	     }
	 }
    }
if (totalCount == 0)
    {
    displayData(conn, colList, NULL);
    if (anyWild(search))
        warn("Sorry, the search box doesn't take wildcards, "
	     "though in most cases it will find things without "
	     "them.  Try entering your search without * or ? "
	     "characters.");
    else
	warn("Sorry, couldn't find '%s'", search);
    }
else if (totalCount == 1 || allSame(csrList))
// else if (totalCount == 1)
    displayData(conn, colList, &srOne->gp);
else
    {
    makeTitle("Simple Search Results", NULL);
    for (csr = csrList; csr != NULL; csr = csr->next)
        {
	hPrintf("<H2>%s</H2>\n", csr->label);
	slSort(&csr->results, searchResultCmpShortLabel);
	for (sr = csr->results; sr != NULL; sr = sr->next)
	    {
	    selfAnchorSearch(&sr->gp);
	    if (sr->matchingId != NULL)
		hPrintf("%s (%s)", sr->matchingId, sr->shortLabel);
	    else
		hPrintf("%s", sr->shortLabel);
	    hPrintf("</A> - %s<BR>\n", sr->longLabel);
	    }
	}
    }
}
예제 #20
0
void doAdvFilter(struct sqlConnection *conn, struct column *colList)
/* Put up advanced filter page. */
{
struct column *col;
boolean passPresent[2];
int onOff = 0;

makeTitle("Gene Sorter Filter", "hgNearHelp.html#Filter");
hPrintf("<FORM ACTION=\"../cgi-bin/hgNear\" METHOD=%s>\n",
	cartUsualString(cart, "formMethod", "POST"));
cartSaveSession(cart);

controlPanelStart();
hPrintf("On this page you can restrict which genes appear in the main table<BR>");
hPrintf("based on the values in any column. Click the <em>submit</em> button to return<BR>");
hPrintf("to the main Gene Sorter page with the current filter settings applied.");
bigButtons();
hPrintf("Quickly obtain a list of gene "
 "names that pass the filter: ");
cgiMakeButton(advFilterListVarName, "list names");
controlPanelEnd();

/* See if have any to do in either first (displayed columns)
 * or second (hidden columns) pass. */
passPresent[0] = passPresent[1] = FALSE;
for (onOff = 1; onOff >= 0; --onOff)
    {
    for (col = colList; col != NULL; col = col->next)
        if (col->filterControls && col->on == onOff)
	    passPresent[onOff] = TRUE;
    }

/* Print out two tables of search controls - one for displayed
 * columns and one for hidden ones. */
for (onOff = 1; onOff >= 0; --onOff)
    {
    if (passPresent[onOff])
	{
	hPrintf("<H2>Filter Controls for %s Columns:</H2>", 
		(onOff ? "Displayed" : "Hidden"));
	hPrintf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=2 BGCOLOR=\"#"HG_COL_INSIDE"\">\n");
	for (col = colList; col != NULL; col = col->next)
	    {
	    if (col->filterControls && col->on == onOff)
		{
		hPrintf("<TR><TD>");
		hPrintf("<TABLE>\n");
		hPrintf("<TR><TD><B>%s - %s</B></TD></TR>\n", 
			col->shortLabel, col->longLabel);
		hPrintf("<TR><TD>");
		col->filterControls(col, conn);
		hPrintf("</TD></TR>\n");
		hPrintf("</TABLE>");
		hPrintf("<BR>");
		hPrintf("</TD></TR>\n");
		}
	    }
	hPrintf("</TABLE>\n");
	hPrintf("<BR>");
	cgiMakeButton("submit", "submit");
	}
    }
hPrintf("</FORM>\n");
}
예제 #21
0
파일: plFgtSS.C 프로젝트: star-bnl/star-emc
plFgtSS( int page=1,char *core="d1",int pl=0){ //1=gif, 2=ps, 3=both
  //  core="R7098001a";
  char *path="./";
  TString fullInpName=path;  fullInpName+=core;
  fullInpName+=".fgt.hist.root";

  double seedThres=30;

  fd=new TFile(fullInpName);
  if(! fd->IsOpen()) {
    printf("EROR: input histo file not found, quit\n",fullInpName.Data());
    return;
  }
  // fd->ls();
  gStyle->SetPalette(1,0);

  char *nameA[]={"ss_inDE","ss_inDS","ss_inZ","ss_hitStat","ss_inXY","ss_cTof","ss_inR","ss_cPmag","ss_gXY1"};
  char *nameB[]={"fr_pairEne","fr_nPrimPair", "fr_totEne","fr_nTotPair","fr_pathL","fr_avrTPath"};
  char *nameC[]={"ss_hitStat","cl_Stat1D","ev_Stat1D"};

  
  switch (page) {    
  case 1:{ // general stats from all disks
    can=new TCanvas("aa","aa",800,500);    TPad *c=makeTitle(can,core,page);
    c->Divide(1,3);gStyle->SetOptStat(111111);
    char **nameX=nameC;
    for(int i=0;i<3;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)fd->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
    } 
    break;
  }//--------------------------------------



  case 2:{ // g2t track properties
    can=new TCanvas("aa","aa",800,700);   TPad *c=makeTitle(can,core,page);
    c->Divide(3,3);
    char **nameX=nameA;
    int i;
    for(i=0;i<9;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)fd->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      if(i==4|| i==8)  h->Draw("colz"); 
      if(i==3) 	if(h->GetEntries()>0) c->GetPad(1+i)->SetLogz();      
    } 
    break;
  }//--------------------------------------

  case 3: { //  EVENT: 2D digitalization
    can=new TCanvas("aa","aa",800,420);    TPad *c=makeTitle(can,core,page);
    c->Divide(2,1);
    c->cd(1);ss_inXY->Draw("colz");
    c->cd(2);digXY->Draw("colz");
    break;
  }//--------------------------------------

  case 4: { //  EVENT: zoom in of digXY
    can=new TCanvas("aa","aa",400,420);    TPad *c=makeTitle(can,core,page);
    digXY->SetAxisRange(14.,15.,"x"); 
    digXY->SetAxisRange(35.,36.,"y");
    digXY->Draw("colz"); 
    break;
  }//--------------------------------------

  case 5: { // EVENT: projection  on rad & phi strips
    can=new TCanvas("aa","aa",800,420);    TPad *c=makeTitle(can,core,page);
    c->Divide(1,2);gStyle->SetOptStat(1001111);
    c->cd(1);digRad->Draw();
    c->cd(2);digPhi->Draw();
    break;
  }//--------------------------------------

  case 6:{ // properties of Frank's hit distribution generator
    can=new TCanvas("aa","aa",800,500);    TPad *c=makeTitle(can,core,page);
    c->Divide(3,2);
    char **nameX=nameB;
    for(int i=0;i<6;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)fd->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      if(i==5) { h->SetAxisRange(0,2);} //h->Fit("gaus");
    } 
    break;
  }//--------------------------------------

  case 7: { // R-cluster finder properties
    can=new TCanvas("aa","aa",800,550);    TPad *c=makeTitle(can,core,page);
    c->Divide(3,2);gStyle->SetOptStat(111111);
    c->cd(1);cl_RmxAmp->Draw();
    cl_RmxAmp->Fit("landau","R","",seedThres,99999);
    // c->cd(2);cl_rMul->Draw();
    c->cd(2);cl_Rwid->Draw();
    c->cd(4);cl_Rpf->Draw();
    c->cd(5);//ev_errRad->Fit("gaus","R","",-80,80);//Draw();
    ev_errRad->Rebin(3);
    ev_errRad->Fit("gaus");
    c->cd(6);ev_dRad_R->Draw("colz");
    break;
  }//--------------------------------------


  case 8: { // Phi-cluster finder properties
    can=new TCanvas("aa","aa",800,550);    TPad *c=makeTitle(can,core,page);
    c->Divide(3,2);gStyle->SetOptStat(111111);
    c->cd(1);cl_PmxAmp->Draw();cl_PmxAmp->Fit("landau","R","",seedThres,99999);
    // c->cd(2);cl_pMul->Draw();
    c->cd(2);cl_Pwid->Draw();
    c->cd(4);cl_Ppf->Draw(); // fr_Rdiff->Draw("colz");
    c->cd(5);ev_RerrPhi->Fit("gaus","R","",-100,100);//->Draw();
    c->cd(6);ev_RdPhi_R->Draw("colz");
    break;
  }//--------------------------------------


  case 9: { // Rad vs. Phi-cluster finder properties
   can=new TCanvas("aa","aa",500,280);    TPad *c=makeTitle(can,core,page);
    c->Divide(2,1);gStyle->SetOptStat(111111);
    c->cd(1);cl_rpMul->Draw("colz");
   
     break;
  }//--------------------------------------


  case 10: { // Rad err vs. R
    can=new TCanvas("aa","aa",800,420);    TPad *c=makeTitle(can,core,page);
    c->Divide(2,1);gStyle->SetOptStat(0);gStyle->SetOptFit(1);
    int nReb=4;
    c->cd(1);spreadFit(ev_dRad_R->RebinX(nReb,"dRreb")); 
    c->cd(2);spreadFit(ev_RdPhi_R->RebinX(nReb,"RdPreb"));
     break;
  }//--------------------------------------


  case 101: { // tmp1
    can=new TCanvas("aa","aa",1100,850);    TPad *c=makeTitle(can,core,page);
    c->Divide(3,2);gStyle->SetOptStat(111111);
    c->cd(1);cl_rpMul->Draw("colz");
    c->cd(4);ev_Stat1D->Draw(); ev_Stat1D->SetAxisRange(0,6);
    float yy=ev_Stat1D->GetMaximum();
    ev_Stat1D->SetMinimum(yy*.75);
    c->cd(2);ev_errRad->Fit("gaus","R","",-200,200);//Draw();
    c->cd(3);ev_dRad_R->Draw("colz");

    c->cd(5);ev_RerrPhi->Fit("gaus","R","",-60,60);//->Draw();
    c->cd(6);ev_RdPhi_R->Draw("colz");

    break;
  }//--------------------------------------

  case 102: { // tmp1
    can=new TCanvas("aa","aa",500,280);    TPad *c=makeTitle(can,core,page);
    c->Divide(2,1);
    c->cd(1);cl_RmxAmp->Fit("landau","R","",seedThres,99999);
    c->cd(2);cl_PmxAmp->Fit("landau","R","",seedThres,99999);

    break;
  }//--------------------------------------

  case 103: { // tmp1
    can=new TCanvas("aa","aa",1100,400);    TPad *c=makeTitle(can,core,page);
    c->Divide(3,1);gStyle->SetOptStat(1111);
    c->cd(1);ev_Stat1D->Draw(); ev_Stat1D->SetAxisRange(0,6);
    float yy=ev_Stat1D->GetMaximum();
    ev_Stat1D->SetMinimum(yy*.75);
    c->cd(2);ev_errRad->Fit("gaus","R","",-200,200);//Draw();
    c->cd(3);ev_RerrPhi->Fit("gaus","R","",-60,60);//->Draw();

    break;
  }//--------------------------------------

  case 104: { // tmp1
    can=new TCanvas("aa","aa",900,750);    TPad *c=makeTitle(can,core,page);
    c->Divide(3,2);gStyle->SetOptStat(1111);
    c->cd(1);cl_RmxAmp->Fit("landau","R","",seedThres,99999);
    c->cd(2);cl_Rpf->Draw();
    c->cd(3);ev_errRad->Fit("gaus","R","",-200,200);

    c->cd(4);cl_PmxAmp->Fit("landau","R","",seedThres,99999);
    c->cd(5);cl_Ppf->Draw();
    c->cd(6);ev_RerrPhi->Fit("gaus","R","",-80,80);

    break;
  }//--------------------------------------

  case 105: { // tmp1
    can=new TCanvas("aa","aa",1100,800);    TPad *c=makeTitle(can,core,page);
    c->Divide(3,2);gStyle->SetOptStat(111111);
    c->cd(4);ev_RokXY->Draw("colz"); //  ev_RokXY->Rebin2D(2,2);
 
    c->cd(1);ev_Stat1D->Draw(); ev_Stat1D->SetAxisRange(0,6);
    float yy=ev_Stat1D->GetMaximum();
    ev_Stat1D->SetMinimum(yy*.75);

    int nReb=4;
    c->cd(2);ev_RerrPhi->Fit("gaus","R","",-100,100);//->Draw();
    // ev_RdPhi_R->RebinY(2);
    c->cd(3);spreadFit(ev_RdPhi_R->RebinX(nReb,"RdPreb"),370);

    c->cd(5);ev_errRad->Fit("gaus","R","",-300,300);//Draw();
    c->cd(6);spreadFit(ev_dRad_R->RebinX(nReb,"dRreb"),370); 

    break;
  }//--------------------------------------


  default:
    printf("page=%d NOT defined\n",page);
 
  }

  char text[100];
  sprintf(text,"%s_page%03d",core,page);
  TString tit=text;
  can->SetTitle(tit);
  can->SetName(tit);
  //  c->Clear();
  
  if(pl&1) can->Print(tit+".gif");
  if(pl&2) can->Print(tit+".ps");
  
}
예제 #22
0
//=================================================
plZana(  int page=0,int pl=2,  char *core0="run12long", char *iPath="../9.10.12/", char *oPath="./out/z/"){ //1=gif, 2=ps, 3=both
  //core0="jba322";
  if(page==0) {
    doAll(core0,iPath);
    return;
  }
  

  char *nameA[]={"_Z_EventType"}; //pg 1
  char *nameB[]={"_Z_et1iso","_Z_et1val","_Z_et1frac","_Z_et2iso","_Z_et2val","_Z_et2frac"}; //pg 2
  char *nameC[]={"_Z_phi12","_Z_ZmassLike","_Z_chRecPNp","_Z_ZmassUnlike"};
  char *nameD[]={"muEne_Deta","_Z_Ene_Deta"};// pg 4

  char *nameE[]={"_Z_Endcap_EventType","_Z_Y2","_Z_etaZ"}; //pg 5
  char *nameF[]={"_Z_Eet1iso","_Z_Eet1val","_Z_Eet1frac","_Z_Eet2iso","_Z_Eet2val","_Z_Eet2frac"}; //pg 6
  char *nameG[]={"_Z_Ephi12","_Z_ELike_chRecPNp","_Z_E_ZmassLike","_Z_Eeta12","_Z_EUnlike_chRecPNp","_Z_E_ZmassUnlike"} //pg7

  gStyle->SetOptFit(1);
  TString fullInpName=iPath;  fullInpName+=core0;
  fullInpName+=".wana.hist.root";  
  fd=new TFile(fullInpName);
  if(! fd->IsOpen()) {
    printf("EROR: input histo file not found, quit\n",fullInpName.Data());
    return;
  } else {
    printf("Opened: %s\n",fullInpName.Data());
  }

  //switch to TDirectory for eta binning
  if(fd->Get("muStatEve")==0)
    fd->cd("Z");

  if(page==1){ 
    //fd->ls(); 
    h0=(TH1*)gDirectory->Get("_Z_EventType"); assert(h0);
    printf("%s: ",h0->GetName());
    for(int k=1;k<=14;k++) printf("%.0f, ",h0->GetBinContent(k));
    printf("\n");
  }
 gStyle->SetPalette(1,0);
 gStyle->SetOptStat(0);
 char padTit[1000];
 sprintf(padTit,"%s",core0);

 switch (page) {

 case 1:{   
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(1,1);gStyle->SetOptStat(0);
    char **nameX=nameA;
    for(int i=0;i<1;i++) {
      char txt[100];
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      if(i==0) h->Draw("h text");
    }
    c->GetPad(1)->SetLogy();
   
 } break;//--------------------------------------

 case 2:{   
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(3,2);gStyle->SetOptStat(1110);
    char **nameX=nameB;
    for(int i=0;i<6;i++) {
      char txt[100];
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
    }
   c->GetPad(2)->SetLogy();
   
 } break;//--------------------------------------


 case 3:{  
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    //can->SetGrayscale();
    c->Divide(2,2);gStyle->SetOptStat(10);
    char **nameX=nameC;
    for(int i=0;i<4;i++) {
      char txt[100];
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      if(i==2) {
	h2=(TH2F*) h;
	h2->Rebin2D(2,2); //h2->SetMaximum(3);
	h2->Draw("colz");
	//h2->Draw("box"); h2->SetFillColor(kBlack);
	//h3=(TH2F*)pubchRecPNp;	h3->Rebin2D(2,2);
	//h3->Draw("colz same");
	//h2->Draw("box same");  
      }
      if(i==3)  {
	//h->SetFillColor(kYellow);
	//h->SetMaximum(4);
        h->SetAxisRange(0,130);
	//h->Fit("gaus","","RH",75.,115.);
      }
    }
 
        
 } break;//--------------------------------------

 case 4:{   
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(1,2);gStyle->SetOptStat(1110);
    char **nameX=nameD;
    for(int i=0;i<2;i++) {
      char txt[100];
      if(i==0) continue;
      printf("->%s<\n",nameX[i]);
      h2=(TH2F*)gDirectory->Get(nameX[i]);  assert(h2);
      h2->Rebin2D(2,2);
      c->cd(i+1); h2->Draw("colz");	
    }
 
 } break;//--------------------------------------

 case 5:{   
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,2);gStyle->SetOptStat(0);
    char **nameX=nameE;
    for(int i=0;i<3;i++) {
      char txt[100];
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  //assert(h);
      if(h==0) continue;
      c->cd(i+1); h->Draw();
      if(i<2) {  h->Draw("h text");
	h->SetMarkerSize(2); // for bigger text
      }
      if(i==2) { h->Rebin(8); h->Draw(); }
      
    }
    c->GetPad(1)->SetLogy();
   
 } break;//--------------------------------------

 case 6:{   
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(3,2);gStyle->SetOptStat(1110);
    char **nameX=nameF;
    for(int i=0;i<6;i++) {
      char txt[100];
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
    }
   c->GetPad(2)->SetLogy();
   
 } break;//--------------------------------------
   
 case 7:{  
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    //can->SetGrayscale();
    c->Divide(3,2);gStyle->SetOptStat(10);
    char **nameX=nameG;
    for(int i=0;i<6;i++) {
      char txt[100];
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      if(i==3) h->Draw("colz");
      if(i==1 || i==4) {
	h2=(TH2F*) h;
	h2->Rebin2D(2,2); //h2->SetMaximum(3);
	h2->Draw("colz");
	//h2->Draw("box"); h2->SetFillColor(kBlack);
	//h3=(TH2F*)pubchRecPNp;	h3->Rebin2D(2,2);
	//h3->Draw("colz same");
	//h2->Draw("box same");  
      }
      //if(i==3)  {
	//h->SetFillColor(kYellow);
	//h->SetMaximum(4);
        //h->SetAxisRange(0,130);
	//h->Fit("gaus","","RH",75.,115.);
      //}
    }
 
        
 } break;//--------------------------------------

 
 default:
     printf("page=%d NOT defined\n",page);

 }

 char text[100];
 sprintf(text,"%s%s_page%03d",oPath,core0,page);
 TString tit=text;
 can->SetTitle(tit);
 can->SetName(tit);

 
 if(pl&1) can->Print(tit+".gif");
 if(pl&2) can->Print(tit+".ps");
 
}
예제 #23
0
//=================================================
void plEana(  int page=-1,int pl=2, char *core0="sumR12P13ib", char *iPath="/star/u/jlzhang/run12-dev/", char *oPath="/star/u/jlzhang/run12-dev/movies/", int isMC=0, char *etaBin="Eta7"){ //1=gif, 2=ps, 3=both
    
  cout<<iPath<<core0<<endl;

  if(page<=-1) {
    doAll(core0,iPath,isMC,oPath,etaBin);
    return;
  }
   
/*
cat mcSetD1*W*ps | ps2pdf - ~/WWW/tmp/all-W.pdf
*/


  char *nameA[]={"muEStatEve","muEStatTrk"}; //pg 1
  char *nameB[]={"muEVRf","muEZv","muENV","muEbX48"};//pg 2
  char *nameC[]={"muEbX7","muEbX7v"};//pg 3
  char *nameD[]={"muEDsm1","muEDsm2","muEDsm3","muEDsm4"};//pg 4
  char *nameE[]={"muETrNfit","muETrFitFrac","muETrch2","muETrRxyIn","muETrRxyOut","muETrch2b"};//pg 5
  char *nameF[]={"muETr2D1","muETrPt1","muETrPt1N","muETrPt1Pr","muETrPt1NPr"};//pg 6
  char *nameG[]={"muEeXY","muEmaxAdc","muEtotAdc","muEclAdcPt","muEclET"};//pg 7
  char *nameH[]={"muEclET24","muEclE242D","muEclET24R"};//pg 8
  
  char *nameJ[]={"muEdist1","muEdist2","muEdist3","muEdist4"};//pg 9
  char *nameK[]={"muETEMCjetETR","muETjetEMCjet2D","muETEMCjetET"};//pg 10
  char *nameL[]={"muEEMCjetET","muEclEMCjetE2D","muETjetET"};//pg 11
  char *nameM[]={"muETwayET","muEBwayET","muEEclETPt","muEEwayET"};//pg 12
  
  char *nameW[]={"muETotwayET2D","muEsPtBalance_clust","muE_WET","muE_W2D1"};//pg 13
  char *namePB[]={"muEsPtBalance_clust", "muEsPtBalance_awayTot","muE_Weta","muE_WXY"};// pg 14 -Pt-Balance plots
  char *nameN[]={"muETrdEdX","muE_Wdedx"}; //pg 16 -> pg 15 pg21 -> pg16
  char *nameO[]={"muE_WglDcaSP","muE_WglDcaSN"}; // pg 17
  
  char *nameP[]={"muE_ETlive0","muE_ETlive1","muE_ETlive2","muE_ETlive3","muE_Wcar1","muE_Wcar2","muE_Wcar3"}; // pg 18
  
  //add histograms for q/pt plots etc.
  char *nameR2[]={"muEchRecPNg","muEchRecPNp"};// pg 19
  char *nameR3[]={"muEchRecHypCorrPNg" ,"muEchRecHypCorrPNp"};// pg 20

  char *nameSMD[]={"muE_UoffStr","muE_VoffStr"}; // pg21 -> pg 16

  TString spinPre='A';
  char *nameS1[]={"spinEStatEve","spinEs4mon","spinEbX48","spinEbX7","spinEbX48c","spinEbX7c"};// pg 23
  char *nameS5[]={"spinE_ET_P","spinE_ET_N","spinEQpT","spinEQpT2"};// pg 24
  char *nameS6[]={"spinEQpT_hits","spinEQpT_hitF","spinEHitsFit_Frac"};// pg 25
  char *nameS2[]={"spinEY0","spinEY1","spinEY2_P","spinEY2_N"};// pg 26
  char *nameS3[]={,"spinEY3_P","spinEY3_N","spinEY4_P","spinEY4_N"};// pg 27
  char *nameS4[]={"spinEY5_P","spinEY5_N","spinELepEta_P","spinELepEta_N"};// pg 28

  char *nameEsmd1[]={"muEsmdNhit","muEsmdEne","muEsmdRatioUV","muEclustET_esmdNhit","muEclustET_esmdEne","muEclustET_esmdRatio"};//pg 29
  char *nameEsmd2[]={"muEclustET_esmdEneSum7","muEsPtBalance_clustPassSMD","muEsPtBalance_clustFailSMD","muEsPtBalance_esmdRatio_ET25","muEsPtBalance2_clustPassSMD","muEsPtBalance2_clustFailSMD"};//pg 30

  //use  Page 30-42 TPC sectors per cut, 2 pages per cut

  gStyle->SetOptFit(1);
  TString fullInpName=iPath;  fullInpName+=core0;
  fullInpName+=".wana.hist.root";  
  fd=new TFile(fullInpName);
  if(! fd->IsOpen()) {
    printf("EROR: input histo file not found, quit\n",fullInpName.Data());
    return;
  } else {
    printf("Opened: %s\n",fullInpName.Data());
  }

  //switch to TDirectory for eta binning
  if(fd->Get("muEStatEve")==0) {
    cout<<"Switching to etaBin="<<etaBin<<" now have to use gDirectory"<<endl;
    spinPre+=etaBin;
    if(!fd->cd(etaBin)) {
      cout<<"Missing TDirectory of interest, no plots!"<<endl;
      return;
    }
  }

  if(page==1||page==13){ 
   //fd->ls(); 
   h0=(TH1*)gDirectory->Get("muEStatEve"); assert(h0);
   printf("%s: ",h0->GetName());
   for(int k=1;k<=16;k++) printf("%.0f, ",h0->GetBinContent(k));
   printf("\n");
 }
 // if(page>=23 && page<=25 && gDirectory->Get("AspinStatEve")==0) return; // skip spin plots if maker was not used

  //skip tpc plots if using tree reader code
  if( ((page>=2 && page<=6) || (page>=31 && page<=43)) && !fd->cd("tpc")) return;
  fd->cd(); 
  gStyle->SetPalette(1,0);
  gStyle->SetOptStat(0);
  char padTit[1000];
  sprintf(padTit,"%s",core0);

 switch (page) {

 case 1:{   
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(1,2);gStyle->SetOptStat(0);
    char **nameX=nameA;
    for(int i=0;i<2;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      if(i==0) h->Draw("h text");
    }
    c->GetPad(1)->SetLogy();
    c->GetPad(2)->SetLogy();
 } break;//--------------------------------------

 case 2:{   
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,2);gStyle->SetOptStat(1110);
    char **nameX=nameB;
    for(int i=0;i<4;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      if(i==1) h->Fit("gaus","","hR",-50,50);
    }
    c->GetPad(1)->SetLogy();
    c->GetPad(3)->SetLogy();
 } break;//--------------------------------------


 case 3:{  // efficiency vs. bXing, only for data 
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(1,2);gStyle->SetOptStat(10);
    char **nameX=nameC;
    TH1F *hA[2];
    c->cd(1);
    for(int i=0;i<2;i++) {
      printf("->%s<\n",nameX[i]);
      hA[i]=(TH1F*)gDirectory->Get(nameX[i]);  assert(hA[i]);
      if(i==0)  hA[i]->Draw();
      else  hA[i]->Draw("same");
      
    }
    // c->GetPad(1)->SetLogy();
    
    hA[0]->SetFillColor(0); 

    TH1 *hEf=(TH1F*) hA[1]->Clone(); 
    hEf->SetTitle("Vertex effi vs. bXing");
    hEf->SetName("muVefbx");
    hEf->SetFillColor(0);     hEf->SetLineColor(kMagenta);
    hEf->Divide(hA[0]);
    c->cd(2);
    hEf->Draw(); hEf->SetMaximum(1.1);
    hEf->Fit("pol0","","Rh",50,100);
    
 } break;//--------------------------------------

 case 4:{   
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,2);gStyle->SetOptStat(1001111);
    char **nameX=nameD;
    for(int i=0;i<4;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      if(i==3) {
	  h->SetFillColor(kBlue);
	  c->cd(3);
	  h->Draw("same");
      }
    }
    c->GetPad(1)->SetLogy();
    c->GetPad(2)->SetLogy();
    c->GetPad(3)->SetLogy();
 } break;//--------------------------------------

 case 5:{    sprintf(padTit,"Track selection cuts, %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(3,2);gStyle->SetOptStat(110);
    char **nameX=nameE;
    for(int i=0;i<6;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      if(i==5) h->Draw("colz");
    }
    //c->GetPad(1)->SetLogy();
 } break;//--------------------------------------




 case 6:{    sprintf(padTit,"Selected high PT tracks, %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c0=makeTitle(can,padTit,page);
    TPad *cL,*cR;   splitPadX(0.4,&cL,&cR);
    cR->cd();
    cR->Divide(2,2);gStyle->SetOptStat(10);
    char **nameX=nameF;
    TH1F *h1,*h2;
    for(int i=0;i<5;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      if(i==0) { cL->cd();  
	h->Draw("colz");
	for( float eta=-0.8; eta<.6; eta+=1.4) // print sectors IDs
	  for(float x=-PI-.1; x<PI; x+=PI/6) {
	    int sec=tpcSec(x, eta);;
	    char txt[100];
	    sprintf(txt,"sec %d",sec);
	    tx=new TText(eta,x,txt); tx->Draw();
	  }
      }
      
      if(i==1 || i==3) {cR->cd(1+i/2); h1=h; h->Draw(); h->SetMinimum(.1);}
      if(i==4) h->SetFillColor(9);
      if(i==2 || i==4) {  h2=h; h->Draw("same");  cR->cd(2+i/2);
	h=(TH1F*) h2->Clone(); h->SetTitle("Ratio Negtive/all");h->Divide(h1); h->Draw();
	h->SetMinimum(0.2);	h->SetMaximum(0.7);
      }
      if(i>0) h->SetAxisRange(0,50);
    }
    cR->GetPad(1)->SetLogy();
    cR->GetPad(2)->SetLogy();
 } break;//--------------------------------------

 case 7:{    sprintf(padTit,"ETOW response, %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(3,2);gStyle->SetOptStat(1000110);
    char **nameX=nameG;
    for(int i=0;i<5;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      if(i==3 || i==0) h->Draw("colz");
      if(i==3) h->SetMaximum(0.6* h->GetMaximum());
    }
    c->GetPad(2)->SetLogy();    
    c->GetPad(3)->SetLogy();    
    // c->GetPad(4)->SetLogz();    
    c->GetPad(5)->SetLogy();    
 } break;//--------------------------------------

 case 8:{    sprintf(padTit,"2x1 / 4x4 cluster isolation cut, %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,2);gStyle->SetOptStat(10);
    char **nameX=nameH;
    for(int i=0;i<3;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      if(i==1  ) h->Draw("colz");
    }
   c->GetPad(1)->SetLogy();       
   c->GetPad(2)->SetLogz();       
 } break;//--------------------------------------

 case 9:{     sprintf(padTit,"3D distance between track & cluster, %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,2);gStyle->SetOptStat(10);
    char **nameX=nameJ;
    for(int i=0;i<4;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); 
      if(i==3) h->Draw();
      else h->Draw("colz");
    }
 } break;//--------------------------------------

 case 10:{    sprintf(padTit,"separted near jet in BOW & TPC, %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,2);gStyle->SetOptStat(10);
    char **nameX=nameL;
    for(int i=0;i<3;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      if(i==1  ) h->Draw("colz");
    }
   c->GetPad(1)->SetLogy();       
   c->GetPad(2)->SetLogz();       
   c->GetPad(3)->SetLogy();       
 } break;//--------------------------------------


 case 11:{    sprintf(padTit,"TPC+BTOW near jet ET, %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,2);gStyle->SetOptStat(10);
    char **nameX=nameK;
    for(int i=0;i<3;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      if(i==1  ) h->Draw("colz");
    }
 
   c->GetPad(2)->SetLogz();       
   
 } break;//--------------------------------------

 case 12:{    sprintf(padTit,"away ET veto, %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,2);gStyle->SetOptStat(10);
    char **nameX=nameM;
    for(int i=0;i<4;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      if(i==2)	h->SetAxisRange(0,60);
      if(i==2  ){
	h->Draw("colz");
      }
    }
   c->GetPad(1)->SetLogy();       
   c->GetPad(2)->SetLogy();       
   c->GetPad(4)->SetLogy();       

 } break;//--------------------------------------


 case 13:{    sprintf(padTit,"best W selection, %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,2);gStyle->SetOptStat(10);
    char **nameX=nameW;
    for(int i=0;i<4;i++) {
      char txt[100];
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      if(i==3) { // draw on previous
	float sum=h->GetEntries();
	sprintf(txt,"%.0f eve >thres",sum);
	tx=new TText(30,52,txt); tx->Draw();
      }

      c->cd(i+1); h->Draw();
      if(i<3)	h->SetAxisRange(0,60);   
      if(i!=2 ) h->Draw("colz");
      if(i==0 )	h->SetAxisRange(0,60,"y");
      if(i==1 )	{h->SetAxisRange(0,60,"x");h->SetAxisRange(-40,60,"y");}
      if(i==2 ) {
	h->Draw("eh");  	h->SetAxisRange(0,60);
	h->SetFillColor(8);
	//	if(strstr("run9",core0)>=0) h->SetMaximum(80);
      }
    }
   
 } break;//--------------------------------------
   
 case 14: {   sprintf(padTit,"pT-Balance plots (out of order)  %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,2);gStyle->SetOptStat(10);
    char **nameX=namePB;
    for(int i=0;i<4;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); 
      if(i==2) {h->Rebin(8); h->GetXaxis()->SetRangeUser(0.5,2.0);}
      if(i<2) h->Draw("colz");
      else  h->Draw();
      if(i==3) h->Draw("colz");
    }
   
 } break;//--------------------------------------

case 15:{    sprintf(padTit,"TPC dEdx for all & W tracks, %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,1);gStyle->SetOptStat(10);
    char **nameX=nameN;
    for(int i=0;i<2;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw("colz");
    }
    c->GetPad(1)->SetLogz();   
 } break;//--------------------------------------

 case 16:{    sprintf(padTit,"TRack-SMD peak offset , %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(1,2);gStyle->SetOptStat(10);
    char **nameX=nameSMD;
    for(int i=0;i<2;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1);  h->Draw("colz");
      for(int sec=1;sec<=12;sec++) {
	float phiC= (3-sec)*30;
	if(phiC<-179) phiC+=360;
	float phiL= (phiC-15.)/180*3.1416;
	//printf("sec=%d phiC/deg=%.0d  phiL/rad=%.2f\n",sec,phiC, phiL);
	ln=new TLine(phiL,-7,phiL,7); ln->Draw(); ln->SetLineColor(8);
	tx=new TText(phiL+0.05,5,Form("sec %d",sec)); tx->Draw();
      }
    }
 } break;//--------------------------------------

case 17:{    sprintf(padTit,"TPC global DCA to Vertex for W tracks, %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,2);gStyle->SetOptStat(10);
    char **nameX=nameO;
    for(int i=0;i<2;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      c->cd(i+1); h->Draw("colz");
      h->SetAxisRange(0,60);      h->SetAxisRange(-2.,2.,"y");
    }
 } break;//--------------------------------------



 case 18:{    sprintf(padTit,"electron candidate ET vs. condition, %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    gStyle->SetOptStat(10);
    char **nameX=nameP;
    c->cd(); TPad *cL,*cR;   splitPadX(0.5,&cL,&cR);
    cL->cd(); cR->Divide(1,3);
    for(int i=0;i<7;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(nameX[i]);  assert(h);
      if(i==0) { h->Draw(); h->SetAxisRange(0,60);}
      if(i>0 && i<4)   h->Draw("same");
      if(i==1) h->SetFillColor(kBlue);
      if(i==2) h->SetFillColor(8);
      if(i==3) h->SetFillColor(kRed);
      if(i==4) { cR->cd(1); h->Draw(); h->SetAxisRange(0,5); }
      if(i==5) { cR->cd(2); h->Draw();}
      if(i==6) { cR->cd(3); h->Draw(); h->Fit("gaus","","Rh",-100,80);	h->GetXaxis()->SetTitle("Z (cm)");}
      if(i>3) {
	h->GetXaxis()->SetTitleOffset(0.9);
	h->GetXaxis()->SetLabelSize(0.06);  h->GetXaxis()->SetTitleSize(0.05); h->SetMinimum(0.8);}
      
    }
    cL->GetPad(0)->SetLogy();
    cR->GetPad(1)->SetLogy();

 } break;//--------------------------------------

 case 19:{    sprintf(padTit,"charge separation, %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,1);gStyle->SetOptStat(110110);
    ln=new TLine(0,0,80,0); ln->SetLineColor(kMagenta);
    char **nameX=nameR2;
    for(int i=0;i<2;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH2*)gDirectory->Get(nameX[i]);  assert(h); h->Rebin2D(3,3);
      c->cd(i+1);  h->Draw("colz");
      h->SetAxisRange(0,70); ln->Draw();
    }
 } break;//--------------------------------------
    
 case 20:{    sprintf(padTit,"Charge Separation Hyperbola Corrected, %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,1);gStyle->SetOptStat(110110);
    ln=new TLine(0,0,70,0); ln->SetLineColor(kMagenta);
    char **nameX=nameR3;
    for(int i=0;i<2;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH2*)gDirectory->Get(nameX[i]);  assert(h); h->Rebin2D(3,3);
      c->cd(i+1);  h->Draw("colz");
      h->SetAxisRange(0,70); ln->Draw();
    }
 } break;//--------------------------------------

 case 23:{    sprintf(padTit,"bXing & spin QA, %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,spinPre+padTit,page);
    c->Divide(2,3);gStyle->SetOptStat(1000010);
    char **nameX=nameS1;
    for(int i=0;i<6;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(spinPre+nameX[i]);  assert(h);
      c->cd(i+1); h->Draw();
      if(i==1) { h->Draw("colz");}
    }
    c->GetPad(1)->SetLogy();
    
 } break;//--------------------------------------


 case 24:{    sprintf(padTit,"Final Endcap Ws for spin analysis, %s",core0);
   can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,spinPre+padTit,page);
   c->Divide(2,2);gStyle->SetOptStat(10);
   char **nameX=nameS5;
   for(int i=0;i<4;i++) {
     printf("->%s<\n",nameX[i]);
     h=(TH1*)gDirectory->Get(spinPre+nameX[i]);  assert(h);
     c->cd(i+1);  h->Draw();
     if(i==2) { hx=(TH1*) h->Clone(); h->SetFillColor(9); hx->SetFillColor(46);
       hx->SetAxisRange(0,1); hx->Draw("same");
     }
     
     if(i==3) { h->Draw("colz"); ((TH2F*)h)->Rebin2D(1,2);}
     if(i<2) h->Rebin();
     if(i<2||i==3) h->SetAxisRange(0,70);
     gPad->SetGrid(0,0);
   }
 } break;//--------------------------------------
 case 25:{  sprintf(padTit,"Charge separation vs. track quality, %s", core0);
   can=new TCanvas("aa","aa",800,600); TPad *c=makeTitle(can,spinPre+padTit,page);
   c->Divide(2,2);gStyle->SetOptStat(10);
   char **nameX=nameS6;
   for(int i=0;i<3;i++) {
	 printf("->%s<\n",nameX[i]);
     h=(TH1*)gDirectory->Get(spinPre+nameX[i]);  assert(h);  
	 c->cd(i+1);  h->Draw("colz"); ((TH2F*)h)->Rebin2D(2,2);
	 gPad->SetGrid(0,0);
   }
		 }break;//-----------------------------------

 case 26:
 case 27:
   {    sprintf(padTit,"spin sorting: lumi & Ws, %s",core0);
     char **nameX=nameS2;
     if(page==26) { nameX=nameS3;sprintf(padTit,"spin sorting: QCD background, %s",core0);}
     can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,spinPre+padTit,page);
     c->Divide(2,2);gStyle->SetOptStat(1000010);

    for(int i=0;i<4;i++) {
      printf("->%s<\n",nameX[i]);
      cout<<spinPre+nameX[i]<<endl;
      h=(TH1*)gDirectory->Get(spinPre+nameX[i]);  assert(h);
      c->cd(i+1); h->Draw("h  text");
    }
 } break;//--------------------------------------
 
  case 28:{    sprintf(padTit,"charge & ET vs. spin state, %s",core0);
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,spinPre+padTit,page);
    c->Divide(2,2);gStyle->SetOptStat(10);
    char **nameX=nameS4;
    for(int i=0;i<4;i++) {
      printf("->%s<\n",nameX[i]);
      h=(TH1*)gDirectory->Get(spinPre+nameX[i]);  assert(h);
      c->cd(i+1);  h->Draw("colz");
      if(i>1) h->Draw();
    }
 } break;//--------------------------------------

 case 29:{    sprintf(padTit,"ESMD 1, %s",core0);
     can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
     c->Divide(3,2);gStyle->SetOptStat(10);
     char **nameX=nameEsmd1;
     for(int i=0;i<6;i++) {
       printf("->%s<\n",nameX[i]);
       h=(TH2F*)gDirectory->Get(nameX[i]);  assert(h);
       if(i==1) h->Rebin2D(4,4);
       if(i==3) h->Rebin2D(4,2);
       if(i==4) h->Rebin2D(4,10);
       if(i==5) h->Rebin2D(4,2); 
       if(i>2) h->GetXaxis()->SetRangeUser(0,70);
     
       c->cd(i+1);  h->Draw("colz");
     }
 } break;//--------------------------------------

 case 30:{    sprintf(padTit,"ESMD 2, %s",core0);
     can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
     c->Divide(3,2);gStyle->SetOptStat(10);
     char **nameX=nameEsmd2;
     for(int i=0;i<6;i++) {
       printf("->%s<\n",nameX[i]);
       h=(TH2F*)gDirectory->Get(nameX[i]);  assert(h);
       if(i==0) {
	 h->Rebin2D(4,10);
	 h->GetXaxis()->SetRangeUser(0,70);
       }
       if(i!=0 && i!=3) {
	 h->GetXaxis()->SetRangeUser(0,70);
	 h->GetYaxis()->SetRangeUser(-60,60);
       }
       c->cd(i+1);  h->Draw("colz");
     }
 } break;//--------------------------------------   

 
 case 31: // TPC stats
 case 32: 
 case 33: // TPC nFitPts
 case 34:
 case 35: // TPC nFit/nPossibe
 case 36:
 case 37: // TPC 1st hit R
 case 38:
 case 39: // TPC last hit R
 case 40: 
 case 41: // TPC dE/dX
 case 42:
   {    
   fd->cd("tpc");
   int iew=(page-31)%2; // East-West
   int iCut=(page-31)/2;
   int sec1=1, sec2=12; if(iew) {sec1=13, sec2=24; return;}
   char *titA[]={"stats","nFitPoints", " nFit/nPossible","1st hit Rxy","last hit Rxy","dE/dX"};
   char *titB[]={"Stat","TrNfit","TrFitFrac","TrRxyIn","TrRxyOut","TrdEdX"};
   sprintf(padTit,"TPC %s   sectors[%d,%d], %s",titA[iCut],sec1,sec2,core0);
   can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
   c->Divide(4,3);gStyle->SetOptStat(10);
   for(int i=0;i<12;i++) {
     char name[100];
     sprintf(name,"secEemcTr%d_%s",i+sec1,titB[iCut]);
     printf("->%s<\n",name);
      h=(TH1*)gDirectory->Get(name);  assert(h);
      c->cd(i+1);
      if(iCut==5) 
	h->Draw("colz");
      else
	h->Draw();
      int col=30+i+sec1;
      h->SetFillColor(col);

      
   }
 } break;//--------------------------------------

 case 43:{    sprintf(padTit,"TPC accepted tracks, %s",core0);
    fd->cd();
    can=new TCanvas("aa","aa",800,600);    TPad *c=makeTitle(can,padTit,page);
    c->Divide(2,1);gStyle->SetOptStat(10);
    h2=muETr2D1; // cumulative
    c->cd(1); h2->Draw("colz");
    c->cd(2);
  
    fd->cd("tpc");
    for(int i=0;i<24;i++) {
      char name[100];
      sprintf(name,"secEemcTr%d_Tr2D1",i+1);
      printf("->%s<\n",name);
      h=(TH1*)gDirectory->Get(name);  assert(h); h->SetLineColor(30+i);
      if(i==0) h->Draw("box");
      else h->Draw("box same");
    }

 } break;//--------------------------------------

 default:
     printf("page=%d NOT defined\n",page);
     return;
 }

 char text[100];
 sprintf(text,"%s%s_page%03d",oPath,core0,page);
 TString tit=text;
 can->SetTitle(tit);
 can->SetName(tit);

 
 if(pl&1) can->Print(tit+".gif");
 if(pl&2) can->Print(tit+spinPre+".ps");
 
}

//------------------------
void splitPadX(float x, TPad **cL, TPad **cR) {
  (*cL) = new TPad("padL", "apdL",0.0,0.,x,0.95);
  (*cL)->Draw();    
  (*cR) = new TPad("padL", "apdL",x+0.005,0.,1.0,0.95);
  (*cR)->Draw();
}
예제 #24
0
static bool runCompiler (const EditorInfoEx *ei, const TLang *lng, const wchar_t *fn, const wchar_t *path, const wchar_t *title, const TExec *e)
{
	wchar_t	cwd[NM] = L"", baseFile[NM] = L"";
	if (!e->enable.empty())
	{
		wchar_t	temp[NM];
		makeCmdLine (false, baseFile, e->enable, path, fn);

		bool	enable = isFile (baseFile);
		if (!enable && e->searchBase && findBaseFile (path, baseFile, temp)) wcscpy (baseFile, temp);
	}

	if (!makeCmdLine (true, cmd, e->cmd, path, fn, makeTitle (title, 30, path, fn))) return (false);
	wcscpy(cmdpath, path);
	wchar_t	temp[NM];
	wcscpy(temp, cmd);
	ExpandEnvironmentStrings (temp, cmd, NM);

	if (e->saveType != saNone)
	{
		if (e->saveType == saCurrent)
		{
			wchar_t	witypename[NM];
			wchar_t	winame[NM];
			WindowInfoEx	wi;
			wi.TypeName = witypename;
			wi.TypeNameSize = NM;
			wi.Name = winame;
			wi.NameSize = NM;
			wi.Pos = -1;
			Info.AdvControl (&MainGuid, ACTL_GETWINDOWINFO, 0, (void *) &wi);
			if (wi.Type == WTYPE_EDITOR && (wi.Flags & WIF_MODIFIED))
				if (!Info.EditorControl (-1, ECTL_SAVEFILE, 0, nullptr)) return (false);
		}
		else
		{
			if (!SaveAll ())
			{
				const wchar_t *MsgItems[] = { GetMsg (MTitle), GetMsg (MSaveError), GetMsg (MContinue) };
				if (Info.Message (&MainGuid, &RunCompilerGuid, FMSG_MB_YESNO, nullptr, MsgItems, _countof (MsgItems), 0)) return (false);
			}
		}
	}

	if (e->cd != cdNone)
	{
		wchar_t	newDir[NM] = L"", *p;
		if (e->cd == cdFile)
			p = wcsrchr (wcscpy (newDir, fn), L'\\');
		else if ((e->cd == cdBase) && *baseFile)
			p = wcsrchr (wcscpy (newDir, baseFile), L'\\');
		if (p) *p = 0;
		if (*newDir)
		{
			GetCurrentDirectory (_countof (cwd), cwd);
			SetCurrentDirectory (newDir);
		}
	}

	if (compilerOutColl)
		compilerOutColl->removeAll ();
	else
		compilerOutColl = new TCollection<TOutputLine>;

	if (errColl)
		errColl->removeAll ();
	else
		errColl = new TCollection<TErrData>;

	compilerOutP = -1;
	execute (compilerOutColl, cmd, e->echo);

	size_t	n = compilerOutColl->getCount ();
	if (n)
	{
		intptr_t nErr = 0, aj = -1;
		compilerOut = new FarMenuItemEx[compilerOutN = n + 1];
		for (size_t i = 0; i < n; i++)
		{
			const TOutputLine *outData = (*compilerOutColl)[i];
			const wchar_t	*line = outData->line;
			compilerOut[i].Text = line;
			compilerOut[i].Flags = MIF_DISABLE;
			compilerOut[i].UserData = 0;

			wchar_t	compiler[MAX_STR_LEN];
			wcscpy (compiler, e->compiler);

			wchar_t	*pp, *p = compiler;
			bool	found = false;
			while ((pp = wcschr (p, L',')) != nullptr)
			{
				*pp = 0;
				if (parseError (lng, p, path, fn, line, i, aj))
				{
					nErr++;
					found = true;
				}

				p = pp + 1;
				if (found) break;
			}

			if (!found && parseError (lng, p, path, fn, line, i, aj)) nErr++;
		}

		if ((aj >= 0) && ((e->jumpType == jtFirst)) || ((e->jumpType == jtSmart) && (nErr == 1)))
			jumpToError (ei, path, aj, true);
		else
		{
			if (aj < 0)
			{
				if (compilerOut[n - 1].Text[0] == 0)
				{
					compilerOutN--;
					n--;
				}

				compilerOut[n].Text = L"";
				compilerOut[n].Flags = MIF_SELECTED;
			}
			else
				compilerOutN--;
			if ((e->jumpType == jtMenu) || (e->jumpType == jtSmart)) showCompileOut (ei, path);
		}
	}
	else if (compilerOut)
	{
		delete compilerOutColl;
		compilerOutColl = nullptr;
		delete[] compilerOut;
		compilerOut = nullptr;
	}

	if (*cwd) SetCurrentDirectory (cwd);
	return (true);
}