]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/MUONpadtest.C
Updated.
[u/mrichter/AliRoot.git] / MUON / MUONpadtest.C
index a7d7609320b33c9e3484777d7ecdf4f703676a4d..a9a91d5754c329d4305e4d6fedb0e2df2c03abe2 100644 (file)
@@ -7,28 +7,15 @@ void MUONpadtest (Int_t evNumber1=0,Int_t evNumber2=1)
 //   
 /////////////////////////////////////////////////////////////////////////
 
-
-  Int_t NpadX = 252;                 // number of pads on X
-  Int_t NpadY = 374;                 // number of pads on Y
-
-    Int_t Pad[NpadX][NpadY];
-    for (Int_t i=0;i<NpadX;i++) {
-      for (Int_t j=0;j<NpadY;j++) {
-          Pad[i][j]=0;
-      }
-    }
-
-
+  const Int_t NpadX = 252;                 // number of pads on X
+  const Int_t NpadY = 374;                 // number of pads on Y
 
 // Dynamically link some shared libs
 
    if (gClassTable->GetID("AliRun") < 0) {
-      gSystem->Load("libGeant3Dummy.so");        // a dummy version of Geant3
-      gSystem->Load("PHOS/libPHOSdummy.so");     // the standard Alice classes 
-      gSystem->Load("libgalice.so");             // the standard Alice classes 
+      gROOT->LoadMacro("loadlibs.C");
+      loadlibs();
    }
-      
-// Connect the Root Galice file containing Geometry, Kine and Hits
 
    TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
    if (!file) file = new TFile("galice.root");
@@ -56,6 +43,7 @@ void MUONpadtest (Int_t evNumber1=0,Int_t evNumber2=1)
 
    Int_t Nh=0;
    Int_t Nh1=0;
