TH2F* getTrigsAndMerge(TFile* fa,char* hname,const int nTCombData,string tCombData[]) { TH2F* theData[nTCombData]; if (fa == NULL) { std::cout << "getTrigsAndMerge: no hfile opened" << std::endl; return NULL; } std::cout << "getTrigsAndMerge: hname=" << hname << std::endl; for (int iTCombData=0; iTCombData<nTCombData; ++iTCombData) { // std::cout << "getTrigsAndMerge: iTCombData= " << iTCombData << " tCombData=" << tCombData[iTCombData] << std::endl; theData[iTCombData] = (TH2F*) fa->Get(Form("%s%s",hname,tCombData[iTCombData].c_str())); if (theData[iTCombData] == NULL) { std::cout << "getTrigsAndMerge: histogram " << Form("%s%s",hname,tCombData[iTCombData].c_str()) << " not found" << std::endl; return 0; } } string theName( hname ); // strip off any path in histogram name long unsigned int nsl = theName.find_last_of('/'); if (nsl != theName.npos) { theName = theName.substr(nsl+1,theName.size()-nsl-1); } string theTitle( theData[0]->GetTitle() ); TH2F* mergedData = new TH2F( *theData[0] ); for (int iTCombData=0; iTCombData<nTCombData; ++iTCombData) { theName += tCombData[iTCombData]; if (iTCombData != 0) theTitle += tCombData[iTCombData]; } mergedData->SetName( theName.c_str() ); for (int iTCombData=1; iTCombData<nTCombData; ++iTCombData) { mergedData->Add( theData[iTCombData] ); } std::cout << "getTrigsAndMerge: new name: " << mergedData->GetName() << std::endl; return mergedData; }
void CTagBase::setTitle(const wchar_t* s) { _sTitle = s; if (_tagFile && _tagFile->tag()) { TagLib::String theTitle(CW2A(s, CP_UTF8), TagLib::String::UTF8); _tagFile->tag()->setTitle(theTitle); } }
TH2F* mergeSignal(TFile* fa,char* hname,const char* newname) { TH2F* theData[2]; if (fa == NULL) { std::cout << "mergeSignal: no hfile opened" << std::endl; return NULL; } // // weights // double tWeight[2]; // tWeight[0] = (524.90+265.75)*.94*0.94 + 193.58+251.12+453.33; // tWeight[1] = 246.53+732.73; // double sumWeight = tWeight[0]+tWeight[1]; // for (int ii=0; ii<2; ++ii) { // tWeight[ii] = tWeight[ii] / sumWeight; // } // std::cout << "Trig weights: " << tWeight[0] << " " << tWeight[1] << std::endl; // only Trig0 is needed for (int ii=0; ii<1; ++ii) { std::cout << "mergeSignal: pick histogram " << Form("%sTrig%d",hname,ii) << std::endl; theData[ii] = (TH2F*) fa->Get(Form("%sTrig%d",hname,ii)); if (theData[ii] == NULL) { std::cout << "mergeSignal: histogram " << Form("%sTrig%d",hname,ii) << " not found" << std::endl; return 0; } //theData[ii]->Draw(); } std::string theName( hname ); // strip off any path in histogram name long unsigned int nsl = theName.find_last_of('/'); if (nsl != theName.npos) { theName = theName.substr(nsl+1,theName.size()-nsl-1); } std::string theTitle( theData[0]->GetTitle() ); TH2F* mergedData = new TH2F( *theData[0] ); //mergedData->Add(theData[0],theData[1],tWeight[0],tWeight[1]); if (newname == 0) { mergedData->SetName( Form("%s%s",theName.c_str(),"TrigMerged") ); } else { mergedData->SetName( newname ); } mergedData->SetTitle( mergedData->GetName() ); std::cout << "mergeSignal: hist has name " << mergedData->GetName() << std::endl; //mergedData->Draw(); //canvas->Print(Form("%s.png",newname)); return mergedData; }