add chamber map/status maker
authorabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 25 Nov 2011 07:27:01 +0000 (07:27 +0000)
committerabercuci <abercuci@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 25 Nov 2011 07:27:01 +0000 (07:27 +0000)
add summary maker

PWG1/TRD/AliTRDinfoGen.cxx
PWG1/TRD/AliTRDinfoGen.h

index ede6ab4..9268938 100644 (file)
 #include <TObjArray.h>\r
 #include <TObject.h>\r
 #include <TString.h>\r
+#include <TVectorT.h>\r
 #include <TH1.h>\r
 #include <TH2.h>\r
+#include <TCanvas.h>\r
 #include <TPad.h>\r
 #include <TFile.h>\r
 #include <TTree.h>\r
@@ -80,6 +82,7 @@
 #include "AliTRDrecoParam.h"\r
 #include "AliTRDcalibDB.h"\r
 #include "AliTRDtrackerV1.h"\r
+#include "AliTRDpadPlane.h"\r
 #include "AliTRDgeometry.h"\r
 #include "AliTRDtrackV1.h"\r
 #include "AliTRDseedV1.h"\r
@@ -192,7 +195,7 @@ AliTRDinfoGen::~AliTRDinfoGen()
     delete fV0List;\r
     fV0List = NULL;\r
   }\r
