]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HMPID/AliHMPIDDigit.cxx
Comics run analizer
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDDigit.cxx
index 6df0e81b2dd70713097f259802ccc57c3425df80..171336bba9ac0565742600f31ed55c346a2ab34b 100644 (file)
 ClassImp(AliHMPIDDigit)
 
 /*
-Any given LDC collects data from a number of D-RORC cards connected to this same LDC by separate DDLs. This data is stored in corresponding number
-of DDL buffers.
+Preface: all geometrical information (like left-right sides) is reported as seen from electronic side.
 
-Each DDL buffer corresponds to a single D-RORC. The data this buffer contains are hardware generated by D-RORC. The buffer starts with common header 
-which size and structure is standartized and mandatory for all detectors.
+
+The DDL file starts with common header which size and structure is standartized and mandatory for all detectors. 
 The header contains among other words, so called Equipment ID word. This unique value for each D-RORC is calculated as detector ID << 8 + DDL index. 
 For HMPID the detector ID is 6 (reffered in the code as kRichRawId) while DDL indexes are from 0 to 13.
 
 Common header might be followed by the private one although  HMPID has no any private header, just uses the common one.
 
-Single HMPID D-RORC serves one half of a chamber i.e. 3 photocathodes even LDC for left part( PCs 0-2-4) and odd LDC for right part(1-3-5
-as it's seen from electronics side.
+Single HMPID D-RORC (with 2 channels) serves a single chamber so that channel 0 serves left half (PCs 0-2-4
+                                                                              1 serves right half(PCs 1-3-5) 
 
 So the LDC -chamber-ddl map is:
-DDL index  0 -> ch 1 left -> DDL ID 0x600          DDL index  1 -> ch 1 right -> DDL ID 0x601 
-DDL index  2 -> ch 2 left -> DDL ID 0x602          DDL index  3 -> ch 2 right -> DDL ID 0x603 
-DDL index  4 -> ch 3 left -> DDL ID 0x604          DDL index  5 -> ch 3 right -> DDL ID 0x605 
-DDL index  6 -> ch 4 left -> DDL ID 0x606          DDL index  7 -> ch 4 right -> DDL ID 0x607 
-DDL index  8 -> ch 5 left -> DDL ID 0x608          DDL index  9 -> ch 5 right -> DDL ID 0x609 
-DDL index 10 -> ch 6 left -> DDL ID 0x60a          DDL index 11 -> ch 6 right -> DDL ID 0x60b 
-DDL index 12 -> ch 7 left -> DDL ID 0x60c          DDL index 13 -> ch 7 right -> DDL ID 0x60d 
+DDL index  0 -> ch 0 left -> DDL ID 0x600          DDL index  1 -> ch 1 right -> DDL ID 0x601 
+DDL index  2 -> ch 1 left -> DDL ID 0x602          DDL index  3 -> ch 2 right -> DDL ID 0x603 
+DDL index  4 -> ch 2 left -> DDL ID 0x604          DDL index  5 -> ch 3 right -> DDL ID 0x605 
+DDL index  6 -> ch 3 left -> DDL ID 0x606          DDL index  7 -> ch 4 right -> DDL ID 0x607 
+DDL index  8 -> ch 4 left -> DDL ID 0x608          DDL index  9 -> ch 5 right -> DDL ID 0x609 
+DDL index 10 -> ch 5 left -> DDL ID 0x60a          DDL index 11 -> ch 6 right -> DDL ID 0x60b 
+DDL index 12 -> ch 6 left -> DDL ID 0x60c          DDL index 13 -> ch 7 right -> DDL ID 0x60d 
 
 HMPID FEE as seen by single D-RORC is composed from a number of DILOGIC chips organized in vertical stack of rows. 
-Each DILOGIC chip serves 48 channels for the 8x6 pads (reffered in the code as kDilX,kDilY). Channels counted from 0 to 47.
+Each DILOGIC chip serves 48 channels for the 8x6 pads Channels counted from 0 to 47.
 
 The mapping inside DILOGIC chip has the following structure (see from electronics side):
+pady
 
-5  04 10 16 22 28 34 40 46
-4  02 08 14 20 26 32 38 44
-3  00 06 12 18 24 30 36 42
-2  01 07 13 19 25 31 37 43
-1  03 09 15 21 27 33 39 45
-0  05 11 17 23 29 35 41 47
+5  04 10 16 22 28 34 40 46                   due to repetition in column structure we may introduce per column map:   
+4  02 08 14 20 26 32 38 44                   pady= 0 1 2 3 4 5          
+3  00 06 12 18 24 30 36 42                   addr= 5 3 1 0 2 4
+2  01 07 13 19 25 31 37 43                   or vice versa 
+1  03 09 15 21 27 33 39 45                   addr= 0 1 2 3 4 5
+0  05 11 17 23 29 35 41 47                   pady= 3 2 4 1 5 0  
     
     0  1  2  3  4  5  6  7  padx
 
@@ -90,7 +90,7 @@ Float_t AliHMPIDDigit::Hit2Sdi(AliHMPIDHit *pHit,TClonesArray *pSdiLst)
   Int_t iSdiCnt=pSdiLst->GetEntries();
   for(Int_t i=0;i<9;i++){                                      //affected pads loop
     AliHMPIDDigit dig(pHit->Ch(),qdcTot,pHit->Tid(),pHit->LorsX(),y,i); //c,q,tid,x,y   create tmp sdigit for pad i around hit position
-    if(dig.PadX()==-1) continue;
+    if(dig.PadPcX()==-1) continue;
     new((*pSdiLst)[iSdiCnt++]) AliHMPIDDigit(dig);
   }
   return qdcTot;
@@ -101,8 +101,9 @@ void AliHMPIDDigit::Print(Option_t*)const
 // Print current digit  
 // Arguments: option string not used
 //   Returns: none    
-  Printf("pad=(%2i,%2i,%3i,%3i),pos=(%7.2f,%7.2f) QDC=%8.3f, TID=(%5i,%5i,%5i) raw r=%2i d=%2i a=%2i",
-               Ch(),Pc(),PadX(),PadY(),LorsX(),LorsY(), Q(),  fTracks[0],fTracks[1],fTracks[2], Row(), Dilogic(), Addr());
+  UInt_t w32; Raw(w32);
+  Printf("(ch=%1i,pc=%1i,x=%2i,y=%2i),pos=(%7.2f,%7.2f) Q=%8.3f TID=(%5i,%5i,%5i) ddl=%i raw=0x%x (r=%2i,d=%2i,a=%2i)",
+               A2C(fPad),A2P(fPad),A2X(fPad),A2Y(fPad),LorsX(),LorsY(), Q(),  fTracks[0],fTracks[1],fTracks[2],DdlIdx(),w32,Row(),Dilogic(),Addr());
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void AliHMPIDDigit::PrintSize()
@@ -111,22 +112,24 @@ void AliHMPIDDigit::PrintSize()
 // Arguments: none
 //   Returns: none    
   Printf("-->pad    =(%6.2f,%6.2f) cm dead zone %.2f cm\n"
-         "-->PC     =(%6.2f,%6.2f) cm\n"
-         "-->all PCs=(%6.2f,%6.2f) cm",
-               SizePadX(),SizePadY(),SizeDead(),SizePcX(),SizePcY(),SizeAllX(),SizeAllY());
+         "-->PC     =(%6.2f,%6.2f) cm (%3i,%3i) pads\n"
+         "-->all PCs=(%6.2f,%6.2f) cm (%3i,%3i) pads",
+               SizePadX(),SizePadY(),SizeDead(),
+               SizePcX() ,SizePcY() ,kPadPcX ,kPadPcY,
+               SizeAllX(),SizeAllY(),kPadAllX,kPadAllY);
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void AliHMPIDDigit::TestSeg()
+void AliHMPIDDigit::DrawSeg()
 {
 // Draws the picture of segmentation   
 // Arguments: none
 //   Returns: none     
-  TCanvas *pC=new TCanvas("pads","View from electronics side, IP is behind the picture.");pC->ToggleEventStatus();
-  gPad->AddExec("test","AliHMPIDDigit::Zoom()");
+  TCanvas *pC=new TCanvas("pads","View from electronics side, IP is behind the picture.",1000,900);pC->ToggleEventStatus();
+  gPad->AddExec("test","AliHMPIDDigit::DrawZoom()");
   DrawPc();  
 }//TestSeg()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void AliHMPIDDigit::Zoom()
+void AliHMPIDDigit::DrawZoom()
 {
 // Show info about current cursur position in status bar of the canvas
 // Arguments: none
@@ -137,11 +140,17 @@ void AliHMPIDDigit::Zoom()
   pBar->SetParts(5);
   Float_t x=gPad->AbsPixeltoX(gPad->GetEventX());
   Float_t y=gPad->AbsPixeltoY(gPad->GetEventY());
-  AliHMPIDDigit dig(1,100,1,x,y);  
+  AliHMPIDDigit dig(1,0,1,x,y); UInt_t w32=0; 
   if(IsInDead(x,y))
     pBar->SetText("Out of sensitive area",4);    
-  else
-    pBar->SetText(Form("p%i x%i y%i r%i d%i a%i (%.2f,%.2f)",dig.Pc(),dig.PadX(),dig.PadY(),dig.Row(),dig.Dilogic(),dig.Addr(),dig.LorsX(),dig.LorsY()),4);
+  else{
+    Int_t ddl=dig.Raw(w32);
+    pBar->SetText(Form("(p%i,x%i,y%i) ddl=%i 0x%x (r%i,d%i,a%i) (%.2f,%.2f)",
+        dig.Pc(),dig.PadPcX(),dig.PadPcY(),
+        ddl,w32,
+        dig.Row(),dig.Dilogic(),dig.Addr(),
+        dig.LorsX(),dig.LorsY()                            ),4);
+  }    
   if(gPad->GetEvent()==1){
     new TCanvas("zoom",Form("Row %i DILOGIC %i",dig.Row(),dig.Dilogic()));  
   }
@@ -177,22 +186,51 @@ void AliHMPIDDigit::DrawPc(Bool_t isFill)
   Float_t yC[5]={y3,y4,y4,y3,y3};  
   Float_t yU[5]={y5,y6,y6,y5,y5};
     
-  TLatex t; t.SetTextSize(0.01); t.SetTextAlign(22);
+  TLatex txt; txt.SetTextSize(0.01);
   Int_t iColLeft=29,iColRight=41;
-  TPolyLine *pc=0;  TLine *pL; Float_t x0=0,y0=0,wRow=kDilY*SizePadY(),wDil=kDilX*SizePadX();
+  TPolyLine *pc=0;  TLine *pL;
+  AliHMPIDDigit dig;
   for(Int_t iPc=0;iPc<kPcAll;iPc++){
-    if(iPc==4) {pc=new TPolyLine(5,xL,yU);t.DrawText(x1-3.5,y6-20,"PC4");x0=x1;y0=y5;} if(iPc==5) {pc=new TPolyLine(5,xR,yU);t.DrawText(x4+3.5,y6-20,"PC5");x0=x3;y0=y5;}
-    if(iPc==2) {pc=new TPolyLine(5,xL,yC);t.DrawText(x1-3.5,y4-20,"PC2");x0=x1;y0=y3;} if(iPc==3) {pc=new TPolyLine(5,xR,yC);t.DrawText(x4+3.5,y4-20,"PC3");x0=x3;y0=y3;}
-    if(iPc==0) {pc=new TPolyLine(5,xL,yD);t.DrawText(x1-3.5,y2-20,"PC0");x0=x1;y0=y1;} if(iPc==1) {pc=new TPolyLine(5,xR,yD);t.DrawText(x4+3.5,y2-20,"PC1");x0=x3;y0=y1;}    
+    if(iPc==4) pc=new TPolyLine(5,xL,yU); if(iPc==5) pc=new TPolyLine(5,xR,yU); //draw PCs
+    if(iPc==2) pc=new TPolyLine(5,xL,yC); if(iPc==3) pc=new TPolyLine(5,xR,yC);
+    if(iPc==0) pc=new TPolyLine(5,xL,yD); if(iPc==1) pc=new TPolyLine(5,xR,yD);
     (iPc%2)? pc->SetFillColor(iColLeft): pc->SetFillColor(iColRight);
     if(isFill) pc->Draw("f"); else pc->Draw();
-    for(Int_t i=1;i<=8 ;i++){//draw row lines (horizontal)
-      Float_t y=y0+i*wRow;
-      Int_t row=i+iPc/2*8; if(iPc%2!=0) row=25-row; t.DrawText(x0-1,y -3,Form("r%i",row)); 
-      if(i==8) break;                                      //do not draw the last line of PC
-      pL=new TLine(x0,y,x0+SizePcX(),y);   pL->Draw(); 
-    }    
-    for(Int_t iDil=1;iDil<=10;iDil++){Float_t x=x0+iDil*wDil;t.DrawText(x -3,y0-1,Form("d%i",11-iDil));   if(iDil==10) break;    pL=new TLine(x,y0,x,y0+SizePcY());  pL->Draw();}  
-  }      
+    if(iPc%2) {dig.Set(0,iPc,79,25); txt.DrawText(dig.LorsX()+2,dig.LorsY(),Form("PC%i",dig.Pc()));}//print PC#    
+    
+    txt.SetTextAlign(32);
+    for(Int_t iRow=0;iRow<8 ;iRow++){//draw row lines (horizontal)
+      dig.Set(0,iPc,0,iRow*6);   //set digit to the left-down pad of this row
+      if(iPc%2) txt.DrawText(dig.LorsX()-1           ,dig.LorsY(),Form("%i",dig.PadPcY())); //print PadY#    
+                txt.DrawText(dig.LorsX()-1+(iPc%2)*67,dig.LorsY()+2,Form("r%i",dig.Row())); //print Row#    
+      pL=new TLine(dig.LorsX()-0.5*SizePadX(),dig.LorsY()-0.5*SizePadY(),dig.LorsX()+SizePcX()-0.5*SizePadX(),dig.LorsY()-0.5*SizePadY()); 
+      if(iRow!=0) pL->Draw(); 
+    }//row loop  
+    
+    txt.SetTextAlign(13);
+    for(Int_t iDil=0;iDil<10;iDil++){//draw dilogic lines (vertical)
+      dig.Set(0,iPc,iDil*8,0);       //set this digit to the left-down pad of this dilogic        
+                           txt.DrawText(dig.LorsX()  ,dig.LorsY()-1,Form("%i",dig.PadPcX()));   //print PadX# 
+      if(iPc==4 || iPc==5) txt.DrawText(dig.LorsX()+2,dig.LorsY()+42,Form("d%i",dig.Dilogic())); //print Dilogic#    
+      pL=new TLine(dig.LorsX()-0.5*SizePadX(),dig.LorsY()-0.5*SizePadY(),dig.LorsX()-0.5*SizePadX(),dig.LorsY()+SizePcY()-0.5*SizePadY()); 
+      if(iDil!=0)pL->Draw();
+    }//dilogic loop        
+  }//PC loop      
 }//DrawPc()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void AliHMPIDDigit::Test()
+{
+  AliHMPIDDigit d1,d2; Int_t ddl;UInt_t w32;
+  for(Int_t i=0;i<10000;i++){
+    Int_t ch=Int_t(gRandom->Rndm()*7);
+    Int_t pc=Int_t(gRandom->Rndm()*6);
+    Int_t px=Int_t(gRandom->Rndm()*80);
+    Int_t py=Int_t(gRandom->Rndm()*48);
+    d1.Set(ch,pc,px,py);                
+    ddl=d1.Raw(w32);    d2.Raw(ddl,w32);
+    if(d1.Compare(&d2)) Printf("Problem!!!");
+  }
+  Printf("OK");
+}//Test()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+