Exemple #1
0
std::string Flp::fruityWrapper(unsigned char * buffer, int size)
{
    const int cidPluginName = 54;
    unsigned char * cursor = buffer;
    unsigned char * cursorEnd = cursor + size;
    int version = read32LEMem(&cursor);
    if (version <= 4) {
        // "old format"
        int extraBlockSize = read32LEMem(&cursor);
        int midiPort = read32LEMem(&cursor);
        int synthSaved = read32LEMem(&cursor);
        int pluginType = read32LEMem(&cursor);
        int pluginSpecificBlockSize = read32LEMem(&cursor);

        int pluginNameLen = readByteMem(&cursor);
        std::string pluginName((const char *)cursor, pluginNameLen);
        return pluginName;
    } else {
        // "new format"
        while (cursor < cursorEnd) {
            int chunkId = read32LEMem(&cursor);
            int64 chunkSize = read64LEMem(&cursor);
            if (chunkId == cidPluginName) {
                std::string pluginName((const char *)cursor,
                    (size_t)chunkSize);
                return pluginName;
            }
            skipMem(&cursor, chunkSize);
        }
    }
    return "";
}    
Exemple #2
0
DeviceManager::DeviceError DevicePluginConrad::executeAction(Device *device, const Action &action)
{

    QList<int> rawData;
    QByteArray binCode;

    int repetitions = 10;

    if (action.actionTypeId() == upActionTypeId) {
        binCode = "10101000";
    } else if (action.actionTypeId() == downActionTypeId) {
        binCode = "10100000";
    } else if (action.actionTypeId() == syncActionTypeId) {
        binCode = "10100000";
        repetitions = 20;
    } else {
        return DeviceManager::DeviceErrorActionTypeNotFound;
    }

    // append ID
    binCode.append("100101010110011000000001");

    //QByteArray remoteId = "100101010110011000000001";
    //    QByteArray motionDetectorId = "100100100101101101101010";
    //QByteArray wallSwitchId = "000001001101000010110110";
    //    QByteArray randomID     = "100010101010111010101010";



    // =======================================
    //create rawData timings list
    int delay = 650;

    // sync signal
    rawData.append(1);
    rawData.append(10);

    // add the code
    foreach (QChar c, binCode) {
        if(c == '0'){
            rawData.append(1);
            rawData.append(2);
        }
        if(c == '1'){
            rawData.append(2);
            rawData.append(1);
        }
    }

    // =======================================
    // send data to driver
    if(transmitData(delay, rawData, repetitions)){
        qCDebug(dcRF433) << "transmitted successfully" << pluginName() << device->name() << action.actionTypeId();
        return DeviceManager::DeviceErrorNoError;
    }else{
        qCWarning(dcRF433) << "could not transmitt" << pluginName() << device->name() << action.actionTypeId();
        return DeviceManager::DeviceErrorHardwareNotAvailable;
    }
}
DeviceManager::DeviceError DevicePluginUnitec::executeAction(Device *device, const Action &action)
{   
    QList<int> rawData;
    QByteArray binCode;

    if (action.actionTypeId() != powerActionTypeId) {
        return DeviceManager::DeviceErrorActionTypeNotFound;
    }

    // Bin codes for buttons
    if (device->paramValue("Channel").toString() == "A" && action.param("power").value().toBool() == true) {
        binCode.append("111011000100111010111111");
    } else if (device->paramValue("Channel").toString() == "A" && action.param("power").value().toBool() == false) {
        binCode.append("111001100110100001011111");
    } else if (device->paramValue("Channel").toString() == "B" && action.param("power").value().toBool() == true) {
        binCode.append("111011000100111010111011");
    } else if (device->paramValue("Channel").toString() == "B" && action.param("power").value().toBool() == false) {
        binCode.append("111000111001100111101011");
    } else if (device->paramValue("Channel").toString() == "C" && action.param("power").value().toBool() == true) {
        binCode.append("111000000011011111000011");
    } else if (device->paramValue("Channel").toString() == "C" && action.param("power").value().toBool() == false) {
        binCode.append("111001100110100001010011");
    } else if (device->paramValue("Channel").toString() == "D" && action.param("power").value().toBool() == true) {
        binCode.append("111001100110100001011101");
    } else if (device->paramValue("Channel").toString() == "D" && action.param("power").value().toBool() == false) {
        binCode.append("111000000011011111001101");
    }

    // =======================================
    //create rawData timings list
    int delay = 500;

    // add sync code
    rawData.append(6);
    rawData.append(14);

    // add the code
    foreach (QChar c, binCode) {
        if(c == '0'){
            rawData.append(2);
            rawData.append(1);
        }else{
            rawData.append(1);
            rawData.append(2);
        }
    }

    // =======================================
    // send data to hardware resource
    if(transmitData(delay, rawData)){
        qCDebug(dcUnitec) << "transmitted" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
        return DeviceManager::DeviceErrorNoError;
    }else{
        qCWarning(dcUnitec) << "could not transmitt" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
        return DeviceManager::DeviceErrorHardwareNotAvailable;
    }
}
Exemple #4
0
TestRegisterInterface::SuitePtr ToolkitTestPlugin::registerTests() const {
    SuitePtr res( new Suite( pluginName() + " test suite" ) );
    
    res->addTest( Suite::item_type( new BasicTestCase() ) );
    res->addTest( Suite::item_type( new MacroTestCase() ) );
    
    return res;
};
void CustomWidgetPluginWizardPage::slotCheckCompleteness()
{
    // A collection is complete only with class name
    bool completeNow = false;
    if (!pluginName().isEmpty()) {
        if (m_classCount > 1)
            completeNow = !collectionClassName().isEmpty();
        else
            completeNow = true;
    }
    if (completeNow != m_complete) {
        m_complete = completeNow;
        emit completeChanged();
    }
}
Exemple #6
0
	XdevLModule* createModule(const XdevLPluginDescriptor& pluginDescriptor, XdevLModuleDescriptor& moduleDescriptor, const XdevLFileName& pluginPath) {

		XdevLSharedLibrary* sharedLibrary = new XdevLSharedLibrary();
		XdevLFileName pluginName("");

		// Did the user specify a plugin folder?
		if(pluginPath != XdevLFileName()) {
			pluginName = pluginPath;
			pluginName += XdevLFileName("/");
		}

#ifdef XDEVL_PLATFORM_ANDROID
		pluginName += xdl::XdevLFileName("lib");
#endif

		pluginName += pluginDescriptor.getName() + STRING("-") + XdevLString(pluginDescriptor.getVersion().toString());
#ifdef XDEVL_DEBUG
		pluginName += STRING("d");
#endif
		pluginName += XdevLSharedLibrary::extension;
		std::string tmp(pluginName.toString());

		xdl_int ret;
		if((ret = checkLocal(tmp, sharedLibrary)) != RET_SUCCESS) {
			std::cerr << "## Could not find XdevLCore plugin at all." << std::endl;
			exit(-1);
		}

		//
		// Get the plugins create and delte function pointer.
		//
		moduleDescriptor.create = (CREATE_XDEVL_MODULE)(sharedLibrary->getFunctionAddress("_createModule"));
		if(!moduleDescriptor.create) {
			return nullptr;
		}
		moduleDescriptor.destroy = (DELETE_XDEVL_MODULE)(sharedLibrary->getFunctionAddress("_delete"));
		if(!moduleDescriptor.destroy) {
			return nullptr;
		}

		moduleDescriptor.setLibrary(sharedLibrary);

		return moduleDescriptor.create(pluginDescriptor, moduleDescriptor);

	}
