ATO-17 - reset cach matrix and current matrix after dumping to the tree (not before)
[u/mrichter/AliRoot.git] / TPC / FindKrClustersRaw.C
index 0a00aea..b3df0ba 100644 (file)
-//\r
-\r
-Int_t FindKrClusterCheck(const char *fileName="data.root");\r
-\r
-\r
-Int_t FindKrClustersRaw(const char *fileName="data.root"){\r
-\r
-  \r
-\r
-  //\r
-  // remove Altro warnings\r
-  //\r
-  AliLog::SetClassDebugLevel("AliTPCRawStream",-5);\r
-  AliLog::SetClassDebugLevel("AliRawReaderDate",-5);\r
-  AliLog::SetClassDebugLevel("AliTPCAltroMapping",-5);\r
-  AliLog::SetModuleDebugLevel("RAW",-5);\r
-  //\r
-  // Get calibration\r
-  //\r
-  char *ocdbpath = gSystem->Getenv("OCDB_PATH");\r
-  //char *ocdbpath ="local:///afs/cern.ch/alice/tpctest/OCDB";\r
-  if (ocdbpath==0){\r
-    ocdbpath="alien://folder=/alice/data/2007/LHC07w/OCDB/";\r
-  }\r
-  printf("OCDB PATH = %s\n",ocdbpath); \r
-  AliCDBManager * man = AliCDBManager::Instance();\r
-  man->SetDefaultStorage(ocdbpath);\r
-  man->SetRun(100000000);\r
-\r
-  AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();\r
-  AliTPCAltroMapping** mapping =AliTPCcalibDB::Instance()->GetMapping();\r
-  //\r
-  //\r
-\r
-\r
-  //define tree\r
-  TFile *hfile=new TFile("adc.root","RECREATE","ADC file");\r
-  // Create a ROOT Tree\r
-  TTree *mytree = new TTree("Kr","Krypton cluster tree");\r
-\r
-\r
-  Int_t debugLevel=1;\r
-  if(debugLevel>0){\r
-    TH1F *histoRow   =new TH1F("histoRow","rows",100,0.,100.);\r
-    TH1F *histoPad   =new TH1F("histoPad","pads",150,0.,150.);\r
-    TH1F *histoTime  =new TH1F("histoTime","timebins",100,0.,1000.);\r
-    TH2F *histoRowPad=new TH2F("histoRowPad","pads-vs-rows" ,150,0.,150.,100,0.,100.);\r
-  }\r
-\r
-\r
-  //one general output\r
-  AliTPCclustererKr *clusters = new AliTPCclustererKr();\r
-  clusters->SetOutput(mytree);\r
-  clusters->SetRecoParam(0);\r
-\r
-  if(debugLevel>0){\r
-    clusters->SetDebugLevel(debugLevel);\r
-    clusters->SetHistoRow(histoRow   );\r
-    clusters->SetHistoPad(histoPad   );\r
-    clusters->SetHistoTime(histoTime  );\r
-    clusters->SetHistoRowPad(histoRowPad);\r
-  }\r
-\r
-\r
-  AliTPCParamSR *param=new AliTPCParamSR();\r
-  //only for geometry parameters loading - temporarly\r
-//  AliRunLoader* rl = AliRunLoader::Open("galice.root");\r
-//  AliTPCParam *param=(AliTPCParamSR *)gDirectory->Get("75x40_100x60_150x60");\r
-  //if (!param) {cerr<<"TPC parameters have not been found !\n"; return 4;}\r
-\r
-  clusters->SetParam(param);\r
-\r
-  //set cluster finder parameters (from data)\r
-  clusters->SetZeroSup(param->GetZeroSup());//zero suppression parameter\r
-  clusters->SetFirstBin(60);//first bin\r
-  clusters->SetLastBin(950);//last bin\r
-  clusters->SetMaxNoiseAbs(2);//maximal noise\r
-  clusters->SetMaxNoiseSigma(3);//maximal amount of sigma of noise\r
-\r
-  //set cluster finder parameters (from MC)\r
-  clusters->SetMinAdc(3);//signal threshold (everything below is treated as 0)\r
-  clusters->SetMinTimeBins(2);//number of neighbouring timebins\r
-  clusters->SetMaxPadRangeCm(5.);//distance of the cluster center to the center of a pad (in cm)\r
-  clusters->SetMaxRowRangeCm(5.);//distance of the cluster center to the center of a padrow (in cm)\r
-  clusters->SetMaxTimeRange(5.);//distance of the cluster center to the max time bin on a pad (in tackts)\r
-  //ie. fabs(centerT - time)<7\r
-  clusters->SetValueToSize(7.);//cut reduce peak at 0\r
-  clusters->SetIsolCut(3);//set isolation cut threshold\r
-\r
-  AliRawReader *reader = new AliRawReaderRoot(fileName);\r
-  reader->Reset();\r
-\r
-  TStopwatch timer;\r
-  timer.Start();\r
-\r
-  AliAltroRawStreamFast* stream = new AliAltroRawStreamFast(reader);\r
-  stream->SelectRawData("TPC");\r
-\r
-  Int_t evtnr=0;\r
-  while (reader->NextEvent()) {\r
-    //output for each event\r
-\r
-    //if(evtnr>4) break;\r
-    cout<<"Evt = "<<evtnr<<endl;\r
-    clusters->FinderIO(reader);\r
-    evtnr++;\r
-    AliSysInfo::AddStamp(Form("Event%d",evtnr),evtnr);\r
-  }\r
-\r
-\r
-  mytree->Print();//print rootuple summary \r
-  // Save all objects in this file\r
-  hfile->Write();\r
-  // Close the file\r
-  hfile->Close();\r
-\r
-  timer.Stop();\r
-  timer.Print();\r
-  printf("Deleting clusterer\n");\r
-  delete clusters;\r
-  printf("Deleting stream\n");\r
-  delete stream;\r
-  printf("Deleting raw reader\n");\r
-  delete reader;\r
-\r
-//   TCanvas *c2=new TCanvas("c2","title",800,800);\r
-//   c2->SetHighLightColor(2);\r
-//   c2->Range(-458.9552,-2948.238,3296.642,26856.6);\r
-//   c2->SetBorderSize(2);\r
-//   c2->SetLeftMargin(0.15);\r
-//   c2->SetRightMargin(0.06);\r
-//   c2->SetFrameFillColor(0);\r
-\r
-//   gStyle->SetOptStat(111111);\r
-//   histoRow->Draw();\r
-//   c2->Print("rows.ps");\r
-//   histoPad->Draw();\r
-//   c2->Print("pads.ps");\r
-//   histoTime->Draw();\r
-//   c2->Print("timebins.ps");\r
-//   histoRowPad->Draw();\r
-//   c2->Print("row-pad.ps");\r
-\r
-  return 0;\r
-}\r
-\r
-\r
-Int_t FindKrClusterCheck(const char *fileName){\r
-  //\r
-  //\r
-  gSystem->Load("$ROOTSYS/lib/libGui.so");\r
-  gSystem->Load("$ROOTSYS/lib/libTree.so");\r
-  gSystem->Load("$MEMSTAT/libMemStat.so");\r
-  {\r
-    TMemStat memstat(1000000,100000,kTRUE);\r
-    AliSysInfo::AddCallBack(TMemStatManager::GetInstance()->fStampCallBack);\r
-    FindKrClustersRaw(fileName); \r
-  }\r
-  // the output memstat.root file\r
-  TMemStat draw("memstat.root");\r
-  // Print some information\r
-  // code info\r
-  draw.MakeReport(0,0);\r
-\r
-}\r
+//
+
+Int_t FindKrClusterCheck(const char *fileName="data.root");
+
+
+Int_t FindKrClustersRaw(const char *fileName="data.root"){
+
+  
+
+  //
+  // remove Altro warnings
+  //
+  AliLog::SetClassDebugLevel("AliRawReaderDate",-5);
+  AliLog::SetClassDebugLevel("AliTPCAltroMapping",-5);
+  AliLog::SetModuleDebugLevel("RAW",-5);
+  //
+  // Get calibration
+  //
+  char *ocdbpath = gSystem->Getenv("OCDB_PATH");
+  //char *ocdbpath ="local:///afs/cern.ch/alice/tpctest/OCDB";
+  if (ocdbpath==0){
+    ocdbpath="alien://folder=/alice/data/2007/LHC07w/OCDB/";
+  }
+  printf("OCDB PATH = %s\n",ocdbpath); 
+  AliCDBManager * man = AliCDBManager::Instance();
+  man->SetDefaultStorage(ocdbpath);
+  man->SetRun(100000000);
+
+  AliTPCCalPad * noiseTPC = AliTPCcalibDB::Instance()->GetPadNoise();
+  AliTPCAltroMapping** mapping =AliTPCcalibDB::Instance()->GetMapping();
+  //
+  //
+
+
+  //define tree
+  TFile *hfile=new TFile("adc.root","RECREATE","ADC file");
+  // Create a ROOT Tree
+  TTree *mytree = new TTree("Kr","Krypton cluster tree");
+
+
+  Int_t debugLevel=1;
+  if(debugLevel>0){
+    TH1F *histoRow   =new TH1F("histoRow","rows",100,0.,100.);
+    TH1F *histoPad   =new TH1F("histoPad","pads",150,0.,150.);
+    TH1F *histoTime  =new TH1F("histoTime","timebins",100,0.,1000.);
+    TH2F *histoRowPad=new TH2F("histoRowPad","pads-vs-rows" ,150,0.,150.,100,0.,100.);
+  }
+
+
+  //one general output
+  AliTPCclustererKr *clusters = new AliTPCclustererKr();
+  clusters->SetOutput(mytree);
+  clusters->SetRecoParam(0);
+
+  if(debugLevel>0){
+    clusters->SetDebugLevel(debugLevel);
+    clusters->SetHistoRow(histoRow   );
+    clusters->SetHistoPad(histoPad   );
+    clusters->SetHistoTime(histoTime  );
+    clusters->SetHistoRowPad(histoRowPad);
+  }
+
+
+  AliTPCParamSR *param=new AliTPCParamSR();
+  //only for geometry parameters loading - temporarly
+//  AliRunLoader* rl = AliRunLoader::Open("galice.root");
+//  AliTPCParam *param=(AliTPCParamSR *)gDirectory->Get("75x40_100x60_150x60");
+  //if (!param) {cerr<<"TPC parameters have not been found !\n"; return 4;}
+
+  clusters->SetParam(param);
+
+  //set cluster finder parameters (from data)
+  clusters->SetZeroSup(param->GetZeroSup());//zero suppression parameter
+  clusters->SetFirstBin(60);//first bin
+  clusters->SetLastBin(950);//last bin
+  clusters->SetMaxNoiseAbs(2);//maximal noise
+  clusters->SetMaxNoiseSigma(3);//maximal amount of sigma of noise
+
+  //set cluster finder parameters (from MC)
+  clusters->SetMinAdc(3);//signal threshold (everything below is treated as 0)
+  clusters->SetMinTimeBins(2);//number of neighbouring timebins
+  clusters->SetMaxPadRangeCm(5.);//distance of the cluster center to the center of a pad (in cm)
+  clusters->SetMaxRowRangeCm(5.);//distance of the cluster center to the center of a padrow (in cm)
+  clusters->SetMaxTimeRange(5.);//distance of the cluster center to the max time bin on a pad (in tackts)
+  //ie. fabs(centerT - time)<7
+  clusters->SetValueToSize(7.);//cut reduce peak at 0
+  clusters->SetIsolCut(3);//set isolation cut threshold
+
+  AliRawReader *reader = new AliRawReaderRoot(fileName);
+  reader->Reset();
+
+  TStopwatch timer;
+  timer.Start();
+
+  AliAltroRawStreamFast* stream = new AliAltroRawStreamFast(reader);
+  stream->SelectRawData("TPC");
+
+  Int_t evtnr=0;
+  while (reader->NextEvent()) {
+    //output for each event
+
+    //if(evtnr>4) break;
+    cout<<"Evt = "<<evtnr<<endl;
+    clusters->FinderIO(reader);
+    evtnr++;
+    AliSysInfo::AddStamp(Form("Event%d",evtnr),evtnr);
+  }
+
+
+  mytree->Print();//print rootuple summary 
+  // Save all objects in this file
+  hfile->Write();
+  // Close the file
+  hfile->Close();
+
+  timer.Stop();
+  timer.Print();
+  printf("Deleting clusterer\n");
+  delete clusters;
+  printf("Deleting stream\n");
+  delete stream;
+  printf("Deleting raw reader\n");
+  delete reader;
+
+//   TCanvas *c2=new TCanvas("c2","title",800,800);
+//   c2->SetHighLightColor(2);
+//   c2->Range(-458.9552,-2948.238,3296.642,26856.6);
+//   c2->SetBorderSize(2);
+//   c2->SetLeftMargin(0.15);
+//   c2->SetRightMargin(0.06);
+//   c2->SetFrameFillColor(0);
+
+//   gStyle->SetOptStat(111111);
+//   histoRow->Draw();
+//   c2->Print("rows.ps");
+//   histoPad->Draw();
+//   c2->Print("pads.ps");
+//   histoTime->Draw();
+//   c2->Print("timebins.ps");
+//   histoRowPad->Draw();
+//   c2->Print("row-pad.ps");
+
+  return 0;
+}
+
+
+Int_t FindKrClusterCheck(const char *fileName){
+  //
+  //
+  gSystem->Load("$ROOTSYS/lib/libGui.so");
+  gSystem->Load("$ROOTSYS/lib/libTree.so");
+  gSystem->Load("$MEMSTAT/libMemStat.so");
+  {
+    TMemStat memstat(1000000,100000,kTRUE);
+    AliSysInfo::AddCallBack(TMemStatManager::GetInstance()->fStampCallBack);
+    FindKrClustersRaw(fileName); 
+  }
+  // the output memstat.root file
+  TMemStat draw("memstat.root");
+  // Print some information
+  // code info
+  draw.MakeReport(0,0);
+
+}