> TFile file(filename.c_str(),"READ");
> int bytes = objectToSendBack.Read(key.c_str());
Histogram are (by default) associated with the TFile they are read from and are deleted as soon as the TFile is close or deleted.
See the ROOT's User Guide chapter on object ownership for more details.
Cheers,
Philippe.
On 9/19/11 6:14 AM, Harinder Singh Bawa wrote:
> *Hello,
>
> Could someone points me what I am doing wrong???
>
> I am running Package under Root which is a set of functions.
>
> *********The main code function is doShowFitToPythia which is retreiving histogram from file and then scaling to Lumi.
>
> The problem is in retreiving function
>
> It is supposed to read filename, the key is histogram and it is supposed to fill to object named h_pythia [histogram]. But its not
> doing so.
>
> When I want to make sure , it reads "massMC" histogram and saved to h_pythia object, I wanted to print the entries. But it
> crashes saying Signalhandler error shown after the function definitions:
>
>
> if(doShowFitToPythia) {*
> //get Pythia reco spectrum and fit it to show the function works.
> gPad->SetLogy(kTRUE);
> // gPad->SetLogx(kTRUE);
> TH1F h_pythia;
>
> cout<<"Retreiving file\t"<<endl;
> retrieve(mcFile,"massMC",h_pythia);
>
> *cout<<"files entries\t"<< h_pythia.GetEntries()<<endl;**********I did it because I am using h_pythia in next function* *Functions
> like scaleToLumi expect a histogram, not a pointer to a histogram.
>
> * cout<<"file retreived\t"<<endl;
> scaleToLumi(h_pythia,lumi);
>
> cout<<"histogram scaled to lumi\t"<<endl;
> h_pythia = KeepBinsBetween(&h_pythia,massMin,massMax);
>
> h_pythia.Draw();
> print(cv);
> }
>
>
> bool*retrieve(string filename, string key, TObject& objectToSendBack) {*
> TFile file(filename.c_str(),"READ");
> int bytes = objectToSendBack.Read(key.c_str());
> cout << " retrieved bytes=\t" << bytes << "\t of \t" << "\t filename= \t"<< filename << "\t with :key:: \t" << key << endl;
> file.Close();
> bool success = (bytes > 0);
> return success;
> }
>
> *void scaleToLumi(TH1F& hist, const double& desiredLumi, double currentAssumedLumi = 1.) {*
>
> cout<<"hist entries=\t"<<h_pythia.GetEntries()<<endl;
>
> cout<<"calculating area\t"<<endl;
> double area = hist.Integral();
>
> cout<<"Area of Histogram=\t"<<area<<endl;
> assert (area != 0);
> hist.Scale(desiredLumi / currentAssumedLumi);
> return;
> }
>
>
>
> *
> ERROR:*******************************************************************
> [bawa_at_pt3nfs resonance_old]$ ./producePlotsForICHEP.bash
> part 1
> rm: cannot remove `setLimits_output.root': No such file or directory
>
> Processing setLimits.C...
> Error in <TROOT::SetStyle>: Unknown style:ATLAS
> Info in <TCanvas::Print>: ps file pics/all.ps <http://all.ps> has been created
> Command to : doShowFitToPythia
> nominalDataFile = signal/june2011_B-H1/dijetMass_data.root
> mcFile = signal/june2011_B-H1/dijetMass_mc_noK.root
> nominalSignalsFile = signal/june2011_B-H1/dijetMass_exq.root
> Setting luminosity to 163.4 pb^-1
> Setting massMin to 700 GeV
> Setting massMax to 6000 GeV
> Setting outputFilename to setLimits_output.root
> Retreiving file
> retrieved bytes= 983 of filename= signal/june2011_B-H1/dijetMass_mc_noK.root with :key:: massMC
> file retreived
>
> *** Break *** segmentation violation
> file entries=
>
>
> ===========================================================
> There was a crash (#7 0xf7a0b5fd in SigHandler(ESignals) ()).
> This is the entire stack trace of all threads:
> ===========================================================
> #0 0xffffe410 in __kernel_vsyscall ()
> #1 0x00c37833 in __waitpid_nocancel () from /lib/libc.so.6
> #2 0x00bdc19b in do_system () from /lib/libc.so.6
> #3 0x00d40ead in system () from /lib/libpthread.so.0
> #4 0xf7a05ffd in TUnixSystem::Exec(char const*) ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCore.so
> #5 0xf7a0bbe6 in TUnixSystem::StackTrace() ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCore.so
> #6 0xf7a0b4e7 in TUnixSystem::DispatchSignals(ESignals) ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCore.so
> #7 0xf7a0b5fd in SigHandler(ESignals) ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCore.so
> #8 0xf7a02a32 in sighandler(int) ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCore.so
> #9 <signal handler called>
> #10 0x09f25788 in ?? ()
> #11 0xf6a42ec2 in G__G__Hist_100_0_101(G__value*, char const*, G__param*, int)
> ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libHist.so
> #12 0xf7276056 in Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCint.so
> #13 0xf732fd8c in G__execute_call ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCint.so
> #14 0xf7330b5f in G__call_cppfunc ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCint.so
> #15 0xf730affc in G__interpret_func ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCint.so
> #16 0xf72f7666 in G__getfunction ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCint.so
> #17 0xf73f1546 in G__getstructmem(int, G__FastAllocString&, char*, int, char*, int*, G__var_array*, int) ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCint.so
> #18 0xf73e71cd in G__getvariable ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCint.so
> #19 0xf72c8ecf in G__getitem ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCint.so
> #20 0xf72d5711 in G__getexpr ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCint.so
> #21 0xf735ab76 in G__exec_statement ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCint.so
> #22 0xf7361a3a in G__exec_statement ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCint.so
> #23 0xf730a5f7 in G__interpret_func ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCint.so
> #24 0xf72f773f in G__getfunction ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCint.so
> #25 0xf72c8fd8 in G__getitem ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCint.so
> #26 0xf72cd53c in G__getexpr ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCint.so
> #27 0xf72dbaf5 in G__calc_internal ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCint.so
> #28 0xf736fda7 in G__process_cmd ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCint.so
> #29 0xf79c669c in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCore.so
> #30 0xf79c408f in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCore.so
> #31 0xf7911c1f in TApplication::ExecuteFile(char const*, int*, bool) ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCore.so
> #32 0xf7911efc in TApplication::ProcessFile(char const*, int*, bool) ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCore.so
> #33 0xf790f5ff in TApplication::ProcessLine(char const*, bool, int*) ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libCore.so
> #34 0xf700ce51 in TRint::Run(bool) ()
> from /nfs/t3nfs/share/atlas/ATLASLocalRootBase/x86_64/root/5.28.00f-slc5-gcc4.3-i686/lib/libRint.so
> #35 0x08048db5 in main ()
> ===========================================================
>
>
> The lines below might hint at the cause of the crash.
> If they do not help you then please submit a bug report at
> http://root.cern.ch/bugs. Please post the ENTIRE stack trace
> from above as an attachment in addition to anything else
> that might help us fixing this issue.
> ===========================================================
> #10 0x09f25788 in ?? ()
> ===========================================================
>
Received on Mon Sep 19 2011 - 18:07:21 CEST
This archive was generated by hypermail 2.2.0 : Mon Sep 19 2011 - 23:50:01 CEST