+++ /dev/null
-/****************************************************************************
- * This macro is supposed to do reconstruction in the barrel ALICE trackers *
- * (Make sure you have TPC digits and ITS hits before using this macro !!!) *
- * It does the following steps (July 9, 2002,Dubna) *
- * 1) TPC cluster finding *
- * 2) TPC track finding *
- * 3) ITS cluster finding V2 *
- * 4) ITS track finding V2 *
- * 5) ITS back track propagation V2 *
- * 6) TPC back track propagation *
- * (Origin: I.Belikov, CERN, Jouri.Belikov@cern.ch) *
- ****************************************************************************/
-
-#ifndef __CINT__
- #include "alles.h"
- #include "AliMagF.h"
- #include "AliTPCtracker.h"
-
- #include "AliITS.h"
- #include "AliITSgeom.h"
- #include "AliITSRecPoint.h"
- #include "AliITSclusterV2.h"
- #include "AliITSsimulationFastPoints.h"
- #include "AliITStrackerV2.h"
- #include<iostream.h>
-#endif
-
-Int_t TPCFindClusters(const Char_t *inname, const Char_t *outname, Int_t n);
-Int_t TPCFindTracks(const Char_t *inname, const Char_t *outname, Int_t n);
-Int_t TPCSortTracks(const Char_t *inname, const Char_t *inname2, const Char_t *outname, Int_t n);
-Int_t TPCPropagateBack(const Char_t *inname, const Char_t *outname);
-
-Int_t ITSFindClusters(const Char_t *inname, const Char_t *outname, Int_t n);
-Int_t ITSFindTracks(const Char_t *inname, const Char_t *inname2, const Char_t *outname, Int_t n);
-Int_t ITSPropagateBack(const Char_t *inname, const Char_t *outname);
-
-
-Int_t AliBarrelReconstructionV2(Int_t n=1) {
- //const Char_t *TPCdigName="rfio:galice.root";
- const Char_t *TPCdigName="galice.root";
- const Char_t *TPCclsName="AliTPCclusters.root";
- const Char_t *TPCtrkName="AliTPCtracks.root";
- const Char_t *TPCtrkNameS="AliTPCtracksSorted.root";
-
-
- //const Char_t *ITSdigName="rfio:galice.root";
- const Char_t *ITSdigName="galice.root";
- const Char_t *ITSclsName="AliITSclustersV2.root";
- const Char_t *ITStrkName="AliITStracksV2.root";
-
- AliKalmanTrack::SetConvConst(100/0.299792458/0.2/gAlice->Field()->Factor());
-
-
-// ********** Find TPC clusters *********** //
- if (TPCFindClusters(TPCdigName,TPCclsName, n)) {
- cerr<<"Failed to get TPC clusters !\n";
- return 1;
- }
-
-// ********** Find TPC tracks *********** //
- if (TPCFindTracks(TPCclsName,TPCtrkName,n)) {
- cerr<<"Failed to get TPC tracks !\n";
- return 1;
- }
-
-// ********** Sort and label TPC tracks *********** //
- if (TPCSortTracks(TPCclsName,TPCtrkName,TPCtrkNameS,n)) {
- cerr<<"Failed to sort TPC tracks !\n";
- return 1;
- }
-
-// ********** Find ITS clusters *********** //
- if (ITSFindClusters(ITSdigName,ITSclsName,n)) {
- cerr<<"Failed to get ITS clusters !\n";
- return 1;
- }
-
-// ********** Find ITS tracks *********** //
- {
- //TFile *clsFile=TFile::Open(ITSclsName);
- if (ITSFindTracks(TPCtrkNameS,ITSclsName,ITStrkName,n)) {
- cerr<<"Failed to get ITS tracks !\n";
- return 1;
- }
- //clsFile->Close();
- }
- return 1;
-// ********** Back propagation of the ITS tracks *********** //
- {TFile *clsFile=TFile::Open(ITSclsName);
- if (ITSPropagateBack(ITStrkName,TPCtrkNameS)) {
- cerr<<"Failed to propagate back the ITS tracks !\n";
- return 1;
- }
- clsFile->Close();}
-
-
-// ********** Back propagation of the TPC tracks *********** //
- {TFile *clsFile=TFile::Open(TPCclsName);
- if (TPCPropagateBack(TPCtrkName,TPCtrkName)) {
- cerr<<"Failed to propagate back the TPC tracks !\n";
- return 1;
- }
- clsFile->Close();}
-
- return 0;
-}
-
-
-Int_t TPCFindClusters(const Char_t *inname, const Char_t *outname, Int_t n) {
- Int_t rc=0;
- const Char_t *name="TPCFindClusters";
- cerr<<'\n'<<name<<"...\n";
- gBenchmark->Start(name);
-
- TFile *out=TFile::Open(outname,"recreate");
- TFile *in =TFile::Open(inname);
-
- AliTPCParam *param=(AliTPCParam *)in->Get("75x40_100x60_150x60");
- if (!param) {cerr<<"TPC parameters have not been found !\n"; return 1;}
- AliTPCv2 tpc;
- tpc.SetParam(param);
-
- //tpc.Digits2Clusters(out); //MI change
- cout<<"TPCFindClusters: nev ="<<n<<endl;
- for (Int_t i=0;i<n;i++){
- printf("Processing event %d\n",i);
- tpc.Digits2Clusters(out,i);
- // AliTPCclusterer::Digits2Clusters(dig, out, i);
- }
- in->Close();
- out->Close();
- gBenchmark->Stop(name);
- gBenchmark->Show(name);
-
- return rc;
-}
-
-Int_t TPCFindTracks(const Char_t *inname, const Char_t *outname, Int_t n) {
- Int_t rc=0;
- const Char_t *name="TPCFindTracks";
- cerr<<'\n'<<name<<"...\n";
- gBenchmark->Start(name);
- TFile *out=TFile::Open(outname,"recreate");
- TFile *in =TFile::Open(inname);
- AliTPCParam *param=(AliTPCParam *)in->Get("75x40_100x60_150x60");
- if (!param) {cerr<<"TPC parameters have not been found !\n"; return 1;}
-
- //AliTPCtracker *tracker=new AliTPCtracker(param);
- //rc=tracker->Clusters2Tracks(0,out);
- //delete tracker;
- cout<<"TPCFindTracks: nev ="<<n<<endl;
-
- for (Int_t i=0;i<n;i++){
- printf("Processing event %d\n",i);
- AliTPCtracker *tracker = new AliTPCtracker(param,i);
- //Int_t rc=
- tracker->Clusters2Tracks(0,out);
- delete tracker;
- }
-
- in->Close();
- out->Close();
- gBenchmark->Stop(name);
- gBenchmark->Show(name);
-
- return rc;
-}
-Int_t TPCSortTracks(const Char_t *inname, const Char_t *inname2, const Char_t * outname, Int_t eventn){
- Int_t rc=0;
- const Char_t *name="TPCSortTracks";
- cerr<<'\n'<<name<<"...\n";
- gBenchmark->Start(name);
-
- TFile *out =TFile::Open(outname,"recreate");
- TFile *in1 =TFile::Open(inname);
- TFile *in2 =TFile::Open(inname2);
-
-
- AliTPCParam *param=(AliTPCParam *)in1->Get("75x40_100x60_150x60");
- if (!param) {cerr<<"TPC parameters have not been found !\n"; return 1;}
-
- cout<<"TPCSortedtracks: nev ="<<eventn<<endl;
-
-
- // loop over events
- for (Int_t event=0;event<eventn; event++){
- TObjArray tarray(10000);
- AliTPCtrack *iotrack=0;
- Int_t i;
-
-
- in2->cd();
- char tname[100];
- sprintf(tname,"TreeT_TPC_%d",event);
-
- TTree *tracktree=(TTree*)in2->Get(tname);
- TBranch *tbranch=tracktree->GetBranch("tracks");
- Int_t nentr=(Int_t)tracktree->GetEntries();
- for (i=0; i<nentr; i++) {
- iotrack=new AliTPCtrack;
- tbranch->SetAddress(&iotrack);
- tracktree->GetEvent(i);
- tarray.AddLast(iotrack);
- }
- tarray.Sort();
- // in2->Close();
-
- //assign thacks GEANT labels
- in1->cd();
- AliTPCtracker *tracker = new AliTPCtracker(param,event);
- tracker->LoadInnerSectors();
- tracker->LoadOuterSectors();
- for (i=0; i<nentr; i++) {
- iotrack=(AliTPCtrack*)tarray.UncheckedAt(i);
- tracker->CookLabel(iotrack,0.1);
- }
- delete tracker;
- //in->Close();
- //end of GEANT label assignment
-
- tracktree=new TTree(tname,"Tree with TPC tracks");
- tracktree->Branch("tracks","AliTPCtrack",&iotrack,32000,0);
- for (i=0; i<nentr; i++) {
- iotrack=(AliTPCtrack*)tarray.UncheckedAt(i);
- tracktree->Fill();
- }
- out->cd();
- tracktree->Write();
- }
-
- out->Close();
- in2->Close();
- in1->Close();
-
- gBenchmark->Stop(name);
- gBenchmark->Show(name);
-
- return rc;
-}
-
-Int_t ITSFindClusters(const Char_t *inname, const Char_t *outname, Int_t n) {
- Int_t rc=0;
- const Char_t *name="ITSFindClusters";
- cerr<<'\n'<<name<<"...\n";
- gBenchmark->Start(name);
- TFile *out=TFile::Open(outname,"recreate");
- TFile *in =TFile::Open(inname,"update");
-
- if (!(gAlice=(AliRun*)in->Get("gAlice"))) {
- cerr<<"Can't get gAlice !\n";
- return 1;
- }
-
- AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
- if (!ITS) { cerr<<"Can't get the ITS !\n"; return 1;}
- AliITSgeom *geom=ITS->GetITSgeom();
- out->cd();
- geom->Write();
-
- cout<<"ITSFindClusters: nev ="<<n<<endl;
- Int_t ev=0;
- for (ev = 0; ev<n; ev++){
- in->cd(); // !!!! MI directory must point to galice. - othervise problem with Tree -connection
- gAlice->GetEvent(ev);
- //gAlice->TreeR()->Reset(); //reset reconstructed tree
-
-
- TTree *pTree=gAlice->TreeR();
- if (!pTree){
- gAlice->MakeTree("R");
- pTree = gAlice->TreeR();
- }
- TBranch *branch=pTree->GetBranch("ITSRecPoints");
- /*
- if (!branch) {
- //if not reconstructed ITS branch do reconstruction
- ITS->MakeBranch("R",0);
-
- //////////////// Taken from ITSHitsToFastPoints.C ///////////////////////
- AliITSsimulationFastPoints *sim = new AliITSsimulationFastPoints();
- for (Int_t i=0;i<3;i++) { ITS->SetSimulationModel(i,sim); }
- Int_t nsignal=25;
- Int_t size=-1;
- Int_t bgr_ev=Int_t(ev/nsignal);
- ITS->HitsToFastRecPoints(ev,bgr_ev,size," ","All"," ");
- //////////////////////////////////////////////////////////////////////////
- gAlice->GetEvent(ev); //MI comment - in HitsToFast... they reset treeR to 0
- //they overwrite full reconstructed event ???? ... so lets connect TreeR one more
- //time
- }
- */
-
-
- out->cd();
- TClonesArray *clusters=new TClonesArray("AliITSclusterV2",10000);
- char cname[100];
- sprintf(cname,"TreeC_ITS_%d",ev);
-
- TTree *cTree=new TTree(cname,"ITS clusters");
- cTree->Branch("Clusters",&clusters);
-
- pTree=gAlice->TreeR();
- if (!pTree) { cerr<<"Can't get TreeR !\n"; return 1; }
- branch=pTree->GetBranch("ITSRecPoints");
- if (!branch) { cerr<<"Can't get ITSRecPoints branch !\n"; return 1;}
- TClonesArray *points=new TClonesArray("AliITSRecPoint",10000);
- branch->SetAddress(&points);
-
- TClonesArray &cl=*clusters;
- Int_t nclusters=0;
- Int_t nentr=(Int_t)pTree->GetEntries();
- Int_t lab[6];
- Float_t lp[5];
- AliITSgeom *geom=ITS->GetITSgeom();
-
- cout<<"!!!! nentr ="<<nentr<<endl;
- for (Int_t i=0; i<nentr; i++) {
- if (!pTree->GetEvent(i)) {cTree->Fill(); continue;}
- Int_t lay,lad,det; geom->GetModuleId(i,lay,lad,det);
- Float_t x,y,zshift; geom->GetTrans(lay,lad,det,x,y,zshift);
- Double_t rot[9]; geom->GetRotMatrix(lay,lad,det,rot);
- Double_t yshift = x*rot[0] + y*rot[1];
- Int_t ndet=(lad-1)*geom->GetNdetectors(lay) + (det-1);
- Int_t ncl=points->GetEntriesFast();
- nclusters+=ncl;
-
- Float_t kmip=1.;
- if(lay<5&&lay>2){kmip=280.;}; // b.b.
- if(lay<7&&lay>4){kmip=38.;};
-
-
- for (Int_t j=0; j<ncl; j++) {
- AliITSRecPoint *p=(AliITSRecPoint*)points->UncheckedAt(j);
- lp[0]=-p->GetX()-yshift; if (lay==1) lp[0]=-lp[0];
- lp[1]=p->GetZ()+zshift;
- lp[2]=p->GetSigmaX2();
- lp[3]=p->GetSigmaZ2();
- lp[4]=p->GetQ(); lp[4]/=kmip; // b.b.
- if(ncl==11)cout<<"mod,cl,Q ="<<i<<","<<j<<","<<lp[4]<<endl;
- lab[0]=p->GetLabel(0);lab[1]=p->GetLabel(1);lab[2]=p->GetLabel(2);
- lab[3]=ndet;
-
- Int_t label=lab[0];
- if(label>=0) { // b.b.
- TParticle *part=(TParticle*)gAlice->Particle(label);
- label=-3;
- while (part->P() < 0.005) {
- Int_t m=part->GetFirstMother();
- if (m<0) {cerr<<"Primary momentum: "<<part->P()<<endl; break;}
- label=m;
- part=(TParticle*)gAlice->Particle(label);
- }
- }
- if (lab[1]<0) lab[1]=label;
- else if (lab[2]<0) lab[2]=label;
- else cerr<<"No empty labels !\n";
-
- new(cl[j]) AliITSclusterV2(lab,lp);
- }
- cTree->Fill(); clusters->Delete();
- points->Delete();
- }
- cTree->Write();
- cerr<<"Number of clusters: "<<nclusters<<endl;
- delete cTree; delete clusters; delete points;
-
- }
-
- delete gAlice; gAlice=0;
- in->Close();
- out->Close();
- gBenchmark->Stop(name);
- gBenchmark->Show(name);
-
- return rc;
-}
-
-Int_t ITSFindTracks(const Char_t * inname, const Char_t *inname2, const Char_t *outname, Int_t n) {
- Int_t rc=0;
- const Char_t *name="ITSFindTracks";
- cerr<<'\n'<<name<<"...\n";
- gBenchmark->Start(name);
-
-
- TFile *out=TFile::Open(outname,"recreate");
- TFile *in =TFile::Open(inname);
- TFile *in2 =TFile::Open(inname2);
-
- AliITSgeom *geom=(AliITSgeom*)gFile->Get("AliITSgeom");
- if (!geom) { cerr<<"can't get ITS geometry !\n"; return 1;}
-
- cout<<"ITSFindtracks: nev ="<<n<<endl;
-
- for (Int_t i=0;i<n;i++){
- AliITStrackerV2 tracker(geom,i);
- rc=tracker.Clusters2Tracks(in,out);
- }
-
- in->Close();
- in2->Close();
- out->Close();
-
- gBenchmark->Stop(name);
- gBenchmark->Show(name);
-
- return rc;
-}
-
-Int_t ITSPropagateBack(const Char_t *inname, const Char_t *outname) {
-
- Int_t rc=0;
- /*
- const Char_t *name="ITSPropagateBack";
- cerr<<'\n'<<name<<"...\n";
- gBenchmark->Start(name);
-
- AliITSgeom *geom=(AliITSgeom*)gFile->Get("AliITSgeom");
- if (!geom) { cerr<<"can't get ITS geometry !\n"; return 1;}
- AliITStrackerV2 tracker(geom);
-
- TFile *out=TFile::Open(outname,"update");
- TFile *in =TFile::Open(inname);
- rc=tracker.PropagateBack(in,out);
- in->Close();
- out->Close();
-
- gBenchmark->Stop(name);
- gBenchmark->Show(name);
- */
- return rc;
-}
-
-Int_t TPCPropagateBack(const Char_t *inname, const Char_t *outname) {
- Int_t rc=0;
- const Char_t *name="TPCPropagateBack";
- cerr<<'\n'<<name<<"...\n";
- gBenchmark->Start(name);
-
- AliTPCParam *param=(AliTPCParam *)gFile->Get("75x40_100x60_150x60");
- if (!param) {cerr<<"TPC parameters have not been found !\n"; return 1;}
- AliTPCtracker *tracker=new AliTPCtracker(param);
-
- TFile *out=TFile::Open(outname,"update");
- TFile *in =TFile::Open(inname);
- rc=tracker->PropagateBack(in,out);
- delete tracker;
- in->Close();
- out->Close();
-
- gBenchmark->Stop(name);
- gBenchmark->Show(name);
-
- return rc;
-}
-
-
-
-
-
+++ /dev/null
-#if !defined(__CINT__) || defined(__MAKECINT__)
-#include <iostream.h>
-#include <TClonesArray.h>
-#include <TFile.h>
-#include <TParticle.h>
-#include <TStopwatch.h>
-#include <TTree.h>
-#include <TFile.h>
-
-#include "AliRun.h"
-#include "AliHeader.h"
-#include "AliITS.h"
-#include "AliITSDetType.h"
-#include "AliITSsimulationFastPoints.h"
-#include "AliITSresponse.h"
-#include "AliITSresponseSDD.h"
-#include "AliITSreconstruction.h"
-#include "AliRunDigitizer.h"
-#include "AliITSsegmentationSDD.h"
-#include "AliITSDigitizer.h"
-
-#endif
-
-TFile* AccessInpFile(TString inFile);
-void writeAR(TFile * fin, TFile *fou);
-void AliITSSD2D(TString inFile = "galice.root", TString outFile = "");
-void AliITSH2FR2files (TString inFile, TString outfile);
-void AliITSH2SD2Files(TFile *file2);
-void copyTK(TString inFile, TString outFile);
-
-void AliITSHits2SDR(TString inFile = "galice.root", TString File1 = "galiceS.root",TString File2 = "galiceD.root", TString File3 = "galiceR.root"){
- ////////////////////////////////////////////////////////////////////
- // This macro takes hits from inFile file and
- // produce fast RecPoints, Sdigits, Digits and slow Rec Points
- // for the ITS using the standard detector simulations.
- // The first argument is the input file which contains the tree with hits
- // The second argument is the output file name onto which TreeS will
- // be written.
- // The third and fourth arguments are the file names onto which TreeD
- // and TreeR+TreeC will be written (respectively).
- // The AliRun object and the KINE tree will be saved onto
- // these files as well.
- // This macro will process all of the events on input the root file.
- // This macro can be compiled and it should be launched from an aliroot
- // session.
- // WARNING: Fast Rec Points are written on a branch named ITSRecPointsF
- // this macro should be used with aliroot (it does not load the libraries)
- ////////////////////////////////////////////////////////////////////
-
-
-
- // Produce Fast Rec Points (on File3)
- cout<<"Producing Fast rec points...\n";
- AliITSH2FR2files(inFile,File3);
-
- // TreeK is copied to File3 (for comparison purposes)
-
- copyTK(inFile,File3);
-
- // Produce SDigits
- TFile *file = AccessInpFile(inFile);
- if(!file){
- cerr<<"Problems in accessing the input file\n";
- return;
- }
- TFile *file2 = gAlice->InitTreeFile("S",File1);
- file2->cd();
- cout<<"Producing Summable digits ....\n";
- AliITSH2SD2Files(file2);
- // write the AliRun object to the output file
- writeAR(file,file2);
- delete gAlice;
- gAlice = 0;
- file->Close();
- delete file;
- file2 = 0;
-
- // Produce Digits
- cout<<"Producing Digits ...\n";
- AliITSSD2D(File1,File2);
-
- // Produce Slow Rec. Points
- TFile *fin = new TFile(File2);
- gAlice = (AliRun*) fin->Get("gAlice");
- const char *nulptr=0;
- AliITSreconstruction *itsr = new AliITSreconstruction(nulptr);
- itsr->SetOutputFile(File3);
- itsr->Init();
- itsr->Exec();
- TFile *fou = gAlice->GetTreeRFile();
- writeAR(fin,fou);
- delete itsr;
-
-}
-
-void AliITSH2SD2Files(TFile *file2){
-
- // Function used to produce s-digits
-
- AliITS *ITS = (AliITS*) gAlice->GetModule("ITS");
- if (!ITS) {
- cerr<<"AliITS object not found on file" << endl;
- return;
- }
- if(!(ITS->GetITSgeom())){
- cerr << " AliITSgeom not found. Can't digitize without it." << endl;
- return ;
- }
-
- // these re-instantiations are necessary if the input file was created
- // with aliroot version V3.07 or older
- AliITSresponseSDD *resp1 = (AliITSresponseSDD*)ITS->DetType(1)->GetResponseModel();
- resp1 = new AliITSresponseSDD();
- ITS->SetResponseModel(1,resp1);
- cout << "Changed response class for SDD: \n";
- resp1->Print();
-
- for (Int_t nevent=0; nevent<gAlice->TreeE()->GetEntries(); nevent++) {
- gAlice->GetEvent(nevent);
- gAlice->MakeTree("S",file2);
- ITS->MakeBranch("S");
- ITS->SetTreeAddress();
- ITS->Hits2SDigits();
- }
-}
-
-
-TFile * AccessInpFile(TString inFile){
-
- // Function used to open the input file and fetch the AliRun object
-
- TFile *retfil = 0;
- TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(inFile);
- if (file) {file->Close(); delete file;}
- file = new TFile(inFile);
- if (!file->IsOpen()) {
- cerr<<"Can't open "<<inFile<<" !" << endl;
- return retfil;
- }
-
- // Get AliRun object from file or return if not on file
- if (gAlice) delete gAlice; gAlice = 0;
- gAlice = (AliRun*)file->Get("gAlice");
- if (!gAlice) {
- cerr << "AliRun object not found on file"<< endl;
- return retfil;
- }
- return file;
-}
-
-void writeAR(TFile * fin, TFile *fou) {
- TDirectory *current = gDirectory;
- TTree *Te;
- TTree *TeNew;
- AliHeader *alhe = new AliHeader();
- Te = (TTree*)fin->Get("TE");
- Te->SetBranchAddress("Header",&alhe);
- Te->SetBranchStatus("*",1);
- fou->cd();
- TeNew = Te->CloneTree();
- TeNew->Write(0,TObject::kOverwrite);
- gAlice->Write(0,TObject::kOverwrite);
- current->cd();
- delete alhe;
- cout<<"AliRun object written to file\n";
-}
-
-
-void AliITSSD2D(TString inFile, TString outFile){
- AliRunDigitizer * manager = new AliRunDigitizer(1,1);
- char ftmp[50];
- sprintf(ftmp,"%s",inFile.Data());
- manager->SetInputStream(0,ftmp);
- if(outFile != "")manager->SetOutputFile(outFile);
- AliITSDigitizer *dITS = new AliITSDigitizer(manager);
- manager->Exec("");
- TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(inFile);
- TFile *file2= new TFile(outFile,"update");
- writeAR(file,file2);
- delete dITS;
- delete manager;
- file = (TFile*)gROOT->GetListOfFiles()->FindObject(inFile);
- if(file){
- file->Close();
- delete file;
- }
- file2->Close();
- delete file2;
-}
-
-void AliITSH2FR2files (TString inFile, TString outfile)
-{
-
- TFile * file = AccessInpFile(inFile);
- if(!file){
- cerr<<"*** AliITSH2FR2files: Problems in accessing the input file\n";
- return;
- }
-
- // open output file and create TreeR on it
- TFile * file2 = gAlice->InitTreeFile("R",outfile);
- file2->cd();
- // get ITS
- AliITS *ITS = (AliITS*) gAlice->GetModule("ITS");
- if (!ITS) {
- cerr<<"ITSH2FR2files.C : AliITS object not found on file" << endl;
- return;
- } // end if !ITS
-
- // Set the simulation model
-
- for (Int_t i=0;i<3;i++) {
- ITS->SetSimulationModel(i,new AliITSsimulationFastPoints());
- }
-
-
- //
- // Event Loop
- //
- Int_t nsignal=25;
- Int_t size=-1;
- TStopwatch timer;
- for (Int_t nevent=0; nevent<gAlice->TreeE()->GetEntries(); nevent++) {
- gAlice->GetEvent(nevent);
- if(!gAlice->TreeR())gAlice->MakeTree("R",file2);
- ITS->MakeBranch("RF");
- ITS->SetTreeAddress();
- Int_t bgr_ev=nevent/nsignal;
- ITS->HitsToFastRecPoints(nevent,bgr_ev,size," ","All"," ");
- }
-
- timer.Stop(); timer.Print();
-
- delete gAlice;
- gAlice = 0;
- file->Close();
-}
-
-void copyTK(TString inFile, TString outFile) {
-
- TDirectory *current = gDirectory;
- TParticle *part = new TParticle();
- TTree *Tk;
- TTree *TkNew;
- TFile *fin = AccessInpFile(inFile);
- TFile *fou = new TFile(outFile,"update");
- char tname[30];
- for(Int_t event= 0; event < gAlice->TreeE()->GetEntries(); event++){
- current->cd();
- sprintf(tname,"TreeK%d",event);
- Tk = (TTree*)fin->Get(tname);
- if(!Tk){
- cerr<<"Trying to access a non-existent TTree : "<<tname<<endl;
- }
- else {
- Tk->SetBranchAddress("Particles",&part);
- Tk->SetBranchStatus("*",1);
- fou->cd();
- TkNew = Tk->CloneTree();
- TkNew->Write();
- }
- }
- delete gAlice;
- gAlice = 0;
- fin->Close();
- fou->Close();
- delete fin;
- delete fou;
- current->cd();
-
-}
+++ /dev/null
-void AliITSMakeSDigits(Int_t n){
-//gInterpreter->ProcessLine(".L ($ALICE_ROOT)/ITS/AliITSHits2SDigits.C");
-
-gROOT->LoadMacro("$ALICE_ROOT/ITS/AliITSHits2SDigits.C");
-
-AliITSHits2SDigits(0,n-1);
-}
+++ /dev/null
-////////////////////////////////////////////////////////////////////////
-//
-// AliITSandTPCrecoV2.C
-//
-//
-////////////////////////////////////////////////////////////////////////
-
-
-/****************************************************************************
- * This macro is supposed to do reconstruction in the barrel ALICE trackers *
- * (Make sure you have TPC digits and ITS hits before using this macro !!!) *
- * It does the following steps *
- * 1) TPC cluster finding *
- * 2) TPC track finding *
- * 3) ITS cluster finding - fast recpoints - *
- * 4) ITS tracking *
- * TPC part taken from AliTPCTracking.C - Jiri Chudoba *
- * The TPC part will be removed *
- * M.Masera 30/09/2002 09:40 *
- * Last revision: 4/3/2003 *
- * *
- * Use: *
- * The main function is AliITSandTPCrecoV2 All the input arguments have a *
- * default value. *
- * nEvents: number of events to be processed. *
- * If nEvents<0, all the available events are used starting from *
- * the first one *
- * firstEvent: is the first event to be analyzed. *
- * It is set to 0 if nEvents<0 (default) *
- * fileNameHits: input root file with Kine and hits *
- * fileNameDigits: input root file with ITS and TPC digits and with ITS *
- * recpoints. Only fast points are used at the moment. *
- * An option to use slow points should be added *
- * fileNameClusters: output root file with TPC clusters *
- * fileNameTracks: output root file with TPC tracks *
- * fileNameITSClusters: output root file with ITS clusters *
- * fileNameITSTracks: output root file with ITS tracks *
- * *
- * AliITSandTPCrecoV2(Int_t nEvents=-1, Int_t firstEvent=0, *
- * TString fileNameHits="galice.root", *
- * TString fileNameDigits="galiceSDR.root", *
- * TString fileNameClusters="tpc.clusters.root", *
- * TString fileNameTracks="tpc.tracks.root", *
- * TString fileNameITSClusters="its.clusters.root", *
- * TString fileNameITSTracks="its.tracks.root"); *
- * *
- * Global variables:
- *
- * Int_t gDEBUG = 0; // NO verbose printouts if ==0 *
- * TArrayD *gzvtx = 0; // Z coordinate of primary vertices *
- * Int_t gCurrEve = 0; // current event number *
- * Bool_t gPPMode = kTRUE; // it must be set to kTRUE for pp interactions *
- * Bool_t gFastReco = kTRUE; // it must set to kTRUE for fast reconstr. *
- * const Double_t kgVertexNotFound = -100; // the Z coord. of the *
- * primary vertex is set to this value *
- * when the vertexing fails *
- * Bool_t gUseNewClustersV2 = kFALSE; // if kTRUE the AliITSclustereV2 class
- * is used to produce V2 clusters. *
- * ITS recpoints are used otherwise *
- ****************************************************************************/
-
-#if !defined(__CINT__) || defined(__MAKECINT__)
-#include <TH1.h>
-#include <TH2.h>
-#include <TProfile.h>
-#include <TBranch.h>
-#include <TParticle.h>
-#include <TRandom.h>
-#include "alles.h"
-#include "AliMagF.h"
-#include "AliMagFCM.h"
-#include "AliTPCtracker.h"
-#include "AliTPCclusterer.h"
-#include "Riostream.h"
-#include "TString.h"
-#include "TArrayD.h"
-#include "TLine.h"
-#include "TTree.h"
-#include "TNtuple.h"
-#include "TParticle.h"
-#include "TText.h"
-#include "TSystem.h"
-#include "TVector.h"
-#include "TObjArray.h"
-#include "TStyle.h"
-#include "TCanvas.h"
-#include "AliITS.h"
-#include "AliITSclustererV2.h"
-#include "AliITSgeom.h"
-#include "AliITSRecPoint.h"
-#include "AliITSclusterV2.h"
-#include "AliITStrackerV2.h"
-#include "AliITSVertexerPPZ.h"
-#include "AliITSVertexerIons.h"
-#include "AliRun.h"
-#include "AliHeader.h"
-#include "AliGenEventHeader.h"
-#include "TArrayF.h"
-#include "AliGenPythiaEventHeader.h"
-
-#endif
-
-
-Int_t gDEBUG = 0;
-TArrayD *gzvtx = 0;
-Int_t gCurrEve = 0;
-Bool_t gPPMode = kTRUE;
-Bool_t gFastReco = kTRUE;
-Bool_t gUseNewClustersV2 = kFALSE;
-const Double_t kgVertexNotFound = -100.;
-
-
-Int_t TPCFindClusters(Int_t nEvents=1, Int_t firstEvent=0,
- TString fileNameDigits="galiceSDR.root",
- TString fileNameClusters="tpc.clusters.root");
-Int_t TPCFindClusters(Int_t nEvents, Int_t firstEvent,
- TFile* fileDigits, TFile* fileClusters,
- AliTPCParam* paramTPC=0);
-Int_t TPCFindTracks(Int_t nEvents=1, Int_t firstEvent=0,
- TString fileNameClusters="tpc.clusters.root",
- TString fileNameTracks="tpc.tracks.root");
-Int_t TPCFindTracks(Int_t nEvents, Int_t firstEvent,
- TFile* fileClusters, TFile* fileTracks,
- AliTPCParam* paramTPC=0);
-
-Int_t AliTPCTracking(Int_t nEvents=1, Int_t firstEvent=0,
- TString fileNameHits="galice.root",
- TString fileNameDigits="galiceSDR.root",
- TString fileNameClusters="tpc.clusters.root",
- TString fileNameTracks="tpc.tracks.root");
-Int_t AliITSandTPCrecoV2(Int_t nEvents=-1, Int_t firstEvent=0,
- TString fileNameHits="galice.root",
- TString fileNameDigits="galiceSDR.root",
- TString fileNameClusters="tpc.clusters.root",
- TString fileNameTracks="tpc.tracks.root",
- TString fileNameITSClusters="its.clusters.root",
- TString fileNameITSTracks="its.tracks.root");
-Int_t ITSFindClusters(TString inname, TString recpointFileName, TString fileNameITSClusters, Int_t n, Int_t first);
-Int_t ITSFindTracks(TString fileNameTracks, TString fileNameITSClusters, TString fileNameITSTracks, Int_t n, Int_t first, Int_t vc, Int_t vc2);
-void FindZV(Int_t nEvents, Int_t first, TString FileNameHits, TString FileWithRecPoints);
-Int_t DirectClusterFinder(Int_t eventn,Int_t first,TFile *in,TFile *out);
-////////////////////////////////////////////////////////////////////////
-Int_t AliITSandTPCrecoV2(Int_t nEvents, Int_t firstEvent,
- TString fileNameHits,
- TString fileNameDigits,
- TString fileNameClusters,
- TString fileNameTracks,
- TString fileNameITSClusters,
- TString fileNameITSTracks) {
- const Char_t *name="AliITSandTPCrecoV2";
-
- gBenchmark->Start(name);
-
- // Set the conversion constant for the Kalman filter
- // and set the gAlice pointer
- Char_t *finame = (Char_t *)fileNameHits.Data();
- AliTracker::SetFieldFactor(finame,kFALSE);
-
- if(nEvents < 0 ) {
- nEvents = (Int_t)gAlice->TreeE()->GetEntries();
- firstEvent = 0;
- cout << "Processing events from " << firstEvent << " up to " << nEvents-1 <<endl;
- }
-
- if(fileNameDigits!=fileNameHits)gAlice->SetTreeDFileName(fileNameDigits.Data());
- gzvtx = new TArrayD(nEvents);
-
- // measure Z vertex coordinate for seeding
-
- FindZV(nEvents,firstEvent,fileNameHits,fileNameDigits);
-
- // TPC tracking - abort macro execution if tracking fails
- if(AliTPCTracking(nEvents,firstEvent,fileNameHits,fileNameDigits,
- fileNameClusters,fileNameTracks)) {
- cerr << "TPC tracking failed \n";
- return 1;
- }
-
- // ITS clustering
- if(ITSFindClusters(fileNameHits,fileNameDigits,fileNameITSClusters,nEvents,firstEvent)) {
- cerr << "ITS clustering failed \n";
- return 2;
- }
-
- Int_t firstpass = 1; // 1=vert. constraint; 0=no vert. constr.; -1=skip pass
- Int_t secondpass = 0; // as above
- if(ITSFindTracks(fileNameTracks,fileNameITSClusters,fileNameITSTracks,nEvents,firstEvent,firstpass,secondpass)) {
- cerr << "ITS tracking failed \n";
- return 3;
- }
-
-
- gBenchmark->Stop(name);
- gBenchmark->Show(name);
- return 0;
-}
-////////////////////////////////////////////////////////////////////////
-Int_t AliTPCTracking( Int_t nEvents, Int_t firstEvent,
- TString fileNameHits,
- TString fileNameDigits,
- TString fileNameClusters,
- TString fileNameTracks) {
-
-
- // ********** Find TPC clusters *********** //
- if (TPCFindClusters(nEvents,firstEvent,fileNameDigits,fileNameClusters)) {
- cerr<<"Failed to get TPC clusters: !\n";
- return 1;
- }
-
- // ********** Find TPC tracks *********** //
- // if (TPCFindTracks(TPCclsName,TPCtrkName,n)) {
- if (TPCFindTracks(nEvents,firstEvent,fileNameClusters,fileNameTracks)) {
- cerr<<"Failed to get TPC tracks !\n";
- return 2;
- }
-
- return 0;
-}
-
-////////////////////////////////////////////////////////////////////////
-Int_t TPCFindClusters(Int_t nEvents, Int_t firstEvent,
- TString fileNameDigits, TString fileNameClusters) {
-
- Int_t rc;
- const Char_t *name="TPCFindClusters";
- if (gDEBUG>1) cout<<name<<" starts...\n";
- if (gDEBUG>1) gBenchmark->Start(name);
- TFile *fileClusters = TFile::Open(fileNameClusters,"recreate");
- TFile *fileDigits = TFile::Open(fileNameDigits);
- if (!fileDigits->IsOpen()) {
- cerr<<"Cannnot open "<<fileNameDigits<<" !\n";
- return 1;
- }
- if (!fileClusters->IsOpen()) {
- cerr<<"Cannnot open "<<fileNameClusters<<" !\n";
- return 1;
- }
-
- rc = TPCFindClusters(nEvents,firstEvent,fileDigits,fileClusters);
-
- fileDigits->Close();
- fileClusters->Close();
- delete fileDigits;
- delete fileClusters;
- if (gDEBUG>1) gBenchmark->Stop(name);
- if (gDEBUG>1) gBenchmark->Show(name);
-
- return rc;
-}
-////////////////////////////////////////////////////////////////////////
-Int_t TPCFindClusters(Int_t nEvents, Int_t firstEvent,
- TFile* fileDigits, TFile* fileClusters,
- AliTPCParam* paramTPC) {
-
- fileDigits->cd();
- if (!paramTPC) paramTPC = AliTPC::LoadTPCParam(fileDigits);
- if (!paramTPC) return 1;
-
- for (Int_t iEvent = firstEvent; iEvent < firstEvent+nEvents; iEvent++){
- if (gDEBUG > 2) cout<<"TPCFindClusters: event "<<iEvent<<endl;
- AliTPCclusterer::Digits2Clusters(paramTPC, fileClusters, iEvent);
- }
- return 0;
-}
-////////////////////////////////////////////////////////////////////////
-Int_t TPCFindTracks(Int_t nEvents, Int_t firstEvent,
- TString fileNameClusters, TString fileNameTracks) {
-
- Int_t rc = 0;
- const Char_t *name="TPCFindTracks";
- if (gDEBUG>1) cout<<name<<" starts"<<endl;
- if (gDEBUG>1) gBenchmark->Start(name);
- TFile *fileTracks = TFile::Open(fileNameTracks,"recreate");
- TFile *fileClusters =TFile::Open(fileNameClusters);
-
- rc = TPCFindTracks(nEvents, firstEvent, fileClusters, fileTracks);
-
- fileClusters->Close();
- fileTracks->Close();
- delete fileClusters;
- delete fileTracks;
- if (gDEBUG>1) gBenchmark->Stop(name);
- if (gDEBUG>1) gBenchmark->Show(name);
- return rc;
-
-}
-////////////////////////////////////////////////////////////////////////
-Int_t TPCFindTracks(Int_t nEvents, Int_t firstEvent,
- TFile *fileClusters, TFile * fileTracks,
- AliTPCParam* paramTPC) {
-
- Int_t rc = 0;
- if (!paramTPC) paramTPC = AliTPC::LoadTPCParam(fileClusters);
- if (!paramTPC) return 1;
- Double_t vertex[3];
- for(Int_t j=0; j<3; j++){vertex[j]=0.;}
- AliTPCtracker *tracker = new AliTPCtracker(paramTPC);
- for (Int_t iEvent = firstEvent; iEvent < firstEvent+nEvents; iEvent++){
- if (gDEBUG > 2) cout<<"TPCFindTracks: event "<<iEvent<<endl;
- tracker->SetEventNumber(iEvent);
- if((*gzvtx)[iEvent] > -100){
- vertex[2] = (*gzvtx)[iEvent];
- }
- else {
- vertex[2]=0;
- }
- tracker->SetVertex(vertex);
- fileClusters->cd();
- rc = tracker->Clusters2Tracks(0,fileTracks);
- }
- delete tracker;
- return rc;
-}
-
-
-////////////////////////////////////////////////////////////////////////
-Int_t ITSFindClusters(TString inname, TString recpointFileName, TString fileNameITSClusters, Int_t n, Int_t first) {
- Int_t rc=0;
- const Char_t *name="ITSFindClusters";
- cerr<<'\n'<<name<<"...\n";
- gBenchmark->Start(name);
- TFile *out=TFile::Open(fileNameITSClusters,"recreate");
- TFile *in = (TFile*)gROOT->GetListOfFiles()->FindObject(inname.Data());
- if(gUseNewClustersV2){
- cout<<"Direct method\n";
- return DirectClusterFinder(n,first,in,out);
- }
- else {
- cout<<"Clusters through rec points \n";
- }
-
- AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
- if (!ITS) { cerr<<"Can't get the ITS !\n"; return 1;}
- AliITSgeom *geom=ITS->GetITSgeom();
- AliITSclustererV2 *clusterer = new AliITSclustererV2(geom);
- out->cd();
- geom->Write();
-
- Int_t ev;
- if(gFastReco && gDEBUG>0)cout <<"Using fast points\n";
- else cout<<"Using slow points\n";
- for (ev = first; ev<n; ev++){
- cout<<"ITSFindClusters: processing event "<<ev<<endl;
- in->cd();
- gAlice->GetEvent(ev);
-
- TTree *pTree=gAlice->TreeR();
- if (!pTree){
- cerr << "ITSFindClusters: can't get TreeR\n";
- return 1;
- }
- TBranch *branch = 0;
- if (gFastReco) {
- branch = pTree->GetBranch("ITSRecPointsF");
- }
- else {
- branch = pTree->GetBranch("ITSRecPoints");
- }
- if (!branch) {
- cerr << "ITSFindClusters: can't get ITSRecPoints branch \n";
- return 2;
- }
-
- out->cd();
- TClonesArray *clusters=new TClonesArray("AliITSclusterV2",10000);
- char cname[100];
- sprintf(cname,"TreeC_ITS_%d",ev);
-
- TTree *cTree=new TTree(cname,"ITS clusters");
- cTree->Branch("Clusters",&clusters);
-
- TClonesArray *points=new TClonesArray("AliITSRecPoint",10000);
- branch->SetAddress(&points);
-
- TClonesArray &cl=*clusters;
- Int_t nclusters=0;
- Int_t nentr=(Int_t)pTree->GetEntries();
- AliITSgeom *geom=ITS->GetITSgeom();
- Float_t lp[5];
- Double_t rot[9];
- Int_t lab[6];
- for (Int_t i=0; i<nentr; i++) {
- branch->GetEvent(i);
- clusterer->RecPoints2Clusters(points,i,clusters);
- cTree->Fill(); clusters->Delete();
- points->Clear();
- }
- cTree->Write();
- delete cTree; delete clusters; points->Delete(); delete points;
- }
- delete clusterer;
-
- out->Close();
-
- return rc;
-}
-////////////////////////////////////////////////////////////////////////
-Int_t ITSFindTracks(TString inname, TString inname2, TString outname, Int_t n, Int_t first, Int_t vc, Int_t vc2) {
- Int_t rc=0;
- if(gPPMode){
- AliITStrackV2::SetSigmaYV(0.015);
- AliITStrackV2::SetSigmaZV(0.017);
- }
- TFile *out=TFile::Open(outname.Data(),"recreate");
- if (!out->IsOpen()) {
- cerr<<"Can't open file "<<outname.Data()<<endl;
- return 1;
- }
- TFile *in =TFile::Open(inname.Data());
- if (!in->IsOpen()) {
- cerr<<"Can't open file "<<inname.Data()<<endl;
- return 1;
- }
- TFile *in2 =TFile::Open(inname2.Data());
- if (!in2->IsOpen()) {
- cerr<<"Can't open file "<<inname2.Data()<<endl;
- return 1;
- }
-
- AliITSgeom *geom=(AliITSgeom*)gFile->Get("AliITSgeom");
- if (!geom) { cerr<<"can't get ITS geometry !\n"; return 1;}
- Double_t vrtc[3];
- AliITStrackerV2 tracker(geom);
- for (Int_t i=first;i<n;i++){
- tracker.SetEventNumber(i);
- Double_t vtx=(*gzvtx)[i];
- cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
- cout<<"ITSFindTracks -- event "<<i<<endl;
- cout<<"Computed vertex position: "<<vtx<<endl;
- in2->cd();
- vrtc[0]=0.;
- vrtc[1]=0.;
- vrtc[2]=vtx;
- if(vtx != kgVertexNotFound){
- tracker.SetVertex(vrtc); // set vertex only if it was computed
- }
- else {
- vc = 0; // use vertex contraint only if vertex info is available
- vc2 = -1;
- }
-
- tracker.SetupFirstPass(&vc);
-
- tracker.SetupSecondPass(&vc2);
-
- rc=tracker.Clusters2Tracks(in,out);
- }
-
- in->Close();
- in2->Close();
- out->Close();
-
- return rc;
-}
-
-//////////////////////////////////////////////////////////////////
-void FindZV(Int_t nEvents, Int_t first, TString FileNameHits, TString FileWithRecPoints){
- TFile *in = (TFile*)gROOT->GetListOfFiles()->FindObject(FileNameHits.Data());
- TFile *fo = new TFile("AliITSVertices.root","recreate");
- if(FileNameHits!=FileWithRecPoints)gAlice->SetTreeRFileName(FileWithRecPoints);
- AliITSVertexer *findVert;
- if(gPPMode){
- findVert = new AliITSVertexerPPZ(in,fo);
- }
- else {
- findVert = new AliITSVertexerIons(in,fo);
- }
- Int_t last = first + nEvents - 1;
- AliITSVertex *vert = 0;
- for(Int_t i=first; i<=last; i++){
- gAlice->GetEvent(i);
- // The true Z coord. is fetched for comparison
- AliHeader *header = gAlice->GetHeader();
- AliGenEventHeader* genEventHeader = header->GenEventHeader();
- TArrayF primaryVertex(3);
- genEventHeader->PrimaryVertex(primaryVertex);
- vert = findVert->FindVertexForCurrentEvent(i);
- if(vert){
- Double_t pos[3];
- for(Int_t kk=0;kk<3;kk++)pos[kk]=(Double_t)primaryVertex[kk];
- vert->SetTruePos(pos);
- Double_t found = vert->GetZv();
- gzvtx->AddAt(found,i);
- findVert->WriteCurrentVertex();
- }
- else {
- gzvtx->AddAt(kgVertexNotFound,i);
- }
- }
- delete findVert;
- fo->Close();
- delete fo;
-}
-
-
-
-Int_t DirectClusterFinder(Int_t eventn,Int_t first,TFile *in,TFile* out){
-
-
- AliITS *ITS = (AliITS*)gAlice->GetModule("ITS");
- if (!ITS) { cerr<<"Can't find the ITS !\n"; return 3; }
-
- AliITSgeom *geom=ITS->GetITSgeom();
-
- geom->Write();
-
- TStopwatch timer;
- AliITSclustererV2 clusterer(geom);
- for (Int_t i=first; i<eventn; i++) {
- cerr<<"Processing event number: "<<i<<endl;
- gAlice->GetEvent(i);
- //ITS->MakeTreeC(); //To make the V1 cluster finders happy
- clusterer.SetEvent(i);
- if (gFastReco) clusterer.Digits2Clusters(in,out);
- else clusterer.Hits2Clusters(in,out);
- }
- timer.Stop(); timer.Print();
-
- out->Close();
-
- return 0;
-
-}
-