]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Improved access to AliITSgeom in reconstruction
authormasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 6 Mar 2006 17:18:55 +0000 (17:18 +0000)
committermasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 6 Mar 2006 17:18:55 +0000 (17:18 +0000)
ITS/AliITSDetTypeRec.cxx
ITS/AliITSDetTypeRec.h
ITS/AliITSLoader.cxx
ITS/AliITSLoader.h
ITS/AliITSReconstructor.cxx
ITS/AliITSTrackerV1.cxx
ITS/AliITSTrigger.cxx
ITS/AliITSTrigger.h
ITS/AliITSreconstruction.cxx

index 8c02e3fedab6fe74c71de0a554c4262af73d90e8..2871e7d51d5ab89104092b2a58a5af192895a250 100644 (file)
@@ -35,7 +35,6 @@
 #include "AliITSClusterFinderSPD.h"
 #include "AliITSClusterFinderSDD.h"
 #include "AliITSClusterFinderSSD.h"
-#include "AliITSgeom.h"
 #include "AliITSDetTypeRec.h"
 #include "AliITSRawCluster.h"
 #include "AliITSRawClusterSPD.h"
@@ -57,17 +56,7 @@ const Int_t AliITSDetTypeRec::fgkDefaultNModulesSSD = 1698;
 ClassImp(AliITSDetTypeRec)
 
 //________________________________________________________________
-AliITSDetTypeRec::AliITSDetTypeRec(): TObject(),
-fGeom(),        //
-fReconstruction(),// [NDet]
-fSegmentation(),  // [NDet]
-fCalibration(),   // [NMod]
-fPreProcess(),    // [] e.g. Find Calibration values
-fPostProcess(),   // [] e.g. find primary vertex
-fDigits(),        //! [NMod][NDigits]
-fClusterClassName(), // String with Cluster class name
-fDigClassName(),     // String with digit class name.
-fRecPointClassName(){// String with RecPoint class name
+AliITSDetTypeRec::AliITSDetTypeRec(): TObject(){
     // Default Constructor
     // Inputs:
     //    none.
@@ -75,17 +64,56 @@ fRecPointClassName(){// String with RecPoint class name
     //    none.
     // Return:
     //    A properly zero-ed AliITSDetTypeRec class.
+  fReconstruction = 0;
+  fSegmentation = 0;
+  fCalibration = 0;
+  fPreProcess = 0;
+  fPostProcess = 0;
+  fDigits = 0;;
+  for(Int_t i=0; i<3; i++){
+    fClusterClassName[i]=0;
+    fDigClassName[i]=0;
+    fRecPointClassName[i]=0;
+  }
+  fNdtype = 0;
+  fCtype = 0;
+  fNMod = 0;
+  fNctype = 0;
+  fRecPoints = 0;
+  fNRecPoints = 0;
+  SelectVertexer(" ");
+  fLoader = 0;
+  fRunNumber = 0;
+
+}
+//________________________________________________________________
+AliITSDetTypeRec::AliITSDetTypeRec(AliITSLoader *loader): TObject(){
+    // Standard Constructor
+    // Inputs:
+    //    none.
+    // Outputs:
+    //    none.
+    // Return:
+    //   
 
-  fGeom = 0;
   fReconstruction = new TObjArray(fgkNdettypes);
   fSegmentation = 0;
   fCalibration = 0;
   fPreProcess = 0;
   fPostProcess = 0;
   fDigits = new TObjArray(fgkNdettypes);
+  for(Int_t i=0; i<3; i++){
+    fClusterClassName[i]=0;
+    fDigClassName[i]=0;
+    fRecPointClassName[i]=0;
+  }
   fNdtype = new Int_t[fgkNdettypes];
   fCtype = new TObjArray(fgkNdettypes);
   fNctype = new Int_t[fgkNdettypes];
+  fNMod = new Int_t [fgkNdettypes];
+  fNMod[0] = fgkDefaultNModulesSPD;
+  fNMod[1] = fgkDefaultNModulesSDD;
+  fNMod[2] = fgkDefaultNModulesSSD;
   fRecPoints = new TClonesArray("AliITSRecPoint",3000);
   fNRecPoints = 0;
   
@@ -95,12 +123,8 @@ fRecPointClassName(){// String with RecPoint class name
   }
   
   SelectVertexer(" ");
-  fLoader = 0;
-
-  fNMod[0] = fgkDefaultNModulesSPD;
-  fNMod[1] = fgkDefaultNModulesSDD;
-  fNMod[2] = fgkDefaultNModulesSSD;
-  
+  fLoader = loader;
   SetRunNumber();
 }
 //______________________________________________________________________
@@ -134,9 +158,9 @@ AliITSDetTypeRec::~AliITSDetTypeRec(){
     fSegmentation = 0;
   }
   if(fCalibration){
-    AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(fGeom->GetStartSPD()))->GetResponse();    
-    AliITSresponse* rsdd = ((AliITSCalibration*)fCalibration->At(fGeom->GetStartSDD()))->GetResponse();
-    AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(fGeom->GetStartSSD()))->GetResponse();
+    AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(GetITSgeom()->GetStartSPD()))->GetResponse();    
+    AliITSresponse* rsdd = ((AliITSCalibration*)fCalibration->At(GetITSgeom()->GetStartSDD()))->GetResponse();
+    AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(GetITSgeom()->GetStartSSD()))->GetResponse();
     if(rspd) delete rspd;
     if(rsdd) delete rsdd;
     if(rssd) delete rssd;