+   AliMUON *pMUON  = (AliDetector*) gAlice->GetDetector("MUON");
    for (int nev=0; nev<= evNumber2; nev++) {
       Int_t nparticles = gAlice->GetEvent(nev);
       cout<<"nev  "<<nev<<endl;
@@ -64,8 +52,6 @@ void MUONpadtest (Int_t evNumber1=0,Int_t evNumber2=1)
       if (nparticles <= 0) return;
      
 // Get pointers to MUON detector and Hits containers
-
-      AliMUON *MUON  = gAlice->GetDetector("MUON");
       TTree *TH = gAlice->TreeH();
       Int_t ntracks = TH->GetEntries();
 
@@ -74,57 +60,54 @@ void MUONpadtest (Int_t evNumber1=0,Int_t evNumber2=1)
       //      Int_t Nh=0;
       Int_t Nc=0;
       for (Int_t track=0; track<ntracks;track++) {
-       //          printf("ntracks %d\n",ntracks);
+//       printf("ntracks %d\n",ntracks);
           gAlice->ResetHits();
           Int_t nbytes += TH->GetEvent(track);
-          if (MUON)  {
-              TClonesArray *Clusters = MUON->Clusters(); // Cluster branch
-              TClonesArray *Hits = MUON->Hits();         // Hits branch
-             //printf("%d %d \n",Clusters,Hits);
+          if (pMUON)  {
+              TClonesArray *Clusters = pMUON->PadHits();  // Cluster branch
+              TClonesArray *Hits = pMUON->Hits();         // Hits branch
+//           printf("%d %d \n",Clusters,Hits);
           }
           //see hits distribution
           Int_t nhits = Hits->GetEntriesFast();
           if (nhits) Nh+=nhits;
-         //          printf("nhits %d\n",nhits);
+//       printf("nhits %d\n",nhits);
           for (Int_t hit=0;hit<nhits;hit++) {
-              mHit = (AliMUONhit*) Hits->UncheckedAt(hit);
-              Int_t nch  = mHit->fChamber;              // chamber number
-              Float_t x  = mHit->fX;                    // x-pos of hit
-              Float_t y  = mHit->fY;                    // y-pos
+//           printf("hit# %d\n",hit);
+              mHit = (AliMUONHit*) Hits->UncheckedAt(hit);
+              Int_t nch  = mHit->Chamber();              // chamber number
+              Float_t x  = mHit->X();                    // x-pos of hit
+              Float_t y  = mHit->Y();                    // y-pos
               // Fill the histograms
              if( nch==1) {
-                Float_t rhit=TMath::Sqrt(x*x+y*y);
-                 if( rhit<= 55 ) Nh1+=nhits;
+                 Float_t rhit=TMath::Sqrt(x*x+y*y);
+                 if( rhit<= 55 ) Nh1+=nhits;
                   h->Fill(x,y,(float) 1);
               }
-          }
+
+
           //    see signal distribution
-          Int_t nclust = Clusters->GetEntriesFast();
-         //       printf("nclust %d\n",nclust);
-          if (nclust) {
-            Nc+=nclust;
-            for (Int_t hit=0;hit<nclust;hit++) {
-             padHit = (AliMUONcluster*) Clusters->UncheckedAt(hit);
-             Int_t nchamber = padHit->fChamber;     // chamber number
-             Int_t nhit = padHit->fHitNumber;          // hit number
-             Int_t qtot = padHit->fQ;                // charge
-             Int_t ipx  = padHit->fPadX;               // pad number on X
-             Int_t ipy  = padHit->fPadY;               // pad number on Y
-             Int_t iqpad  = padHit->fQpad;           // charge per pad
-             Int_t rpad  = padHit->fRpad;            // R-position of pad
-              if (qtot > 0 && nchamber==1){
-                 charge->Fill(qtot,(float) 1);
-              }
-             if(rpad <= 55 && nchamber==1) {
-             //              if(nchamber==1) {
-                  Pad[ipx+126][ipy+187]+=(iqpad);
-                  hc->Fill(ipx,ipy,(float) iqpad);
-             }         
-            }
-          }
-       }
+             for (AliMUONPadHit* mPad =
+                      (AliMUONPadHit*)pMUON->FirstPad(mHit,Clusters);
+                  mPad;
+                  mPad = (AliMUONPadHit*)pMUON->NextPad(Clusters))
+             {
+                 Int_t nhit   = mPad->HitNumber();          // hit number
+                 Int_t qtot   = mPad->Q();                  // charge
+                 Int_t ipx    = mPad->PadX();               // pad number on X
+                 Int_t ipy    = mPad->PadY();               // pad number on Y
+                 Int_t iqpad  = mPad->QPad();               // charge per pad
+//               printf("%d %d %d\n",ipx,ipy,iqpad);
+                 if (qtot > 0 && nch == 1){
+                     charge->Fill(float(iqpad),(float) 1);
+                 }
+                 if(nch == 1) {
+                     hc->Fill(ipx,ipy,(float) iqpad);
+                 } // if rpad          
+             } // padhits
+          } // hitloops
+      }
       //      cout<<"Nh  "<<Nh<<endl;
-      cout<<"Nc  "<<Nc<<endl;
    }
 //Create a canvas, set the view range, show histograms
    TCanvas *c1 = new TCanvas("c1","Alice MUON pad hits",400,10,600,700);
@@ -139,22 +122,4 @@ void MUONpadtest (Int_t evNumber1=0,Int_t evNumber2=1)
    charge->SetXTitle("ADC units");
    charge->Draw();
 
-   
-   // calculate the number of pads which give a signal
-
-
-    Int_t Np=0;
-    for (Int_t i=0;i< NpadX;i++) {
-      for (Int_t j=0;j< NpadY;j++) {
-         if (Pad[i][j]>=6){
-             Np+=1;
-            //             cout<<"i, j  "<<i<<"  "<<j<<endl;
-         }
-      }
-    }
-
-    cout<<"The total number of pads which give a signal "<<Np<<endl; 
-      cout<<"Nh  "<<Nh<<endl;
-      cout<<"Nh1  "<<Nh1<<endl;
-
 }