]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/UPGRADE/AliITSUSimulation.cxx
added new data member for max clusters/track
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUSimulation.cxx
index 383ea89d1a3faed38a18ca35e452fdace019cafe..29885418e802f73f0cbe1bdb91eac2e8ef7f067d 100644 (file)
@@ -37,6 +37,8 @@ AliITSUSimulation::AliITSUSimulation()
   ,fSimuParam(0)
   ,fResponseParam(0)
   ,fModule(0)
+  ,fReadOutCycleOffset(0)
+  ,fReadOutCycleLength(25e-6)  
   ,fEvent(0)
   ,fDebug(0)
 {
@@ -51,6 +53,8 @@ AliITSUSimulation::AliITSUSimulation(AliITSUSimuParam* sim,AliITSUSensMap* map)
   ,fSimuParam(sim)
   ,fResponseParam(0)
   ,fModule(0)
+  ,fReadOutCycleOffset(0)
+  ,fReadOutCycleLength(25e-6)
   ,fEvent(0)
   ,fDebug(0)
 {
@@ -67,6 +71,8 @@ AliITSUSimulation::AliITSUSimulation(const AliITSUSimulation &s)
   ,fSimuParam(s.fSimuParam)   
   ,fResponseParam(s.fResponseParam)
   ,fModule(s.fModule)
+  ,fReadOutCycleOffset(s.fReadOutCycleOffset)
+  ,fReadOutCycleLength(s.fReadOutCycleLength)
   ,fEvent(s.fEvent)
   ,fDebug(s.fDebug)
 {
@@ -85,6 +91,8 @@ AliITSUSimulation&  AliITSUSimulation::operator=(const AliITSUSimulation &s)
   fSimuParam = s.fSimuParam;
   fResponseParam = s.fResponseParam;
   fModule    = s.fModule;
+  fReadOutCycleOffset = s.fReadOutCycleOffset;
+  fReadOutCycleLength = s.fReadOutCycleLength;
   fEvent     = s.fEvent;
   return *this;
 }
@@ -99,9 +107,8 @@ void AliITSUSimulation::InitSimulationModule(AliITSUModule* mod, Int_t event, Al
   SetSegmentation(seg);
   SetResponseParam(resp);
   ClearMap();
-  memset(fCyclesID,0,2*kMaxROCycleAccept*sizeof(Bool_t));
+  memset(fCyclesID,0,(1+2*kMaxROCycleAccept)*sizeof(Bool_t));
   //
-  if (event != fEvent) GenerateReadOutCycleOffset(); 
   SetEvent(event);
   
 }
@@ -136,19 +143,28 @@ void AliITSUSimulation::UpdateMapSignal(UInt_t col,UInt_t row,Int_t trk,Int_t ht
 {
   // update map with new hit
   // Note: roCycle can be anything between -kMaxROCycleAccept : kMaxROCycleAccept
+  if (Abs(roCycle)>kMaxROCycleAccept) {
+    AliError(Form("CycleID %d is outside of allowed +-%d range",roCycle,kMaxROCycleAccept));
+    return;
+  }
   UInt_t ind = fSensMap->GetIndex(col,row,roCycle);
-  AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(ind);
-  if (!oldItem) {
+  AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(ind);  
+  if (!oldItem) {    
     fSensMap->RegisterItem( new(fSensMap->GetFree()) AliITSUSDigit(trk,ht,fModule->GetIndex(),ind,signal,roCycle) );
     fCyclesID[roCycle+kMaxROCycleAccept] = kTRUE;
   }
   else oldItem->AddSignal(trk,ht,signal);
+  //
 }
 
 //______________________________________________________________________
 void AliITSUSimulation::UpdateMapNoise(UInt_t col,UInt_t row,Double_t noise, Int_t roCycle) 
 {
   // update map with new hit
+  if (Abs(roCycle)>kMaxROCycleAccept) {
+    AliError(Form("CycleID %d is outside of allowed +-%d range",roCycle,kMaxROCycleAccept));
+    return;
+  }
   UInt_t ind = fSensMap->GetIndex(col,row,roCycle);
   AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(ind);
   if (!oldItem) {
@@ -183,3 +199,15 @@ Int_t AliITSUSimulation::GenOrderedSample(UInt_t nmax,UInt_t ngen,TArrayI &vals,
   Sort((int)ngen,valA,indA,kFALSE);
   return ngen;
 }
+
+//______________________________________________________________________
+Double_t AliITSUSimulation::GenerateReadOutCycleOffset()
+{
+  // Generate randomly the strobe
+  // phase w.r.t to the LHC clock
+  return fReadOutCycleOffset = fReadOutCycleLength*gRandom->Rndm();
+  // fReadOutCycleOffset = 25e-9*gRandom->Rndm(); // clm: I think this way we shift too much 10-30 us! The global shift should be between the BCs?!
+  // RS: 25 ns is too small number, the staggering will not work. Let's at the moment keep fully random shift (still, no particle from correct
+  // collision will be lost) untill real number is specified
+ //
+}