static shared_ptr<mw::Component> createRealtimeComponent(const shared_ptr<ComponentRegistry> &componentRegistry,
                                                         const Datum &realtimeComponentsValue,
                                                         const std::string &componentType,
                                                         const std::string &defaultPluginName)
{
    std::string pluginName(defaultPluginName);
    
    if (realtimeComponentsValue.isDictionary()) {
        Datum componentValue = realtimeComponentsValue.getElement(componentType);
        if (componentValue.isString()) {
            pluginName = componentValue.getString();
        }
    }
    
    mprintf(M_SYSTEM_MESSAGE_DOMAIN, "  %s:\t%s", componentType.c_str(), pluginName.c_str());
    
    return componentRegistry->createNewObject(pluginName, map<string, string>());
}
Exemple #8
0
extern "C" JNIEXPORT jlongArray JNICALL Java_com_wikitude_architect_PluginManager_createNativePlugins(JNIEnv *env, jobject thisObj, jstring jPluginName) {

	env->GetJavaVM(&pluginJavaVM);

	int numberOfPlugins = 1;

    jlong cPluginsArray[numberOfPlugins];
    
    JavaStringResource pluginName(env, jPluginName);
    
    if (pluginName.str == "face_detection") {
        FaceDetectionPluginConnector* connector = new FaceDetectionPluginConnector();
        cPluginsArray[0] = (jlong) new FaceDetectionPlugin(640, 480, connector);
    } else if (pluginName.str == "barcode") {
    	cPluginsArray[0] = (jlong) new BarcodePlugin(640, 480);
    }
    
    jlongArray jPluginsArray = env->NewLongArray(numberOfPlugins);
    if (jPluginsArray != nullptr) {
        env->SetLongArrayRegion(jPluginsArray, 0, numberOfPlugins, cPluginsArray);
    }
    
    return jPluginsArray;
}
QString ApplicationDescription::getPluginName() const
{
    return QString::fromStdString(pluginName());
}
Exemple #10
0
DeviceManager::DeviceError DevicePluginLeynew::executeAction(Device *device, const Action &action)
{   

    if (device->deviceClassId() != rfControllerDeviceClassId) {
        return DeviceManager::DeviceErrorDeviceClassNotFound;
    }

    QList<int> rawData;
    QByteArray binCode;


    // TODO: find out how the id will be calculated to bin code or make it discoverable
    // =======================================
    // bincode depending on the id
    if (device->paramValue("id") == "0115"){
        binCode.append("001101000001");
    } else if (device->paramValue("id") == "0014") {
        binCode.append("110000010101");
    } else if (device->paramValue("id") == "0008") {
        binCode.append("111101010101");
    } else {
        qCWarning(dcLeynew) << "Could not get id of device: invalid parameter" << device->paramValue("id");
        return DeviceManager::DeviceErrorInvalidParameter;
    }

    int repetitions = 12;
    // =======================================
    // bincode depending on the action
    if (action.actionTypeId() == brightnessUpActionTypeId) {
        binCode.append("000000000011");
        repetitions = 8;
    } else if (action.actionTypeId() == brightnessDownActionTypeId) {
        binCode.append("000000001100");
        repetitions = 8;
    } else if (action.actionTypeId() == powerActionTypeId) {
        binCode.append("000011000000");
    } else if (action.actionTypeId() == redActionTypeId) {
        binCode.append("000000001111");
    } else if (action.actionTypeId() == greenActionTypeId) {
        binCode.append("000000110011");
    } else if (action.actionTypeId() == blueActionTypeId) {
        binCode.append("000011000011");
    } else if (action.actionTypeId() == whiteActionTypeId) {
        binCode.append("000000111100");
    } else if (action.actionTypeId() == orangeActionTypeId) {
        binCode.append("000011001100");
    } else if (action.actionTypeId() == yellowActionTypeId) {
        binCode.append("000011110000");
    } else if (action.actionTypeId() == cyanActionTypeId) {
        binCode.append("001100000011");
    } else if (action.actionTypeId() == purpleActionTypeId) {
        binCode.append("110000000011");
    } else if (action.actionTypeId() == playPauseActionTypeId) {
        binCode.append("000000110000");
    } else if (action.actionTypeId() == speedUpActionTypeId) {
        binCode.append("001100110000");
        repetitions = 8;
    } else if (action.actionTypeId() == speedDownActionTypeId) {
        binCode.append("110000000000");
        repetitions = 8;
    } else if (action.actionTypeId() == autoActionTypeId) {
        binCode.append("001100001100");
    } else if (action.actionTypeId() == flashActionTypeId) {
        binCode.append("110011000000");
    } else if (action.actionTypeId() == jump3ActionTypeId) {
        binCode.append("111100001100");
    } else if (action.actionTypeId() == jump7ActionTypeId) {
        binCode.append("001111000000");
    } else if (action.actionTypeId() == fade3ActionTypeId) {
        binCode.append("110000110000");
    } else if (action.actionTypeId() == fade7ActionTypeId) {
        binCode.append("001100000000");
    } else {
        return DeviceManager::DeviceErrorActionTypeNotFound;
    }

    // =======================================
    //create rawData timings list
    int delay = 50;

    // sync signal (starting with ON)
    rawData.append(3);
    rawData.append(90);

    // add the code
    foreach (QChar c, binCode) {
        if(c == '0'){
            //   _
            //  | |_ _
            rawData.append(3);
            rawData.append(9);
        }else{
            //   _ _
            //  |   |_
            rawData.append(9);
            rawData.append(3);
        }
    }

    // =======================================
    // send data to hardware resource
    if(transmitData(delay, rawData, repetitions)){
        qCDebug(dcLeynew) << "Transmitted" << pluginName() << device->name() << action.id();
        return DeviceManager::DeviceErrorNoError;
    }else{
        qCWarning(dcLeynew) << "Could not transmitt" << pluginName() << device->name() << action.id();
        return DeviceManager::DeviceErrorHardwareNotAvailable;
    }
}
Exemple #11
0
TestRegisterInterface::SuitePtr UtrPlugin::registerTests() const {
    SuitePtr res( new Suite( pluginName() + " test suite" ) );
    
    return res;
};
Exemple #12
0
void MuonPlots(TString pluginSuffix = ""){
  
  
  // Specify all input files
  TFile* a_file[nFiles];
  for(size_t iFile=0; iFile<nFiles; ++iFile) a_file[iFile]=0;
  a_file[0]=new TFile(inpath->Copy().Append("data/allData.root"));
  //a_file[1]=new TFile(inpath->Copy().Append("mc/zmumu.root"));
  a_file[1]=new TFile(inpath->Copy().Append("mc/zmumuB.root"));
  a_file[2]=new TFile(inpath->Copy().Append("mc/zmumuUdsc.root"));
  a_file[3]=new TFile(inpath->Copy().Append("mc/zz.root"));
  a_file[4]=new TFile(inpath->Copy().Append("mc/wz.root"));
  a_file[5]=new TFile(inpath->Copy().Append("mc/ww.root"));
  a_file[6]=new TFile(inpath->Copy().Append("mc/ztautau.root"));
  a_file[7]=new TFile(inpath->Copy().Append("mc/wmunu.root"));
  a_file[8]=new TFile(inpath->Copy().Append("mc/wtaunu.root"));
  a_file[9]=new TFile(inpath->Copy().Append("mc/singletopTw.root"));
  a_file[10]=new TFile(inpath->Copy().Append("mc/ttbar.root"));
  a_file[11]=new TFile(inpath->Copy().Append("mc/qcd.root"));
  
  //Specify plugin name
  TString* pluginName(0);
  pluginName = new TString("MuonAnalyzer");
  
  TString* pluginFolder(0);
  pluginFolder = new TString("");
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  // Do not touch this area
  
  pluginName->Append(pluginSuffix);
  if(!pluginName->IsNull())pluginName->Append("/");
  
  if(!pluginFolder->IsNull())pluginFolder->Append("/");
  
  HistogramTools tools;
  tools.SetDefaultStyle();
  
  TCanvas* canvas1(0);

  TLegend* legend1(0); 
   
  TH1F* a_hist1[nFiles];
  for(size_t iFile=0; iFile<nFiles; ++iFile) a_hist1[iFile]=0;
  
  THStack* stack1(0);
  
  TString* histName1(0);
  
  TString* plotName1(0);
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("EventProperties/h_nMuon");
  // Give base name of output plot
  plotName1 = new TString("nMuon");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("MuonProperties/h_chi2");
  // Give base name of output plot
  plotName1 = new TString("chi2");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("MuonProperties/h_d0Beamspot");
  // Give base name of output plot
  plotName1 = new TString("d0Beamspot");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("MuonProperties/h_eta");
  // Give base name of output plot
  plotName1 = new TString("eta");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("MuonProperties/h_isGlobal");
  // Give base name of output plot
  plotName1 = new TString("isGlobal");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("MuonProperties/h_isTracker");
  // Give base name of output plot
  plotName1 = new TString("isTracker");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("MuonProperties/h_nMatches");
  // Give base name of output plot
  plotName1 = new TString("nMatches");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("MuonProperties/h_nMuonHitsGlobal");
  // Give base name of output plot
  plotName1 = new TString("nMuonHitsGlobal");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("MuonProperties/h_nPixelHits");
  // Give base name of output plot
  plotName1 = new TString("nPixelHits");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("MuonProperties/h_nTrackerHits");
  // Give base name of output plot
  plotName1 = new TString("nTrackerHits");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("MuonProperties/h_pt");
  // Give base name of output plot
  plotName1 = new TString("pt");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("MuonProperties/h_isoCombRel");
  // Give base name of output plot
  plotName1 = new TString("isoCombRel");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  stack1->GetXaxis()->SetRangeUser(0.,3.);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("MuonProperties/h_isoTrk");
  // Give base name of output plot
  plotName1 = new TString("isoTrk");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // again, no changes here
  
  delete pluginFolder;
  delete pluginName;
  
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_file[iFile])a_file[iFile]->Close();
  }
  
  //delete inpath;
  //delete outpath;
  //delete outform;
  
}
void GeneratorZmumuPlots(TString pluginSuffix = ""){
  
  
  // Specify all input files
  TFile* file;
  file = new TFile(inpath->Copy().Append("simulation/generatorTopZmumu.root"));
  //file = new TFile(inpath->Copy().Append("generatorTopZmumuSelection.root"));
  
  //Specify plugin name
  TString* pluginName(0);
  pluginName = new TString("GeneratorZmumuAnalyzer");
  
  TString* a_flavour[nFlavour];
  for(size_t iFlavour=0; iFlavour<nFlavour; ++iFlavour) a_flavour[iFlavour]=0;
  a_flavour[1] = new TString("");
  //a_flavour[2] = new TString("C");
  //a_flavour[3] = new TString("B");
  
  
  TString* pluginFolder(0);
  pluginFolder = new TString("");
  
  
  
  
//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  // Do not touch this area
  
  
  if(!pluginFolder->IsNull())pluginFolder->Append("/");
  
  TString* a_baseString[nFlavour];
  for(size_t iFlavour=0; iFlavour<nFlavour; ++iFlavour) a_baseString[iFlavour]=0;
  
  for(size_t iFlavour=0; iFlavour<nFlavour; ++iFlavour){  // do not use array [0]
    if(!a_flavour[iFlavour])continue;
    const TString flavour(*a_flavour[iFlavour]);
    a_baseString[iFlavour] = new TString(pluginName->Copy().Append(flavour).Append(pluginSuffix).Append("/").Append(*pluginFolder));
  }
  
  
//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  
  // Do not touch this area
  
  
  
  HistogramTools tools;
  //tools.SetDefaultStyle();
  // for publications tdr style is used
  setTDRStyle();
  TGaxis::SetMaxDigits(3);
  
  
  TCanvas* canvas1(0);

  TLegend* legend1(0); 
   
  TH1F* a_hist1[nFlavour];  // do not use array [0]
  for(size_t iFlavour=0; iFlavour<nFlavour; ++iFlavour) a_hist1[iFlavour]=0;
  TH1F* a_hist2[nFlavour];  // For addition of histograms
  for(size_t iFlavour=0; iFlavour<nFlavour; ++iFlavour) a_hist2[iFlavour]=0;
  
  THStack* stack1(0);
  
  TString* histName1(0);
  TString* histName2(0);  // For addition of histograms
  
  TString* plotName1(0);
  
//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("GeneratedZ/h_zMass");
  // Give base name of output plot
  plotName1 = new TString("Z_mass");
  // Change position & size of legend
  legend1 = new TLegend(0.85,0.75,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArraySameFile(file, a_baseString, *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1, nFlavour);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1, nFlavour);
  tools.FillLegendGenerator(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  //legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist1[iHist])a_hist1[iHist]->Delete();
  }
  canvas1->Close();
  
  
  
  
//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("GeneratedZ/h_zEta");
  // Give base name of output plot
  plotName1 = new TString("Z_eta");
  // Change position & size of legend
  legend1 = new TLegend(0.85,0.75,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArraySameFile(file, a_baseString, *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1, nFlavour);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1, nFlavour);
  tools.FillLegendGenerator(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  //legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist1[iHist])a_hist1[iHist]->Delete();
  }
  canvas1->Close();
  
  
  
  
//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("GeneratedZ/h_zY");
  // Give base name of output plot
  plotName1 = new TString("Z_y");
  // Change position & size of legend
  legend1 = new TLegend(0.85,0.75,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArraySameFile(file, a_baseString, *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1, nFlavour);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1, nFlavour);
  tools.FillLegendGenerator(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  //legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist1[iHist])a_hist1[iHist]->Delete();
  }
  canvas1->Close();
  
  
  
  
//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("GeneratedZ/h_zPt");
  // Give base name of output plot
  plotName1 = new TString("Z_pt");
  // Change position & size of legend
  legend1 = new TLegend(0.85,0.75,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArraySameFile(file, a_baseString, *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1, nFlavour);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1, nFlavour);
  tools.FillLegendGenerator(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  //legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist1[iHist])a_hist1[iHist]->Delete();
  }
  canvas1->Close();
  
  
  
  
//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("GeneratedZ/h_zQuarkOrigin");
  // Give base name of output plot
  plotName1 = new TString("Z_quarkOrigin");
  // Change position & size of legend
  legend1 = new TLegend(0.85,0.75,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArraySameFile(file, a_baseString, *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1, nFlavour);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1, nFlavour);
  tools.FillLegendGenerator(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  //legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist1[iHist])a_hist1[iHist]->Delete();
  }
  canvas1->Close();
  
  
  
  
  
//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("SingleMu/h_muEtaHigh");
  // Give base name of output plot
  plotName1 = new TString("mu_etaHigh");
  // Change position & size of legend
  legend1 = new TLegend(0.85,0.75,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArraySameFile(file, a_baseString, *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1, nFlavour);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1, nFlavour);
  tools.FillLegendGenerator(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  //legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist1[iHist])a_hist1[iHist]->Delete();
  }
  canvas1->Close();
  
  
  
  
//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("SingleMu/h_muEtaLow");
  // Give base name of output plot
  plotName1 = new TString("mu_etaLow");
  // Change position & size of legend
  legend1 = new TLegend(0.85,0.75,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArraySameFile(file, a_baseString, *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1, nFlavour);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1, nFlavour);
  tools.FillLegendGenerator(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  //legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist1[iHist])a_hist1[iHist]->Delete();
  }
  canvas1->Close();
  
  
  
  
//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("SingleMu/h_muEtaLow");
  // Give name of second input histogram for addition
  histName2 = new TString("SingleMu/h_muEtaHigh");
  // Give base name of output plot
  plotName1 = new TString("mu_etaBoth");
  // Change position & size of legend
  legend1 = new TLegend(0.85,0.75,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArraySameFile(file, a_baseString, *histName1, a_hist1, nFlavour);
  tools.GetHistArraySameFile(file, a_baseString, *histName2, a_hist2, nFlavour);
  tools.AddHistArrays(a_hist1, a_hist2, nFlavour);
  tools.SetPlotFilling(a_hist1, nFlavour);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1, nFlavour);
  tools.FillLegendGenerator(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->SetTitle("pseudorapidity #eta of both muons");
  stack1->Draw();
  //legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete histName2;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist1[iHist])a_hist1[iHist]->Delete();
  }
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist2[iHist])a_hist2[iHist]->Delete();
  }
  canvas1->Close();
  
  
  
  
