]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Most of these updates are related to the offline software needed for the pixel trigge...
authormasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 3 Apr 2009 20:02:49 +0000 (20:02 +0000)
committermasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 3 Apr 2009 20:02:49 +0000 (20:02 +0000)
* Managing pixel trigger conditions data.
* Simulating generation of fast-or signals from SPD.
* Simulating pixel trigger response.
See also class schematics at http://tydes.home.cern.ch/tydes/doc/PitOffline

The treatment of dead/noisy pixels has also changed, both in the simulation and the reconstruction step. During simulation, it will be possible (via AliITSSimuParam) to choose whether dead/noisy pixels should be removed/added. Default is to add noisy pixels (which may be none, as one likes), but not to remove dead pixels. A similar choice for local reconstruction (via AliITSRecoParam) removes by default both noisy and dead pixels before the clusterization step. This is the safe way to proceed. However, in case of real data, one might speed up by skipping the removal of dead pixels, since they could not appear - by definition - in this case. With this strategy there will hopefully be less confusion on the meaning of dead and noisy pixels.

--------------------
MODIFIED/NEW CLASSES
--------------------

AliITS:
* CreateTriggerDetector is passing the AliITSTriggerConditions to AliITSTrigger upon creation.
* In HitsToDigits and SDigitsToDigits, AliITSDetTypeSim object (which takes care of generating the AliITSFOSignalsSPD) will be called to reset the fast-or signals before the event and to add noise and store them after wards (using the AliITSLoader).
* Digits2Raw will take the AliITSFOSignalsSPD from the AliITSLoader in order to pass them to AliITSDDLRawData::RawDataSPD, where they will be added to the simulated raw data.

AliITSClusterFinderV2SPD:
* The two FindClustersSPD methods (one for raw data, one for digits) are now filling the FastOrFiredMap (TBits) member of AliITSDetTypeRec. Fast-or signals come either directly from raw data or from AliITSFOSignalsSPD object in digits file.
* Before clustering, there is a possibility to remove noisy and dead pixels from the fired pixel map. Default is to remove both noisy and dead, but may be changed via AliITSRecoParam. In case of real data one might want to speed up by skipping removing dead pixels (which anyway should not appear in this case).
* Henrik's comment: The name of this class is a bit misleading, since it does several things apart from clustering. It might be discussed if one should separate into something like AliITSLocalReconstructionSPD and AliITSClusterFinderSPD. For instance, with the existing code, it is a bit strange that the cluster finder needs to know how the raw data is written, what a digit is, and so on.

AliITSDDLRawData:
* Modified to be able to write fast-or signals into raw data. The signals are fed from outside to this class (see AliITS::Digits2Raw).
* The procedure that converts digits into raw data (inside GetDigitsSPD method) was reimplemented, since the old code was unreadable.

AliITSDetTypeRec:
* Added pointer to AliITSFOSignalsSPD. This is used to let the AliITSClusterFinderV2SPD access the fast-or signals generated during simulation.
* Added pointer to AliITSTriggerConditions. This is used to remove the inactive chips from the fFastOrFiredMap (TBits), needed in real data. This is done in method RemoveFastOrFiredInActive. The fFastorFiredMap will eventually go into the AliMultiplicity class in the ESD.

AliITSDetTypeSim:
* Added AliITSFOGeneratorSPD object to take care of simulating the generation of fast-or signals.
* Added pointer to noisy calibration objects read from OCDB.
* Added pointer to AliITSTriggerConditions, needed by the AliITSFOGeneratorSPD object.
* GetCalibration method reads AliITSFOEfficiencySPD and AliITSFONoiseSPD objects from OCDB and passes them to the AliITSFOGeneratorSPD object.
* Takes care of storing the generated fast-or signals via AliITSLoader.

AliITSLoader:
* Added an AliBaseLoader for the AliITSFOSignalsSPD object that should be stored in the 'ITS.Digits.root' file. It is placed as a second loader (AliObjectLoader in this case) in the digits data loader, next to the digits tree loader (AliTreeLoader). Its name is the same as the class - 'AliITSFOSignalsSPD'.
* The Load/UnloadDigits methods are presently not taking care of this new loader. It is not clear which is the best way to solve this. It may require changes to the AliLoader class itself.

AliITSRawStreamSPD:
* Added method GetDDLID, which may be useful in places where there is no access to the AliRawReader object (just calls the AliRawReader::GetDDLID).
* Minor modifications to parsing of extra calibration headers.

AliITSsimulationSPD:
* Method RemoveDeadPixels slightly modified. Does not require the AliITSmodule as input anymore.
* Method AddNoisyPixels added. This will allow the possibility to explicitly add noisy pixels as digits, which could then also give rise to fast-or signals. For each noisy pixel, a noise 10 times the threshold will be added to the map.
* For each digit found in method FrompListToDigits (basically SDigits to Digits), the AliITSDetTypeSim::ProcessSPDDigitForFastOr will be called.

AliITSTrigger:
* Added object AliITSTriggerFOProcessor as member. This will take care of simulating the response of the pixel trigger system upon receiving a set of fast-or signals. It will need an AliITSTriggerConditions object, which normally is read from OCDB.
* The CreateInputs method will create inputs based on the AliITSTriggerConditions object.
* The Trigger method reads the AliITSFOSignalsSPD via AliITSLoader and asks the AliITSTriggerFOProcessor for a decision (yes/no) from each of the defined output lines. If yes, SetInput will be called.

ITSSPDSCANda:
* Modified initial comments, since this DA should not be used for run type DAQ_FO_UNIF_SCAN, as originally planned.
* Removed the temporary patch of reading chip present information, which is no longer needed.
* Mean threshold scan header format changed. The current DAC value will now be replaced by RowSpan and current DAC value should be taken from TPLow, assuming it is the same for all 6 half-staves of a half-sector.

AliITSFOEfficiencySPD:
* New class used to store information about the fast-or efficiency. The values stored are the probability that a pixel hit will generate a fast-or signal. In this base class there is one value for each pixel chip. The daughter class AliITSFOEfficiencySPDColumn may be used if there should be even a difference per pixel chip column.
* Will be put in OCDB as "ITS/Calib/SPDFOEfficiency". A new file with 100% efficiency for all is put as default.

AliITSFOEfficiencySPDColumn:
* New class that inherits from AliITSFOEfficiencySPD. May be used instead of base class, when the effiency values differ between single pixel chip columns.

AliITSFONoiseSPD:
* New class used to store information about the fast-or noise. The values stored are the probability that a pixel chip will generate a fast-or signal originating from random noise.
* Will be put in OCDB as "ITS/Calib/SPDFONoise". A new file with 0% noise for all is put as default.

AliITSFOGeneratorSPD:
* New class taking care of generation of fast-or signals in simulation.
* The ProcessPixelHit method should be called for each fired pixel found in the digitization procedure. The decision if the pixel will generate a fast-or signal will be based on an AliITSFOEfficiencySPD object which gives the probability.
* After digitization, method ProcessNoise should be called, which will add noise according to probabilities taken from an AliITSFONoiseSPD object.
* The final result is a filled AliITSFOSignalsSPD object, a member of this class.

AliITSFOSignalsSPD:
* New class that is able to store 1200 bits per event, each saying wether a pixel chip gave a fast-or signal or not. This object will be stored in the 'ITS.Digits.root' file during simulation.

AliITSTriggerConditions:
* New class that represents the conditions of the pixel trigger system. This object will contain the same information as is being sent by the pixel trigger system at start-of-run to DCS file exchange server, and taken offline by the shuttle. Preprocessor code will store the object in OCDB as "ITS/Calib/PITConditions". A new file with some default conditions is placed there.
* Data members: run number, firmware version, input config version, parameters version, a list of AliITSTriggerAlgorithmConditions objects, a list of inactive chips.

AliITSTriggerAlgorithmConditions:
* New class that holds the information regarding a single pixel trigger algorithm.
* Data members: label, id, description, number of parameters, parameter values, parameter names.

AliITSTriggerFOProcessor:
* New class that is able to process the AliITSFOSignalsSPD in order to evaluate if a given pixel trigger output is activated.
* Uses an AliITSTriggerConditions object to know the parameters corresponding to the algorithms in use.
* New algorithms should be added here as soon as they are implemented online. Only a couple of the existing online algorithms have been implemented here so far.
* The two algorithms used in the old AliITSTrigger code, have been adapted to the new framework and are added to the AliITSTriggerConditions object in ITS/Calib/PITConditions.

AliITSSimuParam:
* Added flag saying whether noisy pixels should be added at the level of digitization (which could then also lead to additional fast-or signals).
* Added flag saying whether dead pixels should be removed at the level of digitization.

AliITSRecoParam:
* Added flag saying whether noisy pixels should be removed at the level of local reconstruction (default is true).
* Added flag saying whether dead pixels should be removed at the level of local reconstruction (default is true, but may for instance be put to false to speed up in case of real data, since we then know the dead pixels would not appear in any case).

---------------
REMOVED CLASSES
---------------

AliITSFastOrCalibrationSPD:
* This class is removed, since it is no longer needed. The TBits of fast-or configured chips will be part of AliITSTriggerConditions from now on (instead represented as inactive chips). The calibration file, which before was in "ITS/Calib/SPDFastOr" is removed as well.

Henrik Tydesjo

43 files changed:
ITS/AliITS.cxx
ITS/AliITS.h
ITS/AliITSClusterFinderV2SPD.cxx
ITS/AliITSDDLRawData.cxx
ITS/AliITSDDLRawData.h
ITS/AliITSDetTypeRec.cxx
ITS/AliITSDetTypeRec.h
ITS/AliITSDetTypeSim.cxx
ITS/AliITSDetTypeSim.h
ITS/AliITSFOEfficiencySPD.cxx [new file with mode: 0644]
ITS/AliITSFOEfficiencySPD.h [new file with mode: 0644]
ITS/AliITSFOEfficiencySPDColumn.cxx [new file with mode: 0644]
ITS/AliITSFOEfficiencySPDColumn.h [new file with mode: 0644]
ITS/AliITSFOGeneratorSPD.cxx [new file with mode: 0644]
ITS/AliITSFOGeneratorSPD.h [new file with mode: 0644]
ITS/AliITSFONoiseSPD.cxx [new file with mode: 0644]
ITS/AliITSFONoiseSPD.h [new file with mode: 0644]
ITS/AliITSFOSignalsSPD.cxx [new file with mode: 0644]
ITS/AliITSFOSignalsSPD.h [new file with mode: 0644]
ITS/AliITSFastOrCalibrationSPD.cxx [deleted file]
ITS/AliITSFastOrCalibrationSPD.h [deleted file]
ITS/AliITSLoader.cxx
ITS/AliITSLoader.h
ITS/AliITSRawStreamSPD.h
ITS/AliITSRecoParam.cxx
ITS/AliITSRecoParam.h
ITS/AliITSSimuParam.h
ITS/AliITSTrigger.cxx
ITS/AliITSTrigger.h
ITS/AliITSTriggerAlgorithmConditions.cxx [new file with mode: 0644]
ITS/AliITSTriggerAlgorithmConditions.h [new file with mode: 0644]
ITS/AliITSTriggerConditions.cxx [new file with mode: 0644]
ITS/AliITSTriggerConditions.h [new file with mode: 0644]
ITS/AliITSTriggerFOProcessor.cxx [new file with mode: 0644]
ITS/AliITSTriggerFOProcessor.h [new file with mode: 0644]
ITS/AliITSsimulationSPD.cxx
ITS/AliITSsimulationSPD.h
ITS/CMake_libITSbase.txt
ITS/CMake_libITSsim.txt
ITS/ITSbaseLinkDef.h
ITS/ITSsimLinkDef.h
ITS/libITSbase.pkg
ITS/libITSsim.pkg

index 72636bd63b4d562af0af9ce9c05ecdbfd663ce56..f0d74a4d9c1d90d56058fbc07071021eb265e676 100644 (file)
@@ -95,6 +95,7 @@ the AliITS class.
 #include "AliRun.h"
 #include "AliLog.h"
 #include "AliITSInitGeometry.h"
+#include "AliITSFOSignalsSPD.h"
 
 ClassImp(AliITS)
 