-  if(fContainer && !(AliAnalysisManager::GetAnalysisManager() && AliAnalysisManager::GetAnalysisManager()->IsProofMode())){ \r
+  if(fContainer && !(AliAnalysisManager::GetAnalysisManager() && AliAnalysisManager::GetAnalysisManager()->IsProofMode())){\r
     fContainer->Delete(); \r
     delete fContainer;\r
     fContainer = NULL;\r
@@ -252,10 +255,13 @@ void AliTRDinfoGen::UserCreateOutputObjects()
   ax->SetBinLabel(3, "Cosmic");\r
   ax->SetBinLabel(4, "Calib");\r
   fContainer->AddAt(h, kEvType);\r
-  TH2I* h2=new TH2I("hBC", "Bunch Cross statistics;Fill Bunch;TOF BC;Entries", 3500, -0.5, 3499.5, 31, -10.5, 20.5);\r
+  TH2I* h2=new TH2I("hBC", "Bunch statistics;Fill Bunch;TOF BC;Entries", 3500, -0.5, 3499.5, 31, -10.5, 20.5);\r
   fContainer->AddAt(h2, kBC);\r
   h=new TH1I("hTriggers", "Triggers statistics;;Entries", 21, -0.5, 20.5);\r
   fContainer->AddAt(h, kTrigger);\r
+  TObjArray *chmb = new TObjArray(AliTRDgeometry::kNdet);\r
+  chmb->SetName("Chambers"); chmb->SetOwner();\r
+  fContainer->AddAt(chmb, kChmb);\r
   PostData(AliTRDpwg1Helper::kMonitor, fContainer);\r
 }\r
 \r
@@ -308,7 +314,7 @@ void AliTRDinfoGen::UserExec(Option_t *){
     AliCDBEntry* obj(NULL);\r
     AliCDBManager* ocdb = AliCDBManager::Instance();\r
     if(ocdb->IsDefaultStorageSet()){\r
-      AliInfo("OCDB :: initialized.");\r
+      AliInfo("OCDB :: initialized externally.");\r
     } else {\r
       AliInfo("OCDB :: initializing locally ...");\r
       // prepare OCDB access\r
@@ -335,6 +341,7 @@ void AliTRDinfoGen::UserExec(Option_t *){
     // load misalignment\r
     fgGeo = new AliTRDgeometry;\r
     fgGeo->CreateClusterMatrixArray();\r
+    MakeChambers();\r
     // load reco param list from OCDB\r
     AliInfo("Initializing TRD reco params ...");\r
     fgReconstructor = new AliTRDReconstructor();\r
@@ -742,6 +749,110 @@ void AliTRDinfoGen::UserExec(Option_t *){
   PostData(AliTRDpwg1Helper::kV0List, fV0List);\r
 }\r
 \r
+\r
+//____________________________________________________________________\r
+void AliTRDinfoGen::MakeChambers()\r
+{\r
+// Build chamber position and status\r
+  if(!fContainer){\r
+    AliError("Missing container");\r
+    return;\r
+  }\r
+  AliTRDcalibDB *calib(AliTRDcalibDB::Instance());\r
+  if(!calib){\r
+    AliError("No access to calibration data");\r
+    return;\r
+  }\r
+\r
+  TObjArray *chmb((TObjArray*)fContainer->At(kChmb));\r
+  Double_t alpha(0.), cs(-2.), sn(0.);\r
+  TVectorF pos(5);\r
+  for(Int_t isec(0); isec<AliTRDgeometry::kNsector; isec++){\r
+    alpha = (0.5+isec)*AliTRDgeometry::GetAlpha();\r
+    cs    = TMath::Cos(alpha);\r
+    sn    = TMath::Sin(alpha);\r
+\r
+    for(Int_t istk(0); istk<AliTRDgeometry::kNstack; istk++){\r
+      for(Int_t ilyr(0); ilyr<AliTRDgeometry::kNlayer; ilyr++){\r
+        Int_t idet(AliTRDgeometry::GetDetector(ilyr, istk, isec));\r
+        TGeoHMatrix *matrix(fgGeo->GetClusterMatrix(idet));\r
+        if(!matrix){\r
+          AliDebug(2, Form("Missing matrix for %03d [%02d_%d_%d]", idet, isec, istk, ilyr));\r
+          continue;\r
+        }\r
+        AliDebug(2, Form("Read info for %03d [%02d_%d_%d]", idet, isec, istk, ilyr));\r
+        AliTRDpadPlane *pp(fgGeo->GetPadPlane(ilyr, istk));\r
+        Double_t zm(0.5 * (pp->GetRow0() + pp->GetRowEnd())),\r
+                 loc0[] = {AliTRDgeometry::AnodePos(), pp->GetCol0(), zm-pp->GetRow0()},\r
+                 loc1[] = {AliTRDgeometry::AnodePos(), pp->GetColEnd(), zm-pp->GetRowEnd()},\r
+                 glb[3];\r
+        matrix->LocalToMaster(loc0, glb);\r
+        Float_t phi = TMath::ATan2(glb[0]*sn + glb[1]*cs, glb[0]*cs - glb[1]*sn),\r
+                tgl = glb[2]/glb[0]/TMath::Sqrt(1.+glb[1]*glb[1]/glb[0]/glb[0]),\r
+                eta = -TMath::Log(TMath::Tan(0.5 *  (0.5*TMath::Pi() - TMath::ATan(tgl))));\r
+        pos[0] = eta; pos[1] = phi;\r
+        matrix->LocalToMaster(loc1, glb);\r
+        phi = TMath::ATan2(glb[0]*sn + glb[1]*cs, glb[0]*cs - glb[1]*sn);\r
+        tgl = glb[2]/glb[0]/TMath::Sqrt(1.+glb[1]*glb[1]/glb[0]/glb[0]);\r
+        eta = -TMath::Log(TMath::Tan(0.5 *  (0.5*TMath::Pi() - TMath::ATan(tgl))));\r
+        pos[2] = eta; pos[3] = phi;\r
+        pos[4] = calib->IsChamberGood(idet)?0.:1.;\r
+        chmb->AddAt(new TVectorF(pos), idet);\r
+      }\r
+    }\r
+  }\r
+}\r
+\r
+//____________________________________________________________________\r
+void AliTRDinfoGen::MakeSummary()\r
+{\r
+// Build summary plots\r
+  if(!fContainer){\r
+    AliError("Missing results");\r
+    return;\r
+  }\r
+  TH1 *h1(NULL); TVirtualPad *p(NULL); TCanvas *cOut(NULL);\r
+\r
+  const Int_t nx(2048), ny(750);\r
+  cOut = new TCanvas(GetName(), "Run Statistics", nx, ny);\r
+  cOut->Divide(3,1, 1.e-5, 1.e-5);\r
+  //=========\r
+  p=cOut->cd(1);p->SetRightMargin(0.025);p->SetTopMargin(0.01);p->SetLogy();\r
+  h1 = (TH1*)fContainer->At(kStatTrk);\r
+  h1->SetBarOffset(0.06); h1->SetBarWidth(0.88); h1->SetFillColor(3);\r
+  h1->Draw("bar1");\r
+  //=========\r
+  p=cOut->cd(2);p->SetRightMargin(0.025);p->SetTopMargin(0.01);p->SetLogy();\r
+  h1 = (TH1*)fContainer->At(kEvType);\r
+  h1->SetBarOffset(0.04); h1->SetBarWidth(0.92);h1->SetFillColor(6);\r
+  h1->Draw("bar1");\r
+  //=========\r
+  p=cOut->cd(3);p->SetRightMargin(0.025);p->SetTopMargin(0.01);p->SetLogz();\r
+  TH2 *h2((TH2*)fContainer->At(kBC));\r
+  h1 = h2->ProjectionX("_px");\r
+  Int_t n(0); Int_t bins[3500];\r
+  for(Int_t ib(1); ib<=3500; ib++){\r
+    if(h1->GetBinContent(ib) < 1) continue;\r
+    bins[n++] = ib;\r
+  }\r
+  delete h1;\r
+\r
+  TAxis *ay(h2->GetYaxis());\r
+  TH2 *hs = new TH2I("hBC_Summary", Form("%s;%s;%s", h2->GetTitle(), h2->GetXaxis()->GetTitle(), h2->GetYaxis()->GetTitle()),\r
+                     n, -0.5, n-0.5, ay->GetNbins(), ay->GetXmin(), ay->GetXmax());\r
+  hs->SetLineColor(kBlack);hs->SetLineWidth(1);\r
+  hs->SetMarkerColor(kRed);\r
+  TAxis *ax(hs->GetXaxis());\r
+  for(Int_t ib(0); ib<n; ib++){\r
+    ax->SetBinLabel(ib+1, Form("%d", bins[ib]));\r
+    for(Int_t iy(1); iy<=ay->GetNbins(); iy++){\r
+      hs->SetBinContent(ib+1, iy, h2->GetBinContent(bins[ib], iy));\r
+    }\r
+  }\r
+  hs->Draw("textbox");\r
+  cOut->SaveAs(Form("%s.gif", cOut->GetName()));\r
+}\r
+\r
 //____________________________________________________________________\r
 void AliTRDinfoGen::SetLocalEvSelection(const AliTRDeventCuts &ec)\r
 {\r
index 36ba395..d4d33d5 100644 (file)
@@ -59,6 +59,7 @@ public:
     ,kEvType\r
     ,kBC\r
     ,kTrigger\r
+    ,kChmb\r
     ,kNclasses\r
   };\r
   AliTRDinfoGen();\r
@@ -77,6 +78,7 @@ public:
   // temporary until check with AliAnalysisTaskSE collision selection mechanism\r
   Bool_t  IsInitOCDB() const {return TestBit(kOCDB);}\r
   Bool_t  IsCollision() const {return TestBit(kCollision);}\r
+  void    MakeSummary();\r
   static const AliTRDReconstructor* Reconstructor() {return fgReconstructor;}\r
   static AliTRDgeometry*      Geometry() {return fgGeo;}\r
   void    SetInitOCDB(Bool_t set=kTRUE) {SetBit(kOCDB, set);}\r
@@ -112,6 +114,7 @@ private:
   AliTRDinfoGen(const AliTRDinfoGen&);\r
   AliTRDinfoGen& operator=(const AliTRDinfoGen&);\r
   TTreeSRedirector* DebugStream();\r
+  void              MakeChambers();\r
 \r
   AliESDEvent      *fESDev;          //! ESD event\r
   AliMCEvent       *fMCev;           //! MC event\r