Simplification for Fast Simulator
authorfranken <franken@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 6 Apr 2001 14:38:05 +0000 (14:38 +0000)
committerfranken <franken@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 6 Apr 2001 14:38:05 +0000 (14:38 +0000)
HLT/src/AliL3Evaluate.cxx
HLT/src/AliL3Evaluate.h

index 6da45d54d871ce062237f98eb6c070fd5b9441cf..e72745f9265d2cf5eefce201f127fb1eba7c6387 100644 (file)
@@ -34,6 +34,9 @@ AliL3Evaluate::AliL3Evaluate()
   fMCFile = NULL;
   fTracks = NULL;
   fMCclusterfile = NULL;
+  fNFastPoints = 0;
+  fMcIndex = 0;
+  fMcId = 0;
 }
 
 AliL3Evaluate::AliL3Evaluate(Char_t *mcfile,Int_t *slice)
@@ -59,42 +62,26 @@ AliL3Evaluate::AliL3Evaluate(Char_t *mcfile,Int_t *slice)
 
 AliL3Evaluate::~AliL3Evaluate()
 {
-  if(fDigitsTree) 
-    fDigitsTree->Delete();
-  
-
-  /*if(fMCFile) 
-    {
-      fMCFile->Close();
-      delete fMCFile;
-    }
-  */
-  if(fTransform)
-    delete fTransform;
-  if(fTracks)
-    delete fTracks;
-  if(fPtRes)
-    delete fPtRes;
-  if(fNGoodTracksPt)
-    delete fNGoodTracksPt;
-  if(fNFoundTracksPt)
-    delete fNFoundTracksPt;
-  if(fNFakeTracksPt)
-    delete fNFakeTracksPt;
-  if(fTrackEffPt)
-    delete fTrackEffPt;
-  if(fFakeTrackEffPt)
-    delete fFakeTrackEffPt;
-  if(fNGoodTracksEta)
-    delete fNGoodTracksEta;
-  if(fNFoundTracksEta)
-    delete fNFoundTracksEta;
-  if(fNFakeTracksEta)
-    delete fNFakeTracksEta;
-  if(fTrackEffEta)
-    delete fTrackEffEta;
-  if(fFakeTrackEffEta)
-    delete fFakeTrackEffEta;
+  if(fDigitsTree) fDigitsTree->Delete();
+  if(fMCFile) {
+    fMCFile->Close();
+    delete fMCFile;
+  }
+  if(fTransform) delete fTransform;
+  if(fTracks) delete fTracks;
+  if(fPtRes) delete fPtRes;
+  if(fNGoodTracksPt) delete fNGoodTracksPt;
+  if(fNFoundTracksPt) delete fNFoundTracksPt;
+  if(fNFakeTracksPt) delete fNFakeTracksPt;
+  if(fTrackEffPt) delete fTrackEffPt;
+  if(fFakeTrackEffPt) delete fFakeTrackEffPt;
+  if(fNGoodTracksEta) delete fNGoodTracksEta;
+  if(fNFoundTracksEta) delete fNFoundTracksEta;
+  if(fNFakeTracksEta) delete fNFakeTracksEta;
+  if(fTrackEffEta) delete fTrackEffEta;
+  if(fFakeTrackEffEta) delete fFakeTrackEffEta;
+  if(fMcIndex) delete [] fMcIndex;
+  if(fMcId)    delete [] fMcId;
 }
 
 void AliL3Evaluate::Setup(Char_t *trackfile,Char_t *path)