//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("SingleMu/h_muPtHigh");
  // Give base name of output plot
  plotName1 = new TString("mu_ptHigh");
  // Change position & size of legend
  legend1 = new TLegend(0.85,0.75,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArraySameFile(file, a_baseString, *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1, nFlavour);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1, nFlavour);
  tools.FillLegendGenerator(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  //legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist1[iHist])a_hist1[iHist]->Delete();
  }
  canvas1->Close();
  
  
  
  
//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("SingleMu/h_muPtLow");
  // Give base name of output plot
  plotName1 = new TString("mu_ptLow");
  // Change position & size of legend
  legend1 = new TLegend(0.85,0.75,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArraySameFile(file, a_baseString, *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1, nFlavour);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1, nFlavour);
  tools.FillLegendGenerator(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  //legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist1[iHist])a_hist1[iHist]->Delete();
  }
  canvas1->Close();

  


//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("SingleMu/h_muPtLow");
  // Give name of second input histogram for addition
  histName2 = new TString("SingleMu/h_muPtHigh");
  // Give base name of output plot
  plotName1 = new TString("mu_ptBoth");
  // Change position & size of legend
  legend1 = new TLegend(0.85,0.75,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArraySameFile(file, a_baseString, *histName1, a_hist1, nFlavour);
  tools.GetHistArraySameFile(file, a_baseString, *histName2, a_hist2, nFlavour);
  tools.AddHistArrays(a_hist1, a_hist2, nFlavour);
  tools.SetPlotFilling(a_hist1, nFlavour);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1, nFlavour);
  tools.FillLegendGenerator(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->SetTitle("transverse momentum p_{t} of both muons");
  stack1->Draw();
  //legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete histName2;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist1[iHist])a_hist1[iHist]->Delete();
  }
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist2[iHist])a_hist2[iHist]->Delete();
  }
  canvas1->Close();
  
  
  
  
//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("DiMu/h_diMuMass");
  // Give base name of output plot
  plotName1 = new TString("diMu_mass");
  // Change position & size of legend
  legend1 = new TLegend(0.85,0.75,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArraySameFile(file, a_baseString, *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1, nFlavour);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1, nFlavour);
  tools.FillLegendGenerator(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  //legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist1[iHist])a_hist1[iHist]->Delete();
  }
  canvas1->Close();

  



//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("DiMu/h_diMuEta");
  // Give base name of output plot
  plotName1 = new TString("diMu_eta");
  // Change position & size of legend
  legend1 = new TLegend(0.85,0.75,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArraySameFile(file, a_baseString, *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1, nFlavour);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1, nFlavour);
  tools.FillLegendGenerator(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  //legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist1[iHist])a_hist1[iHist]->Delete();
  }
  canvas1->Close();




//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("DiMu/h_diMuPt");
  // Give base name of output plot
  plotName1 = new TString("diMu_pt");
  // Change position & size of legend
  legend1 = new TLegend(0.85,0.75,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArraySameFile(file, a_baseString, *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1, nFlavour);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1, nFlavour);
  tools.FillLegendGenerator(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  //legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist1[iHist])a_hist1[iHist]->Delete();
  }
  canvas1->Close();




//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("Difference/h_diffMass");
  // Give base name of output plot
  plotName1 = new TString("diff_mass");
  // Change position & size of legend
  legend1 = new TLegend(0.85,0.75,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArraySameFile(file, a_baseString, *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1, nFlavour);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1, nFlavour);
  tools.FillLegendGenerator(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  //legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist1[iHist])a_hist1[iHist]->Delete();
  }
  canvas1->Close();





//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("Difference/h_diffEta");
  // Give base name of output plot
  plotName1 = new TString("diff_eta");
  // Change position & size of legend
  legend1 = new TLegend(0.85,0.75,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArraySameFile(file, a_baseString, *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1, nFlavour);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1, nFlavour);
  tools.FillLegendGenerator(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  //legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist1[iHist])a_hist1[iHist]->Delete();
  }
  canvas1->Close();






//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("Difference/h_diffPt");
  // Give base name of output plot
  plotName1 = new TString("diff_pt");
  // Change position & size of legend
  legend1 = new TLegend(0.85,0.75,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArraySameFile(file, a_baseString, *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1, nFlavour);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1, nFlavour);
  tools.FillLegendGenerator(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  //legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_hist1[iHist])a_hist1[iHist]->Delete();
  }
  canvas1->Close();




//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
//  histName1 = new TString("Difference/h2_zMassVsDiMuMass");
  // Give base name of output plot
//  plotName1 = new TString("diff_2d_mass");
  