@@ -219,7 +220,7 @@ AliITS::~AliITS(){
     if (fDetTypeSim){
       delete fDetTypeSim;
       fDetTypeSim = 0;
-    }
+   }
 }
 //______________________________________________________________________
 AliDigitizer* AliITS::CreateDigitizer(AliRunDigitizer* manager)const{
@@ -254,8 +255,6 @@ void AliITS::Init(){
     if(gMC) for(i=0;i<fIdN;i++) fIdSens[i] = gMC->VolId(fIdName[i]);
  
 }
-
-
 //______________________________________________________________________
 void AliITS::SetDefaults(){
     // sets the default segmentation, response, digit and raw cluster classes.
@@ -482,8 +481,6 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
   
   
 }
-
-
 //______________________________________________________________________
 void AliITS::FillModules(TTree *treeH, Int_t mask) {
     // fill the modules with the sorted by module hits; 
@@ -592,8 +589,7 @@ void AliITS::Hits2SDigits(){
 
    if(!fDetTypeSim) {
      Error("Hits2SDigits","fDetTypeSim is null!");
-     return;
-    
+     return; 
   } 
      
   SetDefaults();
@@ -684,6 +680,9 @@ void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
   Int_t nmodules;
   InitModules(size,nmodules);
   FillModules(evNumber,bgrev,nmodules,option,filename);
+  // Reset Fast-OR signals for this event
+  fDetTypeSim->ResetFOSignals();
 
   AliITSsimulation *sim      = 0;
   AliITSmodule     *mod      = 0;
@@ -707,6 +706,17 @@ void AliITS::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
   
   ClearModules();
   
+  // Add random noise to FO signals
+  if (all || det[0]) { // SPD present
+    fDetTypeSim->ProcessNoiseForFastOr();
+  }
+
+  // Add Fast-OR signals to event (only one object per event)
+  if (all || det[0]) { // SPD present
+    fDetTypeSim->WriteFOSignals();
+  }
+
+  
   fLoader->TreeD()->GetEntries();
   fLoader->TreeD()->AutoSave();
   // reset tree
@@ -946,20 +956,35 @@ void AliITS::CheckLabels(Int_t lab[3]) const {
 
 //______________________________________________________________________
 void AliITS::SDigitsToDigits(Option_t *opt){
-    // Standard Summable digits to Digits function.
-    // Inputs:
-    //      none.
-    // Outputs:
-    //      none.
-    if(!fDetTypeSim) {
-      Error("SDigitsToSDigits","fDetTypeSim is 0!");
-      return;
-    }
-   
-    fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
-    SetDefaults();
-    fDetTypeSim->SDigitsToDigits(opt,(Char_t*)GetName());
+  // Standard Summable digits to Digits function.
+  // Inputs:
+  //      none.
+  // Outputs:
+  //      none.
+  if (!fDetTypeSim) {
+    AliError("fDetTypeSim is 0!");
+    return;
+  }
 
+  const char *all = strstr(opt,"All");
+  const char *det[3] ={strstr(opt,"SPD"),strstr(opt,"SDD"),
+                      strstr(opt,"SSD")};
+
+  // Reset Fast-OR signals for this event
+  fDetTypeSim->ResetFOSignals();
+
+  fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
+  SetDefaults();
+  fDetTypeSim->SDigitsToDigits(opt,(Char_t*)GetName());
+
+  // Add random noise to FO signals
+  if (all || det[0]) { // SPD present
+    fDetTypeSim->ProcessNoiseForFastOr();
+  }
+  // Add Fast-OR signals to event (only one object per event)
+  if (all || det[0]) { // SPD present
+    fDetTypeSim->WriteFOSignals();
+  }
 }
 
 //______________________________________________________________________
@@ -1076,6 +1101,32 @@ void AliITS::Digits2Raw(){
       return;
   }
   fDetTypeSim->SetTreeAddressD(digits,(Char_t*)GetName());
+  
+   // Get the FO signals for this event
+  AliITSFOSignalsSPD* foSignals = NULL;
+  AliRunLoader* runLoader = AliRunLoader::Instance();
+  AliITSLoader* itsLoader = (AliITSLoader*) runLoader->GetLoader("ITSLoader");
+  if (!itsLoader) {
+    AliError("ITS loader is NULL.");
+  }
+  else {
+    AliBaseLoader* foLoader = itsLoader->GetFOSignalsLoader();
+    if (!foLoader) {
+      AliError("FO signals base loader not retrieved.");
+    }
+    else {
+      foLoader->Load();
+      foSignals = (AliITSFOSignalsSPD*) foLoader->Get();
+    }
+  }
+  Bool_t deleteFOsignalsLater = kFALSE;
+  if (!foSignals) {
+    AliError("FO signals not available. No FO bits will be written.");
+    foSignals = new AliITSFOSignalsSPD(); // make a temporary dummy signals object
+    deleteFOsignalsLater = kTRUE;
+  }
+  
+  
   AliITSDDLModuleMapSDD* ddlsdd=fDetTypeSim->GetDDLModuleMapSDD();
   Bool_t isHLTmodeC=fDetTypeSim->IsHLTmodeC();
   AliITSDDLRawData rawWriter;
@@ -1093,7 +1144,8 @@ void AliITS::Digits2Raw(){
     
   //SILICON PIXEL DETECTOR
   Info("Digits2Raw", "Formatting raw data for SPD");
-  rawWriter.RawDataSPD(digits->GetBranch("ITSDigitsSPD"));
+  rawWriter.RawDataSPD(digits->GetBranch("ITSDigitsSPD"),foSignals);
+  if(deleteFOsignalsLater) delete foSignals;
     
   //SILICON DRIFT DETECTOR
   Info("Digits2Raw", "Formatting raw data for SDD");
@@ -1115,7 +1167,7 @@ AliLoader* AliITS::MakeLoader(const char* topfoldername){
     fLoader = new AliITSLoader(GetName(),topfoldername);
     return fLoader;
 }
-
+//______________________________________________________________________
 Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
 {
   //
@@ -1129,16 +1181,14 @@ Bool_t AliITS::Raw2SDigits(AliRawReader* rawReader)
     for (Int_t mod = 0; mod < size; mod++) modA[mod] = new TClonesArray("AliITSpListItem", 10000);
     
     AliLoader* loader =  (AliRunLoader::Instance())->GetLoader("ITSLoader");
-    if (!loader)
-    {
+    if (!loader){
        Error("Open","Can not get ITS loader from Run Loader");
        return kFALSE;
     }
 
     TTree* tree = 0;
     tree = loader->TreeS();
-    if (!tree)
-    {
+    if (!tree){
        loader->MakeTree("S");
        tree = loader->TreeS();
     }
@@ -1269,4 +1319,9 @@ void AliITS::UpdateInternalGeometry(){
   AliITSgeom* geom = initgeom.CreateAliITSgeom(version,minor);
   SetITSgeom(geom);
 }
+//______________________________________________________________________
+AliTriggerDetector* AliITS::CreateTriggerDetector() const {
+  // create an AliITSTrigger object (and set trigger conditions as input)
+  return new AliITSTrigger(fDetTypeSim->GetTriggerConditions());
+}
 
index eb39b9c8ae5788b738da4f5bf0b1565d549fa2de..325c585e1643caf9f05fbf5a587d4b5abc9280a0 100644 (file)
@@ -101,8 +101,7 @@ class AliITS : public AliDetector {
     virtual void ClearModules(){if(fITSmodules) fITSmodules->Delete();}
     virtual void AddHit(Int_t track, Int_t *vol, Float_t *hits);
    // Trigger
-    virtual AliTriggerDetector* CreateTriggerDetector() const
-       { return new AliITSTrigger(); }
+    virtual AliTriggerDetector* CreateTriggerDetector() const;
 
     AliDigitizer* CreateDigitizer(AliRunDigitizer* manager) const;
     virtual void UpdateInternalGeometry();
index fc33d7659408cd004bf0239ae63e2353db4479a0..ae991069f0f5cdbfde8fec15a3a0ca346ad27b33 100644 (file)
 #include "AliITSRawStreamSPD.h"
 #include <TClonesArray.h>
 #include "AliITSdigitSPD.h"
+#include "AliITSFOSignalsSPD.h"
 
 ClassImp(AliITSClusterFinderV2SPD)
 
+//__________________________________________________________________________
 AliITSClusterFinderV2SPD::AliITSClusterFinderV2SPD(AliITSDetTypeRec* dettyp):AliITSClusterFinder(dettyp),
 fLastSPD1(AliITSgeomTGeo::GetModuleIndex(2,1,1)-1),
 fNySPD(256),
@@ -63,18 +65,16 @@ fHlSPD(3.48){
   }
 
 }
-
+//__________________________________________________________________________
 void AliITSClusterFinderV2SPD::FindRawClusters(Int_t mod){
-
   //Find clusters V2
   SetModule(mod);
   FindClustersSPD(fDigits);
 
 }
-
+//__________________________________________________________________________
 void AliITSClusterFinderV2SPD::RawdataToClusters(AliRawReader* rawReader, TClonesArray** clusters){
-    //------------------------------------------------------------
+  //------------------------------------------------------------
   // This function creates ITS clusters from raw data
   //------------------------------------------------------------
   rawReader->Reset();
@@ -82,7 +82,7 @@ void AliITSClusterFinderV2SPD::RawdataToClusters(AliRawReader* rawReader, TClone
   FindClustersSPD(&inputSPD, clusters);
 
 }
-
+//__________________________________________________________________________
 Int_t AliITSClusterFinderV2SPD::ClustersSPD(AliBin* bins, TClonesArray* digits,TClonesArray* clusters,Int_t maxBins,Int_t nzbins,Int_t iModule,Bool_t rawdata){
   
   //Cluster finder for SPD (from digits and from rawdata)
@@ -97,16 +97,35 @@ Int_t AliITSClusterFinderV2SPD::ClustersSPD(AliBin* bins, TClonesArray* digits,T
   }
   const TGeoHMatrix *mT2L=AliITSgeomTGeo::GetTracking2LocalMatrix(iModule);
 
-  AliITSCalibrationSPD *cal =  
-       (AliITSCalibrationSPD*) fDetTypeRec->GetCalibrationModel(iModule); 
-  // Loop on bad pixels and reset them
-  for(Int_t ipix = 0; ipix<cal->GetNrBad(); ipix++){
-    Int_t row, col;
-    cal->GetBadPixel(ipix,row,col);
-    Int_t index = (row+1) * nzbins + (col+1);
-    bins[index].SetQ(0);
-    bins[index].SetMask(0xFFFFFFFE);
+   if (repa->GetSPDRemoveNoisyFlag()) {
+    // Loop on noisy pixels and reset them
+    AliITSCalibrationSPD *cal =  
+      (AliITSCalibrationSPD*) fDetTypeRec->GetCalibrationModel(iModule);
+    for(Int_t ipix = 0; ipix<cal->GetNrBad(); ipix++){
+      Int_t row, col;
+      cal->GetBadPixel(ipix,row,col);
+      printf(" module %d   row %d  col %d \n",iModule,row,col);
+      Int_t index = (row+1) * nzbins + (col+1);
+      
+      bins[index].SetQ(0);
+      bins[index].SetMask(0xFFFFFFFE);
+    }
+  }
+  
+    if (repa->GetSPDRemoveDeadFlag()) {
+    // Loop on dead pixels and reset them
+    AliITSCalibrationSPD *cal =  
+      (AliITSCalibrationSPD*) fDetTypeRec->GetSPDDeadModel(iModule); 
+    if (cal->IsBad()) return 0; // if all ladder is dead, return to save time
+    for(Int_t ipix = 0; ipix<cal->GetNrBad(); ipix++){
+      Int_t row, col;
+      cal->GetBadPixel(ipix,row,col);
+      Int_t index = (row+1) * nzbins + (col+1);
+      bins[index].SetQ(0);
+      bins[index].SetMask(0xFFFFFFFE);
+    }
   }
+  
   Int_t nclu=0;
   for(Int_t iBin =0; iBin < maxBins;iBin++){
     if(bins[iBin].IsUsed()) continue;
@@ -138,6 +157,7 @@ Int_t AliITSClusterFinderV2SPD::ClustersSPD(AliBin* bins, TClonesArray* digits,T
       zmin=dig->GetCoord1();
       zmax=zmin;
     }
+     if(iModule == 24 || iModule == 25)  printf("\n");
     for (Int_t idx = 0; idx < nBins; idx++) {
       Int_t iy;
       Int_t iz; 
@@ -149,6 +169,7 @@ Int_t AliITSClusterFinderV2SPD::ClustersSPD(AliBin* bins, TClonesArray* digits,T
        AliITSdigitSPD* dig = (AliITSdigitSPD*)digits->UncheckedAt(idxBins[idx]);
        iy = dig->GetCoord2();
        iz = dig->GetCoord1();
+        //if(iModule == 24 || iModule == 25) printf(" ||  iy %d   iz %d  in Module %d \n",iy,iz,iModule);
       }
       if (ymin > iy) ymin = iy;
       if (ymax < iy) ymax = iy;
@@ -247,16 +268,15 @@ Int_t AliITSClusterFinderV2SPD::ClustersSPD(AliBin* bins, TClonesArray* digits,T
   return nclu;
   
 }
-
-
-
-
+//__________________________________________________________________________
 void AliITSClusterFinderV2SPD::FindClustersSPD(AliITSRawStreamSPD* input, 
                                        TClonesArray** clusters) 
 {
   //------------------------------------------------------------
-  // Actual SPD cluster finder for raw data
+  // SPD cluster finder for raw data (this method is called once per event)
+  // Now also fills fast-or fired map
   //------------------------------------------------------------
+  
   Int_t nClustersSPD = 0;
   Int_t kNzBins = fNzSPD + 2;
   Int_t kNyBins = fNySPD + 2;
@@ -284,23 +304,12 @@ void AliITSClusterFinderV2SPD::FindClustersSPD(AliITSRawStreamSPD* input,
       memcpy(binsSPD,binsSPDInit,sizeof(AliBin)*kMaxBin);
     }
 
-    // fill the current digit into the bins array
-    Int_t index = (input->GetCoord2()+1) * kNzBins + (input->GetCoord1()+1);
-    bins[index].SetIndex(index);
-    bins[index].SetMask(1);
-    bins[index].SetQ(1);
-  }
-
-  // get the FastOr bit map
-  fDetTypeRec->ResetFastOrFiredMap();
-  for(UInt_t eq=0; eq<20; eq++) {
-    for(UInt_t hs=0; hs<6; hs++) {
-      for(UInt_t chip=0; chip<10; chip++) {
-        if(input->GetFastOrSignal(eq,hs,chip)) {
-          UInt_t chipKey = input->GetOfflineChipKeyFromOnline(eq,hs,chip);
-          fDetTypeRec->SetFastOrFiredMap(chipKey);
-        }
-      }
+    if (next) {
+      // fill the current digit into the bins array
+      Int_t index = (input->GetCoord2()+1) * kNzBins + (input->GetCoord1()+1);
+      bins[index].SetIndex(index);
+      bins[index].SetQ(1);
+      bins[index].SetMask(1);
     }
   }
 
@@ -309,13 +318,24 @@ void AliITSClusterFinderV2SPD::FindClustersSPD(AliITSRawStreamSPD* input,
   
   // AliDebug(1,Form("found clusters in ITS SPD: %d", nClustersSPD));
   Info("FindClustersSPD", "found clusters in ITS SPD: %d", nClustersSPD);
+    // Fill the FastOr fired map
+  for (UInt_t eq=0; eq<20; eq++) {
+    for (UInt_t hs=0; hs<6; hs++) {
+      for (UInt_t chip=0; chip<10; chip++) {
+        if (input->GetFastOrSignal(eq,hs,chip)) {
+         fDetTypeRec->SetFastOrFiredMapOnline(eq,hs,chip);
+        }
+      }
+    }
+  }
+  
 }
-
-
-
+//__________________________________________________________________________
 void AliITSClusterFinderV2SPD::FindClustersSPD(TClonesArray *digits) {
   //------------------------------------------------------------
-  // Actual SPD cluster finder
+  // SPD cluster finder for digits (this method is called for each module)
+  // Now also fills the fast-or fired map
   //------------------------------------------------------------
 
 
@@ -325,19 +345,36 @@ void AliITSClusterFinderV2SPD::FindClustersSPD(TClonesArray *digits) {
   Int_t ndigits=digits->GetEntriesFast();
   AliBin *bins=new AliBin[kMAXBIN];
 
-  Int_t k;
-  AliITSdigitSPD *d=0;
-  for (k=0; k<ndigits; k++) {
-     d=(AliITSdigitSPD*)digits->UncheckedAt(k);
-     Int_t i=d->GetCoord2()+1;   //y
-     Int_t j=d->GetCoord1()+1;
-     Int_t index=i*kNzBins+j;
-     bins[index].SetIndex(k);
-     bins[index].SetMask(1);
+  Int_t idig;
+  AliITSdigitSPD *digit=0;
+  for (idig=0; idig<ndigits; idig++) {
+    digit=(AliITSdigitSPD*)digits->UncheckedAt(idig);
+    Int_t i=digit->GetCoord2()+1;   //y
+    Int_t j=digit->GetCoord1()+1;
+    Int_t index=i*kNzBins+j;
+
+    bins[index].SetIndex(idig);
+    bins[index].SetQ(1);
+    bins[index].SetMask(1);
   }
+
    
   Int_t nClustersSPD = ClustersSPD(bins,digits,0,kMAXBIN,kNzBins,fModule,kFALSE); 
   delete [] bins;
 
   AliDebug(1,Form("found clusters in ITS SPD: %d", nClustersSPD));
+  
+    //  Fill the FastOr fired map
+  AliITSFOSignalsSPD* foSignals = fDetTypeRec->GetFOSignals();
+  if (foSignals) {
+    UInt_t eq = AliITSRawStreamSPD::GetOnlineEqIdFromOffline(fModule);
+    UInt_t hs = AliITSRawStreamSPD::GetOnlineHSFromOffline(fModule);
+    for(UInt_t ch=0; ch<5; ch++) {
+      UInt_t chip = AliITSRawStreamSPD::GetOnlineChipFromOffline(fModule,ch*32);
+      if (foSignals->GetSignal(eq,hs,chip)) {
+       fDetTypeRec->SetFastOrFiredMapOnline(eq,hs,chip);
+      }
+    }
+  }
+  
 }
index 4eaae88e72543db6bc0527b501db0b8ed5b0389e..79e11cc8b9b305b77b8f2a7228038152f3d8df47 100644 (file)
@@ -37,6 +37,7 @@
 #include "AliBitPacking.h"
 #include "AliDAQ.h"
 #include "AliFstream.h"
+#include "AliITSFOSignalsSPD.h"
 
 ClassImp(AliITSDDLRawData)
 
@@ -260,7 +261,7 @@ void AliITSDDLRawData::GetDigitsSDD(TClonesArray *ITSdigits,Int_t mod,Int_t modR
             if value >=128value = value - (1 << 7) (word is 7 bit long)
 
          */
-         if(digarr[anode][tb]<4) continue; // not write <4 cnts above tL
+         //if(digarr[anode][tb]<4) continue; // not write <4 cnts above tL
          if(digarr[anode][tb]<8){
            bitinfo1[3] = 2;
            wordinfo1[2] = 2;
@@ -414,7 +415,7 @@ void AliITSDDLRawData::GetDigitsSDD(TClonesArray *ITSdigits,Int_t mod,Int_t modR
 //PIXEL 
 //
 
-void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod,Int_t ddl, UInt_t *buf){
+void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod,Int_t ddl, UInt_t *buf, AliITSFOSignalsSPD* foSignals){
   //This method packs the SPD digits in a proper 32 structure
   //Since data is zero suppressed,the coordinates for the chip having zero digits 
   //doesn't get listed in the galice.root file. However the SPD format requires 
@@ -424,25 +425,27 @@ void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod,Int_t ddl,
   Int_t chipHigh = AliITSRawStreamSPD::GetOnlineChipFromOffline(mod,159);
 
   if (chipLow>chipHigh) {chipLow  -= 4; chipHigh += 4;}
+  UInt_t eq = AliITSRawStreamSPD::GetOnlineEqIdFromOffline(mod);
   UInt_t hs = AliITSRawStreamSPD::GetOnlineHSFromOffline(mod);
 
   // create int map to later hold all digits sorted
   AliITSIntMap* digMap = new AliITSIntMap();
 
   UInt_t baseWord=0;
-  Int_t chipHitCount=0;  //Number of Hit in the current chip
-  Int_t previousChip=-1; //Previuos chip respect to the actual aone
   Int_t ndigits = ITSdigits->GetEntries(); //number of digits in the current module
   //cout<<"      Number of digits in the current module:"<<ndigits<<" module:"<<mod<<endl;
 
+  // _______________________________________________________________________
+  // Preprocess the digits - sort them in integer map (Henrik Tydesjo)
+  // Needed to have exact same order as in real raw data
   AliITSdigit *digs;
 ofstream ftxt;
-  if(ndigits){
+ ofstream ftxt;
+  if (ndigits) {
     //loop over digits
-    if (fVerbose==2)
-      ftxt.open("SPDdigits.txt",ios::app);
-    for (Int_t digit=0;digit<ndigits;digit++){
-      digs = (AliITSdigit*)ITSdigits->UncheckedAt(digit);
+    if (fVerbose==2) ftxt.open("SPDdigits.txt",ios::app);
+    for (Int_t digit=0; digit<ndigits; digit++) {
+      digs = (AliITSdigit*) ITSdigits->UncheckedAt(digit);
       /*---------------------------------------------------------------------------
        *     Each module contains 5 read out chips of 256 rows and 32 columns.
        *     So, the cell number in Z direction varies from 0 to 159.
@@ -450,9 +453,8 @@ void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod,Int_t ddl,
       Int_t iz=digs->GetCoord1();  // Cell number in Z direction 
       Int_t ix=digs->GetCoord2();  // Cell number in X direction
 
-      if(fVerbose==2)
-       ftxt<<"DDL:"<<ddl<<" Mod:"<<mod<<" Row:"<<ix<<" Col:"<<iz<<endl;
-      UInt_t dummyDDL,dummyHS,chip,col,row;
+      if(fVerbose==2) ftxt<<"DDL:"<<ddl<<" Mod:"<<mod<<" Row:"<<ix<<" Col:"<<iz<<endl;
+      UInt_t dummyDDL, dummyHS, chip, col, row;
       AliITSRawStreamSPD::OfflineToOnline(mod,iz,ix,dummyDDL,dummyHS,chip,col,row);
 
       //  insert digit into map...
@@ -461,60 +463,60 @@ void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod,Int_t ddl,
     }
   }
 
+   // _______________________________________________________________________
+  // Procedure for writing raw data (Henrik Tydesjo)
+  // Reimplemented because of unreadability (5 Mar 2009)
+  // Now also with fast-or signals
+  Int_t  previousChip = chipLow-1;
+  Int_t  chip         = chipLow-1;
+  UInt_t chipHitCount = 0;
+
+
   UInt_t nrHits = digMap->GetNrEntries();
-  if (nrHits>0) {
-    Int_t chip = 0;
-    for (UInt_t nHit=0; nHit<nrHits; nHit++) {
-      Int_t key = digMap->GetKeyIndex(nHit);
-      chip = key/(256*32);
-      Int_t col = 31 - (key%(256*32))/256;
-      Int_t row = digMap->GetValIndex(nHit);
-
-      if(previousChip==-1) { // first hit
-       //loop over chip without digits 
-       //Even if there aren't digits for a given chip 
-       //the chip header and the chip trailer are stored
-       for (Int_t i=chipLow; i<chip; i++) {
-         WriteChipHeader(i,hs,baseWord);
-         WriteChipTrailer(buf,0,baseWord);
-       }
-       WriteChipHeader(chip,hs,baseWord);
-       WriteHit(buf,row,col,baseWord);
-       chipHitCount++;
-       previousChip=chip;
-      }//end if
-      else{
-       if(previousChip!=(Int_t)chip) {
-         WriteChipTrailer(buf,chipHitCount,baseWord);
-         chipHitCount=0;
-         for(Int_t i=previousChip+1; i<chip; i++) {
-           WriteChipHeader(i,hs,baseWord);
-           WriteChipTrailer(buf,0,baseWord);
-         }//end for
-         WriteChipHeader(chip,hs,baseWord);
-         previousChip=chip;
-       }//end if
-       chipHitCount++;
-       WriteHit(buf,row,col,baseWord);
-      }//end else
-    }//end for
-    //Even if there aren't digits for a given chip 
-    //the chip header and the chip trailer are stored
-    WriteChipTrailer(buf,chipHitCount,baseWord);
-    chipHitCount=0;
-    for(Int_t i=chip+1;i<=chipHigh;i++){
-      WriteChipHeader(i,hs,baseWord);
-      WriteChipTrailer(buf,0,baseWord);
-    }//end for
-  }//end if
-  else{
-    //In this module there aren't digits but
-    //the chip header and chip trailer are stored anyway
-    for(Int_t i=chipLow; i<=chipHigh; i++){
-      WriteChipHeader(i,hs,baseWord);
-      WriteChipTrailer(buf,0,baseWord);
-    }//end for
-  }//end else 
+  for (UInt_t nHit=0; nHit<nrHits; nHit++) {
+
+    Int_t key  = digMap->GetKeyIndex(nHit);
+    chip = key/(256*32);
+    Int_t col  = 31 - (key%(256*32))/256;
+    Int_t row  = digMap->GetValIndex(nHit);
+
+    // add trailer for previous chip (if there was one...)
+    if (chip>previousChip && previousChip>chipLow-1) {
+      WriteChipTrailer(buf, chipHitCount, foSignals->GetSignal(eq,hs,previousChip), baseWord);
+    }
+
+    // add headers/trailers for chips without hits (if any)
+    for (Int_t ch=previousChip+1; ch<chip; ch++) {
+      WriteChipHeader(ch, hs, baseWord);
+      WriteChipTrailer(buf, 0, foSignals->GetSignal(eq,hs,ch), baseWord);
+    }
+
+    // if new chip, add header
+    if (chip>previousChip) {
+      WriteChipHeader(chip, hs, baseWord);
+      chipHitCount = 0;
+      previousChip = chip;
+    }
+
+    chipHitCount++;
+
+    // add pixel hit
+    WriteHit(buf,row,col,baseWord);
+
+  }
+
+  // add trailer for last chip (if there was one...)
+  if (chip>chipLow-1) {
+    WriteChipTrailer(buf, chipHitCount, foSignals->GetSignal(eq,hs,chip), baseWord);
+  }
+
+  // add REMAINING headers/trailers for chips without hits (if any)
+  for (Int_t ch=chip+1; ch<=chipHigh; ch++) {
+    WriteChipHeader(ch, hs, baseWord);
+    WriteChipTrailer(buf, 0, foSignals->GetSignal(eq,hs,ch), baseWord);
+  }
+  // _______________________________________________________________________
+
 
   delete digMap;
 
@@ -525,7 +527,7 @@ void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod,Int_t ddl,
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-Int_t AliITSDDLRawData::RawDataSPD(TBranch* branch){
+Int_t AliITSDDLRawData::RawDataSPD(TBranch* branch, AliITSFOSignalsSPD* foSignals){
   //This method creates the Raw data files for SPD detectors
   const Int_t kSize=21000; //256*32*5=40960 max number of digits per module
   UInt_t buf[kSize];      //One buffer cell can contain 2 digits 
@@ -550,7 +552,7 @@ Int_t AliITSDDLRawData::RawDataSPD(TBranch* branch){
       branch->GetEvent(moduleNumber);
       //For each Module, buf contains the array of data words in Binary format   
       //fIndex gives the number of 32 bits words in the buffer for each module
-      GetDigitsSPD(digits,moduleNumber,ddl,buf);
+      GetDigitsSPD(digits, moduleNumber, ddl, buf, foSignals);
       outfile->WriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t)));
       for(Int_t i=0;i<(fIndex+1);i++){
        buf[i]=0;
@@ -705,13 +707,15 @@ void AliITSDDLRawData::WriteChipHeader(Int_t ChipAddr,Int_t halfStave,UInt_t &Ba
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-void  AliITSDDLRawData::WriteChipTrailer(UInt_t *buf,Int_t ChipHitCount,UInt_t &BaseWord){
+void  AliITSDDLRawData::WriteChipTrailer(UInt_t *buf, Int_t ChipHitCount, Bool_t foBit, UInt_t &BaseWord){
   //This method writes a chip trailer
   //pixel fill word
   if((ChipHitCount%2)!=0){
     AliBitPacking::PackWord(0xC000,BaseWord,16,31);
   }
-  AliBitPacking::PackWord(ChipHitCount,BaseWord,0,13);
+  AliBitPacking::PackWord(ChipHitCount,BaseWord,0,11);
+  AliBitPacking::PackWord(0x0,BaseWord,12,12);
+  AliBitPacking::PackWord(foBit,BaseWord,13,13);
   AliBitPacking::PackWord(0x0,BaseWord,14,15);
   fIndex++;
   buf[fIndex]=BaseWord;
index 5f7cb979960d7d06758812afa377d4322d82623e..4caf0b4549fb29437a99a6e875999372e6bc6fd0 100644 (file)
@@ -13,6 +13,7 @@
 
 class TTree;
 class AliITSDDLModuleMapSDD;
+class AliITSFOSignalsSPD;
 
 class AliITSDDLRawData:public TObject{
  public:
@@ -20,7 +21,7 @@ class AliITSDDLRawData:public TObject{
   virtual ~AliITSDDLRawData(){;}//destructor
   AliITSDDLRawData(const AliITSDDLRawData &source); // copy constructor
   AliITSDDLRawData& operator=(const AliITSDDLRawData &source); // ass. op.
-  Int_t RawDataSPD(TBranch* branch);
+  Int_t RawDataSPD(TBranch* branch, AliITSFOSignalsSPD* foSignals = NULL);
   // This method generates the files with the Silicon pixel detector data
   Int_t RawDataSDD(TBranch* branch, AliITSDDLModuleMapSDD* ddlsdd); 
   // This method generates the files with the Silicon drift detector data
@@ -32,7 +33,7 @@ class AliITSDDLRawData:public TObject{
     fUseCompressedSDDFormat=opt;
   }
  private: 
-  void  GetDigitsSPD(TClonesArray *ITSdigits, Int_t mod,Int_t ddl,UInt_t *buf);
+  void  GetDigitsSPD(TClonesArray *ITSdigits, Int_t mod,Int_t ddl,UInt_t *buf, AliITSFOSignalsSPD* foSignals = NULL);
   //This method formats and stores in buf all the digits of a SPD module
   void  GetDigitsSDDCompressed(TClonesArray *ITSdigits, Int_t mod,UInt_t *buf);
   void  GetDigitsSDD(TClonesArray *ITSdigits, Int_t mod,Int_t modR,Int_t ddl,UInt_t *buf);
@@ -40,7 +41,7 @@ class AliITSDDLRawData:public TObject{
   void  GetDigitsSSD(TClonesArray *ITSdigits, Int_t mod,Int_t modR,Int_t ddl,UInt_t *buf);
   //This method formats and stores in buf all the digits of a SSD module
   void  WriteChipHeader(Int_t ChipAddr,Int_t halfStave,UInt_t &BaseWord);
-  void  WriteChipTrailer(UInt_t *buf,Int_t ChipHitCount,UInt_t &BaseWord);
+  void  WriteChipTrailer(UInt_t *buf, Int_t ChipHitCount, Bool_t foBit, UInt_t &BaseWord);
   void  WriteHit(UInt_t *buf,Int_t RowAddr,Int_t HitAddr,UInt_t &BaseWord);
   //The three previous  methods are used to store the data according to the 
   //Silicon pixel detector data format
index 0b46848ebf89d92169f0c7fe39edec5a4d3f49aa..ad459560b95828927c185e5faa4dd80931a7b8ad 100644 (file)
 #include "AliITSsegmentationSDD.h"
 #include "AliITSsegmentationSSD.h"
 #include "AliLog.h"
+#include "AliITSRawStreamSPD.h"
+#include "AliITSTriggerConditions.h"
+#include "AliITSFOSignalsSPD.h"
+#include "AliRunLoader.h"
+#include "AliDataLoader.h"
+#include "AliITSLoader.h"
 
 class AliITSDriftSpeedArraySDD;
 class AliITSMapSDD;
@@ -69,8 +75,9 @@ fSegmentation(0),
 fCalibration(0),
 fSSDCalibration(0),
 fSPDDead(0),
-fSPDFastOr(0),
+fTriggerConditions(0),
 fDigits(0),
+fFOSignals(0),
 fDDLMapSDD(0),
 fRespSDD(0),
 fAveGainSDD(0),
@@ -113,8 +120,9 @@ fSegmentation(rec.fSegmentation),
 fCalibration(rec.fCalibration),
 fSSDCalibration(rec.fSSDCalibration),
 fSPDDead(rec.fSPDDead),
-fSPDFastOr(rec.fSPDFastOr),
+fTriggerConditions(rec.fTriggerConditions),
 fDigits(rec.fDigits),
+fFOSignals(rec.fFOSignals),
 fDDLMapSDD(rec.fDDLMapSDD),
 fRespSDD(rec.fRespSDD),
 fAveGainSDD(rec.fAveGainSDD),
@@ -167,7 +175,14 @@ AliITSDetTypeRec::~AliITSDetTypeRec(){
       delete fSPDDead;
       fSPDDead = 0;
     }
-  }  
+  } 
+  if(fTriggerConditions){
+    if(!(AliCDBManager::Instance()->GetCacheFlag())) {
+      fTriggerConditions->Delete();
+      delete fTriggerConditions;
+      fTriggerConditions = 0;
+    }
+  } 
   if(fDigits){
     fDigits->Delete();
     delete fDigits;
@@ -283,36 +298,44 @@ AliITSCalibration* AliITSDetTypeRec::GetSPDDeadModel(Int_t iMod) const {
     AliWarning("fSPDDead is 0!");
     return 0; 
   }  
-
   return (AliITSCalibration*)fSPDDead->At(iMod);
 }
-
+//_______________________________________________________________________
+AliITSTriggerConditions* AliITSDetTypeRec::GetTriggerConditions() const {
+  //Get Pixel Trigger Conditions
+  if (fTriggerConditions==0) {
+    AliWarning("fTriggerConditions is 0!");
+  }
+  return fTriggerConditions;
+}
 //______________________________________________________________________
 void AliITSDetTypeRec::SetTreeAddressD(TTree* const treeD){
     // Set branch address for the tree of digits.
 
-    const char *det[4] = {"SPD","SDD","SSD","ITS"};
-    TBranch *branch;
-    const Char_t* digclass;
-    Int_t i;
-    char branchname[30];
-
-    if(!treeD) return;
-    if (fDigits == 0x0) fDigits = new TObjArray(fgkNdettypes);
-    for (i=0; i<fgkNdettypes; i++) {
-        digclass = GetDigitClassName(i);
-       if(!(fDigits->At(i))) {
-            fDigits->AddAt(new TClonesArray(digclass,1000),i);
-        }else{
-            ResetDigits(i);
-        } 
-        if (fgkNdettypes==3) sprintf(branchname,"%sDigits%s",det[3],det[i]);
-        else  sprintf(branchname,"%sDigits%d",det[3],i+1);
-        if (fDigits) {
-            branch = treeD->GetBranch(branchname);
-            if (branch) branch->SetAddress(&((*fDigits)[i]));
-        } 
+  const char *det[4] = {"SPD","SDD","SSD","ITS"};
+  TBranch *branch;
+  const Char_t* digclass;
+  Int_t i;
+  char branchname[30];
+
+  if(!treeD) return;
+  if (fDigits == 0x0) fDigits = new TObjArray(fgkNdettypes);
+  for (i=0; i<fgkNdettypes; i++) {
+    digclass = GetDigitClassName(i);
+    if(!(fDigits->At(i))) {
+      fDigits->AddAt(new TClonesArray(digclass,1000),i);
+    }
+    else{
+      ResetDigits(i);
     } 
+    if (fgkNdettypes==3) sprintf(branchname,"%sDigits%s",det[3],det[i]);
+    else  sprintf(branchname,"%sDigits%d",det[3],i+1);
+    if (fDigits) {
+      branch = treeD->GetBranch(branchname);
+      if (branch) branch->SetAddress(&((*fDigits)[i]));
+    }
+  } 
+
 }
 
 //_______________________________________________________________________
@@ -422,46 +445,47 @@ Bool_t AliITSDetTypeRec::GetCalibrationSPD(Bool_t cacheStatus) {
   // Get SPD calibration objects from OCDB
   // dead pixel are not used for local reconstruction
 
-  AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy");
+  AliCDBEntry *noisySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy");
   AliCDBEntry *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead");
-  AliCDBEntry *fastOrSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDFastOr");
-  if(!entrySPD || !deadSPD || !fastOrSPD ){
+  AliCDBEntry *pitCond = AliCDBManager::Instance()->Get("ITS/Calib/PITConditions");
+  if(!noisySPD || !deadSPD || !pitCond ){
     AliFatal("SPD Calibration object retrieval failed! ");
     return kFALSE;
-  }    
+  }
 
-  TObjArray *calSPD = (TObjArray *)entrySPD->GetObject();
-  if(!cacheStatus)entrySPD->SetObject(NULL);
-  entrySPD->SetOwner(kTRUE);
+  TObjArray *calNoisySPD = (TObjArray*) noisySPD->GetObject();
+  if (!cacheStatus) noisySPD->SetObject(NULL);
+  noisySPD->SetOwner(kTRUE);
  
-  TObjArray *caldeadSPD = (TObjArray *)deadSPD->GetObject();
-  if(!cacheStatus)deadSPD->SetObject(NULL);
+  TObjArray *calDeadSPD = (TObjArray*) deadSPD->GetObject();
+  if (!cacheStatus) deadSPD->SetObject(NULL);
   deadSPD->SetOwner(kTRUE);
 
-  AliITSFastOrCalibrationSPD *calfastOrSPD = (AliITSFastOrCalibrationSPD *)fastOrSPD->GetObject();
-  if(!cacheStatus)fastOrSPD->SetObject(NULL);
-  fastOrSPD->SetOwner(kTRUE);
+  AliITSTriggerConditions *calPitCond = (AliITSTriggerConditions*) pitCond->GetObject();
+  if (!cacheStatus) pitCond->SetObject(NULL);
+  pitCond->SetOwner(kTRUE);
 
   if(!cacheStatus){
-    delete entrySPD;
+    delete noisySPD;
     delete deadSPD;
-    delete fastOrSPD;
+    delete pitCond;
   }
-  if ((!calSPD) || (!caldeadSPD) || (!calfastOrSPD)){ 
+  if ((!calNoisySPD) || (!calDeadSPD) || (!calPitCond)){ 
     AliWarning("Can not get SPD calibration from calibration database !");
     return kFALSE;
   }
 
-  fNMod[0] = calSPD->GetEntries();
+  fNMod[0] = calNoisySPD->GetEntries();
 
   AliITSCalibration* cal;
   for (Int_t i=0; i<fNMod[0]; i++) {
-    cal = (AliITSCalibration*) calSPD->At(i);
+    cal = (AliITSCalibration*) calNoisySPD->At(i);
     SetCalibrationModel(i, cal);
-    cal = (AliITSCalibration*) caldeadSPD->At(i);
+    cal = (AliITSCalibration*) calDeadSPD->At(i);
     SetSPDDeadModel(i, cal);
   }
-  fSPDFastOr = calfastOrSPD;
+  fTriggerConditions = calPitCond;
 
   return kTRUE;
 }
@@ -756,24 +780,24 @@ void AliITSDetTypeRec::SetTreeAddressR(TTree* const treeR){
     //      none.
     // Return:
 
-    char branchname[30];
-    Char_t namedet[10]="ITS";
+   char branchname[30];
+   Char_t namedet[10]="ITS";
 
-    if(!treeR) return;
-    if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
-    TBranch *branch;
-    sprintf(branchname,"%sRecPoints",namedet);
-    branch = treeR->GetBranch(branchname);
-    if (branch) {
+   if(!treeR) return;
+   if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
+   TBranch *branch;
+   sprintf(branchname,"%sRecPoints",namedet);
+   branch = treeR->GetBranch(branchname);
+   if (branch) {
       branch->SetAddress(&fRecPoints);
-    }else {
+    } 
+    else {
       sprintf(branchname,"%sRecPointsF",namedet);
       branch = treeR->GetBranch(branchname);
       if (branch) {
        branch->SetAddress(&fRecPoints);
       }
-
-    }
+   }
 }
 //____________________________________________________________________
 void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){
@@ -816,6 +840,30 @@ void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastent
     AliInfo("Cluster Finder Option not implemented, V2 cluster finder will be used \n");    
   }
 
+  
+  // Reset Fast-OR fired map
+  ResetFastOrFiredMap();
+
+  if (all || det[0]) { // SPD present
+    // Get the FO signals for this event
+    AliRunLoader* runLoader = AliRunLoader::Instance();
+    AliITSLoader* itsLoader = (AliITSLoader*) runLoader->GetLoader("ITSLoader");
+    if (!itsLoader) {
+      AliError("ITS loader is NULL.");
+    }
+    else {
+      AliBaseLoader* foLoader = itsLoader->GetFOSignalsLoader();
+      if (!foLoader) {
+       AliError("FO signals base loader not retrieved.");
+      }
+      else {
+       foLoader->Load();
+       fFOSignals = (AliITSFOSignalsSPD*) foLoader->Get();
+      }
+    }
+  }
+
+  
   AliITSClusterFinder *rec     = 0;
   Int_t id,module,first=0;
   for(module=0;module<GetITSgeom()->GetIndexMax();module++){
@@ -829,19 +877,25 @@ void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastent
       ResetDigits();  // MvL: Not sure we neeed this when rereading anyways
       if (all) {
           treeD->GetEvent(lastentry+module);
-      }else {
-          treeD->GetEvent(lastentry+(module-first));
-      }
-      Int_t ndigits = itsDigits->GetEntriesFast();
-      if(ndigits>0){
-       rec->SetDetTypeRec(this);
-       rec->SetDigits(DigitsAddress(id));
-       //      rec->SetClusters(ClustersAddress(id));
-       rec->FindRawClusters(module);
-      } // end if
-      treeR->Fill();
-      ResetRecPoints();
-  } 
+        }
+    else {
+      treeD->GetEvent(lastentry+(module-first));
+    }
+    Int_t ndigits = itsDigits->GetEntriesFast();
+    if (ndigits>0 || id==0) { // for SPD we always want to call FindRawClusters (to process FO signals)
+      rec->SetDetTypeRec(this);
+      rec->SetDigits(DigitsAddress(id));
+      //       rec->SetClusters(ClustersAddress(id));
+      rec->FindRawClusters(module);
+    } // end if
+    treeR->Fill();
+    ResetRecPoints();
+  }
+  
+   // Remove PIT in-active chips from Fast-OR fired map
+  if (all || det[0]) { // SPD present
+    RemoveFastOrFiredInActive();
+  }
 }
 //______________________________________________________________________
 void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Option_t *opt){
@@ -859,6 +913,10 @@ void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Op
   const char *all = strstr(opt,"All");
   const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
                         strstr(opt,"SSD")};
+  
+  // Reset Fast-OR fired map
+  ResetFastOrFiredMap();
+  
   AliITSClusterFinder *rec     = 0;
   Int_t id=0;
 
@@ -903,6 +961,10 @@ void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Op
   Info("DigitsToRecPoints", "total number of found recpoints in ITS: %d\n", 
        nClusters);
   
+  // Remove PIT in-active chips from Fast-OR fired map
+  if (all || det[0]) { // SPD present
+    RemoveFastOrFiredInActive();
+  }  
 }
 
 //______________________________________________________________________
@@ -976,5 +1038,26 @@ void AliITSDetTypeRec::ReadOldSSDGain(const TObjArray *array,
                        arrayNSide.At(iNCounter));
   }//loop over modules 
 }
+//______________________________________________________________________
+void AliITSDetTypeRec::RemoveFastOrFiredInActive() {
+  // Removes the chips that were in-active in the pixel trigger (from fast-or fired map)
+  if (fTriggerConditions==NULL) {
+    AliError("Pixel trigger conditions are missing.");
+    return;
+  }
+  Int_t eq   = -1;
+  Int_t hs   = -1;
+  Int_t chip = -1;
+  while (fTriggerConditions->GetNextInActiveChip(eq,hs,chip)) {
+    UInt_t chipKey = AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(eq,hs,chip);
+    fFastOrFiredMap.SetBitNumber(chipKey,kFALSE);
+  }
+}
+//______________________________________________________________________
+void AliITSDetTypeRec::SetFastOrFiredMapOnline(UInt_t eq, UInt_t hs, UInt_t chip) {
+  // Set fast-or fired map for this chip
+  Int_t chipKey = AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(eq,hs,chip);
+  return SetFastOrFiredMap(chipKey);
+}
 
 
index 7503ceed15138c97631233918b560bceb09a9088..d7e0380116e0e32d6c94e0b2eb979e193e188eac 100644 (file)
@@ -22,7 +22,6 @@ class AliITSgeom;
 class AliITSsegmentation;
 class AliITSCalibration;
 class AliITSCalibrationSSD;
-class AliITSFastOrCalibrationSPD;
 class AliITSresponseSDD;
 class AliITSClusterFinder;
 class AliITSRecPoint;
@@ -31,6 +30,8 @@ class AliITSGainSSDv2;
 class AliITSBadChannelsSSDv2;
 class AliITSDDLModuleMapSDD;
 class AliITSNoiseSSDv2;
+class AliITSTriggerConditions;
+class AliITSFOSignalsSPD;
 
 class AliITSDetTypeRec : public TObject {
   public:
@@ -53,10 +54,10 @@ class AliITSDetTypeRec : public TObject {
     virtual Bool_t GetCalibrationSPD(Bool_t cacheStatus);
     virtual Bool_t GetCalibrationSDD(Bool_t cacheStatus);
     virtual Bool_t GetCalibrationSSD(Bool_t cacheStatus);
-    virtual AliITSFastOrCalibrationSPD* GetFastOrCalibrationSPD() const { return fSPDFastOr;}
     virtual AliITSsegmentation* GetSegmentationModel(Int_t dettype) const;
     virtual AliITSCalibration* GetCalibrationModel(Int_t iMod) const;
     virtual AliITSCalibration* GetSPDDeadModel(Int_t iMod) const;
+    virtual AliITSTriggerConditions* GetTriggerConditions() const;
     virtual AliITSClusterFinder* GetReconstructionModel(Int_t dettype) const;
     virtual AliITSDDLModuleMapSDD* GetDDLModuleMapSDD() const { return fDDLMapSDD;}
     virtual AliITSresponseSDD* GetResponseSDD() const { return fRespSDD;}
@@ -78,6 +79,8 @@ class AliITSDetTypeRec : public TObject {
     TObjArray* GetDigits() const {return fDigits;} 
     TClonesArray *DigitsAddress(Int_t id) const {return ((TClonesArray*)(*fDigits)[id]);}
 
+        AliITSFOSignalsSPD* GetFOSignals() const {return fFOSignals;}
+    
     TBranch* MakeBranchInTree(TTree* const tree, const char* name, const char *classname, void* address,Int_t size, Int_t splitlevel);
 
     virtual void ResetDigits();
@@ -93,10 +96,12 @@ class AliITSDetTypeRec : public TObject {
     void DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastEntry,Option_t *det, Int_t optCluFind=0);
     void DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Option_t *det="All");
 
+    void   SetFastOrFiredMapOnline(UInt_t eq, UInt_t hs, UInt_t chip);
     void   SetFastOrFiredMap(UInt_t chipKey){fFastOrFiredMap.SetBitNumber(chipKey);} 
     TBits  GetFastOrFiredMap() const {return fFastOrFiredMap;}
     void   ResetFastOrFiredMap(){fFastOrFiredMap.ResetAllBits();}
-
+    void   RemoveFastOrFiredInActive(); // (using Trigger Conditions)
+   
   private:
     // private methods
     AliITSDetTypeRec(const AliITSDetTypeRec& rec);
@@ -124,8 +129,9 @@ class AliITSDetTypeRec : public TObject {
     TObjArray    *fCalibration;   //! [NMod]
     AliITSCalibrationSSD* fSSDCalibration;  //! SSD calibration object
     TObjArray    *fSPDDead;       //! [fgkDefaultNModulesSPD]
-    AliITSFastOrCalibrationSPD *fSPDFastOr; // Map of FastOr configured chips
+    AliITSTriggerConditions *fTriggerConditions; //! PIT conditions object
     TObjArray    *fDigits;        //! [NMod][NDigits]
+    AliITSFOSignalsSPD *fFOSignals; //! Fast-Or signals (used when reconstructing from digits)
     AliITSDDLModuleMapSDD *fDDLMapSDD; //! mapping DDL/module -> SDD module number
     AliITSresponseSDD *fRespSDD;  //! SDD response parameters 
     Float_t       fAveGainSDD;    //! Average gain of SDD good anodes
@@ -139,9 +145,9 @@ class AliITSDetTypeRec : public TObject {
     Bool_t fFirstcall;         //! flag
     Bool_t fLoadOnlySPDCalib;  //! flag for loading calibrations only fr SPD
 
-    TBits fFastOrFiredMap;     // Map of FastOr fired chips
+    TBits fFastOrFiredMap;     //! Map of FastOr fired chips (after processing of raw signals)
 
-    ClassDef(AliITSDetTypeRec,17) // ITS Reconstruction structure
+    ClassDef(AliITSDetTypeRec,18) // ITS Reconstruction structure
 };
 
 #endif
index abeca192b5d3f98d1039d176d12168a1e98b3536..daf293bc3cdb0262513b39c669b983065a836af6 100644 (file)
@@ -64,6 +64,8 @@
 #include "AliITSsimulationSDD.h"
 #include "AliITSsimulationSSD.h"
 #include "AliITSDDLModuleMapSDD.h"
+#include "AliITSTriggerConditions.h"
+#include "AliBaseLoader.h"
 
 const Int_t AliITSDetTypeSim::fgkNdettypes = 3;
 const Int_t AliITSDetTypeSim::fgkDefaultNModulesSPD =  240;
@@ -79,6 +81,7 @@ fSimulation(),   // [NDet]
 fSegmentation(), // [NDet]
 fCalibration(),     // [NMod]
 fSSDCalibration(0),
+fSPDNoisy(0),
 fNSDigits(0),    //! number of SDigits
 fSDigits("AliITSpListItem",1000),   
 fNDigits(0),     //! number of Digits
@@ -89,7 +92,10 @@ fDDLMapSDD(0),
 fkDigClassName(), // String with digit class name.
 fLoader(0),      // local pointer to loader
 fFirstcall(kTRUE),
-fIsHLTmodeC(0){ // flag
+fIsHLTmodeC(0), // flag
+fFOGenerator(),
+fTriggerConditions(NULL)
+{ 
     // Default Constructor
     // Inputs:
     //    none.
@@ -138,6 +144,13 @@ AliITSDetTypeSim::~AliITSDetTypeSim(){
     }
     fCalibration = 0;
     if(fSSDCalibration) delete fSSDCalibration;
+    if(fSPDNoisy){
+    if(!(AliCDBManager::Instance()->GetCacheFlag())) {
+       fSPDNoisy->Delete();
+       delete fSPDNoisy;
+       fSPDNoisy = 0;
+      }
+    }
     if(fSimuPar) delete fSimuPar;
     if(fDDLMapSDD) delete fDDLMapSDD;
     if(fNDigits) delete [] fNDigits;
@@ -157,6 +170,7 @@ fSimulation(source.fSimulation),   // [NDet]
 fSegmentation(source.fSegmentation), // [NDet]
 fCalibration(source.fCalibration),     // [NMod]
 fSSDCalibration(source.fSSDCalibration),
+fSPDNoisy(source.fSPDNoisy),
 fNSDigits(source.fNSDigits),    //! number of SDigits
 fSDigits(*((TClonesArray*)source.fSDigits.Clone())),
 fNDigits(source.fNDigits),     //! number of Digits
@@ -167,7 +181,9 @@ fDDLMapSDD(source.fDDLMapSDD),
 fkDigClassName(), // String with digit class name.
 fLoader(source.fLoader),      // local pointer to loader
 fFirstcall(source.fFirstcall),
-fIsHLTmodeC(source.fIsHLTmodeC)
+fIsHLTmodeC(source.fIsHLTmodeC),
+fFOGenerator(source.fFOGenerator),
+fTriggerConditions(source.fTriggerConditions) 
 {
     // Copy Constructor for object AliITSDetTypeSim not allowed
   for(Int_t i=0;i<fgkNdettypes;i++){
@@ -329,6 +345,19 @@ void AliITSDetTypeSim::SetCalibrationModel(Int_t iMod, AliITSCalibration *resp){
        delete (AliITSCalibration*) fCalibration->At(iMod);
     fCalibration->AddAt(resp, iMod);
 }
+//_______________________________________________________________________
+void AliITSDetTypeSim::SetSPDNoisyModel(Int_t iMod, AliITSCalibration *cal){
+  //Set noisy pixel info for the SPD module iMod
+  if (fSPDNoisy==0) {
+    fSPDNoisy = new TObjArray(fgkDefaultNModulesSPD);
+    fSPDNoisy->SetOwner(kTRUE);
+    fSPDNoisy->Clear();
+  }
+
+  if (fSPDNoisy->At(iMod) != 0)
+    delete (AliITSCalibration*) fSPDNoisy->At(iMod);
+  fSPDNoisy->AddAt(cal,iMod);
+}
 //______________________________________________________________________
 void AliITSDetTypeSim::ResetCalibrationArray(){
     //resets response array
@@ -369,6 +398,15 @@ AliITSCalibration* AliITSDetTypeSim::GetCalibrationModel(Int_t iMod) const {
 
 }
 //_______________________________________________________________________
+AliITSCalibration* AliITSDetTypeSim::GetSPDNoisyModel(Int_t iMod) const {
+  //Get SPD noisy calib for module iMod 
+  if(fSPDNoisy==0) {
+    AliWarning("fSPDNoisy is 0!");
+    return 0; 
+  }
+  return (AliITSCalibration*)fSPDNoisy->At(iMod);
+}
+//_______________________________________________________________________
 void AliITSDetTypeSim::SetDefaults(){
     //Set defaults for segmentation and response
 
@@ -418,7 +456,10 @@ Bool_t AliITSDetTypeSim::GetCalibration() {
 
   AliCDBManager::Instance()->SetCacheFlag(isCacheActive);
 
-  AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead", run);
+  AliCDBEntry *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead", run);
+  AliCDBEntry *noisySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy", run);
+  AliCDBEntry *foEffSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDFOEfficiency", run);
+  AliCDBEntry *foNoiSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDFONoise", run);
   AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD", run);
   AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD",run);
   AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD",run);
@@ -430,17 +471,29 @@ Bool_t AliITSDetTypeSim::GetCalibration() {
   AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD");
   AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD");
 
-  if(!entrySPD || !entrySDD || !entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD || 
-      !drSpSDD || !ddlMapSDD || !hltforSDD || !mapTSDD){
+if(!deadSPD || !noisySPD || !foEffSPD || !foNoiSPD 
+     || !entrySDD || !entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD 
+     || !drSpSDD || !ddlMapSDD || !hltforSDD || !mapTSDD){
     AliFatal("Calibration object retrieval failed! ");
     return kFALSE;
-  }    
+  }            
        
 
-  TObjArray *calSPD = (TObjArray *)entrySPD->GetObject();
-  if(!isCacheActive)entrySPD->SetObject(NULL);
-  entrySPD->SetOwner(kTRUE);
+  TObjArray *calDeadSPD = (TObjArray*) deadSPD->GetObject();
+  if (!isCacheActive) deadSPD->SetObject(NULL);
+  deadSPD->SetOwner(kTRUE);
 
+  TObjArray *calNoisySPD = (TObjArray*) noisySPD->GetObject();
+  if (!isCacheActive) noisySPD->SetObject(NULL);
+  noisySPD->SetOwner(kTRUE);
+
+  AliITSFOEfficiencySPD *calFoEffSPD = (AliITSFOEfficiencySPD*) foEffSPD->GetObject();
+  if (!isCacheActive) foEffSPD->SetObject(NULL);
+  foEffSPD->SetOwner(kTRUE);
+
+  AliITSFONoiseSPD *calFoNoiSPD = (AliITSFONoiseSPD*) foNoiSPD->GetObject();
+  if (!isCacheActive) foNoiSPD->SetObject(NULL);
+  foNoiSPD->SetOwner(kTRUE);
    
   TObjArray *calSDD = (TObjArray *)entrySDD->GetObject();
   if(!isCacheActive)entrySDD->SetObject(NULL);
@@ -524,7 +577,10 @@ Bool_t AliITSDetTypeSim::GetCalibration() {
 
   // DB entries are deleted. In this way metadeta objects are deleted as well
   if(!isCacheActive){
-    delete entrySPD;
+    delete deadSPD;
+    delete noisySPD;
+    delete foEffSPD;
+    delete foNoiSPD;
     delete entrySDD;
     delete entryNoiseSSD;
     delete entryGainSSD;
@@ -538,23 +594,30 @@ Bool_t AliITSDetTypeSim::GetCalibration() {
   
   AliCDBManager::Instance()->SetCacheFlag(origCacheStatus);
 
-  if ((!calSPD) || (!calSDD) || (!drSp) || (!ddlsdd)
-      || (!hltsdd) || (!mapT) || (!noiseSSD)|| (!gainSSD)|| (!badChannelsSSD)) {
+ if ((!calDeadSPD) || (!calNoisySPD) || (!calFoEffSPD) || (!calFoNoiSPD) 
+      || (!calSDD) || (!drSp) || (!ddlsdd) || (!hltsdd) 
+      || (!mapT) || (!noiseSSD)|| (!gainSSD)|| (!badChannelsSSD)) {
     AliWarning("Can not get calibration from calibration database !");
     return kFALSE;
   }
 
-  fNMod[0] = calSPD->GetEntries();
+
+  fNMod[0] = calDeadSPD->GetEntries();
   fNMod[1] = calSDD->GetEntries();
   //  fNMod[2] = noiseSSD->GetEntries();
   AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database",
               fNMod[0], fNMod[1], fNMod[2]));
   AliITSCalibration* cal;
   for (Int_t i=0; i<fNMod[0]; i++) {
-    cal = (AliITSCalibration*) calSPD->At(i);
+    cal = (AliITSCalibration*) calDeadSPD->At(i);
     SetCalibrationModel(i, cal);
+    cal = (AliITSCalibration*) calNoisySPD->At(i);
+    SetSPDNoisyModel(i, cal);
   }
 
+  fFOGenerator.SetEfficiency(calFoEffSPD); // this cal object is used only by the generator
+  fFOGenerator.SetNoise(calFoNoiSPD); // this cal object is used only by the generator
+  
   fDDLMapSDD->SetDDLMap(ddlsdd);
   fIsHLTmodeC=hltsdd->IsHLTmodeC();
 
@@ -894,4 +957,60 @@ void AliITSDetTypeSim::ReadOldSSDGain(const TObjArray *array,
                        arrayNSide.At(iNCounter));
   }//loop over modules 
 }
+//______________________________________________________________________
+void AliITSDetTypeSim::ProcessSPDDigitForFastOr(UInt_t module, UInt_t colM, UInt_t rowM) {
+  // Processes wether a single fired pixel will give rise to a fast-or signal
+  fFOGenerator.ProcessPixelHitM(module,colM,rowM);
+}
+//_______________________________________________________________________
+AliITSTriggerConditions* AliITSDetTypeSim::GetTriggerConditions() {
+  // Get Pixel Trigger Conditions (separate method since it is used only when simulating trigger)
+  if (fTriggerConditions==NULL) { // read from db
+    fRunNumber = ((Int_t)AliCDBManager::Instance()->GetRun());
+    Bool_t origCacheStatus = AliCDBManager::Instance()->GetCacheFlag();
+    Bool_t isCacheActive;
+    if (fRunNumber<0) isCacheActive=kFALSE;
+    else              isCacheActive=kTRUE;
+    AliCDBManager::Instance()->SetCacheFlag(isCacheActive);
+    AliCDBEntry *pitCond = AliCDBManager::Instance()->Get("ITS/Calib/PITConditions", fRunNumber);
+    if (!pitCond) {
+      AliError("Trigger conditions retrieval failed! ");
+      return NULL;
+    }
+    fTriggerConditions = (AliITSTriggerConditions*) pitCond->GetObject();
+    if (!isCacheActive) pitCond->SetObject(NULL);
+    pitCond->SetOwner(kTRUE);
+    if (!isCacheActive) {
+      delete pitCond;
+    }
+    AliCDBManager::Instance()->SetCacheFlag(origCacheStatus);
+    if (fTriggerConditions==NULL) {
+      AliWarning("fTriggerConditions is NULL!");
+    }
+  }
+  return fTriggerConditions;
+}
+//_______________________________________________________________________
+void AliITSDetTypeSim::WriteFOSignals() {
+  // write fo signals to event
+
+  if (!fLoader) {
+    AliError("ITS loader is NULL.");
+    return;
+  }
+
+  AliBaseLoader* foLoader = fLoader->GetFOSignalsLoader();
+  if (!foLoader) {
+    AliError("Base loader (FO) not retrieved.");
+    return;
+  }
+  
+  // make a new fo signals object - to have the loader own and delete as it wants later
+  AliITSFOSignalsSPD *foSignals = new AliITSFOSignalsSPD(*GetFOSignals());
+
+  foLoader->Post(foSignals);
+
+  foLoader->WriteData();
+
+}
 
index d007ceefed773eb22e456cc6caa383a2246550f5..cf57a31a6f86b959b3265c4f83536d1259ddccf0 100644 (file)
@@ -15,6 +15,7 @@ $Id$
 #include <TObject.h>
 #include "AliITSLoader.h"
 #include "AliITSSimuParam.h"
+#include "AliITSFOGeneratorSPD.h"
 
 class TObjArray;
 class TClonesArray;
@@ -33,6 +34,8 @@ class AliITSNoiseSSDv2;
 class AliITSDDLModuleMapSDD;
 class AliITSCalibration;
 class AliITSgeom;
+class AliITSFOSignalsSPD;
+class AliITSTriggerConditions;
 
 class AliITSDetTypeSim : public TObject {
  public:
@@ -55,7 +58,11 @@ class AliITSDetTypeSim : public TObject {
     virtual AliITSsegmentation* GetSegmentationModelByModule(Int_t module) const;
 
     virtual void SetCalibrationModel(Int_t iMod,AliITSCalibration *resp);
+   virtual void SetSPDNoisyModel(Int_t iMod, AliITSCalibration *cal);
+
     virtual AliITSCalibration* GetCalibrationModel(Int_t iMod) const;
+    virtual AliITSCalibration* GetSPDNoisyModel(Int_t iMod) const;
+    virtual AliITSTriggerConditions* GetTriggerConditions();
 
     virtual void SetSimuParam(const AliITSSimuParam* spar){
       if(fSimuPar) delete fSimuPar;
@@ -100,6 +107,13 @@ class AliITSDetTypeSim : public TObject {
        fkDigClassName[i]=name;}
     const Char_t* GetDigitClassName(Int_t i) const {return fkDigClassName[i];}
 
+    virtual void ResetFOSignals() {fFOGenerator.ResetSignals();}
+    virtual void ProcessSPDDigitForFastOr(UInt_t module, UInt_t colM, UInt_t rowM);
+    virtual void ProcessNoiseForFastOr() {fFOGenerator.ProcessNoise();}
+    virtual AliITSFOSignalsSPD* GetFOSignals() {return fFOGenerator.GetFOSignals();}
+    virtual void WriteFOSignals();
+
+
  protected:
     virtual void CreateCalibrationArray(); 
     virtual Bool_t GetCalibration();
@@ -125,6 +139,7 @@ class AliITSDetTypeSim : public TObject {
     TObjArray    *fSegmentation; //! [NDet]
     TObjArray    *fCalibration;  //! [NMod]
     AliITSCalibrationSSD* fSSDCalibration;  //! SSD calibration object
+    TObjArray    *fSPDNoisy;     //! [fgkDefaultNModulesSPD]
     Int_t         fNSDigits;     //! number of SDigits
     TClonesArray  fSDigits;      //! Summable digits
     Int_t*        fNDigits;      //! [NDet] number of Digits for det.
@@ -136,8 +151,10 @@ class AliITSDetTypeSim : public TObject {
     AliITSLoader* fLoader;          //! loader  
     Bool_t        fFirstcall;       //! flag
     Bool_t        fIsHLTmodeC;    //! flag for HLT mode C status (used by SDD)
-    
-    ClassDef(AliITSDetTypeSim,9) // ITS Simulation structure
+    AliITSFOGeneratorSPD fFOGenerator; //! Fast-OR generator object
+    AliITSTriggerConditions* fTriggerConditions; //! Trigger conditions 
+       
+    ClassDef(AliITSDetTypeSim,10) // ITS Simulation structure
  
 };
 
diff --git a/ITS/AliITSFOEfficiencySPD.cxx b/ITS/AliITSFOEfficiencySPD.cxx
new file mode 100644 (file)
index 0000000..d291649
--- /dev/null
@@ -0,0 +1,96 @@
+/////////////////////////////////////////////////////////////////////
+// Author: Henrik Tydesjo                                          //
+//                                                                 //
+// This class is used to store Fast-OR efficiency values in OCDB.  //
+// One value per pixel chip in this base class (if per column      //
+// accuracy is needed, use AliITSFOEfficiencySPDColumn class).     //
+// The values are the probability that a pixel hit will generate a //
+// fast-OR signal.                                                 //
+//                                                                 //
+/////////////////////////////////////////////////////////////////////
+
+#include "AliITSFOEfficiencySPD.h"
+
+AliITSFOEfficiencySPD::AliITSFOEfficiencySPD() :
+  TObject()
+{
+  // default constructor, puts all efficiency values to 100%
+  ResetValues();
+}
+//______________________________________________________________________
+AliITSFOEfficiencySPD::AliITSFOEfficiencySPD(const AliITSFOEfficiencySPD& foEff) :
+  TObject() 
+{  
+  // copy constructor, copy the array values from input object
+  for (UInt_t eq=0; eq<20; eq++) {
+    for (UInt_t hs=0; hs<6; hs++) {
+      for (UInt_t chip=0; chip<10; chip++) {
+       fChipEfficiency[eq][hs][chip] = foEff.fChipEfficiency[eq][hs][chip];
+      }
+    }
+  }
+}
+//______________________________________________________________________
+AliITSFOEfficiencySPD::~AliITSFOEfficiencySPD() {}
+//______________________________________________________________________
+void AliITSFOEfficiencySPD::ResetValues() {
+  // Set all efficiency values to 100%
+  for (UInt_t eq=0; eq<20; eq++) {
+    for (UInt_t hs=0; hs<6; hs++) {
+      for (UInt_t chip=0; chip<10; chip++) {
+       fChipEfficiency[eq][hs][chip] = 1;
+      }
+    }
+  }
+}
+//______________________________________________________________________
+AliITSFOEfficiencySPD& AliITSFOEfficiencySPD::operator=(const AliITSFOEfficiencySPD& foEff) {
+  // assignment operator
+  if (this!=&foEff) {
+    for (UInt_t eq=0; eq<20; eq++) {
+      for (UInt_t hs=0; hs<6; hs++) {
+       for (UInt_t chip=0; chip<10; chip++) {
+         fChipEfficiency[eq][hs][chip] = foEff.fChipEfficiency[eq][hs][chip];
+       }
+      }
+    }
+  }
+  return *this;
+}
+//______________________________________________________________________
+void AliITSFOEfficiencySPD::SetChipEfficiency(UInt_t eq, UInt_t hs, UInt_t chip, Float_t value) {
+  // set a chip efficiency value
+  if (eq>=20) {
+    Error("AliITSFOEfficiencySPD::SetChipEfficiency", "eq (%d) out of bounds.",eq);
+    return;
+  }
+  if (hs>=6) {
+    Error("AliITSFOEfficiencySPD::SetChipEfficiency", "hs (%d) out of bounds.",hs);
+    return;
+  }
+  if (chip>=10) {
+    Error("AliITSFOEfficiencySPD::SetChipEfficiency", "chip (%d) out of bounds.",chip);
+    return;
+  }
+  
+  fChipEfficiency[eq][hs][chip] = value;
+}
+//______________________________________________________________________
+Float_t AliITSFOEfficiencySPD::GetChipEfficiency(UInt_t eq, UInt_t hs, UInt_t chip) const {
+  // get a chip efficiency value
+  if (eq>=20) {
+    Error("AliITSFOEfficiencySPD::GetChipEfficiency", "eq (%d) out of bounds.",eq);
+    return 0;
+  }
+  if (hs>=6) {
+    Error("AliITSFOEfficiencySPD::GetChipEfficiency", "hs (%d) out of bounds.",hs);
+    return 0;
+  }
+  if (chip>=10) {
+    Error("AliITSFOEfficiencySPD::GetChipEfficiency", "chip (%d) out of bounds.",chip);
+    return 0;
+  }
+
+  return fChipEfficiency[eq][hs][chip];
+}
+
diff --git a/ITS/AliITSFOEfficiencySPD.h b/ITS/AliITSFOEfficiencySPD.h
new file mode 100644 (file)
index 0000000..d904aea
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef ALIITS_FOEFFICIENCYSPD_H
+#define ALIITS_FOEFFICIENCYSPD_H
+
+/////////////////////////////////////////////////////////////////////
+// Author: Henrik Tydesjo                                          //
+//                                                                 //
+// This class is used to store Fast-OR efficiency values in OCDB.  //
+// One value per pixel chip in this base class (if per column      //
+// accuracy is needed, use AliITSFOEfficiencySPDColumn class).     //
+// The values are the probability that a pixel hit will generate a //
+// fast-OR signal.                                                 //
+//                                                                 //
+/////////////////////////////////////////////////////////////////////
+
+#include <TObject.h>
+#include <TError.h>
+
+class AliITSFOEfficiencySPD : public TObject {
+
+ public:
+  AliITSFOEfficiencySPD();
+  AliITSFOEfficiencySPD(const AliITSFOEfficiencySPD& foEff);
+  virtual ~AliITSFOEfficiencySPD();
+  AliITSFOEfficiencySPD& operator=(const AliITSFOEfficiencySPD& foEff);
+
+  virtual void    ResetValues();
+  virtual void    SetChipEfficiency(UInt_t eq, UInt_t hs, UInt_t chip, Float_t value);
+  virtual void    SetColumnEfficiency(UInt_t /*eq*/, UInt_t /*hs*/, UInt_t /*chip*/, UInt_t /*col*/, Float_t /*value*/) 
+    {Error("AliITSFOEfficiencySPD::SetColumnEfficiency","You need daughter class to set column efficiencies!");}
+
+  virtual Float_t GetChipEfficiency(UInt_t eq, UInt_t hs, UInt_t chip) const;
+  virtual Float_t GetColumnEfficiency(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t /*col*/) const
+    {return GetChipEfficiency(eq,hs,chip);}
+  virtual Float_t GetEfficiency(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t /*col*/, UInt_t /*row*/) const
+    {return GetChipEfficiency(eq,hs,chip);}
+
+ protected:
+  Float_t fChipEfficiency[20][6][10]; // efficiency values per chip
+
+  ClassDef(AliITSFOEfficiencySPD,1) // FO Efficiency Base
+};
+
+#endif
diff --git a/ITS/AliITSFOEfficiencySPDColumn.cxx b/ITS/AliITSFOEfficiencySPDColumn.cxx
new file mode 100644 (file)
index 0000000..7319447
--- /dev/null
@@ -0,0 +1,109 @@
+/////////////////////////////////////////////////////////////////////
+// Author: Henrik Tydesjo                                          //
+//                                                                 //
+// This class is used to store Fast-OR efficiency values in OCDB.  //
+// One value per pixel chip column in this daughter class.         //
+// The values are the probability that a pixel hit will generate a //
+// fast-OR signal.                                                 //
+//                                                                 //
+/////////////////////////////////////////////////////////////////////
+
+#include "AliITSFOEfficiencySPDColumn.h"
+
+AliITSFOEfficiencySPDColumn::AliITSFOEfficiencySPDColumn() : 
+  AliITSFOEfficiencySPD() 
+{
+  // default constructor, sets all efficiency values to 100%
+  ResetValues();
+}
+//______________________________________________________________________
+AliITSFOEfficiencySPDColumn::AliITSFOEfficiencySPDColumn(const AliITSFOEfficiencySPDColumn& foEff) :
+  AliITSFOEfficiencySPD()
+{  
+  // copy constructor, copy the array values from input object
+  for (UInt_t eq=0; eq<20; eq++) {
+    for (UInt_t hs=0; hs<6; hs++) {
+      for (UInt_t chip=0; chip<10; chip++) {
+       for (UInt_t col=0; col<32; col++) {
+         fColumnEfficiency[eq][hs][chip][col] = foEff.fColumnEfficiency[eq][hs][chip][col];
+       }
+      }
+    }
+  }
+}
+//______________________________________________________________________
+AliITSFOEfficiencySPDColumn::~AliITSFOEfficiencySPDColumn() {}
+//______________________________________________________________________
+AliITSFOEfficiencySPDColumn& AliITSFOEfficiencySPDColumn::operator=(const AliITSFOEfficiencySPDColumn& foEff) {
+  // assignment operator
+  if (this!=&foEff) {
+    for (UInt_t eq=0; eq<20; eq++) {
+      for (UInt_t hs=0; hs<6; hs++) {
+       for (UInt_t chip=0; chip<10; chip++) {
+         for (UInt_t col=0; col<32; col++) {
+           fColumnEfficiency[eq][hs][chip][col] = foEff.fColumnEfficiency[eq][hs][chip][col];
+         }
+       }
+      }
+    }
+  }
+  return *this;
+}
+//______________________________________________________________________
+void AliITSFOEfficiencySPDColumn::ResetValues() {
+  // set all efficiency values to 100%
+  for (UInt_t eq=0; eq<20; eq++) {
+    for (UInt_t hs=0; hs<6; hs++) {
+      for (UInt_t chip=0; chip<10; chip++) {
+       for (UInt_t col=0; col<32; col++) {
+         fColumnEfficiency[eq][hs][chip][col] = 1;
+       }
+      }
+    }
+  }
+}
+//______________________________________________________________________
+void AliITSFOEfficiencySPDColumn::SetColumnEfficiency(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, Float_t value) {
+  // set a column efficiency value
+  if (eq>=20) {
+    Error("AliITSFOEfficiencySPDColumn::SetColumnEfficiency", "eq (%d) out of bounds.",eq);
+    return;
+  }
+  if (hs>=6) {
+    Error("AliITSFOEfficiencySPDColumn::SetColumnEfficiency", "hs (%d) out of bounds.",hs);
+    return;
+  }
+  if (chip>=10) {
+    Error("AliITSFOEfficiencySPDColumn::SetColumnEfficiency", "chip (%d) out of bounds.",chip);
+    return;
+  }
+  if (col>=32) {
+    Error("AliITSFOEfficiencySPDColumn::SetColumnEfficiency", "col (%d) out of bounds.",col);
+    return;
+  }
+
+  fColumnEfficiency[eq][hs][chip][col] = value;
+}
+//______________________________________________________________________
+Float_t AliITSFOEfficiencySPDColumn::GetColumnEfficiency(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col) const {
+  // get a column efficiency value
+  if (eq>=20) {
+    Error("AliITSFOEfficiencySPDColumn::GetEfficiency", "eq (%d) out of bounds.",eq);
+    return 0;
+  }
+  if (hs>=6) {
+    Error("AliITSFOEfficiencySPDColumn::GetEfficiency", "hs (%d) out of bounds.",hs);
+    return 0;
+  }
+  if (chip>=10) {
+    Error("AliITSFOEfficiencySPDColumn::GetEfficiency", "chip (%d) out of bounds.",chip);
+    return 0;
+  }
+  if (col>=32) {
+    Error("AliITSFOEfficiencySPDColumn::GetEfficiency", "col (%d) out of bounds.",col);
+    return 0;
+  }
+
+  return fColumnEfficiency[eq][hs][chip][col];
+}
+
diff --git a/ITS/AliITSFOEfficiencySPDColumn.h b/ITS/AliITSFOEfficiencySPDColumn.h
new file mode 100644 (file)
index 0000000..b3d736d
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef ALIITS_FOEFFICIENCYSPDCOLUMN_H
+#define ALIITS_FOEFFICIENCYSPDCOLUMN_H
+
+/////////////////////////////////////////////////////////////////////
+// Author: Henrik Tydesjo                                          //
+//                                                                 //
+// This class is used to store Fast-OR efficiency values in OCDB.  //
+// One value per pixel chip column in this daughter class.         //
+// The values are the probability that a pixel hit will generate a //
+// fast-OR signal.                                                 //
+//                                                                 //
+/////////////////////////////////////////////////////////////////////
+
+#include "AliITSFOEfficiencySPD.h"
+
+class AliITSFOEfficiencySPDColumn : public AliITSFOEfficiencySPD {
+
+ public:
+  AliITSFOEfficiencySPDColumn();
+  AliITSFOEfficiencySPDColumn(const AliITSFOEfficiencySPDColumn& foEff);
+  virtual ~AliITSFOEfficiencySPDColumn();
+  AliITSFOEfficiencySPDColumn& operator=(const AliITSFOEfficiencySPDColumn& foEff);
+
+  virtual void    ResetValues();
+  virtual void    SetColumnEfficiency(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, Float_t value);
+
+  virtual Float_t GetEfficiency(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t /*row*/) const
+    {return GetColumnEfficiency(eq,hs,chip,col);}
+  virtual Float_t GetColumnEfficiency(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col) const;
+
+ protected:
+  Float_t fColumnEfficiency[20][6][10][32]; // efficiency values per chip column
+
+  ClassDef(AliITSFOEfficiencySPDColumn,1)   // FO Efficiency Per Column
+};
+
+#endif
diff --git a/ITS/AliITSFOGeneratorSPD.cxx b/ITS/AliITSFOGeneratorSPD.cxx
new file mode 100644 (file)
index 0000000..0afbcb7
--- /dev/null
@@ -0,0 +1,123 @@
+/////////////////////////////////////////////////////////////////////
+// Author: Henrik Tydesjo                                          //
+//                                                                 //
+// This class is used to generate Fast-OR signals from SPD chips.  //
+//                                                                 //
+// This procedure is meant to be used during the digitization,     //
+// and will be based on the number of pixels firing in each chip.  //
+// The method 'ProcessPixelHit' should be used for each fired      //
+// pixel. An efficiency value on Fast-Or signal creation upon a    //
+// single fired pixel will then be used. Optionally, there may be  //
+// one value per chip or even one value per column. These values   //
+// are taken from the class AliITSFOEfficiencySPD, normally placed //
+// in OCDB.                                                        //
+//                                                                 //
+// Through a similar class, AliITSFONoiseSPD, there is a           //
+// possibility to apply random noise to the generation of fast-or  //
+// signals. This will then be performed by method 'ProcessNoise',  //
+// normally called after the processing of the fired pixels.       //
+//                                                                 //
+// The output signals are represented by the AliITSFOsignalsSPD    //
+// class. Basically, it contains a bit map with all the 1200 pixel //
+// chips.                                                          //
+/////////////////////////////////////////////////////////////////////
+
+#include "AliITSFOGeneratorSPD.h"
+#include "AliITSRawStreamSPD.h"
+#include <TRandom.h>
+
+AliITSFOGeneratorSPD::AliITSFOGeneratorSPD() :
+  fSignals(), fOCDBEff(NULL), fOCDBNoise(NULL)
+{
+  // default constructor
+}
+//______________________________________________________________________
+AliITSFOGeneratorSPD::AliITSFOGeneratorSPD(AliITSFOEfficiencySPD* ocdbEff, AliITSFONoiseSPD* ocdbNoise) :
+    fSignals(), fOCDBEff(ocdbEff), fOCDBNoise(ocdbNoise)
+{
+  // constructor
+}
+//______________________________________________________________________
+AliITSFOGeneratorSPD::AliITSFOGeneratorSPD(const AliITSFOGeneratorSPD& handle): 
+  fSignals(handle.fSignals), fOCDBEff(handle.fOCDBEff), fOCDBNoise(handle.fOCDBNoise)
+{
+  // copy constructor
+}
+//______________________________________________________________________
+AliITSFOGeneratorSPD::~AliITSFOGeneratorSPD() {
+  // destructor
+}
+//______________________________________________________________________
+AliITSFOGeneratorSPD& AliITSFOGeneratorSPD::operator=(const AliITSFOGeneratorSPD& handle) {
+  // assignment operator
+  if (this!=&handle) {
+    fSignals = handle.fSignals;
+    fOCDBEff = handle.fOCDBEff;
+    fOCDBNoise = handle.fOCDBNoise;
+  }
+  return *this;
+}
+//______________________________________________________________________
+void AliITSFOGeneratorSPD::SetEfficiencyAndNoise(AliITSFOEfficiencySPD* ocdbEff, AliITSFONoiseSPD* ocdbNoise) {
+  // Method to give pointers to the OCDB entries, needed by methods ProcessPixelHit and ProcessNoise
+  SetEfficiency(ocdbEff);
+  SetNoise(ocdbNoise);
+}
+//______________________________________________________________________
+void AliITSFOGeneratorSPD::SetEfficiency(AliITSFOEfficiencySPD* ocdbEff) {
+  // Method to give pointer to the OCDB efficiency entry
+  fOCDBEff = ocdbEff;
+}
+//______________________________________________________________________
+void AliITSFOGeneratorSPD::SetNoise(AliITSFONoiseSPD* ocdbNoise) {
+  // Method to give pointer to the OCDB noise entry
+  fOCDBNoise = ocdbNoise;
+}
+//______________________________________________________________________
+void AliITSFOGeneratorSPD::ProcessPixelHit(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) {
+  // Here it will be decided wether a fired pixel will give rise to a fast-or signal or not
+  if (eq>=20 || hs>=6 || chip>=10 || col>=32 || row>=256) {
+    Error("AliITSFOGeneratorSPD::ProcessPixelHit", "eq,hs,chip,col,row (%d,%d,%d,%d,%d) out of bounds.",
+         eq,hs,chip,col,row);
+    return;
+  }
+  if (fOCDBEff==NULL) {
+    Error("AliITSFOGeneratorSPD::ProcessPixelHit", "No AliITSFOEfficiencySPD entry has been provided.");
+    return;
+  }
+  // simulate if this fired pixel gives rise to a fast-or signal:
+  if (gRandom->Rndm() < fOCDBEff->GetColumnEfficiency(eq,hs,chip,col)) {
+    fSignals.SetSignal(eq,hs,chip);
+  }
+}
+//______________________________________________________________________
+void AliITSFOGeneratorSPD::ProcessPixelHitM(UInt_t module, UInt_t colM, UInt_t rowM) {
+  // Converts offline coordinates to online, and calls ProcessPixelHit
+  if (module>=240 || colM>=160 || rowM>=256) {
+    Error("AliITSFOGeneratorSPD::ProcessPixelHitM", "module,colM,rowM (%d,%d,%d) out of bounds.",
+         module,colM,rowM);
+    return;
+  }
+  UInt_t eq,hs,chip,col,row;
+  if (AliITSRawStreamSPD::OfflineToOnline(module,colM,rowM,eq,hs,chip,col,row)) {
+    ProcessPixelHit(eq,hs,chip,col,row);
+  }
+}
+//______________________________________________________________________
+void AliITSFOGeneratorSPD::ProcessNoise() {
+  // 
+  if (fOCDBNoise==NULL) {
+    Error("AliITSFOGeneratorSPD::ProcessNoise", "No AliITSFONoiseSPD entry has been provided.");
+    return;
+  }
+  // simulate if each pixel chip will give rise to a random noise induced fast-or signal:
+  for (UInt_t eq=0; eq<20; eq++) {
+    for (UInt_t hs=0; hs<6; hs++) {
+      for (UInt_t chip=0; chip<10; chip++) {
+       if (gRandom->Rndm() < fOCDBNoise->GetChipNoise(eq,hs,chip)) {
+         fSignals.SetSignal(eq,hs,chip);
+       }
+      }
+    }
+  }
+}
diff --git a/ITS/AliITSFOGeneratorSPD.h b/ITS/AliITSFOGeneratorSPD.h
new file mode 100644 (file)
index 0000000..24907fe
--- /dev/null
@@ -0,0 +1,63 @@
+#ifndef ALIITS_FOGENERATORSPD_H
+#define ALIITS_FOGENERATORSPD_H
+
+/////////////////////////////////////////////////////////////////////
+// Author: Henrik Tydesjo                                          //
+//                                                                 //
+// This class is used to generate Fast-OR signals from SPD chips.  //
+//                                                                 //
+// This procedure is meant to be used during the digitization,     //
+// and will be based on the number of pixels firing in each chip.  //
+// The method 'ProcessPixelHit' should be used for each fired      //
+// pixel. An efficiency value on Fast-Or signal creation upon a    //
+// single fired pixel will then be used. Optionally, there may be  //
+// one value per chip or even one value per column. These values   //
+// are taken from the class AliITSFOEfficiencySPD, normally placed //
+// in OCDB.                                                        //
+//                                                                 //
+// Through a similar class, AliITSFONoiseSPD, there is a           //
+// possibility to apply random noise to the generation of fast-or  //
+// signals. This will then be performed by method 'ProcessNoise',  //
+// normally called after the processing of the fired pixels.       //
+//                                                                 //
+// The output signals are represented by the AliITSFOsignalsSPD    //
+// class. Basically, it contains a bit map with all the 1200 pixel //
+// chips.                                                          //
+/////////////////////////////////////////////////////////////////////
+
+#include "AliITSFOEfficiencySPD.h"
+#include "AliITSFONoiseSPD.h"
+#include "AliITSFOSignalsSPD.h"
+
+class AliITSFOGeneratorSPD {
+
+ public:
+  AliITSFOGeneratorSPD();
+  AliITSFOGeneratorSPD(AliITSFOEfficiencySPD* ocdbEff, AliITSFONoiseSPD* ocdbNoise);
+  AliITSFOGeneratorSPD(const AliITSFOGeneratorSPD& handle);
+  virtual ~AliITSFOGeneratorSPD();
+  AliITSFOGeneratorSPD& operator=(const AliITSFOGeneratorSPD& handle);
+
+  virtual void   SetEfficiencyAndNoise(AliITSFOEfficiencySPD* ocdbEff, AliITSFONoiseSPD* ocdbNoise);
+  virtual void   SetEfficiency(AliITSFOEfficiencySPD* ocdbEff);
+  virtual void   SetNoise(AliITSFONoiseSPD* ocdbNoise);
+  virtual Bool_t EfficiencyAndNoiseAreSet() {return fOCDBEff!=NULL && fOCDBNoise!=NULL;}
+
+  virtual void   ResetSignals() {fSignals.ResetSignals();}
+
+  virtual void   ProcessPixelHitM(UInt_t module, UInt_t colM, UInt_t rowM);
+  virtual void   ProcessPixelHit(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
+  virtual void   ProcessNoise();
+
+  virtual AliITSFOSignalsSPD* GetFOSignals() {return &fSignals;}
+
+
+ protected:
+  AliITSFOSignalsSPD     fSignals;   // Fast-OR signals object
+
+  AliITSFOEfficiencySPD *fOCDBEff;   // link to FO efficiency obj
+  AliITSFONoiseSPD      *fOCDBNoise; // link to FO noise obj
+
+};
+
+#endif
diff --git a/ITS/AliITSFONoiseSPD.cxx b/ITS/AliITSFONoiseSPD.cxx
new file mode 100644 (file)
index 0000000..1c9047a
--- /dev/null
@@ -0,0 +1,95 @@
+/////////////////////////////////////////////////////////////////////
+// Author: Henrik Tydesjo                                          //
+//                                                                 //
+// This class is used to store Fast-OR noise values in OCDB.       //
+// One value per pixel chip.                                       //
+// The values are the probability that a pixel chip will generate  //
+// a fast-OR signal independently (originating from noise).        //
+//                                                                 //
+/////////////////////////////////////////////////////////////////////
+
+#include "AliITSFONoiseSPD.h"
+
+AliITSFONoiseSPD::AliITSFONoiseSPD() :
+  TObject()
+{
+  // default constructor, sets all noise values to 0%
+  ResetValues();
+}
+//______________________________________________________________________
+AliITSFONoiseSPD::AliITSFONoiseSPD(const AliITSFONoiseSPD& foNoi) :
+  TObject()
+{
+  // copy constructor, copy the array values from input object
+  for (UInt_t eq=0; eq<20; eq++) {
+    for (UInt_t hs=0; hs<6; hs++) {
+      for (UInt_t chip=0; chip<10; chip++) {
+       fChipNoise[eq][hs][chip] = foNoi.fChipNoise[eq][hs][chip];
+      }
+    }
+  }
+}
+//______________________________________________________________________
+AliITSFONoiseSPD::~AliITSFONoiseSPD() {}
+//______________________________________________________________________
+void AliITSFONoiseSPD::ResetValues() {
+  // set all noise values to 0%
+  for (UInt_t eq=0; eq<20; eq++) {
+    for (UInt_t hs=0; hs<6; hs++) {
+      for (UInt_t chip=0; chip<10; chip++) {
+       fChipNoise[eq][hs][chip] = 0;
+      }
+    }
+  }
+}
+//______________________________________________________________________
+AliITSFONoiseSPD& AliITSFONoiseSPD::operator=(const AliITSFONoiseSPD& foNoi) {
+  // assignment operator
+  if (this!=&foNoi) {
+    for (UInt_t eq=0; eq<20; eq++) {
+      for (UInt_t hs=0; hs<6; hs++) {
+       for (UInt_t chip=0; chip<10; chip++) {
+         fChipNoise[eq][hs][chip] = foNoi.fChipNoise[eq][hs][chip];
+       }
+      }
+    }
+  }
+  return *this;
+}
+//______________________________________________________________________
+void AliITSFONoiseSPD::SetChipNoise(UInt_t eq, UInt_t hs, UInt_t chip, Float_t value) {
+  // set a chip noise value
+  if (eq>=20) {
+    Error("AliITSFONoiseSPD::SetChipNoise", "eq (%d) out of bounds.",eq);
+    return;
+  }
+  if (hs>=6) {
+    Error("AliITSFONoiseSPD::SetChipNoise", "hs (%d) out of bounds.",hs);
+    return;
+  }
+  if (chip>=10) {
+    Error("AliITSFONoiseSPD::SetChipNoise", "chip (%d) out of bounds.",chip);
+    return;
+  }
+  
+  fChipNoise[eq][hs][chip] = value;
+}
+//______________________________________________________________________
+Float_t AliITSFONoiseSPD::GetChipNoise(UInt_t eq, UInt_t hs, UInt_t chip) const {
+  // get a chip noise value
+  if (eq>=20) {
+    Error("AliITSFONoiseSPD::GetChipNoise", "eq (%d) out of bounds.",eq);
+    return 0;
+  }
+  if (hs>=6) {
+    Error("AliITSFONoiseSPD::GetChipNoise", "hs (%d) out of bounds.",hs);
+    return 0;
+  }
+  if (chip>=10) {
+    Error("AliITSFONoiseSPD::GetChipNoise", "chip (%d) out of bounds.",chip);
+    return 0;
+  }
+
+  return fChipNoise[eq][hs][chip];
+}
+
diff --git a/ITS/AliITSFONoiseSPD.h b/ITS/AliITSFONoiseSPD.h
new file mode 100644 (file)
index 0000000..f5e5963
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef ALIITS_FONOISESPD_H
+#define ALIITS_FONOISESPD_H
+
+/////////////////////////////////////////////////////////////////////
+// Author: Henrik Tydesjo                                          //
+//                                                                 //
+// This class is used to store Fast-OR noise values in OCDB.       //
+// One value per pixel chip.                                       //
+// The values are the probability that a pixel chip will generate  //
+// a fast-OR signal independently (originating from noise).        //
+//                                                                 //
+/////////////////////////////////////////////////////////////////////
+
+#include <TObject.h>
+#include <TError.h>
+
+class AliITSFONoiseSPD : public TObject {
+
+ public:
+  AliITSFONoiseSPD();
+  AliITSFONoiseSPD(const AliITSFONoiseSPD& foNoi);
+  virtual ~AliITSFONoiseSPD();
+  AliITSFONoiseSPD& operator=(const AliITSFONoiseSPD& foNoi);
+
+  virtual void    ResetValues();
+  virtual void    SetChipNoise(UInt_t eq, UInt_t hs, UInt_t chip, Float_t value);
+  virtual Float_t GetChipNoise(UInt_t eq, UInt_t hs, UInt_t chip) const;
+  virtual Float_t GetNoise(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t /*col*/, UInt_t /*row*/) const
+    {return GetChipNoise(eq,hs,chip);}
+
+ protected:
+  Float_t fChipNoise[20][6][10]; // noise values per chip
+
+  ClassDef(AliITSFONoiseSPD,1)      // FO Noise Base
+};
+
+#endif
diff --git a/ITS/AliITSFOSignalsSPD.cxx b/ITS/AliITSFOSignalsSPD.cxx
new file mode 100644 (file)
index 0000000..7cd7f4c
--- /dev/null
@@ -0,0 +1,91 @@
+/////////////////////////////////////////////////////////////////////
+// Author: Henrik Tydesjo                                          //
+//                                                                 //
+// This class is used to store information on generated Fast-OR    //
+// signals. 1200 bits, one per pixel chip.                         //
+//                                                                 //
+/////////////////////////////////////////////////////////////////////
+
+#include "AliITSFOSignalsSPD.h"
+
+ClassImp(AliITSFOSignalsSPD)
+
+AliITSFOSignalsSPD::AliITSFOSignalsSPD() :
+  TObject(), fSignals(1200)
+{
+  // default constructor
+}
+//______________________________________________________________________
+AliITSFOSignalsSPD::~AliITSFOSignalsSPD() {}
+//______________________________________________________________________
+AliITSFOSignalsSPD::AliITSFOSignalsSPD(const AliITSFOSignalsSPD& fo):
+  TObject(), fSignals(fo.fSignals)
+{
+  // copy constructor
+}
+//______________________________________________________________________
+AliITSFOSignalsSPD& AliITSFOSignalsSPD::operator=(const AliITSFOSignalsSPD& fo) {
+  // assignment operator
+  if (this!=&fo) {
+    fSignals = fo.fSignals;
+  }
+  return *this;
+}
+//______________________________________________________________________
+void AliITSFOSignalsSPD::SetSignal(UInt_t eq, UInt_t hs, UInt_t chip, Bool_t setVal) {
+  // Set 0 or 1 for a specific chip
+  fSignals.SetBitNumber(GetChipKey(eq,hs,chip),setVal);
+}
+//______________________________________________________________________
+Bool_t AliITSFOSignalsSPD::GetSignal(UInt_t eq, UInt_t hs, UInt_t chip) const {
+  // check if a specific chip has a signal
+  return fSignals.TestBitNumber(GetChipKey(eq,hs,chip));
+}
+//______________________________________________________________________
+Bool_t AliITSFOSignalsSPD::GetNextSignal(Int_t& eq, Int_t& hs, Int_t& chip) const {
+  // Returns true if a signal was found (start looking after the bit number
+  // corresponding to the input parameters eq,hs,chip).
+  // If either of eq,hs,chip < 0 , start from beginning of TBits array.
+  // See example of usage in DumpSignals method.
+  UInt_t searchIndex;
+  if (eq<0 || hs<0 || chip<0) searchIndex = 0;
+  else searchIndex = GetChipKey(eq, hs, chip) + 1;
+  UInt_t nextIndex = fSignals.FirstSetBit(searchIndex);
+  if (nextIndex==1200) return kFALSE;
+  GetChipFromKey(nextIndex, eq, hs, chip);
+  return kTRUE;
+}
+//__________________________________________________________________________________
+void AliITSFOSignalsSPD::DumpSignals() {
+  // print a list of the chips which have a signal
+  printf("These chips (given in eq,hs,chip) have a signal:\n");
+  UInt_t nrSignals=0;
+  Int_t eq   = -1;
+  Int_t hs   = -1;
+  Int_t chip = -1;
+  while (GetNextSignal(eq,hs,chip)) {
+    printf("%d,%d,%d\n",eq,hs,chip);
+    nrSignals++;
+  }
+  printf("In total %d signals.\n",nrSignals);
+}
+//______________________________________________________________________
+UInt_t AliITSFOSignalsSPD::GetChipKey(Int_t eq, Int_t hs, Int_t chip) const {
+  // translates eq,hs,chip numbers into one integer key (0-1199)
+  if (eq>=20 || eq<0 || hs>=6 || hs<0 || chip>=10 || chip<0) {
+    Error("AliITSFOSignalsSPD::GetChipKey", "eq,hs,chip = %d,%d,%d out of range",eq,hs,chip);
+    return 0;
+  }
+  return eq*60 + hs*10 + chip;
+}
+//__________________________________________________________________________________
+void AliITSFOSignalsSPD::GetChipFromKey(UInt_t key, Int_t& eq, Int_t& hs, Int_t& chip) const {
+  // translates a chip key back into eq,hs,chip numbers
+  if (key>=1200) {
+    Error("AliITSFOSignalsSPD::GetChipFromKey", "key = %d out of range", key);
+    return;
+  }
+  eq   = key/60;
+  hs   = (key%60)/10;
+  chip = key%10;
+}
diff --git a/ITS/AliITSFOSignalsSPD.h b/ITS/AliITSFOSignalsSPD.h
new file mode 100644 (file)
index 0000000..449cbc1
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef ALIITS_FOSIGNALSSPD_H
+#define ALIITS_FOSIGNALSSPD_H
+
+/////////////////////////////////////////////////////////////////////
+// Author: Henrik Tydesjo                                          //
+//                                                                 //
+// This class is used to store information on generated Fast-OR    //
+// signals. 1200 bits, one per pixel chip.                         //
+//                                                                 //
+/////////////////////////////////////////////////////////////////////
+
+#include <TObject.h>
+#include <TBits.h>
+
+class AliITSFOSignalsSPD : public TObject {
+
+ public:
+  AliITSFOSignalsSPD();
+  virtual ~AliITSFOSignalsSPD();
+  AliITSFOSignalsSPD(const AliITSFOSignalsSPD& fo);
+  AliITSFOSignalsSPD& operator=(const AliITSFOSignalsSPD& fo);
+
+  virtual void    ResetSignals() {fSignals.ResetAllBits();}
+  virtual void    SetSignal(UInt_t eq, UInt_t hs, UInt_t chip, Bool_t setVal=kTRUE);
+  virtual Bool_t  GetSignal(UInt_t eq, UInt_t hs, UInt_t chip) const;
+
+  virtual Bool_t  GetNextSignal(Int_t& eq, Int_t& hs, Int_t& chip) const;
+  virtual void    DumpSignals();
+
+ protected:
+  TBits fSignals; // FO signals, one bit per chip
+
+  UInt_t  GetChipKey(Int_t eq, Int_t hs, Int_t chip) const;
+  void    GetChipFromKey(UInt_t key, Int_t& eq, Int_t& hs, Int_t& chip) const;
+
+  ClassDef(AliITSFOSignalsSPD,1)
+};
+
+#endif
diff --git a/ITS/AliITSFastOrCalibrationSPD.cxx b/ITS/AliITSFastOrCalibrationSPD.cxx
deleted file mode 100644 (file)
index fc25c5b..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- *                                                                        *
- * Author: The ALICE Off-line Project.                                    *
- * Contributors are mentioned in the code where appropriate.              *
- *                                                                        *
- * Permission to use, copy, modify and distribute this software and its   *
- * documentation strictly for non-commercial purposes is hereby granted   *
- * without fee, provided that the above copyright notice appears in all   *
- * copies and that both the copyright notice and this permission notice   *
- * appear in the supporting documentation. The authors make no claims     *
- * about the suitability of this software for any purpose. It is          *
- * provided "as is" without express or implied warranty.                  *
- **************************************************************************/
-
-#include "AliITSFastOrCalibrationSPD.h"
-///////////////////////////////////////////////////////////////////////////
-//
-//  Calibration class for the SPD FastOr configuration info
-//  
-//  C. Di Giglio Carmelo.Digiglio@ba.infn.it
-//  D. Elia      Domenico.Elia@ba.infn.it 
-//
-///////////////////////////////////////////////////////////////////////////
-
-ClassImp(AliITSFastOrCalibrationSPD)
-
-//-----------------------------------------------
-//Deafault constructor
-AliITSFastOrCalibrationSPD::AliITSFastOrCalibrationSPD():
-TObject(),
-fFastOrConfiguredChips(1200)
-{
-// constructor
-}
-
-//Default destructor
-AliITSFastOrCalibrationSPD::~AliITSFastOrCalibrationSPD() {}
-//____________________________________________________________________________________________
-Bool_t AliITSFastOrCalibrationSPD::WriteFOConfToDB(Int_t runNrStart, Int_t runNrEnd)  {
-
-  AliCDBManager* man = AliCDBManager::Instance();
-
-  if(!man->IsDefaultStorageSet()) {
-     man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
-  }
-
-  AliCDBMetaData* metaData = new AliCDBMetaData();
-  metaData->SetResponsible("Domenico Elia");
-  metaData->SetComment("Created by storeFastOrConfToDB.C");
-  AliCDBId idCalSPD("ITS/Calib/SPDFastOr",runNrStart,runNrEnd);
-  AliCDBEntry* cdbEntry = new AliCDBEntry(this,idCalSPD,metaData);
-  man->Put(cdbEntry);
-  delete cdbEntry;
-  delete metaData;
-
-  return kTRUE;
-}
diff --git a/ITS/AliITSFastOrCalibrationSPD.h b/ITS/AliITSFastOrCalibrationSPD.h
deleted file mode 100644 (file)
index d78b496..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef AliITSFastOrCalibrationSPD_H
-#define AliITSFastOrCalibrationSPD_H
-
-#include <TObject.h>
-#include <TBits.h>
-#include <AliCDBManager.h>
-#include <AliCDBMetaData.h>
-#include <AliCDBEntry.h>
-
-
-class AliITSFastOrCalibrationSPD : public TObject{
- public:
-    AliITSFastOrCalibrationSPD(); //default constructor
-    virtual ~AliITSFastOrCalibrationSPD(); //destructor
-
-    //setters          
-    void   SetFastOrConfiguredChips(UInt_t chipKey) {fFastOrConfiguredChips.SetBitNumber(chipKey);}
-    void   ResetFastOrConfiguredChips() {fFastOrConfiguredChips.ResetAllBits();}
-
-    //getters
-    TBits  GetFastOrConfiguredChips() const {return fFastOrConfiguredChips;}
-    Bool_t TestFastOrConfiguredChips(UInt_t chipKey) const {return fFastOrConfiguredChips.TestBitNumber(chipKey);}
-
-    Bool_t WriteFOConfToDB(Int_t runNrStart, Int_t runNrEnd); 
-
- private:
-    TBits  fFastOrConfiguredChips;     // Map of FastOr configured chips
-
-    ClassDef(AliITSFastOrCalibrationSPD,1) 
-};
-
-#endif
index c1ed5709c44c31a9229f5018c01152fbf31a4817..fd49c8f60be89b67920acade98a655d4885703ee 100644 (file)
@@ -22,6 +22,7 @@
 #include "AliITSdigit.h"
 #include "AliITSLoader.h"
 #include "AliRunLoader.h"
+#include "AliObjectLoader.h"
 #include "AliITSInitGeometry.h"
 #include "AliLog.h"
 
@@ -84,6 +85,12 @@ fGeom(0){
     fDataLoaders->Add(cascadeDataLoader);
     cascadeDataLoader->SetEventFolder(fEventFolder);
     cascadeDataLoader->SetFolder(GetDetectorDataFolder());
+    
+    // 2009/03/03: addition of object loader for fast-or signals (Henrik Tydesjo)
+    AliDataLoader* dl = GetDigitsDataLoader();
+    AliBaseLoader* foLoader = new AliObjectLoader("AliITSFOSignalsSPD",dl);
+    dl->AddBaseLoader(foLoader);
+    
 }
 /**********************************************************************/
 AliITSLoader::AliITSLoader(const Char_t *name,TFolder *topfolder): 
@@ -124,6 +131,13 @@ fGeom(0){
     fDataLoaders->Add(cascadeDataLoader);
     cascadeDataLoader->SetEventFolder(fEventFolder);
     cascadeDataLoader->SetFolder(GetDetectorDataFolder());
+    
+    // 2009/03/03: addition of object loader for fast-or signals (Henrik Tydesjo)
+    AliDataLoader* dl = GetDigitsDataLoader();
+    AliBaseLoader* foLoader = new AliObjectLoader("AliITSFOSignalsSPD",dl);
+    dl->AddBaseLoader(foLoader);
+
+    
 }
 
 
@@ -359,4 +373,14 @@ void AliITSLoader::SetITSgeom(AliITSgeom *geom){
     }// end if
     fGeom=geom;
 }
+//______________________________________________________________________
+AliBaseLoader* AliITSLoader::GetFOSignalsLoader() {
+  // return pointer to FO signals base loader
+  AliDataLoader* dl = GetDigitsDataLoader();
+  if (!dl) {
+    AliError("Data loader is NULL.");
+    return NULL;
+  }
+  return dl->GetBaseLoader("AliITSFOSignalsSPD");
+}
 
index 4e0825feb11c1a166470e95e654de549b46c0970..642457e46bd7ea8a77811ea7c8ffdc787b45842d 100644 (file)
@@ -106,6 +106,9 @@ class AliITSLoader: public AliLoader{
     virtual Int_t  WriteBackTracks(Option_t* opt=""){
         return GetBackTracksDataLoader()->GetBaseLoader(0)->WriteData(opt);}
 
+    virtual AliBaseLoader* GetFOSignalsLoader();
+
+        
     // Geometry. Geom is read from file, unless already loaded
     // readout from file can be forced if force=kTRUE
     AliITSgeom* GetITSgeom(Bool_t force=kFALSE); 
index 87ee115097a8d0a750959ad35eb5ca47458ce271..bc4be3fd12742acdfbd8b0d95ec588c0f35326d5 100644 (file)
@@ -11,6 +11,7 @@
 ///
 ///////////////////////////////////////////////////////////////////////////////
 
+#include "AliRawReader.h"
 #include "AliITSRawStream.h"
 #include "AliITSRawStreamSPDErrorLog.h"
 
@@ -84,11 +85,13 @@ class AliITSRawStreamSPD: public AliITSRawStream {
     UInt_t GetHrowStart() const {return (UInt_t) ((fCalHeadWord[6]>>24) & 0x000000ff);}
     UInt_t GetHrowEnd() const {return (UInt_t) ((fCalHeadWord[6]>>16) & 0x000000ff);}
     UInt_t GetHrowValue() const {return (UInt_t) ((fCalHeadWord[6]>> 8) & 0x000000ff);}
+    UInt_t GetHrowSpan() const {return (UInt_t) ((fCalHeadWord[6]) & 0x000000ff);}    
     UInt_t GetHdacValue() const {return (Int_t) ((fCalHeadWord[6]) & 0x000000ff);}
     UInt_t GetHdacHigh(UInt_t hs) const;
     UInt_t GetHdacLow(UInt_t hs) const;
     UInt_t GetHTPAmp(UInt_t hs) const;
     Bool_t GetHminTHchipPresent(UInt_t chip) const;
+    UInt_t GetHglobalDBversion() const {return fCalHeadWord[16];}
     // use the methods below to extract the information from the fo calibration header:
     UInt_t GetFOHrouterNr() const {return GetHrouterNr();}
     UInt_t GetFOHtype() const {return GetHtype();}
index 59042af76bb0c6650d435526eb64abc95f01731d..6bb0fb3928f03ff492fcfa3956caca3a435fafdf 100644 (file)
@@ -160,7 +160,9 @@ fTrackleterZetaWindow(1.00),
 fTrackleterRemoveClustersFromOverlaps(kFALSE),
 fTrackleterPhiOverlapCut(0.005),
 fTrackleterZetaOverlapCut(0.05),
-fUseCosmicRunShiftsSSD(kFALSE)
+fUseCosmicRunShiftsSSD(kFALSE),
+fSPDRemoveNoisyFlag(kTRUE),
+fSPDRemoveDeadFlag(kTRUE)
 {
   //
   // constructor
index ad3ef8f5bdb42cbf98eb1305d216ee3081fc3d7c..e2920377036ca39e788ccbe95d372f05f99dbdad 100644 (file)
@@ -320,6 +320,11 @@ class AliITSRecoParam : public AliDetectorRecoParam
 
   //
 
+  void   SetSPDRemoveNoisyFlag(Bool_t value) {fSPDRemoveNoisyFlag = value;}
+  Bool_t GetSPDRemoveNoisyFlag() {return fSPDRemoveNoisyFlag;}
+  void   SetSPDRemoveDeadFlag(Bool_t value) {fSPDRemoveDeadFlag = value;}
+  Bool_t GetSPDRemoveDeadFlag() {return fSPDRemoveDeadFlag;}
+  
   enum {fgkMaxClusterPerLayer=70000}; //7000*10;   // max clusters per layer
   enum {fgkMaxClusterPerLayer5=28000};//7000*10*2/5;  // max clusters per layer
   enum {fgkMaxClusterPerLayer10=14000};//7000*10*2/10; // max clusters per layer
@@ -507,6 +512,12 @@ class AliITSRecoParam : public AliDetectorRecoParam
   Bool_t fUseCosmicRunShiftsSSD; // SSD time shifts for cosmic run 2007/2008 (use for data taken up to 18 sept 2008)
 
 
+   // SPD flags to specify whether noisy and dead pixels 
+  // should be removed at the local reconstruction step (default and safe way is true for both)
+  Bool_t  fSPDRemoveNoisyFlag;  // Flag saying whether noisy pixels should be removed
+  Bool_t  fSPDRemoveDeadFlag;   // Flag saying whether dead pixels should be removed
+
+  
   ClassDef(AliITSRecoParam,18) // ITS reco parameters
 };
 
index 4d28d30b1965cb18d572b31d277f8ef948ef91a7..125e9344e53f6bd7feaf2cc7bd37fe7ded1ddb60 100644 (file)
@@ -67,6 +67,12 @@ class AliITSSimuParam : public TObject {
   void   SetSPDSigmaDiffusionAsymmetry(Double_t ecc) {fSPDEccDiff=ecc;}   
   void   GetSPDSigmaDiffusionAsymmetry(Double_t &ecc) const {ecc=fSPDEccDiff;}
 
+  
+  void   SetSPDAddNoisyFlag(Bool_t value) {fSPDAddNoisyFlag = value;}
+  Bool_t GetSPDAddNoisyFlag() {return fSPDAddNoisyFlag;}
+  void   SetSPDRemoveDeadFlag(Bool_t value) {fSPDRemoveDeadFlag = value;}
+  Bool_t GetSPDRemoveDeadFlag() {return fSPDRemoveDeadFlag;}
+  
   void SetSDDElectronics(Int_t p1=1) {fSDDElectronics=p1;   }
   Int_t GetSDDElectronics()  const {return fSDDElectronics;}
 
@@ -205,7 +211,9 @@ class AliITSSimuParam : public TObject {
   Double_t fSPDCouplCol;    // SPD Coupling parameter along the cols
   Double_t fSPDCouplRow;    // SPD Coupling parameter along the rows
   Float_t  fSPDEccDiff;     // Eccentricity (i.e. asymmetry parameter) in the 
-                            // Gaussian diffusion for SPD
+                            // Gaussian diffusion for SPD  
+  Bool_t   fSPDAddNoisyFlag;     // Flag saying whether noisy pixels should be added to digits
+  Bool_t   fSPDRemoveDeadFlag;   // Flag saying whether dead pixels should be removed from digits
 
   Int_t    fSDDElectronics;  // SDD Electronics Pascal (1) or OLA (2)
   Float_t  fSDDDiffCoeff;    // SDD Diffusion Coefficient (scaling the time)
@@ -229,6 +237,6 @@ class AliITSSimuParam : public TObject {
   Double_t fN;  // the impurity concentration of the material in #/cm^3  (NOT USED!)
   Float_t fT;   // The temperature of the Si in Degree K.
 
-  ClassDef(AliITSSimuParam,2);
+  ClassDef(AliITSSimuParam,3);
 };
 #endif
index 4fca33fcef8ff750a69e699e663ca7bd319461f2..7ee066b5bd3f181b84db8678001c463d3bd1b6c2 100644 (file)
 
 /* $Id$ */
 
-#include <TClonesArray.h>
+////////////////////////////////////////////////////////////////////////
+//                                                                    //
+// Simulates generation of Fast-OR signals from SPD (if needed).      //
+// Processes the Fast-OR signals generated in AliITSsimulationSPD.    //
+// Provides inputs for AliCentralTrigger.                             //
+//                                                                    //
+// Version 2, Henrik Tydesjo, Feb 2009                                //
+// Version 1, D. Elia, C. Jorgensen, Mar 2006                         //
+// Version 0, J. Conrad, E. Lopez Torres, Oct 2005                    //
+//                                                                    //
+////////////////////////////////////////////////////////////////////////
 
+#include "AliITSTrigger.h"
 #include "AliLog.h"
 #include "AliRun.h"
 #include "AliRunLoader.h"
-#include "AliTriggerInput.h"
-
-#include "AliITSTrigger.h"
-#include "AliITSdigitSPD.h"
-#include "AliITSgeom.h"
 #include "AliITSLoader.h"
+#include "AliTriggerInput.h"
 
-//______________________________________________________________________
 ClassImp(AliITSTrigger)
-////////////////////////////////////////////////////////////////////////
-//                                                                    //
-// Version 1                                                          //
-// Modified by D. Elia, C. Jorgensen                                  //
-// March 2006                                                         //
-//                                                                    //
-// Version 0                                                          //
-// Written by J. Conrad, E. Lopez Torres                              //
-// October 2005                                                       //
-//                                                                    //
-// AliITSTrigger: implementation of the SPD Fast-OR based triggers.   //
-//                                                                    //
-////////////////////////////////////////////////////////////////////////
 
 //______________________________________________________________________
-AliITSTrigger::AliITSTrigger()
-  : AliTriggerDetector(),
-fGlobalFOThreshold(1),
-fHighMultFOThreshold(190){
-
+AliITSTrigger::AliITSTrigger() : 
+  AliTriggerDetector(),
+  fPITprocessor()
+{
   //standard constructor
   SetName("ITS");
-
-  // set parameters to define trigger condition thresholds
-  //fGlobalFOThreshold = 1;
-  //fHighMultFOThreshold = 150; 
 }
-
 //______________________________________________________________________
-void AliITSTrigger::CreateInputs()
+AliITSTrigger::AliITSTrigger(AliITSTriggerConditions* cond) : 
+  AliTriggerDetector(),
+  fPITprocessor(cond)
 {
-   // inputs
-
-   // Do not create inputs again!!
-   if( fInputs.GetEntriesFast() > 0 ) return;
-   
-   fInputs.AddLast( new AliTriggerInput( "SPD_GFO_L0",     "SPD", 0 ) );
-   fInputs.AddLast( new AliTriggerInput( "SPD_HMULT_L0",   "SPD", 0 ) );
-
+  // optional constructor
+  SetName("ITS");
 }
-
 //______________________________________________________________________
-void AliITSTrigger::Trigger()
-{
-
-  //  ********** Get run loader for the current event **********
-  AliRunLoader* runLoader = AliRunLoader::Instance();
-
-  AliITSLoader* loader = (AliITSLoader* )runLoader->GetLoader( "ITSLoader" );
-  AliITSgeom* geom = loader->GetITSgeom();
-  loader->LoadDigits("READ");
-  TTree *treeD = loader->TreeD();
-  if (!treeD) return;
-
-  TObjArray *digDet = 0;
-  digDet = new TObjArray(3);
-
-
-  // Cut on Signal In the Pixel Detector
-  TBranch* br = treeD->GetBranch( "ITSDigitsSPD" );
-  br->SetAddress( &((*digDet)[0]) );
-  ((TClonesArray*)(digDet->At(0)))->Clear();
-
-  MultiplicityTriggers(digDet, treeD, geom);
-  //  GeometryTriggers(digDet, treeD, geom);
-
-  // Debug : FIX change to AliLog
-//  cout << "=================================================" << endl;
-//  cout << "  Pixel Trigger Mask ( " << hex << "0x" << GetMask() << " )" << endl << endl;
-//  cout << " Global Fast OR        " << "0x" << GetInput( "ITS_SPD_GFO_L0"      )->GetValue() << endl;
-//  cout << " High Multiplicity     " << "0x" << GetInput( "ITS_SPD_HMULT_L0"      )->GetValue() << endl;
-//  cout << "=================================================" << endl << endl;
-
+void AliITSTrigger::SetTriggerConditions(AliITSTriggerConditions* cond) {
+  // Sets the trigger conditions, normally coming from OCDB
+  fPITprocessor.SetTriggerConditions(cond);
 }
-
 //______________________________________________________________________
-void AliITSTrigger::MultiplicityTriggers(TObjArray* digDet, TTree* treeD, AliITSgeom* geom)
-{
-  // simple FO triggers that only cares about the multiplicity
-
-  const Int_t nChipsInModule = 5;
-  Int_t startSPD = geom->GetStartSPD();
-  Int_t lastSPD  = geom->GetLastSPD();
-
-  Int_t totalNumberOfFO = 0;
-  Int_t totalNumberOfFOLay1 = 0;
-  Int_t ndigitsInChip[5];
-
-  // loop over modules (ladders)
-  for (Int_t moduleIndex=startSPD; moduleIndex<lastSPD+1; moduleIndex++) {
-    treeD->GetEvent(moduleIndex);
-    TClonesArray* digits = (TClonesArray*) (digDet->At(0)); // SPD only.
-    Int_t lay,stav,det;  geom->GetModuleId(moduleIndex,lay,stav,det);
-    
-    // get number of digits in this module
-    Int_t ndigitsInModule = digits->GetEntriesFast();
-
-    // get number of digits in each chip of the module
-    for( Int_t iChip=0; iChip<5; iChip++ ) {
-       ndigitsInChip[iChip]=0;
-    }  
-    for( Int_t iDig=0; iDig<ndigitsInModule; iDig++ ) {
-       AliITSdigitSPD* dp = (AliITSdigitSPD*) digits->At(iDig);
-       Int_t column = dp->GetCoord1();
-       Int_t isChip = nChipsInModule - Int_t(column/32.) - 1;
-       ndigitsInChip[isChip]++;
-    }
-    // get number of FOs in the module
-    for( Int_t ifChip=0; ifChip<5; ifChip++ ) {
-       if( ndigitsInChip[ifChip] >= 1 ) {
-            totalNumberOfFO++;
-            if(lay==1) totalNumberOfFOLay1++;
-       }       
-    }
-  // end of loop over modules
+void AliITSTrigger::CreateInputs() {
+  // Create inputs, based on OCDB Pixel Trigger Conditions
+  if( fInputs.GetEntriesFast() > 0 ) return; // Inputs already created, no need to proceed
+  
+  // Load trigger conditions from OCDB if needed
+  if (! fPITprocessor.TriggerConditionsSet() ) {
+    AliError("Trigger conditions not set. No inputs created.");
+    return;
   }
 
-  // produce input trigger condition
-  if (totalNumberOfFO>=fGlobalFOThreshold) 
-    SetInput( "SPD_GFO_L0" );
-
-  if (totalNumberOfFOLay1>=fHighMultFOThreshold) 
-    SetInput( "SPD_HMULT_L0" );
-
-  return;
-
+  UInt_t numInputs = fPITprocessor.GetNumOutputs();
+  AliInfo(Form("Number of trigger inputs: %d",numInputs));
+  for (UInt_t inp=0; inp<numInputs; inp++) {
+    fInputs.AddLast( new AliTriggerInput(fPITprocessor.GetOutputLabel(inp), "SPD", 0) );
+  }
 }
-
 //______________________________________________________________________
-// void AliITSTrigger::GeometryTriggers(TObjArray* digDet, TTree* treeD, AliITSgeom* geom)
-void AliITSTrigger::GeometryTriggers()
-{
-
-//   //   const Int_t nlay = 2;      // not used
-//   //   const Int_t nlad = 240;    // not used
-//   //   const Int_t nstave = 40;   // not used
-//   //   const Int_t ndet = 4;      // not used
-//   //   const Int_t nchip = 5;     // not used
-//   //   const Int_t ntotal = 1200;
-  
-//   Int_t ndigA[5];
-//   Int_t iFOperlayer[2];
-//   Int_t iFOperladder[240];
-//   Int_t iFOperstave[40][2];
-//   //   Int_t iFOperchip[ntotal];   // not used
-//   Int_t iFOperChipinStave[20][40][2];
-  
-//   for (Int_t m=startSPD;m<lastSPD+1;m++) {
-//     iFOperladder[m] = 0;
-//   }
-
-//   for (Int_t k = 0;k<2;k++){
-//     iFOperlayer[k] = 0;
-//     for (Int_t o=0; o<40; o++) {
-//       iFOperstave[o][k] = 0;
-//       for (Int_t ich=0; ich<20; ich++) {
-//     iFOperChipinStave[ich][o][k] = 0;
-//       }
-//     }
-//   }
-
-//   // nFO = 0.0;
-//   Int_t mInStaveCounter = 0;
-//   Int_t checkStave = 0;
-  
-//   // loop over modules
-//   for (Int_t moduleIndex=startSPD; moduleIndex<lastSPD+1; moduleIndex++) {
-//     treeD->GetEvent(moduleIndex);
-//     TClonesArray* digits = (TClonesArray*) (digDet->At(0)); // SPD only.
-
-//     Int_t lay, stav, det;
-//     geom->GetModuleId(moduleIndex,lay,stav,det);
-
-//     ndig = digits->GetEntriesFast();
-
-//     for( Int_t l=0; l<5; l++ ) {
-//       ndigA[l] = 0 ;
-//     }
-//     for( Int_t dig=0; dig<ndig; dig++) {
-//       AliITSdigitSPD* dp = (AliITSdigitSPD*) digits->At(dig);
-//       Int_t column = dp->GetCoord1();
-//       //   Int_t row = dp->GetCoord2();
-//       Int_t chip = Int_t(column/32.);
-//       ndigA[chip]++;
-//     }
-    
-//     if (checkStave != stav) {
-//       mInStaveCounter = 0;
-//     } else {
-//       mInStaveCounter += 1;
-//     }
-
-//     // m 0,.., 239
-//     // stav 1,..,40
-//     // mInStave 0,..,3
-//     // chipInStave 0,..,19
-    
-//     //cout << "m " << m << " stav "  << stav  << " mInStave " << mInStaveCounter << " " <<lay << endl;
-    
-//     for (Int_t ichip=0; ichip<5; ichip++) {
-//       //Int_t seq = (m*5+ichip);
-//       Int_t chipInStave = (mInStaveCounter *5) + ichip;
-      
-//       if (ndigA[ichip] >= 1) {
-//     iFOperladder[moduleIndex]++;
-//     iFOperlayer[lay-1]++;
-//     iFOperstave[stav-1][lay-1]++;
-//     //iFOperHstave[hstav-1][lay-1]++;
-//     iFOperChipinStave[chipInStave][stav-1][lay-1]++;
-//         //    nFO++;
-//       }
-//     }
-//     // SIMPLE FO ---> ANY HIT TRIGGERS
-//     ndigfo += ndig;
-//     checkStave = stav;
-//   } // endl loop over SPD's
-
+void AliITSTrigger::Trigger() {
+  // Performs Pixel Trigger processing of the simulated fast-or signals
 
+  // Get the FO signals for this event
+  AliITSFOSignalsSPD* foSignals = NULL;
+  AliRunLoader* runLoader = AliRunLoader::Instance();
+  AliITSLoader* itsLoader = (AliITSLoader*) runLoader->GetLoader("ITSLoader");
+  if (!itsLoader) {
+    AliError("ITS loader is NULL.");
+  }
+  else {
+    AliBaseLoader* foLoader = itsLoader->GetFOSignalsLoader();
+    if (!foLoader) {
+      AliError("FO signals base loader not retrieved.");
+    }
+    else {
+      foLoader->Load();
+      foSignals = (AliITSFOSignalsSPD*) foLoader->Get();
+    }
+  }
 
-//    if ( ndigfo >= singhitthreshold ) {
-//       // Set input GLOBAL FO
-//       SetInput( "ITS_SPD_GFO_L0" );
-//       // or SetInput( "0x01" );
-//       // or ((AliTriggerInput*)fInputs.At(0))->Set();
-//       // bit1 |= (1 << 1);
-//    }
+  // Process the FO signals
+  if (foSignals) {
+    fPITprocessor.PreprocessFOSignals(foSignals);
+    UInt_t numInputs = fPITprocessor.GetNumOutputs();
+    for (UInt_t inp=0; inp<numInputs; inp++) {
+      if (fPITprocessor.ProcessFOSignalsIndex(inp, foSignals)) {
+       SetInput(fPITprocessor.GetOutputLabel(inp));
+      }
+    }
+  }
+  else {
+    AliError("Fast-OR signals not available. No trigger processing done.");
+  }
 
-   // return bit1;
 }
index c7a920d498deab446aab537fa5454db5fbb7b860..357e4d4f3728353633c9033696a05cdbe4fe1c33 100644 (file)
@@ -5,42 +5,39 @@
 
 /* $Id$ */
 
+////////////////////////////////////////////////////////////////////////
+//                                                                    //
+// Simulates generation of Fast-OR signals from SPD (if needed).      //
+// Processes the Fast-OR signals generated in AliITSsimulationSPD.    //
+// Provides inputs for AliCentralTrigger.                             //
+//                                                                    //
+// Version 2, Henrik Tydesjo, Feb 2009                                //
+// Version 1, D. Elia, C. Jorgensen, Mar 2006                         //
+// Version 0, J. Conrad, E. Lopez Torres, Oct 2005                    //
+//                                                                    //
+////////////////////////////////////////////////////////////////////////
+
 #include "AliTriggerDetector.h"
+#include "AliITSTriggerFOProcessor.h"
 
-class AliITSgeom;
+class AliITSTriggerConditions;
 
-////////////////////////////////////////////////////////////////////////
-//
-// Version 1
-// Modified by D. Elia, C. Jorgensen
-// March 2006
-//
-// Version 0
-// Written by J. Conrad, E. Lopez Torres
-// October 2005
-//
-// AliITSTrigger: implementation of the SPD Fast-OR based triggers.
-//
-////////////////////////////////////////////////////////////////////////
+class AliITSTrigger : public AliTriggerDetector {
 
-class AliITSTrigger : public AliTriggerDetector
-{
  public:
-                   AliITSTrigger();   // constructor
-        virtual   ~AliITSTrigger(){}  // destructor
-   virtual void    CreateInputs();
-   virtual void    Trigger();
+  AliITSTrigger();
+  AliITSTrigger(AliITSTriggerConditions* cond);
+  virtual ~AliITSTrigger() {}
 
-private:
+  virtual void    SetTriggerConditions(AliITSTriggerConditions* cond);
+  virtual void    CreateInputs();
+  virtual void    Trigger();
 
-   Int_t fGlobalFOThreshold;         // minimum number of FOs to fire Global FO trigger
-   Int_t fHighMultFOThreshold;       // minimum number of FOs to fire High Mult FO trigger
+ private:
+  AliITSTriggerFOProcessor fPITprocessor; //! used for processing of FO signals
 
-   void MultiplicityTriggers(TObjArray* digDet, TTree* treeD, AliITSgeom* geom);
-//   void GeometryTriggers(TObjArray* digDet, TTree* treeD, AliITSgeom* geom);
-   void GeometryTriggers();
+  ClassDef( AliITSTrigger, 2 )  // ITS SPD Trigger Detector class
 
-  ClassDef( AliITSTrigger, 1 )  // ITS SPD Trigger Detector class
 };
 
 #endif
diff --git a/ITS/AliITSTriggerAlgorithmConditions.cxx b/ITS/AliITSTriggerAlgorithmConditions.cxx
new file mode 100644 (file)
index 0000000..dbf3393
--- /dev/null
@@ -0,0 +1,135 @@
+////////////////////////////////////////////////////////////////////////////////////
+// Author: Henrik Tydesjo                                                         //
+//                                                                                //
+// Class for storing conditions data from Pixel Trigger (PIT) algorithms.         //
+// This holds a sub set of the conditions data needed.                            //
+// It is used by AliITSTriggerConditions, which holds all the information.        //
+// AliITSTriggerConditions contains a TObjArray of this type.                     //
+//                                                                                //
+////////////////////////////////////////////////////////////////////////////////////
+
+#include "AliITSTriggerAlgorithmConditions.h"
+#include <TObjString.h>
+
+ClassImp(AliITSTriggerAlgorithmConditions)
+
+//__________________________________________________________________________
+AliITSTriggerAlgorithmConditions::AliITSTriggerAlgorithmConditions():
+TObject(),
+fId(0),
+fLabel(TString("label")),
+fDescription(TString("descr")),
+fNumParam(0),
+fParamNames(TObjArray(3)),
+fParamValues(TArrayI(3))
+{
+  // default constructor
+  fParamNames.SetOwner(kTRUE);
+}
+//__________________________________________________________________________
+AliITSTriggerAlgorithmConditions::AliITSTriggerAlgorithmConditions(UShort_t id, const Char_t* label, const Char_t* descr):
+TObject(),
+fId(id),
+fLabel(label),
+fDescription(descr),
+fNumParam(0),
+fParamNames(TObjArray(3)),
+fParamValues(TArrayI(3))
+{
+  // optional constructor
+  fParamNames.SetOwner(kTRUE);
+}
+//__________________________________________________________________________
+AliITSTriggerAlgorithmConditions::AliITSTriggerAlgorithmConditions(const AliITSTriggerAlgorithmConditions& cond):
+TObject(),
+fId(cond.fId),
+fLabel(cond.fLabel),
+fDescription(cond.fDescription),
+fNumParam(cond.fNumParam),
+fParamNames(cond.fParamNames),
+fParamValues(cond.fParamValues)
+{
+  // default constructor
+  fParamNames.SetOwner(kTRUE);
+}
+//__________________________________________________________________________
+AliITSTriggerAlgorithmConditions::~AliITSTriggerAlgorithmConditions() 
+{
+  // destructor
+  ClearParams();
+}
+//__________________________________________________________________________
+AliITSTriggerAlgorithmConditions& AliITSTriggerAlgorithmConditions::operator=(const AliITSTriggerAlgorithmConditions& cond) {
+  // assignment operator
+  if (this!=&cond) {
+    fId = cond.fId;
+    fLabel = cond.fLabel;
+    fDescription = cond.fDescription;
+    fNumParam = cond.fNumParam;
+    fParamNames = cond.fParamNames;
+    fParamValues = cond.fParamValues;
+  }
+  return *this;
+}
+//__________________________________________________________________________
+void AliITSTriggerAlgorithmConditions::ClearParams() {
+  // clears parameter list
+  fParamNames.Clear();
+  fNumParam=0;
+}
+//__________________________________________________________________________
+void AliITSTriggerAlgorithmConditions::AddParam(const Char_t* name, Int_t value) {
+  // adds a new parameter with name 'name' and value 'value'
+  // if the name is already present in the list, the parameter value will be over-written
+  UShort_t findIndex=fNumParam;
+  for (UInt_t i=0; i<fNumParam; i++) {
+    if (((TObjString*)fParamNames.At(i))->GetString().CompareTo(name, TString::kIgnoreCase) == 0) {
+      findIndex = i;
+      break;
+    }
+  }
+  if (findIndex<fNumParam) {
+    fParamValues[findIndex]=value;
+  }
+  else {
+    fParamNames.AddAtAndExpand(new TObjString(name),fNumParam);
+    Int_t valSize = fParamValues.GetSize();
+    if (valSize<=fNumParam) fParamValues.Set(valSize*2);
+    fParamValues[fNumParam]=value;
+    fNumParam++;
+  }
+}
+//__________________________________________________________________________
+const Char_t* AliITSTriggerAlgorithmConditions::GetParamNameI(UShort_t index) const {
+  // returns parameter name for parameter at position index
+  if (index>=fNumParam) {
+    Error("AliITSTriggerAlgorithmConditions::GetParamNameI", "index %d out of range", index);
+    return "dummy";
+  }
+  return ((TObjString*)fParamNames.At(index))->GetString().Data();
+}
+//__________________________________________________________________________
+Int_t AliITSTriggerAlgorithmConditions::GetParamValueI(UShort_t index) const {
+  // returns paramter value at position index
+  if (index>=fNumParam) {
+    Error("AliITSTriggerAlgorithmConditions::GetParamValueI", "index %d out of range", index);
+    return -1;
+  }
+  return fParamValues.At(index);
+}
+//__________________________________________________________________________
+Int_t AliITSTriggerAlgorithmConditions::GetParamValueN(const Char_t* name) const {
+  // returns parameter value for parameter with name 'name'
+  UShort_t findIndex=fNumParam;
+  for (UInt_t i=0; i<fNumParam; i++) {
+    if (((TObjString*)fParamNames.At(i))->GetString().CompareTo(name, TString::kIgnoreCase) == 0) {
+      findIndex = i;
+      break;
+    }
+  }
+  if (findIndex==fNumParam) {
+    Error("AliITSTriggerAlgorithmConditions::GetParamValueN", "name %s not found", name);
+    return -1;
+  }
+  return fParamValues.At(findIndex);
+}
diff --git a/ITS/AliITSTriggerAlgorithmConditions.h b/ITS/AliITSTriggerAlgorithmConditions.h
new file mode 100644 (file)
index 0000000..59bfd12
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef AliITSTriggerAlgorithmConditions_H
+#define AliITSTriggerAlgorithmConditions_H
+
+////////////////////////////////////////////////////////////////////////////////////
+// Author: Henrik Tydesjo                                                         //
+//                                                                                //
+// Class for storing conditions data from Pixel Trigger (PIT) algorithms.         //
+// This holds a sub set of the conditions data needed.                            //
+// It is used by AliITSTriggerConditions, which holds all the information.        //
+// AliITSTriggerConditions contains a TObjArray of this type.                     //
+//                                                                                //
+////////////////////////////////////////////////////////////////////////////////////
+
+#include <TObject.h>
+#include <TString.h>
+#include <TObjArray.h>
+#include <TArrayI.h>
+
+class AliITSTriggerAlgorithmConditions : public TObject {
+
+ public:
+  AliITSTriggerAlgorithmConditions();
+  AliITSTriggerAlgorithmConditions(UShort_t id, const Char_t* label, const Char_t* descr);
+  AliITSTriggerAlgorithmConditions(const AliITSTriggerAlgorithmConditions& cond);
+  virtual ~AliITSTriggerAlgorithmConditions();
+  AliITSTriggerAlgorithmConditions& operator=(const AliITSTriggerAlgorithmConditions& cond);
+
+  virtual UShort_t      GetID() const {return fId;}
+  virtual const Char_t* GetLabel() const {return fLabel.Data();}
+  virtual const Char_t* GetDescription() const {return fDescription.Data();}
+
+  virtual void          SetID(UShort_t id) {fId=id;}
+  virtual void          SetLabel(const Char_t* label) {fLabel=label;}
+  virtual void          SetDescription(const Char_t* descr) {fDescription=descr;}
+
+  virtual void          ClearParams();
+
+  virtual void          AddParam(const Char_t* name, Int_t value);
+
+  virtual UShort_t      GetNumParam() const {return fNumParam;}
+  virtual const Char_t* GetParamNameI(UShort_t index) const;
+  virtual Int_t         GetParamValueI(UShort_t index) const;
+  virtual Int_t         GetParamValueN(const Char_t* name) const;
+
+
+ protected:
+  UShort_t  fId;          // ID of output (1-10 for real system)
+  TString   fLabel;       // label of output (ex: OSH1)
+  TString   fDescription; // description of output
+  UShort_t  fNumParam;    // Number of parameters used
+  TObjArray fParamNames;  // list of parameter names (strings)
+  TArrayI   fParamValues; // list of parameter values (integers)
+  
+  ClassDef(AliITSTriggerAlgorithmConditions,1) // Trigger algorithm conditions class
+};
+
+#endif
diff --git a/ITS/AliITSTriggerConditions.cxx b/ITS/AliITSTriggerConditions.cxx
new file mode 100644 (file)
index 0000000..1fd6431
--- /dev/null
@@ -0,0 +1,575 @@
+////////////////////////////////////////////////////////////////////////////////////
+// Author: Henrik Tydesjo                                                         //
+//                                                                                //
+// Implementation of conditions data from Pixel Trigger (PIT)                     //
+//                                                                                //
+// The information is propagated from pixel trigger system to DCS file exchange   //
+// server (text file format). The ReadFromTextFile method will populate this      //
+// object with the values from the text file. Via a Preprocessor, this object     //
+// can be stored in OCDB.                                                         //
+//                                                                                //
+// One can also manually create conditions data that may be interesting for       //
+// simulation.                                                                    //
+//                                                                                //
+////////////////////////////////////////////////////////////////////////////////////
+
+#include "AliITSTriggerConditions.h"
+#include "AliITSTriggerAlgorithmConditions.h"
+#include <TError.h>
+#include <fstream>
+
+ClassImp(AliITSTriggerConditions)
+
+//__________________________________________________________________________________
+AliITSTriggerConditions::AliITSTriggerConditions() :
+TObject(),
+fRunNumber(0),
+fFirmWareVersion(0),
+fGlobalDescription("n/a"),
+fVersionRegister(0),
+fInputConditionsVersion(0),
+fParametersVersion(0),
+fInActiveChips(1200),
+fNumAlgo(0),
+fAlgoList(TObjArray(10))
+{
+  // default constructor
+  fAlgoList.SetOwner(kTRUE);
+}
+//__________________________________________________________________________________
+AliITSTriggerConditions::AliITSTriggerConditions(const AliITSTriggerConditions& cond) :
+TObject(),
+fRunNumber(cond.fRunNumber),
+fFirmWareVersion(cond.fFirmWareVersion),
+fGlobalDescription(cond.fGlobalDescription),
+fVersionRegister(cond.fVersionRegister),
+fInputConditionsVersion(cond.fInputConditionsVersion),
+fParametersVersion(cond.fParametersVersion),
+fInActiveChips(cond.fInActiveChips),
+fNumAlgo(cond.fNumAlgo),
+fAlgoList(cond.fAlgoList)
+{
+  // copy constructor
+  fAlgoList.SetOwner(kTRUE);
+}
+//__________________________________________________________________________________
+AliITSTriggerConditions::~AliITSTriggerConditions() 
+{
+  // destructor
+  ClearAlgorithms();
+}
+//______________________________________________________________________
+AliITSTriggerConditions& AliITSTriggerConditions::operator=(const AliITSTriggerConditions& cond) {
+  // assignment operator
+  if (this!=&cond) {
+    fRunNumber = cond.fRunNumber;
+    fFirmWareVersion = cond.fFirmWareVersion;
+    fGlobalDescription = cond.fGlobalDescription;
+    fVersionRegister = cond.fVersionRegister;
+    fInputConditionsVersion = cond.fInputConditionsVersion;
+    fParametersVersion = cond.fParametersVersion;
+    fInActiveChips = cond.fInActiveChips;
+    fNumAlgo = cond.fNumAlgo;
+    fAlgoList = cond.fAlgoList;
+  }
+  return *this;
+}
+//__________________________________________________________________________________
+void AliITSTriggerConditions::DumpAll() const {
+  // Dumps all conditions data
+
+  printf("[Header]\n");
+  printf("RUN_NUMBER = %d\n",fRunNumber);
+  printf("PROCESSING_FIRMWARE_VERSION = %d\n",fFirmWareVersion);
+  printf("GLOBAL_DESCRIPTION = %s\n",fGlobalDescription.Data());
+  printf("VERSION_REGISTER_VALUE = %d\n",fVersionRegister);
+  printf("INPUT_CONDITIONS_VERSION = %d\n",fInputConditionsVersion);
+  printf("PARAMETERS_VERSION = %d\n",fParametersVersion);
+  printf("\n");
+
+  printf("[Outputs]\n");
+  for (UInt_t i=0; i<fNumAlgo; i++) {
+    printf("%d = '%s', '%s'\n", GetAlgoIDI(i), GetAlgoLabelI(i), GetAlgoDescriptionI(i));
+  }
+  printf("\n");
+
+  printf("[Output_parameters]\n");
+  for (UInt_t i=0; i<fNumAlgo; i++) {
+    printf("%d =", GetAlgoIDI(i));
+    for (Short_t p=0; p<GetNumAlgoParamI(i); p++) {
+      printf(" '%s', %d;", GetAlgoParamNameII(i,p), GetAlgoParamValueII(i,p));
+    }
+    printf("\n");
+  }
+  printf("\n");
+
+  printf("[Active_chips]\n");
+  for (UInt_t eq=0; eq<20; eq++) {
+    for (UInt_t hs=0; hs<6; hs++) {
+      UInt_t nActiveOnHs = 0;
+      TString inactiveStr = "";
+      for (UInt_t chip=0; chip<10; chip++) {
+       Bool_t isChipActive = IsChipActive(eq,hs,chip);
+       inactiveStr.Append(Form("%d",isChipActive));
+       nActiveOnHs+=isChipActive;
+      }
+      if (nActiveOnHs<10) {
+       printf("%d,%c,%d=%s\n", eq%10, eq<10 ? 'A' : 'C', hs, inactiveStr.Data());
+      }
+    }
+  }
+
+}
+//__________________________________________________________________________________
+void AliITSTriggerConditions::ResetAll() {
+  // clear all data, and put default values
+  fRunNumber=0;
+  fFirmWareVersion=0;
+  fGlobalDescription="n/a";
+  fVersionRegister=0;
+  fInputConditionsVersion=0;
+  fParametersVersion=0;
+  ResetInActiveChips();
+  ClearAlgorithms();
+}
+//__________________________________________________________________________________
+void AliITSTriggerConditions::ClearAlgorithms() {
+  // clears the list of algorithms
+  fAlgoList.Clear();
+  fNumAlgo=0;
+}
+//__________________________________________________________________________________
+void AliITSTriggerConditions::ClearAlgoParamsI(UShort_t aIndex) {
+  // clears the list of parameters for algorithm with index aIndex  
+  if (aIndex>=fNumAlgo) {
+    Error("AliITSTriggerConditions::ClearAlgoParamsI", "index %d out of range", aIndex);
+    return;
+  }
+  ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(aIndex))->ClearParams();
+}
+//__________________________________________________________________________________
+void AliITSTriggerConditions::ClearAlgoParamsL(const Char_t* aLabel) {
+  // clears the list of parameters for algorithm with label aLabel
+  UShort_t findIndex=fNumAlgo;
+  for (UInt_t i=0; i<fNumAlgo; i++) {
+    if (strcmp(((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetLabel(),aLabel) == 0) {
+      findIndex = i;
+      break;
+    }
+  }
+  if (findIndex==fNumAlgo) {
+    Error("AliITSTriggerConditions::ClearAlgoParamsL", "label %s not found", aLabel);
+  }
+  ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(findIndex))->ClearParams();
+}
+//__________________________________________________________________________________
+void AliITSTriggerConditions::AddAlgo(UShort_t id, const Char_t* aLabel, const Char_t* aDescr) {
+  // adds a new algorithm with id 'id', label aLabel, and description aDescr
+  // if the id or label is already used in the list of algorithms, the old entry will be over-written
+  UShort_t findIndex=fNumAlgo;
+  for (UInt_t i=0; i<fNumAlgo; i++) {
+    if (strcmp(((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetLabel(), aLabel) == 0 || 
+       ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetID() == id ) {
+      findIndex = i;
+      break;
+    }
+  }
+  if (findIndex<fNumAlgo) {
+    delete fAlgoList.At(findIndex);
+    fAlgoList.AddAt(new AliITSTriggerAlgorithmConditions(id,aLabel,aDescr),findIndex);
+  }
+  else {
+    fAlgoList.AddAtAndExpand(new AliITSTriggerAlgorithmConditions(id,aLabel,aDescr),fNumAlgo);
+    fNumAlgo++;
+  }
+}
+//__________________________________________________________________________________
+void AliITSTriggerConditions::AddAlgoParam(UShort_t id, const Char_t* name, Int_t value) {
+  // adds a new parameter with name 'name' and value 'value', for the algorithm with id 'id'
+  UShort_t findIndex=fNumAlgo;
+  for (UInt_t i=0; i<fNumAlgo; i++) {
+    if (((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetID() == id) {
+      findIndex = i;
+      break;
+    }
+  }
+  if (findIndex==fNumAlgo) {
+    Error("AliITSTriggerConditions::AddAlgoParam", "id %d not found", id);
+    return;
+  }
+  ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(findIndex))->AddParam(name, value);
+}
+//__________________________________________________________________________________
+Short_t AliITSTriggerConditions::GetAlgoIndexL(const Char_t* aLabel) const {
+  // returns the index for the algorithm with label aLabel
+  UShort_t findIndex=fNumAlgo;
+  for (UInt_t i=0; i<fNumAlgo; i++) {
+    if (strcmp(((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetLabel(), aLabel) == 0) {
+      findIndex = i;
+      break;
+    }
+  }
+  if (findIndex==fNumAlgo) {
+    Error("AliITSTriggerConditions::GetAlgoIndexL", "label %s not found", aLabel);
+    return -1;
+  }
+  return findIndex;
+}
+//__________________________________________________________________________________
+Short_t AliITSTriggerConditions::GetAlgoIDI(UShort_t aIndex) const {
+  // returns the ID for the algorithm with index aIndex (in real life, could be 1-10)
+  if (aIndex>=fNumAlgo) {
+    Error("AliITSTriggerConditions::GetAlgoIDI", "index %d out of range", aIndex);
+    return -1;
+  }
+  return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(aIndex))->GetID();
+}
+//__________________________________________________________________________________
+const Char_t* AliITSTriggerConditions::GetAlgoLabelI(UShort_t aIndex) const {
+  // returns the label for the algorithm with index aIndex
+  if (aIndex>=fNumAlgo) {
+    Error("AliITSTriggerConditions::GetAlgoLabelI", "index %d out of range", aIndex);
+    return "";
+  }
+  return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(aIndex))->GetLabel();
+}
+//__________________________________________________________________________________
+const Char_t* AliITSTriggerConditions::GetAlgoDescriptionI(UShort_t aIndex) const {
+  // returns the description for the algorithm with index aIndex
+  if (aIndex>=fNumAlgo) {
+    Error("AliITSTriggerConditions::GetAlgoDescriptionI", "index %d out of range", aIndex);
+    return "";
+  }
+  return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(aIndex))->GetDescription();
+}
+//__________________________________________________________________________________
+Short_t AliITSTriggerConditions::GetNumAlgoParamI(UShort_t aIndex) const {
+  // returns the number of parameters, corresponding to the algorithm with index aIndex
+  if (aIndex>=fNumAlgo) {
+    Error("AliITSTriggerConditions::GetNumAlgoParamI", "index %d out of range", aIndex);
+    return -1;
+  }
+  return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(aIndex))->GetNumParam();
+}
+//__________________________________________________________________________________
+const Char_t* AliITSTriggerConditions::GetAlgoParamNameII(UShort_t aIndex, UShort_t pIndex) const {
+  // returns the parameter name for the parameter with index pIndex, corresponding to the algorithm with index aIndex
+  if (aIndex>=fNumAlgo) {
+    Error("AliITSTriggerConditions::GetAlgoParamNameII", "index %d out of range", aIndex);
+    return "";
+  }
+  return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(aIndex))->GetParamNameI(pIndex);
+}
+//__________________________________________________________________________________
+Int_t AliITSTriggerConditions::GetAlgoParamValueII(UShort_t aIndex, UShort_t pIndex) const {
+  // returns the parameter value for the parameter with index pIndex, corresponding to the algorithm with index aIndex
+  if (aIndex>=fNumAlgo) {
+    Error("AliITSTriggerConditions::GetAlgoParamValueII", "index %d out of range", aIndex);
+    return -1;
+  }
+  return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(aIndex))->GetParamValueI(pIndex);
+}
+//__________________________________________________________________________________
+Int_t AliITSTriggerConditions::GetAlgoParamValueIN(UShort_t aIndex, const Char_t* pName) const {
+  // returns parameter value for the parameter named pName, corresponding to the algorithm with index aIndex
+  if (aIndex>=fNumAlgo) {
+    Error("AliITSTriggerConditions::GetAlgoParamValueIN", "index %d out of range", aIndex);
+    return -1;
+  }
+  return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(aIndex))->GetParamValueN(pName);
+}
+//__________________________________________________________________________________
+Short_t AliITSTriggerConditions::GetNumAlgoParamL(const Char_t* aLabel) const {
+  // returns the number of parameters, corresponding to the algorithm with label aLabel
+  UShort_t findIndex=fNumAlgo;
+  for (UInt_t i=0; i<fNumAlgo; i++) {
+    if (strcmp(((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetLabel(), aLabel) == 0) {
+      findIndex = i;
+      break;
+    }
+  }
+  if (findIndex==fNumAlgo) {
+    Error("AliITSTriggerConditions::GetNumAlgoParamL", "label %s not found", aLabel);
+    return -1;
+  }
+  return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(findIndex))->GetNumParam();
+}
+//__________________________________________________________________________________
+const Char_t* AliITSTriggerConditions::GetAlgoParamNameLI(const Char_t* aLabel, UShort_t pIndex) const {
+  // returns parameter name for the parameter with index pIndex, corresponding to the algorithm with label aLabel
+  UShort_t findIndex=fNumAlgo;
+  for (UInt_t i=0; i<fNumAlgo; i++) {
+    if (strcmp(((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetLabel(), aLabel) == 0) {
+      findIndex = i;
+      break;
+    }
+  }
+  if (findIndex==fNumAlgo) {
+    Error("AliITSTriggerConditions::GetAlgoParamNameLI", "label %s not found", aLabel);
+    return "";
+  }
+  return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(findIndex))->GetParamNameI(pIndex);
+}
+//__________________________________________________________________________________
+Int_t AliITSTriggerConditions::GetAlgoParamValueLI(const Char_t* aLabel, UShort_t pIndex) const {
+  // returns parameter value for the parameter with index pIndex, corresponding to the algorithm with label aLabel
+  UShort_t findIndex=fNumAlgo;
+  for (UInt_t i=0; i<fNumAlgo; i++) {
+    if (strcmp(((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetLabel(), aLabel) == 0) {
+      findIndex = i;
+      break;
+    }
+  }
+  if (findIndex==fNumAlgo) {
+    Error("AliITSTriggerConditions::GetAlgoParamValueLI", "label %s not found", aLabel);
+    return -1;
+  }
+  return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(findIndex))->GetParamValueI(pIndex);
+}
+//__________________________________________________________________________________
+Int_t AliITSTriggerConditions::GetAlgoParamValueLN(const Char_t* aLabel, const Char_t* pName) const {
+  // returns parameter value for the parameter named pName, corresponding to the algorithm with label aLabel
+  UShort_t findIndex=fNumAlgo;
+  for (UInt_t i=0; i<fNumAlgo; i++) {
+    if (strcmp(((AliITSTriggerAlgorithmConditions*)fAlgoList.At(i))->GetLabel(), aLabel) == 0) {
+      findIndex = i;
+      break;
+    }
+  }
+  if (findIndex==fNumAlgo) {
+    Error("AliITSTriggerConditions::GetAlgoParamValueLN", "label %s not found", aLabel);
+    return -1;
+  }
+  return ((AliITSTriggerAlgorithmConditions*)fAlgoList.At(findIndex))->GetParamValueN(pName);
+}
+//__________________________________________________________________________________
+UInt_t AliITSTriggerConditions::GetChipKey(Int_t eq, Int_t hs, Int_t chip) const {
+  // translates eq,hs,chip numbers into one integer key (0-1199)
+  if (eq<0 || eq>=20 || hs<0 || hs>=6 || chip<0 || chip>=10) {
+    Error("AliITSTriggerConditions::GetChipKey", "eq,hs,chip = %d,%d,%d out of range",eq,hs,chip);
+    return 0;
+  }
+  return eq*60 + hs*10 + chip;
+}
+//__________________________________________________________________________________
+void AliITSTriggerConditions::GetChipFromKey(UInt_t key, Int_t& eq, Int_t& hs, Int_t& chip) const {
+  // translates a chip key back into eq,hs,chip numbers
+  if (key>=1200) {
+    Error("AliITSTriggerConditions::GetChipFromKey", "key = %d out of range", key);
+    return;
+  }
+  eq   = key/60;
+  hs   = (key%60)/10;
+  chip = key%10;
+}
+//__________________________________________________________________________________
+Bool_t AliITSTriggerConditions::GetNextInActiveChip(Int_t& eq, Int_t& hs, Int_t& chip) const {
+  // Returns true if an in-active chip was found (start looking after the bit number
+  // corresponding to the input parameters eq,hs,chip).
+  // If either of eq,hs,chip < 0 , start from beginning of TBits array.
+  // See example of usage in AliITSDetTypeRec::RemoveFastOrFiredInActive.
+  UInt_t searchIndex;
+  if (eq<0 || hs<0 || chip<0) searchIndex = 0;
+  else searchIndex = GetChipKey(eq, hs, chip) + 1;
+  UInt_t nextIndex = fInActiveChips.FirstSetBit(searchIndex);
+  if (nextIndex==1200) return kFALSE;
+  GetChipFromKey(nextIndex, eq, hs, chip);
+  return kTRUE;
+}
+//__________________________________________________________________________________
+void AliITSTriggerConditions::DumpInActiveChips() const {
+  // Prints a list of all inactive chips
+  UInt_t startBit=0;
+  UInt_t occ=0;
+  while (startBit<1200) {
+    startBit = fInActiveChips.FirstSetBit(startBit);
+    if (startBit<1200) {
+      occ++;
+      Int_t eq,hs,chip;
+      GetChipFromKey(startBit,eq,hs,chip);
+      printf("%3d: %d,%d,%d\n",occ,eq,hs,chip);
+      startBit++;
+    }
+  }
+}
+//__________________________________________________________________________________
+void AliITSTriggerConditions::ReadFromTextFile(const Char_t* fileName) {
+  // Reads conditions from text file (file format is used online by PIT system)
+
+  ResetAll();
+
+  const Int_t maxS = 500;
+  enum headers {HEAD, OUTPUT, PARAM, ACTIVECHIP};
+
+  ifstream file;
+  file.open(fileName, ifstream::in);
+  if (file.fail()) {
+    Error("AliITSTriggerConditions::ReadFromTextFile","No file (%s) present.",fileName);
+    return;
+  }
+
+  Int_t headType = -1; // no header read from start
+  UInt_t nl = 0;
+  Char_t cline[maxS];
+  while(!file.eof()) {
+    // *** get line
+    nl++;
+    file.getline(cline,maxS);
+    TString line(cline);
+
+    // *** remove comments from line
+    Int_t skipPos = line.First('#');
+    if (skipPos>=0) {
+      line.Remove(skipPos,maxS);
+    }
+
+    // *** check what type of information the line has (header or not...)
+    Int_t brackPos1 = line.First('[');
+    Int_t brackPos2 = line.First(']');
+    if (brackPos1==0 && brackPos2-1>brackPos1) {
+      // *** parse header line (header has to come first on the line)
+      TString headword = line(brackPos1+1,brackPos2-1-brackPos1);
+      if      (headword.CompareTo("Header",           TString::kIgnoreCase) == 0) headType = HEAD;
+      else if (headword.CompareTo("Outputs",          TString::kIgnoreCase) == 0) headType = OUTPUT;
+      else if (headword.CompareTo("Output_parameters",TString::kIgnoreCase) == 0) headType = PARAM;
+      else if (headword.CompareTo("Active_chips",     TString::kIgnoreCase) == 0) headType = ACTIVECHIP;
+    }
+    else {
+      // *** parse non-header line
+
+      // HEAD data
+      if (headType==HEAD) {
+       TString descrWord, valueWord;
+       if (! SplitStringIn2(line,descrWord,valueWord,'=')) continue;
+       descrWord.ReplaceAll(" ","");
+       valueWord.Remove(TString::kBoth,' ');
+
+       if (descrWord.CompareTo("RUN_NUMBER",TString::kIgnoreCase) == 0 && valueWord.IsDigit()) {
+         SetRunNumber(valueWord.Atoi());
+       }
+       else if (descrWord.CompareTo("PROCESSING_FIRMWARE_VERSION",TString::kIgnoreCase) == 0 && valueWord.IsDigit()) {
+         SetFirmWareVersion(valueWord.Atoi());
+       }
+       else if (descrWord.CompareTo("GLOBAL_DESCRIPTION",TString::kIgnoreCase) == 0) {
+         SetGlobalDescription(valueWord.Data());
+       }
+       else if (descrWord.CompareTo("VERSION_REGISTER_VALUE",TString::kIgnoreCase) == 0 && valueWord.IsDigit()) {
+         SetVersionRegister(valueWord.Atoi());
+       }
+       else if (descrWord.CompareTo("INPUT_CONDITIONS_VERSION",TString::kIgnoreCase) == 0 && valueWord.IsDigit()) {
+         SetInputConditionsVersion(valueWord.Atoi());
+       }
+       else if (descrWord.CompareTo("PARAMETERS_VERSION",TString::kIgnoreCase) == 0 && valueWord.IsDigit()) {
+         SetParametersVersion(valueWord.Atoi());
+       }
+      }
+      // OUTPUT data
+      else if (headType==OUTPUT) {
+       TString idWord, labelWord, descrWord, restWord;
+       if (! SplitStringIn2(line,idWord,restWord,'=')) continue;
+       if (! idWord.IsDigit()) continue;
+       if (! SplitStringIn2(restWord,labelWord,descrWord,',')) continue;
+       labelWord = GetStringBetween(labelWord,'\'','\'');
+       descrWord = GetStringBetween(descrWord,'\'','\'');
+       if (labelWord.Length()==0 || descrWord.Length()==0) continue;
+       //      printf("id: %d , label '%s' , descr '%s'\n", idWord.Atoi(),labelWord.Data(),descrWord.Data());
+       AddAlgo(idWord.Atoi(),labelWord.Data(),descrWord.Data());
+      }
+      // PARAM data
+      else if (headType==PARAM) {
+       TString idWord, restWord;
+       if (! SplitStringIn2(line,idWord,restWord,'=')) continue;
+       if (! idWord.IsDigit()) continue;
+       while (restWord.Length()>0) {
+         TString parWord, nameWord, valWord;
+         SplitStringIn2(restWord,parWord,restWord,';');
+         if (! SplitStringIn2(parWord,nameWord,valWord,',')) break;
+         nameWord = GetStringBetween(nameWord,'\'','\'');
+         if (nameWord.Length()==0 || valWord.Length()==0 || ! valWord.IsDigit()) break;
+         //      printf("id %d , param %s , value %d\n",idWord.Atoi(),nameWord.Data(),valWord.Atoi());
+         AddAlgoParam(idWord.Atoi(),nameWord.Data(),valWord.Atoi());
+       }
+      }
+      // ACTIVECHIP data
+      if (headType==ACTIVECHIP) {
+       TString eqWord, sideWord, hsWord, chipWord, restWord;
+       if (! SplitStringIn2(line,eqWord,restWord,',')) continue;
+       if (! eqWord.IsDigit()) continue;
+       UInt_t eq = eqWord.Atoi();
+       if (eq>=20) continue;
+       if (! SplitStringIn2(restWord,sideWord,restWord,',')) continue;
+       sideWord.ReplaceAll(" ","");
+       if (sideWord.CompareTo("A",TString::kIgnoreCase) == 0) {}
+       else if (sideWord.CompareTo("C",TString::kIgnoreCase) == 0) eq+=10;
+       else continue;
+       if (! SplitStringIn2(restWord,hsWord,chipWord,'=')) continue;
+       if (! hsWord.IsDigit()) continue;
+       UInt_t hs = hsWord.Atoi();
+       if (hs>=6) continue;
+       chipWord.ReplaceAll(" ","");
+       if (chipWord.Length()!=10) continue;
+       for (UInt_t chip=0; chip<10; chip++) {
+         if (chipWord[9-chip]=='0') {
+           //      printf("Chip %d,%d,%d inactive\n",eq,hs,chip);
+           SetInActiveChip(eq,hs,chip);
+         }
+       }
+      }
+
+    }
+  }
+  file.close();
+}
+//__________________________________________________________________________________
+Bool_t AliITSTriggerConditions::SplitStringIn2(TString orig, TString& word1, TString& word2, Char_t sep) {
+  // splits a string in two parts (one before separator character and one after)
+  Int_t sepPos = orig.First(sep);
+  if (sepPos<0) sepPos = orig.Length();
+  word1 = orig(0,sepPos);
+  word2 = orig(sepPos+1,orig.Length());
+  return (word1.Length()>0 && word2.Length()>0);
+}
+//__________________________________________________________________________________
+TString AliITSTriggerConditions::GetStringBetween(TString orig, Char_t sep1, Char_t sep2) {
+  // returns string between separator character 1 and separator character 2
+  Int_t pos1 = orig.First(sep1);
+  if (pos1<0) return "";
+  TString ret = orig(pos1+1,orig.Length());
+  Int_t pos2 = ret.First(sep2);
+  if (pos2<0) return "";
+  ret = ret(0,pos2);
+  return ret;
+}
+//__________________________________________________________________________________
+Bool_t AliITSTriggerConditions::IsEqualTo(AliITSTriggerConditions *cond) const {
+  // checks if this object contains the same information as the input cond object
+  if (fRunNumber != cond->GetRunNumber()) return kFALSE;
+  if (fFirmWareVersion != cond->GetFirmWareVersion()) return kFALSE;
+  if (fGlobalDescription.CompareTo(cond->GetGlobalDescription()) !=0) return kFALSE;
+  if (fVersionRegister != cond->GetVersionRegister()) return kFALSE;
+  if (fInputConditionsVersion != cond->GetInputConditionsVersion()) return kFALSE;
+  if (fParametersVersion != cond->GetParametersVersion()) return kFALSE;
+
+  for (UInt_t eq=0; eq<20; eq++) {
+    for (UInt_t hs=0; hs<6; hs++) {
+      for (UInt_t chip=0; chip<10; chip++) {
+       if (IsChipActive(eq,hs,chip) != cond->IsChipActive(eq,hs,chip)) return kFALSE;
+      }
+    }
+  }
+
+  if (fNumAlgo != cond->GetNumAlgo()) return kFALSE;
+  for (Short_t alg1=0; alg1<fNumAlgo; alg1++) {
+    Short_t alg2 = cond->GetAlgoIndexL(GetAlgoLabelI(alg1));
+    if (alg2<0) return kFALSE;
+    if (GetAlgoIDI(alg1) != cond->GetAlgoIDI(alg2)) return kFALSE;
+    if (strcmp(GetAlgoDescriptionI(alg1), cond->GetAlgoDescriptionI(alg2)) != 0) return kFALSE;
+    if (GetNumAlgoParamI(alg1) != cond->GetNumAlgoParamI(alg2)) return kFALSE;
+    for (Short_t par1=0; par1<GetNumAlgoParamI(alg1); par1++) {      
+      const Char_t* paramName = GetAlgoParamNameII(alg1,par1);
+      if (GetAlgoParamValueIN(alg1,paramName) != cond->GetAlgoParamValueIN(alg2,paramName)) return kFALSE;
+    }
+  }
+
+  return kTRUE;
+}
diff --git a/ITS/AliITSTriggerConditions.h b/ITS/AliITSTriggerConditions.h
new file mode 100644 (file)
index 0000000..f1e8b74
--- /dev/null
@@ -0,0 +1,105 @@
+#ifndef AliITSTriggerConditions_H
+#define AliITSTriggerConditions_H
+
+////////////////////////////////////////////////////////////////////////////////////
+// Author: Henrik Tydesjo                                                         //
+//                                                                                //
+// Implementation of conditions data from Pixel Trigger (PIT)                     //
+//                                                                                //
+// The information is propagated from pixel trigger system to DCS file exchange   //
+// server (text file format). The ReadFromTextFile method will populate this      //
+// object with the values from the text file. Via a Preprocessor, this object     //
+// can be stored in OCDB.                                                         //
+//                                                                                //
+// One can also manually create conditions data that may be interesting for       //
+// simulation.                                                                    //
+//                                                                                //
+////////////////////////////////////////////////////////////////////////////////////
+
+#include <TObject.h>
+#include <TObjArray.h>
+#include <TString.h>
+#include <TBits.h>
+
+class AliITSTriggerConditions : public TObject{
+ public:
+    AliITSTriggerConditions();
+    AliITSTriggerConditions(const AliITSTriggerConditions& cond);
+    virtual ~AliITSTriggerConditions();
+    AliITSTriggerConditions& operator=(const AliITSTriggerConditions& cond);
+
+    virtual Bool_t        IsEqualTo(AliITSTriggerConditions *cond) const;
+
+    virtual void          DumpAll() const;
+    virtual void          ResetAll();
+
+    virtual void          SetRunNumber(UInt_t num) {fRunNumber=num;}
+    virtual UInt_t        GetRunNumber() const {return fRunNumber;}
+    virtual void          SetFirmWareVersion(UShort_t num) {fFirmWareVersion=num;}
+    virtual UShort_t      GetFirmWareVersion() const {return fFirmWareVersion;}
+    virtual void          SetGlobalDescription(const Char_t* descr) {fGlobalDescription=descr;}
+    virtual const Char_t* GetGlobalDescription() const {return fGlobalDescription.Data();}
+    virtual void          SetVersionRegister(UShort_t num) {fVersionRegister=num;}
+    virtual UShort_t      GetVersionRegister() const {return fVersionRegister;}
+    virtual void          SetInputConditionsVersion(UShort_t num) {fInputConditionsVersion=num;}
+    virtual UShort_t      GetInputConditionsVersion() const {return fInputConditionsVersion;}
+    virtual void          SetParametersVersion(UShort_t num) {fParametersVersion=num;}
+    virtual UShort_t      GetParametersVersion() const {return fParametersVersion;}
+
+    virtual void          SetInActiveChip(UInt_t eq, UInt_t hs, UInt_t chip) 
+      {fInActiveChips.SetBitNumber(GetChipKey(eq,hs,chip));}
+    virtual void          ResetInActiveChips() {fInActiveChips.ResetAllBits();}
+    virtual void          SetActiveChip(UInt_t eq, UInt_t hs, UInt_t chip) 
+      {fInActiveChips.SetBitNumber(GetChipKey(eq,hs,chip),kFALSE);}
+    virtual void          DumpInActiveChips() const;
+
+    virtual Bool_t        IsChipActive(UInt_t eq, UInt_t hs, UInt_t chip) const 
+      {return !IsChipInActive(eq,hs,chip);}
+    virtual Bool_t        IsChipInActive(UInt_t eq, UInt_t hs, UInt_t chip) const 
+      {return fInActiveChips.TestBitNumber(GetChipKey(eq,hs,chip));}
+    virtual Bool_t        GetNextInActiveChip(Int_t& eq, Int_t& hs, Int_t& chip) const;
+
+    virtual void          ClearAlgorithms();
+    virtual void          ClearAlgoParamsI(UShort_t aIndex);
+    virtual void          ClearAlgoParamsL(const Char_t* aLabel);
+
+    virtual void          AddAlgo(UShort_t id, const Char_t* aLabel, const Char_t* aDescr);
+    virtual void          AddAlgoParam(UShort_t id, const Char_t* pName, Int_t pValue);
+
+    virtual UShort_t      GetNumAlgo() const {return fNumAlgo;}
+    virtual Short_t       GetAlgoIndexL(const Char_t* aLabel) const;
+    virtual Short_t       GetAlgoIDI(UShort_t aIndex) const;
+    virtual const Char_t* GetAlgoLabelI(UShort_t aIndex) const;
+    virtual const Char_t* GetAlgoDescriptionI(UShort_t aIndex) const;
+
+    virtual Short_t       GetNumAlgoParamI(UShort_t aIndex) const;
+    virtual const Char_t* GetAlgoParamNameII(UShort_t aIndex, UShort_t pIndex) const;
+    virtual Int_t         GetAlgoParamValueII(UShort_t aIndex, UShort_t pIndex) const;
+    virtual Int_t         GetAlgoParamValueIN(UShort_t aIndex, const Char_t* pName) const;
+    virtual Short_t       GetNumAlgoParamL(const Char_t* aLabel) const;
+    virtual const Char_t* GetAlgoParamNameLI(const Char_t* aLabel, UShort_t pIndex) const;
+    virtual Int_t         GetAlgoParamValueLI(const Char_t* aLabel, UShort_t pIndex) const;
+    virtual Int_t         GetAlgoParamValueLN(const Char_t* aLabel, const Char_t* pName) const;
+
+    virtual void          ReadFromTextFile(const Char_t* fileName);
+
+ protected:
+    UInt_t    fRunNumber;              // Run number
+    UShort_t  fFirmWareVersion;        // PIT Processing firmware version
+    TString   fGlobalDescription;      // PIT Global description
+    UShort_t  fVersionRegister;        // PIT Version register value
+    UShort_t  fInputConditionsVersion; // PIT Input configuration version
+    UShort_t  fParametersVersion;      // PIT Parameters version
+    TBits     fInActiveChips;          // Map of PIT de-activated chips
+    UShort_t  fNumAlgo;                // Number of algorithms used
+    TObjArray fAlgoList;               // List of conditions for each algorithm used
+
+    UInt_t  GetChipKey(Int_t eq, Int_t hs, Int_t chip) const;
+    void    GetChipFromKey(UInt_t key, Int_t& eq, Int_t& hs, Int_t& chip) const;
+    Bool_t  SplitStringIn2(TString orig, TString& word1, TString& word2, Char_t sep);
+    TString GetStringBetween(TString orig, Char_t sep1, Char_t sep2);
+
+    ClassDef(AliITSTriggerConditions,1) // Trigger conditions class
+};
+
+#endif
diff --git a/ITS/AliITSTriggerFOProcessor.cxx b/ITS/AliITSTriggerFOProcessor.cxx
new file mode 100644 (file)
index 0000000..0ed9853
--- /dev/null
@@ -0,0 +1,246 @@
+/////////////////////////////////////////////////////////////////////
+// Author: Henrik Tydesjo                                          //
+//                                                                 //
+// This class takes care of simulating the output from the pixel   //
+// trigger system.                                                 //
+// The fast-or signals are given as input and they are processed   //
+// to see which algorithm will give a signal to the central        //
+// trigger system. To avoid doing the same operations many times,  //
+// there is a method called PreprocessFOSignals, which should      //
+// always be called for each event before the processing of        //
+// each individual algorithm is done.                              //
+//                                                                 //
+// As soon as a new algorithm has been implemented online, a       //
+// corresponding method should be implemented here. Which method   //
+// should be used for a given trigger label is taken care of in    //
+// ProcessFOSignalsLabel method.                                   //
+//                                                                 //
+/////////////////////////////////////////////////////////////////////
+
+#include "AliITSTriggerFOProcessor.h"
+#include "AliITSTriggerConditions.h"
+#include <TError.h>
+
+AliITSTriggerFOProcessor::AliITSTriggerFOProcessor() :
+  fFOInner(0), fFOOuter(0), fTriggerCond(NULL)
+{
+  // default constructor
+}
+//______________________________________________________________________
+AliITSTriggerFOProcessor::AliITSTriggerFOProcessor(AliITSTriggerConditions* ocdbCond) :
+  fFOInner(0), fFOOuter(0), fTriggerCond(ocdbCond)
+{
+  // constructor
+}
+//______________________________________________________________________
+AliITSTriggerFOProcessor::AliITSTriggerFOProcessor(const AliITSTriggerFOProcessor& handle): 
+  fFOInner(handle.fFOInner), fFOOuter(handle.fFOOuter), fTriggerCond(handle.fTriggerCond)
+{
+  // copy constructor
+}
+//______________________________________________________________________
+AliITSTriggerFOProcessor::~AliITSTriggerFOProcessor() {
+  // destructor
+}
+//______________________________________________________________________
+AliITSTriggerFOProcessor& AliITSTriggerFOProcessor::operator=(const AliITSTriggerFOProcessor& handle) {
+  // assignment operator
+  if (this!=&handle) {
+    fFOInner = handle.fFOInner;
+    fFOOuter = handle.fFOOuter;
+    fTriggerCond = handle.fTriggerCond;
+  }
+  return *this;
+}
+//______________________________________________________________________
+void AliITSTriggerFOProcessor::SetTriggerConditions(AliITSTriggerConditions* ocdbCond) {
+  // Method to give pointer to the OCDB conditions entry
+  fTriggerCond = ocdbCond;
+}
+//______________________________________________________________________
+UInt_t AliITSTriggerFOProcessor::GetNumOutputs() const {
+  // return number of outputs (algorithms) in use
+  if (fTriggerCond==NULL) {
+    Error("AliITSTriggerFOProcessor::GetNumOutputs","Trigger conditions entry not yet given.");
+    return 0;
+  }
+  return fTriggerCond->GetNumAlgo();
+}
+//______________________________________________________________________
+const Char_t* AliITSTriggerFOProcessor::GetOutputLabel(Short_t index) const {
+  // return the label of the index'th algorithm in use
+  if (fTriggerCond==NULL) {
+    Error("AliITSTriggerFOProcessor::GetOutputLabel","Trigger conditions entry not yet given.");
+    return "";
+  }
+  return fTriggerCond->GetAlgoLabelI(index);
+}
+//______________________________________________________________________
+void AliITSTriggerFOProcessor::PreprocessFOSignals(AliITSFOSignalsSPD* signals) {
+  // Pre-process the fast-or signals to retrieve some data needed by most algorithms
+  if (fTriggerCond==NULL) {
+    Error("AliITSTriggerFOProcessor::PreprocessFOSignals","Trigger conditions entry not yet given.");
+    return;
+  }
+  fFOInner = 0;
+  fFOOuter = 0;
+
+  Int_t eq   = -1;
+  Int_t hs   = -1;
+  Int_t chip = -1;
+  while (signals->GetNextSignal(eq,hs,chip)) {
+    if (fTriggerCond->IsChipActive( (UInt_t)eq, (UInt_t)hs, (UInt_t)chip) ) {
+      if (hs<=1) fFOInner++;
+      else       fFOOuter++;
+    }
+  }
+}
+//______________________________________________________________________
+Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsIndex(Short_t index, AliITSFOSignalsSPD* signals) {
+  // NB: For every event - Always call PreprocessFOSignals before calling this method
+  // Process index'th algorithm - returns true if output active
+  return ProcessFOSignalsLabel(GetOutputLabel(index), signals);
+}
+//______________________________________________________________________
+Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsLabel(const Char_t* label, AliITSFOSignalsSPD* signals) {
+  // NB: For every event - Always call PreprocessFOSignals before calling this method
+  // Process algorithm with label ... - returns true if output active 
+  if (fTriggerCond==NULL) {
+    Error("AliITSTriggerFOProcessor::ProcessFOSignalsLabel","Trigger conditions entry not yet given.");
+    return kFALSE;
+  }
+
+  Short_t index = fTriggerCond->GetAlgoIndexL(label);
+  if (index<0) {
+    Error("AliITSTriggerFOProcessor::ProcessFOSignalsLabel", "No conditions for label '%s'.",label);
+    return kFALSE;
+  }
+
+  if      (strcmp(label, "0SMB") == 0) return ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter(index, signals);
+  else if (strcmp(label, "0SH1") == 0) return ProcessFOSignalsTHRInnerAndTHROuter(index, signals);
+  else if (strcmp(label, "0SH2") == 0) return ProcessFOSignalsTHRInnerAndTHROuter(index, signals);
+  else if (strcmp(label, "0SH3") == 0) return ProcessFOSignalsTHRInnerAndTHROuter(index, signals);
+  else if (strcmp(label, "0SH4") == 0) return ProcessFOSignalsTHRInnerAndTHROuter(index, signals);
+  else if (strcmp(label, "0SPF") == 0) return ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter(index, signals);
+  else if (strcmp(label, "0SBK") == 0) return ProcessFOSignalsInnerGTOuterPlusOffset(index, signals);
+  else if (strcmp(label, "0SBK") == 0) return ProcessFOSignalsOuterGTInnerPlusOffset(index, signals);
+  else if (strcmp(label, "0SBK") == 0) return ProcessFOSignalsTHRTotal(index, signals);
+  else if (strcmp(label, "SPD_GFO_L0") == 0) return ProcessFOSignalsTHRTotal(index, signals);
+  else if (strcmp(label, "SPD_HMULT_L0") == 0) return ProcessFOSignalsTHRTotal(index, signals);
+
+  else {
+    Error("AliITSTriggerFOProcessor::ProcessFOSignalsLabel", "Algorithm not yet implemented for label '%s'.",label);
+    return kFALSE;
+  }
+}
+//______________________________________________________________________
+Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
+  // NB: For every event - Always call PreprocessFOSignals before calling this method
+  // Process algorithm ' I+O > thr && I > thr && O > thr ' (index is needed to get the correct parameters from the ocdb object)
+  if (fTriggerCond==NULL) {
+    Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter","Trigger conditions entry not yet given.");
+    return kFALSE;
+  }
+  
+  // Get parameter values:
+  Int_t thIO = fTriggerCond->GetAlgoParamValueIN(index, "total_threshold");
+  if (thIO<0) {
+    Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter","Parameter 'total_threshold' not defined");
+    return kFALSE;
+  }
+  Int_t thI = fTriggerCond->GetAlgoParamValueIN(index, "inner_threshold");
+  if (thI<0) {
+    Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter","Parameter 'inner_threshold' not defined");
+    return kFALSE;
+  }
+  Int_t thO = fTriggerCond->GetAlgoParamValueIN(index, "outer_threshold");
+  if (thO<0) {
+    Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter","Parameter 'outer_threshold' not defined");
+    return kFALSE;
+  }
+
+  // Evaluate:
+  return (fFOInner+fFOOuter >= thIO && fFOInner >= thI && fFOOuter >= thO);
+}
+//______________________________________________________________________
+Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsTHRInnerAndTHROuter(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
+  // NB: For every event - Always call PreprocessFOSignals before calling this method
+  // Process algorithm ' I > thr && O > thr ' (index is needed to get the correct parameters from the ocdb object)
+  if (fTriggerCond==NULL) {
+    Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRInnerAndTHROuter","Trigger conditions entry not yet given.");
+    return kFALSE;
+  }
+  
+  // Get parameter values:
+  Int_t thI = fTriggerCond->GetAlgoParamValueIN(index, "inner_threshold");
+  if (thI<0) {
+    Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRInnerAndTHROuter","Parameter 'inner_threshold' not defined");
+    return kFALSE;
+  }
+  Int_t thO = fTriggerCond->GetAlgoParamValueIN(index, "outer_threshold");
+  if (thO<0) {
+    Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRInnerAndTHROuter","Parameter 'outer_threshold' not defined");
+    return kFALSE;
+  }
+
+  // Evaluate:
+  return (fFOInner >= thI && fFOOuter >= thO);
+}
+//______________________________________________________________________
+Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotal(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
+  // NB: For every event - Always call PreprocessFOSignals before calling this method
+  // Process algorithm ' I+O > thr' (index is needed to get the correct parameters from the ocdb object)
+  if (fTriggerCond==NULL) {
+    Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotal","Trigger conditions entry not yet given.");
+    return kFALSE;
+  }
+  
+  // Get parameter values:
+  Int_t thIO = fTriggerCond->GetAlgoParamValueIN(index, "total_threshold");
+  if (thIO<0) {
+    Error("AliITSTriggerFOProcessor::ProcessFOSignalsTHRTotal","Parameter 'total_threshold' not defined");
+    return kFALSE;
+  }
+
+  // Evaluate:
+  return (fFOInner + fFOOuter >= thIO);
+}
+//______________________________________________________________________
+Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsInnerGTOuterPlusOffset(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
+  // NB: For every event - Always call PreprocessFOSignals before calling this method
+  // Process algorithm ' I > O+offset ' (index is needed to get the correct parameters from the ocdb object)
+  if (fTriggerCond==NULL) {
+    Error("AliITSTriggerFOProcessor::ProcessFOSignalsGTOuterPlusOffset","Trigger conditions entry not yet given.");
+    return kFALSE;
+  }
+  
+  // Get parameter values:
+  Int_t offset = fTriggerCond->GetAlgoParamValueIN(index, "offset");
+  if (offset<0) {
+    Error("AliITSTriggerFOProcessor::ProcessFOSignalsInnerGTOuterPlusOffset","Parameter 'offset' not defined");
+    return kFALSE;
+  }
+
+  // Evaluate:
+  return (fFOInner >=  fFOOuter + offset);
+}
+//______________________________________________________________________
+Bool_t AliITSTriggerFOProcessor::ProcessFOSignalsOuterGTInnerPlusOffset(Short_t index, AliITSFOSignalsSPD* /*signals*/) {
+  // NB: For every event - Always call PreprocessFOSignals before calling this method
+  // Process algorithm ' O > I+offset ' (index is needed to get the correct parameters from the ocdb object)
+  if (fTriggerCond==NULL) {
+    Error("AliITSTriggerFOProcessor::ProcessFOSignalsGTOuterPlusOffset","Trigger conditions entry not yet given.");
+    return kFALSE;
+  }
+  
+  // Get parameter values:
+  Int_t offset = fTriggerCond->GetAlgoParamValueIN(index, "offset");
+  if (offset<0) {
+    Error("AliITSTriggerFOProcessor::ProcessFOSignalsOuterGTInnerPlusOffset","Parameter 'offset' not defined");
+    return kFALSE;
+  }
+
+  // Evaluate:
+  return (fFOOuter >=  fFOInner + offset);
+}
+
diff --git a/ITS/AliITSTriggerFOProcessor.h b/ITS/AliITSTriggerFOProcessor.h
new file mode 100644 (file)
index 0000000..9903594
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef ALIITS_TRIGGERFOPROCESSOR_H
+#define ALIITS_TRIGGERFOPROCESSOR_H
+
+/////////////////////////////////////////////////////////////////////
+// Author: Henrik Tydesjo                                          //
+//                                                                 //
+// This class takes care of simulating the output from the pixel   //
+// trigger system.                                                 //
+// The fast-or signals are given as input and they are processed   //
+// to see which algorithm will give a signal to the central        //
+// trigger system. To avoid doing the same operations many times,  //
+// there is a method called PreprocessFOSignals, which should      //
+// always be called for each event before the processing of        //
+// each individual algorithm is done.                              //
+//                                                                 //
+// As soon as a new algorithm has been implemented online, a       //
+// corresponding method should be implemented here. Which method   //
+// should be used for a given trigger label is taken care of in    //
+// ProcessFOSignalsLabel method.                                   //
+//                                                                 //
+/////////////////////////////////////////////////////////////////////
+
+#include "AliITSFOSignalsSPD.h"
+
+class AliITSTriggerConditions;
+
+class AliITSTriggerFOProcessor {
+
+ public:
+  AliITSTriggerFOProcessor();
+  AliITSTriggerFOProcessor(AliITSTriggerConditions* ocdbCond);
+  AliITSTriggerFOProcessor(const AliITSTriggerFOProcessor& handle);
+  virtual ~AliITSTriggerFOProcessor();
+  AliITSTriggerFOProcessor& operator=(const AliITSTriggerFOProcessor& handle);
+
+  virtual void          SetTriggerConditions(AliITSTriggerConditions* ocdbCond);
+  virtual Bool_t        TriggerConditionsSet() {return fTriggerCond!=NULL;}
+
+  virtual UInt_t        GetNumOutputs() const;
+  virtual const Char_t* GetOutputLabel(Short_t index) const;
+
+
+  virtual void          PreprocessFOSignals(AliITSFOSignalsSPD* signals); // NB! Call this before calling the below methods!!!
+
+  virtual Bool_t        ProcessFOSignalsIndex(Short_t index, AliITSFOSignalsSPD* signals);
+  virtual Bool_t        ProcessFOSignalsLabel(const Char_t* label, AliITSFOSignalsSPD* signals);
+  
+  virtual Bool_t        ProcessFOSignalsTHRTotal(Short_t index, AliITSFOSignalsSPD* /*signals*/);
+  virtual Bool_t        ProcessFOSignalsTHRTotalAndTHRInnerAndTHROuter(Short_t index, AliITSFOSignalsSPD* /*signals*/);
+  virtual Bool_t        ProcessFOSignalsTHRInnerAndTHROuter(Short_t index, AliITSFOSignalsSPD* /*signals*/);
+  virtual Bool_t        ProcessFOSignalsInnerGTOuterPlusOffset(Short_t index, AliITSFOSignalsSPD* /*signals*/);
+  virtual Bool_t        ProcessFOSignalsOuterGTInnerPlusOffset(Short_t index, AliITSFOSignalsSPD* /*signals*/);
+
+  
+ protected:
+  Int_t fFOInner;
+  Int_t fFOOuter;
+  AliITSTriggerConditions *fTriggerCond;
+
+};
+
+#endif
index cbf1c2728c5f14eb30fb42be3b4c18e4e6c30dd1..e5bdd1eb89a904d4410905859b882aa15ba5f6d8 100644 (file)
@@ -288,7 +288,9 @@ void AliITSsimulationSPD::SDigitiseModule(AliITSmodule *mod,Int_t,
    InitSimulationModule( GetModuleNumber() , event );
    // HitToSDigit(mod);
    HitToSDigitFast(mod);
-   RemoveDeadPixels(mod);
+  if (fDetType->GetSimuParam()->GetSPDAddNoisyFlag())   AddNoisyPixels();
+  if (fDetType->GetSimuParam()->GetSPDRemoveDeadFlag()) RemoveDeadPixels();
+
 //    cout << "After Remove in SDigitiseModule !!!!!" << endl; // dom
 //    cout << "Module " << mod->GetIndex() << " Event " << event << endl; // dom
    WriteSDigits();
@@ -357,7 +359,9 @@ void AliITSsimulationSPD::DigitiseModule(AliITSmodule *mod,Int_t,
    // HitToSDigit(mod);
    InitSimulationModule( mod->GetIndex(), event );
    HitToSDigitFast(mod);
-   RemoveDeadPixels(mod);
+   
+  if (fDetType->GetSimuParam()->GetSPDAddNoisyFlag())   AddNoisyPixels();
+  if (fDetType->GetSimuParam()->GetSPDRemoveDeadFlag()) RemoveDeadPixels();
 //    cout << "After Remove in DigitiseModule in module " << mod->GetIndex() << endl; // dom
    FrompListToDigits();
    ClearMap();
@@ -717,26 +721,29 @@ void AliITSsimulationSPD::SpreadChargeAsym(Double_t x0,Double_t z0,
    } // end for ix, iz
 }
 //______________________________________________________________________
-void AliITSsimulationSPD::RemoveDeadPixels(AliITSmodule *mod){
-   //    Removes dead pixels on each module (ladder)
-   // Inputs:
-   //    Module Index (0,239)
-   // Outputs:
-   //    none.
-   // Return:
-   //    none.
+void AliITSsimulationSPD::RemoveDeadPixels(){
+  // Removes dead pixels on each module (ladder)
+  // This should be called before going from sdigits to digits (FrompListToDigits)
+  Int_t mod = GetModuleNumber();
+  AliITSCalibrationSPD* calObj = (AliITSCalibrationSPD*) fDetType->GetCalibrationModel(mod);
 
- Int_t moduleNr = mod->GetIndex();
- AliITSCalibrationSPD* calObj = (AliITSCalibrationSPD*) GetCalibrationModel(moduleNr);
+  Int_t nrDead = calObj->GetNrBad();
+  for (Int_t i=0; i<nrDead; i++) {
+    GetMap()->DeleteHit(calObj->GetBadColAt(i), calObj->GetBadRowAt(i));
+  }
+}
+//______________________________________________________________________
+void AliITSsimulationSPD::AddNoisyPixels() {
+  // Adds noisy pixels on each module (ladder)
+  // This should be called before going from sdigits to digits (FrompListToDigits)
+  Int_t mod = GetModuleNumber();
+  AliITSCalibrationSPD* calObj = (AliITSCalibrationSPD*) fDetType->GetSPDNoisyModel(mod);
 
- Int_t nrDead = calObj->GetNrBad();
-//  cout << "Module --> " << moduleNr << endl; // dom
-//  cout << "nr of dead " << nrDead << endl; // dom
- for (Int_t i=0; i<nrDead; i++) {
-   GetMap()->DeleteHit(calObj->GetBadColAt(i),calObj->GetBadRowAt(i));
-//    cout << "dead index " << i << endl; // dom
-//    cout << "col row --> " << calObj->GetDeadColAt(i) << " " << calObj->GetDeadRowAt(i) << endl; // dom
- }
+  Int_t nrNoisy = calObj->GetNrBad();
+  for (Int_t i=0; i<nrNoisy; i++) {
+    // adding 10 times the threshold will for sure make this pixel fire...
+    GetMap()->AddNoise(calObj->GetBadColAt(i), calObj->GetBadRowAt(i), mod, 10*GetThreshold());
+  }
 }
 //______________________________________________________________________
 void AliITSsimulationSPD::FrompListToDigits(){
@@ -783,7 +790,8 @@ void AliITSsimulationSPD::FrompListToDigits(){
            cout<<sig<<"+"<<electronics<<">threshold("<<ix<<","<<iz
                <<")="<<GetThreshold() <<endl;
        } // end if GetDebug
-       if (sig+electronics <= GetThreshold()) continue;
+      // if (sig+electronics <= GetThreshold()) continue;
+       if (GetMap()->GetSignal(iz,ix) <= GetThreshold()) continue;
        dig.SetCoord1(iz);
        dig.SetCoord2(ix);
        dig.SetSignal(1);
@@ -811,6 +819,8 @@ void AliITSsimulationSPD::FrompListToDigits(){
            cout<<iz<<","<<ix<<","<<*(GetMap()->GetpListItem(iz,ix))<<endl;
        } // end if GetDebug
        aliITS->AddSimDigit(0,&dig);
+       // simulate fo signal response for this pixel hit:
+       fDetType->ProcessSPDDigitForFastOr(fModule, dig.GetCoord1(), dig.GetCoord2());
    } //  for ix/iz
 }
 //______________________________________________________________________
index b61fa58f6b8d8ddb0c29e50ce31c626b95a9c34c..5883b9fbeb065dc5ef29d8dc7c4cfd702ea9677f 100644 (file)
@@ -51,8 +51,10 @@ public:
    void HitToSDigit(AliITSmodule *mod);
    // fill pList from hits, charge sharing, diffusion, coupling  (faster method optimized by Bjorne)
    void HitToSDigitFast(AliITSmodule *mod);
+   // Adds noisy pixels to pList
+   void AddNoisyPixels();   
    // Removes dead pixels from pList
-   void RemoveDeadPixels(AliITSmodule *mod);
+   void RemoveDeadPixels();
    // Take pList of signals and apply noise... create Digits
    void FrompListToDigits();
    // This set the Lorentz drift of Electrons and Holes: by deafult equal weights to Electrons and Holes
index 995a5e61f775688c4a7b0d8870c4c56718da7f9e..b31a9cd06f17aa2ff71f5f69bc92e3c1fc090081 100644 (file)
@@ -30,7 +30,6 @@ set(SRCS
                AliITSresponseSPD.cxx
                AliITSresponseSDD.cxx
                AliITSCalibrationSPD.cxx
-               AliITSFastOrCalibrationSPD.cxx
                AliITSCalibrationSDD.cxx
                AliITSCalibrationSSD.cxx
                 AliITSChannelStatus.cxx
index 63599d072de4c8ac7b291cd72e2eeb96c5b0cc0a..b909dde8e40602a52ecc8409c61dcd5b7ceb8e53 100644 (file)
@@ -41,6 +41,14 @@ set(SRCS
                 AliITSQASPDDataMakerSim.cxx 
                 AliITSQASDDDataMakerSim.cxx 
                 AliITSQASSDDataMakerSim.cxx
+               AliITSFOEfficiencySPD.cxx
+               AliITSFOEfficiencySPDColumn.cxx
+               AliITSFONoiseSPD.cxx
+               AliITSFOGeneratorSPD.cxx
+               AliITSFOSignalsSPD.cxx
+               AliITSTriggerFOProcessor.cxx
+               AliITSTriggerConditions.cxx
+               AliITSTriggerAlgorithmConditions.cxx
 )
 
 # fill list of header files from list of source files
index c4c7f4537a9488053f7da660b8dc0ec0e98362d1..62cbfcf8e49bfbf119f546ce598c024b40ae303e 100644 (file)
@@ -50,7 +50,6 @@
 #pragma link C++ class  AliITSresponseSPD+;
 #pragma link C++ class  AliITSresponseSDD+;
 #pragma link C++ class  AliITSCalibrationSPD-;
-#pragma link C++ class  AliITSFastOrCalibrationSPD+;
 #pragma link C++ class  AliITSCalibrationSDD+;
 #pragma link C++ class  AliITSCalibrationSSD+;
 #pragma link C++ class  AliITSChannelStatus+;
index 30c1806a13b826df85ffe509276ae8045015ff55..bae4d1553d4118cc068968578e68fc8c2b87ee55 100644 (file)
 //#pragma link C++ class DisplayITSv11+;
 // Raw data
 
+
+#pragma link C++ class AliITSFOEfficiencySPD+;
+#pragma link C++ class AliITSFOEfficiencySPDColumn+;
+#pragma link C++ class AliITSFONoiseSPD+;
+#pragma link C++ class AliITSFOGeneratorSPD+;
+#pragma link C++ class AliITSFOSignalsSPD+;
+
 #pragma link C++ class AliITSTrigger+;
+#pragma link C++ class AliITSTriggerConditions+;
+#pragma link C++ class AliITSTriggerAlgorithmConditions+;
+#pragma link C++ class AliITSTriggerFOProcessor+;
 #pragma link C++ class AliITSQADataMakerSim+;
 #pragma link C++ class AliITSQASPDDataMakerSim+;
 #pragma link C++ class AliITSQASDDDataMakerSim+;
index 686982edcde65cd94ec2db1179d9d7f17716a644..32305fefe8c8f9a4e0300c4fdc4d8303bd2b10c5 100644 (file)
@@ -29,7 +29,6 @@ SRCS =        AliITSgeom.cxx \
                AliITSresponseSPD.cxx \
                AliITSresponseSDD.cxx \
                AliITSCalibrationSPD.cxx \
-               AliITSFastOrCalibrationSPD.cxx \
                AliITSCalibrationSDD.cxx \
                AliITSCalibrationSSD.cxx \
                 AliITSChannelStatus.cxx \
index c426e5a85d6f15faff61c1dadd238a3741235f35..d25ad4a406c3bcde57493d2ec99796cf0f1fadd9 100644 (file)
@@ -25,7 +25,15 @@ SRCS =       AliITS.cxx \
                AliITSsDigitize.cxx \
                AliITSDigitizer.cxx \
                AliITSFDigitizer.cxx \
+               AliITSFOEfficiencySPD.cxx \
+               AliITSFOEfficiencySPDColumn.cxx \
+               AliITSFONoiseSPD.cxx \
+               AliITSFOGeneratorSPD.cxx \
+               AliITSFOSignalsSPD.cxx \
                AliITSTrigger.cxx \
+               AliITSTriggerFOProcessor.cxx \
+               AliITSTriggerConditions.cxx \
+               AliITSTriggerAlgorithmConditions.cxx \
                AliITSv11.cxx \
                AliITSv11Geometry.cxx \
                AliITSv11GeomCable.cxx \