@@ -157,6 +144,7 @@ void AliL3Evaluate::SetupFast(Char_t *trackfile,Char_t *mcClusterfile,Char_t *pa
   //Setup for using the fast simulator.
 
   fIsSlow = false;
+  GetFastClusterIDs(path);
   
   fMCclusterfile = new TFile(mcClusterfile);
   if(!fMCclusterfile->IsOpen())
@@ -170,25 +158,6 @@ void AliL3Evaluate::SetupFast(Char_t *trackfile,Char_t *mcClusterfile,Char_t *pa
       <<"Error setting up particle array"<<ENDLOG;
 }
 
-void AliL3Evaluate::CreateHistos(Int_t nbin,Int_t xlow,Int_t xup)
-{
-  //Create the histograms 
-  
-  fPtRes = new TH1F("fPtRes","Relative Pt resolution",30,-10.,10.); 
-  fNGoodTracksPt = new TH1F("fNGoodTracksPt","Good tracks vs pt",nbin,xlow,xup);    
-  fNFoundTracksPt = new TH1F("fNFoundTracksPt","Found tracks vs pt",nbin,xlow,xup);
-  fNFakeTracksPt = new TH1F("fNFakeTracksPt","Fake tracks vs pt",nbin,xlow,xup);
-  fTrackEffPt = new TH1F("fTrackEffPt","Tracking efficiency vs pt",nbin,xlow,xup);
-  fFakeTrackEffPt = new TH1F("fFakeTrackEffPt","Efficiency for fake tracks vs pt",nbin,xlow,xup);
-  
-  fNGoodTracksEta = new TH1F("fNGoodTracksEta","Good tracks vs eta",20,-50,50);
-  fNFoundTracksEta = new TH1F("fNFoundTracksEta","Found tracks vs eta",20,-50,50);
-  fNFakeTracksEta = new TH1F("fNFakeTracksEta","Fake tracks vs eta",20,-50,50);
-  fTrackEffEta = new TH1F("fTrackEffEta","Tracking efficienct vs eta",20,-50,50);
-  fFakeTrackEffEta = new TH1F("fFakeTrackEffEta","Efficiency for fake tracks vs eta",20,-50,50);
-
-}
-
 Bool_t AliL3Evaluate::SetDigitsTree()
 {
 
@@ -407,138 +376,39 @@ void AliL3Evaluate::EvaluateGlobal(Int_t min_points,Int_t good_number)
   CalcEffHistos();
 }
 
-void AliL3Evaluate::FillEffHistos(TObjArray *good_particles,Int_t *particle_id)
-{  
-  //Fill the efficiency histograms.
-
-  for(Int_t i=0; i<good_particles->GetEntriesFast(); i++)
-    {
-      TParticle *p = (TParticle*)good_particles->UncheckedAt(i);
-      Double_t ptg=p->Pt(),pzg=p->Pz();
-      Float_t dipangle=TMath::ATan2(pzg,ptg)*180./TMath::Pi();
-      fNGoodTracksPt->Fill(ptg);
-      fNGoodTracksEta->Fill(dipangle);
-      Int_t found = 0;
-      for(Int_t k=0; k<fTracks->GetNTracks(); k++)
-       {
-         AliL3Track *track = fTracks->GetCheckedTrack(k);
-         if(!track) continue;
-         Int_t nHits = track->GetNumberOfPoints();
-         if(nHits < fMinPointsOnTrack) break;
-         
-         Int_t tracklabel;
-         tracklabel = track->GetMCid();
-         
-         if(TMath::Abs(tracklabel) != particle_id[i]) continue;
-         found=1;
-         if(tracklabel == particle_id[i]) {fNFoundTracksPt->Fill(ptg); fNFoundTracksEta->Fill(dipangle);}
-         else {fNFakeTracksPt->Fill(ptg); fNFakeTracksEta->Fill(dipangle);}
-         Float_t pt=track->GetPt();
-         fPtRes->Fill((pt-ptg)/ptg*100.);
-         break;
-         
-       }
-    }
-}
-
-void AliL3Evaluate::CalcEffHistos(){  
-  
-  Stat_t ngood=fNGoodTracksPt->GetEntries();
-  Stat_t nfound=fNFoundTracksPt->GetEntries();
-  Stat_t nfake=fNFakeTracksPt->GetEntries();
-  
-  LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency")
-    <<AliL3Log::kDec<<"There was "<<ngood<<" generated good tracks"<<ENDLOG;
-  LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency")
-    <<AliL3Log::kDec<<"Found "<<nfound<<" tracks"<<ENDLOG;
-  LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency")
-    <<AliL3Log::kDec<<"Integral efficiency is about "<<nfound/ngood*100<<ENDLOG;
-  LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency")
-    <<AliL3Log::kDec<<"Fake tracks relative is about "<<nfake/ngood*100<<ENDLOG;
-  
-  fNFoundTracksPt->Sumw2(); fNGoodTracksPt->Sumw2();
-  fTrackEffPt->Divide(fNFoundTracksPt,fNGoodTracksPt,1,1.,"b");
-  fFakeTrackEffPt->Divide(fNFakeTracksPt,fNGoodTracksPt,1,1.,"b");
-  fTrackEffPt->SetMaximum(1.4);
-  fTrackEffPt->SetXTitle("P_{T} [GeV]");
-  fTrackEffPt->SetLineWidth(2);
-  fFakeTrackEffPt->SetFillStyle(3013);
-  fTrackEffPt->SetLineColor(4);
-  fFakeTrackEffPt->SetFillColor(2);
-  
-  fNFoundTracksEta->Sumw2(); fNGoodTracksEta->Sumw2();
-  fTrackEffEta->Divide(fNFoundTracksEta,fNGoodTracksEta,1,1.,"b");
-  fFakeTrackEffEta->Divide(fNFakeTracksEta,fNGoodTracksEta,1,1.,"b");
-  fTrackEffEta->SetMaximum(1.4);
-  fTrackEffEta->SetXTitle("#lambda [degrees]");
-  fTrackEffEta->SetLineWidth(2);
-  fFakeTrackEffEta->SetFillStyle(3013);
-  fTrackEffEta->SetLineColor(4);
-  fFakeTrackEffEta->SetFillColor(2);
-       
-}
-
 void AliL3Evaluate::AssignIDs()
 {
   //Assign MC id to the tracks.
   
-  UInt_t *index=0,tmp_ind=0;
-  Int_t *pID=0,npoints=0;
-  
-  if(!fIsSlow)
-    {
-      pID = GetFastIDs(tmp_ind,npoints);
-      index = (UInt_t*)tmp_ind;
-    }
-  
   fTracks->QSort();
   LOG(AliL3Log::kDebug,"AliL3Evaluate::AssignIDs","Track Loop")
     <<"Assigning MC id to the found tracks...."<<ENDLOG;
   for(Int_t i=0; i<fTracks->GetNTracks(); i++)
     {
       AliL3Track *track = (AliL3Track*)fTracks->GetCheckedTrack(i);
-      if(!track) 
-       {
-         LOG(AliL3Log::kWarning,"AliL3Evaluate::AssignIDs","Track Loop")
-           <<AliL3Log::kDec<<"No track in track array, index "<<i<<ENDLOG;
-         continue;
-       }
+      if(!track) continue; 
       if(track->GetNumberOfPoints() < fMinPointsOnTrack) break;
-      Int_t tID;
-      if(!fIsSlow)
-       tID = GetMCTrackLabel(track,index,pID,npoints);
-      else
-       tID = GetMCTrackLabel(track);
+      Int_t tID = GetMCTrackLabel(track);
       track->SetMCid(tID);
       printf("track %i id %d\n",i,tID);
     }
-  
-  if(pID)   delete [] pID;
-  if(index) delete [] index;
 }
 
 
 struct S {Int_t lab; Int_t max;};
-Int_t AliL3Evaluate::GetMCTrackLabel(AliL3Track *track,UInt_t *index,Int_t *pID,Int_t npoints) 
-{
+Int_t AliL3Evaluate::GetMCTrackLabel(AliL3Track *track){ 
   //Returns the MCtrackID of the belonging clusters.
   //If MCLabel < 0, means that track is fake.
   //Fake track means that more than 10 percent of clusters are assigned incorrectly.
-  
+
   Int_t num_of_clusters = track->GetNumberOfPoints();
   S *s=new S[num_of_clusters];
   Int_t i;
   for (i=0; i<num_of_clusters; i++) s[i].lab=s[i].max=0;
   UInt_t *hitnum = track->GetHitNumbers();  
   UInt_t id;
-
-  Int_t **trackID;
     
-  if(fIsSlow)
-    trackID = GetClusterIDs(track);
-  else
-    trackID = GetClusterIDs(track,index,pID,npoints);
-  
+  Int_t **  trackID = GetClusterIDs(track);
 
   Int_t lab=123456789;
   for (i=0; i<num_of_clusters; i++) 
@@ -550,10 +420,7 @@ Int_t AliL3Evaluate::GetMCTrackLabel(AliL3Track *track,UInt_t *index,Int_t *pID,
       UInt_t pos = id&0x3fffff;              
       
       AliL3SpacePointData *points = fClusters[slice][patch];
-      
-      if(!points) 
-       continue;
-      
+      if(!points) continue; 
       if(pos>=fNcl[slice][patch]) 
        {
          LOG(AliL3Log::kError,"AliL3Evaluate::GetMCTrackLabel","Clusterarray")
@@ -585,10 +452,7 @@ Int_t AliL3Evaluate::GetMCTrackLabel(AliL3Track *track,UInt_t *index,Int_t *pID,
       UInt_t pos = id&0x3fffff;              
       
       AliL3SpacePointData *points = fClusters[slice][patch];
-      
-      if(!points) 
-       continue;
-      
+      if(!points) continue; 
       if(pos>=fNcl[slice][patch]) 
        {
          LOG(AliL3Log::kError,"AliL3Evaluate::GetMCTrackLabel","Clusterarray")
@@ -611,19 +475,18 @@ Int_t AliL3Evaluate::GetMCTrackLabel(AliL3Track *track,UInt_t *index,Int_t *pID,
 }
 
 
-Int_t **AliL3Evaluate::GetClusterIDs(AliL3Track *track,UInt_t *index,Int_t *pID,Int_t npoints)
+Int_t **AliL3Evaluate::GetClusterIDs(AliL3Track *track)
 {
   //Return the MC information of all clusters belonging to track.
-  
+
   Int_t num_of_clusters = track->GetNumberOfPoints();
   Int_t **trackID = new Int_t*[num_of_clusters];
   
   UInt_t *hitnum = track->GetHitNumbers();  
   UInt_t id;
-
   
   Float_t xyz[3];
-  Int_t sector,padrow;
+  Int_t padrow;
   for(Int_t i=0; i<num_of_clusters; i++)
     {
       id = hitnum[i];
@@ -671,10 +534,10 @@ Int_t **AliL3Evaluate::GetClusterIDs(AliL3Track *track,UInt_t *index,Int_t *pID,
       else
        {
          Int_t tmp_pid=0;
-         for(Int_t ii=0; ii<npoints; ii++)
+         for(Int_t ii=0; ii<fNFastPoints; ii++)
            {
-             tmp_pid = pID[ii];
-             if(index[ii] == id) break;
+             tmp_pid = fMcId[ii];
+             if(fMcIndex[ii] == id) break;
            }
          trackID[i] = new Int_t[3];
          trackID[i][0] = tmp_pid;
@@ -685,32 +548,118 @@ Int_t **AliL3Evaluate::GetClusterIDs(AliL3Track *track,UInt_t *index,Int_t *pID,
   return trackID;
 }
 
-Int_t *AliL3Evaluate::GetFastIDs(UInt_t &tmp_ind,Int_t &npoints)
+void AliL3Evaluate::GetFastClusterIDs(Char_t *path)
 {
   //Get the MC id of space points in case of using the fast simulator. 
-
-  FILE *infile = fopen("point_mc.dat","r");
-  if(!infile) return 0;
+  char fname[256];
+  sprintf(fname,"%s/point_mc.dat",path);
+  FILE *infile = fopen(fname,"r");
+  if(!infile) return;
   Int_t hitid,hitmc,i;
   
   for(i=0; ; i++)
     if(fscanf(infile,"%d %d",&hitid,&hitmc)==EOF) break;
-  npoints = i;
   rewind(infile);
-  Int_t *pID = new Int_t[npoints];
-  UInt_t *ind = new UInt_t[npoints];
-  tmp_ind = (UInt_t)ind;
+  fNFastPoints = i;
+  fMcId = new Int_t[fNFastPoints];
+  fMcIndex = new UInt_t[fNFastPoints];
   
-  for(i=0; i<npoints; i++)
+  for(i=0; i<fNFastPoints; i++)
     {
       if(fscanf(infile,"%d %d",&hitid,&hitmc)==EOF) break;
-      pID[i] = hitmc;
-      ind[i] = hitid;
+      fMcId[i] = hitmc;
+      fMcIndex[i] = hitid;
     }
   fclose(infile);
+}
+
+void AliL3Evaluate::CreateHistos(Int_t nbin,Int_t xlow,Int_t xup)
+{
+  //Create the histograms 
+  
+  fPtRes = new TH1F("fPtRes","Relative Pt resolution",30,-10.,10.); 
+  fNGoodTracksPt = new TH1F("fNGoodTracksPt","Good tracks vs pt",nbin,xlow,xup);    
+  fNFoundTracksPt = new TH1F("fNFoundTracksPt","Found tracks vs pt",nbin,xlow,xup);
+  fNFakeTracksPt = new TH1F("fNFakeTracksPt","Fake tracks vs pt",nbin,xlow,xup);
+  fTrackEffPt = new TH1F("fTrackEffPt","Tracking efficiency vs pt",nbin,xlow,xup);
+  fFakeTrackEffPt = new TH1F("fFakeTrackEffPt","Efficiency for fake tracks vs pt",nbin,xlow,xup);
+  
+  fNGoodTracksEta = new TH1F("fNGoodTracksEta","Good tracks vs eta",20,-50,50);
+  fNFoundTracksEta = new TH1F("fNFoundTracksEta","Found tracks vs eta",20,-50,50);
+  fNFakeTracksEta = new TH1F("fNFakeTracksEta","Fake tracks vs eta",20,-50,50);
+  fTrackEffEta = new TH1F("fTrackEffEta","Tracking efficienct vs eta",20,-50,50);
+  fFakeTrackEffEta = new TH1F("fFakeTrackEffEta","Efficiency for fake tracks vs eta",20,-50,50);
+}
 
-  return pID;
+void AliL3Evaluate::FillEffHistos(TObjArray *good_particles,Int_t *particle_id)
+{  
+  //Fill the efficiency histograms.
 
+  for(Int_t i=0; i<good_particles->GetEntriesFast(); i++)
+    {
+      TParticle *p = (TParticle*)good_particles->UncheckedAt(i);
+      Double_t ptg=p->Pt(),pzg=p->Pz();
+      Float_t dipangle=TMath::ATan2(pzg,ptg)*180./TMath::Pi();
+      fNGoodTracksPt->Fill(ptg);
+      fNGoodTracksEta->Fill(dipangle);
+      Int_t found = 0;
+      for(Int_t k=0; k<fTracks->GetNTracks(); k++)
+       {
+         AliL3Track *track = fTracks->GetCheckedTrack(k);
+         if(!track) continue;
+         Int_t nHits = track->GetNumberOfPoints();
+         if(nHits < fMinPointsOnTrack) break;
+         
+         Int_t tracklabel;
+         tracklabel = track->GetMCid();
+         
+         if(TMath::Abs(tracklabel) != particle_id[i]) continue;
+         found=1;
+         if(tracklabel == particle_id[i]) {fNFoundTracksPt->Fill(ptg); fNFoundTracksEta->Fill(dipangle);}
+         else {fNFakeTracksPt->Fill(ptg); fNFakeTracksEta->Fill(dipangle);}
+         Float_t pt=track->GetPt();
+         fPtRes->Fill((pt-ptg)/ptg*100.);
+         break;
+         
+       }
+    }
+}
+
+void AliL3Evaluate::CalcEffHistos(){  
+  
+  Stat_t ngood=fNGoodTracksPt->GetEntries();
+  Stat_t nfound=fNFoundTracksPt->GetEntries();
+  Stat_t nfake=fNFakeTracksPt->GetEntries();
+  
+  LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency")
+    <<AliL3Log::kDec<<"There was "<<ngood<<" generated good tracks"<<ENDLOG;
+  LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency")
+    <<AliL3Log::kDec<<"Found "<<nfound<<" tracks"<<ENDLOG;
+  LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency")
+    <<AliL3Log::kDec<<"Integral efficiency is about "<<nfound/ngood*100<<ENDLOG;
+  LOG(AliL3Log::kInformational,"AliL3Evaluate::FillEffHistos","Efficiency")
+    <<AliL3Log::kDec<<"Fake tracks relative is about "<<nfake/ngood*100<<ENDLOG;
+  
+  fNFoundTracksPt->Sumw2(); fNGoodTracksPt->Sumw2();
+  fTrackEffPt->Divide(fNFoundTracksPt,fNGoodTracksPt,1,1.,"b");
+  fFakeTrackEffPt->Divide(fNFakeTracksPt,fNGoodTracksPt,1,1.,"b");
+  fTrackEffPt->SetMaximum(1.4);
+  fTrackEffPt->SetXTitle("P_{T} [GeV]");
+  fTrackEffPt->SetLineWidth(2);
+  fFakeTrackEffPt->SetFillStyle(3013);
+  fTrackEffPt->SetLineColor(4);
+  fFakeTrackEffPt->SetFillColor(2);
+  
+  fNFoundTracksEta->Sumw2(); fNGoodTracksEta->Sumw2();
+  fTrackEffEta->Divide(fNFoundTracksEta,fNGoodTracksEta,1,1.,"b");
+  fFakeTrackEffEta->Divide(fNFakeTracksEta,fNGoodTracksEta,1,1.,"b");
+  fTrackEffEta->SetMaximum(1.4);
+  fTrackEffEta->SetXTitle("#lambda [degrees]");
+  fTrackEffEta->SetLineWidth(2);
+  fFakeTrackEffEta->SetFillStyle(3013);
+  fTrackEffEta->SetLineColor(4);
+  fFakeTrackEffEta->SetFillColor(2);
+       
 }
 
 void AliL3Evaluate::Write2File(Char_t *outputfile)
index 1533b8d250527ecb4081faa9e83f6e9c71a1318a..f5bf3a6b20a66ba632f79e8a0067e53ecb9035f8 100644 (file)
@@ -38,8 +38,8 @@ class AliL3Evaluate : public TObject {
   Int_t fMinPointsOnTrack;  //Minimum points on track to be considered.
   Bool_t fIsSlow;
   Int_t fNFastPoints;
-  UInt_t fMcIndex;
-  Int_t fMcId;
+  UInt_t *fMcIndex;//!
+  Int_t *fMcId;//!
   
   //Histograms
   TH1F *fPtRes;
@@ -60,9 +60,9 @@ class AliL3Evaluate : public TObject {
   Bool_t SetDigitsTree();
   Bool_t SetMCParticleArray();
   TObjArray *DefineGoodTracks(Int_t slice,Int_t *padrow,Int_t good_number,Int_t *particle_id);
-  Int_t GetMCTrackLabel(AliL3Track *track,UInt_t *index=0,Int_t *pID=0,Int_t npoints=0);
-  Int_t **GetClusterIDs(AliL3Track *track,UInt_t *index=0,Int_t *pID=0,Int_t npoints=0);
-  Int_t *GetFastIDs(UInt_t &tmp_ind,Int_t &npoints);
+  Int_t GetMCTrackLabel(AliL3Track *track);
+  Int_t **GetClusterIDs(AliL3Track *track);
+  void GetFastClusterIDs(Char_t *path);
   void Setup(Char_t *trackfile,Char_t *path);
 
  public:
@@ -71,8 +71,8 @@ class AliL3Evaluate : public TObject {
 
   virtual ~AliL3Evaluate();
 
-  void SetupFast(Char_t *trackfile,Char_t *mcClusterfile,Char_t *path="./");
-  void SetupSlow(Char_t *trackfile,Char_t *path="./");
+  void SetupFast(Char_t *trackfile,Char_t *mcClusterfile,Char_t *path=".");
+  void SetupSlow(Char_t *trackfile,Char_t *path=".");
   void CreateHistos(Int_t nbin=20,Int_t xlow=0,Int_t xup=4);
   void EvaluatePatch(Int_t slice,Int_t patch,Int_t min_points,Int_t good_number);
   void EvaluateSlice(Int_t slice,Int_t min_points,Int_t good_number);