]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Fixed bug into TOF time resolution control (F.Noferini)
authordecaro <decaro@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 13 Dec 2010 12:03:10 +0000 (12:03 +0000)
committerdecaro <decaro@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 13 Dec 2010 12:03:10 +0000 (12:03 +0000)
TOF/AliTOFSDigitizer.cxx
TOF/AliTOFSDigitizer.h

index 11bc1455f315bae7cfc40d53466c9245c05cbe64..c397831945c95a46838d96b3aad0245116fab4e7 100644 (file)
@@ -316,7 +316,7 @@ void AliTOFSDigitizer::InitParameters()
   fTimeWalkCenter = 0.  ;
   fTimeWalkBoundary=0.  ;
   fTimeWalkSlope  = 0.  ;
-  fTimeDelayFlag  = 1   ;
+  fTimeDelayFlag  = 0   ;
   fPulseHeightSlope=2.0 ;
   fTimeDelaySlope =0.060;
   // was fMinimumCharge = TMath::Exp(fPulseHeightSlope*fKparameter/2.);
@@ -531,6 +531,7 @@ void AliTOFSDigitizer::Exec(Option_t *verboseOption) {
            if(nFiredPads) {
              for(Int_t indexOfPad=0; indexOfPad<nActivatedPads; indexOfPad++) {
                if(isFired[indexOfPad]){ // the pad has fired
+
                  Float_t timediff=geantTime-tofAfterSimul[indexOfPad];
 
                  // TOF matching window (~200ns) control
@@ -720,6 +721,478 @@ void AliTOFSDigitizer::SimulateDetectorResponse(Float_t z0, Float_t x0, Float_t
   x = 0.5 * AliTOFGeometry::XPad() - TMath::Abs(dX);                               // variable for eff., res. and timeWalk. functions;
   ix++;                                                                              // x row: 1, ..., AliTOFGeometry::NpadX = 48
   
+  ////// Pad A:
+  nActivatedPads++;
+  nPlace[nActivatedPads-1] = (iz - 1) * AliTOFGeometry::NpadX() + ix;
+  qInduced[nActivatedPads-1] = qCenterPad;
+  padId[nActivatedPads-1] = 1;
+
+  switch (fEdgeEffect) {
+  case 0:
+    eff[nActivatedPads-1] = fEffCenter;
+    if (gRandom->Rndm() < eff[nActivatedPads-1]) {
+      nFiredPads = 1;
+      res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + fResCenter * fResCenter); // ns
+      isFired[nActivatedPads-1] = kTRUE;
+      tofTime[nActivatedPads-1] = gRandom->Gaus(geantTime + fTimeWalkCenter, res[0]);
+      averageTime = tofTime[nActivatedPads-1];
+    }
+    break;
+
+  case 1:
+    if(z < h) {
+      if(z < h2) {
+       effZ = fEffBoundary + (fEff2Boundary - fEffBoundary) * z / h2;
+      } else {
+       effZ = fEff2Boundary + (fEffCenter - fEff2Boundary) * (z - h2) / (h - h2);
+      }
+      //resZ = fTimeResolution;
+      //timeWalkZ = 0.;
+      nTail[nActivatedPads-1] = 1;
+    } else {
+      effZ = fEffCenter;
+      //resZ = fTimeResolution;
+      //timeWalkZ = 0.;
+    }
+    
+    if(x < h) {
+      if(x < h2) {
+       effX = fEffBoundary + (fEff2Boundary - fEffBoundary) * x / h2;
+      } else {
+       effX = fEff2Boundary + (fEffCenter - fEff2Boundary) * (x - h2) / (h - h2);
+      }
+      //resX = fTimeResolution;
+      //timeWalkX = 0.;
+      nTail[nActivatedPads-1] = 1;
+    } else {
+      effX = fEffCenter;
+      //resX = fTimeResolution;
+      //timeWalkX = 0.;
+    }
+    
+    (effZ<effX) ? eff[nActivatedPads-1] = effZ : eff[nActivatedPads-1] = effX;
+    res[nActivatedPads-1] = 0.001 * fTimeResolution; // ns
+    timeWalk[nActivatedPads-1] = 0.; // ns
+
+
+    ////// Pad B:
+    if(z < k2) {
+      effZ = fEffBoundary - (fEffBoundary - fEff3Boundary) * (z / k2);
+    } else {
+      effZ = fEff3Boundary * (k - z) / (k - k2);
+    }
+    //resZ = fTimeResolution;
+    //timeWalkZ = 0.;
+    
+    if(z < k && z > 0) {
+      if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
+       nActivatedPads++;
+       nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFGeometry::NpadX();
+       eff[nActivatedPads-1] = effZ;
+       res[nActivatedPads-1] = 0.001 * fTimeResolution; // ns 
+       timeWalk[nActivatedPads-1] = 0.; // ns
+       nTail[nActivatedPads-1] = 2;
+       if (fTimeDelayFlag) {
+         qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
+         logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
+         timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
+       } else {
+         timeDelay[nActivatedPads-1] = 0.;
+       }
+       padId[nActivatedPads-1] = 2;
+      }
+    }
+
+    
+    ////// Pad C, D, E, F:
+    if(x < k2) {
+      effX = fEffBoundary - (fEffBoundary - fEff3Boundary) * (x / k2);
+    } else {
+      effX = fEff3Boundary * (k - x) / (k - k2);
+    }
+    //resX = fTimeResolution;
+    //timeWalkX = 0.;
+    
+    if(x < k && x > 0) {
+      //   C:
+      if(ix > 1 && dX < 0) {
+       nActivatedPads++;
+       nPlace[nActivatedPads-1] = nPlace[0] - 1;
+       eff[nActivatedPads-1] = effX;
+       res[nActivatedPads-1] = 0.001 * fTimeResolution; // ns 
+       timeWalk[nActivatedPads-1] = 0.; // ns
+       nTail[nActivatedPads-1] = 2;
+       if (fTimeDelayFlag) {
+         qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
+         logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
+         timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
+       } else {
+         timeDelay[nActivatedPads-1] = 0.;
+       }
+       padId[nActivatedPads-1] = 3;
+
+       //     D:
+       if(z < k && z > 0) {
+         if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
+           nActivatedPads++;
+           nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFGeometry::NpadX() - 1;
+           eff[nActivatedPads-1] = effX * effZ;
+           res[nActivatedPads-1] = 0.001 * fTimeResolution; // ns
+           timeWalk[nActivatedPads-1] = 0.; // ns
+           
+           nTail[nActivatedPads-1] = 2;
+           if (fTimeDelayFlag) {
+             if (TMath::Abs(x) < TMath::Abs(z)) {
+               qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
+               logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
+             } else {
+               qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
+               logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
+             }
+             timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
+           } else {
+             timeDelay[nActivatedPads-1] = 0.;
+           }
+           padId[nActivatedPads-1] = 4;
+         }
+       }  // end D
+      }  // end C
+      
+      //   E:
+      if(ix < AliTOFGeometry::NpadX() && dX > 0) {
+       nActivatedPads++;
+       nPlace[nActivatedPads-1] = nPlace[0] + 1;
+       eff[nActivatedPads-1] = effX;
+       res[nActivatedPads-1] = 0.001 * fTimeResolution; // ns
+       timeWalk[nActivatedPads-1] = 0.; // ns
+       nTail[nActivatedPads-1] = 2;
+       if (fTimeDelayFlag) {
+         qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
+         logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
+         timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
+       } else {
+         timeDelay[nActivatedPads-1] = 0.;
+       }
+       padId[nActivatedPads-1] = 5;
+
+
+       //     F:
+       if(z < k && z > 0) {
+         if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
+           nActivatedPads++;
+           nPlace[nActivatedPads - 1] = nPlace[0] + (3 - 2 * iz) * AliTOFGeometry::NpadX() + 1;
+           eff[nActivatedPads - 1] = effX * effZ;
+           res[nActivatedPads-1] = 0.001 * fTimeResolution; // ns
+           timeWalk[nActivatedPads-1] = 0.; // ns
+           nTail[nActivatedPads-1] = 2;
+           if (fTimeDelayFlag) {
+             if (TMath::Abs(x) < TMath::Abs(z)) {
+               qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
+               logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
+             } else {
+               qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
+               logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
+             }
+             timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
+           } else {
+             timeDelay[nActivatedPads-1] = 0.;
+           }
+           padId[nActivatedPads-1] = 6;
+         }
+       }  // end F
+      }  // end E
+    } // end if(x < k)
+
+
+    for (Int_t iPad = 0; iPad < nActivatedPads; iPad++) {
+      if(gRandom->Rndm() < eff[iPad]) {
+       isFired[iPad] = kTRUE;
+       nFiredPads++;
+       if(fEdgeTails) {
+         if(nTail[iPad] == 0) {
+           tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
+         } else {
+           ftail->SetParameters(res[iPad], 2. * res[iPad], kSigmaForTail[nTail[iPad]-1]);
+           Double_t timeAB = ftail->GetRandom();
+           tofTime[iPad] = geantTime + timeWalk[iPad] + timeDelay[iPad] + timeAB;
+         }
+       } else {
+         //AliDebug(1,Form(" ----------------- TOF time resolution = %f",res[iPad]));
+         tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
+       }
+       if (fAverageTimeFlag) {
+         averageTime += tofTime[iPad] * qInduced[iPad];
+         weightsSum += qInduced[iPad];
+       } else {
+         averageTime += tofTime[iPad];
+         weightsSum += 1.;
+       }
+
+       AliDebug(1,Form(" Activated pad %d: geantTime=%f, tw=%fns, td=%fns, tofTime=%fns, sigma=%fps",iPad,geantTime,timeWalk[iPad],timeDelay[iPad],tofTime[iPad],1000.*res[iPad]));
+
+      }
+
+    }
+    if (weightsSum!=0) averageTime /= weightsSum;
+    break;
+
+
+  case 2:
+    if(z < h) {
+      if(z < h2) {
+       effZ = fEffBoundary + (fEff2Boundary - fEffBoundary) * z / h2;
+      } else {
+       effZ = fEff2Boundary + (fEffCenter - fEff2Boundary) * (z - h2) / (h - h2);
+      }
+      resZ = fResBoundary + (fResCenter - fResBoundary) * z / h;
+      timeWalkZ = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * z / h;
+      nTail[nActivatedPads-1] = 1;
+    } else {
+      effZ = fEffCenter;
+      resZ = fResCenter;
+      timeWalkZ = fTimeWalkCenter;
+    }
+    
+    if(x < h) {
+      if(x < h2) {
+       effX = fEffBoundary + (fEff2Boundary - fEffBoundary) * x / h2;
+      } else {
+       effX = fEff2Boundary + (fEffCenter - fEff2Boundary) * (x - h2) / (h - h2);
+      }
+      resX = fResBoundary + (fResCenter - fResBoundary) * x / h;
+      timeWalkX = fTimeWalkBoundary + (fTimeWalkCenter - fTimeWalkBoundary) * x / h;
+      nTail[nActivatedPads-1] = 1;
+    } else {
+      effX = fEffCenter;
+      resX = fResCenter;
+      timeWalkX = fTimeWalkCenter;
+    }
+    
+    (effZ<effX) ? eff[nActivatedPads-1] = effZ : eff[nActivatedPads-1] = effX;
+    (resZ<resX) ? res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resX * resX) : res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resZ * resZ); // ns
+    (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 *  timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
+
+
+    ////// Pad B:
+    if(z < k2) {
+      effZ = fEffBoundary - (fEffBoundary - fEff3Boundary) * (z / k2);
+    } else {
+      effZ = fEff3Boundary * (k - z) / (k - k2);
+    }
+    resZ = fResBoundary + fResSlope * z / k;
+    timeWalkZ = fTimeWalkBoundary + fTimeWalkSlope * z / k;
+    
+    if(z < k && z > 0) {
+      if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
+       nActivatedPads++;
+       nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFGeometry::NpadX();
+       eff[nActivatedPads-1] = effZ;
+       res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resZ * resZ); // ns 
+       timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ; // ns
+       nTail[nActivatedPads-1] = 2;
+       if (fTimeDelayFlag) {
+         qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
+         logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
+         timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
+       } else {
+         timeDelay[nActivatedPads-1] = 0.;
+       }
+       padId[nActivatedPads-1] = 2;
+      }
+    }
+
+    
+    ////// Pad C, D, E, F:
+    if(x < k2) {
+      effX = fEffBoundary - (fEffBoundary - fEff3Boundary) * (x / k2);
+    } else {
+      effX = fEff3Boundary * (k - x) / (k - k2);
+    }
+    resX = fResBoundary + fResSlope*x/k;
+    timeWalkX = fTimeWalkBoundary + fTimeWalkSlope*x/k;
+    
+    if(x < k && x > 0) {
+      //   C:
+      if(ix > 1 && dX < 0) {
+       nActivatedPads++;
+       nPlace[nActivatedPads-1] = nPlace[0] - 1;
+       eff[nActivatedPads-1] = effX;
+       res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resX * resX); // ns 
+       timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
+       nTail[nActivatedPads-1] = 2;
+       if (fTimeDelayFlag) {
+         qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
+         logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
+         timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
+       } else {
+         timeDelay[nActivatedPads-1] = 0.;
+       }
+       padId[nActivatedPads-1] = 3;
+
+       //     D:
+       if(z < k && z > 0) {
+         if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
+           nActivatedPads++;
+           nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFGeometry::NpadX() - 1;
+           eff[nActivatedPads-1] = effX * effZ;
+           (resZ<resX) ? res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resX * resX) : res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resZ * resZ); // ns
+           (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
+           
+           nTail[nActivatedPads-1] = 2;
+           if (fTimeDelayFlag) {
+             if (TMath::Abs(x) < TMath::Abs(z)) {
+               qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
+               logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
+             } else {
+               qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
+               logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
+             }
+             timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
+           } else {
+             timeDelay[nActivatedPads-1] = 0.;
+           }
+           padId[nActivatedPads-1] = 4;
+         }
+       }  // end D
+      }  // end C
+      
+      //   E:
+      if(ix < AliTOFGeometry::NpadX() && dX > 0) {
+       nActivatedPads++;
+       nPlace[nActivatedPads-1] = nPlace[0] + 1;
+       eff[nActivatedPads-1] = effX;
+       res[nActivatedPads-1] = 0.001 * (TMath::Sqrt(fAddTRes*fAddTRes + resX * resX)); // ns
+       timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
+       nTail[nActivatedPads-1] = 2;
+       if (fTimeDelayFlag) {
+         qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
+         logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
+         timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
+       } else {
+         timeDelay[nActivatedPads-1] = 0.;
+       }
+       padId[nActivatedPads-1] = 5;
+
+
+       //     F:
+       if(z < k && z > 0) {
+         if( (iz == 1 && dZ > 0) || (iz == 2 && dZ < 0) ) {
+           nActivatedPads++;
+           nPlace[nActivatedPads - 1] = nPlace[0] + (3 - 2 * iz) * AliTOFGeometry::NpadX() + 1;
+           eff[nActivatedPads - 1] = effX * effZ;
+           (resZ<resX) ? res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resX * resX) : res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resZ * resZ); // ns
+           (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001*timeWalkX; // ns
+           nTail[nActivatedPads-1] = 2;
+           if (fTimeDelayFlag) {
+             if (TMath::Abs(x) < TMath::Abs(z)) {
+               qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * z);
+               logOfqInd = gRandom->Gaus(-fPulseHeightSlope * z, fLogChargeSmearing);
+             } else {
+               qInduced[nActivatedPads-1] = TMath::Exp(-fPulseHeightSlope * x);
+               logOfqInd = gRandom->Gaus(-fPulseHeightSlope * x, fLogChargeSmearing);
+             }
+             timeDelay[nActivatedPads-1] = gRandom->Gaus(-fTimeDelaySlope * logOfqInd, fTimeSmearing);
+           } else {
+             timeDelay[nActivatedPads-1] = 0.;
+           }
+           padId[nActivatedPads-1] = 6;
+         }
+       }  // end F
+      }  // end E
+    } // end if(x < k)
+
+
+    for (Int_t iPad = 0; iPad < nActivatedPads; iPad++) {
+      if (res[iPad] < fTimeResolution) res[iPad] = fTimeResolution;
+      if(gRandom->Rndm() < eff[iPad]) {
+       isFired[iPad] = kTRUE;
+       nFiredPads++;
+       if(fEdgeTails) {
+         if(nTail[iPad] == 0) {
+           tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
+         } else {
+           ftail->SetParameters(res[iPad], 2. * res[iPad], kSigmaForTail[nTail[iPad]-1]);
+           Double_t timeAB = ftail->GetRandom();
+           tofTime[iPad] = geantTime + timeWalk[iPad] + timeDelay[iPad] + timeAB;
+         }
+       } else {
+         AliDebug(1,Form(" ----------------- TOF time resolution = %f",res[iPad]));
+         tofTime[iPad] = gRandom->Gaus(geantTime + timeWalk[iPad] + timeDelay[iPad], res[iPad]);
+       }
+       if (fAverageTimeFlag) {
+         averageTime += tofTime[iPad] * qInduced[iPad];
+         weightsSum += qInduced[iPad];
+       } else {
+         averageTime += tofTime[iPad];
+         weightsSum += 1.;
+       }
+      }
+    }
+    if (weightsSum!=0) averageTime /= weightsSum;
+
+  } // switch (fEdgeEffect)
+
+}
+
+//__________________________________________________________________
+void AliTOFSDigitizer::SimulateDetectorResponseOLD(Float_t z0, Float_t x0, Float_t geantTime, Int_t& nActivatedPads, Int_t& nFiredPads, Bool_t* isFired, Int_t* nPlace, Float_t* qInduced, Float_t* tofTime, Float_t& averageTime)
+{
+  // Description:
+  // Input:  z0, x0 - hit position in the strip system (0,0 - center of the strip), cm
+  //         geantTime - time generated by Geant, ns
+  // Output: nActivatedPads - the number of pads activated by the hit (1 || 2 || 4)
+  //         nFiredPads - the number of pads fired (really activated) by the hit (nFiredPads <= nActivatedPads)
+  //         qInduced[iPad]- charge induced on pad, arb. units
+  //                         this array is initialized at zero by the caller
+  //         tofAfterSimul[iPad] - time calculated with edge effect algorithm, ns
+  //                                   this array is initialized at zero by the caller
+  //         averageTime - time given by pad hited by the Geant track taking into account the times (weighted) given by the pads fired for edge effect also.
+  //                       The weight is given by the qInduced[iPad]/qCenterPad
+  //                                   this variable is initialized at zero by the caller
+  //         nPlace[iPad] - the number of the pad place, iPad = 0, 1, 2, 3
+  //                                   this variable is initialized at zero by the caller
+  //
+  // Description of used variables:
+  //         eff[iPad] - efficiency of the pad
+  //         res[iPad] - resolution of the pad, ns
+  //         timeWalk[iPad] - time walk of the pad, ns
+  //         timeDelay[iPad] - time delay for neighbouring pad to hited pad, ns
+  //         PadId[iPad] - Pad Identifier
+  //                    E | F    -->   PadId[iPad] = 5 | 6
+  //                    A | B    -->   PadId[iPad] = 1 | 2
+  //                    C | D    -->   PadId[iPad] = 3 | 4
+  //         nTail[iPad] - the tail number, = 1 for tailA, = 2 for tailB
+  //         qCenterPad - charge extimated for each pad, arb. units
+  //         weightsSum - sum of weights extimated for each pad fired, arb. units
+  
+  const Float_t kSigmaForTail[2] = {AliTOFGeometry::SigmaForTail1(),AliTOFGeometry::SigmaForTail2()}; //for tail                                                   
+  Int_t iz = 0, ix = 0;
+  Float_t dX = 0., dZ = 0., x = 0., z = 0.;
+  Float_t h = fHparameter, h2 = fH2parameter, k = fKparameter, k2 = fK2parameter;
+  Float_t effX = 0., effZ = 0., resX = 0., resZ = 0., timeWalkX = 0., timeWalkZ = 0.;
+  Float_t logOfqInd = 0.;
+  Float_t weightsSum = 0.;
+  Int_t nTail[4]  = {0,0,0,0};
+  Int_t padId[4]  = {0,0,0,0};
+  Float_t eff[4]  = {0.,0.,0.,0.};
+  Float_t res[4]  = {0.,0.,0.,0.};
+  //  Float_t qCenterPad = fMinimumCharge * fMinimumCharge;
+  Float_t qCenterPad = 1.;
+  Float_t timeWalk[4]  = {0.,0.,0.,0.};
+  Float_t timeDelay[4] = {0.,0.,0.,0.};
+  
+  nActivatedPads = 0;
+  nFiredPads = 0;
+  
+  (z0 <= 0) ? iz = 0 : iz = 1;
+  dZ = z0 + (0.5 * AliTOFGeometry::NpadZ() - iz - 0.5) * AliTOFGeometry::ZPad(); // hit position in the pad frame, (0,0) - center of the pad
+  z = 0.5 * AliTOFGeometry::ZPad() - TMath::Abs(dZ);                               // variable for eff., res. and timeWalk. functions
+  iz++;                                                                              // z row: 1, ..., AliTOFGeometry::NpadZ = 2
+  ix = (Int_t)((x0 + 0.5 * AliTOFGeometry::NpadX() * AliTOFGeometry::XPad()) / AliTOFGeometry::XPad());
+  dX = x0 + (0.5 * AliTOFGeometry::NpadX() - ix - 0.5) * AliTOFGeometry::XPad(); // hit position in the pad frame, (0,0) - center of the pad
+  x = 0.5 * AliTOFGeometry::XPad() - TMath::Abs(dX);                               // variable for eff., res. and timeWalk. functions;
+  ix++;                                                                              // x row: 1, ..., AliTOFGeometry::NpadX = 48
+  
   ////// Pad A:
   nActivatedPads++;
   nPlace[nActivatedPads-1] = (iz - 1) * AliTOFGeometry::NpadX() + ix;
@@ -780,7 +1253,10 @@ void AliTOFSDigitizer::SimulateDetectorResponse(Float_t z0, Float_t x0, Float_t
     }
     
     (effZ<effX) ? eff[nActivatedPads-1] = effZ : eff[nActivatedPads-1] = effX;
-    (resZ<resX) ? res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resX * resX) : res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resZ * resZ); // ns
+    if (fEdgeEffect==1)
+      (resZ<resX) ? res[nActivatedPads-1] = 0.001 * resX : res[nActivatedPads-1] = 0.001 * resZ; // ns
+    else
+      (resZ<resX) ? res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resX * resX) : res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resZ * resZ); // ns
     (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 *  timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
 
 
@@ -801,7 +1277,10 @@ void AliTOFSDigitizer::SimulateDetectorResponse(Float_t z0, Float_t x0, Float_t
        nActivatedPads++;
        nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFGeometry::NpadX();
        eff[nActivatedPads-1] = effZ;
-       res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resZ * resZ); // ns 
+       if (fEdgeEffect==1)
+         res[nActivatedPads-1] = 0.001 * resZ; // ns 
+       else
+         res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resZ * resZ); // ns 
        timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ; // ns
        nTail[nActivatedPads-1] = 2;
        if (fTimeDelayFlag) {
@@ -836,7 +1315,10 @@ void AliTOFSDigitizer::SimulateDetectorResponse(Float_t z0, Float_t x0, Float_t
        nActivatedPads++;
        nPlace[nActivatedPads-1] = nPlace[0] - 1;
        eff[nActivatedPads-1] = effX;
-       res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resX * resX); // ns 
+       if (fEdgeEffect==1)
+         res[nActivatedPads-1] = 0.001 * resX; // ns 
+       else if (fEdgeEffect==2)
+         res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resX * resX); // ns 
        timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
        nTail[nActivatedPads-1] = 2;
        if (fTimeDelayFlag) {
@@ -856,7 +1338,10 @@ void AliTOFSDigitizer::SimulateDetectorResponse(Float_t z0, Float_t x0, Float_t
            nActivatedPads++;
            nPlace[nActivatedPads-1] = nPlace[0] + (3 - 2 * iz) * AliTOFGeometry::NpadX() - 1;
            eff[nActivatedPads-1] = effX * effZ;
-           (resZ<resX) ? res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resX * resX) : res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resZ * resZ); // ns
+           if (fEdgeEffect==1)
+             (resZ<resX) ? res[nActivatedPads-1] = 0.001 * resX : res[nActivatedPads-1] = 0.001 * resZ; // ns
+           else if (fEdgeEffect==2)
+             (resZ<resX) ? res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resX * resX) : res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resZ * resZ); // ns
            (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
            
            nTail[nActivatedPads-1] = 2;
@@ -886,7 +1371,10 @@ void AliTOFSDigitizer::SimulateDetectorResponse(Float_t z0, Float_t x0, Float_t
        nActivatedPads++;
        nPlace[nActivatedPads-1] = nPlace[0] + 1;
        eff[nActivatedPads-1] = effX;
-       res[nActivatedPads-1] = 0.001 * (TMath::Sqrt(fAddTRes*fAddTRes + resX * resX)); // ns
+       if (fEdgeEffect==1)
+         res[nActivatedPads-1] = 0.001 * resX; // ns
+       else if (fEdgeEffect==2)
+         res[nActivatedPads-1] = 0.001 * (TMath::Sqrt(fAddTRes*fAddTRes + resX * resX)); // ns
        timeWalk[nActivatedPads-1] = 0.001 * timeWalkX; // ns
        nTail[nActivatedPads-1] = 2;
        if (fTimeDelayFlag) {
@@ -907,7 +1395,10 @@ void AliTOFSDigitizer::SimulateDetectorResponse(Float_t z0, Float_t x0, Float_t
            nActivatedPads++;
            nPlace[nActivatedPads - 1] = nPlace[0] + (3 - 2 * iz) * AliTOFGeometry::NpadX() + 1;
            eff[nActivatedPads - 1] = effX * effZ;
-           (resZ<resX) ? res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resX * resX) : res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resZ * resZ); // ns
+           if (fEdgeEffect==1)
+             (resZ<resX) ? res[nActivatedPads-1] = 0.001 * resX : res[nActivatedPads-1] = 0.001 * resZ; // ns
+           else if (fEdgeEffect==2)
+             (resZ<resX) ? res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resX * resX) : res[nActivatedPads-1] = 0.001 * TMath::Sqrt(fAddTRes*fAddTRes + resZ * resZ); // ns
            (timeWalkZ<timeWalkX) ? timeWalk[nActivatedPads-1] = 0.001 * timeWalkZ : timeWalk[nActivatedPads-1] = 0.001*timeWalkX; // ns
            nTail[nActivatedPads-1] = 2;
            if (fTimeDelayFlag) {
index 50f2381a6ec3591eb25fae8a503372abbb19910a..9ab5f43ce739a6100f712443012f62ad5d281576 100644 (file)
@@ -44,6 +44,7 @@ public:
   void InitParameters();
   virtual void PrintParameters() const ;
   virtual void SimulateDetectorResponse(Float_t z0, Float_t x0, Float_t geantTime, Int_t& nActivatedPads, Int_t& nFiredPads, Bool_t* isFired, Int_t* nPlace, Float_t* qInduced, Float_t* tofTime, Float_t& averageTime);
+  virtual void SimulateDetectorResponseOLD(Float_t z0, Float_t x0, Float_t geantTime, Int_t& nActivatedPads, Int_t& nFiredPads, Bool_t* isFired, Int_t* nPlace, Float_t* qInduced, Float_t* tofTime, Float_t& averageTime);
   virtual void Print(Option_t* opt) const ;
   void  SetFirstEvent(Int_t event1)      {fEvent1 = event1;}
   void  SetSecondEvent(Int_t event2)     {fEvent2 = event2;}