]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/scripts/SpectraMonitor.C
Added test scripts.
[u/mrichter/AliRoot.git] / FMD / scripts / SpectraMonitor.C
1 // 
2 //____________________________________________________________________
3 //
4 // $Id: DrawHits.C 22496 2007-11-26 13:50:44Z cholm $
5 //
6 // Script that contains a class to draw hits, using the
7 // AliFMDInputHits class in the util library. 
8 //
9 // Use the script `Compile.C' to compile this class using ACLic. 
10 //
11
12 void
13 SpectraMonitor(const char* file="", 
14                Int_t       runno=0, 
15                const char* cdbSrc="local://$ALICE_ROOT/OCDB", 
16                UShort_t    over=0)
17 {
18   gSystem->Load("libANALYSIS.so");
19   gSystem->Load("libFMDanalysis.so");
20   gSystem->Load("libFMDutil.so");
21   // AliLog::SetModuleDebugLevel("FMD", 8);
22   TString fname(file);
23   if (fname.CompareTo("help", TString::kIgnoreCase) == 0) { 
24     std::cout << "Usage: RunSpectraMonitor(<src>[,<runno>[,<cdb>[,<over>]]])\n"
25               << "\n"
26               << "Where:\n\n"
27               << "   <src>         Is a data source (online, file)\n"
28               << "   <runno>       Is the (optional) run number\n"
29               << "   <cdb>         Is the (optional) CDB storage\n"
30               << "   <over>        Is the (optional) over sampling rate\n\n"
31               << "Defaults are <runno>=0 and cdb=\"local://$ALICE_ROOT/OCDB\"\n" 
32               << "<over> allows one to override the CDB setting.  Default\n"
33               << "is to use the CDB setting.\n\n"
34               << "Note: This script _must_ be compiled with ACLic"
35               << std::endl;
36     return;
37   }
38   AliCDBManager* cdb = AliCDBManager::Instance();
39   cdb->SetDefaultStorage(cdbSrc);
40   cdb->SetRun(runno);
41   UInt_t what = (AliFMDParameters::kPulseGain      |
42                  AliFMDParameters::kPedestal       |
43                  AliFMDParameters::kDeadMap        |
44                  AliFMDParameters::kZeroSuppression|
45                  AliFMDParameters::kAltroMap       |
46                  AliFMDParameters::kStripRange);
47   if (over != 0) what |= AliFMDParameters::kSampleRate;
48   AliFMDParameters::Instance()->Init(kFALSE, what);
49   if (over != 0) AliFMDParameters::Instance()->SetSampleRate(over);
50   
51   AliFMDSpectraDisplay* d = new AliFMDSpectraDisplay;
52   // d->AddLoad(AliFMDInput::kRaw);
53   d->AddLoad(AliFMDInput::kDigits);
54   // d->SetRawFile(file);
55   d->Run();
56 }
57
58 #if 0
59 #include <AliCDBManager.h>
60 #include <AliFMDParameters.h>
61 #include <AliFMDHit.h>
62 #include <AliFMDDigit.h>
63 #include <AliFMDSDigit.h>
64 #include <AliFMDRecPoint.h>
65 #include <AliESDFMD.h>
66 #include <AliFMDPattern.h>
67 #include <TBrowser.h>
68 #include <TDirectory.h>
69 #include <TObjArray.h>
70 #include <TH1.h>
71 #include <TH2.h>
72 #include <TH3.h>
73 #include <TGraph.h>
74 #include <TF1.h>
75 #include <iostream>
76 #include <TStyle.h>
77 #include <TEnv.h>
78 #include <TCanvas.h>
79 #include <TGFrame.h>
80 #include <TGCanvas.h>
81 #include <TGListTree.h>
82 #include <TGClient.h>
83 #include <TSystem.h>
84 #include <KeySymbols.h>
85 #include <TClass.h>
86 #include <RQ_OBJECT.h>
87 #include <TSlider.h>
88
89 namespace Spectra { 
90   struct Top;
91   struct Detector;
92   struct Ring;
93   struct Sector;
94   struct Strip;
95   
96   //__________________________________________________________________
97   struct Element : public TNamed 
98   {
99     virtual ~Element() {}
100     virtual void Draw(Option_t* option, Double_t l, Double_t h);
101     virtual Top& GetTop() = 0;
102     virtual void MakeHistograms(TAxis* axis);
103   protected:
104     Element(const char* name, const char* title) 
105       : TNamed(name, title), fFull(0), fCut(0)
106     {}
107     void DoFill(Double_t v);
108     TH1* fFull;
109     TH1* fCut;
110   };
111
112   //__________________________________________________________________
113   struct Top : public Element
114   {
115     RQ_OBJECT("Spectra::Top")
116     public:
117     Top(TGCompositeFrame& frame, TCanvas* canvas);
118     TGListTree& GetList() { return fList; }
119     Detector& GetOrAdd(UShort_t id);
120     void      Fill(UShort_t d, Char_t ring, 
121                    UShort_t sec, UShort_t str, Double_t v);
122     TAxis* GetAxis() { return fAxis; }
123     void SetAxis(TAxis* a);
124     Top&   GetTop() { return *this; }
125        
126     /** Handle entries 
127         @param e  selected entry, if any 
128         @param id Id of entry */
129     virtual void HandleEntry(TGListTreeItem* e, Int_t id);
130     /** Handle key strokes 
131         @param f      Item selected, if any 
132         @param keysym Key symbol 
133         @param mask   Modifier mask */
134     virtual void HandleKey(TGListTreeItem* f, UInt_t keysym, UInt_t mask);
135     /** Handle Return 
136         @param f Selected item, if any */
137     virtual void HandleReturn(TGListTreeItem* f);
138     /** Clear the list */
139     virtual void ClearList();
140     /** Clear the canvas */ 
141     virtual void ClearCanvas();
142     /** Update canvas */ 
143     virtual void UpdateCanvas();
144     /** Update canvas */ 
145     virtual void UpdateList();
146     /** Return the currently selected entry */ 
147     TGListTreeItem* CurrentEntry() const { return fCurrentEntry; }
148     /** @return the currently selected user data (possibly 0) */
149     TObject* Current() const;
150     /** Selection changed signal */
151     void SelectionChanged() { Emit("SelectionChanged()"); }//*SIGNAL*
152     /** Get Picture for 1D histogram */
153     const TGPicture* GetH1Pic() { return fHist1DIcon; }
154     /** 2D Histogram Icon */
155     const TGPicture* GetH2Pic() { return fHist2DIcon; }
156     /** 3D Histogram Icon */
157     const TGPicture* GetH3Pic() { return fHist3DIcon; }
158     /** Graph Icon */
159     const TGPicture* GetGPic() { return fGraphIcon; }
160     TGListTreeItem&  GetEntry() { return fEntry; }
161   protected:
162     TGLayoutHints fHints;
163     TGCanvas      fContainer;
164     TGListTree    fList;
165     TObjArray     fChildren;
166     TGListTreeItem* fCurrentEntry;
167     TCanvas*        fCanvas;
168     /** 1D Histogram Icon */
169     const TGPicture*    fHist1DIcon;
170     /** 2D Histogram Icon */
171     const TGPicture*    fHist2DIcon;
172     /** 3D Histogram Icon */
173     const TGPicture*    fHist3DIcon;
174     /** Graph Icon */
175     const TGPicture*    fGraphIcon;
176     /** The axis to use */ 
177     TAxis* fAxis;
178     /** Top entry */ 
179     TGListTreeItem& fEntry;
180   };
181
182   //__________________________________________________________________
183   struct Detector : public Element 
184   {
185     Detector(UShort_t det, Top& top);
186     UShort_t Id() const { return fId; }
187     Top&     GetTop() { return fParent; }
188     Top&     GetParent() { return fParent; }
189     Ring&    GetOrAdd(Char_t id);
190     void     Fill(Char_t ring, UShort_t sec, UShort_t str, Double_t v);
191     TGListTreeItem&  GetEntry() { return fEntry; }
192   protected:
193     UShort_t        fId;
194     Top&            fParent;
195     TObjArray       fChildren;
196     TGListTreeItem& fEntry;
197   };
198
199   //__________________________________________________________________
200   struct Ring : public Element 
201   {
202     Ring(Char_t id, Detector& d);
203     Char_t    Id() const { return fId; }
204     UShort_t  DetectorId() { return fParent.Id(); }
205     Top&      GetTop() { return fParent.GetTop(); }
206     Detector& GetDetector() { return GetParent(); }
207     Detector& GetParent() { return fParent; }
208     Sector&   GetOrAdd(UShort_t id);
209     void      Fill(UShort_t sec, UShort_t str, Double_t v);
210     TGListTreeItem&  GetEntry() { return fEntry; }
211   protected:
212     Detector&       fParent;
213     Char_t          fId;
214     TObjArray       fChildren;
215     TGListTreeItem& fEntry;
216   };
217   
218   //__________________________________________________________________
219   struct Sector : public Element 
220   {
221     Sector(UShort_t id, Ring& r);
222     UShort_t  Id() const    { return fId; }
223     UShort_t  DetectorId()  { return fParent.DetectorId(); }
224     Char_t    RingId()      { return fParent.Id(); }
225     Top&      GetTop()      { return fParent.GetTop(); }
226     Detector& GetDetector() { return fParent.GetDetector(); }
227     Ring&     GetRing()     { return fParent; }
228     Ring&     GetParent()   { return fParent; }
229     Strip&    GetOrAdd(UShort_t id);
230     void      Fill(UShort_t str, Double_t v);
231     TGListTreeItem&  GetEntry() { return fEntry; }
232   protected:
233     Ring&           fParent;
234     UShort_t        fId;
235     TObjArray       fChildren;
236     TGListTreeItem& fEntry;
237   };
238
239   //__________________________________________________________________
240   struct Strip : public Element 
241   {
242     Strip(UShort_t id, Sector& s);
243     UShort_t  Id() const    { return fId; }
244     UShort_t  DetectorId()  { return fParent.DetectorId(); }
245     Char_t    RingId()      { return fParent.RingId(); }
246     UShort_t  SectorId()    { return fParent.Id(); }
247     Top&      GetTop()      { return fParent.GetTop(); }
248     Detector& GetDetector() { return fParent.GetDetector(); }
249     Ring&     GetRing()     { return fParent.GetRing(); }
250     Sector&   GetSector()   { return fParent; }
251     Sector&   GetParent()   { return fParent; }
252     void      Fill(Double_t v);
253     TGListTreeItem&  GetEntry() { return fEntry; }
254   protected:
255     Sector&         fParent;
256     UShort_t        fId;
257     TGListTreeItem& fEntry;
258   };
259
260   //==================================================================
261   void Element::MakeHistograms(TAxis* axis) 
262   {
263     if (fFull) return;
264     if (axis->IsVariableBinSize()) {
265       fFull = new TH1F(Form("f_%s", GetName()), Form("%s spectra", GetName()),
266                        axis->GetXbins()->fN, axis->GetXbins()->fArray);
267       fCut = new TH1F(Form("c_%s", GetName()), 
268                       Form("%s restricted spectra", GetName()),
269                       axis->GetXbins()->fN, axis->GetXbins()->fArray);
270     }
271     else { 
272       fFull = new TH1F(Form("f_%s", GetName()), Form("%s spectra", GetName()),
273                        axis->GetNbins(), axis->GetXmin(), axis->GetXmax());
274       fCut = new TH1F(Form("c_%s", GetName()), 
275                       Form("%s restricted spectra", GetName()),
276                       axis->GetNbins(), axis->GetXmin(), axis->GetXmax());
277     }
278     fFull->SetFillColor(kRed);
279     fFull->SetFillStyle(3001);
280     fCut->SetFillColor(kBlue);
281     fCut->SetFillStyle(3001);
282   }
283   //__________________________________________________________________
284   void Element::DoFill(Double_t v) 
285   {
286     if (fFull) fFull->Fill(v);
287   }
288   //__________________________________________________________________
289   void Element::Draw(Option_t* option, Double_t l, Double_t h) 
290   {
291     if (!fFull) return;
292     if (fFull->GetMinimum() < 0) gPad->SetLogy(kFALSE);
293     fFull->Draw(option);
294     Double_t lx = fFull->GetXaxis()->GetXmin();
295     Double_t hx = fFull->GetXaxis()->GetXmax();
296     Double_t rr = (hx-lx);
297     Double_t ll = rr * l + lx;
298     Double_t hh = rr * h + lx;
299     for (Int_t i = 1; i <= fFull->GetNbinsX(); i++) { 
300       if (fFull->GetBinCenter(i) <= ll || 
301           fFull->GetBinCenter(i) >  hh) { 
302         fCut->SetBinContent(i, 0); 
303         continue;
304       }
305       fCut->SetBinContent(i, fFull->GetBinContent(i));
306     }
307     fCut->Draw(Form("%s same", option));
308   }
309   //==================================================================
310   Top::Top(TGCompositeFrame& frame, TCanvas* canvas) 
311     : Element("All", "Everything"), 
312       fHints(kLHintsExpandX|kLHintsExpandY,3, 3, 3, 3),
313       fContainer(&frame, 200, 350), 
314       fList(&fContainer, kHorizontalFrame),
315       fChildren(0),
316       fCurrentEntry(0),
317       fCanvas(canvas),
318       fHist1DIcon(gClient->GetPicture("h1_t.xpm")),
319       fHist2DIcon(gClient->GetPicture("h2_t.xpm")),
320       fHist3DIcon(gClient->GetPicture("h3_t.xpm")),
321       fGraphIcon(gClient->GetPicture("graph.xpm")), 
322       fEntry(*(fList.AddItem(0, GetName(), this)))
323   {
324     fContainer.AddFrame(&fList, &fHints);
325     frame.AddFrame(&fContainer, &fHints);
326
327     fList.Connect("Clicked(TGListTreeItem*,Int_t)", "Spectra::Top", this, 
328                   "HandleEntry(TGListTreeItem*,Int_t)");
329     fList.Connect("KeyPressed(TGListTreeItem*,ULong_t,ULong_t)", 
330                   "Spectra::Top", this, 
331                   "HandleKey(TGListTreeItem*,UInt_t,UInt_t)");
332     fList.Connect("ReturnPressed(TGListTreeItem*)", "Spectra::Top", this, 
333                   "HandleReturn(TGListTreeItem*)");
334   }
335   //____________________________________________________________________
336   void
337   Top::SetAxis(TAxis* axis) 
338   {
339     fAxis = axis;
340     MakeHistograms(axis);
341   }
342   //____________________________________________________________________
343   void
344   Top::ClearCanvas()
345   {
346     if (!fCanvas) return;
347     fCanvas->Clear();
348   }
349   
350   //____________________________________________________________________
351   void
352   Top::ClearList()
353   {
354     fList.DeleteItem(fList.GetFirstItem());
355     UpdateList();
356   }
357   
358   
359   //____________________________________________________________________
360   void
361   Top::HandleReturn(TGListTreeItem * f)
362   {
363     
364     if (!f) { 
365       fList.UnselectAll(kFALSE);
366       fList.SetSelected(0);
367       return;
368     }
369     fList.ToggleItem(f);
370     UpdateList();
371   }
372   
373   
374   //____________________________________________________________________
375   void
376   Top::HandleKey(TGListTreeItem * f, UInt_t keysym, UInt_t /*mask*/)
377   {
378     if (!f) { 
379       fList.UnselectAll(kFALSE);
380       fList.SetSelected(0);
381       return;
382     }
383     TGListTreeItem* next = 0;
384     switch (keysym) {
385     case kKey_Up:
386       next = f->GetPrevSibling();
387     if (!next) { 
388       next = f->GetParent();
389       if (next) fList.CloseItem(next);
390     }
391     break;
392     case kKey_Down:
393       next = f->GetNextSibling();
394       if (!next && f->GetParent()) {
395         next = f->GetParent()->GetNextSibling();
396         fList.CloseItem(f->GetParent());
397       }
398       break;
399     case kKey_Left:
400       next = f->GetParent();
401       if (next) fList.CloseItem(next);
402       break;
403     case kKey_Right:
404       next = f->GetFirstChild();
405       if (next) fList.OpenItem(f);
406       break;
407     case kKey_PageUp:
408       fList.PageUp(kTRUE);
409       next = fList.GetSelected();
410       break;
411     case kKey_PageDown:
412       fList.PageDown(kTRUE);
413       next = fList.GetSelected();
414       break;
415     }
416     if (next) gClient->NeedRedraw(&fList);
417     if (next && next != f) {
418       fList.ClearHighlighted();
419       fList.SetSelected(next);
420       HandleEntry(next,0);
421     }
422   }
423
424   //____________________________________________________________________
425   void
426   Top::HandleEntry(TGListTreeItem* entry, Int_t /*id*/) 
427   {
428     TGListTreeItem* old = fCurrentEntry;
429     if (entry) {
430       if (!entry->GetUserData()) return;
431       fCurrentEntry = entry;
432     }
433     else {
434       fCurrentEntry = 0;
435       ClearCanvas();
436     }
437     if (old != fCurrentEntry && fCanvas) fCanvas->cd();
438     SelectionChanged();
439   }
440
441   //____________________________________________________________________
442   void
443   Top::UpdateList() 
444   {
445     gClient->NeedRedraw(&fList);
446   }
447
448   //____________________________________________________________________
449   void
450   Top::UpdateCanvas() 
451   {
452     if (!fCanvas) return;
453     fCanvas->Modified();
454     fCanvas->Update();
455     fCanvas->cd();
456   }
457   //____________________________________________________________________
458   TObject* Top::Current() const
459   {
460     if (!fCurrentEntry) return 0;
461     if (!fCurrentEntry->GetUserData()) return 0;
462     return static_cast<TObject*>(fCurrentEntry->GetUserData());
463   }
464   
465   //__________________________________________________________________
466   Detector& Top::GetOrAdd(UShort_t id) 
467   { 
468     Int_t     idx = id - 1;
469     Detector* d   = 0;
470     if (fChildren.GetEntriesFast() <= idx ||
471         !(d = static_cast<Detector*>(fChildren.At(idx))))  { 
472       d = new Detector(id, *this);
473       fChildren.AddAtAndExpand(d, idx);
474       // fList.SortChildren(&fEntry);
475     }
476     return *d;
477   }
478   //__________________________________________________________________
479   void Top::Fill(UShort_t det, Char_t ring, 
480                  UShort_t sec, UShort_t str, Double_t v) 
481   { 
482     Detector& d = GetOrAdd(det);
483     d.Fill(ring, sec, str, v);
484     DoFill(v);
485   }
486   //==================================================================
487   Detector::Detector(UShort_t det, Top& tree) 
488     : Element(Form("FMD%d", det), "FMD Sub-detector"), 
489       fId(det), 
490       fParent(tree),
491       fChildren(0),
492       fEntry(*(tree.GetList().AddItem(&(tree.GetEntry()), GetName())))
493   {
494     fEntry.SetUserData(this);
495     if (GetTop().GetAxis()) MakeHistograms(GetTop().GetAxis());
496   }
497   //__________________________________________________________________
498   Ring& Detector::GetOrAdd(Char_t id) 
499   { 
500     Int_t idx = (id == 'I' || id == 'i') ? 0 : 1;
501     Ring* r   = 0;;
502     if (fChildren.GetEntriesFast() <= idx ||
503         !(r = static_cast<Ring*>(fChildren.At(idx))))  { 
504       r = new Ring(id, *this);
505       fChildren.AddAtAndExpand(r, idx);
506       // GetTop().GetList().SortChildren(&fEntry);
507     }
508     return *r;
509   }
510   //__________________________________________________________________
511   void Detector::Fill(Char_t ring, UShort_t sec, UShort_t str, Double_t v) 
512   { 
513     Ring& r = GetOrAdd(ring);
514     r.Fill(sec, str, v);
515     DoFill(v);
516   }  
517   //==================================================================
518   Ring::Ring(Char_t id, Detector& d) 
519     : Element(Form("FMD%d%c", d.Id(), id), "FMD Ring"), 
520       fParent(d),
521       fId(id),
522       fChildren(0),
523       fEntry(*(GetTop().GetList().AddItem(&(d.GetEntry()), GetName(), this)))
524   {
525     if (GetTop().GetAxis()) MakeHistograms(GetTop().GetAxis());
526   }
527   //__________________________________________________________________
528   Sector& Ring::GetOrAdd(UShort_t id) 
529   { 
530     Sector* s = 0;
531     if (fChildren.GetEntriesFast() <= id ||
532         !(s = static_cast<Sector*>(fChildren.At(id)))) {
533       s = new Sector(id, *this);
534       fChildren.AddAtAndExpand(s, id);
535       // GetTop().GetList().SortChildren(&fEntry);
536     }
537     return *s;
538   }
539   //__________________________________________________________________
540   void Ring::Fill(UShort_t sec, UShort_t str, Double_t v) 
541   { 
542     Sector& s = GetOrAdd(sec);
543     s.Fill(str, v);
544     DoFill(v);
545   }
546   //==================================================================
547   Sector::Sector(UShort_t id, Ring& r) 
548     : Element(Form("FMD%d%c_%02d", r.DetectorId(), r.Id(), id), "FMD Sector"), 
549       fParent(r),
550       fId(id),
551       fChildren(0),
552       fEntry(*(GetTop().GetList().AddItem(&(r.GetEntry()), GetName(), this)))
553   {
554     if (GetTop().GetAxis()) MakeHistograms(GetTop().GetAxis());
555   }
556   //__________________________________________________________________
557   Strip& Sector::GetOrAdd(UShort_t id) 
558   { 
559     Strip* s = 0;
560     if (fChildren.GetEntriesFast() <= id || 
561         !(s = static_cast<Strip*>(fChildren.At(id)))) {
562       s = new Strip(id, *this);
563       fChildren.AddAtAndExpand(s, id);
564       // GetTop().GetList().SortChildren(&fEntry);
565     }
566     return *s;
567   }
568   //__________________________________________________________________
569   void Sector::Fill(UShort_t str, Double_t v) 
570   { 
571     Strip& s = GetOrAdd(str);
572     s.Fill(v);
573     DoFill(v);
574   }
575   //==================================================================
576   Strip::Strip(UShort_t id, Sector& s) 
577     : Element(Form("FMD%d%c_%02d_%03d", s.DetectorId(), s.RingId(), 
578                    s.Id(), id), "FMD Strip"), 
579       fParent(s),
580       fId(id),
581       fEntry(*(GetTop().GetList().AddItem(&(s.GetEntry()), GetName(), this)))
582   {
583     fEntry.SetPictures(GetTop().GetH1Pic(), GetTop().GetH1Pic());
584     if (GetTop().GetAxis()) MakeHistograms(GetTop().GetAxis());
585   }
586   //__________________________________________________________________
587   void Strip::Fill(Double_t v) 
588   { 
589     DoFill(v);
590   }
591 }
592
593
594 //====================================================================
595 class SpectraMonitor : public AliFMDPattern
596 {
597 private:
598   TGMainFrame  fSelector;
599   Spectra::Top fTop;
600 public:
601   SpectraMonitor()
602     : AliFMDPattern(), 
603       fSelector(gClient->GetRoot(), 100, 100), 
604       fTop(fSelector, fAux)
605   {
606     AddLoad(AliFMDInput::kRaw);
607     SetName("RAW");
608     SetTitle("RAW");
609
610     fTop.Connect("SelectionChanged()", "SpectraMonitor", this, "HandleDraw()");
611
612     fSelector.MapSubwindows();
613     fSelector.Resize(fSelector.GetDefaultSize());
614     fSelector.MapWindow();
615   }
616   // void SetAxis(TAxis* axis) { fTop.SetAxis(axis); }
617   Bool_t HandleDraw()
618   {
619     TObject* user = fTop.Current();
620     if (!user) return kFALSE;
621     if (!user->InheritsFrom(Spectra::Element::Class())) { 
622       Warning("HandleDraw", "%s does not inherit from Spectra::Element", 
623               user->GetName());
624       return kFALSE;
625     }
626     fAux->cd();
627     Spectra::Element* e = static_cast<Spectra::Element*>(user);
628     e->Draw("hist", fSlider->GetMinimum(), fSlider->GetMaximum());
629     fAux->Modified();
630     fAux->Update();
631     fAux->cd();
632     return kTRUE;
633   }
634   void MakeAux()
635   {
636     AliFMDPattern::MakeAux();
637     if (!fAux) return;
638     fTop.SetAxis(fSpec->GetXaxis());
639   }
640   void DrawAux()
641   {
642     // Draw in the Aux the canvas 
643     // For example draw the spectra 
644     // or such stuff 
645     if (fTop.Current() != &fTop && HandleDraw()) return;
646     AliFMDPattern::DrawAux();
647   }
648   Bool_t ProcessHit(AliFMDHit* hit, TParticle* p) 
649   {
650     fTop.Fill(hit->Detector(), 
651               hit->Ring(), 
652               hit->Sector(),
653               hit->Strip(), 
654               hit->Edep());
655     return AliFMDPattern::ProcessHit(hit, p);
656   }
657   Bool_t ProcessDigit(AliFMDDigit* digit)
658   {
659     fTop.Fill(digit->Detector(), 
660               digit->Ring(), 
661               digit->Sector(),
662               digit->Strip(), 
663               digit->Counts());
664     return AliFMDDisplay::ProcessDigit(digit);
665   }
666   Bool_t ProcessSDigit(AliFMDSDigit* sdigit)
667   {
668     fTop.Fill(sdigit->Detector(), 
669               sdigit->Ring(), 
670               sdigit->Sector(),
671               sdigit->Strip(), 
672               sdigit->Counts());
673     return AliFMDDisplay::ProcessSDigit(sdigit);
674   }
675   Bool_t ProcessRawDigit(AliFMDDigit* digit)
676   {
677     return ProcessDigit(digit);
678   }
679   Bool_t ProcessRecPoint(AliFMDRecPoint* recpoint)
680   {
681     fTop.Fill(recpoint->Detector(), 
682               recpoint->Ring(), 
683               recpoint->Sector(),
684               recpoint->Strip(), 
685               recpoint->Particles());
686     return AliFMDDisplay::ProcessRecPoint(recpoint);
687   }
688   Bool_t ProcessESD(UShort_t det, Char_t rng, UShort_t sec, UShort_t str,
689                     Float_t x, Float_t mult)
690   {
691     fTop.Fill(det, rng, sec, str, mult);
692     return AliFMDDisplay::ProcessESD(det, rng, sec, str, x, mult);
693   }
694 };
695
696 void
697 RunSpectraMonitor(const char* file="", 
698                   Int_t       runno=0, 
699                   const char* cdbSrc="local://$ALICE_ROOT/OCDB", 
700                   UShort_t    over=0)
701 {
702   // AliLog::SetModuleDebugLevel("FMD", 8);
703   TString fname(file);
704   if (fname.CompareTo("help", TString::kIgnoreCase) == 0) { 
705     std::cout << "Usage: RunSpectraMonitor(<src>[,<runno>[,<cdb>[,<over>]]])\n"
706               << "\n"
707               << "Where:\n\n"
708               << "   <src>         Is a data source (online, file)\n"
709               << "   <runno>       Is the (optional) run number\n"
710               << "   <cdb>         Is the (optional) CDB storage\n"
711               << "   <over>        Is the (optional) over sampling rate\n\n"
712               << "Defaults are <runno>=0 and cdb=\"local://$ALICE_ROOT/OCDB\"\n" 
713               << "<over> allows one to override the CDB setting.  Default\n"
714               << "is to use the CDB setting.\n\n"
715               << "Note: This script _must_ be compiled with ACLic"
716               << std::endl;
717     return;
718   }
719   AliCDBManager* cdb = AliCDBManager::Instance();
720   cdb->SetDefaultStorage(cdbSrc);
721   cdb->SetRun(runno);
722   UInt_t what = (AliFMDParameters::kPulseGain      |
723                  AliFMDParameters::kPedestal       |
724                  AliFMDParameters::kDeadMap        |
725                  AliFMDParameters::kZeroSuppression|
726                  AliFMDParameters::kAltroMap       |
727                  AliFMDParameters::kStripRange);
728   if (over != 0) what |= AliFMDParameters::kSampleRate;
729   AliFMDParameters::Instance()->Init(kFALSE, what);
730   if (over != 0) AliFMDParameters::Instance()->SetSampleRate(over);
731   
732   SpectraMonitor* d = new SpectraMonitor;
733   d->AddLoad(AliFMDInput::kRaw);
734   d->SetRawFile(file);
735   d->Run();
736 }
737 #endif
738
739   
740
741 //____________________________________________________________________
742 //
743 // EOF
744 //