]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added new FillModules routine and cleaned up the old one.
authornilsen <nilsen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 10 Jun 2002 17:28:55 +0000 (17:28 +0000)
committernilsen <nilsen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 10 Jun 2002 17:28:55 +0000 (17:28 +0000)
ITS/AliITS.cxx
ITS/AliITS.h

index 5af7556a849e64a4bbeadb71389c5fa2fdb9b645..6f9cf74ded4da6cac38694a804630a933a8db10d 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
 
 /*
 $Log$
+Revision 1.71  2002/05/13 14:27:56  hristov
+TreeC created once per event (M.Masera)
+
 Revision 1.70  2002/05/10 22:28:30  nilsen
 Changes by Massimo Masera to allow the TTree of clusters to be written to a
 file otherthan the one with digits in it.
 Revision 1.70  2002/05/10 22:28:30  nilsen
 Changes by Massimo Masera to allow the TTree of clusters to be written to a
 file otherthan the one with digits in it.
@@ -440,10 +443,10 @@ AliITS::~AliITS(){
     // Return:
     //      none.
 
     // Return:
     //      none.
 
-    delete fHits;
-    delete fSDigits;
-    delete fDigits;
-    delete fRecPoints;
+    delete fHits; fHits=0;
+    delete fSDigits; fSDigits=0;
+//    delete fDigits; fDigits=0;
+    delete fRecPoints; fRecPoints=0;
     if(fIdName!=0) delete[] fIdName;  // Array of TStrings
     if(fIdSens!=0) delete[] fIdSens;
     if(fITSmodules!=0) {
     if(fIdName!=0) delete[] fIdName;  // Array of TStrings
     if(fIdSens!=0) delete[] fIdSens;
     if(fITSmodules!=0) {
@@ -927,7 +930,7 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
     // Return:
     //      none.
     static TTree *trH1;                 //Tree with background hits
     // Return:
     //      none.
     static TTree *trH1;                 //Tree with background hits
-    static TClonesArray *fHits2;        //List of hits for one track only
+//    static TClonesArray *fHits2;        //List of hits for one track only
     static Bool_t first=kTRUE;
     static TFile *file;
     const char *addBgr = strstr(option,"Add");
     static Bool_t first=kTRUE;
     static TFile *file;
     const char *addBgr = strstr(option,"Add");
@@ -935,13 +938,13 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
     if (addBgr ) {
        if(first) {
            file=new TFile(filename);
     if (addBgr ) {
        if(first) {
            file=new TFile(filename);
-           fHits2     = new TClonesArray("AliITShit",1000  );
+//         fHits2     = new TClonesArray("AliITShit",1000  );
        } // end if first
        first=kFALSE;
        file->cd();
        file->ls();
        // Get Hits Tree header from file
        } // end if first
        first=kFALSE;
        file->cd();
        file->ls();
        // Get Hits Tree header from file
-       if(fHits2) fHits2->Clear();
+//     if(fHits2) fHits2->Clear();
        if(trH1) delete trH1;
        trH1=0;
 
        if(trH1) delete trH1;
        trH1=0;
 
@@ -952,6 +955,7 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
            Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
        } // end if !trH1
        // Set branch addresses
            Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
        } // end if !trH1
        // Set branch addresses
+/*
        TBranch *branch;
        char branchname[20];
        sprintf(branchname,"%s",GetName());
        TBranch *branch;
        char branchname[20];
        sprintf(branchname,"%s",GetName());
@@ -959,8 +963,11 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
            branch = trH1->GetBranch(branchname);
            if (branch) branch->SetAddress(&fHits2);
        } // end if trH1 && fHits
            branch = trH1->GetBranch(branchname);
            if (branch) branch->SetAddress(&fHits2);
        } // end if trH1 && fHits
+*/
     } // end if addBgr
 
     } // end if addBgr
 