@@ -144,7 +168,6 @@ AliITSDetTypeRec::~AliITSDetTypeRec(){
     delete fCalibration;
     fCalibration = 0;
   }
-  if(fGeom) delete fGeom;
   if(fPreProcess) delete fPreProcess;
   if(fPostProcess) delete fPostProcess;
 
@@ -165,9 +188,11 @@ AliITSDetTypeRec::~AliITSDetTypeRec(){
   }
   delete [] fNctype;
   delete [] fNdtype;
+  delete [] fNMod;
   if(fLoader) delete fLoader;
   
 }
+
 //___________________________________________________________________
 void AliITSDetTypeRec::SetReconstructionModel(Int_t dettype,AliITSClusterFinder *clf){
 
@@ -215,7 +240,7 @@ void AliITSDetTypeRec::SetCalibrationModel(Int_t iMod, AliITSCalibration *cal){
 
   //Set calibration (response) for the module iMod of type dettype
   if (fCalibration==0) {
-    fCalibration = new TObjArray(fGeom->GetIndexMax());
+    fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
     fCalibration->SetOwner(kTRUE);
     fCalibration->Clear();
   }
@@ -311,8 +336,8 @@ void AliITSDetTypeRec::SetDefaults(){
   
   //Set defaults for segmentation and response
 
-  if(fGeom==0){
-    Warning("SetDefaults","fGeom is 0!");
+  if(!GetITSgeom()){
+    Warning("SetDefaults","null pointer to AliITSgeomGeom !");
     return;
   }
 
@@ -321,15 +346,15 @@ void AliITSDetTypeRec::SetDefaults(){
 
   for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
     if(dettype==0){
-      seg = new AliITSsegmentationSPD(fGeom);
+      seg = new AliITSsegmentationSPD(GetITSgeom());
       SetSegmentationModel(dettype,seg);
       SetDigitClassName(dettype,"AliITSdigitSPD");
       SetClusterClassName(dettype,"AliITSRawClusterSPD");
 
     }
     if(dettype==1){
-      AliITSCalibrationSDD* res=(AliITSCalibrationSDD*) GetCalibrationModel(fGeom->GetStartSDD()); 
-      seg = new AliITSsegmentationSDD(fGeom,res);
+      AliITSCalibrationSDD* res=(AliITSCalibrationSDD*) GetCalibrationModel(GetITSgeom()->GetStartSDD()); 
+      seg = new AliITSsegmentationSDD(GetITSgeom(),res);
       SetSegmentationModel(dettype,seg);
       const char *kopt = ((AliITSresponseSDD*)res->GetResponse())->ZeroSuppOption();
       if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D"))) SetDigitClassName(dettype,"AliITSdigit");
@@ -338,7 +363,7 @@ void AliITSDetTypeRec::SetDefaults(){
 
     }
     if(dettype==2){
-      AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD(fGeom);
+      AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD(GetITSgeom());
       seg2->SetAngles(0.0075,0.0275); // strip angels rad P and N side.
       seg2->SetAnglesLay5(0.0075,0.0275); // strip angels rad P and N side.
       seg2->SetAnglesLay6(0.0275,0.0075); // strip angels rad P and N side.
@@ -448,8 +473,8 @@ void AliITSDetTypeRec::SetDefaultClusterFinders(){
   
   //set defaults for standard cluster finder
 
-  if(fGeom==0){
-    Warning("SetDefaults","fGeom is 0!");
+  if(!GetITSgeom()){
+    Warning("SetDefaults","null pointer to AliITSgeom!");
     return;
   }
 
@@ -498,8 +523,8 @@ void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata){
 
   //Set defaults for cluster finder V2
 
-  if(fGeom==0){
-    Warning("SetDefaults","fGeom is 0!");
+  if(!GetITSgeom()){
+    Warning("SetDefaults","Null pointer to AliITSgeom !");
     return;
   }
 
@@ -794,8 +819,8 @@ void AliITSDetTypeRec::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t
   //                       be processed. If ="All" then all of the ITS
   //                       sub detectors are processed.
 
-  if(!fGeom){
-    Warning("DigitsToRecPoints","fGeom is null!");
+  if(!GetITSgeom()){
+    Warning("DigitsToRecPoints","Null pointer to AliITSgeom !");
     return;
   }
   if(!fLoader){
@@ -822,10 +847,10 @@ void AliITSDetTypeRec::DigitsToRecPoints(Int_t evNumber,Int_t lastentry,Option_t
   }
   AliITSClusterFinder *rec     = 0;
   Int_t id,module,first=0;
-  for(module=0;module<fGeom->GetIndexMax();module++){
-      id       = fGeom->GetModuleType(module);
+  for(module=0;module<GetITSgeom()->GetIndexMax();module++){
+      id       = GetITSgeom()->GetModuleType(module);
       if (!all && !det[id]) continue;
-      if(det[id]) first = fGeom->GetStartDet(id);
+      if(det[id]) first = GetITSgeom()->GetStartDet(id);
       rec = (AliITSClusterFinder*)GetReconstructionModel(id);
       TClonesArray *itsDigits  = DigitsAddress(id);
       if (!rec) {
@@ -874,8 +899,8 @@ void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader){
   //      none.
   // Return:
   //      none.
-  if(!fGeom){
-    Warning("DigitsToRecPoints","fGeom is null!");
+  if(!GetITSgeom()){
+    Warning("DigitsToRecPoints","Null pointer to AliITSgeom !");
     return;
   }
   if(!fLoader){
@@ -893,8 +918,8 @@ void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader){
   cTree->Branch("ITSRecPoints",&array);
   delete array;
  
-  TClonesArray** clusters = new TClonesArray*[fGeom->GetIndexMax()]; 
-  for (Int_t iModule = 0; iModule < fGeom->GetIndexMax(); iModule++) {
+  TClonesArray** clusters = new TClonesArray*[GetITSgeom()->GetIndexMax()]; 
+  for (Int_t iModule = 0; iModule < GetITSgeom()->GetIndexMax(); iModule++) {
     clusters[iModule] = NULL;
   }
   for(id=0;id<3;id++){
@@ -908,7 +933,7 @@ void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader){
     rec->RawdataToClusters(rawReader,clusters);    
   } 
   Int_t nClusters =0;
-  for(Int_t iModule=0;iModule<fGeom->GetIndexMax();iModule++){
+  for(Int_t iModule=0;iModule<GetITSgeom()->GetIndexMax();iModule++){
     array = clusters[iModule];
     if(!array){
       Error("DigitsToRecPoints","data for module %d missing!",iModule);
index 1b5a6d5bcf04fb7451d727c892ef37b69ab1e440..19110dd853eab1c65b5e053ec045e95b0c0f74d4 100644 (file)
@@ -30,14 +30,13 @@ class AliITSgeom;
 class AliITSDetTypeRec : public TObject {
   public:
     AliITSDetTypeRec(); // Default constructor
+    AliITSDetTypeRec(AliITSLoader *loader); // Standard constructor
     AliITSDetTypeRec(const AliITSDetTypeRec& rec);
     AliITSDetTypeRec& operator=(const AliITSDetTypeRec &source);
 
     virtual ~AliITSDetTypeRec(); // Proper Destructor
-    AliITSgeom* GetITSgeom()const{return fGeom;}
-    void SetITSgeom(AliITSgeom *geom) {fGeom=geom;}
+    AliITSgeom* GetITSgeom()const{return GetLoader()->GetITSgeom();}
 
-    virtual void SetLoader(AliITSLoader* loader) {fLoader=loader;}
     AliITSLoader* GetLoader() const {return fLoader;}
     virtual void SetDefaults();
     virtual void SetDefaultClusterFinders();
@@ -102,14 +101,14 @@ class AliITSDetTypeRec : public TObject {
     virtual Int_t GetRunNumber() const {return fRunNumber;}
 
   private:
-
+    // private methods
+    virtual void SetLoader(AliITSLoader* loader) {fLoader=loader;}
     static const Int_t fgkNdettypes;          // number of det. types
     static const Int_t fgkDefaultNModulesSPD; // Total numbers of SPD modules by default
     static const Int_t fgkDefaultNModulesSDD; // Total numbers of SDD modules by default
     static const Int_t fgkDefaultNModulesSSD; // Total numbers of SSD modules by default
-    Int_t fNMod[3];                           // numbers of modules from different types
+    Int_t *fNMod;     // numbers of modules from different types
 
-    AliITSgeom   *fGeom;          // ITS geometry
     TObjArray    *fReconstruction;//! [NDet]
     TObjArray    *fSegmentation;  //! [NDet]
     TObjArray    *fCalibration;   //! [NMod]
@@ -128,10 +127,10 @@ class AliITSDetTypeRec : public TObject {
     Int_t         fNRecPoints; // Number of rec points
 
     TString fSelectedVertexer; // Vertexer selected in CreateVertexer
-    AliITSLoader* fLoader;     // ITS loader
+    AliITSLoader* fLoader;     //! ITS loader
     Int_t         fRunNumber;    //! run number (to access DB)
 
-    ClassDef(AliITSDetTypeRec,4) // ITS Reconstruction structure
+    ClassDef(AliITSDetTypeRec,5) // ITS Reconstruction structure
 };
 
 #endif
index 63ab36069bf2c2e26b486b1d459708adcaa864f1..9be5bf547c44290ff6747e816d68a337de27b348 100644 (file)
@@ -20,6 +20,7 @@ ClassImp(AliITSLoader)
   AliITSLoader::AliITSLoader():AliLoader(){
   // Default constructor
   fITSpid = 0;
+  fGeom = 0;
 }
 /*********************************************************************/
 AliITSLoader::AliITSLoader(const Char_t *name,const Char_t *topfoldername):
@@ -59,6 +60,7 @@ AliLoader(name,topfoldername){
     cascadeDataLoader->SetEventFolder(fEventFolder);
     cascadeDataLoader->SetFolder(GetDetectorDataFolder());
     fITSpid=0;
+    fGeom = 0;
 }
 /**********************************************************************/
 AliITSLoader::AliITSLoader(const Char_t *name,TFolder *topfolder): 
@@ -97,7 +99,8 @@ AliLoader(name,topfolder) {
     fDataLoaders->Add(cascadeDataLoader);
     cascadeDataLoader->SetEventFolder(fEventFolder);
     cascadeDataLoader->SetFolder(GetDetectorDataFolder());
-    fITSpid=0;
+    fITSpid = 0;
+    fGeom = 0;
 }
 
 //______________________________________________________________________
@@ -139,6 +142,7 @@ AliITSLoader::~AliITSLoader(){
     dl = GetCascadeDataLoader();
     fDataLoaders->Remove(dl);
     if(fITSpid)delete fITSpid;
+    if(fGeom)delete fGeom;
 }
 /*
 //----------------------------------------------------------------------
@@ -309,22 +313,29 @@ void AliITSLoader::MakeTree(Option_t *opt){
 }
 
 //----------------------------------------------------------------------
-AliITSgeom* AliITSLoader::GetITSgeom() {
+AliITSgeom* AliITSLoader::GetITSgeom(Bool_t force) {
   // retrieves the ITS geometry from file
+  if(fGeom && !force)return fGeom;
+  if(fGeom && force){
+    delete fGeom;
+    fGeom = 0;
+  }
   AliRunLoader *runLoader = GetRunLoader();
- if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
 if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
   if (!runLoader->GetAliRun()) {
     Error("GetITSgeom", "couldn't get AliRun object");
     return NULL;
   }
   
+  TDirectory *curdir = gDirectory;
   runLoader->CdGAFile();
-  AliITSgeom* geom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
-  if(!geom){
+  fGeom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
+  curdir->cd();
+  if(!fGeom){
     Error("GetITSgeom","no ITS geometry available");
     return NULL;
   }
   
-  return geom;
+  return fGeom;
 }
 
index f9c0c106e9a1640ffeb7d7634fa920542c9f62b6..bbe9a900e8877fa0d62aad8eb831cf4a477b61bb 100644 (file)
@@ -109,8 +109,10 @@ class AliITSLoader: public AliLoader{
     virtual Int_t  WriteBackTracks(Option_t* opt=""){
         return GetBackTracksDataLoader()->GetBaseLoader(0)->WriteData(opt);}
 
-    // Geometry
-    AliITSgeom* GetITSgeom();
+    // Geometry. Geom is read from file, unless already loaded
+    // readout from file can be forced if force=kTRUE
+    AliITSgeom* GetITSgeom(Bool_t force=kFALSE); 
+    void SetITSgeom(AliITSgeom* g){fGeom=g;}
     // PID
     AliITSpidESD* GetITSpid() const {return fITSpid;}
     void  AdoptITSpid(AliITSpidESD* pid) {fITSpid=pid;}
@@ -139,8 +141,9 @@ class AliITSLoader: public AliLoader{
     static const TString fgkDefaultVerticesContainerName;     //default for primary vertices container name
     static const TString fgkDefaultV0ContainerName;           //default for V0 container name
     static const TString fgkDefaultCascadeContainerName;      //default fo cascade container name
-    AliITSpidESD* fITSpid; //!pointer for ITS pid
-    ClassDef(AliITSLoader,4) // Loader for additional ITS specific trees.
+    AliITSpidESD* fITSpid; //! pointer for ITS pid
+    AliITSgeom *fGeom;     //! pointer to the ITS geometry class
+    ClassDef(AliITSLoader,5) // Loader for additional ITS specific trees.
 };
  
 #endif
index 937a18b36df4ec8cf808ef8aa3c92e10e0151f82..429f71e056cd7e9a3ebbf88582d9e23b6c723639 100644 (file)
@@ -74,19 +74,12 @@ void AliITSReconstructor::Reconstruct(AliRunLoader* runLoader) const
 // reconstruct clusters
 
 
-  AliLoader* loader = runLoader->GetLoader("ITSLoader");
+  AliITSLoader* loader = static_cast<AliITSLoader*>(runLoader->GetLoader("ITSLoader"));
   if (!loader) {
     Error("Reconstruct", "ITS loader not found");
     return;
   }
-  gAlice=runLoader->GetAliRun();
-  TDirectory* olddir = gDirectory;
-  runLoader->CdGAFile();
-  AliITSgeom* geom = (AliITSgeom*)gDirectory->Get("AliITSgeom");  
-  olddir->cd();
-  AliITSDetTypeRec* rec = new AliITSDetTypeRec();
-  rec->SetLoader((AliITSLoader*)loader);
-  rec->SetITSgeom(geom);
+  AliITSDetTypeRec* rec = new AliITSDetTypeRec(loader);
   rec->SetDefaults();
 
   loader->LoadRecPoints("recreate");
@@ -118,20 +111,13 @@ void AliITSReconstructor::Reconstruct(AliRunLoader* runLoader,
 // reconstruct clusters
 
  
-  AliLoader* loader = runLoader->GetLoader("ITSLoader");
+  AliITSLoader* loader = static_cast<AliITSLoader*>(runLoader->GetLoader("ITSLoader"));
   if (!loader) {
     Error("Reconstruct", "ITS loader not found");
     return;
   }
-  gAlice=runLoader->GetAliRun();
-  TDirectory* olddir = gDirectory;
-  runLoader->CdGAFile();
-  AliITSgeom* geom = (AliITSgeom*)gDirectory->Get("AliITSgeom");  
-  olddir->cd();
 
-  AliITSDetTypeRec* rec = new AliITSDetTypeRec();
-  rec->SetLoader((AliITSLoader*)loader);
-  rec->SetITSgeom(geom);
+  AliITSDetTypeRec* rec = new AliITSDetTypeRec(loader);
   rec->SetDefaults();
   rec->SetDefaultClusterFindersV2(kTRUE);
 
@@ -268,11 +254,8 @@ AliITSgeom* AliITSReconstructor::GetITSgeom(AliRunLoader* runLoader) const
     Error("GetITSgeom", "couldn't get AliRun object");
     return NULL;
   }
-  
-  TDirectory * olddir = gDirectory;
-  runLoader->CdGAFile();
-  AliITSgeom* geom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
-  olddir->cd();
+  AliITSLoader *loader = (AliITSLoader*)runLoader->GetLoader("ITSLoader");
+  AliITSgeom* geom = (AliITSgeom*)loader->GetITSgeom();
   if(!geom){
     Error("GetITSgeom","no ITS geometry available");
     return NULL;
index 95b61ba6ee4efdb0e7db257af4fc8ef974264ff2..30b44ac2910fc1cca3bc5672dbd5d7594193aad8 100644 (file)
@@ -97,7 +97,6 @@ AliITSTrackerV1::AliITSTrackerV1(Int_t evnumber, Bool_t flag) {
 
   //PH Initialisation taken from the default constructor
   //fITS      = IITTSS;
-  fDetTypeRec = new AliITSDetTypeRec();
   fresult = 0;
   fPtref    = 0.;
   fChi2max  =0.; 
@@ -116,8 +115,13 @@ AliITSTrackerV1::AliITSTrackerV1(Int_t evnumber, Bool_t flag) {
   
   //////////  gets information on geometry /////////////////////////////
   AliRunLoader* rl = AliRunLoader::Open("galice.root");
-  rl->CdGAFile();
-  AliITSgeom* g1 = (AliITSgeom*)gDirectory->Get("AliITSgeom");
+  AliITSLoader* loader = (AliITSLoader*)runLoader->GetLoader("ITSLoader");
+  if (!loader) {
+    Error("AliITSTrackerV1", "ITS loader not found");
+    return;
+  }
+  fDetTypeRec = new AliITSDetTypeRec(loader);
+  AliITSgeom* g1 = loader->GetITSgeom();
 
   Int_t ll=1, dd=1;
   TVector det(9);
index 9940b28c267bbc677ffcd1dd6dcbf5bc15af0a68..79f63f29cc5e78432dff0160dbc33d5c408e9649 100644 (file)
 #include "AliLog.h"
 #include "AliRun.h"
 #include "AliRunLoader.h"
-#include "AliITSLoader.h"
-#include "AliITSgeom.h"
-#include "AliITSdigitSPD.h"
 
-#include "AliTriggerInput.h"
 #include "AliITSTrigger.h"
 
 //______________________________________________________________________
@@ -47,6 +43,10 @@ AliITSTrigger::AliITSTrigger()
 {
    SetName("ITS");
    CreateInputs();
+
+   // FIX: should this be hardcoded?
+   fFODigistThreshold = 1;
+   fHighMultFODigistThreshold = 100; 
 }
 
 //______________________________________________________________________
@@ -58,18 +58,7 @@ void AliITSTrigger::CreateInputs()
    if( fInputs.GetEntriesFast() > 0 ) return;
    
    fInputs.AddLast( new AliTriggerInput( "ITS_SPD_GFO_L0",     "Global, Fast OR all detectors", 0x01 ) );
-   fInputs.AddLast( new AliTriggerInput( "ITS_SPD_LAYER_L0",   "Layer, hit in each layer",      0x02 ) );
-   fInputs.AddLast( new AliTriggerInput( "ITS_SPD_SECTOR_L0",  "Sector, hit coincidence in one sector", 0x04 ) );
-   fInputs.AddLast( new AliTriggerInput( "ITS_SPD_HSECTOR_L0", "Half Sector, hit coincidence in one half sector", 0x08 ) );
-   fInputs.AddLast( new AliTriggerInput( "ITS_SPD_SW1_L0",     "Sliding Window 1, hit coincidence on phi windows",  0x10 ) );
-   fInputs.AddLast( new AliTriggerInput( "ITS_SPD_SW2_L0",     "Sliding Window 2, hit coincidence on phi windows",  0x20 ) );
-   fInputs.AddLast( new AliTriggerInput( "ITS_SPD_VERTEX_L0",  "Vertex, hit coincidence on theta windows", 0x40 ) );
-   fInputs.AddLast( new AliTriggerInput( "ITS_SPD_SVERTEX_L0", "Sector+Vertex, hit coincidence on one sector and theta windows", 0x80 ) );
-   fInputs.AddLast( new AliTriggerInput( "ITS_SPD_HSVERTEX_L0","Half Sector+Vertex, hit coincidence on one half sector and theta windows", 0x100 ) );
-   fInputs.AddLast( new AliTriggerInput( "ITS_SPD_SWVERTEX_L0","Sliding Window+Vertex, hit coincidence on phi windows and theta windows", 0x200 ) );
-   fInputs.AddLast( new AliTriggerInput( "ITS_SPD_LUCUT_L0",   "Layer+Upper Cut, hit in each layer and FO occupancy cut", 0x400 ) );
-   // Not yet implemented
-   fInputs.AddLast( new AliTriggerInput( "ITS_SPD_HMULT_L0",   "High Multiplicity, to be defined!!", 0x600 ) );
+   fInputs.AddLast( new AliTriggerInput( "ITS_SPD_HMULT_L0",   "High Multiplicity",             0x600 ) );
 
 }
 
@@ -77,293 +66,171 @@ void AliITSTrigger::CreateInputs()
 void AliITSTrigger::Trigger()
 {
 
-   //  ********** Get run loader for the current event **********
-   AliRunLoader* runLoader = gAlice->GetRunLoader();
-
-   AliITSLoader * loader = (AliITSLoader* )runLoader->GetLoader( "ITSLoader" );
-   AliITSgeom* geom = loader->GetITSgeom();
-   loader->LoadDigits("READ");
-   TTree *treeD = loader->TreeD();
-
-   TObjArray *digDet = 0;
-   digDet = new TObjArray(3);
-
-   Int_t startSPD = geom->GetStartSPD();
-   Int_t lastSPD  = geom->GetLastSPD();
-
-   // Cut on Signal In the Pixel Detector
-   TBranch * br = treeD->GetBranch( "ITSDigitsSPD" );
-   br->SetAddress( &((*digDet)[0]) );
-   ((TClonesArray*)(digDet->At(0)))->Clear();
-
-   Int_t ndig = 0;
-   Int_t ndigfo = 0;
-   Int_t singhitthreshold = 1; // single hit threshold
-   Int_t threshold = 1;
-
-//   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;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;
-
-   for (Int_t m=startSPD; m<lastSPD; m++) {
-      treeD->GetEvent( m );
-      TClonesArray* digits = (TClonesArray*) (digDet->At(0)); // SPD only.
-      Int_t lay, stav, det;
-      geom->GetModuleId(m,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
-
-
-      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[m]++;
-            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
-
-
-   //Int_t bit1 = 0;
-   Int_t upper_cut = 120;
-
-   if ( ndigfo >= singhitthreshold ) {
-      // Set input GLOBAL FO
-      SetInput( "ITS_SPD_GFO_L0" );
-      // or SetInput( "0x01" );
-      // or ((AliTriggerInput*)fInputs.At(0))->Set();
-      // bit1 |= (1 << 1);
-   }
-
-   //  if ( ndigfo <= upper_cut) { bit1 |= (1 << 10); }
-
-   if (iFOperlayer[0] >= threshold && iFOperlayer[1] >=threshold) {
-      // Set input LAYER
-      //bit1 |= (1 << 2);
-      SetInput( "ITS_SPD_LAYER_L0" );
-      if ( ndigfo <= upper_cut) {
-         //bit1 |= (1 << 10);
-         //  LAYER and UPPER CUT
-         SetInput( "ITS_SPD_LUCUT_L0" );
-      }
-   }
-
-   // Sector coincidence
-
-   // Int_t nsec = 0;
-   Int_t finstav = 0;
-   Int_t istav;
-   Int_t jstav;
-
-   // staves layer 1  1-20
-   // staves layer 2: 0-39
-   for (istav=1; istav<21; istav++) {
-      for (jstav = finstav; jstav<finstav+4; jstav++) {
-         if ((iFOperstave[istav-1][0] >= threshold) &&
-             (iFOperstave[jstav][1] >= threshold)) {
-            // Set input SECTOR
-            //bit1 |= (1 << 3);
-            SetInput( "ITS_SPD_SECTOR_L0" );
-            if ( RequireZ10cm( iFOperChipinStave, istav-1, jstav ) == kTRUE ) {
-               // Set input SECTOR & VERTEX
-               // bit1 |= (1 << 7);
-               SetInput( "ITS_SPD_SVERTEX_L0" );
-            }
-         }
-
-      }
-      if (TMath::Even(istav)) {
-         finstav = jstav;
-      }
-
-   }
-
-   // half sector coincidence
-
-   finstav = 0;
-   for (istav=1; istav<21; istav++){
-      for (jstav = finstav; jstav<finstav+2; jstav++) {
-         if (iFOperstave[istav-1][0] >= threshold && iFOperstave[jstav][1] >= threshold) {
-            // Set input HALF SECTOR
-            //bit1 |= (1 << 4);
-            SetInput( "ITS_SPD_HSECTOR_L0" );
-            if (RequireZ10cm(iFOperChipinStave,istav-1,jstav) == kTRUE) {
-               // Set input HALF SECTOR & VERTEX
-               SetInput( "ITS_SPD_HSVERTEX_L0" );
-               //bit1 |= (1 << 8);
-            }
-         }
-      }
-      finstav = jstav;
-   }
-
-   finstav = 0;
-   for (istav=1; istav<21; istav++) {
-      for (jstav = finstav-1; jstav<finstav+3; jstav++) {
-         Int_t probe_stav = jstav;
-         if (jstav == -1) probe_stav = 39;
-         if (jstav == 40) probe_stav = 0;
-         if (iFOperstave[istav-1][0] >= threshold && iFOperstave[probe_stav][1] >= threshold) {
-            // Set input SLIDING WINDOW1
-            SetInput( "ITS_SPD_SW1_L0" );
-            //bit1 |= (1 << 5);
-         }
-      }
-      finstav = jstav-1;
-   }
-
-  // sliding window coincidence (symmetric): 1 (layer 1), 5 (layer 2)
-
-   finstav = 0;
-   for (istav=1;istav<21; istav++) {
-      for (jstav = finstav-2; jstav<finstav+3; jstav++) {
-         Int_t probe_stav = jstav;
-         if (jstav == -2) probe_stav = 38;
-         if (jstav == -1) probe_stav = 39;
-         if (jstav == 40) probe_stav = 0;
-         if (jstav == 41) probe_stav = 1;
-
-         if ((iFOperstave[istav-1][0] >= threshold) && (iFOperstave[probe_stav][1] >= threshold)) {
-            // Set input SLIDING WINDOW 2
-            SetInput( "ITS_SPD_SW2_L0" );
-            // bit1 |= (1 << 6);
-            if (RequireZ10cm(iFOperChipinStave,istav-1,probe_stav) == kTRUE) {
-               // Set input SLIDING WINDOW & VERTEX
-               SetInput( "ITS_SPD_SWVERTEX_L0" );
-               //bit1 |= (1 << 9);
-            }
-         }
-      }
-      finstav = jstav-1;
-   }
+  //  ********** Get run loader for the current event **********
+  AliRunLoader* runLoader = gAlice->GetRunLoader();
+
+  AliITSLoader* loader = (AliITSLoader* )runLoader->GetLoader( "ITSLoader" );
+  AliITSgeom* geom = loader->GetITSgeom();
+  loader->LoadDigits("READ");
+  TTree *treeD = loader->TreeD();
+
+  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 << "=================================================" << endl << endl;
 
 }
 
+//______________________________________________________________________
+void AliITSTrigger::MultiplicityTriggers(TObjArray* digDet, TTree* treeD, AliITSgeom* geom)
+{
+  // simple FO triggers that only cares about the multiplicity
+
+  // first and last module?
+  Int_t startSPD = geom->GetStartSPD();
+  Int_t lastSPD  = geom->GetLastSPD();
+
+  Int_t totalNumberOfDigits = 0;
 
+  // loop over modules
+  for (Int_t moduleIndex=startSPD; moduleIndex<lastSPD; moduleIndex++) {
+    treeD->GetEvent(moduleIndex);
+    TClonesArray* digits = (TClonesArray*) (digDet->At(0)); // SPD only.
+    
+    // get number of digits in this module
+    Int_t numberOfDigitsInModule = digits->GetEntriesFast();
+    
+    // sum of digits in all modules
+    totalNumberOfDigits = totalNumberOfDigits + numberOfDigitsInModule;
+
+  }
+
+  if (totalNumberOfDigits>=fFODigistThreshold) 
+    SetInput( "ITS_SPD_GFO_L0" );
+
+  if (totalNumberOfDigits>=fHighMultFODigistThreshold) 
+    SetInput( "ITS_SPD_HMULT_L0" );
+
+  return;
+
+}
 
 //______________________________________________________________________
-Bool_t AliITSTrigger::RequireZ10cm(Int_t iFOperChipinStave[][40][2], Int_t stave1, Int_t stave2)
+void AliITSTrigger::GeometryTriggers(TObjArray* digDet, TTree* treeD, AliITSgeom* geom)
 {
-   // z  sliding window
-   // Bool_t zFlag = kFALSE;
-
-   Int_t threshold = 1;
-   Int_t start1 = 1;
-   Int_t start2 = 3;
-   Int_t start3 = 6;
-   Int_t start4 = 7;
- //  Int_t i = 1;
-
-   for (Int_t ic=0; ic<=19; ic++) {
-      if (ic <= 5) {
-         for (Int_t jc=0;jc<=ic-1;jc++) {
-            if (iFOperChipinStave[ic][stave1][0] >=threshold) {
-               if (iFOperChipinStave[jc][stave2][1] >= threshold){
-                  return kTRUE; // zFlag = kTRUE;
-               }
-            }
-         }
-      }
-      if (ic >= 6 && ic <= 8) {
-         for (Int_t jc=(2*start1-1);jc<=(2*start1-1)+5;jc++) {
-            if (iFOperChipinStave[ic][stave1][0] >=threshold) {
-               if  (iFOperChipinStave[jc][stave2][1] >= threshold) {
-                  return kTRUE; // zFlag = kTRUE;
-               }
-            }
-         }
-         start1++;
-      }
-      if (ic >= 9 && ic <= 11) {
-         for (Int_t jc=(2*start2); jc<=(2*start2+5); jc++) {
-            if (iFOperChipinStave[ic][stave1][0] >= threshold) {
-               if (iFOperChipinStave[jc][stave2][1] >= threshold) {
-                  return kTRUE; // zFlag = kTRUE;
-               }
-            }
-         }
-         start2++;
-      }
-      if (ic >= 12 && ic <= 13) {
-         for (Int_t jc=(2*start3-1);jc<=(2*start3-1)+5;jc++) {
-            if (iFOperChipinStave[ic][stave1][0] >= threshold) {
-               if  (iFOperChipinStave[jc][stave2][1] >= threshold){
-                  return kTRUE; // zFlag = kTRUE;
-               }
-            }
-         }
-         start3++;
-      }
-      if (ic >= 14) {
-         for (Int_t jc=(2*start4);jc<=19;jc++) {
-            if (iFOperChipinStave[ic][stave1][0] >= threshold) {
-               if  (iFOperChipinStave[jc][stave2][1] >= threshold){
-                  return kTRUE; // zFlag = kTRUE;
-               }
-            }
-         }
-         start4++;
-      }
-   }
-
-   return kFALSE; // zFlag;
+
+
+  
+//   //   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;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; 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
+
+
+
+//    if ( ndigfo >= singhitthreshold ) {
+//       // Set input GLOBAL FO
+//       SetInput( "ITS_SPD_GFO_L0" );
+//       // or SetInput( "0x01" );
+//       // or ((AliTriggerInput*)fInputs.At(0))->Set();
+//       // bit1 |= (1 << 1);
+//    }
+
+   // return bit1;
 }
 
 
+
+
index 625ccd27e650c22fe141dd241baa8745df9e0a92..fa280f6adea1e6b15ca03bb1a637504c00e1c749 100644 (file)
 
 #include "AliTriggerDetector.h"
 
+#include "AliITSLoader.h"
+#include "AliITSgeom.h"
+#include "AliITSdigitSPD.h"
+
+#include "AliTriggerInput.h"
+
+
 class AliITSTrigger : public AliTriggerDetector
 {
  public:
@@ -24,7 +31,12 @@ class AliITSTrigger : public AliTriggerDetector
    virtual void    Trigger();
 
 private:
-         Bool_t    RequireZ10cm(Int_t iFOperChipinStave[][40][2], Int_t stave1, Int_t stave2);
+
+   Int_t fFODigistThreshold;         // minimum number of digits to fire the FO trigger
+   Int_t fHighMultFODigistThreshold; // minimum number of digits to fire the FO high mult trigger
+
+   void MultiplicityTriggers(TObjArray* digDet, TTree* treeD, AliITSgeom* geom);
+   void GeometryTriggers(TObjArray* digDet, TTree* treeD, AliITSgeom* geom);
 
   ClassDef( AliITSTrigger, 1 )  // ITS SPD Trigger Detector class
 };
index 00cd8ce126d67bd982085e938080807cdd574b14..e3bc6267db9d23219c4c456714681d3134279712 100644 (file)
@@ -155,8 +155,7 @@ Bool_t AliITSreconstruction::Init(){
     fRunLoader->CdGAFile();
     fITSgeom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
 
-    fDetTypeRec = new AliITSDetTypeRec();
-    fDetTypeRec->SetITSgeom(fITSgeom);
+    fDetTypeRec = new AliITSDetTypeRec(fLoader);
     fDetTypeRec->SetDefaults();
     fDet[0] = fDet[1] = fDet[2] = kTRUE;
     fEnt0 = 0;
@@ -170,7 +169,6 @@ Bool_t AliITSreconstruction::Init(){
     if (fLoader->TreeR() == 0x0) fLoader->MakeTree("R");
     if (fLoader->TreeC() == 0x0) fLoader->MakeTree("C");
  
-    fDetTypeRec->SetLoader(fLoader);
     fDetTypeRec->MakeBranchR(0);
     fDetTypeRec->MakeBranchC();
     fDetTypeRec->SetTreeAddress();
@@ -272,8 +270,6 @@ void AliITSreconstruction::Exec(const Option_t *opt){
       Info("Exec","");
 
       fRunLoader->GetEvent(evnt);
-      fDetTypeRec->SetITSgeom(fITSgeom);
-      fDetTypeRec->SetLoader(fLoader);
       if (fLoader->TreeR() == 0x0) fLoader->MakeTree("R");
       fDetTypeRec->MakeBranchR(0);
       if (fLoader->TreeC() == 0x0){