GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FillIt.C
Go to the documentation of this file.
1 
3 void FillIt()
4 {
5  const Int_t MAXMARKERS = 100; Int_t i, nbmarkers; Stat_t x[MAXMARKERS]; Int_t ind[MAXMARKERS]; TList markers; markers.SetOwner(false);
6 
7  // this is an action on pad
8  if ( TVirtualPad::Pad() == NULL ) return;
9 
10  // look for an histogram and markers in the current pad
11  TH1 *hist;
12  TIter next(TVirtualPad::Pad()->GetListOfPrimitives());
13 
14  hist = NULL; nbmarkers = 0;
15  while ( (obj = next()) ) {
16  if ( obj->InheritsFrom("TMarker") ) {
17  x[nbmarkers] = ((TMarker*)obj)->GetX(); markers.AddAt(obj,nbmarkers); nbmarkers++;
18  }
19  if ( obj->InheritsFrom("TH1") ) { hist = (TH1 *)obj; }
20  }
21  if ( hist == NULL || nbmarkers < 2 ) {
22  printf("There is no histograms or enough clicks in the current pad to realise an integration \n"); return; }
23 
24  TMath::Sort(nbmarkers,x,ind,false); // in case markers have been added without order
25 
26  Int_t first_bin, last_bin; Stat_t first_bin_c, last_bin_c;
27 
28  for ( i = 0; i < nbmarkers - 1; i++ ) {
29 
30  TH1 *clone = hist->Clone(); clone->Reset("ICE"); clone->SetFillColor( ((TMarker *)markers.At(ind[i]))->GetMarkerColor() );
31 
32  if ( i % 2 == 0 ) clone->SetFillStyle(3004);
33  else clone->SetFillStyle(3005);
34 
35  first_bin = hist->FindBin( x[ind[i]] );
36  last_bin = hist->FindBin( x[ind[i+1]] );
37  for (Int_t bin = first_bin; bin < last_bin; bin++ ) { clone->SetBinContent(bin,hist->GetBinContent(bin)); }
38 
39  clone->Draw("same");
40  }
41 }
42 
43 
printf("******************************************************************** \n")
void FillIt()
Function to fill areas between markers.
Definition: FillIt.C:3