/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/src/analyse/root/HistoFileBuilder.C

Go to the documentation of this file.
00001 //void HistoFileBuilder(TString path ; Tstring fileName )
00002 {
00003 gROOT->Reset();
00004 gSystem->Load("./libMicro.so");
00005 
00006 TString path = "./";
00007 TString fileName= "analyse.root"; 
00008 
00009 TFile *f = new TFile(path+fileName);
00010 cout<<"reading File : "<<path<<fileName<<endl;
00011 TTree *tree;
00012 tree  = (TTree*) f.Get("t1");cout<<"tree built\n";
00013 int nEntries = tree.GetEntries();
00014 MTEvent *evt = new MTEvent();
00015 TBranch *branch= tree->GetBranch("MTEvent");
00016 branch->SetAddress(&evt);
00017 //nEntries=500;
00018 cout <<"nEntries="<<nEntries<<endl;
00019 
00020 
00021   //construire NC Histogrammes qui vont contenir le signal de chaque canal
00022   //THStack hs("HStack","Histo for each pad");
00023   THStack *hs = new THStack("HStack","Histo for each channel");
00024   TH1F *hh = new TH1F("hh","single channel histo",1024,0.,1023.);
00025   TString trackname;
00026   int NC = 672;
00027   for(int j=0;j<NC;j++)
00028     {
00029       trackname = "channel";
00030       trackname+=j;
00031       hs->Add((TH1F*)hh->Clone(trackname));
00032     }
00033   cout<<"histo stack ready\n";
00034   //boucle sur les evt pour remplir les histo
00035   //nEntries=20000;
00036 
00037   for( int i=0;i<nEntries;i++)
00038     {    if(i%1000==0){cout<<i<<endl;}
00039       tree.GetEntry(i);
00040         for(int j=0;j<evt->GetNchannel();j++)
00041           {
00042             MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(j);
00043             TH1F *h=(TH1F*)hs.GetStack().UncheckedAt(channel->GetHardId());
00044             //if(channel.GetOrder()==0||channel.GetOrder()==96||channel.GetOrder()==192||channel.GetOrder()==288)
00045             {
00046               //cout<<i<<"\t"<<j<<"\t"<<channel.GetValue()<<endl;
00047               h.Fill(channel.GetValue());
00048             }
00049           }
00050     }
00051   cout<<"->histo filled\n";
00052 //////////////////////////////////////////////////////////////////////////////////////////////////////
00053 fileName="Histo_"+fileName;
00054 cout<<"root file to store histo"<<path<<fileName<<endl;
00055 TFile *fh = new TFile(path+fileName,"recreate");
00056 cout<<"Writing in rootfile"<<endl;
00057 for(int i=0;i<672;i++)
00058 {
00059   trackname = "channel";
00060   trackname+=i;
00061   
00062   TH1F *h=(TH1F*)hs.GetStack().UncheckedAt(i);
00063   
00064   h->Write(trackname);
00065 }
00066 fh->Close();
00067 cout<<"Histos written\n";
00068 ////////////////////////////////////////////////////////////////////////////////////////////////////
00069 
00070 
00071 }

Generated on Mon Jan 7 13:15:21 2013 for MicromegasFramework by  doxygen 1.4.7