+    FillModules(gAlice->TreeH(),0); // fill from this file's tree.
+/*
     TClonesArray *itsHits = this->Hits();
     Int_t lay,lad,det,index;
     AliITShit *itsHit=0;
     TClonesArray *itsHits = this->Hits();
     Int_t lay,lad,det,index;
     AliITShit *itsHit=0;
@@ -984,10 +991,12 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
            mod->AddHit(itsHit,t,h);
        } // end loop over hits 
     } // end loop over tracks
            mod->AddHit(itsHit,t,h);
        } // end loop over hits 
     } // end loop over tracks
-
+*/
     // open the file with background
     
     if (addBgr ) {
     // open the file with background
     
     if (addBgr ) {
+       FillModules(trH1,10000000); // Default mask 10M.
+/*
        Int_t track,i;
        ntracks =(Int_t)trH1->GetEntries();     
        // Loop over tracks
        Int_t track,i;
        ntracks =(Int_t)trH1->GetEntries();     
        // Loop over tracks
@@ -1006,6 +1015,7 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
                mod->AddHit(itsHit,track,i);
            }  // end loop over hits
        } // end loop over tracks
                mod->AddHit(itsHit,track,i);
            }  // end loop over hits
        } // end loop over tracks
+*/
        TTree *fAli=gAlice->TreeK();
        TFile *fileAli=0;
        if (fAli) fileAli =fAli->GetCurrentFile();
        TTree *fAli=gAlice->TreeK();
        TFile *fileAli=0;
        if (fAli) fileAli =fAli->GetCurrentFile();
@@ -1013,6 +1023,52 @@ void AliITS::FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
     } // end if add
 }
 //______________________________________________________________________
     } // end if add
 }
 //______________________________________________________________________
+void AliITS::FillModules(TTree *treeH, Int_t mask) {
+    // fill the modules with the sorted by module hits; 
+    // can be called many times to do a merging
+    // Inputs:
+    //      TTree *treeH  The tree containing the hits to be copied into
+    //                    the modules.
+    //      Int_t mask    The track number mask to indecate which file
+    //                    this hits came from.
+    // Outputs:
+    //      none.
+    // Return:
+    //      none.
+
+    Int_t lay,lad,det,index;
+    AliITShit *itsHit=0;
+    AliITSmodule *mod=0;
+    char branchname[20];
+    sprintf(branchname,"%s",GetName());
+    TBranch *branch = treeH->GetBranch(branchname);
+    if (!branch) {
+       Error("FillModules","%s branch in TreeH not found",branchname);
+       return;
+    } // end if !branch
+    branch->SetAddress(&fHits);
+    Int_t nTracks =(Int_t) treeH->GetEntries();
+    Int_t iPrimTrack,h;
+    for(iPrimTrack=0; iPrimTrack<nTracks; iPrimTrack++){
+       ResetHits();
+       Int_t nBytes = treeH->GetEvent(iPrimTrack);
+       if (nBytes <= 0) continue;
+       Int_t nHits = fHits->GetEntriesFast();
+       for(h=0; h<nHits; h++){
+           itsHit = (AliITShit *)fHits->UncheckedAt(h);
+           itsHit->GetDetectorID(lay,lad,det);
+           if (fITSgeom) {
+               index = fITSgeom->GetModuleIndex(lay,lad,det);
+           } else {
+               index=det-1; // This should not be used.
+           } // end if [You must have fITSgeom for this to work!]
+           mod = GetModule(index);
+           itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
+           mod->AddHit(itsHit,iPrimTrack,h);
+       } // end loop over hits 
+    } // end loop over tracks
+}
+//______________________________________________________________________
 void AliITS::ClearModules(){
     // Clear the modules TObjArray.
     // Inputs:
 void AliITS::ClearModules(){
     // Clear the modules TObjArray.
     // Inputs:
index 72f49a9d3417932f5c3708d93d0ee1da2401d9b9..5acac25f969964b75fc84702479c3eca8395a9bd 100644 (file)
@@ -102,6 +102,7 @@ class AliITS : public AliDetector {
     virtual void AddHit(Int_t track, Int_t *vol, Float_t *hits);
     //------------ sort hits by module for Digitisation ----------------
     virtual void InitModules(Int_t size,Int_t &nmodules);  
     virtual void AddHit(Int_t track, Int_t *vol, Float_t *hits);
     //------------ sort hits by module for Digitisation ----------------
     virtual void InitModules(Int_t size,Int_t &nmodules);  
+    virtual void FillModules(TTree *treeH, Int_t mask = 0);
     virtual void FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
                             Option_t *opt,Text_t *filename);
     virtual void ClearModules();
     virtual void FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules,
                             Option_t *opt,Text_t *filename);
     virtual void ClearModules();