Esempio n. 1
0
void arrow (Double_t x1, Double_t y1, Double_t x2, Double_t y2, Int_t ls)
{
   TArrow *arr = new TArrow(x1,y1,x2,y2,0.025,"|>");
   arr->SetFillColor(1);
   arr->SetFillStyle(1001);
   arr->SetLineStyle(ls);
   arr->SetAngle(19);
   arr->Draw();
}
Esempio n. 2
0
void transparency()
{
   TCanvas *c1 = new TCanvas("c1", "c1",224,330,700,527);
   c1->Range(-0.125,-0.125,1.125,1.125);

   TLatex *tex = new TLatex(0.06303724,0.0194223,"This text is opaque and this line is transparent");
   tex->SetLineWidth(2);
   tex->Draw();

   TArrow *arrow = new TArrow(0.5555158,0.07171314,0.8939828,0.6195219,0.05,"|>");
   arrow->SetLineWidth(4);
   arrow->SetAngle(30);
   arrow->Draw();

   // Draw a transparent graph.
   Double_t x[10] = {
   0.5232808, 0.8724928, 0.9280086, 0.7059456, 0.7399714,
   0.4659742, 0.8241404, 0.4838825, 0.7936963, 0.743553};
   Double_t y[10] = {
   0.7290837, 0.9631474, 0.4775896, 0.6494024, 0.3555777,
   0.622012, 0.7938247, 0.9482072, 0.3904382, 0.2410359};
   TGraph *graph = new TGraph(10,x,y);
   graph->SetLineColorAlpha(46, 0.1);
   graph->SetLineWidth(7);
   graph->Draw("l");

   // Draw an ellipse with opaque colors.
   TEllipse *ellipse = new TEllipse(0.1740688,0.8352632,0.1518625,0.1010526,0,360,0);
   ellipse->SetFillColor(30);
   ellipse->SetLineColor(51);
   ellipse->SetLineWidth(3);
   ellipse->Draw();

   // Draw an ellipse with transparent colors, above the previous one.
   ellipse = new TEllipse(0.2985315,0.7092105,0.1566977,0.1868421,0,360,0);
   ellipse->SetFillColorAlpha(9, 0.571);
   ellipse->SetLineColorAlpha(8, 0.464);
   ellipse->SetLineWidth(3);
   ellipse->Draw();

   // Draw a transparent blue text.
   tex = new TLatex(0.04871059,0.1837649,"This text is transparent");
   tex->SetTextColorAlpha(9, 0.476);
   tex->SetTextSize(0.125);
   tex->SetTextAngle(26.0);
   tex->Draw();
}
Esempio n. 3
0
int
main (int argc, char *argv[])
{
  if (argc != 2)
    {
      cout << "Usage: " << argv[0] << " INPUT_FILE" << endl;
      cout << "  or:  " << argv[0] << " INPUT_LIST" << endl;
      cout << "" << endl;
      cout << endl;

      return 0;
    }
  string inputFile = argv[1], upperInputFile;
  upperInputFile.resize (inputFile.length ());
  transform (inputFile.begin (), inputFile.end (), upperInputFile.begin (), ::toupper);

  // so canvases don't appear on the screen when being created
  // very useful when running on the OSU T3 from CERN
  gROOT->SetBatch();
  gStyle->SetPadTopMargin(0.1);
  gStyle->SetPadBottomMargin(0.1);
  gStyle->SetPadLeftMargin(0.03);
  gStyle->SetPadRightMargin(0.08);

  //Create chain of root trees
  TChain chain("Delphes");

  if (upperInputFile.length () < 5 || upperInputFile.substr (upperInputFile.length () - 5, 5) != ".ROOT")
  {
    ifstream fin (inputFile);
    string line;
    while(getline(fin, line))
      {
        chain.Add(line.c_str());
      }
    fin.close();
  }
  else
    chain.Add(inputFile.c_str());

  // Create object of class ExRootTreeReader
  ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);

  // Get pointers to branches used in this analysis
  TClonesArray *branchTrack = treeReader->UseBranch("Track");
  TClonesArray *branchCluster = treeReader->UseBranch("Cluster"); 
  TClonesArray *branchNPU = treeReader->UseBranch("NPU");

  //gStyle->SetOptStat(10011);
  //actually, let's turn this off for now
  gStyle->SetOptStat(0);


  TH2D *hist[LEN];
  signal (SIGINT, signalHandler);
  //Loop over a LEN Events
  for (int event = 0; event < LEN && !interrupted; event++) {

    //Load Branches
    treeReader->ReadEntry(event);

    // N.B. this is a hack put in by Andrew using the ScalarHT class                                                                                                                                    
    // it's the number of pileup interactions, it's not actually the HT                                                                                                                                 
    unsigned nInteractions = (unsigned) ((ScalarHT *) branchNPU->At(0))->HT + 1;
    int nClusters = branchCluster->GetEntries();


    // create and format the histogram for this event
    TString name = "TrackPtVsTrackZ_" + TString(Form("%d",event+1));
    TCanvas *can = new TCanvas(name,name,1600,500);

    TString title = "Event " + TString(Form("%d",event+1)) + ": ";
    title += TString(Form("%d",nInteractions)) + " Interactions, ";
    title += TString(Form("%d",nClusters)) + " Clusters";

    hist[event] = new TH2D(name, title, X_BIN, X_MIN, X_MAX, Y_BIN, Y_MIN, Y_MAX);
    hist[event]->GetXaxis()->SetTitle("track z [mm]");
    hist[event]->GetXaxis()->SetLabelOffset(0.02);
    hist[event]->GetXaxis()->SetTitleOffset(1.2);
    hist[event]->GetYaxis()->SetTitle("track p_{T} [GeV]");
    hist[event]->GetYaxis()->SetTitleOffset(0.35);


    
    TArrow *genPVArrow = new TArrow(0,0,0,0.01,0.01,"|>");
    genPVArrow->SetLineColor(3);
    genPVArrow->SetFillColor(3);
    genPVArrow->SetLineWidth(0.1);
    genPVArrow->SetAngle(40);

    vector<float> interactionPositions;
    vector<TLine *> clusterLineVector;
    Cluster *recoPV = (Cluster *) branchCluster->At(0);
    TLine *highELine = new TLine(recoPV->Z,0,recoPV->Z,Y_MAX);
    highELine->SetLineColor(1);
    highELine->SetLineWidth(0.8);
    highELine->SetLineStyle(3);

    // Draw cluster lines
    // Skip first cluster since we've already drawn it (start from 1)
    for(int iCluster = 1; iCluster < branchCluster->GetEntries(); iCluster++) {
	Cluster *cluster = (Cluster *) branchCluster->At(iCluster);
	TLine *clusterLine = new TLine(cluster->Z,0,cluster->Z,Y_MAX);
	clusterLine->SetLineWidth(0.5);
	clusterLineVector.push_back(clusterLine);
    }
   
    for(int iTrack = 0; iTrack < branchTrack->GetEntries(); iTrack++) {
        Track *track = (Track *) branchTrack->At(iTrack);
	if (track->PT < Y_MAX) hist[event]->Fill(track->Z, track->PT);
	else hist[event]->Fill(track->Z, Y_MAX-0.01); // if entry would be off the y-scale, draw it in the last bin

        if(track->IsPU==0) { // track comes from primary interaction
//           genPVArrow->SetX1(track->TrueZ);  FIXME
//           genPVArrow->SetX2(track->TrueZ); FIXME
	}
//	else if (find(interactionPositions.begin(), interactionPositions.end(), track->TrueZ) == interactionPositions.end()){ FIXME
//	  interactionPositions.push_back(track->TrueZ); FIXME
//	} FIXME
    }

    //create arrows for all the generated pileup interactions
    vector<TArrow *> interactionArrowVector;
    for(uint iInteraction = 0; iInteraction < interactionPositions.size() ; iInteraction++) {
      TArrow *interactionArrow = new TArrow(interactionPositions.at(iInteraction),0,interactionPositions.at(iInteraction),0.01,0.01,"|>");
      interactionArrow->SetLineWidth(0.1);
      interactionArrow->SetAngle(20);
      interactionArrow->SetLineColor(2);
      interactionArrow->SetFillColor(2);
      interactionArrowVector.push_back(interactionArrow);
    }
  
    //Draw and save images
    hist[event]->Draw("contz");
    for(uint iCluster = 0; iCluster < clusterLineVector.size(); iCluster++) {
      clusterLineVector.at(iCluster)->Draw();
    } 
    for(uint iInteraction = 0; iInteraction < interactionArrowVector.size(); iInteraction++) {
      interactionArrowVector.at(iInteraction)->Draw();
    } 
    highELine->Draw();
    genPVArrow->Draw();

    TLegend *leg = new TLegend(0.07,0.6,0.25,0.89);
    leg->SetBorderSize(0);
    leg->SetFillColor(0);
    leg->SetFillStyle(0);
    leg->AddEntry(genPVArrow, "Primary Gen. Interaction", "");
    if (interactionArrowVector.size() > 0) leg->AddEntry(interactionArrowVector.at(0), "Pileup Interactions", "");
    leg->AddEntry(highELine, "Highest #Sigmap_{T}^{2} Cluster", "l");
    if (clusterLineVector.size() > 0) leg->AddEntry(clusterLineVector.at(0), "Other Clusters", "l");
    leg->Draw();


    //hack to get the triangles to draw in the legend
    double x_left = X_MIN + (X_MAX-X_MIN)/13;
    double x_right = X_MIN + (X_MAX-X_MIN)/13;

    if (interactionArrowVector.size() > 0){
      TArrow *interactionArrowLabel = new TArrow(x_left,Y_MAX*0.86,x_right,Y_MAX*0.86,0.02,"|>");
      interactionArrowLabel->SetLineWidth(1);
      interactionArrowLabel->SetAngle(20);
      interactionArrowLabel->SetLineColor(2);
      interactionArrowLabel->SetFillColor(2);
      interactionArrowLabel->Draw();
    }
    TArrow *genPVArrowLabel = new TArrow(x_left,Y_MAX*0.94,x_right,Y_MAX*0.94,0.02,"|>");
    genPVArrowLabel->SetLineWidth(1);
    genPVArrowLabel->SetAngle(40);
    genPVArrowLabel->SetLineColor(3);
    genPVArrowLabel->SetFillColor(3);
    genPVArrowLabel->Draw();
    
    can->SaveAs("output/" + name + ".pdf");
    //can->Write();

  }
}