]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDPattern.cxx
added low and high flux parameters to the array
[u/mrichter/AliRoot.git] / FMD / AliFMDPattern.cxx
index ebdb15e77e12c8f0d3d31db6589e4c47b7c3a961..932736d11b423abfe9db4a9905946c48c2c9bc0e 100644 (file)
@@ -65,7 +65,8 @@ AliFMDPattern::AliFMDPatternDetector::AliFMDPatternDetector(UShort_t id)
   : fId(id),
     fCounts(0), 
     fGraphs(0), 
-    fFrame(0)
+    fFrame(0), 
+    fInners(id == 1 ? 10 : 0)
 {
   // CTOR 
   // 
@@ -103,8 +104,48 @@ AliFMDPattern::AliFMDPatternDetector::DrawShape(TObjArray& a)
 
 //____________________________________________________________________
 void
-AliFMDPattern::AliFMDPatternDetector::Begin(Int_t nlevel, Double_t r, 
-                              TObjArray& inners, TObjArray& outers)
+AliFMDPattern::AliFMDPatternDetector::CopyShapes(TObjArray& src, 
+                                                TObjArray& dest, 
+                                                Double_t ang, 
+                                                Double_t fx, 
+                                                Double_t fy)
+{
+  TIter     next(&src);
+  TGraph*   g = 0;
+  while ((g = static_cast<TGraph*>(next()))) { 
+    TGraph* gg = new TGraph(*g);
+    Double_t* x  = gg->GetX();
+    Double_t* y  = gg->GetY();
+    for (Int_t i = 0; i < gg->GetN(); i++) { 
+      Float_t xx = x[i] * TMath::Cos(ang) - y[i] * TMath::Sin(ang);
+      Float_t yy = x[i] * TMath::Sin(ang) + y[i] * TMath::Cos(ang);
+      gg->SetPoint(i, fx * xx, fy * yy);
+    }
+    gg->SetFillStyle(g->GetFillStyle());
+    gg->SetFillColor(g->GetFillColor());
+    gg->SetLineStyle(g->GetLineStyle());
+    gg->SetLineColor(g->GetLineColor());
+    gg->SetLineWidth(g->GetLineWidth());
+    gg->SetMarkerStyle(g->GetMarkerStyle());
+    gg->SetMarkerColor(g->GetMarkerColor());
+    gg->SetMarkerSize(g->GetMarkerSize());
+    TString name(g->GetName());
+    name.ReplaceAll("X", Form("%d",fId));
+    gg->SetName(name.Data());
+    TString title(g->GetTitle());
+    title.ReplaceAll("X", Form("%d",fId));
+    gg->SetTitle(title.Data());
+    dest.Add(gg);
+  }
+  dest.SetOwner();
+}
+
+//____________________________________________________________________
+void
+AliFMDPattern::AliFMDPatternDetector::Begin(Int_t      nlevel, 
+                                           Double_t   r, 
+                                           TObjArray& inners, 
+                                           TObjArray& outers)
 {
   // Start of a run. 
   // 
@@ -120,16 +161,26 @@ AliFMDPattern::AliFMDPatternDetector::Begin(Int_t nlevel, Double_t r,
   TStyle* style = gStyle;  
   if (nlevel < 1) nlevel = style->GetNumberOfColors();
   fCounts.Set(nlevel);
+  Double_t rr = 1.05 * r;
   if (!fFrame) {
     // The code-checker thinks this is not using the declaration of
     // TH2F - what a morron!   
     fFrame = new TH2F(Form("fmd%dFrame", fId), Form("FMD%d", fId), 
-                     10, -r, r, 10, -r, r);
+                     100, -rr, rr, 100, -rr, rr);
     fFrame->SetStats(kFALSE);
     fFrame->Draw();
   }
-  DrawShape(inners);
-  if (fId != 1) DrawShape(outers);
+  Double_t ang = (fId == 1 ? -TMath::Pi() / 2 : 0);
+  Double_t fx  = (fId == 3 ? -1               : 1); // Flip around Y
+  Double_t fy  = (fId == 1 ?  1               : 1); // Flip around X
+  
+  CopyShapes(inners, fInners, ang, fx, fy);
+  DrawShape(fInners);
+  if (fId != 1) { 
+    CopyShapes(outers, fOuters, ang, fx, fy);
+    DrawShape(fOuters);
+  }
+
   for (Int_t i = 0; i < nlevel; i++) { 
     TGraph* g = new TGraph;
     Int_t idx = Int_t(Float_t(i) / nlevel * style->GetNumberOfColors());
@@ -140,10 +191,11 @@ AliFMDPattern::AliFMDPatternDetector::Begin(Int_t nlevel, Double_t r,
     g->SetFillColor(col);
     g->SetMarkerSize(i * .2 + .2);
     g->SetMarkerStyle(2);
+    g->SetEditable(kFALSE);
     g->Draw("same p");
     fGraphs.AddAtAndExpand(g, i);
   }
-  TIter   next(&fGraphs);
+  // TIter   next(&fGraphs);
 }
 
 //____________________________________________________________________
@@ -167,12 +219,25 @@ AliFMDPattern::AliFMDPatternDetector::End()
   TIter   next(&fGraphs);
   TGraph* g = 0;
   Int_t   i = 0;
-  while ((g = static_cast<TGraph*>(next()))) g->Set(fCounts[i++]);
+  while ((g = static_cast<TGraph*>(next()))) { 
+    Int_t cnt = fCounts[i++];
+    if (cnt > 0) { 
+      g->Set(cnt);
+      g->SetMarkerSize(i * .2 + .2);
+    }
+    else {
+      g->SetPoint(0,0,0);
+      g->SetMarkerSize(0);
+    }
+  }
+  
 }
 //____________________________________________________________________
 void
-AliFMDPattern::AliFMDPatternDetector::AddMarker(Double_t x, Double_t y, Float_t s, 
-                                  Float_t max)
+AliFMDPattern::AliFMDPatternDetector::AddMarker(Double_t x, 
+                                               Double_t y, 
+                                               Float_t  s, 
+                                               Float_t  max)
 {
   // Add a marker at (X,Y,Z).  The marker color and size is chosen
   // relative to the MAX argument. 
@@ -195,6 +260,8 @@ AliFMDPattern::AliFMDPatternDetector::AddMarker(Double_t x, Double_t y, Float_t
 //____________________________________________________________________
 AliFMDPattern::AliFMDPattern(const char* gAliceFile)
   : AliFMDDisplay(kTRUE, gAliceFile),
+    fInners(0), 
+    fOuters(0),
     fInnerMax(0), 
     fOuterMax(0),
     fFMD1Pad(0),
@@ -203,6 +270,7 @@ AliFMDPattern::AliFMDPattern(const char* gAliceFile)
     fFMD2(2),
     fFMD3Pad(0),
     fFMD3(3),
+    fSummary(0),
     fEvent(.1, .8, "Event #"),
     fFMD1Sum(.2, .7, "# in FMD1: "),
     fFMD2Sum(.2, .6, "# in FMD2: "),
@@ -217,6 +285,9 @@ AliFMDPattern::AliFMDPattern(const char* gAliceFile)
   //   gAliceFile      The galice.root file to use - if any. 
   // 
 
+  SetName("AliFMDPattern");
+  SetName("2D display of FMD data");
+  
   // RemoveLoad(kGeometry);
   fEvent.SetBit(TLatex::kTextNDC);
   fFMD1Sum.SetBit(TLatex::kTextNDC);
@@ -245,6 +316,7 @@ AliFMDPattern::Init()
   // Initialize.  Get transforms and such, 
   if (!AliFMDInput::Init()) return kFALSE;
   AliFMDGeometry* geom = AliFMDGeometry::Instance();
+  if (!geom) return kFALSE;
   geom->Init();
   geom->InitTransformations();
   
@@ -257,7 +329,7 @@ AliFMDPattern::Init()
     TObjArray&       gs = (*r == 'I' ? fInners   : fOuters);
     Float_t&         mr = (*r == 'I' ? fInnerMax : fOuterMax);
     Int_t            nm = ring->GetNModules();
-    AliInfo(Form("Making %d modules for %c", nm, *r));
+    AliFMDDebug(1, ("Making %d modules for %c", nm, *r));
     for (Int_t m = 0; m < nm; m++) {
       Int_t          nv = vs.GetEntries();
       Double_t       a  = TMath::Pi() / 180 * (m * 2 + 1) * ring->GetTheta();
@@ -271,7 +343,8 @@ AliFMDPattern::Init()
        if (c == 0) { x0 = w.X(); y0 = w.Y(); }
        g->SetPoint(c, w.X(), w.Y());
       }
-      g->SetName(Form("FMDX%c_%02d", *r, m));
+      g->SetName(Form("FMDX%c_%02d%02d", *r, 2*m,2*m+1));
+      g->SetTitle(Form("FMDX%c, sectors %d and %d", *r, 2*m,2*m+1));
       g->SetPoint(nv, x0, y0);
       g->SetFillColor((*rs == 'I' ? 
                       (m % 2 == 0 ? 18 : 17) :
@@ -298,7 +371,7 @@ AliFMDPattern::Begin(Int_t event)
   // 
   MakeAux();
   if (!fCanvas) {
-    const char* which[] = { "Continue", "Redisplay", 0 };
+    const char* which[] = { "Continue", "Start", "Pause", "Redisplay", 0 };
     MakeCanvas(which);
     
     AliFMDGeometry* geom = AliFMDGeometry::Instance();
@@ -400,10 +473,21 @@ AliFMDPattern::ProcessHit(AliFMDHit* hit, TParticle*)
   //   HIT             The hit to process. 
   // 
   // The TParticle argument is never used. 
+  static const Float_t rMin  = fgkEdepRange.fLow;
+  static const Float_t rMax  = fgkEdepRange.fHigh;
+
+  if (!hit) { AliError("No hit");   return kFALSE; }
+  // if (!p)   { AliError("No track"); return kFALSE; }
+  Float_t  edep  = hit->Edep();
+
+  if (fHits)                        fHits->Add(hit);
+  if (fSpec)                        fSpec->Fill(edep);
+  if (InsideCut(edep, rMin, rMax) && fSpecCut) fSpecCut->Fill(edep);
+
   switch (hit->Detector()) {
-  case 1: fFMD1.AddMarker(hit->X(), hit->Y(), hit->Edep(), 1); break;
-  case 2: fFMD2.AddMarker(hit->X(), hit->Y(), hit->Edep(), 1); break;
-  case 3: fFMD3.AddMarker(hit->X(), hit->Y(), hit->Edep(), 1); break;
+  case 1: fFMD1.AddMarker(hit->X(), hit->Y(), hit->Edep(), rMax); break;
+  case 2: fFMD2.AddMarker(hit->X(), hit->Y(), hit->Edep(), rMax); break;
+  case 3: fFMD3.AddMarker(hit->X(), hit->Y(), hit->Edep(), rMax); break;
   }
   return kTRUE;
 }
@@ -413,7 +497,7 @@ AliFMDPattern::ProcessHit(AliFMDHit* hit, TParticle*)
 void
 AliFMDPattern::AddMarker(UShort_t det, Char_t rng, 
                         UShort_t sec, UShort_t str,
-                        TObject*, Float_t s, Float_t max)
+                        TObject*, Float_t s, Float_t /*min*/, Float_t max)
 {
   // Add a marker to the display
   //
@@ -437,7 +521,7 @@ AliFMDPattern::AddMarker(UShort_t det, Char_t rng,
   geom->Detector2XYZ(det, rng, sec, str, x, y, z);
   // Make code-checker shut the f**k up 
   TRandom* rand = gRandom;
-  if (true) {
+  if (false) {
     AliFMDRing* r  = geom->GetRing(rng);
     Double_t    t  = .9 * r->GetTheta() / 2;
     Double_t    a  = rand->Uniform(-t,t) * TMath::Pi() / 180;