Added macro to check run properties.
[u/mrichter/AliRoot.git] / PWG4 / TwoPartCorr / DataChecker.C
1 // $Id$
2
3 #if !defined(__CINT__) || defined(__MAKECINT__)
4 #include <Riostream.h>
5 #include <TFile.h>
6 #include <TKey.h>
7 #include <TTree.h>
8 #include <TMath.h>
9 #include <TChain.h>
10 #include <TH2F.h>
11 #include <TSystem.h>
12 #include <TTimeStamp.h>
13 #include <TStyle.h>
14 #include "TreeClasses.h"
15 #include "Utils.h"        // PlotUtils and Noti classes
16 #endif
17
18 Int_t nCuts = 2;
19 Bool_t quit = 0;
20 Bool_t printPDF = 0;
21 TFile* outFile = new TFile("out.root", "recreate");
22 const Double_t PI = TMath::Pi();
23 Int_t nEvents = -1; // Run over whole chain if < 0
24 MyHeader     *event   = 0;
25 TClonesArray *tracks  = 0;
26 TBranch      *hBranch = 0;
27 TBranch      *tBranch = 0;
28
29 // Event
30 //TH1F* hRun;            
31 TH1F* hBx;               // crossing times (ns)
32 TH1F* hNChips1;  
33 TH1F* hNChips2;  
34 TH1F* hNTracks;  
35 TH1F* hNSelTracks;       // no kink daughters, NClTPC > 20.
36 TH1F* hNTracklets;       
37 TH1F* hVx;             
38 TH1F* hVy;             
39 TH1F* hVz;               // from V0 (?)
40 TH1F* hVc;               // from TPC (?)
41 TH1F* hIsPileupSPD;      
42 TH1F* hNPileupSPD;       
43 TH1F* hNPileup;  
44 TH1F* hTrClassMask;      // get names from constantin 
45 TH1F* hTrCluster;        
46 TH1F* hVxSPD;          
47 TH1F* hVySPD;          
48 TH1F* hVzSPD;          
49 TH1F* hVcSPD;          
50 TH1F* hVxTPC;          
51 TH1F* hVyTPC;          
52 TH1F* hVzTPC;          
53 TH1F* hVcTPC;                     
54
55 // Track
56 TH1F* hSt;           // status
57 TH1F* hC;            // charge
58 TH1F* hPt;           
59 TH1F* hEta;          
60 TH1F* hPhi;          
61 TH1F* hNClTPC;       
62 TH1F* hNClTPC1;      // ?
63 TH1F* hNClTPCShared; 
64 TH1F* hNClITS;       
65 TH1F* hChi2TPC;      
66 TH1F* hChi2TPC1;     
67 TH1F* hChi2ITS;      
68 TH1F* hD;            // Transverse DCA or "impact parameter"
69 TH1F* hZ;            // Z DCA
70 TH1F* hDTPC;         
71 TH1F* hZTPC;           
72
73 // Other
74 TH1F* hStBits;
75 TH1F* hL0Bits;
76 TH1F* hTrClBits;
77 // TH1F *hEta1, *hEta2, *hEta3;
78 // TH1F *hD1, *hD2, *hD3;
79 // TH1F *hZ1, *hZ2, *hZ3;
80 TH1F* hChi2ndfTPC;   
81
82 TH2F* hDZ;
83 TH2F* hDZTPC;
84
85 void BookHistos();
86 TObjArray* GetHistList(TFile& inFile, TString clname);
87 void SetHistProps();
88 void DrawHistos(TFile& inFile);
89 void FillEventInfo(const MyHeader& ev);
90 void FillTrackInfo(const MyPart& trk);
91
92 void DataChecker(const char* inFileNames = "../rootfiles/res_LHC10c_09212010/merged_*.root")
93 {
94   // --- TTree/TChain input ---
95   Noti *nme = new Noti;
96   TChain *tree = new TChain("MyTree");
97   tree->Add(inFileNames);
98   tree->SetNotify(nme);
99   
100   Int_t nents = tree->GetEntries();
101   cout << "Found " << nents << " entries!" << endl;
102   if (nents<=0)
103     return;
104   if (nEvents>0 && nEvents<nents) { 
105     nents=nEvents;
106     cout << "Using " << nents << " entries!" << endl;
107   }
108
109   if (TClass::GetClass("MyPart"))
110     TClass::GetClass("MyPart")->IgnoreTObjectStreamer();
111   if (TClass::GetClass("MyTracklet"))
112     TClass::GetClass("MyTracklet")->IgnoreTObjectStreamer();
113
114   BookHistos();
115   
116   // --- Event loop ---
117   for (Int_t i=0;i<nents;++i) {
118     Int_t li = tree->LoadTree(i);
119     if (nme->Notified()) {
120       hBranch = tree->GetBranch("header");
121       hBranch->SetAddress(&event);
122       tBranch = tree->GetBranch("parts");
123       tBranch->SetAddress(&tracks);
124       nme->Reset();
125     }
126     
127     hBranch->GetEntry(li);
128     tBranch->GetEntry(li);
129
130     FillEventInfo(*event);
131
132     // --- Track loop ---
133     Int_t ntracks = tracks->GetEntries();
134     for (Int_t t=0;t<ntracks;++t) {
135       MyPart *trk = (MyPart*)tracks->At(t);
136
137       if (!event->fIsPileupSPD && trk->fPt > 0.4)
138         FillTrackInfo(*trk);
139     }
140   }
141   
142   outFile->Write();
143   SetHistProps();
144   DrawHistos(*outFile);
145
146   return;
147 }
148
149 void BookHistos()
150 {
151   // From MyHeader
152   // hRun                  = new TH1F("hRun", "", 1e3, 0, 5e5);                   
153  hBx               = new TH1F("hBx", "", 3000, 0, 3000);                          
154  hNChips1          = new TH1F("hNChips1", "", 150, 0, 150);           
155  hNChips2          = new TH1F("hNChips2", "", 150, 0, 150);           
156  hNTracks          = new TH1F("hNTracks", "", 500, 0, 500);           
157  hNSelTracks       = new TH1F("hNSelTracks", "", 500, 0, 500);            
158  hNTracklets       = new TH1F("hNTracklets", "", 100, 0, 100);            
159  hVx               = new TH1F("hVx", "", 100, -0.1, 0.0);               
160  hVy               = new TH1F("hVy", "", 100, 0.15, 0.25);               
161  hVz               = new TH1F("hVz", "", 40, -20, 20);               
162  hVc               = new TH1F("hVc", "", 100, 0, 100);               
163  hIsPileupSPD      = new TH1F("hIsPileupSPD", "", 3, 0, 3);                       
164  hNPileupSPD       = new TH1F("hNPileupSPD", "", 10, 0, 10);              
165  hNPileup          = new TH1F("hNPileup", "", 10, 0, 10);             
166  hTrCluster        = new TH1F("hTrCluster", "", 10, 0, 10);               
167  hVxSPD            = new TH1F("hVxSPD", "", 100, -0.5, 0.5);            
168  hVySPD            = new TH1F("hVySPD", "", 100, -0.5, 0.5);            
169  hVzSPD            = new TH1F("hVzSPD", "", 100, -20, 20);            
170  hVcSPD            = new TH1F("hVcSPD", "", 100, 0, 100);            
171  hVxTPC            = new TH1F("hVxTPC", "", 100, -0.01, 0.01);             
172  hVyTPC            = new TH1F("hVyTPC", "", 100, -0.01, 0.01);             
173  hVzTPC            = new TH1F("hVzTPC", "", 100, -5, 5);            
174  hVcTPC            = new TH1F("hVcTPC", "", 100, -1, 1);            
175                                       
176  // Other evt histos
177  hL0Bits           = new TH1F("hL0Bits", "", 32, 0, 32);   // UInt_t 
178  hTrClBits         = new TH1F("hTrClBits", "", 64, 0, 64); // ULong64_t
179
180  // From MyPart
181  hC                = new TH1F("hC", "", 5, -2.5, 2.5);                    
182  hPt               = new TH1F("hPt", "", 200, 0, 20);               
183  hEta              = new TH1F("hEta", "", 600, -3, 3);              
184  hPhi              = new TH1F("hPhi", "", 100, 0, 2*PI);              
185  hNClTPC           = new TH1F("hNClTPC", "", 200, 0, 200);            
186  hNClTPC1          = new TH1F("hNClTPC1", "", 200, 0, 200);           
187  hNClTPCShared     = new TH1F("hNClTPCShared", "", 200, 0, 200);     
188  hNClITS           = new TH1F("hNClITS", "", 20, 0, 20);              
189  hChi2TPC          = new TH1F("hChi2TPC", "", 100, 0, 100);          
190  hChi2ndfTPC       = new TH1F("hChi2ndfTPC", "", 100, 0, 100); // AMA
191  hChi2TPC1         = new TH1F("hChi2TPC1", "", 100, 0, 100);         
192  hChi2ITS          = new TH1F("hChi2ITS", "", 100, 0, 100);          
193  hD                = new TH1F("hD", "", 200, -0.1, 0.1);                
194  // hD1               = new TH1F("hD1", "", 200, -0.1, 0.1);      // AMA
195  // hD2               = new TH1F("hD2", "", 200, -0.1, 0.1);      // AMA    
196  // hD3               = new TH1F("hD3", "", 200, -0.1, 0.1);      // AMA    
197  hZ                = new TH1F("hZ", "", 200, -0.1, 0.1);                
198  // hZ1               = new TH1F("hZ1", "", 200, -0.1, 0.1);      // AMA    
199  // hZ2               = new TH1F("hZ2", "", 200, -0.1, 0.1);      // AMA    
200  // hZ3               = new TH1F("hZ3", "", 200, -0.1, 0.1);      // AMA    
201  hDTPC             = new TH1F("hDTPC", "", 200, -0.1, 0.1);                
202  hZTPC             = new TH1F("hZTPC", "", 200, -0.1, 0.1);                
203
204  // Other trk histos
205  hStBits           = new TH1F("hStBits", "", 32, 0, 32); // ULong_t
206  hDZ               = new TH2F("hDZ",    "", 100,-0.1,0.1, 100,-0.1,0.1);
207  hDZTPC            = new TH2F("hDZTPC", "", 100,-0.1,0.1, 100,-0.1,0.1);
208
209  // hEta1              = new TH1F("hEta1", "", 600, -3, 3);              
210  // hEta2              = new TH1F("hEta2", "", 600, -3, 3);              
211  // hEta3              = new TH1F("hEta3", "", 600, -3, 3);              
212
213   return;
214 }
215
216 void SetHistProps()
217 {
218   // MyHeader
219   //  hRun                  ->SetTitle("Run number;Run;events");
220   hBx               ->SetTitle("Bx;bunch crossing time [ns];events");
221   hNChips1          ->SetTitle("NChips1;chips - SPD layer 1;events");
222   hNChips2          ->SetTitle("NChips2;chips - SPD layer 2;events");
223   hNTracks          ->SetTitle("NTracks;reconstructed tracks;events");
224   hNSelTracks       ->SetTitle("NSelTracks;selected tracks;events");
225   hNTracklets       ->SetTitle("NTracklets;tracklets;events");
226   hVx               ->SetTitle("x-vertex;v_{x} [cm];events");
227   hVy               ->SetTitle("y-vertex;v_{y} [cm];events");
228   hVz               ->SetTitle("z-vertex;v_{z} [cm];events");
229   hVc               ->SetTitle("Vertex contributors;tracks;events");
230   hIsPileupSPD      ->SetTitle("IsPileupSPD;IsPileupSPD;events");
231   hNPileupSPD       ->SetTitle("NPileupSPD;pileup events;events");
232   hNPileup          ->SetTitle("NPileup;pileup events;events");
233   hTrCluster        ->SetTitle("Trigger cluster;trigger cluster;events");
234   hVxSPD            ->SetTitle("SPD x-vertex;v_{x} [cm];events");
235   hVySPD            ->SetTitle("SPD y-vertex;v_{y} [cm];events");
236   hVzSPD            ->SetTitle("SPD z-vertex;v_{z} [cm];events");
237   hVcSPD            ->SetTitle("SPD vertex contributors;tracks;events");
238   hVxTPC            ->SetTitle("TPC x-vertex;v_{x} [cm];events");
239   hVyTPC            ->SetTitle("TPC y-vertex;v_{y} [cm];events");
240   hVzTPC            ->SetTitle("TPC z-vertex;v_{z} [cm];events");
241   hVcTPC            ->SetTitle("TPC vertex contributors;tracks;events");
242
243   // Other evt histos
244   hL0Bits           ->SetTitle("L0 trigger bits;;events");
245   hTrClBits         ->SetTitle("Trigger class bits;;events");
246
247   // MyPart
248   hC                ->SetTitle("Charge;charge;tracks");
249   hPt               ->SetTitle("Pt;p_{T} [GeV/c];tracks");
250   hEta              ->SetTitle("Eta;#eta;tracks");
251   // hEta1             ->SetTitle("Eta;#eta;tracks");
252   // hEta2             ->SetTitle("Eta;#eta;tracks");
253   // hEta3             ->SetTitle("Eta;#eta;tracks");
254   hPhi              ->SetTitle("Phi;#phi;tracks");
255   hNClTPC           ->SetTitle("TPC clusters in track;TPC clusters;tracks");
256   hNClTPC1          ->SetTitle("TPC clusters in track (iter 1);TPC clusters;tracks");
257   hNClTPCShared     ->SetTitle("NClTPCShared;ITS/TPC clusters;tracks");
258   hNClITS           ->SetTitle("ITS clusters;clusters;tracks");
259   hChi2TPC          ->SetTitle("TPC #chi^{2};#chi^{2}_{TPC};tracks");
260   hChi2TPC1         ->SetTitle("TPC #chi^{2} (iter 1);#chi^{2}_{TPC};tracks");
261   hChi2ITS          ->SetTitle("ITS #chi^{2};#chi^{2}_{ITS};tracks");
262   hD                ->SetTitle("Transverse DCA;x-y impact parameter [cm];tracks");
263   // hD1               ->SetTitle("Transverse DCA;x-y impact parameter [cm];tracks");
264   // hD2               ->SetTitle("Transverse DCA;x-y impact parameter [cm];tracks");
265   // hD3               ->SetTitle("Transverse DCA;x-y impact parameter [cm];tracks");
266   hZ                ->SetTitle("Longitudinal DCA;z impact parameter [cm];tracks");
267   // hZ1               ->SetTitle("Longitudinal DCA;z impact parameter [cm];tracks");
268   // hZ2               ->SetTitle("Longitudinal DCA;z impact parameter [cm];tracks");
269   // hZ3               ->SetTitle("Longitudinal DCA;z impact parameter [cm];tracks");
270   hDTPC             ->SetTitle("Transverse TPC DCA;x-y impact parameter [cm];tracks");
271   hZTPC             ->SetTitle("Longitudinal TPC DCA;z impact parameter [cm];tracks");
272
273   // Other trk histos
274   hStBits           ->SetTitle("Track status flags;;tracks");
275   hDZ               ->SetTitle("DCA;x-y impact parameter [cm];z impact parameter [cm]");
276   hDZTPC            ->SetTitle("TPC DCA;x-y impact parameter [cm];z impact parameter [cm]");
277   hChi2ndfTPC       ->SetTitle("#chi^{2}/N_{TPC clusters}/;#chi^{2};tracks");
278
279   // Put this in TreeClasses.h (and don't change the ordering)!
280   ULong_t flagValue[32] = 
281     {
282      MyPart::kITSin,
283      MyPart::kITSout,
284      MyPart::kITSrefit,
285      MyPart::kITSpid,
286      MyPart::kTPCin,
287      MyPart::kTPCout,
288      MyPart::kTPCrefit,
289      MyPart::kTPCpid,
290      MyPart::kTRDin,
291      MyPart::kTRDout,
292      MyPart::kTRDrefit,
293      MyPart::kTRDpid,
294      MyPart::kTOFin,
295      MyPart::kTOFout,
296      MyPart::kTOFrefit,
297      MyPart::kTOFpid,
298      MyPart::kHMPIDout,
299      MyPart::kHMPIDpid,
300      MyPart::kEMCALmatch,
301      MyPart::kTRDbackup,
302      0x0,     //20 missing
303      MyPart::kPHOSmatch,
304      0x0,     // 22-24 missing
305      0x0,
306      0x0,
307      MyPart::kMultInV0,
308      MyPart::kMultSec,
309      MyPart::kGlobalMerge,
310      MyPart::kITSpureSA,
311      MyPart::kTRDStop,
312      MyPart::kESDpid,
313      MyPart::kTIME
314     };
315
316   // Put this in TreeClasses.h (and don't change the ordering)!
317   TString flagLabel[32] =
318     {
319       "kITSin",
320       "kITSout",
321       "kITSrefit",
322       "kITSpid",
323       "kTPCin",
324       "kTPCout",
325       "kTPCrefit",
326       "kTPCpid",
327       "kTRDin",
328       "kTRDout",
329       "kTRDrefit",
330       "kTRDpid",
331       "kTOFin",
332       "kTOFout",
333       "kTOFrefit",
334       "kTOFpid",
335       "kHMPIDout",
336       "kHMPIDpid",
337       "kEMCALmatch",
338       "kTRDbackup",
339       "--",
340       "kPHOSmatch",
341       "--",
342       "--",
343       "--",
344       "kMultInV0",
345       "kMultSec",
346       "kGlobalMerge",
347       "kITSpureSA",
348       "kTRDStop",
349       "kESDpid",
350       "kTIME"
351     };
352
353   if (0) {
354     for (int i=0; i<28; i++) {
355       int pos = TMath::Log2(flagValue[i]);
356       cout << pos << " " << flagLabel[i].Data() << endl;
357     }
358   }
359   
360   for (Int_t n=0; n<32; ++n) {
361     hStBits->GetXaxis()->SetBinLabel(n+1, flagLabel[n].Data());
362   }
363   return;
364 }
365
366 void FillEventInfo(const MyHeader& ev)
367 {
368   //  hRun                ->Fill(ev.fRun                );   
369   hBx             ->Fill(ev.fBx                 );
370   hNChips1        ->Fill(ev.fNChips1            );
371   hNChips2        ->Fill(ev.fNChips2            );
372   hNTracks        ->Fill(ev.fNTracks            );
373   hNSelTracks     ->Fill(ev.fNSelTracks         );
374   hNTracklets     ->Fill(ev.fNTracklets         );
375   hVx              ->Fill(ev.fVx                );
376   hVy              ->Fill(ev.fVy                );
377   hVz              ->Fill(ev.fVz                );
378   hVc              ->Fill(ev.fVc                );
379   hIsPileupSPD    ->Fill(ev.fIsPileupSPD        );   
380   hNPileupSPD     ->Fill(ev.fNPileupSPD         );
381   hNPileup        ->Fill(ev.fNPileup            );
382   hTrCluster      ->Fill(ev.fTrCluster          );
383   hVxSPD           ->Fill(ev.fVxSPD             );
384   hVySPD           ->Fill(ev.fVySPD             );
385   hVzSPD           ->Fill(ev.fVzSPD             );
386   hVcSPD           ->Fill(ev.fVcSPD             );
387   hVxTPC           ->Fill(ev.fVxTPC             );
388   hVyTPC           ->Fill(ev.fVyTPC             );
389   hVzTPC           ->Fill(ev.fVzTPC             );
390   hVcTPC           ->Fill(ev.fVcTPC             );
391
392   /*
393     http://root.cern.ch/root/html/ListOfTypes.html  
394     UChar_t Unsigned Character 1 byte (unsigned char)
395     UInt_t Unsigned integer 4 bytes (unsigned int)
396     ULong64_t Portable unsigned long integer 8 bytes
397     ULong_t Unsigned long integer 8 bytes (unsigned long)
398   */
399   for (UInt_t n=0; n<32; n++) {
400     ULong64_t uno = 1;
401     Bool_t bit = ev.fL0 & uno<<n;
402     hL0Bits->Fill(n+0.5, bit);
403   }
404   for (ULong64_t n=0; n<64; n++) {
405     ULong64_t uno = 1;
406     Bool_t bit = ev.fTrClassMask & uno<<n;
407     hTrClBits->Fill(n+0.5, bit);
408   }
409
410   return;
411 }
412
413 void FillTrackInfo(const MyPart& trk)
414 {
415   // N.B. a pt > 0.4 cut is applied outside this fn.
416
417   // MyPart
418   hC             ->Fill(trk.fC);                          
419   hPt            ->Fill(trk.fPt);               
420   hEta           ->Fill(trk.fEta);              
421   hPhi           ->Fill(trk.fPhi);              
422   hNClTPC        ->Fill(trk.fNClTPC);         
423   hNClTPC1       ->Fill(trk.fNClTPC1);        
424   hNClTPCShared  ->Fill(trk.fNClTPCShared);     
425   hNClITS        ->Fill(trk.fNClITS);         
426   hChi2TPC       ->Fill(trk.fChi2TPC);          
427   hChi2TPC1      ->Fill(trk.fChi2TPC1);         
428   hChi2ITS       ->Fill(trk.fChi2ITS);          
429   hD             ->Fill(trk.fD);                
430   hZ             ->Fill(trk.fZ);                
431   hDTPC          ->Fill(trk.fDTPC);             
432   hZTPC          ->Fill(trk.fZTPC);             
433
434   Double_t chi2tpc = trk.fNClTPC > 0? trk.fChi2TPC/trk.fNClTPC : 999;
435   hChi2ndfTPC    ->Fill(chi2tpc);
436   hDZ            ->Fill(trk.fD, trk.fZ);                
437   hDZTPC         ->Fill(trk.fDTPC, trk.fZTPC);
438
439   // fSt is a ULong_t (8 bytes), but only the first 32 seem to make sense
440   for (ULong_t n=0; n<32; ++n) {
441     ULong64_t uno = 1;
442     Bool_t bit = trk.fSt & uno<<n; // 0 or 1 * 2^n, downcasted
443     hStBits->Fill(n+0.5, bit);
444   }
445
446   return;
447 }
448
449 TObjArray* GetHistList(TFile& inFile, TString clname)
450 {
451   TObjArray* hList = new TObjArray();
452   TIter next(inFile.GetListOfKeys()); 
453   TKey *key;
454
455   while ((key=(TKey*)next())) {
456     TString className(key->GetClassName());
457     TString keyName(key->GetName());
458     if (0) printf("%10s %20s\n", className.Data(), keyName.Data());
459     
460     if (className.Contains(clname) && clname=="TH1F") {
461       TH1F* h1 = (TH1F*)inFile.Get(keyName.Data());
462       hList->Add(h1);
463     }
464     if (className.Contains(clname) && clname=="TH2F") {
465       TH2F* h2 = (TH2F*)inFile.Get(keyName.Data());
466       hList->Add(h2);
467     }
468   }
469   return hList;
470 }
471
472 void DrawHistos(TFile& inFile)
473 {
474   gStyle->SetTitleFontSize(0.06);
475   gStyle->SetOptStat(0);
476
477   TObjArray* cList = new TObjArray();
478   TObjArray* h1List = GetHistList(inFile, "TH1F");
479   TObjArray* h2List = GetHistList(inFile, "TH2F");
480
481   Int_t fillCol=kYellow, lineCol=kBlack, mkrCol=kBlack, mkrSty=kFullCircle;
482   Float_t mkrSize=1.0;
483   PlotUtils::set_hist_props(h1List,lineCol,fillCol,mkrCol,mkrSty,mkrSize);
484
485   Int_t nCanv = 0, nPrinted = 0;  
486   TCanvas* c;
487
488   // TH1Fs
489   for (int i=0; i<h1List->GetEntries(); i++) {
490     
491     TH1F* h1 = (TH1F*)h1List->At(i);
492     h1->SetStats(1);
493     TString s(h1->GetName());
494     TString options(h1->GetDrawOption());
495
496     if (s.Contains("hEta2") || 
497         s.Contains("hD2") || 
498         s.Contains("hZ2")) {
499       options.Append("same");
500       h1->SetFillColor(kGreen);
501     }
502     if (s.Contains("hEta3") || 
503         s.Contains("hD3") || 
504         s.Contains("hZ3")) {
505       options.Append("same");
506       h1->SetFillColor(kAzure-9);
507     }
508
509     if (s.Contains("hChi2ndfTPC")) {
510       h1->SetFillColor(kNone);
511       h1->SetLineColor(kRed);
512       h1->SetLineWidth(2);
513       options.Append("same");
514     }
515      
516     if (!options.Contains("same")) {
517       TString ylabel(h1->GetYaxis()->GetTitle());
518       TString prefix("c");
519       if (ylabel=="events") prefix = "ev";
520       if (ylabel=="tracks") prefix = "tr";
521       char* title = Form("%s_%s", prefix.Data(), h1->GetName());
522       cList->Add(new TCanvas(Form("c%i", nCanv++), title, 1));
523     }  
524     c = (TCanvas*)cList->Last(); 
525     c->cd();
526     
527     if (s.Contains("hPt") ||
528         s.Contains("NClTPC") ||
529         s.Contains("Chi2") ) 
530       c->SetLogy();
531     if (s.Contains("hMult"))
532       h1->SetStats(1);
533     if (s.Contains("hStBits") || 
534         s.Contains("hL0Bits") || 
535         s.Contains("hTrClBits")) {
536       h1->SetFillColor(kRed);
537       h1->SetBarWidth(0.9 * h1->GetBinWidth(1));
538       options.Append("hbar");
539       c->SetLeftMargin(0.2);
540     }
541     if (!options.Contains("hbar"))
542       PlotUtils::make_nice_axes(c, h1, 1.5);
543     if (s.Contains("hVx") || s.Contains("hVy") || 
544         s.Contains("hBx") || s.Contains("hTime") ||
545         s.Contains("hEvNumber") || s.Contains("hC") || 
546         s.Contains("hOrbit") || s=="hD" ||  s=="hZ")  
547       h1->GetXaxis()->SetNdivisions(5); // unclutter
548
549     printf("Drawing %20s opt: %s", s.Data(), options.Data());
550     cout << endl;
551     h1->Draw(options.Data());
552     
553   }
554
555   // TH2Fs
556   for (int i=0; i<h2List->GetEntries(); i++) {
557     
558     TH2F* h2 = (TH2F*)h2List->At(i);
559     TString s(h2->GetName());
560     TString options("colz");
561
562     if (s.Contains("hDZ"))  
563       h2->GetXaxis()->SetNdivisions(5); // unclutter
564     
565     cout << "Drawing " << s.Data() << endl;
566     
567
568     if (!options.Contains("same")) {
569       TString ylabel(h2->GetYaxis()->GetTitle());
570       TString prefix("c");
571       if (ylabel=="events") prefix = "ev";
572       if (ylabel=="tracks") prefix = "tr";
573       char* title = Form("%s_%s", prefix.Data(), h2->GetName());
574       cList->Add(new TCanvas(Form("c%i", nCanv++), title, 1));
575     }  
576     c = (TCanvas*)cList->Last(); 
577     c->cd();
578
579     PlotUtils::make_nice_axes(c, h2, 1.5);
580     
581     h2->Draw(options.Data());
582   }
583   
584   if (printPDF) {
585     TTimeStamp ts;
586     UInt_t date = ts.GetDate();
587     for (int i=0; i<cList->GetEntries(); i++) {
588       TCanvas* c = (TCanvas*)cList->At(i); 
589       c->Print(Form("plots/pngs/%s_%i.png", 
590                     c->GetTitle(), date));
591       if (nPrinted==0) {
592         c->Print(Form("plots/datacheck_%i.ps%s", date, "["));
593       }
594       c->Print(Form("plots/datacheck_%i.ps%s",         
595                     date, i==cList->GetEntries()-1 ? "]" : ""));
596       nPrinted++;
597     }
598     TString base = Form("plots/datacheck_%i", date); 
599     TString cmd = "ps2pdf " + base + ".ps " + base + ".pdf";             
600     gSystem->Exec(cmd.Data()); 
601   }
602
603   return;
604 }