//++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // again, no changes here
  
  
  for(size_t iHist=0; iHist<nFlavour; ++iHist){
    if(a_flavour[iHist])delete a_flavour[iHist];
  }
  
  delete pluginFolder;
  delete pluginName;
  
  file->Close();
  
  // do not delete as long as they are defined outside function
  //delete inpath;
  //delete outpath;
  //delete outform;
  
}
Exemple #14
0
bool AP_Win32App::initialize(void)
{
	bool bSuccess = true;
	const char * szUserPrivateDirectory = getUserPrivateDirectory();
	bool bVerified = s_createDirectoryIfNecessary(szUserPrivateDirectory);

	UT_return_val_if_fail (bVerified, false);

	// create templates directory
	UT_String sTemplates = szUserPrivateDirectory;
	sTemplates += "/templates";
	s_createDirectoryIfNecessary(sTemplates.c_str());

	// load the preferences.
	
	m_prefs = new AP_Win32Prefs();
	UT_return_val_if_fail (m_prefs, false);
	
	m_prefs->fullInit();
		   
	// now that preferences are established, let the xap init

	m_pClipboard = new AP_Win32Clipboard();
	UT_return_val_if_fail (m_pClipboard, false);
	   
	m_pEMC = AP_GetEditMethods();
	UT_return_val_if_fail (m_pEMC, false);

	m_pBindingSet = new AP_BindingSet(m_pEMC);
	UT_return_val_if_fail (m_pBindingSet, false);
	
	m_pMenuActionSet = AP_CreateMenuActionSet();
	UT_return_val_if_fail (m_pMenuActionSet,false);

	m_pToolbarActionSet = AP_CreateToolbarActionSet();
	UT_return_val_if_fail (m_pToolbarActionSet,false);

	//////////////////////////////////////////////////////////////////
	// load the dialog and message box strings
	//////////////////////////////////////////////////////////////////
	
	{
		// assume we will be using the builtin set (either as the main
		// set or as the fallback set).
		
		AP_BuiltinStringSet * pBuiltinStringSet = new AP_BuiltinStringSet(this,AP_PREF_DEFAULT_StringSet);
		UT_return_val_if_fail (pBuiltinStringSet, false);
		m_pStringSet = pBuiltinStringSet;

		// see if we should load an alternate set from the disk
		
		const char * szDirectory = NULL;
		const char * szStringSet = NULL;

		if (   (getPrefsValue(AP_PREF_KEY_StringSet,&szStringSet))
			&& (szStringSet)
			&& (*szStringSet)
			&& (g_ascii_strcasecmp(szStringSet,AP_PREF_DEFAULT_StringSet) != 0))
		{
			getPrefsValueDirectory(true,AP_PREF_KEY_StringSetDirectory,&szDirectory);
			UT_return_val_if_fail ((szDirectory) && (*szDirectory), false);

			char * szPathname = (char *)UT_calloc(sizeof(char),strlen(szDirectory)+strlen(szStringSet)+100);
			UT_return_val_if_fail (szPathname, false);

			sprintf(szPathname,"%s%s%s.strings",
					szDirectory,
					((szDirectory[strlen(szDirectory)-1]=='\\') ? "" : "\\"),
					szStringSet);

			AP_DiskStringSet * pDiskStringSet = new AP_DiskStringSet(this);
			UT_return_val_if_fail (pDiskStringSet, false);

			if (pDiskStringSet->loadStringsFromDisk(szPathname))
			{
				pDiskStringSet->setFallbackStringSet(m_pStringSet);
				m_pStringSet = pDiskStringSet;
				UT_Language_updateLanguageNames();
				UT_DEBUGMSG(("Using StringSet [%s]\n",szPathname));
			}
			else
			{
				UT_DEBUGMSG(("Unable to load StringSet [%s] -- using builtin strings instead.\n",szPathname));				
				DELETEP(pDiskStringSet);
			}
				
			g_free(szPathname);
		}
	}

	// AP_App::initilize() calls for us XAP_Win32App::initialize()
	if (! AP_App::initialize())
		return false;

	
	// let various window types register themselves

	if (!AP_Win32Frame::RegisterClass(this))
	{
		UT_DEBUGMSG(("couldn't register class\n"));
		return false;
	}

	//////////////////////////////////////////////////////////////////
	// Initialize the importers/exporters
	//////////////////////////////////////////////////////////////////
	IE_ImpExp_RegisterXP ();

	//////////////////////////////////////////////////////////////////
	// initializes the spell checker.
	//////////////////////////////////////////////////////////////////
	
	{
#if ENABLE_SPELL
		SpellManager::instance();
#endif
	}
	
	
	// Now we have the strings loaded we can populate the field names correctly
	int i;
	
	for (i = 0; fp_FieldTypes[i].m_Type != FPFIELDTYPE_END; i++)
	{
	    (&fp_FieldTypes[i])->m_Desc = m_pStringSet->getValue(fp_FieldTypes[i].m_DescId);
	    UT_DEBUGMSG(("Setting field type desc for type %d, desc=%s\n", fp_FieldTypes[i].m_Type, fp_FieldTypes[i].m_Desc));
	}

	for (i = 0; fp_FieldFmts[i].m_Tag != NULL; i++)
	{
	    (&fp_FieldFmts[i])->m_Desc = m_pStringSet->getValue(fp_FieldFmts[i].m_DescId);
	    UT_DEBUGMSG(("Setting field desc for field %s, desc=%s\n", fp_FieldFmts[i].m_Tag, fp_FieldFmts[i].m_Desc));
	}

    ///////////////////////////////////////////////////////////////////////
    /// Build a labelset so the plugins can add themselves to something ///
    ///////////////////////////////////////////////////////////////////////

	const char * szMenuLabelSetName = NULL;
	if (getPrefsValue( AP_PREF_KEY_StringSet, (const gchar**)&szMenuLabelSetName)
		&& (szMenuLabelSetName) && (*szMenuLabelSetName))
	{
		;
	}
	else
		szMenuLabelSetName = AP_PREF_DEFAULT_StringSet;

	getMenuFactory()->buildMenuLabelSet(szMenuLabelSetName);	
	
	//////////////////////////////////////////////////////////////////
	// Check for necessary DLLs now that we can do localized error messages
	//////////////////////////////////////////////////////////////////

	// Ensure that common control DLL is loaded
	HINSTANCE hinstCC = LoadLibraryW(L"comctl32.dll");
	UT_return_val_if_fail (hinstCC, false);
	InitCommonControlsEx_fn  pInitCommonControlsEx = NULL;
	if( hinstCC != NULL )
		pInitCommonControlsEx = (InitCommonControlsEx_fn)GetProcAddress( hinstCC, "InitCommonControlsEx");
	if( pInitCommonControlsEx != NULL )
	{
		INITCOMMONCONTROLSEX icex;
		icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
		icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES 	// load the rebar and toolbar
					| ICC_TAB_CLASSES | ICC_UPDOWN_CLASS	// and tab and spin controls
					| ICC_STANDARD_CLASSES;
		pInitCommonControlsEx(&icex);
	}
	else
	{
		InitCommonControls();

		UT_Win32LocaleString err;
		err.fromUTF8 (m_pStringSet->getValue(AP_STRING_ID_WINDOWS_COMCTL_WARNING));		
		MessageBoxW(NULL, err.c_str(), NULL, MB_OK);
	}

	//////////////////////////////////////////////////////////////////
	// load the all Plugins from the correct directory
	//////////////////////////////////////////////////////////////////

#ifndef DISABLE_BUILTIN_PLUGINS
	abi_register_builtin_plugins();
#endif

	bool bLoadPlugins = true;
	bool bFound = getPrefsValueBool(XAP_PREF_KEY_AutoLoadPlugins,&bLoadPlugins);

	if(bLoadPlugins || !bFound)
	{
		WCHAR szPath[PATH_MAX];
		WCHAR szPlugin[PATH_MAX];
		_getExeDir( szPath, PATH_MAX);
#ifdef _MSC_VER
		lstrcatW(szPath, L"..\\plugins\\*.dll");
#else
#define ABI_WIDE_STRING(t) L ## t
		lstrcatW(szPath, ABI_WIDE_STRING("..\\lib\\" PACKAGE L"-" ABIWORD_SERIES L"\\plugins\\*.dll"));
#endif

		WIN32_FIND_DATAW cfile;
		HANDLE findtag = FindFirstFileW( szPath, &cfile );
		if( findtag != INVALID_HANDLE_VALUE )
		{
			do
			{	
				_getExeDir( szPlugin, PATH_MAX );
#ifdef _MSC_VER
				lstrcatW( szPlugin, L"..\\plugins\\" );
#else
				lstrcatW( szPlugin, ABI_WIDE_STRING("..\\lib\\" PACKAGE L"-" ABIWORD_SERIES L"\\plugins\\" ));
#endif
				lstrcatW( szPlugin, cfile.cFileName );
				XAP_ModuleManager::instance().loadModule( getUTF8String(szPlugin) );
			} while( FindNextFileW ( findtag, &cfile ) );
			FindClose( findtag );
		}

		UT_String pluginName( getUserPrivateDirectory() ); 
		UT_String pluginDir( getUserPrivateDirectory() );
		pluginDir += "\\AbiWord\\plugins\\*.dll";
		UT_Win32LocaleString str;
		str.fromUTF8(pluginDir.c_str());
		findtag = FindFirstFileW( str.c_str(), &cfile );
		if( findtag != INVALID_HANDLE_VALUE )
		{
			do
			{	
				pluginName = getUserPrivateDirectory();
				pluginName += "\\AbiWord\\plugins\\";
				pluginName += getUTF8String(cfile.cFileName);
				XAP_ModuleManager::instance().loadModule( pluginName.c_str() );
			} while( FindNextFileW( findtag, &cfile ) );
			FindClose( findtag );
		}
	}
	return bSuccess;
}
//----------------------------------------------------------------------------
int main(int argv, char** argc)
{
  QApplication app(argv, argc);

  qApp->setOrganizationName("CTK");
  qApp->setOrganizationDomain("commontk.org");
  qApp->setApplicationName("ctkExampleHostedApp");

  ctkCommandLineParser parser;
  parser.setArgumentPrefix("--", "-"); // Use Unix-style argument names

  // Add command line argument names
  parser.addArgument("hostURL", "", QVariant::String, "Hosting system URL");
  parser.addArgument("applicationURL", "", QVariant::String, "Hosted Application URL");
  parser.addArgument("help", "h", QVariant::Bool, "Show this help text");

  bool ok = false;
  QHash<QString, QVariant> parsedArgs = parser.parseArguments(QCoreApplication::arguments(), &ok);
  if (!ok)
    {
    QTextStream(stderr, QIODevice::WriteOnly) << "Error parsing arguments: "
                                              << parser.errorString() << "\n";
    return EXIT_FAILURE;
    }

  // Show a help message
   if (parsedArgs.contains("help"))
     {
     print_usage();
     QTextStream(stdout, QIODevice::WriteOnly) << parser.helpText();
     return EXIT_SUCCESS;
     }

  if(parsedArgs.count() != 2)
    {
    qCritical() << "Wrong number of command line arguments.";
    print_usage();
    QTextStream(stdout, QIODevice::WriteOnly) << parser.helpText();
    return EXIT_FAILURE;
    }

  QString hostURL = parsedArgs.value("hostURL").toString();
  QString appURL = parsedArgs.value("applicationURL").toString();
  qDebug() << "appURL is: " << appURL << " . Extracted port is: " << QUrl(appURL).port();

  // setup the plugin framework
  ctkProperties fwProps;
  fwProps.insert("dah.hostURL", hostURL);
  fwProps.insert("dah.appURL", appURL);
  ctkPluginFrameworkFactory fwFactory(fwProps);
  QSharedPointer<ctkPluginFramework> framework = fwFactory.getFramework();

  try
    {
    framework->init();
    }
  catch (const ctkPluginException& exc)
    {
    qCritical() << "Failed to initialize the plug-in framework:" << exc;
    return EXIT_FAILURE;
    }

#ifdef CMAKE_INTDIR
  QString pluginPath = CTK_PLUGIN_DIR CMAKE_INTDIR "/";
#else
  QString pluginPath = CTK_PLUGIN_DIR;
#endif

  qApp->addLibraryPath(pluginPath);

  // Construct the name of the plugin with the business logic
  // (thus the actual logic of the hosted app)
  QString pluginName("org_commontk_dah_exampleapp");
  if(parser.unparsedArguments().count() > 0)
    {
    pluginName = parser.unparsedArguments().at(0);
    }

  // try to find the plugin and install all plugins available in
  // pluginPath containing the string "org_commontk_dah" (but do not start them)
  QSharedPointer<ctkPlugin> appPlugin;
  QStringList libFilter;
  libFilter << "*.dll" << "*.so" << "*.dylib";
  QDirIterator dirIter(pluginPath, libFilter, QDir::Files);
  while(dirIter.hasNext())
    {
    try
      {
      QString fileLocation = dirIter.next();
      if (fileLocation.contains("org_commontk_dah"))
        {
        QSharedPointer<ctkPlugin> plugin = framework->getPluginContext()->installPlugin(QUrl::fromLocalFile(fileLocation));
        if (fileLocation.contains(pluginName))
          {
          appPlugin = plugin;
          }
        //plugin->start(ctkPlugin::START_TRANSIENT);
        }
      }
    catch (const ctkPluginException& e)
      {
      qCritical() << e.what();
      }
    }

  // if we did not find the business logic: abort
  if(!appPlugin)
    {
    qCritical() << "Could not find plugin.";
    qCritical() << "  Plugin name: " << pluginName;
    qCritical() << "  Plugin path: " << pluginPath;
    return EXIT_FAILURE;
    }

  // start the plugin framework
  framework->start();

  // start the plugin with the business logic
  try
    {
    appPlugin->start();
    }
  catch (const ctkPluginException& e)
    {
    qCritical() << e;
    }

  return app.exec();
}
Exemple #16
0
void DimuonPlots(TString pluginSuffix = ""){
  
  
  // Specify all input files
  TFile* a_file[nFiles];
  for(size_t iFile=0; iFile<nFiles; ++iFile) a_file[iFile]=0;
  a_file[0]=new TFile(inpath->Copy().Append("data/allData.root"));
  //a_file[1]=new TFile(inpath->Copy().Append("mc/zmumu.root"));
  a_file[1]=new TFile(inpath->Copy().Append("mc/zmumuB.root"));
  a_file[2]=new TFile(inpath->Copy().Append("mc/zmumuUdsc.root"));
  a_file[3]=new TFile(inpath->Copy().Append("mc/zz.root"));
  a_file[4]=new TFile(inpath->Copy().Append("mc/wz.root"));
  a_file[5]=new TFile(inpath->Copy().Append("mc/ww.root"));
  a_file[6]=new TFile(inpath->Copy().Append("mc/ztautau.root"));
  a_file[7]=new TFile(inpath->Copy().Append("mc/wmunu.root"));
  a_file[8]=new TFile(inpath->Copy().Append("mc/wtaunu.root"));
  a_file[9]=new TFile(inpath->Copy().Append("mc/singletopTw.root"));
  a_file[10]=new TFile(inpath->Copy().Append("mc/ttbar.root"));
  a_file[11]=new TFile(inpath->Copy().Append("mc/qcd.root"));
  
  //Specify plugin name
  TString* pluginName(0);
  pluginName = new TString("DiMuonAnalyzer");
  
  TString* pluginFolder(0);
  pluginFolder = new TString("OppositeCharge");
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  // Do not touch this area
  
  pluginName->Append(pluginSuffix);
  if(!pluginName->IsNull())pluginName->Append("/");
  
  if(!pluginFolder->IsNull())pluginFolder->Append("/");
  
  HistogramTools tools;
  tools.SetDefaultStyle();
  
  TCanvas* canvas1(0);

  TLegend* legend1(0); 
   
  TH1F* a_hist1[nFiles];
  for(size_t iFile=0; iFile<nFiles; ++iFile) a_hist1[iFile]=0;
  TH1F* a_hist2[nFiles];  // For addition of histograms
  for(size_t iFile=0; iFile<nFiles; ++iFile) a_hist2[iFile]=0;
  
  THStack* stack1(0);
  
  TString* histName1(0);
  TString* histName2(0);  // For addition of histograms
  
  TString* plotName1(0);
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("h_nDimuon");
  // Give base name of output plot
  plotName1 = new TString("nDimuon");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("h_deltaEta");
  // Give base name of output plot
  plotName1 = new TString("deltaEta");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("h_deltaPhi");
  // Give base name of output plot
  plotName1 = new TString("deltaPhi");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("h_diMass");
  // Give base name of output plot
  plotName1 = new TString("diMass");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("h_diPt");
  // Give base name of output plot
  plotName1 = new TString("diPt");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("h_diY");
  // Give base name of output plot
  plotName1 = new TString("diY");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("h_etaHigh");
  // Give base name of output plot
  plotName1 = new TString("etaHigh");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("h_etaLow");
  // Give base name of output plot
  plotName1 = new TString("etaLow");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("h_etaLow");
  // Give name of second input histogram for addition
  histName2 = new TString("h_etaHigh");
  // Give base name of output plot
  plotName1 = new TString("etaBoth");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName2, a_hist2);
  tools.AddHistArrays(a_hist1, a_hist2);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->SetTitle("pseudorapidity of both muons");
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete histName2;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist2[iFile])a_hist2[iFile]->Delete();
  }
  canvas1->Close();

  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("h_ptHigh");
  // Give base name of output plot
  plotName1 = new TString("ptHigh");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  

  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("h_ptLow");
  // Give base name of output plot
  plotName1 = new TString("ptLow");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  canvas1->Close();
  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // Next few lines are only one to change for histo (except for individual style changes)
  
  // Give name of input histogram
  histName1 = new TString("h_ptLow");
  // Give name of second input histogram for addition
  histName2 = new TString("h_ptHigh");
  // Give base name of output plot
  plotName1 = new TString("ptBoth");
  // Change position & size of legend
  legend1 = new TLegend(0.65,0.55,0.99,0.95); 
  
  
  // Change only style here
  
  canvas1 = new TCanvas("plot", "plot", 800, 800);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName1, a_hist1);
  tools.GetHistArray(a_file, pluginName->Copy().Append(*pluginFolder), *histName2, a_hist2);
  tools.AddHistArrays(a_hist1, a_hist2);
  tools.SetPlotFilling(a_hist1);
  tools.SetWeights(a_hist1, dataLumi);
  stack1 = new THStack("stack","stack");
  tools.FillStack(stack1, a_hist1);
  // If you want to set maximum by hand, else use function and scale
  // stack1->SetMaximum(30);
  stack1->SetMaximum(tools.GetMaximumValue(stack1, a_hist1[0]) *1.2);
  tools.FillLegend(legend1, a_hist1, "f");
  canvas1->Clear();
  stack1->SetTitle("transverse momentum p_{t} of both muons");
  stack1->Draw();
  if(a_hist1[0]){ 
    a_hist1[0]->Draw("same,e1");
  }  
  legend1->Draw("same");
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append(*outform));
  
  gPad->SetLogy(1);
  stack1->SetMinimum(0.01);
  canvas1->Update();
  canvas1->Print(outpath->Copy().Append(*plotName1).Append(pluginSuffix).Append("_log").Append(*outform));
      
  delete histName1;
  delete histName2;
  delete plotName1;
  legend1->Delete();
  stack1->Delete();
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist1[iFile])a_hist1[iFile]->Delete();
  }
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_hist2[iFile])a_hist2[iFile]->Delete();
  }
  canvas1->Close();

  
  

  
  
  
  
  //++++++++++++++++++++++++++++++++++=====================================+++++++++++++++++++++++++++++++
  
  
  // again, no changes here
  
  delete pluginFolder;
  delete pluginName;
  
  for(size_t iFile=0; iFile<nFiles; ++iFile){
    if(a_file[iFile])a_file[iFile]->Close();
  }
  
  //delete inpath;
  //delete outpath;
  //delete outform;
  
}
Exemple #17
0
DeviceManager::DeviceError DevicePluginElro::executeAction(Device *device, const Action &action)
{   

    if (action.actionTypeId() != powerActionTypeId)
        return DeviceManager::DeviceErrorActionTypeNotFound;

    QList<int> rawData;
    QByteArray binCode;

    // create the bincode
    // channels
    if (device->paramValue(chan1ParamTypeId).toBool()) {
        binCode.append("00");
    } else {
        binCode.append("01");
    }
    if (device->paramValue(chan2ParamTypeId).toBool()) {
        binCode.append("00");
    } else {
        binCode.append("01");
    }
    if (device->paramValue(chan3ParamTypeId).toBool()) {
        binCode.append("00");
    }else{
        binCode.append("01");
    }
    if(device->paramValue(chan4ParamTypeId).toBool()){
        binCode.append("00");
    } else {
        binCode.append("01");
    }
    if (device->paramValue(chan5ParamTypeId).toBool()) {
        binCode.append("00");
    } else {
        binCode.append("01");
    }

    // Buttons
    if (device->paramValue(aParamTypeId).toBool()) {
        binCode.append("00");
    } else {
        binCode.append("01");
    }
    if (device->paramValue(bParamTypeId).toBool()) {
        binCode.append("00");
    } else {
        binCode.append("01");
    }
    if (device->paramValue(cParamTypeId).toBool()) {
        binCode.append("00");
    } else {
        binCode.append("01");
    }
    if (device->paramValue(dParamTypeId).toBool()) {
        binCode.append("00");
    } else {
        binCode.append("01");
    }
    if (device->paramValue(eParamTypeId).toBool()) {
        binCode.append("00");
    } else {
        binCode.append("01");
    }

    // Power
    if (action.param(powerParamTypeId).value().toBool()) {
        binCode.append("0001");
    } else {
        binCode.append("0100");
    }

    //create rawData timings list
    int delay = 350;

    // sync signal
    rawData.append(1);
    rawData.append(31);

    // add the code
    foreach (QChar c, binCode) {
        if (c == '0') {
            rawData.append(1);
            rawData.append(3);
        } else {
            rawData.append(3);
            rawData.append(1);
        }
    }

    // send data to hardware resource
    if (transmitData(delay, rawData)) {
        qCDebug(dcElro) << "Transmitted" << pluginName() << device->name() << "power: " << action.param(powerParamTypeId).value().toBool();
        return DeviceManager::DeviceErrorNoError;
    } else {
        qCWarning(dcElro) << "Could not transmitt" << pluginName() << device->name() << "power: " << action.param(powerParamTypeId).value().toBool();
        return DeviceManager::DeviceErrorHardwareNotAvailable;
    }
}
Exemple #18
0
//-----------------------------------------------------------------------------
void SplashInstaller::slotSetTheme(int id)
{
  bool enabled;
  QString path = QString();
  QString infoTxt;

  if (id < 0)
  {
    mPreview->setText(QString());
    mText->setText(QString());
    enabled = false;
  }
  else
  {
    QString error = i18n("(Could not load theme)");
    path = mThemesList->item(id)->text();
    if ( mThemesList->text2path.contains( path ) )
        path = mThemesList->text2path[path];
    enabled = false;
    KUrl url;
    QString themeName;
    if (!path.isEmpty())
    {
      // Make sure the correct plugin is installed.
      int i = path.lastIndexOf('/');
      if (i >= 0)
        themeName = path.mid(i+1);
      url.setPath( path + "/Theme.rc" );
      if (!KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0))
      {
        url.setPath( path + "/Theme.RC" );
        if (!KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0))
        {
          url.setPath( path + "/theme.rc" );
          if (!KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0))
            url.setPath( path + '/' + themeName + ".rc" );
        }
      }
      if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0))
      {
        KConfig _cnf(url.path());
	KConfigGroup cnf(&_cnf, QString("KSplash Theme: %1").arg(themeName) );

        // Get theme information.
        infoTxt = "<qt>";
        if ( cnf.hasKey( "Name" ) )
          infoTxt += i18n( "<b>Name:</b> %1", cnf.readEntry( "Name", i18nc( "Unknown name", "Unknown" ) ) ) + "<br />";
        if ( cnf.hasKey( "Description" ) )
          infoTxt += i18n( "<b>Description:</b> %1", cnf.readEntry( "Description", i18nc( "Unknown description", "Unknown" ) ) ) + "<br />";
        if ( cnf.hasKey( "Version" ) )
          infoTxt += i18n( "<b>Version:</b> %1", cnf.readEntry( "Version", i18nc( "Unknown version", "Unknown" ) ) ) + "<br />";
        if ( cnf.hasKey( "Author" ) )
          infoTxt += i18n( "<b>Author:</b> %1", cnf.readEntry( "Author", i18nc( "Unknown author", "Unknown" ) ) ) + "<br />";
        if ( cnf.hasKey( "Homepage" ) )
          infoTxt += i18n( "<b>Homepage:</b> %1", cnf.readEntry( "Homepage", i18nc( "Unknown homepage", "Unknown" ) ) ) + "<br />";
        infoTxt += "</qt>";

        QString pluginName( cnf.readEntry( "Engine", "KSplashX" ).trimmed() );
        if( pluginName == "Simple"
                || pluginName == "None"
                || pluginName == "KSplashX"
                || pluginName == "KSplashQML"
                )
            enabled = true; // these are not plugins
        else if ((KServiceTypeTrader::self()->query("KSplash/Plugin", QString("[X-KSplash-PluginName] == '%1'").arg(pluginName))).isEmpty())
        {
          enabled = false;
          error = i18n("This theme requires the plugin %1 which is not installed.", pluginName);
        }
        else
          enabled = true; // Hooray, there is at least one plugin which can handle this theme.
        mEngineOfSelected = pluginName;
      }
      else
      {
        error = i18n("Could not load theme configuration file.");
      }
    }
    mBtnTest->setEnabled(enabled && themeName != "None" );
    mText->setHtml(infoTxt);
    if (!enabled)
    {
      url.setPath( path + '/' + "Preview.png" );
      if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0))
        mPreview->setPixmap(QPixmap(url.path()));
      else
        mPreview->setText(i18n("(Could not load theme)"));
      KMessageBox::sorry(this, error);
    }
    else
    {
      url.setPath( path + '/' + "Preview.png" );
      if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0))
        mPreview->setPixmap(QPixmap(url.path()));
      else
        mPreview->setText(i18n("No preview available."));
      emit changed(true);
    }
  }
  mBtnRemove->setEnabled( !path.isEmpty() && QFileInfo(path).isWritable());
}
Exemple #19
0
/*! Return a list of \l{DeviceClass}{DeviceClasses} describing all the devices supported by this plugin.
    If a DeviceClass has an invalid parameter it will be ignored.
*/
QList<DeviceClass> DevicePlugin::supportedDevices() const
{
    QList<DeviceClass> deviceClasses;
    foreach (const QJsonValue &vendorJson, m_metaData.value("vendors").toArray()) {
        bool broken = false;
        VendorId vendorId = vendorJson.toObject().value("id").toString();
        foreach (const QJsonValue &deviceClassJson, vendorJson.toObject().value("deviceClasses").toArray()) {
            QJsonObject jo = deviceClassJson.toObject();
            DeviceClass deviceClass(pluginId(), vendorId, jo.value("deviceClassId").toString());
            deviceClass.setName(jo.value("name").toString());
            DeviceClass::CreateMethods createMethods;
            foreach (const QJsonValue &createMethodValue, jo.value("createMethods").toArray()) {
                if (createMethodValue.toString() == "discovery") {
                    createMethods |= DeviceClass::CreateMethodDiscovery;
                } else if (createMethodValue.toString() == "auto") {
                    createMethods |= DeviceClass::CreateMethodAuto;
                } else if (createMethodValue.toString() == "user") {
                    createMethods |= DeviceClass::CreateMethodUser;
                } else {
                    qCWarning(dcDeviceManager) << "Unknown createMehtod" << createMethodValue.toString() <<
                                                  "in deviceClass " << deviceClass.name() << ". Falling back to CreateMethodUser.";
                    createMethods |= DeviceClass::CreateMethodUser;
                }
            }
            deviceClass.setCreateMethods(createMethods);
            deviceClass.setDeviceIcon(loadAndVerifyDeviceIcon(jo.value("deviceIcon").toString()));
            deviceClass.setDiscoveryParamTypes(parseParamTypes(jo.value("discoveryParamTypes").toArray()));

            QString setupMethod = jo.value("setupMethod").toString();
            if (setupMethod == "pushButton") {
                deviceClass.setSetupMethod(DeviceClass::SetupMethodPushButton);
            } else if (setupMethod == "displayPin") {
                deviceClass.setSetupMethod(DeviceClass::SetupMethodDisplayPin);
            } else if (setupMethod == "enterPin") {
                deviceClass.setSetupMethod(DeviceClass::SetupMethodEnterPin);
            } else if (setupMethod == "justAdd") {
                qCWarning(dcDeviceManager) << "Unknown setupMehtod" << setupMethod <<
                                              "in deviceClass " << deviceClass.name() << ". Falling back to SetupMethodJustAdd.";
                deviceClass.setSetupMethod(DeviceClass::SetupMethodJustAdd);
            }
            deviceClass.setPairingInfo(jo.value("pairingInfo").toString());
            deviceClass.setParamTypes(parseParamTypes(jo.value("paramTypes").toArray()));

            QList<DeviceClass::BasicTag> basicTags;
            foreach (const QJsonValue &basicTagJson, jo.value("basicTags").toArray()) {
                basicTags.append(loadAndVerifyBasicTag(basicTagJson.toString()));
            }
            deviceClass.setBasicTags(basicTags);

            QList<ActionType> actionTypes;
            QList<StateType> stateTypes;
            foreach (const QJsonValue &stateTypesJson, jo.value("stateTypes").toArray()) {
                QJsonObject st = stateTypesJson.toObject();
                QStringList missingFields = verifyFields(QStringList() << "type" << "id" << "name", st);
                if (!missingFields.isEmpty()) {
                    qCWarning(dcDeviceManager) << "Skipping device class" << deviceClass.name() << "because of missing" << missingFields.join(", ") << "in stateTypes";
                    broken = true;
                    break;
                }

                QVariant::Type t = QVariant::nameToType(st.value("type").toString().toLatin1().data());
                StateType stateType(st.value("id").toString());
                stateType.setName(st.value("name").toString());
                stateType.setType(t);
                stateType.setUnit(loadAndVerifyUnit(st.value("unit").toString()));
                stateType.setDefaultValue(st.value("defaultValue").toVariant());
                if (st.contains("minValue"))
                    stateType.setMinValue(st.value("minValue").toVariant());

                if (st.contains("maxValue"))
                    stateType.setMaxValue(st.value("maxValue").toVariant());

                if (st.contains("possibleValues")) {
                    QVariantList possibleValues;
                    foreach (const QJsonValue &possibleValueJson, st.value("possibleValues").toArray()) {
                        possibleValues.append(possibleValueJson.toVariant());
                    }
                    stateType.setPossibleValues(possibleValues);

                    // inform the plugin developer about the error in the plugin json file
                    Q_ASSERT_X(stateType.possibleValues().contains(stateType.defaultValue()),
                               QString("\"%1\" plugin").arg(pluginName()).toLatin1().data(),
                               QString("The given default value \"%1\" is not in the possible values of the stateType \"%2\".")
                               .arg(stateType.defaultValue().toString()).arg(stateType.name()).toLatin1().data());

                }
                stateTypes.append(stateType);

                // create ActionType if this StateType is writable
                if (st.contains("writable") && st.value("writable").toBool()) {
                    // Note: fields already checked in StateType
                    ActionType actionType(ActionTypeId(stateType.id().toString()));
                    actionType.setName("set " + stateType.name());
                    ParamType paramType(stateType.name(), t, stateType.defaultValue());
                    paramType.setAllowedValues(stateType.possibleValues());
                    paramType.setUnit(stateType.unit());
                    paramType.setLimits(stateType.minValue(), stateType.maxValue());
                    actionType.setParamTypes(QList<ParamType>() << paramType);
                    actionTypes.append(actionType);
                }
            }
            deviceClass.setStateTypes(stateTypes);

            foreach (const QJsonValue &actionTypesJson, jo.value("actionTypes").toArray()) {
                QJsonObject at = actionTypesJson.toObject();
                QStringList missingFields = verifyFields(QStringList() << "id" << "name", at);
                if (!missingFields.isEmpty()) {
                    qCWarning(dcDeviceManager) << "Skipping device class" << deviceClass.name() << "because of missing" << missingFields.join(", ") << "in actionTypes";
                    broken = true;
                    break;
                }

                ActionType actionType(at.value("id").toString());
                actionType.setName(at.value("name").toString());
                actionType.setParamTypes(parseParamTypes(at.value("paramTypes").toArray()));
                actionTypes.append(actionType);
            }
            deviceClass.setActionTypes(actionTypes);

            QList<EventType> eventTypes;
            foreach (const QJsonValue &eventTypesJson, jo.value("eventTypes").toArray()) {
                QJsonObject et = eventTypesJson.toObject();
                QStringList missingFields = verifyFields(QStringList() << "id" << "name", et);
                if (!missingFields.isEmpty()) {
                    qCWarning(dcDeviceManager) << "Skipping device class" << deviceClass.name() << "because of missing" << missingFields.join(", ") << "in eventTypes";
                    broken = true;
                    break;
                }

                EventType eventType(et.value("id").toString());
                eventType.setName(et.value("name").toString());
                eventType.setParamTypes(parseParamTypes(et.value("paramTypes").toArray()));
                eventTypes.append(eventType);
            }
            deviceClass.setEventTypes(eventTypes);

            if (!broken)
                deviceClasses.append(deviceClass);

        }
    }
void DevicePluginIntertechno::radioData(const QList<int> &rawData)
{


    // filter right here a wrong signal length
    if(rawData.length() != 49){
        return;
    }
    
    QList<Device*> deviceList = deviceManager()->findConfiguredDevices(intertechnoRemote);
    if(deviceList.isEmpty()){
        return;
    }

    int delay = rawData.first()/31;
    QByteArray binCode;
    
    // =======================================
    // average 314
    if(delay > 300 && delay < 400){
        // go trough all 48 timings (without sync signal)
        for(int i = 1; i <= 48; i+=2 ){
            int div;
            int divNext;
            
            // if short
            if(rawData.at(i) <= 700){
                div = 1;
            }else{
                div = 3;
            }
            // if long
            if(rawData.at(i+1) < 700){
                divNext = 1;
            }else{
                divNext = 3;
            }
            
            //              _
            // if we have  | |___ = 0 -> in 4 delays => 1000
            //                 _
            // if we have  ___| | = 1 -> in 4 delays => 0001
            
            if(div == 1 && divNext == 3){
                binCode.append('0');
            }else if(div == 3 && divNext == 1){
                binCode.append('1');
            }else{
                return;
            }
        }
    }else{
        return;
    }

    // =======================================
    // Check nibble 16-19, must be 0001
    if(binCode.mid(16,4) != "0001"){
        return;
    }

    // =======================================
    // Get family code
    QString familyCode;
    bool ok;
    QByteArray familyCodeBin = binCode.left(8);
    int famiyCodeInt = familyCodeBin.toInt(&ok,2);

    if(!ok){
        return;
    }

    switch (famiyCodeInt) {
    case 0b00000000:
        familyCode = "A";
        break;
    case 0b01000000:
        familyCode = "B";
        break;
    case 0b00010000:
        familyCode = "C";
        break;
    case 0b01010000:
        familyCode = "D";
        break;
    case 0b00000100:
        familyCode = "E";
        break;
    case 0b01000100:
        familyCode = "F";
        break;
    case 0b00010100:
        familyCode = "G";
        break;
    case 0b01010100:
        familyCode = "H";
        break;
    case 0b00000001:
        familyCode = "I";
        break;
    case 0b01000001:
        familyCode = "J";
        break;
    case 0b00010001:
        familyCode = "K";
        break;
    case 0b01010001:
        familyCode = "L";
        break;
    case 0b00000101:
        familyCode = "M";
        break;
    case 0b01000101:
        familyCode = "N";
        break;
    case 0b00010101:
        familyCode = "O";
        break;
    case 0b01010101:
        familyCode = "P";
        break;
    default:
        return;
    }

    // =======================================
    // Get button code
    QString buttonCode;
    QByteArray buttonCodeBin = binCode.mid(8,8);
    int buttonCodeInt = buttonCodeBin.toInt(&ok,2);

    if(!ok){
        return;
    }

    switch (buttonCodeInt) {
    case 0b00000000:
        buttonCode = "1";
        break;
    case 0b01000000:
        buttonCode = "2";
        break;
    case 0b00010000:
        buttonCode = "3";
        break;
    case 0b01010000:
        buttonCode = "4";
        break;
    case 0b00000100:
        buttonCode = "5";
        break;
    case 0b01000100:
        buttonCode = "6";
        break;
    case 0b00010100:
        buttonCode = "7";
        break;
    case 0b01010100:
        buttonCode = "8";
        break;
    case 0b00000001:
        buttonCode = "9";
        break;
    case 0b01000001:
        buttonCode = "10";
        break;
    case 0b00010001:
        buttonCode = "11";
        break;
    case 0b01010001:
        buttonCode = "12";
        break;
    case 0b00000101:
        buttonCode = "13";
        break;
    case 0b01000101:
        buttonCode = "14";
        break;
    case 0b00010101:
        buttonCode = "15";
        break;
    case 0b01010101:
        buttonCode = "16";
        break;
    default:
        return;
    }

    // =======================================
    // get power status -> On = 0100, Off = 0001
    bool power;
    if(binCode.right(4).toInt(0,2) == 5){
        power = true;
    }else if(binCode.right(4).toInt(0,2) == 4){
        power = false;
    }else{
        return;
    }

    qDebug() << "family code = " << familyCode << "button code =" << buttonCode << power;

    // ===================================================
    Device *device = 0;
    foreach (Device *dev, deviceList) {
        if (dev->paramValue("familyCode").toString() == familyCode) {
            // Yippie! We found the device.
            device = dev;
            break;
        }
    }
    if (!device) {
        qWarning() << "couldn't find any configured device for intertech familyCode:" << familyCode;
        return;
    }

    ParamList params;
    Param powerParam("power", power);
    params.append(powerParam);

    // FIXME: find a better way to get to the remote DeviceClass
    DeviceClass deviceClass = supportedDevices().first();
    foreach (const EventType &eventType, deviceClass.eventTypes()) {
        if (eventType.name() == buttonCode) {
            qDebug() << "emit event " << pluginName() << familyCode << eventType.name() << power;
            Event event = Event(eventType.id(), device->id(), params);
            emit emitEvent(event);
            return;
        }
    }
}
DeviceManager::DeviceError DevicePluginIntertechno::executeAction(Device *device, const Action &action)
{

    QList<int> rawData;
    QByteArray binCode;

    QString familyCode = device->paramValue("familyCode").toString();

    // =======================================
    // generate bin from family code
    if(familyCode == "A"){
        binCode.append("00000000");
    }else if(familyCode == "B"){
        binCode.append("01000000");
    }else if(familyCode == "C"){
        binCode.append("00010000");
    }else if(familyCode == "D"){
        binCode.append("01010000");
    }else if(familyCode == "E"){
        binCode.append("00000100");
    }else if(familyCode == "F"){
        binCode.append("01000100");
    }else if(familyCode == "G"){
        binCode.append("01000000");
    }else if(familyCode == "H"){
        binCode.append("01010100");
    }else if(familyCode == "I"){
        binCode.append("00000001");
    }else if(familyCode == "J"){
        binCode.append("01000001");
    }else if(familyCode == "K"){
        binCode.append("00010001");
    }else if(familyCode == "L"){
        binCode.append("01010001");
    }else if(familyCode == "M"){
        binCode.append("00000101");
    }else if(familyCode == "N"){
        binCode.append("01000101");
    }else if(familyCode == "O"){
        binCode.append("00010101");
    }else if(familyCode == "P"){
        binCode.append("01010101");
    }else{
        return DeviceManager::DeviceErrorNoError;
    }

    QString buttonCode = device->paramValue("buttonCode").toString();

    // =======================================
    // generate bin from button code
    if(familyCode == "1"){
        binCode.append("00000000");
    }else if(familyCode == "2"){
        binCode.append("01000000");
    }else if(familyCode == "3"){
        binCode.append("00010000");
    }else if(familyCode == "4"){
        binCode.append("01010000");
    }else if(familyCode == "5"){
        binCode.append("00000100");
    }else if(familyCode == "6"){
        binCode.append("01000100");
    }else if(familyCode == "7"){
        binCode.append("01000000");
    }else if(familyCode == "8"){
        binCode.append("01010100");
    }else if(familyCode == "9"){
        binCode.append("00000001");
    }else if(familyCode == "10"){
        binCode.append("01000001");
    }else if(familyCode == "11"){
        binCode.append("00010001");
    }else if(familyCode == "12"){
        binCode.append("01010001");
    }else if(familyCode == "13"){
        binCode.append("00000101");
    }else if(familyCode == "14"){
        binCode.append("01000101");
    }else if(familyCode == "15"){
        binCode.append("00010101");
    }else if(familyCode == "16"){
        binCode.append("01010101");
    }else{
        return DeviceManager::DeviceErrorNoError;
    }

    // =======================================
    // add fix nibble (0F)
    binCode.append("0001");

    // =======================================
    // add power nibble
    if(action.param("power").value().toBool()){
        binCode.append("0101");
    }else{
        binCode.append("0100");
    }
    //qDebug() << "bin code:" << binCode;

    // =======================================
    //create rawData timings list
    int delay = 350;

    // sync signal
    rawData.append(1);
    rawData.append(31);

    // add the code
    foreach (QChar c, binCode) {
        if(c == '0'){
            rawData.append(1);
            rawData.append(3);
        }else{
            rawData.append(3);
            rawData.append(1);
        }
    }

    // =======================================
    // send data to hardware resource
    if(transmitData(delay, rawData)){
        qDebug() << "transmitted" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
        return DeviceManager::DeviceErrorNoError;
    }else{
        qWarning() << "ERROR: could not transmitt" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
        return DeviceManager::DeviceErrorHardwareNotAvailable;
    }
}
Exemple #22
0
ZConfDlg::ZConfDlg(QWidget *parent, const char *name,
		   bool modal, WFlags f)
    : QDialog(parent, name, modal, f) 
{
    char *pEnvVarVal;
    int retval;
    char optVal[256];

    origConfigHasPass = FALSE;

    // First things first, I want this dialog to be modal (not allow access to
    // the windows below it once it has been opened).
    setModal(TRUE);
    setCaption(tr("Configuration"));

    // Now that I have setup the dialog the way I wanted, I create a grid
    // layout so that I can organize widgets in the dialog easily.
    pZConfDlgLayout = new QGridLayout(this, 1, 1, 11, 6, "ZConfDlgLayout");

    // In this section I create the Zaurus IP entry area and its label.
    QLabel *pZIpLabel = new QLabel(this, "ZIpLabel");
    pZIpLabel->setAlignment(int(QLabel::AlignVCenter));
    pZIpLabel->setText(tr("Zaurus IP:"));
    pZConfDlgLayout->addWidget(pZIpLabel, 0, 0);

    pZIpLineEdit = new QLineEdit(this, "ZIpLineEdit");
    pZIpLineEdit->setMaxLength(15);
    pZConfDlgLayout->addMultiCellWidget(pZIpLineEdit, 0, 0, 1, 2);

    // In this section I create the Conflict Winner label and combo box.
    QLabel *pConfWinLabel = new QLabel(this, "ConfWinLabel");
    pConfWinLabel->setAlignment(int(QLabel::AlignVCenter));
    pConfWinLabel->setText(tr("Conflict Winner:"));
    pZConfDlgLayout->addWidget(pConfWinLabel, 1, 0);

    pConfWinComboBox = new QComboBox(FALSE, this, "ConfWinComboBox");
    pZConfDlgLayout->addMultiCellWidget(pConfWinComboBox, 1, 1, 1, 2);
    pConfWinComboBox->clear();
    pConfWinComboBox->insertItem(tr("Both"));
    pConfWinComboBox->insertItem(tr("Zaurus"));
    pConfWinComboBox->insertItem(tr("Desktop"));

    // In this section I create the Save Password check box and the password
    // entry field.
    pPasswdCheckBox = new QCheckBox(this, "PasswdCheckBox");
    pPasswdCheckBox->setEnabled(TRUE);
    pPasswdCheckBox->setText(tr("Save Passcode:"));
    pZConfDlgLayout->addMultiCellWidget(pPasswdCheckBox, 2, 2, 0, 1);

    pPasswdLineEdit = new QLineEdit(this, "PasswdLineEdit");
    pPasswdLineEdit->setEnabled(FALSE);
    pPasswdLineEdit->setEchoMode(QLineEdit::Password);
    pZConfDlgLayout->addWidget(pPasswdLineEdit, 2, 2);

    // In this section I create the Apply and Cancel buttons.
    pApplyButton = new QPushButton(this, "ApplyButton");
    pApplyButton->setText(tr("Apply"));
    pZConfDlgLayout->addWidget(pApplyButton, 0, 3);
    pCancelButton = new QPushButton(this, "CancelButton");
    pCancelButton->setText(tr("Cancel"));
    pZConfDlgLayout->addWidget(pCancelButton, 1, 3);

    // In this section I create the Plug-in Group box to house the tabbed
    // plug-in selection widgets.
    pPluginGroupBox = new QGroupBox(this, "PluginGroupBox");
    pPluginGroupBox->setFrameShape(QGroupBox::Box);
    pPluginGroupBox->setFrameShadow(QGroupBox::Sunken);
    pPluginGroupBox->setAlignment(int(QGroupBox::AlignHCenter));
    pPluginGroupBox->setFlat(TRUE);
    pPluginGroupBox->setTitle(tr("Desktop Plug-in Selections"));
    pZConfDlgLayout->addMultiCellWidget(pPluginGroupBox, 3, 3, 0, 3);

    // In this section I fill the Plug-in Group box I just created with a
    // tabbed widet which will provide a mechanism for selecting plugins.
    pPluginTabWidget = new QTabWidget(pPluginGroupBox, "PluginTabWidget");
    pPluginTabWidget->setGeometry(QRect(0, 20, 370, 160));

    // In this section I create the Todo Tab for the tabbed widget and fill it
    // with the proper widgets.
    pTodoTab = new QWidget(pPluginTabWidget, "TodoTab");
    pPluginTabWidget->insertTab(pTodoTab, "To-Do");

    pTodoPluginComboBox = new QComboBox(FALSE, pTodoTab, "TodoPluginComboBox");
    pTodoPluginComboBox->setGeometry(QRect(10, 10, 340, 30));

    pTodoPluginDesc = new QTextEdit(pTodoTab, "TodoPluginDesc");
    pTodoPluginDesc->setGeometry(QRect(10, 50, 340, 70));
    pTodoPluginDesc->setReadOnly(TRUE);

    printf("created todo plugin desc box.\n");

    // The segfault occurs when I do this section!!!!!!!!!
    todoPluginPath = QString("/usr/local/lib/zync/plugins/todo/");
    QDir todoPluginDir(todoPluginPath);
    QStringList todoPlugins;
    todoPlugins = todoPluginDir.entryList("*.so");

    for (QStringList::Iterator it = todoPlugins.begin();
        it != todoPlugins.end(); ++it) {
        QString fooBar((*it));
        // The following either two lines cause a segfault.
        QString pluginName(GetTodoPluginName(todoPluginPath + (*it)));
        //QString pluginDesc(GetTodoPluginDesc(todoPluginPath + (*it)));
        printf("Testing: %s.\n", fooBar.ascii());
        printf("Testing: %s.\n", pluginName.ascii());
        pTodoPluginComboBox->insertItem(tr(fooBar));
    }

    
    /*
    for (QStringList::Iterator it = todoPlugins.begin();
	    it != todoPlugins.end(); ++it) {
    	QString pluginName(GetTodoPluginName(todoPluginPath + (*it)));
    	QString pluginDesc(GetTodoPluginDesc(todoPluginPath + (*it)));
    	todoPluginMap[pluginName] = (*it);
    	pTodoPluginComboBox->insertItem(tr(pluginName));
    }
    */

    /*

    printf("filled in the todo plugin info.\n");

    // In this section I create the Calendar Tab for the tabbed widget and
    // fill it with the proper widgets.
    pCalTab = new QWidget(pPluginTabWidget, "CalTab");
    pPluginTabWidget->insertTab(pCalTab, "Calendar");

    pCalPluginComboBox = new QComboBox(FALSE, pCalTab, "CalPluginComboBox");
    pCalPluginComboBox->setGeometry(QRect(10, 10, 340, 30));

    pCalPluginDesc = new QTextEdit(pCalTab, "CalPluginDesc");
    pCalPluginDesc->setGeometry(QRect(10, 50, 340, 70));
    pCalPluginDesc->setReadOnly(TRUE);

    // In this section I create the Address Boox Tab for the tabbed widget and
    // fill it with the proper widgets.
    pAddrTab = new QWidget(pPluginTabWidget, "AddrTab");
    pPluginTabWidget->insertTab(pAddrTab, "Address Book");

    pAddrPluginComboBox = new QComboBox(FALSE, pAddrTab, "AddrPluginComboBox");
    pAddrPluginComboBox->setGeometry(QRect(10, 10, 340, 30));

    pAddrPluginDesc = new QTextEdit(pAddrTab, "AddrPluginDesc");
    pAddrPluginDesc->setGeometry(QRect(10, 50, 340, 70));
    pAddrPluginDesc->setReadOnly(TRUE);

    printf("Created addr plugin desc box.\n");

    // Here I resize the dialog to a size which I like.
    //resize(QSize(391, 301).expandedTo(minimumSizeHint()));

    // Now I start to set the connections between the signals and the slots.

    // This first connection connects the save passcode check box to the
    // enable/disable feature of the passcode line edit.
    connect(pPasswdCheckBox, SIGNAL(toggled(bool)), pPasswdLineEdit,
	    SLOT(setEnabled(bool)));

    connect(pCancelButton, SIGNAL(clicked()), this, SLOT(reject()));

    connect(pTodoPluginComboBox, SIGNAL(activated(const QString &)), this,
	    SLOT(updatePluginDesc(const QString &)));

    connect(pApplyButton, SIGNAL(clicked()), this, SLOT(saveConfig()));
    //connect(this, SIGNAL(configUpdated()), this, SLOT(accept()));

    // Here I try to obtain in the needed config content and set the values of
    // the proper widgets based on it.
    pEnvVarVal = getenv("HOME");
    if (!pEnvVarVal) {
	    QMessageBox::critical(0, "zync-gui", QString("Failed to obtain") +
			      " value of HOME environment variable.");
    }

    confPath = QString(pEnvVarVal);
    confPath.append("/.zync.conf");

    printf("Created the zync.conf path.\n");

    // At this point the full path to the config for the user which is running
    // this application has been built. Hence, I try and load the config file.
    retval = confManager.Open((char *)confPath.ascii());
    printf("Finished opening the file, %d.\n", retval);
    if (retval != 0) {
        printf("Err: Failed to open %s for reading.\n",
            (char *)confPath.ascii());
            */
            /*
	    QMessageBox::critical(0, "zync-gui", QString("Failed to open ") +
			      confPath + " for reading. Please click the" + 
			      " \"Configure\" button and configure zync.");
                  */
                  /*
    }

    printf("Opened the zync.conf file.\n");

    // Now that I have opened the config file I want to go through and set all
    // the widget values based on the config options.
    retval = confManager.GetValue("zaurus_ip", optVal, 256);
    if (retval == 0) {
	    QString zIp(optVal);
	    pZIpLineEdit->setText(tr(zIp));
    }

    retval = confManager.GetValue("conflict_winner", optVal, 256);
    if (retval == 0) {
	    QString confWinner(optVal);
    	if (confWinner == QString("both")) {
	        pConfWinComboBox->setCurrentText("Both");
	    } else if (confWinner == QString("zaurus")) {
	        pConfWinComboBox->setCurrentText("Zaurus");
	    } else if (confWinner == QString("desktop")) {
	        pConfWinComboBox->setCurrentText("Desktop");
	    }
    }

    retval = confManager.GetValue("passcode", optVal, 256);
    if (retval == 0) {
	    QString passcode(optVal);
	    pPasswdCheckBox->setChecked(TRUE);
	    pPasswdLineEdit->setText(passcode);
	    origConfigHasPass = TRUE;
    }

    retval = confManager.GetValue("todo_plugin_path", optVal, 256);
    if (retval == 0) {
	if (!todoPlugins.isEmpty()) {
	    QString todoPluginPath(optVal);
	    QString confTodoPluginName = GetTodoPluginName(todoPluginPath);
	    pTodoPluginComboBox->setCurrentText(confTodoPluginName);
	}
    }

    // Now I need to load the Descriptions for the plugin selections and set
    // them.
    if (!todoPlugins.isEmpty()) {
	    QString curPluginDesc;
	    QString curPluginFileName;
	    curPluginFileName = todoPluginMap[pTodoPluginComboBox->currentText()];
	    curPluginDesc = GetTodoPluginDesc(todoPluginPath + curPluginFileName);
	    pTodoPluginDesc->setText(curPluginDesc);
    } else {
	    pTodoPluginDesc->setText(tr("No Plugins Found!"));
    }
    */
    printf("Finished ZConfDlg Constructor.\n");
}
QString ComicProviderKross::identifier() const
{
    return pluginName() + QLatin1Char(':') + identifierToString(m_wrapper.identifierVariant());
}
QSharedPointer<PluginOptions> CustomWidgetPluginWizardPage::basicPluginOptions() const
{
    QSharedPointer<PluginOptions> po(new PluginOptions);
    po->pluginName = pluginName();
    po->resourceFile = m_ui->resourceFileEdit->text();
    po->collectionClassName = collectionClassName();
    po->collectionHeaderFile = m_ui->collectionHeaderEdit->text();
    po->collectionSourceFile = m_ui->collectionSourceEdit->text();
    return po;
}