コード例 #1
0
ファイル: haitzza_tfidf.cpp プロジェクト: haitzza/classwork
int main(int argc, char* argv[]) {
    std::string searchFile(argv[2]);
    uint topN(std::stoi(argv[3]));
    std::ifstream corpus(argv[1]);
    std::istream_iterator<std::string> corpus_it(corpus), eof;
    std::vector<std::string> fileList(corpus_it, eof);
    strIntMap corpusMap, documentMap;
    std::cout << "Loading corpus using files listed in " << argv[1]
              << std::endl;
    loadCorpusAndSearchFiles(corpusMap, documentMap, searchFile, fileList);
    std::cout << "Loaded corpus of " << corpusMap.size() << " words from "
              << fileList.size() << " file(s)" << std::endl
              << "------[ Starting analysis ]------" << std::endl << "Top "
              << topN << " significant words..." << std::endl;
    std::set<tfidfPair> result;
    getTopN(topN, fileList.size(), result, documentMap, corpusMap);
    printTopN(result);
    std::cout << "Lines with 1 or more significant words:" << std::endl;
    countSigWords(searchFile, result);
    return 0;
}
コード例 #2
0
ファイル: application.cpp プロジェクト: zhivko/SmingRTOS
void ShowInfo() {
	Serial.printf("\r\nSDK: v%s\r\n", system_get_sdk_version());
	Serial.printf("Free Heap: %d\r\n", system_get_free_heap_size());
	Serial.printf("CPU Frequency: %d MHz\r\n", system_get_cpu_freq());
	Serial.printf("System Chip ID: %x\r\n", system_get_chip_id());
	Serial.printf("SPI Flash ID: %x\r\n", spi_flash_get_id());
	//Serial.printf("SPI Flash Size: %d\r\n", (1 << ((spi_flash_get_id() >> 16) & 0xff)));

	Vector<String> files = fileList();
	if (files.count() > 0) {
		Serial.println("\n\rSpiff files:");
		Serial.println("----------------------------");
		{
			for (int i = 0; i < files.count(); i++) {
				Serial.println(files[i]);
			}
		}
		Serial.println("----------------------------");
	} else {
		Serial.println("Empty spiffs!");
	}

}
コード例 #3
0
bool FileSystem::CopyDirectory(const String & sourceDirectory, const String & destinationDirectory)
{
	bool ret = true;

	FileList fileList(sourceDirectory);
	int32 count = fileList.GetCount();
	String fileOnly;
	String pathOnly;
	for(int32 i = 0; i < count; ++i)
	{
		if(!fileList.IsDirectory(i) && !fileList.IsNavigationDirectory(i))
		{
			const String & pathName = fileList.GetPathname(i);
			FileSystem::SplitPath(pathName, pathOnly, fileOnly);
			if(!CopyFile(pathName, destinationDirectory+"/"+fileOnly))
			{
				ret = false;
			}
		}
	}

	return ret;
}
コード例 #4
0
void
CBSearchTextDialog::SearchFilesAndReplace()
{
	JString searchStr, replaceStr;
	JBoolean searchIsRegex, caseSensitive, entireWord, wrapSearch;
	JBoolean replaceIsRegex, preserveCase;
	JRegex* regex;

	JPtrArray<JString> fileList(JPtrArrayT::kDeleteAll),
					   nameList(JPtrArrayT::kDeleteAll);

	if (GetSearchParameters(
			&searchStr, &searchIsRegex, &caseSensitive, &entireWord, &wrapSearch,
			&replaceStr, &replaceIsRegex, &preserveCase,
			&regex) &&
		BuildSearchFileList(&fileList, &nameList))
		{
		const JError err =
			CBSearchDocument::Create(fileList, nameList,
									 searchStr, replaceStr);
		err.ReportIfError();
		}
}
コード例 #5
0
ファイル: qgswfsutils.cpp プロジェクト: wongjimsan/QGIS
void QgsWFSUtils::releaseCacheDirectory()
{
  QMutexLocker locker( &sMutex );
  sCounter --;
  if ( sCounter == 0 )
  {
    if ( sThread )
    {
      sThread->exit();
      sThread->wait();
      delete sThread;
      sThread = nullptr;
    }

    // Destroys our cache directory, and the main cache directory if it is empty
    QString tmpDirname( getCacheDirectory( false ) );
    if ( QDir( tmpDirname ).exists() )
    {
      QgsDebugMsg( QString( "Removing our cache dir %1" ).arg( tmpDirname ) );
      removeDir( tmpDirname );

      QString baseDirname( getBaseCacheDirectory( false ) );
      QDir baseDir( baseDirname );
      QFileInfoList fileList( baseDir.entryInfoList( QDir::NoDotAndDotDot | QDir::AllDirs | QDir::Files ) );
      if ( fileList.size() == 0 )
      {
        QgsDebugMsg( QString( "Removing main cache dir %1" ).arg( baseDirname ) );
        removeDir( baseDirname );
      }
      else
      {
        QgsDebugMsg( QString( "%1 entries remaining in %2" ).arg( fileList.size() ).arg( baseDirname ) );
      }
    }
  }
}
コード例 #6
0
void SurfaceAnimatorDialog::computeMultiGridAnimation()
{
    QListWidget* fileList(m_dialog.fileList);
    m_referenceFrames = fileList->count();
    if (m_referenceFrames < 2) return;

    int interpolationFrames(m_dialog.interpolationFrames->value());
    double isovalue(m_dialog.isovalue->value());
    double delta = 1.0/interpolationFrames;

    QListWidgetItem* item(fileList->item(0));
    Layer::CubeData* cube(QVariantPointer<Layer::CubeData>::toPointer(item->data(Qt::UserRole)));

    Grid* A(cube->grid());
    Grid* B(0);

    Grid::Size size(A->size());
    Grid::DataType dataType(Grid::DataType::CubeData);
    Grid  dAB(dataType, size);
    Grid  t(dataType, size);

    Animator::Combo::DataList frames;
    Layer::Surface* surface;

    QString label;

    int totalSurfaces((m_referenceFrames-1)*interpolationFrames);
    QProgressDialog progressDialog("Calculating surfaces", "Cancel", 0,
                                   totalSurfaces, this);
    progressDialog.setWindowModality(Qt::WindowModal);

    int totalProgress(0);
    progressDialog.setValue(totalProgress);

    // loop over grids
    for (int i = 1; i < m_referenceFrames; ++i) {
        if (progressDialog.wasCanceled()) return;

        Data::Geometry const& geomA(cube->geometry());
        item = fileList->item(i);
        cube = QVariantPointer<Layer::CubeData>::toPointer(item->data(Qt::UserRole));
        Data::Geometry const& geomB(cube->geometry());

//qDebug() << "first geom";
//geomA.dump();
//qDebug() << "second geom";
//geomB.dump();

        // Geometry displacements
        QList<Vec> displacements;
        for (int a = 0; a < geomA.nAtoms(); ++a) {
            Vec d(geomB.position(a)-geomA.position(a));
            displacements.append(d);
        }

        // Grid displacements
        B    = cube->grid();
        t    = (*A);
        dAB  = (*B);
        dAB -= t;

        surface = calculateSurface(&dAB, isovalue);
        surface->setText("Difference Surface");
        cube->appendLayer(surface);

        dAB *= delta;

        // loop over interpolation Frames
        for (int j = 0; j < interpolationFrames; ++j) {
            Data::Geometry geomT;
            for (int a = 0; a < geomA.nAtoms(); ++a) {
                double step = (double)j/(double)interpolationFrames;
                Vec d(geomA.position(a) + step*displacements[a]);
                geomT.append(geomA.atomicNumber(a), d);
            }

            surface = calculateSurface(&t, isovalue);
            frames.append(new Animator::Combo::Data(geomT, surface));
            label = (j == 0) ? "Cube Data " + QString::number(i)
                    : "Interpolation Frame " + QString::number(j);
            surface->setText(label);
            cube->appendLayer(surface);

            ++totalProgress;
            progressDialog.setValue(totalProgress);
            if (progressDialog.wasCanceled()) return;

            t += dAB;  // increment the interpolation grid
        }
        A = B;
    }

    // Take care of the final reference frame
    surface = calculateSurface(B, isovalue);
    surface->setText("Cube Data " + QString::number(m_referenceFrames));
    cube->appendLayer(surface);

    frames.append(new Animator::Combo::Data(cube->geometry(), surface));
    m_animator = new Animator::Combo(m_molecule, frames, interpolationFrames, m_speed);
    connect(m_animator, SIGNAL(finished()), this, SLOT(animationStopped()));
    m_dialog.playbackBox->setEnabled(true);
}
コード例 #7
0
ファイル: maintenance.cpp プロジェクト: Weanuts/ersky9x
void menuUp1(uint8_t event)
{
	FRESULT fr ;
	struct fileControl *fc = &FileControl ;
  static uint8_t mounted = 0 ;
	static uint32_t state ;
	static uint32_t firmwareAddress ;
	uint32_t i ;
	uint32_t width ;
	 
	if (UpdateItem == UPDATE_TYPE_BOOTLOADER )		// Bootloader
	{
  	TITLE( "UPDATE BOOT" ) ;
	}
	else
	{
#ifdef PCBX9D
		if (UpdateItem == UPDATE_TYPE_SPORT_INT )
		{
  		TITLE( "UPDATE Int. XJT" ) ;
		}
		else
		{
  		TITLE( "UPDATE Ext. SPort" ) ;
		}
#endif

#ifdef PCBSKY
 #ifndef REVX
 		if (UpdateItem == UPDATE_TYPE_COPROCESSOR )
		{
  		TITLE( "UPDATE COPROC" ) ;
		}
		else
		{
  		TITLE( "UPDATE SPort" ) ;
		}
 #else
 		if (UpdateItem == UPDATE_TYPE_SPORT_EXT )
		{
  		TITLE( "UPDATE SPort" ) ;
		}
 #endif
#endif
	}
	switch(event)
	{
    case EVT_ENTRY:
			state = UPDATE_NO_FILES ;
			if ( mounted == 0 )
			{
#if defined(PCBTARANIS)
  			fr = f_mount(0, &g_FATFS_Obj) ;
#else				
  			fr = f_mount(0, &g_FATFS) ;
#endif
#ifdef PCBX9D
				unlockFlash() ;
#endif
			}
			else
			{
				fr = FR_OK ;
			}
			if ( fr == FR_OK)
			{
				mounted = 1 ;
			}
			if ( mounted )
			{
				fr = f_chdir( (TCHAR *)"\\firmware" ) ;
				if ( fr == FR_OK )
				{
					state = UPDATE_NO_FILES ;
					fc->index = 0 ;
					fr = f_opendir( &Dj, (TCHAR *) "." ) ;
					if ( fr == FR_OK )
					{
 						if ( (UpdateItem > 1 ) )
						{
							fc->ext[0] = 'F' ;
							fc->ext[1] = 'R' ;
							fc->ext[2] = 'K' ;
						}
						else
						{
							fc->ext[0] = 'B' ;
							fc->ext[1] = 'I' ;
							fc->ext[2] = 'N' ;
						}
						fc->ext[3] = 0 ;
						fc->index = 0 ;
						fc->nameCount = fillNames( 0, fc ) ;
						fc->hpos = 0 ;
						fc->vpos = 0 ;
						if ( fc->nameCount )
						{
							state = UPDATE_FILE_LIST ;
						}
					}
				}
			}
    break ;
    
		case EVT_KEY_FIRST(KEY_EXIT):
			if ( state < UPDATE_ACTION )
			{
      	chainMenu(menuUpdate) ;
    		killEvents(event) ;
			}
    break ;
	}

	switch ( state )
	{
		case UPDATE_NO_FILES :
			lcd_puts_Pleft( 4*FH, "\005No Files" ) ;
	    lcd_outdez( 21*FW, 4*FH, mounted ) ;
    break ;
		
		case UPDATE_FILE_LIST :
			SportVerValid = 0 ;
			if ( fileList( event, &FileControl ) == 1 )
			{
				state = UPDATE_CONFIRM ;
			}
    break ;
		case UPDATE_CONFIRM :
 			if ( (UpdateItem > UPDATE_TYPE_BOOTLOADER ) )
			{
#ifdef PCBX9D
 				if ( (UpdateItem == UPDATE_TYPE_SPORT_INT ) )
				{
					lcd_puts_Pleft( 2*FH, "Flash Int. XJT from" ) ;
				}
				else
				{
					lcd_puts_Pleft( 2*FH, "Flash Ext.SP from" ) ;
				}
				SportVerValid = 0 ;
#else
 #ifndef REVX
 				if ( (UpdateItem == UPDATE_TYPE_COPROCESSOR ) )
				{
					lcd_puts_Pleft( 2*FH, "Flash Co-Proc. from" ) ;
				}
				else
				{
					lcd_puts_Pleft( 2*FH, "Flash SPort from" ) ;
				}
				CoProcReady = 0 ;
 #else
				lcd_puts_Pleft( 2*FH, "Flash SPort from" ) ;
 #endif
#endif
			}
			else
			{
				lcd_puts_Pleft( 2*FH, "Flash Bootloader from" ) ;
			}
			cpystr( cpystr( (uint8_t *)FlashFilename, (uint8_t *)"\\firmware\\" ), (uint8_t *)Filenames[fc->vpos] ) ;
#if defined(PCBTARANIS)
			lcd_putsnAtt( 0, 4*FH, Filenames[fc->vpos], DISPLAY_CHAR_WIDTH, 0 ) ;
#else
			lcd_putsnAtt0( 0, 4*FH, Filenames[fc->vpos], DISPLAY_CHAR_WIDTH, 0 ) ;
#endif
			if ( event == EVT_KEY_LONG(KEY_MENU) )
			{
				state = UPDATE_SELECTED ;
			}
			if ( event == EVT_KEY_LONG(KEY_EXIT) )
			{
				state = UPDATE_FILE_LIST ;		// Canceled
			}
    break ;
		case UPDATE_SELECTED :
			f_open( &FlashFile, FlashFilename, FA_READ ) ;
			f_read( &FlashFile, (BYTE *)FileData, 1024, &BlockCount ) ;
			i = 1 ;
			if (UpdateItem == UPDATE_TYPE_BOOTLOADER )		// Bootloader
			{
				i = validateFile( (uint32_t *) FileData ) ;
			}
			if ( i == 0 )
			{
				state = UPDATE_INVALID ;
			}
			else
			{
				if (UpdateItem == UPDATE_TYPE_BOOTLOADER )		// Bootloader
				{
#ifdef PCBX9D
					firmwareAddress = 0x08000000 ;
#endif
#ifdef PCBSKY
					firmwareAddress = 0x00400000 ;
#endif
				}
#ifdef PCBSKY
 #ifndef REVX
				else if (UpdateItem == UPDATE_TYPE_COPROCESSOR )		// Bootloader
				{
					firmwareAddress = 0x00000080 ;
					if ( check_ready() == 0 )
					{
						CoProcReady = 1 ;
					}
				}
 #endif
#endif
				else
				{
// SPort update
					SportState = SPORT_START ;
					FirmwareSize = FileSize[fc->vpos] ;
					BlockInUse = 0 ;
					f_read( &FlashFile, (BYTE *)ExtraFileData, 1024, &XblockCount ) ;
				}
				BytesFlashed = 0 ;
				BlockOffset = 0 ;
				ByteEnd = 1024 ;
				state = UPDATE_ACTION ;
			}
    break ;
		case UPDATE_INVALID :
			lcd_puts_Pleft( 2*FH, "Invalid File" ) ;
			lcd_puts_Pleft( 4*FH, "Press EXIT" ) ;
			if ( event == EVT_KEY_FIRST(KEY_EXIT) )
			{
				state = UPDATE_FILE_LIST ;		// Canceled
    		killEvents(event) ;
			}
    break ;
		case UPDATE_ACTION :
			// Do the flashing
			lcd_puts_Pleft( 3*FH, "Flashing" ) ;
			if (UpdateItem == UPDATE_TYPE_BOOTLOADER )		// Bootloader
			{
				width = ByteEnd >> 9 ;
				if ( BytesFlashed < ByteEnd )
				{
					program( (uint32_t *)firmwareAddress, &((uint32_t *)FileData)[BlockOffset] ) ;	// size is 256 bytes
					BlockOffset += 64 ;		// 32-bit words (256 bytes)
					firmwareAddress += 256 ;
					BytesFlashed += 256 ;
				}
				else
				{
					if ( ByteEnd >= 32768 )
					{
						state = UPDATE_COMPLETE ;
					}
					else
					{
						f_read( &FlashFile, (BYTE *)FileData, 1024, &BlockCount ) ;
						ByteEnd += 1024 ;
						BlockOffset = 0 ;
					}
				}
			}

#ifdef PCBSKY
 #ifndef REVX
			else if (UpdateItem == UPDATE_TYPE_COPROCESSOR )		// CoProcessor
コード例 #8
0
int main( int argc, const char** argv )
{
    	cv::Mat img;
	std::string posFileName = "";
	std::string negFileName = "";

	ObjectDetection* objDetect = new ObjectDetection();
	objDetect->SetObjectName(argv[4]);

	if(argc == 1) {
		printf("No arguments received\n");
		return 0;
	}
	
	// window size
	int width = atoi(argv[5]);
	int height = atoi(argv[6]);

	objDetect->SetWindowSize(height, width);

	bool bTrain = true;
	if(strcmp("test", argv[1]) == 0)
		bTrain = false;

	if(bTrain == true) {
		posFileName = argv[2];
		negFileName = argv[3];
		objDetect->InitTrain();
	}
	else {
		posFileName = argv[2];

		//MODEL* trainModel = objDetect->LoadSVMModelFile(argv[3]);
		objDetect->InitTest(argv[3]);
	}


	// get the file that contains the file list
	std::ifstream fileList (posFileName.c_str());
	if (fileList.is_open())
	{
		std::string line;
		while ( fileList.good() )
		{
			std::getline (fileList,line);
			cout << line << endl;
			
			if(bTrain == true)
				objDetect->trainMultiScale(line, 1);
			else
				objDetect->test(line);
		}
		fileList.close();
	}

	// get the file that contains the file list
	if(negFileName.empty() == false) {
		std::ifstream negList (negFileName.c_str());
		if (negList.is_open())
		{
			std::string line;
			while ( negList.good() )
			{
				std::getline (negList,line);
				cout << line << endl;

				objDetect->trainMultiScale(line, 0);
			}
			negList.close();
		}
	}

	objDetect->Close();
	return 0;
}
コード例 #9
0
int main()
{
	int i;/**/
	/******************************************************/
	/*test des diférentes fonctions sur la structure data */
	/******************************************************/
	
	/*intitialisation d'un structure Data*/
	Data test_data = initData();
	
	/*intitialisation d'une liste de chaine de caractere*/
	char ** testTable = initAddressTable();/**/
	
	if(test_data!=NULL)
		printf("initalisation de la strucutre test_data s'est bien passee\n");
	else
		erreur("initalisation de la strucutre test_data",99);
	
	addFileInListFile("test", test_data);
	printf("fichier est bien ajouté dans la structure\n");
	printf("le fichier ajouté est ");
	fileList(test_data);
	addFileInListFile("test2", test_data);
	printf("fichier est bien ajouté dans la structure\n");
	printf("le fichier ajouté est ");
	fileList(test_data);
	addFileInListFile("test3", test_data);
	printf("fichier est bien ajouté dans la structure\n");
	printf("le fichier ajouté est ");
	fileList(test_data);
	
	printf("supression de la structure...\n");
	deleteData(test_data);
	printf("structure suprimée\n");
	
	/***********************************************************/
	/*test des diférentes fonctions sur la liste des adresse IP*/
	/***********************************************************/
	if(testTable!=NULL)
	  printf("initalisation de le tableau d'adresse IP s'est bien passee\n");
	else
	  erreur("erreur lors de l'initialisation de la strucutre test_data",99);
	
	for(i=0;i<6;i++)
	{
	  addAddressInTable(testTable, "TEST");
	  printf("adresse %d est bien ajoutee\n",i);
	}
	
	for(i=0;i<6;i++)
	{
	  addAddressInTable(testTable, "TEST");
	  printf("adresse %d est bien ajoutee\n",i);
	}
	
	
	printf("supression du tableau d'adresse IP\n");
	deleteAddessTable(testTable);/**/
	
	return 0;
}
コード例 #10
0
void plot_source_peaks(TString runNumber)
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(12);

  // Style options
  gROOT->SetStyle("Plain");
  //gStyle->SetOptStat(11);
  gStyle->SetOptStat(0);
  gStyle->SetStatFontSize(0.030);
  gStyle->SetOptFit(0);
  gStyle->SetOptTitle(0);
  gStyle->SetTitleFontSize(0.05);
  //gStyle->SetTitleX(0.17);
  //gStyle->SetTitleAlign(13);
  gStyle->SetTitleOffset(0.90, "x");
  gStyle->SetTitleOffset(1.25, "y");
  gStyle->SetPadTickX(1);
  gStyle->SetPadTickY(1);
  gStyle->SetNdivisions(510,"X");
  gStyle->SetNdivisions(510,"Y");
  gStyle->SetPadLeftMargin(0.15); // 0.13
  gStyle->SetPadRightMargin(0.05);
  gStyle->SetPadTopMargin(0.03);
  gStyle->SetPadBottomMargin(0.15); // 0.12
  gStyle->SetLabelSize(0.052,"X");
  gStyle->SetLabelSize(0.052,"Y");
  gStyle->SetTitleSize(0.052,"X");
  gStyle->SetTitleSize(0.052,"Y");
  gROOT->ForceStyle();
  gStyle->SetErrorX(0);

  // Open input ntuple
  TString filenameIn;
  filenameIn  = TString(getenv("SOURCE_PEAKS"))+TString("/source_peaks_");
  filenameIn += runNumber;
  filenameIn += ".root";
  cout << "Processing ... " << filenameIn << endl;
  TFile *filein = new TFile(filenameIn);

  // Open source list file
  int nSources;
  string sourceName[3];
  bool useSource[3] = {false,false,false};
  TString filenameList;
  filenameList  = TString(getenv("SOURCE_LIST"))+TString("/source_list_");
  filenameList += runNumber;
  filenameList += ".dat";
  ifstream fileList(filenameList);
  fileList >> nSources;
  cout << "... nSources: " << nSources << endl;
  for (int n=0; n<nSources;n++) {
    fileList >> sourceName[n];
    if (sourceName[n]=="Ce" || sourceName[n]=="Sn" || sourceName[n]=="Bi") useSource[n]=true;
  }

  // Output file
  TString filenameOut;
  filenameOut  = TString(getenv("SOURCE_PEAKS"))+TString("/source_peaks_");
  filenameOut += runNumber;
  filenameOut += ".pdf";

  TString filenameOutFirst;
  filenameOutFirst  = filenameOut;
  filenameOutFirst += "(";

  TString filenameOutLast;
  filenameOutLast  = filenameOut;
  filenameOutLast += ")";

  // Source #1: East
  if (useSource[0]) {
    double upperRange = 2000.;
    if (sourceName[0]=="Bi") upperRange = 3000.;
    c1 = new TCanvas("c1","c1");
    c1->Divide(2,2);

    c1_1->cd();
    c1_1->SetLogy(0);
    his1_E0->SetXTitle("East PMT 1");
    his1_E0->GetXaxis()->CenterTitle();
    his1_E0->GetXaxis()->SetRangeUser(0.0,upperRange);
    his1_E0->Draw();
    
    c1_2->cd();
    c1_2->SetLogy(0);
    his1_E1->SetXTitle("East PMT 2");
    his1_E1->GetXaxis()->CenterTitle();
    his1_E1->GetXaxis()->SetRangeUser(0.0,upperRange);
    his1_E1->Draw();
    
    c1_3->cd();
    c1_3->SetLogy(0);
    his1_E2->SetXTitle("East PMT 3");
    his1_E2->GetXaxis()->CenterTitle();
    his1_E2->GetXaxis()->SetRangeUser(0.0,upperRange);
    his1_E2->Draw();
    
    c1_4->cd();
    c1_4->SetLogy(0);
    his1_E3->SetXTitle("East PMT 4");
    his1_E3->GetXaxis()->CenterTitle();
    his1_E3->GetXaxis()->SetRangeUser(0.0,upperRange);
    his1_E3->Draw();
    
    c1->Print(filenameOutFirst);
    
    // Source #1: West
    c2 = new TCanvas("c2","c2");
    c2->Divide(2,2);
    
    c2_1->cd();
    c2_1->SetLogy(0);
    his1_W0->SetXTitle("West PMT 1");
    his1_W0->GetXaxis()->CenterTitle();
    his1_W0->GetXaxis()->SetRangeUser(0.0,upperRange);
    his1_W0->Draw();
    
    c2_2->cd();
    c2_2->SetLogy(0);
    his1_W1->SetXTitle("West PMT 2");
    his1_W1->GetXaxis()->CenterTitle();
    his1_W1->GetXaxis()->SetRangeUser(0.0,upperRange);
    his1_W1->Draw();
    
    c2_3->cd();
    c2_3->SetLogy(0);
    his1_W2->SetXTitle("West PMT 3");
    his1_W2->GetXaxis()->CenterTitle();
    his1_W2->GetXaxis()->SetRangeUser(0.0,upperRange);
    his1_W2->Draw();

    c2_4->cd();
    c2_4->SetLogy(0);
    his1_W3->SetXTitle("West PMT 4");
    his1_W3->GetXaxis()->CenterTitle();
    his1_W3->GetXaxis()->SetRangeUser(0.0,upperRange+980.);
    his1_W3->Draw();
    
    if (nSources > 1 && (useSource[1] || useSource[2])) c2->Print(filenameOut);
    else c2->Print(filenameOutLast);
  }
  if (nSources > 1 && useSource[1]) {
    double upperRange = 2000.;
    if (sourceName[1]=="Bi") upperRange = 3000.;
      
    // Source #2: East
    c3 = new TCanvas("c3","c3");
    c3->Divide(2,2);
    
    c3_1->cd();
    c3_1->SetLogy(0);
    his2_E0->SetXTitle("East PMT 1");
    his2_E0->GetXaxis()->CenterTitle();
    his2_E0->GetXaxis()->SetRangeUser(0.0,upperRange);
    his2_E0->Draw();
    
    c3_2->cd();
    c3_2->SetLogy(0);
    his2_E1->SetXTitle("East PMT 2");
    his2_E1->GetXaxis()->CenterTitle();
    his2_E1->GetXaxis()->SetRangeUser(0.0,upperRange);
    his2_E1->Draw();
    
    c3_3->cd();
    c3_3->SetLogy(0);
    his2_E2->SetXTitle("East PMT 3");
    his2_E2->GetXaxis()->CenterTitle();
    his2_E2->GetXaxis()->SetRangeUser(0.0,upperRange);
    his2_E2->Draw();
    
    c3_4->cd();
    c3_4->SetLogy(0);
    his2_E3->SetXTitle("East PMT 4");
    his2_E3->GetXaxis()->CenterTitle();
    his2_E3->GetXaxis()->SetRangeUser(0.0,upperRange);
    his2_E3->Draw();
    
    if (useSource[0]) c3->Print(filenameOut);
    else c3->Print(filenameOutFirst);
    
    // Source #2: West
    c4 = new TCanvas("c4","c4");
    c4->Divide(2,2);
    
    c4_1->cd();
    c4_1->SetLogy(0);
    his2_W0->SetXTitle("West PMT 1");
    his2_W0->GetXaxis()->CenterTitle();
    his2_W0->GetXaxis()->SetRangeUser(0.0,upperRange);
    his2_W0->Draw();
    
    c4_2->cd();
    c4_2->SetLogy(0);
    his2_W1->SetXTitle("West PMT 2");
    his2_W1->GetXaxis()->CenterTitle();
    his2_W1->GetXaxis()->SetRangeUser(0.0,upperRange);
    his2_W1->Draw();
    
    c4_3->cd();
    c4_3->SetLogy(0);
    his2_W2->SetXTitle("West PMT 3");
    his2_W2->GetXaxis()->CenterTitle();
    his2_W2->GetXaxis()->SetRangeUser(0.0,upperRange);
    his2_W2->Draw();
    
    c4_4->cd();
    c4_4->SetLogy(0);
    his2_W3->SetXTitle("West PMT 4");
    his2_W3->GetXaxis()->CenterTitle();
    his2_W3->GetXaxis()->SetRangeUser(0.0,upperRange+980.);
    his2_W3->Draw();
    
    if (nSources > 2 && useSource[2]) c4->Print(filenameOut);
    else c4->Print(filenameOutLast);

  }

  if (nSources > 2 && useSource[2]) {
    double upperRange = 2000.;
    if (sourceName[2]=="Bi") upperRange = 3000.;

    // Source #3: East
    c5 = new TCanvas("c5","c5");
    c5->Divide(2,2);
    
    c5_1->cd();
    c5_1->SetLogy(0);
    his3_E0->SetXTitle("East PMT 1");
    his3_E0->GetXaxis()->CenterTitle();
    his3_E0->GetXaxis()->SetRangeUser(0.0,upperRange);
    his3_E0->Draw();
    
    c5_2->cd();
    c5_2->SetLogy(0);
    his3_E1->SetXTitle("East PMT 2");
    his3_E1->GetXaxis()->CenterTitle();
    his3_E1->GetXaxis()->SetRangeUser(0.0,upperRange);
    his3_E1->Draw();
    
    c5_3->cd();
    c5_3->SetLogy(0);
    his3_E2->SetXTitle("East PMT 3");
    his3_E2->GetXaxis()->CenterTitle();
    his3_E2->GetXaxis()->SetRangeUser(0.0,upperRange);
    his3_E2->Draw();
    
    c5_4->cd();
    c5_4->SetLogy(0);
    his3_E3->SetXTitle("East PMT 4");
    his3_E3->GetXaxis()->CenterTitle();
    his3_E3->GetXaxis()->SetRangeUser(0.0,upperRange);
    his3_E3->Draw();
    
    if (useSource[0] || useSource[1]) c5->Print(filenameOut);
    else c5->Print(filenameOutFirst);
    
    // Source #3: West
    c6 = new TCanvas("c6","c6");
    c6->Divide(2,2);
    
    c6_1->cd();
    c6_1->SetLogy(0);
    his3_W0->SetXTitle("West PMT 1");
    his3_W0->GetXaxis()->CenterTitle();
    his3_W0->GetXaxis()->SetRangeUser(0.0,upperRange);
    his3_W0->Draw();
    
    c6_2->cd();
    c6_2->SetLogy(0);
    his3_W1->SetXTitle("West PMT 2");
    his3_W1->GetXaxis()->CenterTitle();
    his3_W1->GetXaxis()->SetRangeUser(0.0,upperRange);
    his3_W1->Draw();
    
    c6_3->cd();
    c6_3->SetLogy(0);
    his3_W2->SetXTitle("West PMT 3");
    his3_W2->GetXaxis()->CenterTitle();
    his3_W2->GetXaxis()->SetRangeUser(0.0,upperRange);
    his3_W2->Draw();
    
    c6_4->cd();
    c6_4->SetLogy(0);
    his3_W3->SetXTitle("West PMT 4");
    his3_W3->GetXaxis()->CenterTitle();
    his3_W3->GetXaxis()->SetRangeUser(0.0,upperRange+980.);
    his3_W3->Draw();
    
    c6->Print(filenameOutLast);
    
  }

}
コード例 #11
0
void serialCallBack(Stream& stream, char arrivedChar, unsigned short availableCharsCount) {
	if (arrivedChar == '\n') {
		char str[availableCharsCount];
		for (int i = 0; i < availableCharsCount; i++) {
			str[i] = stream.read();
			if (str[i] == '\r' || str[i] == '\n') {
				str[i] = '\0';
			}
		}
		
		if (!strcmp(str, "connect")) {
			// connect to wifi
			WifiStation.config(WIFI_SSID, WIFI_PWD);
			WifiStation.enable(true);
		} else if (!strcmp(str, "ip")) {
			Serial.printf("ip: %s mac: %s\r\n", WifiStation.getIP().toString().c_str(), WifiStation.getMAC().c_str());
		} else if (!strcmp(str, "ota")) {
			OtaUpdate();
		} else if (!strcmp(str, "switch")) {
			Switch();
		} else if (!strcmp(str, "restart")) {
			System.restart();
		} else if (!strcmp(str, "ls")) {
			Vector<String> files = fileList();
			Serial.printf("filecount %d\r\n", files.count());
			for (unsigned int i = 0; i < files.count(); i++) {
				Serial.println(files[i]);
			}
		} else if (!strcmp(str, "cat")) {
			Vector<String> files = fileList();
			if (files.count() > 0) {
				Serial.printf("dumping file %s:\r\n", files[0].c_str());
				Serial.println(fileGetContent(files[0]));
			} else {
				Serial.println("Empty spiffs!");
			}
		} else if (!strcmp(str, "info")) {
			ShowInfo();
		} else if (!strcmp(str, "help")) {
			Serial.println();
			Serial.println("available commands:");
			Serial.println("  help - display this message");
			Serial.println("  ip - show current ip address");
			Serial.println("  connect - connect to wifi");
			Serial.println("  restart - restart the esp8266");
			Serial.println("  switch - switch to the other rom and reboot");
			Serial.println("  ota - perform ota update, switch rom and reboot");
			Serial.println("  info - show esp8266 info");
			Serial.println("  sl - Sleep for 5 seconds");
#ifndef DISABLE_SPIFFS
			Serial.println("  ls - list files in spiffs");
			Serial.println("  cat - show first file in spiffs");
#endif
			Serial.println();
		} else if (!strcmp(str, "sl")) {
			Serial.println("Going to sleep");
			delay(500);
			system_deep_sleep(5000000);
			delay(500);
			Serial.println("Wakeing up");
		} else {
			Serial.println("unknown command");
		}
	}
}
コード例 #12
0
ファイル: application.cpp プロジェクト: gernoteger/DobbyESP
void serialCallBack(Stream& stream, char arrivedChar, unsigned short availableCharsCount) {
	state=!state;
	digitalWrite(LED_PIN2, state);

	if (arrivedChar == '\n') {
		char str[availableCharsCount];
		for (int i = 0; i < availableCharsCount; i++) {
			str[i] = stream.read();
			if (str[i] == '\r' || str[i] == '\n') {
				str[i] = '\0';
			}
		}
		
		if (!strcmp(str, "connect")) {
			// connect to wifi
			WifiStation.config(WIFI_SSID, WIFI_PWD);
			WifiStation.enable(true);
		} else if (!strcmp(str, "ip")) {
			Serial.printf("ip: %s mac: %s\r\n", WifiStation.getIP().toString().c_str(), WifiStation.getMAC().c_str());
		} else if (!strcmp(str, "ota")) {
			OtaUpdate();
		} else if (!strcmp(str, "otafiles")) {
			OtaUpdateFiles();
		} else if (!strcmp(str, "otafs")) {
			//OtaUpdateFiles();
		} else if (!strcmp(str, "switch")) {
			Switch();
		} else if (!strcmp(str, "restart")) {
			System.restart();
		} else if (!strcmp(str, "ls")) {
			Vector<String> files = fileList();
			Serial.printf("filecount %d\r\n", files.count());
			for (unsigned int i = 0; i < files.count(); i++) {
				Serial.println(files[i]);
			}
		} else if (!strncmp(str, "cat ",3)) {
			Vector<String> files = fileList();
			if (files.count() > 0) {
				Serial.printf("dumping file %s:\r\n", files[0].c_str());
				Serial.println(fileGetContent(files[0]));
			} else {
				Serial.println("Empty spiffs!");
			}
		} else if (!strcmp(str, "info")) {
			ShowInfo();
		} else if (!strcmp(str, "help")) {
			Serial.println();
			Serial.println("available commands:");
			Serial.println("  help - display this message");
			Serial.println("  ip - show current ip address");
			Serial.println("  connect - connect to wifi");
			Serial.println("  restart - restart the esp8266");
			Serial.println("  switch - switch to the other rom and reboot");
			Serial.println("  ota - perform ota update, switch rom and reboot");
			Serial.println("  otafiles - update all files over web from src");
			//Serial.println("  otafs - update files system (spiff_rom.bin) over web");
			Serial.println("  info - show esp8266 info");
			Serial.println("  ls - list files in spiffs");
			Serial.println("  cat <filename>- show first file in spiffs");
			Serial.println();
		} else {
			Serial.println("unknown command");
		}
	}
}
コード例 #13
0
ファイル: application.cpp プロジェクト: zhivko/SmingRTOS
void serialCallBack(Stream& stream, char arrivedChar, unsigned short availableCharsCount) {

	/*
	 Serial.print("Class Delegate Demo Time = ");
	 Serial.print(micros());
	 Serial.print(" char = 0x");
	 Serial.print(String(arrivedChar, HEX)); // char hex code
	 Serial.print(" available = ");
	 Serial.println(availableCharsCount);
	 */
	int ia = (int) arrivedChar;
	if (arrivedChar == '\n') // Lets show data!
			{
		char str[availableCharsCount];
		Serial.println("<New line received>");
		int i = 0;
		while (stream.available()) {
			char cur = stream.read();
			if (((int) cur != 13) && ((int) cur != 10)) {
				str[i] = cur;
				Serial.print(cur);
			} else {
				str[i] = '\0';
			}
			i++;
		}
		Serial.println();
		//}

		/*
		 int ia = (int) arrivedChar;
		 if (ia == 13) {
		 char str[availableCharsCount];
		 for (int i = 0; i < availableCharsCount-1; i++) {
		 str[i] = stream.read();
		 Serial.printf("%c",str[i]);
		 if (str[i] == '\r' || str[i] == '\n') {
		 str[i] = '\0';
		 //break;
		 }
		 }
		 */
		Serial.printf("\nCommand: %s, length=%d %d %d\n", str, availableCharsCount, str[availableCharsCount - 2],
				str[availableCharsCount - 1]);
		if (!strcmp(str, "connect")) {
			// connect to wifi
			WifiStation.config(wifi_sid.get(currWifiIndex), wifi_pass.get(currWifiIndex));
			WifiStation.enable(true);
		} else if (!strcmp(str, "ip")) {
			Serial.printf("ip: %s mac: %s\r\n", WifiStation.getIP().toString().c_str(), WifiStation.getMAC().c_str());
		} else if (!strcmp(str, "ota")) {
			OtaUpdate();
		} else if (!strcmp(str, "restart")) {
			System.restart();
		} else if (!strcmp(str, "ls")) {
			Vector<String> files = fileList();
			Serial.printf("filecount %d\r\n", files.count());
			for (unsigned int i = 0; i < files.count(); i++) {
				Serial.println(files[i]);
			}
		} else if (!strcmp(str, "info")) {
			ShowInfo();
		} else if (!strcmp(str, "switch")) {
			Switch();
		} else if (!strcmp(str, "cat")) {
			Vector<String> files = fileList();
			if (files.count() > 0) {
				Serial.printf("dumping file %s:\r\n", files[2].c_str());
				Serial.println(fileGetContent(files[2]));
			} else {
				Serial.println("Empty spiffs!");
			}
		} else if (!strcmp(str, "pos")) {
			reportStatus();
		} else if (!strcmp(str, "move")) {
			Serial.println();
			nextPos[0] += 10000;
			nextPos[1] += 10000;
			nextPos[2] += 10000;
			nextPos[3] += 10000;
//procTimer.initializeUs(deltat, blink1).start(true);
		} else if (!strcmp(str, "help")) {
			Serial.println();
			Serial.println("available commands:");
			Serial.println("  help - display this message");
			Serial.println("  ip - show current ip address");
			Serial.println("  connect - connect to wifi");
			Serial.println("  restart - restart the esp8266");
			Serial.println("  switch - switch to the other rom and reboot");
			Serial.println("  ota - perform ota update, switch rom and reboot");
			Serial.println("  info - show esp8266 info");
#ifndef DISABLE_SPIFFS
			Serial.println("  ls - list files in spiffs");
			Serial.println("  cat - show first file in spiffs");
#endif
			Serial.println();
		} else {
			Serial.printf("Trying to parse as gCode: %s\n", str);
			parseGcode(str);
		}
	} else if (ia == 48) {
		Serial.println();
		stream.read();
		nextPos[0] += 100;
		nextPos[1] += 100;
		nextPos[2] += 100;
		nextPos[3] += 100;
//procTimer.initializeUs(deltat, blink1).start(true);
	} else if (ia == 49) {
		Serial.println();
		stream.read();
		nextPos[0] -= 100;
		nextPos[1] -= 100;
		nextPos[2] -= 100;
		nextPos[3] -= 100;
//procTimer.initializeUs(deltat, blink1).start(true);
	}
}
コード例 #14
0
ファイル: NA61_LRC_2.cpp プロジェクト: LUHEP/NA61_Analysis_2
int main(int argc, char* argv[])
{
	// --- reading of filenames
	cout<<"START"<<endl;
	if (argc < 2) 
	{
		cerr << "usage: " << argv[0] << " <file list>" << endl;
		return 1;
	}

    cout << " reading file names from " << argv[1] << endl;
    ifstream fileList(argv[1]);
    
    if (!fileList.good() || !fileList.is_open())
    {
        cerr << " Error, cannot read file list " << argv[1] << endl;
        return 1;
    }

    //FIXME
    std::vector<std::string> offBranches;  
    offBranches.push_back("eventTree.fEvent.fRecEvent.fBeam");
    offBranches.push_back("eventTree.fEvent.fRawEvent.fBeam");
    std::vector<std::string> onBranches;
    onBranches.push_back("eventTree.fEvent.fRawEvent.fBeam");
    onBranches.push_back("eventTree.fEvent.fRecEvent.fBeam");
    
    // --- creating of handlers 
    // ----- List of handlers 
	HandlerList* HandList = new HandlerList();
	// ----- Handlers

	const int N0 = 3;
	OneWindHandler* arOneWindHandler[N0];
	for (int i = 0; i<N0; i++){
		TString name;
		TString nameBasic = "One_Wind";
		char name2[50];
		sprintf(name2, "_%i", i);
		name = nameBasic + name2;
		arOneWindHandler[i] = new OneWindHandler(name + "Raw.root", false);


        arOneWindHandler[i]->AddStandardCutsRaw();
        if (i==1)
            arOneWindHandler[i]->AddAcceptRapidityCut(0.95);
        if (i==2)
            arOneWindHandler[i]->AddAcceptRapidityCut(0.99);

//        arOneWindHandler[i]->AddS5TracksCloudCut(80,100,200,nTrackInVtxFit);
//		    arOneWindHandler[i]->AddPSDEnergyCut(1470, e28Central);



		HandList->AddHandler(arOneWindHandler[i]);
	}
	
    const int N1=0;//1;
	PtNFluctuationHandler* arHandlerFlucPtNRaw[N1];
    for (int i =0; i<N1; i++){
        TString name;
        TString nameBasic="Full_FlucPt";
        char name2[50];
        sprintf(name2,"_%i",i);
        name = nameBasic + name2;
		arHandlerFlucPtNRaw[i] = new PtNFluctuationHandler(name + "Raw.root", false);
		arHandlerFlucPtNRaw[i]->AddStandardCutsRaw();
		if (i==0 || i==1)
			arHandlerFlucPtNRaw[i]->AddCentrality(0,1);
        if (i==2 || i==3)
            arHandlerFlucPtNRaw[i]->AddCentrality(1,5);
        if (i==4 || i==5)
            arHandlerFlucPtNRaw[i]->AddCentrality(5,10);
        if (i==6 || i==7)
            arHandlerFlucPtNRaw[i]->AddCentrality(10,15);
        if (i==1 || i==3 || i==5 || i==7)
            arHandlerFlucPtNRaw[i]->AddAcceptRapidityCut(0.95);
        else arHandlerFlucPtNRaw[i]->AddAcceptRapidityCut(0.9);



        //arHandlerFlucPtNRaw[i]->AddPSDEnergyCut(0, 80);
//		if (i == 1)
	//		arHandlerFlucPtNRaw[i]->AddAcceptRapidityCut();
//			arHandlerFlucPtNRaw[i]->AddPSDEnergyCut(0, 1850);
//		if (i == 1)
//			arHandlerFlucPtNRaw[i]->AddPSDEnergyCut(0, 4*beamMomentum);
//		if (i == 2)
//			arHandlerFlucPtNRaw[i]->AddPSDEnergyCut(0, 2600);
//		if (i == 3)
//			arHandlerFlucPtNRaw[i]->AddPSDEnergyCut(0, 17 * beamMomentum);


        HandList->AddHandler(arHandlerFlucPtNRaw[i]);
    }

	const int N2 = 0;//3;
	PSDFluctuationHandler* arHandlerFlucPSDRaw[N2];
	for (int i = 0; i<N2; i++){
		TString name;
		TString nameBasic = "Full_FlucPSD";
		char name2[50];
		sprintf(name2, "_%i", i);
		name = nameBasic + name2;
		arHandlerFlucPSDRaw[i] = new PSDFluctuationHandler(name + "Raw.root", false);

		if (i==0 || i==1)
			arHandlerFlucPSDRaw[i]->AddRunNumberCut(0,20445);
		if (i==2 || i==3)
			arHandlerFlucPSDRaw[i]->AddRunNumberCut(20445,20500);
		arHandlerFlucPSDRaw[i]->AddStandardCutsRaw();
		if (i==1 || i==3)
			arHandlerFlucPSDRaw[i]->AddPSDEnergyCut(1850, e28Central);
		HandList->AddHandler(arHandlerFlucPSDRaw[i]);
	}

	const int N3 =0;//21;
	PtNFluctuationHandler* arHandlerEtaFlucPtNRaw[N3];
	for (int i = 0; i<N3; i++){
		TString name;
		TString nameBasic = "Eta_FlucPtRaw";
		char name2[50];
		sprintf(name2, "_%i", i);
		name = nameBasic + name2;
		arHandlerEtaFlucPtNRaw[i] = new PtNFluctuationHandler(name + "Raw.root", false);

        arHandlerEtaFlucPtNRaw[i]->AddRunNumberCut(0,20380);


		arHandlerEtaFlucPtNRaw[i]->AddStandardCutsRaw();

		arHandlerEtaFlucPtNRaw[i]->AddPSDEnergyCut(1850, e28Central);
		//arHandlerEtaFlucPtNRaw[i]->AddEtaCut(2 + i*0.2, 2.5 + i*0.2);
		HandList->AddHandler(arHandlerEtaFlucPtNRaw[i]);
	}

	const int N4 = 0;
	TimeHandler* arTime[N4];
	for (int i =0; i<N4; i++){
		TString name;
		TString nameBasic = "Time";
		char name2[50];
		sprintf(name2, "_%i", i);
		name = nameBasic + name2;
		arTime[i] = new TimeHandler(name + "Raw.root", false);
		arTime[i]->AddStandardCutsRaw();
        if (i==1)
            arTime[i]->AddPSDEnergyCut(0,900, e28Central);

		HandList->AddHandler(arTime[i]);
	}

	const int N6 = 0;
	OneWindHandler* arOneWindHandler1[N6];
	for (int i = 0; i<N6; i++){
        if (i==3) continue;
        if (i==8) continue;

		TString name;
		TString nameBasic = "One_Wind";
		char name2[50];
		sprintf(name2, "_%i", i);
		name = nameBasic + name2;
		arOneWindHandler1[i] = new OneWindHandler(name + "Raw.root", false);

        arOneWindHandler1[i]->Raw();
		if (systemType == ArSc) {
            if (i>0)
                arOneWindHandler1[i]->Remove0BinsEvents();
            if (i>1)
                arOneWindHandler1[i]->RemoveBadRuns();
			if (beamMomentum == 150) {
                if (i>2)
                    arOneWindHandler1[i]->AddRunNumberCut(0,20380);
			}
			if (beamMomentum == 13) {
                if (i>2)
                    arOneWindHandler1[i]->AddRunNumberCut(20551,30000);
			}
		}
        arOneWindHandler1[i]->AddTrigger(T2);
		if (systemType == ArSc) {
            if (i>3)
                arOneWindHandler1[i]->AddWFACut(-100, -200, 4);
            if (i>4)
                arOneWindHandler1[i]->AddWFAT4Cut(0,1000,25);
		}
        if (i>5)
            arOneWindHandler1[i]->AddStrongPBDCut();
        
            arOneWindHandler1[i]->AddFittedVtxCut();
        if (i>8)
            arOneWindHandler1[i]->AddFitQualityCut();
		if (systemType == ArSc){
			if (beamMomentum == 150) {
                if (i>9)
                    arOneWindHandler1[i]->AddZVtxCut(-589.7, -569.7);
                if (i>10)
                    arOneWindHandler1[i]->AddPSDEnergyCut(2800, e16Central);
                if (i>11)
                    arOneWindHandler1[i]->AddPSDEnergyCut(800, 5000, e28Periferal);
                if (i>6)
                    arOneWindHandler1[i]->AddBPD3ClusterSignalCut(3200,8100,2500,7000);
                if (i>14)
                    arOneWindHandler1[i]->AddS5Cut(170);
                if (i>15)
                    arOneWindHandler1[i]->AddS5Cut(50);
                if (i>12)
                    arOneWindHandler1[i]->AddLocalRatioCut(0.25,0,50);
				//this->AddTrackVtxFittedTrackRatioCut(0.25);

			}
			if (beamMomentum == 75){
                if (i>9)
                    arOneWindHandler1[i]->AddZVtxCut(-589.7, -569.7);
                if (i>10)
                    arOneWindHandler1[i]->AddPSDEnergyCut(1300, e16Central);
                if (i>11)
                    arOneWindHandler1[i]->AddPSDEnergyCut(300, 1700, e28Periferal);
                if (i>14)
                    arOneWindHandler1[i]->AddS5Cut(170);
                if (i>15)
                    arOneWindHandler1[i]->AddS5Cut(90);
                if (i>6)
                    arOneWindHandler1[i]->AddBPD3ClusterSignalCut(3800,7200,3600,6800);
                if (i>12)
                    arOneWindHandler1[i]->AddLocalRatioCut(0.17,0,30);

			}
			if (beamMomentum == 13){
                if (i==11) continue;
                if (i>9)
                    arOneWindHandler1[i]->AddZVtxCut(-590, -570);
                if (i>10)
                    arOneWindHandler1[i]->AddPSDEnergyCut(200, e16Central);
                if (i>14)
                    arOneWindHandler1[i]->AddS5Cut(170);
                if (i>6)
                    arOneWindHandler1[i]->AddBPD3ClusterSignalCut(3000,7900,2500,6800);
                if (i>12)
                    arOneWindHandler1[i]->AddLocalRatioCut(0.08,0,6);

			}
			if (beamMomentum == 19) {
                if (i>9)
                    arOneWindHandler1[i]->AddZVtxCut(-589.9, -569.9);
                if (i>10)
                    arOneWindHandler1[i]->AddPSDEnergyCut(350, e16Central);
                if (i>11)
                    arOneWindHandler1[i]->AddPSDEnergyCut(20, 500, e28Periferal);
                if (i>14)
                    arOneWindHandler1[i]->AddS5Cut(170);
                if (i>15)
                    arOneWindHandler1[i]->AddS5Cut(90);
                if (i>6)
                    arOneWindHandler1[i]->AddBPD3ClusterSignalCut(3500, 6500, 3200, 6000);
                if (i>12)
                    arOneWindHandler1[i]->AddLocalRatioCut(0.1,0,10);
			}
			if (beamMomentum == 30) {
                if (i>9)
                    arOneWindHandler1[i]->AddZVtxCut(-589.9, -569.9);
                if (i>10)
                    arOneWindHandler1[i]->AddPSDEnergyCut(600, e16Central);
                if (i>11)
                    arOneWindHandler1[i]->AddPSDEnergyCut(100, 1000, e28Periferal);
				if (i>14)
                    arOneWindHandler1[i]->AddS5Cut(170);
                if (i>15)
                    arOneWindHandler1[i]->AddS5Cut(90);
                if (i>6)
                    arOneWindHandler1[i]->AddBPD3ClusterSignalCut(3400,7400,2800,6600);
                if (i>12)
                    arOneWindHandler1[i]->AddLocalRatioCut(0.1,0,12);
			}
			if (beamMomentum == 40) {
                if (i>9)
                    arOneWindHandler1[i]->AddZVtxCut(-589.8, -569.8);
                if (i>10)
                    arOneWindHandler1[i]->AddPSDEnergyCut(900, e16Central);
                if (i>11)
                    arOneWindHandler1[i]->AddPSDEnergyCut(200, 1000, e28Periferal);
                if (i>14)
                    arOneWindHandler1[i]->AddS5Cut(170);
                if (i>15)
                    arOneWindHandler1[i]->AddS5Cut(90);
                if (i>6)
                    arOneWindHandler1[i]->AddBPD3ClusterSignalCut(3500,8000,3000,7000);
                if (i>12)
                    arOneWindHandler1[i]->AddLocalRatioCut(0.13,0,15);
			}
		}
        if (i>13)
            arOneWindHandler1[i]->AddZeroPositiveTracksCut();

		arOneWindHandler1[i]->AddStandardCutsRaw();
		HandList->AddHandler(arOneWindHandler1[i]);
	}

	const int N7 = 0;
	LRCHandler* arLRCHandler[N7];
	for (int i = 0; i<N7; i++){
		TString name;
		TString nameBasic = "LRC_Wind";
		char name2[50];
		sprintf(name2, "_%i", i);
		name = nameBasic + name2;
		arLRCHandler[i] = new LRCHandler(name + "Raw.root", false);
		arLRCHandler[i]->AddStandardCutsRaw();

		arLRCHandler[i]->AddEtaForward(5.5, 6);
		arLRCHandler[i]->AddEtaBackward(3.2 + i*0.2, 3.7 + i*0.2);
		HandList->AddHandler(arLRCHandler[i]);
	}

	const int N8 = 0;
	PSDHandler* arPSDHandler[N8];
	for (int i = 0; i<N8; i++){
		TString name;
		TString nameBasic = "PSD";
		char name2[50];
		sprintf(name2, "_%i", i);
		name = nameBasic + name2;
		arPSDHandler[i] = new PSDHandler(name + "Raw.root", false);
		arPSDHandler[i]->AddStandardCutsRaw();
		arPSDHandler[i]->AddS5Cut(80);

		if (i==1)
			arPSDHandler[i]->Remove0EPSDEvents(e28Central);

		HandList->AddHandler(arPSDHandler[i]);
	}

	const int N9 = 0;
	PSD0BinsFindHandler* ar0bins[N9];
	for (int i = 0; i<N9; i++){
		TString name;
		TString nameBasic = "0Bins";
		char name2[50];
		sprintf(name2, "_%i", i);
		name = nameBasic + name2;
		ar0bins[i] = new PSD0BinsFindHandler(name + "Raw.root", false);
        ar0bins[i]->Raw();
        if (i==1)
            ar0bins[i]->AddFPGACut(eAll);
 //       ar0bins[i]->Remove0BinsEvents();
		HandList->AddHandler(ar0bins[i]);
	}


	//FIXME: add information about energy and system type inside names of hists!

	cout<<"Initialization"<<endl;
	HandList->Init();
    	int i=0;
	time_t     now;
	struct tm  *ts;
	char       buf[80];
	int nFiles = 0;

    while (true){
        string fileName;
        fileList >> fileName;
        if(!fileList.good())
            break;
        cout << " ->processing " << fileName << endl;
        EventFile eventFile(fileName, eRead, Verbosity::eSilent, offBranches, onBranches);
        Event event;

        cout<<"event loop ... "<<endl;
        // --- loop over events
        
        while (eventFile.Read(event) == eSuccess){
			i++;
//			cout<<"event_event"<<i<<endl;
			// --- working status output
			cout<<i<<"\t";
			if(i%1000==0){
				// Get the current time
				now = time(NULL);          
				// Format and print the time, "ddd yyyy-mm-dd hh:mm:ss zzz" 
				ts = localtime(&now);
				strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z", ts);
				printf("running event %5d time: %s\n",(int) i,buf);
			} 
			CutList::eventCutChecking.Reset();
//			cout<<"eat"<<endl;
            HandList->EatEvent(event);
        }
    }      

    delete HandList; 
    
	return 0;
}
コード例 #15
0
ファイル: main.cpp プロジェクト: TomasRiker/blocks-5
int runTheGame(int argc,
			   char** pp_argv)
{
	FileSystem& fs = FileSystem::inst();
	const std::string homeDirectory(fs.getAppHomeDirectory());
	const std::string versionInitialized(detectInitializedVersion());
	fs.createDirectory(homeDirectory);

	clearLog();
	printfLog("Blocks 5\n");
	printfLog("========\n");
	printfLog("Installed game version: %s\n", p_localVersion);
	printfLog("Last played:            %s\n", versionInitialized.c_str());

	if(versionInitialized != p_localVersion)
	{
		printfLog("Initializing/Updating ...\n");

		bool success = true;
		std::string errorMsg;
		bool severeError = false;
		bool quit = false;

		if(versionInitialized == "not_played" ||
		   versionInitialized == "<= 1.0.7")
		{
			// Verzeichnis initialisieren
			success &= fs.createDirectory(homeDirectory + "levels");
			success &= fs.createDirectory(homeDirectory + "levels/campaigns");
			success &= fs.createDirectory(homeDirectory + "levels/skins");
			success &= fs.createDirectory(homeDirectory + "screenshots");
			success &= fs.createDirectory(homeDirectory + "videos");
			if (fs.fileExists("config.xml")) success &= fs.copyFile("config.xml", homeDirectory + "config.xml");
			success &= fs.copyFile("videos/readme.txt", homeDirectory + "videos/readme.txt");
			if(versionInitialized == "<= 1.0.7") success &= fs.copyFile("progress.zip", homeDirectory + "progress.zip");
			success &= fs.copyFile("update_checker_disable.bat", homeDirectory + "update_checker_disable.bat");
			success &= fs.copyFile("update_checker_enable.bat", homeDirectory + "update_checker_enable.bat");
			if(fs.fileExists(".update_checker")) success &= fs.copyFile(".update_checker", homeDirectory + ".update_checker");

			std::list<std::string> fileList(fs.listDirectory("levels"));
			for(std::list<std::string>::const_iterator it = fileList.begin(); it != fileList.end(); ++it) success &= fs.copyFile(std::string("levels/") + *it, homeDirectory + "levels/" + *it);
			fileList = fs.listDirectory("levels/campaigns");
			for(std::list<std::string>::const_iterator it = fileList.begin(); it != fileList.end(); ++it) success &= fs.copyFile(std::string("levels/campaigns/") + *it, homeDirectory + "levels/campaigns/" + *it);
			fileList = fs.listDirectory("levels/skins");
			for(std::list<std::string>::const_iterator it = fileList.begin(); it != fileList.end(); ++it) success &= fs.copyFile(std::string("levels/skins/") + *it, homeDirectory + "levels/skins/" + *it);
			fileList = fs.listDirectory("screenshots");
			for(std::list<std::string>::const_iterator it = fileList.begin(); it != fileList.end(); ++it) success &= fs.copyFile(std::string("screenshots/") + *it, homeDirectory + "screenshots/" + *it);

			if(success)
			{
				if(versionInitialized != "not_played")
				{
#ifdef _WIN32
					int answer = MessageBoxA(0,
											 "In the new version, Blocks 5 stores the levels, campaigns and other data in a different folder. "
											 "These files are now in a folder called \"Blocks 5\" within your \"My Documents\" folder. "
											 "Please keep this in mind when installing new levels, campaigns or skins!\r\n\r\n"
											 "Do you want to open this folder now in Windows Explorer?",
											 "Important update information",
											 MB_YESNO | MB_ICONINFORMATION);
					if(answer == IDYES)
					{
						std::string temp(homeDirectory);
						for(std::string::iterator it = temp.begin(); it != temp.end(); ++it) if(*it == '/') *it = '\\';
						const std::string cmdLine = std::string("EXPLORER.EXE \"") + temp + "\"";
						WinExec(cmdLine.c_str(), SW_SHOWMAXIMIZED);
						Sleep(5000);
						MessageBoxA(0,
									"Windows Explorer has been started, you should now see the new folder. "
									"Click OK to continue.",
									"Continue",
									MB_OK | MB_ICONINFORMATION);
					}
				}
#endif
			}
			else
			{
				severeError = true;
				errorMsg = std::string("The program could not create and initialize the folder: \"") + homeDirectory + "\"";
			}
		}
		else if(versionInitialized == "1.0.71" ||
				versionInitialized == "1.0.72")
		{
			fs.deleteFile(homeDirectory + "updates.no");
			success &= fs.copyFile("update_checker_disable.bat", homeDirectory + "update_checker_disable.bat");
			success &= fs.copyFile("update_checker_enable.bat", homeDirectory + "update_checker_enable.bat");
			if(fs.fileExists(".update_checker")) success &= fs.copyFile(".update_checker", homeDirectory + ".update_checker");

			success &= fs.createDirectory(homeDirectory + "videos");
			success &= fs.copyFile("videos/readme.txt", homeDirectory + "videos/readme.txt");

			if(!success) errorMsg = "Could not migrate all settings!";
		}
		else if(versionInitialized == "1.0.73")
		{
			fs.deleteFile(homeDirectory + "updates.no");
			success &= fs.copyFile("update_checker_disable.bat", homeDirectory + "update_checker_disable.bat");
			success &= fs.copyFile("update_checker_enable.bat", homeDirectory + "update_checker_enable.bat");
			if (fs.fileExists(".update_checker")) success &= fs.copyFile(".update_checker", homeDirectory + ".update_checker");

			if(!success) errorMsg = "Could not migrate all settings!";
		}

		if(success)
		{
			fs.writeStringToFile(p_localVersion, homeDirectory + ".initialized");
			printfLog("Succeeded initializing/updating user directory!\n");

#ifdef _WIN32
			if(versionInitialized != "not_played")
			{
				int answer = MessageBoxA(0,
										 "Do you want to read the changelog (what's new in this version)? "
										 "If you click \"Yes\", the changelog will be opened in Notepad. "
										 "Once you close the window, the game will start.",
										 "Read changelog?",
										 MB_YESNO | MB_ICONQUESTION);
				if(answer == IDYES)
				{
					system("NOTEPAD.EXE readme.txt");
					Sleep(1000);
				}
			}
#endif
		}
		else
		{
#ifdef _WIN32
			MessageBoxA(0, errorMsg.c_str(), "Error!", MB_OK | MB_ICONERROR);
#else
			std::cerr << errorMsg.c_str() << std::endl;
#endif
			printfLog("%s\n", errorMsg.c_str());
			if(severeError) return 1;
		}

		if(quit) return 0;
	}

	if (!fs.fileExists(homeDirectory + ".update_checker")) fs.writeStringToFile("0", homeDirectory + ".update_checker");
	const std::string updateCheckerStatus(fs.readStringFromFile(homeDirectory + ".update_checker"));
	if(!updateCheckerStatus.empty() && updateCheckerStatus[0] == '1')
	{
		printfLog("Checking for update ...\n");

		// Neue Version da?
		std::string currentVersion = getCurrentVersion();
		if(currentVersion.empty()) printfLog("Could not detect current version!\n");
		else printfLog("Current game version:   %s\n", currentVersion.c_str());
		if(!currentVersion.empty() &&
		   isNewer(currentVersion, p_localVersion))
		{
			std::ostringstream str;
			str << "A new version of Blocks 5 is available.\r\n";
			str << "Installed version: " << p_localVersion << "\r\n";
			str << "New version: " << currentVersion << "\r\n\r\n";
			str << "Do you want to visit the Blocks 5 website now?" << "\r\n\r\n";

#ifdef _WIN32
			int answer = MessageBoxA(0, str.str().c_str(), "Update available!", MB_YESNO | MB_ICONINFORMATION);
			if(answer == IDYES)
			{
				// Seite öffnen
				ShellExecuteA(0, "open", "Blocks 5 Website.url", NULL, NULL, SW_SHOWNORMAL);
				return 0;
			}
		}
#else
#error NOT IMPLEMENTED
#endif
	}
	else
	{
		// Keine automatischen Updates!
		printfLog("Not checking for update!\n");
	}

	// Daten aus dem verschlüsselten Archiv lesen
	fs.pushCurrentDir("data.zip[3Cs18Ab0bV0Aat3Wf27le1ZM12kt0Xs05Aa4PX1EyI2V112Jr26v2GZO3dN0Ec91hk024P3cA32bc3GZ07Em4bf34st4320F7d13S00wd4Mg1ANn4SF2EO94Hz13Qq0LO18iY4Qy2C8r2XF28Bh]");
	
	// Alternativ: Daten aus dem lokalen Verzeichnis lesen
	// fs.pushCurrentDir("data");

	// Fortschritt laden
	ProgressDB::inst().load();

	bool fullScreen;
	bool useHQ2X = false;

#ifdef _DEBUG
	fullScreen = false;
#else
	fullScreen = true;
#endif

	// Argumente parsen
	for(int i = 0; i < argc; i++)
	{
		char* p_arg = pp_argv[i];
		if(!_stricmp(p_arg, "-windowed")) fullScreen = false;
		else if(!_stricmp(p_arg, "-fullScreen")) fullScreen = true;
		else if(!_stricmp(p_arg, "-hq2x")) useHQ2X = true;
	}

	printfLog("Initializing engine ...\n");
	Engine& engine = Engine::inst();

	// Spielaktionen festlegen
	Action* p_action = engine.registerAction("$A_LEFT", engine.getKeyboardVK(SDLK_LEFT), engine.getKeyboardVK(SDLK_KP4));
	p_action->resetsActions.push_back("$A_UP");
	p_action->resetsActions.push_back("$A_DOWN");
	p_action = engine.registerAction("$A_RIGHT", engine.getKeyboardVK(SDLK_RIGHT), engine.getKeyboardVK(SDLK_KP6));
	p_action->resetsActions.push_back("$A_UP");
	p_action->resetsActions.push_back("$A_DOWN");
	p_action = engine.registerAction("$A_UP", engine.getKeyboardVK(SDLK_UP), engine.getKeyboardVK(SDLK_KP8));
	p_action->resetsActions.push_back("$A_LEFT");
	p_action->resetsActions.push_back("$A_RIGHT");
	p_action = engine.registerAction("$A_DOWN", engine.getKeyboardVK(SDLK_DOWN), engine.getKeyboardVK(SDLK_KP2));
	p_action->resetsActions.push_back("$A_LEFT");
	p_action->resetsActions.push_back("$A_RIGHT");
	engine.registerAction("$A_PLANT_BOMB", engine.getKeyboardVK(SDLK_LSHIFT), engine.getKeyboardVK(SDLK_RSHIFT));
	engine.registerAction("$A_PUT_DOWN_BOMB", engine.getKeyboardVK(SDLK_LCTRL), engine.getKeyboardVK(SDLK_RCTRL));
	engine.registerAction("$A_SWITCH_CHARACTER", engine.getKeyboardVK(SDLK_TAB));
	engine.registerAction("$A_SAVE_IN_HOTEL", engine.getKeyboardVK(SDLK_RETURN), engine.getKeyboardVK(SDLK_KP_ENTER));
	p_action = engine.registerAction("$A_RESTART_LEVEL", engine.getKeyboardVK(SDLK_F5));
	p_action->delay = 1000;
	p_action->interval = 1000;
	p_action = engine.registerAction("$A_RESTART_FROM_HOTEL", engine.getKeyboardVK(SDLK_F10));
	p_action->delay = 1000;
	p_action->interval = 1000;
	p_action = engine.registerAction("$A_PAUSE", engine.getKeyboardVK(SDLK_PAUSE));
	p_action->delay = 200;
	p_action->interval = 500;

	// Engine-Aktionen festlegen
	p_action = engine.registerAction("$A_TOGGLE_MUTE", engine.getKeyboardVK(SDLK_F1));
	p_action->delay = INT_MAX;
	p_action = engine.registerAction("$A_CAPTURE_SCREENSHOT", engine.getKeyboardVK(SDLK_F11));
	p_action->delay = INT_MAX;
	p_action = engine.registerAction("$A_TOGGLE_CAPTURE_VIDEO", engine.getKeyboardVK(SDLK_F12));
	p_action->delay = INT_MAX;

	if(!engine.init("Blocks 5", "window.png", 640, 480, fullScreen, useHQ2X))
	{
		printfLog("Error while initializing the engine.\n");
		return 1;
	}

	// Lokalisierung laden
	engine.loadStringDB("languages.txt");

	// Instanzen der Spielzustandsklassen erzeugen
	GS_Menu menu;
	GS_SelectLevel selectLevel;
	GS_Game game;
	GS_LevelEditor levelEditor;
	GS_CampaignEditor campaignEditor;
	GS_Credits credits;
	GS_Loading loading;

	printfLog("Starting game ...\n");
	engine.setGameState("GS_Loading");

	printfLog("Entering main loop ...\n");
	engine.mainLoop();

	printfLog("Shutting down the engine ...\n");
	engine.exit();
	printfLog("Engine has been shut down.\n");

	return 0;
}
コード例 #16
0
ファイル: LayerFactory.C プロジェクト: jlane-waikato/IQmol
Layer::List Factory::toLayers(Data::Base& data)
{
   Layer::List layers;

   //qDebug() << "Layer::Factory converting" << Data::Type::toString(data.typeID());

   try {

      switch (data.typeID()) {
   
         case Data::Type::Bank: {
            Data::Bank& bank(dynamic_cast<Data::Bank&>(data));
            layers << convert(bank);
         } break;

         case Data::Type::GeometryList: {
            Data::GeometryList& list(dynamic_cast<Data::GeometryList&>(data));
            layers << convert(list);
         } break;

         case Data::Type::Geometry: {
            Data::Geometry& geometry(dynamic_cast<Data::Geometry&>(data));
            layers << convert(geometry);
         } break;

         case Data::Type::PointChargeList: {
            Data::PointChargeList&  charges(dynamic_cast<Data::PointChargeList&>(data));
            layers << convert(charges);
         } break;

         case Data::Type::MolecularOrbitalsList: {
            Data::MolecularOrbitalsList& list(dynamic_cast<Data::MolecularOrbitalsList&>(data));
            layers << convert(list);
         } break;

         case Data::Type::MolecularOrbitals: {
            Data::MolecularOrbitals& 
               molecularOrbitals(dynamic_cast<Data::MolecularOrbitals&>(data));
            layers.append(new MolecularOrbitals(molecularOrbitals));
         } break;

         case Data::Type::ExcitedStates: {
            Data::ExcitedStates& 
               states(dynamic_cast<Data::ExcitedStates&>(data));
            layers.append(new ExcitedStates(states));
         } break;

         case Data::Type::Frequencies: {
            Data::Frequencies& 
               frequencies(dynamic_cast<Data::Frequencies&>(data));
            layers.append(new Frequencies(frequencies));
         } break;

         case Data::Type::FileList: {
            Data::FileList& fileList(dynamic_cast<Data::FileList&>(data));
            layers << convert(fileList);
         } break;

         case Data::Type::GridData: {
            QLOG_WARN() << "Data::GridData passed to LayerFactory";
            //Data::GridData& grid(dynamic_cast<Data::GridData&>(data));
            //layers.append(new CubeData(grid));
         } break;

         case Data::Type::CubeData: {
            Data::CubeData& cube(dynamic_cast<Data::CubeData&>(data));
            layers.append(new CubeData(cube));
         } break;


         case Data::Type::EfpFragment: {
            Data::EfpFragment& efp(dynamic_cast<Data::EfpFragment&>(data));
            layers.append(new EfpFragment(efp));
         } break;

         case Data::Type::EfpFragmentList: {
            Data::EfpFragmentList& 
               efpList(dynamic_cast<Data::EfpFragmentList&>(data));
            layers << convert(efpList);
         } break;

         case Data::Type::Mesh: {
            Data::Mesh&  meshData(dynamic_cast<Data::Mesh&>(data));
            Data::Surface surface(meshData);
            Layer::Surface* surfaceLayer(new Surface(surface));
            surfaceLayer->setCheckState(Qt::Checked);
            layers.append(surfaceLayer);
         } break;

         case Data::Type::Surface: {
            Data::Surface&  surfaceData(dynamic_cast<Data::Surface&>(data));
            Layer::Surface* surfaceLayer(new Surface(surfaceData));
            surfaceLayer->setCheckState(surfaceData.isVisible() ? Qt::Checked : Qt::Unchecked);
            layers.append(surfaceLayer);
         } break;

         case Data::Type::Nmr: {
            Data::Nmr&  nmrData(dynamic_cast<Data::Nmr&>(data));
            Layer::Nmr* nmrLayer(new Nmr(nmrData));
            layers.append(nmrLayer);
         } break;

         default:
            QLOG_WARN() << "Unimplemented data type in Layer::Factory"
                        <<  Data::Type::toString(data.typeID());
            break;
      }

   } catch (const std::bad_cast& e) {
       QLOG_ERROR() << "Data cast in Layer::Factory failed"
                    << Data::Type::toString(data.typeID());
   }

   return layers;
}
コード例 #17
0
bool pawsConfigShortcut::PostSetup()
{
//get pointers to Shortcut Menu and its Menu Bar
    psMainWidget*   Main    = psengine->GetMainWidget();
    if( Main==NULL )
    {
        Error1( "pawsConfigShortcut::PostSetup unable to get psMainWidget\n");
        return false;
    }

    ShortcutMenu = Main->FindWidget( "ShortcutMenu",true );
    if( ShortcutMenu==NULL )
    {
        Error1( "pawsConfigShortcut::PostSetup unable to get ShortcutMenu\n");
        return false;
    }

    MenuBar = (pawsScrollMenu*)(ShortcutMenu->FindWidget( "MenuBar",true ));
    if( MenuBar==NULL )
    {
        Error1( "pawsConfigShortcut::PostSetup unable to get MenuBar\n");
        return false;
    }

//get form widgets
    buttonHeight = (pawsScrollBar*)FindWidget("buttonHeight");
    if(!buttonHeight)
    {
        return false;
    }
    buttonHeight->SetMaxValue(64);
    buttonHeight->SetCurrentValue(48,false);

    buttonWidthMode = (pawsRadioButtonGroup*)FindWidget("buttonWidthMode");
    if(!buttonWidthMode)
    {
        return false;
    }

    buttonWidth = (pawsScrollBar*)FindWidget("buttonWidth");
    if(!buttonWidth)
    {
        return false;
    }
    buttonWidth->SetMaxValue(512);
    buttonWidth->SetCurrentValue(48,false);


    editLockMode = (pawsRadioButtonGroup*)FindWidget("editLockMode" );
    if(!editLockMode)
    {
        return false;
    }


    leftScroll = (pawsRadioButtonGroup*)FindWidget("leftScroll");
    if(!leftScroll)
    {
        return false;
    }

    rightScroll = (pawsRadioButtonGroup*)FindWidget("rightScroll");
    if(!rightScroll)
    {
        return false;
    }

    enableScrollBar = (pawsRadioButtonGroup*)FindWidget("enableScrollBar");
    if(!enableScrollBar)
    {
        return false;
    }

    buttonBackground = (pawsCheckBox*)FindWidget("buttonBackground");
    if(!buttonBackground)
    {
        return false;
    }

    healthAndMana = (pawsCheckBox*)FindWidget("healthAndMana");
    if(!healthAndMana)
    {
        return false;
    }

    textFont = (pawsComboBox*)FindWidget("textFont");
    if(!textFont)
    {
        return false;
    }
    csRef<iVFS>           vfs =  csQueryRegistry<iVFS > ( PawsManager::GetSingleton().GetObjectRegistry());
    if( vfs )
    {
        csRef<iStringArray>   fileList( vfs->FindFiles( "/planeshift/data/ttf/*.ttf" ));
        for (size_t i = 0; i < fileList->GetSize(); i++)
        {
            csString fileName ( fileList->Get (i));
            fileName.DeleteAt( 0, 21 ); // remove the leading path.
            fileName.ReplaceAll( ".ttf", "" );

            textFont->NewOption( fileName.GetData() );
        }
    }
    else
    {
        Error1( "pawsConfigShortcutWindow::PostSetup unable to find vfs for font list" );
    }


    textSize = (pawsScrollBar*)FindWidget("textSize");
    if(!textSize)
    {
        return false;
    }
    textSize->SetCurrentValue(10,false);
    textSize->SetMaxValue(40);

    textSpacing = (pawsScrollBar*)FindWidget("textSpacing");
    if(!textSpacing)
    {
        return false;
    }
    textSpacing->SetCurrentValue(4,false);
    textSpacing->SetMaxValue(20);


    return true;
}
コード例 #18
0
void makeAllCtauPlots(const char* workDirName, const char* DSTag, bool paperStyle, bool incSS) {
   // list of files
   vector<TString> theFiles = fileList(workDirName,"",DSTag);

   for (vector<TString>::const_iterator it=theFiles.begin(); it!=theFiles.end(); it++) {
      // if this is not a MB bin, skip it
      anabin thebin = binFromFile(*it);
      // if (!(thebin==anabin(0,1.6,6.5,30,0,200) || thebin==anabin(1.6,2.4,3,30,0,200))) continue;
      if (!(thebin==anabin(0,1.6,9,12,0,200) || 
               thebin==anabin(1.6,2.4,20,30,0,200) ||
               thebin==anabin(1.6,2.4,3,30,40,80) ||
               thebin==anabin(0,1.6,6.5,30,0,200) || thebin==anabin(1.6,2.4,3,30,0,200)
           )) continue;

      TFile *f = TFile::Open(*it);
      TString t; Int_t from = 0;
      bool catchjpsi=false, catchpsip=false, catchbkg=false;
      Char_t jpsiName[128], psipName[128], bkgName[128];
      while (it->Tokenize(t, from, "_")) {
         if (catchjpsi) {strcpy(jpsiName, t.Data()); catchjpsi=false;}
         if (catchpsip) {strcpy(psipName, t.Data()); catchpsip=false;}
         if (catchbkg) {strcpy(bkgName, t.Data()); catchbkg=false;}
         if (t=="Jpsi") catchjpsi=true;
         if (t=="Psi2S") catchpsip=true;
         if (t=="Bkg") catchbkg=true;
      }

      bool isPbPb = (it->Index("PbPb")>0);
      struct KinCuts cut;
      cut.dMuon.M.Min = 3;
      cut.dMuon.M.Max = 3.2;
      
      cut.Centrality.Start = thebin.centbin().low();
      cut.Centrality.End = thebin.centbin().high();
      cut.dMuon.Pt.Min = thebin.ptbin().low();
      cut.dMuon.Pt.Max = thebin.ptbin().high();
      cut.dMuon.AbsRap.Min = thebin.rapbin().low();
      cut.dMuon.AbsRap.Max = thebin.rapbin().high();

      string indMuonMass    = Form("(%.6f < invMass && invMass < %.6f)",       cut.dMuon.M.Min,       cut.dMuon.M.Max);
      // if (fitSB) indMuonMass = indMuonMass + "&&" + "((2.0 < invMass && invMass < 2.7) || (3.3 < invMass && invMass < 3.45) || (3.9 < invMass && invMass < 5.0))";
      string indMuonRap     = Form("(%.6f <= abs(rap) && abs(rap) < %.6f)",    cut.dMuon.AbsRap.Min,  cut.dMuon.AbsRap.Max);
      string indMuonPt      = Form("(%.6f <= pt && pt < %.6f)",                cut.dMuon.Pt.Min,      cut.dMuon.Pt.Max);
      // string indMuonCtau    = Form("(%.6f < ctau && ctau < %.6f)",             cut.dMuon.ctau.Min,    cut.dMuon.ctau.Max); 
      // if(cut.dMuon.ctauCut!=""){ indMuonCtau = cut.dMuon.ctauCut; }
      // string indMuonCtauErr = Form("(%.6f < ctauErr && ctauErr < %.6f)",       cut.dMuon.ctauErr.Min, cut.dMuon.ctauErr.Max);
      string inCentrality   = Form("(%d <= cent && cent < %d)",                cut.Centrality.Start,  cut.Centrality.End);

      string strCut         = indMuonMass +"&&"+ indMuonRap +"&&"+ indMuonPt;// +"&&"+ indMuonCtau +"&&"+ indMuonCtauErr;
      if (isPbPb){ strCut = strCut +"&&"+ inCentrality; } 

      // RooWorkspace *myws = (RooWorkspace*) f->Get("workspace");
      TFile *fmaster = NULL;
      if (isPbPb) fmaster = TFile::Open("DataSet/DATASET_DATA_PbPb.root");
      else fmaster = TFile::Open("DataSet/DATASET_DATA_PP.root");
      if (!fmaster || !fmaster->IsOpen()) continue;
      RooDataSet *dOS = (RooDataSet*) fmaster->Get(Form("dOS_DATA_%s",isPbPb ? "PbPb" : "PP"));
      RooDataSet *dSS = (RooDataSet*) fmaster->Get(Form("dSS_DATA_%s",isPbPb ? "PbPb" : "PP"));
      RooWorkspace *myws = new RooWorkspace("workspace");
      cout << strCut << endl;
      if (dOS) {
         RooDataSet *dOS2 = (RooDataSet*) dOS->reduce(strCut.c_str());
         myws->import(*dOS2);
         cout << dOS2->sumEntries() << endl;
      }
      if (dSS) {
         RooDataSet *dSS2 = (RooDataSet*) dSS->reduce(strCut.c_str());
         myws->import(*dSS2);
         cout << dSS2->sumEntries() << endl;
      }


      string outputDir = string("Output/") + string(workDirName) + string("/");
      struct InputOpt opt;
      opt.pp.RunNb.Start   = 262157; opt.PbPb.RunNb.Start = 262620;
      opt.pp.RunNb.End     = 262328; opt.PbPb.RunNb.End   = 263757;
      opt.pp.TriggerBit    = (int) PP::HLT_HIL1DoubleMu0_v1; 
      opt.PbPb.TriggerBit  = (int) HI::HLT_HIL1DoubleMu0_v1; 
      string plotLabel = "";
      bool cutCtau = true;
      bool doSimulFit = false;
      cout << *it << " " << it->Index("PbPb") << endl;
      bool setLogScale = true; //!paperStyle;
      bool zoomPsi = paperStyle;
      int nBins = 80;

      drawCtauPlot(*myws, outputDir, opt, cut, plotLabel, DSTag, isPbPb, setLogScale, incSS, nBins, paperStyle, false);

      delete myws;
      delete f;
      delete fmaster;
   }
}
コード例 #19
0
ファイル: mergeLheFiles.cpp プロジェクト: parbol/PersonalCode
int main(int argc, char** argv)
{

  std::string line;
  std::string line2;
  /* if(argc < 3)
  {
    std::cout << ">>>splitLheFile.cpp::Usage:   " << argv[0] << "   initialFile.lhe   fileToAdd1.lhe   fileToAdd2.lhe ..." << std::endl;
    return -1;
    }*/
  
  char* fileListName = argv[1];
  char* outputFileName = argv[2]; 
  std::ifstream fileList(fileListName, std::ios::in);
  int fileIt = 0;  

  char* initialFileName;
  std::vector<char*> fileToAddNames;

  while(!fileList.eof()) {
    getline(fileList, line);
    if( !fileList.good() ) break;

    char *cline = new char[line.length() + 1];
    strcpy(cline, line.c_str());
    if (fileIt==0) {
      initialFileName = cline;
      std::cout << "initialFileName = " << initialFileName << std::endl;
    } else {
      fileToAddNames.push_back( cline  );
      std::cout << "fileToAddName = " << fileToAddNames.at(fileIt-1) << std::endl;
    }
    fileIt++;
  }

  std::cout << "Merging " << fileIt << " LHE files" << std::endl;
  /* char* initialFileName = argv[1]; 
  std::cout << "initialFileName = " << initialFileName << std::endl;
  
  std::vector<char*> fileToAddNames;
  for(int fileIt = 0; fileIt < argc-2; ++fileIt)
  {
    fileToAddNames.push_back( argv[2+fileIt] );
    std::cout << "fileToAddName = " << fileToAddNames.at(fileIt) << std::endl;
    }  */
  
  
  // open lhe file
  std::ifstream initialFile(initialFileName, std::ios::in);
  std::ofstream outFile(outputFileName, std::ios::out);
  
 
  bool writeEvent = false;
  int eventIt = 0;
  
  while(!initialFile.eof())
  {
    getline(initialFile, line);
    if( !initialFile.good() ) break;
    
    if( line == "</LesHouchesEvents>" )
    {
      for(int fileIt2 = 0; fileIt2 < fileIt-1; ++fileIt2)
      {
        std::ifstream fileToAdd(fileToAddNames.at(fileIt2), std::ios::in);
        
        while(!fileToAdd.eof())
        {
          getline(fileToAdd, line2); 
          
          // decide whether to skip event or not 
          if( line2 == "<event>" )
          {
            ++eventIt;
            writeEvent = true;
          }
                
          
          // write line to outFile
          if(writeEvent == true)
            outFile << line2 << std::endl;
          
          
          // end of event
          if( line2 == "</event>" )
            writeEvent = false;
        }
      }
      break;
    }
    else outFile << line << std::endl;
    
  }
  outFile << "</LesHouchesEvents>" << std::endl;
  
  std::cout << "Added " << eventIt << " events to file " << outputFileName << std::endl;
  return 0;
}
コード例 #20
0
JBoolean
SVNTabBase::ExecuteJCCDiff
	(
	const JString&	rev,
	const JBoolean	isPrev
	)
{
	JPtrArray<JString> fileList(JPtrArrayT::kDeleteAll);
	JArray<JIndex> revList;
	GetSelectedFilesForDiff(&fileList, &revList);
	if (fileList.IsEmpty())
		{
		return kJFalse;
		}

	const JBoolean customPrev = JI2B( isPrev && !revList.IsEmpty() );

	const JSize count = fileList.GetElementCount();
	JString cmd, s, fullName;
	JSubstitute subst;
	for (JIndex i=1; i<=count; i++)
		{
		if (customPrev)
			{
			const JIndex j = revList.GetElement(i);
			s  = JString(j-1, JString::kBase10);
			s += ":";
			s += JString(j, JString::kBase10);
			}
		else
			{
			s = rev;
			}
		s += " $file_name";

		fullName = JPrepArgForExec(*(fileList.NthElement(i)));
		subst.DefineVariable("file_name", fullName);
		subst.Substitute(&s);

		if (count == 1)
			{
			s.Prepend(" --svn-diff ");
			}
		else
			{
			s.Prepend(" --svn-diff-silent ");
			}

		cmd += s;
		}

	cmd.Prepend("jcc");

	if (itsDirector->HasPath())
		{
		JSimpleProcess::Create(itsDirector->GetPath(), cmd, kJTrue);
		}
	else
		{
		JSimpleProcess::Create(cmd, kJTrue);
		}

	return kJTrue;
}
コード例 #21
0
int main(int argc, char * argv[]) {

  // first argument - config file 
  // second argument - filelist

//  using namespace std;

  //const int CutNumb = 8;
  //string CutList[CutNumb]={"No cut","Trigger","1l","lept-Veto","b-Veto","MET $>$ 50","MET $>$ 100","dPhi $>$ 1"};

  // **** configuration
  Config cfg(argv[1]);
  string Channel="mutau";

  // kinematic cuts on electrons
  bool fillplots= false;
  bool Wtemplate= true;
  const bool isData = cfg.get<bool>("IsData");
  const bool applyPUreweighting = cfg.get<bool>("ApplyPUreweighting");
  const bool applyPUreweighting_vertices = cfg.get<bool>("ApplyPUreweighting_vertices");
  const bool applyPUreweighting_official = cfg.get<bool>("ApplyPUreweighting_official");
  const bool applyLeptonSF = cfg.get<bool>("ApplyLeptonSF");
  const bool InvertTauIso = cfg.get<bool>("InvertTauIso");
  const bool InvertLeptonIso = cfg.get<bool>("InvertLeptonIso");
  const bool InvertMET = cfg.get<bool>("InvertMET");
  const double ptElectronLowCut   = cfg.get<double>("ptElectronLowCut");
  const double ptElectronHighCut  = cfg.get<double>("ptElectronHighCut");
  const double etaElectronCut     = cfg.get<double>("etaElectronCut");
  const double dxyElectronCut     = cfg.get<double>("dxyElectronCut");
  const double dzElectronCut      = cfg.get<double>("dzElectronCut");
  const double isoElectronLowCut  = cfg.get<double>("isoElectronLowCut");
  const double isoElectronHighCut = cfg.get<double>("isoElectronHighCut");
  const bool applyElectronId     = cfg.get<bool>("ApplyElectronId");

  // vertex cuts
  const double ndofVertexCut  = cfg.get<double>("NdofVertexCut");   
  const double zVertexCut     = cfg.get<double>("ZVertexCut");
  const double dVertexCut     = cfg.get<double>("DVertexCut");
  // kinematic cuts on muons
  const double ptMuonLowCut   = cfg.get<double>("ptMuonLowCut");
  const double ptMuonHighCut  = cfg.get<double>("ptMuonHighCut");
  const double etaMuonCut     = cfg.get<double>("etaMuonCut");
  const double dxyMuonCut     = cfg.get<double>("dxyMuonCut");
  const double dzMuonCut      = cfg.get<double>("dzMuonCut");
  const double isoMuonLowCut  = cfg.get<double>("isoMuonLowCut");
  const double isoMuonHighCut = cfg.get<double>("isoMuonHighCut");
  const double isoMuonHighCutQCD = cfg.get<double>("isoMuonHighCutQCD");
  const bool applyMuonId     = cfg.get<bool>("ApplyMuonId");
 
  const double ptTauLowCut = cfg.get<double>("ptTauLowCut"); 
  const double etaTauCut = cfg.get<double>("etaTauCut"); 

  const string dataBaseDir = cfg.get<string>("DataBaseDir");

  string TrigLeg  ;
   if (!isData) TrigLeg  = cfg.get<string>("Mu17LegMC");
   if (isData) TrigLeg  = cfg.get<string>("Mu18LegData");
  const string Mu17Tau20MuLegA  = cfg.get<string>("Mu17Tau20MuLegA");
  const string Mu17Tau20MuLegB  = cfg.get<string>("Mu17Tau20MuLegB");
  const string Mu17Tau20TauLegA  = cfg.get<string>("Mu17Tau20TauLegA");
  const string Mu17Tau20TauLegB  = cfg.get<string>("Mu17Tau20TauLegB");
 
  const string SingleMuonTriggerFile  = cfg.get<string>("Muon17TriggerEff");
  const float singleMuonTriggerPtCut = cfg.get<float>("SingleMuonTriggerPtCut");
  const float singleMuonTriggerEtaCut = cfg.get<float>("SingleMuonTriggerEtaCut");

  const string Region  = cfg.get<string>("Region");
  const string Sign  = cfg.get<string>("Sign");


  const double leadchargedhadrcand_dz = cfg.get<double>("leadchargedhadrcand_dz");
  const double leadchargedhadrcand_dxy = cfg.get<double>("leadchargedhadrcand_dxy");



  // kinematic cuts on Jets
  const double etaJetCut   = cfg.get<double>("etaJetCut");
  const double ptJetCut   = cfg.get<double>("ptJetCut");
  
  
  // topological cuts
  const double dRleptonsCutmutau   = cfg.get<double>("dRleptonsCutmutau");
  const double dZetaCut       = cfg.get<double>("dZetaCut");
  const double deltaRTrigMatch = cfg.get<double>("DRTrigMatch");
  const bool oppositeSign    = cfg.get<bool>("oppositeSign");
  const bool isIsoR03 = cfg.get<bool>("IsIsoR03");
 
  // tau
  const double taupt    = cfg.get<double>("taupt");
  const double taueta    = cfg.get<double>("taueta");
  const double decayModeFinding    = cfg.get<double>("decayModeFinding");
  const double   decayModeFindingNewDMs  = cfg.get<double>("decayModeFindingNewDMs");
  const double   againstElectronVLooseMVA5  = cfg.get<double>("againstElectronVLooseMVA5");
  const double   againstMuonTight3  = cfg.get<double>("againstMuonTight3");
  const double   vertexz =  cfg.get<double>("vertexz");
  const double   byCombinedIsolationDeltaBetaCorrRaw3Hits = cfg.get<double>("byCombinedIsolationDeltaBetaCorrRaw3Hits");
  

  const unsigned int RunRangeMin = cfg.get<unsigned int>("RunRangeMin");
  const unsigned int RunRangeMax = cfg.get<unsigned int>("RunRangeMax");
  
  // vertex distributions filenames and histname
  const string vertDataFileName = cfg.get<string>("VertexDataFileName");
  const string vertMcFileName   = cfg.get<string>("VertexMcFileName");
  const string vertHistName     = cfg.get<string>("VertexHistName");

  // lepton scale factors
  const string muonSfDataBarrel = cfg.get<string>("MuonSfDataBarrel");
  const string muonSfDataEndcap = cfg.get<string>("MuonSfDataEndcap");
  const string muonSfMcBarrel = cfg.get<string>("MuonSfMcBarrel");
  const string muonSfMcEndcap = cfg.get<string>("MuonSfMcEndcap");
  
  const string jsonFile = cfg.get<string>("jsonFile");

  string cmsswBase = (getenv ("CMSSW_BASE"));
  string fullPathToJsonFile = cmsswBase + "/src/DesyTauAnalyses/NTupleMaker/test/json/" + jsonFile;

  const string MuonIdIsoFile = cfg.get<string>("MuonIdIsoEff");
  const string TauFakeRateFile = cfg.get<string>("TauFakeRateEff");

  // Run-lumi selector
  std::vector<Period> periods;  
  if (isData) { // read the good runs 
	  std::fstream inputFileStream(fullPathToJsonFile.c_str(), std::ios::in);
  	  if (inputFileStream.fail() ) {
            std::cout << "Error: cannot find json file " << fullPathToJsonFile << std::endl;
            std::cout << "please check" << std::endl;
            std::cout << "quitting program" << std::endl;
	    exit(-1);
	  }
  
          for(std::string s; std::getline(inputFileStream, s); ) {
	  //std::fstream inputFileStream("temp", std::ios::in);
           periods.push_back(Period());
           std::stringstream ss(s);
           ss >> periods.back();
          }
  }

  TString MainTrigger(TrigLeg);
  TString Muon17Tau20MuLegA (Mu17Tau20MuLegA );
  TString Muon17Tau20MuLegB (Mu17Tau20MuLegB );
  TString Muon17Tau20TauLegA (Mu17Tau20TauLegA );
  TString Muon17Tau20TauLegB (Mu17Tau20TauLegB );



  const double Lumi   = cfg.get<double>("Lumi");
  const double bTag   = cfg.get<double>("bTag");
  const double metcut = cfg.get<double>("metcut");
 
  CutList.clear();
  CutList.push_back("No cut");
  CutList.push_back("No cut after PU");
  CutList.push_back("$\\mu$");
  CutList.push_back("$\\tau_h$");
  CutList.push_back("Trigger");
  CutList.push_back("2nd $\\ell$-Veto");
  CutList.push_back("3rd $\\ell$-Veto");
  CutList.push_back("Lepton SF");
  CutList.push_back("TauFakeRate");
  CutList.push_back("topPtRwgt");
  CutList.push_back("${M}_T>60");
  CutList.push_back("$ E_T^{\\rm miss}>$ 100");
  CutList.push_back("Jets $<$3");
  CutList.push_back("b-Veto");
  CutList.push_back("$40<\\rm{Inv}_M<80");
  CutList.push_back("$1.5<\\Delta R<4$");
 

  int CutNumb = int(CutList.size());
  xs=1;fact=1;fact2=1;
 
  unsigned int RunMin = 9999999;
  unsigned int RunMax = 0;
        
  ifstream ifs("xsecs");
  string line;

  while(std::getline(ifs, line)) // read one line from ifs
    {
		
      fact=fact2=1;
      istringstream iss(line); // access line as a stream

      // we only need the first two columns
      string dt,st1,st2;st1="stau2_1";st2="stau5_2";
      iss >> dt >> xs >> fact >> fact2;
      //ifs >> dt >> xs; // no need to read further
      //cout<< " "<<dt<<"  "<<endl;
      //cout<< "For sample ========================"<<dt<<" xsecs is "<<xs<<" XSec "<<XSec<<"  "<<fact<<"  "<<fact2<<endl;
      //if (dt==argv[2]) {
      //if (std::string::npos != dt.find(argv[2])) {
      if (  dt == argv[2]) {
	XSec= xs*fact*fact2;
	cout<<" Found the correct cross section "<<xs<<" for Dataset "<<dt<<" XSec "<<XSec<<endl;
      }
      /*
  	if ( argv[2] == st1) {ChiMass=100;mIntermediate=200;}
	else if (argv[2] == st2) {ChiMass=200;mIntermediate=500;}
	*/
      if (isData) XSec=1.;
	ChiMass=0.0;
    }

  if (XSec<0&& !isData) {cout<<" Something probably wrong with the xsecs...please check  - the input was "<<argv[2]<<endl;return 0;}

  std::vector<unsigned int> allRuns; allRuns.clear();

  cout<<" ChiMass is "<<ChiMass<<"  "<<mIntermediate<<endl;
  bool doThirdLeptVeto=true;
  bool doMuVeto=true;

  //CutList[CutNumb]=CutListt[CutNumb];
  char ff[100];

	
  sprintf(ff,"%s/%s",argv[3],argv[2]);

  if (applyPUreweighting_vertices and applyPUreweighting_official) 

	{std::cout<<"ERROR: Choose only ONE PU reweighting method (vertices or official, not both!) " <<std::endl; exit(-1);}

  // reweighting with vertices

  // reading vertex weights
  TFile * fileDataNVert = new TFile(TString(cmsswBase)+"/src/"+dataBaseDir+"/"+vertDataFileName);
  TFile * fileMcNVert   = new TFile(TString(cmsswBase)+"/src/"+dataBaseDir+"/"+vertMcFileName);

  TH1D * vertexDataH = (TH1D*)fileDataNVert->Get(TString(vertHistName));
  TH1D * vertexMcH   = (TH1D*)fileMcNVert->Get(TString(vertHistName));

  float normVertexData = vertexDataH->GetSumOfWeights();
  float normVertexMc   = vertexMcH->GetSumOfWeights();


  vertexDataH->Scale(1/normVertexData);
  vertexMcH->Scale(1/normVertexMc);
 
  PileUp * PUofficial = new PileUp();

  TFile * filePUdistribution_data = new TFile(TString(cmsswBase)+"/src/DesyTauAnalyses/NTupleMaker/data/PileUpDistrib/Data_Pileup_2015D_Nov17.root","read");
  TFile * filePUdistribution_MC = new TFile (TString(cmsswBase)+"/src/DesyTauAnalyses/NTupleMaker/data/PileUpDistrib/MC_Spring15_PU25_Startup.root", "read");
  TH1D * PU_data = (TH1D *)filePUdistribution_data->Get("pileup");
  TH1D * PU_mc = (TH1D *)filePUdistribution_MC->Get("pileup");
  PUofficial->set_h_data(PU_data);
  PUofficial->set_h_MC(PU_mc);


  TFile *f10= new TFile(TString(cmsswBase)+"/src/DesyTauAnalyses/NTupleMaker/data/"+muonSfDataBarrel);  // mu SF barrel data
  TFile *f11 = new TFile(TString(cmsswBase)+"/src/DesyTauAnalyses/NTupleMaker/data/"+muonSfDataEndcap); // mu SF endcap data
  TFile *f12= new TFile(TString(cmsswBase)+"/src/DesyTauAnalyses/NTupleMaker/data/"+muonSfMcBarrel);  // mu SF barrel MC
  TFile *f13 = new TFile(TString(cmsswBase)+"/src/DesyTauAnalyses/NTupleMaker/data/"+muonSfMcEndcap); // mu SF endcap MC 
  
  TGraphAsymmErrors *hEffBarrelData = (TGraphAsymmErrors*)f10->Get("ZMassBarrel");
  TGraphAsymmErrors *hEffEndcapData = (TGraphAsymmErrors*)f11->Get("ZMassEndcap");
  TGraphAsymmErrors *hEffBarrelMC = (TGraphAsymmErrors*)f12->Get("ZMassBarrel");
  TGraphAsymmErrors *hEffEndcapMC = (TGraphAsymmErrors*)f13->Get("ZMassEndcap");
  
  double * dataEffBarrel = new double[10];
  double * dataEffEndcap = new double[10];
  double * mcEffBarrel = new double[10];
  double * mcEffEndcap = new double[10];
  
  dataEffBarrel = hEffBarrelData->GetY();
  dataEffEndcap = hEffEndcapData->GetY();
  mcEffBarrel = hEffBarrelMC->GetY();
  mcEffEndcap = hEffEndcapMC->GetY();


// Lepton Scale Factors 

  TH1D * MuSF_IdIso_Mu1H = new TH1D("MuIdIsoSF_Mu1H", "MuIdIsoSF_Mu1", 100, 0.5,1.5);

  ScaleFactor * SF_muonIdIso; 
  if (applyLeptonSF) {
    SF_muonIdIso = new ScaleFactor();
    SF_muonIdIso->init_ScaleFactor(TString(cmsswBase)+"/src/"+TString(MuonIdIsoFile));
  }
	ScaleFactor * SF_muonTrigger = new ScaleFactor();
	SF_muonTrigger->init_ScaleFactor(TString(cmsswBase)+"/src/"+TString(SingleMuonTriggerFile));

  ////////
  cout<<" Will try to initialize the TFR now.... "<<endl;
  ScaleFactor * SF_TFR; 
  bool applyTFR = true;
  if (applyTFR) {
    SF_TFR = new ScaleFactor();
    SF_TFR->init_ScaleFactorb(TString(cmsswBase)+"/src/"+TString(TauFakeRateFile),applyTFR);
  }


  double Weight=0;
  int nTotalFiles = 0;
  int iCut=0;
  double CFCounter[CutNumb];
  double statUnc[CutNumb];
  int iCFCounter[CutNumb];
  for (int i=0;i < CutNumb; i++){
    CFCounter[i] = 0;
    iCFCounter[i] = 0;
    statUnc[i] =0;
  }
  // file name and tree name
  std::string rootFileName(argv[2]);
  //std::ifstream fileList(argv[2]);
  std::ifstream fileList(ff);
  //std::ifstream fileList0(argv[2]);
  std::ifstream fileList0(ff);
  std::string ntupleName("makeroottree/AC1B");
  std::string initNtupleName("initroottree/AC1B");
  
  TString era=argv[3];
  TString invMuStr,invTauStr,invMETStr;
  if(InvertLeptonIso) invMuStr = "_InvMuIso_";
  if(InvertTauIso) invTauStr = "_InvTauIso_";
  if(InvertMET) invMETStr = "_InvMET_";

  TString TStrName(rootFileName+invMuStr+invTauStr+invMETStr+"_"+Region+"_"+Sign);
  std::cout <<" The filename will be "<<TStrName <<std::endl;  

  // output fileName with histograms
  TFile * file;
  if (isData) file = new TFile(era+"/"+TStrName+TString("_DataDriven.root"),"update");
  if (!isData) file = new TFile(era+"/"+TStrName+TString(".root"),"update");
  file->mkdir(Channel.c_str());
  file->cd(Channel.c_str());

  int nFiles = 0;
  int nEvents = 0;
  int selEvents = 0;

  int selEventsAllMuons = 0;
  int selEventsIdMuons = 0;
  int selEventsIsoMuons = 0;
      bool lumi=false;
      bool isLowIsoMu=false;
      bool isHighIsoMu = false;
      bool isLowIsoTau=false;
      bool isHighIsoTau = false;


  std::string dummy;
  // count number of files --->
  while (fileList0 >> dummy) nTotalFiles++;
 
  SetupHists(CutNumb); 
  if (argv[4] != NULL  && atoi(argv[4])< nTotalFiles) nTotalFiles=atoi(argv[4]);
  //if (nTotalFiles>50) nTotalFiles=50;
  //nTotalFiles = 10;
  for (int iF=0; iF<nTotalFiles; ++iF) {

    std::string filen;
    fileList >> filen;

    std::cout << "file " << iF+1 << " out of " << nTotalFiles << " filename : " << filen << std::endl;
    TFile * file_ = TFile::Open(TString(filen));
    
    TH1D * histoInputEvents = NULL;
    histoInputEvents = (TH1D*)file_->Get("makeroottree/nEvents");
    if (histoInputEvents==NULL) continue;
    int NE = int(histoInputEvents->GetEntries());
    for (int iE=0;iE<NE;++iE)
      inputEventsH->Fill(0.);
    std::cout << "      number of input events         = " << NE << std::endl;

    TTree * _inittree = NULL;
    _inittree = (TTree*)file_->Get(TString(initNtupleName));
    if (_inittree==NULL) continue;
    Float_t genweight;
    if (!isData)
      _inittree->SetBranchAddress("genweight",&genweight);
    Long64_t numberOfEntriesInitTree = _inittree->GetEntries();
    std::cout << "      number of entries in Init Tree = " << numberOfEntriesInitTree << std::endl;
    for (Long64_t iEntry=0; iEntry<numberOfEntriesInitTree; iEntry++) {
      _inittree->GetEntry(iEntry);
      if (isData)
	histWeightsH->Fill(0.,1.);
     else
	histWeightsH->Fill(0.,genweight);
    }

    TTree * _tree = NULL;
    _tree = (TTree*)file_->Get(TString(ntupleName));
    if (_tree==NULL) continue;
    Long64_t numberOfEntries = _tree->GetEntries();
    std::cout << "      number of entries in Tree      = " << numberOfEntries << std::endl;
    AC1B analysisTree(_tree);



    

	//	    if (std::string::npos != rootFileName.find("TTJetsLO") || std::string::npos != rootFileName.find("TTPow"))
    	
			    
			    //numberOfEntries = 1000;

    // numberOfEntries = 1000;
    for (Long64_t iEntry=0; iEntry<numberOfEntries; ++iEntry) { 
     
      Float_t weight = 1;
      Float_t puweight = 1;
      //float topptweight = 1;
      analysisTree.GetEntry(iEntry);
      nEvents++;
    
      iCut = 0;
      
    //std::cout << "      number of entries in Tree = " << numberOfEntries <<" starting weight "<<weight<< std::endl;
     
      if (nEvents%50000==0) 
	cout << "      processed " << nEvents << " events" << endl; 
     
      if (fabs(analysisTree.primvertex_z)>zVertexCut) continue;
      if (analysisTree.primvertex_ndof<ndofVertexCut) continue;
      double dVertex = (analysisTree.primvertex_x*analysisTree.primvertex_x+
		       analysisTree.primvertex_y*analysisTree.primvertex_y);
      if (dVertex>dVertexCut) continue;
      if (analysisTree.primvertex_count<2) continue;  

      //isData= false;
      bool lumi=false;
      isLowIsoMu=false;
      isHighIsoMu = false;
      isLowIsoTau=false;
      isHighIsoTau = false;

    Float_t genweights;
    float topPt = 0;
    float antitopPt = 0;
    bool isZTT = false;

    if(!isData) 
    {
 /*   TTree *genweightsTree = (TTree*)file_->Get("initroottree/AC1B");
	     
    genweightsTree->SetBranchAddress("genweight",&genweights);
    Long64_t numberOfEntriesInit = genweightsTree->GetEntries();
    for (Long64_t iEntryInit=0; iEntryInit<numberOfEntriesInit; ++iEntryInit) { 
      genweightsTree->GetEntry(iEntryInit);
	histWeightsH->Fill(0.,genweights);
    }
   */ /*
	for (unsigned int igent=0; igent < analysisTree.gentau_count; ++igent) {
	  if (analysisTree.gentau_isPrompt[igent]) isZTT = true; 
	}
*/
	for (unsigned int igen=0; igen<analysisTree.genparticles_count; ++igen) {
	   // 		cout<< "  info = " <<  int(analysisTree.genparticles_count) <<"  "<<int(analysisTree.genparticles_pdgid[igen])<<endl;

	  if (analysisTree.genparticles_pdgid[igen]==6)
	    topPt = TMath::Sqrt(analysisTree.genparticles_px[igen]*analysisTree.genparticles_px[igen]+
				analysisTree.genparticles_py[igen]*analysisTree.genparticles_py[igen]);
	  if (analysisTree.genparticles_pdgid[igen]==-6)
	    antitopPt = TMath::Sqrt(analysisTree.genparticles_px[igen]*analysisTree.genparticles_px[igen]+
				    analysisTree.genparticles_py[igen]*analysisTree.genparticles_py[igen]);

	}    
    
	  weight *= analysisTree.genweight;
	  lumi=true;
        //cout<<"  weight from init "<<genweights<< "  "<<analysisTree.genweight<<"  "<<weight<<endl;
/*
	if (applyPUreweighting) {
	  int binNvert = vertexDataH->FindBin(analysisTree.primvertex_count);
	  float_t dataNvert = vertexDataH->GetBinContent(binNvert);
	  float_t mcNvert = vertexMcH->GetBinContent(binNvert);
	  if (mcNvert < 1e-10){mcNvert=1e-10;}
	  float_t vertWeight = dataNvert/mcNvert;
	  weight *= vertWeight;
	  //	  cout << "NVert = " << analysisTree.primvertex_count << "   weight = " << vertWeight << endl;
	}
*/
      }



      if (isData)  {
	XSec = 1.;
	histRuns->Fill(analysisTree.event_run);
///////////////according to dimuons
	int n=analysisTree.event_run;
	int lum = analysisTree.event_luminosityblock;
	
	std::string num = std::to_string(n);
	std::string lnum = std::to_string(lum);
	for(const auto& a : periods)
	  {
	    
	    if ( num.c_str() ==  a.name ) {
	      //std::cout<< " Eureka "<<num<<"  "<<a.name<<" ";
	      //     std::cout <<"min "<< last->lower << "- max last " << last->bigger << std::endl;
	      
	      for(auto b = a.ranges.begin(); b != std::prev(a.ranges.end()); ++b) {
		
		//	cout<<b->lower<<"  "<<b->bigger<<endl;
		if (lum  >= b->lower && lum <= b->bigger ) lumi = true;
	      }
	      auto last = std::prev(a.ranges.end());
	      //    std::cout <<"min "<< last->lower << "- max last " << last->bigger << std::endl;
	      if (  (lum >=last->lower && lum <= last->bigger )) lumi=true;
	      
	      
	    }
	    
	  }
    
	if (!lumi) continue;
	//if (lumi ) cout<<"  =============  Found good run"<<"  "<<n<<"  "<<lum<<endl;
      }


      if (analysisTree.event_run<RunMin)
	RunMin = analysisTree.event_run;
      
      if (analysisTree.event_run>RunMax)
	RunMax = analysisTree.event_run;
      
      //std::cout << " Run : " << analysisTree.event_run << std::endl;
      
      bool isNewRun = true;
      if (allRuns.size()>0) {
	for (unsigned int iR=0; iR<allRuns.size(); ++iR) {
	  if (analysisTree.event_run==allRuns.at(iR)) {
	    isNewRun = false;
	    break;
	  }
	}
      }
	
      if (isNewRun) 
	allRuns.push_back(analysisTree.event_run);




      if (!lumi) continue;
      JetsMV.clear();
      ElMV.clear();
      TauMV.clear();
      MuMV.clear();
      LeptMV.clear();
      mu_index=-1;
      tau_index=-1;
      el_index=-1;
      double MET = sqrt ( analysisTree.pfmet_ex*analysisTree.pfmet_ex + analysisTree.pfmet_ey*analysisTree.pfmet_ey);
      
      METV.SetPx(analysisTree.pfmet_ex);	      
      METV.SetPy(analysisTree.pfmet_ey);
      METV.SetPz(analysisTree.pfmet_ez);
      METV.SetPhi(analysisTree.pfmet_phi);
    
      
      if(fillplots)
      FillMainHists(iCut, weight, ElMV, MuMV, TauMV,JetsMV,METV, ChiMass,mIntermediate,analysisTree, Channel, mu_index,el_index,tau_index);
      CFCounter[iCut]+= weight;
      iCFCounter[iCut]++;
      iCut++;
	



 
      for (unsigned int ijj = 0; ijj<analysisTree.pfjet_count; ++ijj) {
	JetsV.SetPxPyPzE(analysisTree.pfjet_px[ijj], analysisTree.pfjet_py[ijj], analysisTree.pfjet_pz[ijj], analysisTree.pfjet_e[ijj]);
	JetsMV.push_back(JetsV);
      } 


      for (unsigned int imm = 0; imm<analysisTree.muon_count; ++imm) {
	MuV.SetPtEtaPhiM(analysisTree.muon_pt[imm], analysisTree.muon_eta[imm], analysisTree.muon_phi[imm], muonMass);
	MuMV.push_back(MuV);
	//	mu_index=0;
      }

      for (unsigned int ie = 0; ie<analysisTree.electron_count; ++ie) {
	ElV.SetPtEtaPhiM(analysisTree.electron_pt[ie], analysisTree.electron_eta[ie], analysisTree.electron_phi[ie], electronMass);
	ElMV.push_back(ElV);
	//	el_index=0;
      }
   
      for (unsigned int itt = 0; itt<analysisTree.tau_count; ++itt) {
	TauV.SetPtEtaPhiM(analysisTree.tau_pt[itt], analysisTree.tau_eta[itt], analysisTree.tau_phi[itt], tauMass);
	TauMV.push_back(TauV);
	//	tau_index=0;
      }

	 if (!isData )
	 	{
	if (applyPUreweighting)	 {
		puweight = float(PUofficial->get_PUweight(double(analysisTree.numtruepileupinteractions)));
	         weight *=puweight;      
		}
	}
      

      // vector <string> ss; ss.push_back(.c_str());
      if(fillplots)
      FillMainHists(iCut, weight, ElMV, MuMV, TauMV,JetsMV,METV, ChiMass,mIntermediate,analysisTree, Channel, mu_index,el_index,tau_index);
      CFCounter[iCut]+= weight;
      iCFCounter[iCut]++;
      iCut++;

 
      //selecTable.Fill(1,0, weight );      
      bool trigAccept = false;
      
      unsigned int nMainTrigger = 0;
      bool isMainTrigger = false;
      
      

      unsigned int nfilters = analysisTree.run_hltfilters->size();
      //  std::cout << "nfiltres = " << nfilters << std::endl;
      for (unsigned int i=0; i<nfilters; ++i) {
	//	std::cout << "HLT Filter : " << i << " = " << analysisTree.run_hltfilters->at(i) << std::endl;
	TString HLTFilter(analysisTree.run_hltfilters->at(i));
	if (HLTFilter==MainTrigger) {
	  nMainTrigger = i;
	  isMainTrigger = true;
	}
      

      
      }


      if (!isMainTrigger) {
	std::cout << "HLT filter for Mu20 " << MainTrigger << " not found" << std::endl;
	return(-1);
      }

      /////now clear the Mu.El.Jets again to fill them again after cleaning
        MuMV.clear();
        ElMV.clear();
        TauMV.clear();
        LeptMV.clear();

      double isoMuMin = 9999;
      bool mu_iso=false;
      vector<int> muons; muons.clear();
      for (unsigned int im = 0; im<analysisTree.muon_count; ++im) {
	if (analysisTree.muon_pt[im]<ptMuonLowCut) continue;
	if (fabs(analysisTree.muon_eta[im])>etaMuonCut) continue;
	if (fabs(analysisTree.muon_dxy[im])>dxyMuonCut) continue;
	if (fabs(analysisTree.muon_dz[im])>dzMuonCut) continue;


         double absIso= analysisTree.muon_r03_sumChargedHadronPt[im]
	            + max(analysisTree.muon_r03_sumNeutralHadronEt[im] + analysisTree.muon_r03_sumPhotonEt[im]
	            - 0.5 * analysisTree.muon_r03_sumPUPt[im],0.0);


	double relIso = absIso/analysisTree.muon_pt[im];
 
	if (relIso<isoMuonLowCut) continue;

	if (applyMuonId && !analysisTree.muon_isMedium[im]) continue;

	  //cout<<" after muIso index "<<int(mu_index)<<" pT "<<analysisTree.muon_pt[im]<<" relIso "<<relIso<<" isoMuMin "<<isoMuMin<<" muon_count "<<analysisTree.muon_count<<" im "<<im<<" event "<<iEntry<<endl;
	if (double(relIso)<double(isoMuMin)) {
	  isoMuMin  = relIso;
	  mu_index = int(im);
	  mu_iso=true;
	  //cout<<" after muIso index "<<int(mu_index)<<" pT "<<analysisTree.muon_pt[im]<<" relIso "<<relIso<<" isoMuMin "<<isoMuMin<<" muon_count "<<analysisTree.muon_count<<" im "<<im<<" event "<<iEntry<<endl;
	  muons.push_back(im);
	  MuV.SetPtEtaPhiM(analysisTree.muon_pt[mu_index], analysisTree.muon_eta[mu_index], analysisTree.muon_phi[mu_index], muonMass);
	  MuMV.push_back(MuV);
          LeptMV.push_back(MuV);
	}
	//cout<<" Indexes here  "<<im<<"   "<<mu_index<<endl;

	if (relIso == isoMuMin && im != mu_index) {
	  //cout<<" found a pair  for muons " <<relIso <<" mu_index  "<<mu_index<<"  pT "<<analysisTree.muon_pt[int(mu_index)]<<" new  index "<<im<<"  pT  "<<analysisTree.muon_pt[int(im)]<<" event "<<iEntry<<endl;
	  analysisTree.muon_pt[im] > analysisTree.muon_pt[mu_index] ? mu_index = int(im) : mu_index = mu_index;
	}
   
      }
         if (muons.size()==0 || !mu_iso ) continue;

         double absIso= analysisTree.muon_r03_sumChargedHadronPt[mu_index]
	            + max(analysisTree.muon_r03_sumNeutralHadronEt[mu_index] + analysisTree.muon_r03_sumPhotonEt[mu_index]
	            - 0.5 * analysisTree.muon_r03_sumPUPt[mu_index],0.0);


	double relIso = absIso/analysisTree.muon_pt[mu_index];

	 if (relIso>isoMuonHighCut && !InvertLeptonIso) continue;

	 if (relIso>isoMuonHighCutQCD ) { isHighIsoMu=true ;isLowIsoMu=false;}
	  else    { isHighIsoMu = false;isLowIsoMu=true;}
 

       sort(LeptMV.begin(), LeptMV.end(),ComparePt); 
       if (LeptMV.size() == 0 ) continue; 
	if (InvertLeptonIso && !isHighIsoMu) continue;
	if (!InvertLeptonIso && isHighIsoMu) continue;
	if (InvertLeptonIso && isLowIsoMu) continue;
      

//cout<<"  Iso check  "<<relIso<<" InvertLeptonIso "<<InvertLeptonIso<<" isHighIsoMu "<<isHighIsoMu<<" isLowIsoMu "<<isLowIsoMu<<" cutQCD "<<isoMuonHighCutQCD<<endl;


      if(fillplots)
      FillMainHists(iCut, weight, ElMV, MuMV, TauMV,JetsMV,METV, ChiMass,mIntermediate,analysisTree, Channel, mu_index,el_index,tau_index);
      CFCounter[iCut]+= weight;
      iCFCounter[iCut]++;
      iCut++;


      double isoTauMin = 999;
      bool tau_iso = false;
      vector<int> tau; tau.clear();
      for (unsigned int it = 0; it<analysisTree.tau_count; ++it) {

	if (analysisTree.tau_pt[it] < ptTauLowCut || fabs(analysisTree.tau_eta[it])> etaTauCut) continue;
	if (analysisTree.tau_decayModeFindingNewDMs[it]<decayModeFindingNewDMs) continue;
	if ( fabs(analysisTree.tau_leadchargedhadrcand_dz[it])> leadchargedhadrcand_dz) continue;

	if (analysisTree.tau_againstElectronVLooseMVA5[it]<againstElectronVLooseMVA5) continue;
	if (analysisTree.tau_againstMuonTight3[it]<againstMuonTight3) continue;

	//cout<<"  "<<analysisTree.tau_byMediumCombinedIsolationDeltaBetaCorr3Hits[it]<<endl;
	
	if (!InvertTauIso && analysisTree.tau_byCombinedIsolationDeltaBetaCorrRaw3Hits[it] > byCombinedIsolationDeltaBetaCorrRaw3Hits ) continue;
	//if (!InvertTauIso && analysisTree.tau_byMediumCombinedIsolationDeltaBetaCorr3Hits[it] < 0.5 ) continue;

	double  tauIso = analysisTree.tau_byCombinedIsolationDeltaBetaCorrRaw3Hits[it];

	if (tauIso<isoTauMin ) {
	  //      cout<<"  there was a chenge  "<<tauIso<<"  "<<isoTauMin<<" it "<<it<<" tau_index "<<tau_index<<"  "<<analysisTree.tau_count<<endl;
	  isoTauMin  = tauIso;
	  tau_iso=true;
	  tau_index = (int)it;
	  tau.push_back(tau_index);
	  TauV.SetPtEtaPhiM(analysisTree.tau_pt[tau_index], analysisTree.tau_eta[tau_index], analysisTree.tau_phi[tau_index], tauMass);
	  TauMV.push_back(TauV);

	}

continue;

	if (tauIso==isoTauMin && it != tau_index) {
	  //analysisTree.tau_pt[it] > analysisTree.tau_pt[tau_index] ? tau_index = it : tau_index = tau_index;
	  if (analysisTree.tau_pt[it] > analysisTree.tau_pt[tau_index] ) tau_index = (int)it ;
	  //cout<<" found a pair  " <<tauIso <<"  "<<tau_index<<"  "<<it<<endl;
	}
      }
      if (tau.size()==0 || !tau_iso ) continue;

      // cout<< " Lets check  "<<mu_index <<"  "<<tau_index <<"  "<<endl;
      //cout<<"  "<<endl;
////////////////////change to new tau inverted definition 
      double tauIsoI = analysisTree.tau_byMediumCombinedIsolationDeltaBetaCorr3Hits[tau_index];
      if (tauIsoI > 0.5  && InvertTauIso) {isHighIsoTau =true;} 
      //else {isHighIsoTau =false ; isLowIsoTau=true;} 
      //if (isHighIsoTau && tauIso > 2*byCombinedIsolationDeltaBetaCorrRaw3Hits ) continue; 

      if (InvertTauIso && !isHighIsoTau) continue;
      if (!InvertTauIso && isHighIsoTau) continue;
      //if (InvertTauIso && isLowIsoTau) continue;


/*
      continue;
      double isoTauMin = 999;
      bool tau_iso = false;
      vector<int> tau; tau.clear();
      for (unsigned  int it = 0; it<analysisTree.tau_count; ++it) {

	if (analysisTree.tau_pt[it] < ptTauLowCut || fabs(analysisTree.tau_eta[it])> etaTauCut) continue;
	if (analysisTree.tau_decayModeFindingNewDMs[it]<decayModeFindingNewDMs) continue;
	if ( fabs(analysisTree.tau_leadchargedhadrcand_dz[it])> leadchargedhadrcand_dz) continue;
	
	if (analysisTree.tau_againstElectronVLooseMVA5[it]<againstElectronVLooseMVA5) continue;
	if (analysisTree.tau_againstMuonTight3[it]<againstMuonTight3) continue;
	//if (!InvertTauIso && analysisTree.tau_byCombinedIsolationDeltaBetaCorrRaw3Hits[it] > byCombinedIsolationDeltaBetaCorrRaw3Hits ) continue;
	cout<<"  "<<analysisTree.tau_byMediumCombinedIsolationDeltaBetaCorr3Hits[it]<<endl;
	//aif (!InvertTauIso && analysisTree.tau_byMediumCombinedIsolationDeltaBetaCorr3Hits[it] < 0.5 ) continue;

	double  tauIso = analysisTree.tau_byCombinedIsolationDeltaBetaCorrRaw3Hits[it];

	if (tauIso<isoTauMin ) {
	  //      cout<<"  there was a chenge  "<<tauIso<<"  "<<isoTauMin<<" it "<<it<<" tau_index "<<tau_index<<"  "<<analysisTree.tau_count<<endl;
	  isoTauMin  = tauIso;
	  tau_iso=true;
	  tau_index = int(it);
	  tau.push_back(tau_index);
	  TauV.SetPtEtaPhiM(analysisTree.tau_pt[tau_index], analysisTree.tau_eta[tau_index], analysisTree.tau_phi[tau_index], tauMass);
	  TauMV.push_back(TauV);

	}

	if (tauIso==isoTauMin && it != tau_index) {
	  analysisTree.tau_pt[it] > analysisTree.tau_pt[tau_index] ? tau_index = int(it) : tau_index = tau_index;
	  //cout<<" found a pair  " <<tauIso <<"  "<<tau_index<<"  "<<it<<endl;
	}
      }
      if (tau.size()==0 || !tau_iso ) continue;
      double tauIsoI = analysisTree.tau_byMediumCombinedIsolationDeltaBetaCorr3Hits[tau_index];
      if (tauIsoI > 0.5  && InvertTauIso) {isHighIsoTau =true;} 
      //else {isHighIsoTau =false ; isLowIsoTau=true;} 
      //if (isHighIsoTau && tauIso > 2*byCombinedIsolationDeltaBetaCorrRaw3Hits ) continue; 

      if (InvertTauIso && !isHighIsoTau) continue;
      if (!InvertTauIso && isHighIsoTau) continue;
      //if (InvertTauIso && isLowIsoTau) continue;
*/
  
      double q = analysisTree.tau_charge[tau_index] * analysisTree.muon_charge[mu_index];
  
      if (q>0 && Sign=="OS" ) continue;
      if (q<0 && Sign=="SS" ) continue;

      bool regionB = (q<0 && isLowIsoMu);
      bool regionA = (q>0 && isLowIsoMu);
      bool regionC = (q<0 && isHighIsoMu);
      bool regionD = (q>0 && isHighIsoMu);

      if(fillplots)
      FillMainHists(iCut, weight, ElMV, MuMV, TauMV,JetsMV,METV, ChiMass,mIntermediate,analysisTree, Channel, mu_index,el_index,tau_index);
      CFCounter[iCut]+= weight;
      iCFCounter[iCut]++;
      iCut++;

	//cout<<"  HOW MANY MUONS DO I HAVE ??  "<<muons.size()<<endl;

	bool isdRLeptonMatched = false;
	for (unsigned int iT=0; iT<analysisTree.trigobject_count; ++iT) {
	  if (analysisTree.trigobject_filters[iT][nMainTrigger]) { // Mu17 Leg
	    double dRtrig = deltaR(analysisTree.muon_eta[mu_index],analysisTree.muon_phi[mu_index],
				  analysisTree.trigobject_eta[iT],analysisTree.trigobject_phi[iT]);
	    if (!isData && analysisTree.trigobject_filters[iT][nMainTrigger] && analysisTree.trigobject_pt[iT]>singleMuonTriggerPtCut && dRtrig<deltaRTrigMatch)
	      isdRLeptonMatched = true;

	    if (isData && dRtrig<deltaRTrigMatch) isdRLeptonMatched=true;
	    
	  }
	}
		
	     if (!isdRLeptonMatched) continue;

	double dR = deltaR(analysisTree.tau_eta[tau_index],analysisTree.tau_phi[tau_index],
			analysisTree.muon_eta[mu_index],analysisTree.muon_phi[mu_index]);

      	if (dR<dRleptonsCutmutau) continue;

   
			double ptMu1 = (double)analysisTree.muon_pt[mu_index];
			double etaMu1 = (double)analysisTree.muon_eta[mu_index];
			float trigweight=1.;


			float Mu17EffData = (float)SF_muonTrigger->get_EfficiencyData(double(ptMu1),double(etaMu1));
			float Mu17EffMC   = (float)SF_muonTrigger->get_EfficiencyMC(double(ptMu1),double(etaMu1));

			if (!isData) {
				if (Mu17EffMC>1e-6)
					trigweight = Mu17EffData / Mu17EffMC;
				weight *= trigweight;
			//	cout<<" Trigger weight "<<trigweight<<endl;
			}




	if(fillplots)
      FillMainHists(iCut, weight, ElMV, MuMV, TauMV,JetsMV,METV, ChiMass,mIntermediate,analysisTree, Channel, mu_index,el_index,tau_index);
      CFCounter[iCut]+= weight;
      iCFCounter[iCut]++;
      iCut++;


      //Set this flag if there is an opposite-charge muon pair in the event with muons separated by DR>0.15 and both passing the loose selection: 
	


      bool MuVeto=false;

      if (doMuVeto){

     	if (muons.size()>1){
	  for (unsigned  int imv = 0; imv<analysisTree.muon_count; ++imv) {
	    if ( imv != mu_index ){
              double absIso= analysisTree.muon_r03_sumChargedHadronPt[imv]
	            + max(analysisTree.muon_r03_sumNeutralHadronEt[imv] + analysisTree.muon_r03_sumPhotonEt[imv]
	            - 0.5 * analysisTree.muon_r03_sumPUPt[imv],0.0);


	     double relIso = absIso/analysisTree.muon_pt[imv];


	      double dRr = deltaR(analysisTree.muon_eta[mu_index],analysisTree.muon_phi[mu_index],
				 analysisTree.muon_eta[imv],analysisTree.muon_phi[imv]);
	        bool OSCharge = false;  
		if ( imv != mu_index  && analysisTree.muon_charge[imv] != analysisTree.muon_charge[mu_index] ) OSCharge=true;

	      //if ( analysisTree.muon_charge[imv] != analysisTree.muon_charge[mu_index] &&  analysisTree.muon_isGlobal[imv] && analysisTree.muon_isTracker[imv] && analysisTree.muon_isPF[imv]  
	      if ( analysisTree.muon_charge[imv] != analysisTree.muon_charge[mu_index] &&  analysisTree.muon_isGlobal[imv] && analysisTree.muon_isTracker[imv] && analysisTree.muon_isPF[imv]  
		   &&  analysisTree.muon_pt[imv]> 15 &&  fabs(analysisTree.muon_eta[imv])< 2.4 && fabs(analysisTree.muon_dxy[imv])<0.045 
		   && fabs(analysisTree.muon_dz[imv] < 0.2 && relIso< 0.3 && analysisTree.muon_isMedium[imv]) && dRr > 0.15 && OSCharge) //removed from last recipe
		MuVeto=true;
	    }
	  }
	}
      }
      if (MuVeto) continue;

      if(fillplots)
      FillMainHists(iCut, weight, ElMV, MuMV, TauMV,JetsMV,METV, ChiMass,mIntermediate,analysisTree, Channel, mu_index,el_index,tau_index);
      CFCounter[iCut]+= weight;
      iCFCounter[iCut]++;
      iCut++;



      bool ThirdLeptVeto=false;

      if (doThirdLeptVeto){
  	if (analysisTree.electron_count>0) {
	  for (unsigned int iev = 0; iev<analysisTree.electron_count; ++iev) {

/*
	    double neutralIsoV = analysisTree.electron_r03_sumNeutralHadronEt[iev] + analysisTree.electron_r03_sumNeutralHadronEt[iev] + analysisTree.electron_r03_sumPhotonEt[iev] -  4*TMath::Pi()*(0.3*0.3)*analysisTree.rho;
	    double IsoWithEA =  analysisTree.electron_r03_sumChargedHadronPt[iev] + TMath::Max(double(0), neutralIsoV);
	

*/

           double IsoWithEA = analysisTree.electron_r03_sumChargedHadronPt[iev] 
			   + max(analysisTree.electron_r03_sumNeutralHadronEt[iev] + analysisTree.electron_r03_sumPhotonEt[iev]
		           - 0.5 * analysisTree.electron_r03_sumPUPt[iev], 0.0) ;

           double relIsoV = IsoWithEA/analysisTree.electron_pt[iev];


	    bool electronMvaId = electronMvaIdWP90(analysisTree.electron_pt[iev], analysisTree.electron_superclusterEta[iev], analysisTree.electron_mva_id_nontrigPhys14[iev]);


	    if ( iev != el_index && analysisTree.electron_pt[iev] > 10 &&  fabs(analysisTree.electron_eta[iev]) < 2.5 && fabs(analysisTree.electron_dxy[iev])<0.045
		 && fabs(analysisTree.electron_dz[iev]) < 0.2 && relIsoV< 0.3 && electronMvaId && analysisTree.electron_pass_conversion[iev] 
		 && analysisTree.electron_nmissinginnerhits[iev] <=1) ThirdLeptVeto=true;

	  }
	}


     	if (analysisTree.muon_count>0){
	  for (unsigned int imvv = 0; imvv<analysisTree.muon_count; ++imvv) {

	    //       if ( imvv != mu_index  && analysisTree.muon_charge[imvv] != analysisTree.muon_charge[mu_index] ){

         double absIso= analysisTree.muon_r03_sumChargedHadronPt[imvv]
	            + max(analysisTree.muon_r03_sumNeutralHadronEt[imvv] + analysisTree.muon_r03_sumPhotonEt[imvv]
	            - 0.5 * analysisTree.muon_r03_sumPUPt[imvv],0.0);

	double relIso = absIso/analysisTree.muon_pt[imvv];


	    if ( imvv != mu_index &&  analysisTree.muon_isMedium[imvv] &&  analysisTree.muon_pt[imvv]> 10 &&  fabs(analysisTree.muon_eta[imvv])< 2.4 && fabs(analysisTree.muon_dxy[imvv])<0.045 
		 && fabs(analysisTree.muon_dz[imvv] < 0.2 && relIso< 0.3 && analysisTree.muon_isMedium[imvv]) ) ThirdLeptVeto=true;
	  }
	}
      }
  
      if (ThirdLeptVeto) continue;


      if(fillplots)
      FillMainHists(iCut, weight, ElMV, MuMV, TauMV,JetsMV,METV, ChiMass,mIntermediate,analysisTree, Channel, mu_index,el_index,tau_index);
      CFCounter[iCut]+= weight;
      iCFCounter[iCut]++;
      iCut++;

	if (!isData && applyLeptonSF) {

	//leptonSFweight = SF_yourScaleFactor->get_ScaleFactor(pt, eta)	
	  double ptMu1 = (double)analysisTree.muon_pt[mu_index];
	  double etaMu1 = (double)analysisTree.muon_eta[mu_index];
	  double IdIsoSF_mu1 = SF_muonIdIso->get_ScaleFactor(ptMu1, etaMu1);

	
	  MuSF_IdIso_Mu1H->Fill(IdIsoSF_mu1);
	  weight = weight*IdIsoSF_mu1;
	}
      if(fillplots)
      FillMainHists(iCut, weight, ElMV, MuMV, TauMV,JetsMV,METV, ChiMass,mIntermediate,analysisTree, Channel, mu_index,el_index,tau_index);
      CFCounter[iCut]+= weight;
      iCFCounter[iCut]++;
      iCut++;



       TLorentzVector muVc ;  muVc.SetPtEtaPhiM(analysisTree.muon_pt[mu_index], analysisTree.muon_eta[mu_index], analysisTree.muon_phi[mu_index], muonMass);
       TLorentzVector tauVc;  tauVc.SetPtEtaPhiM(analysisTree.tau_pt[tau_index], analysisTree.tau_eta[tau_index], analysisTree.tau_phi[tau_index], tauMass);
       double MTv = mT(muVc,METV);

	if (!isData && applyTFR) {

	//leptonSFweight = SF_yourScaleFactor->get_ScaleFactor(pt, eta)	

	  double ptTau1 = (double)analysisTree.tau_pt[tau_index];
	  double etaTau1 = (double)analysisTree.tau_eta[tau_index];
	  double TFRSF_mu1 = SF_TFR->get_ScaleFactor(ptTau1, etaTau1);
	
	  MuSF_IdIso_Mu1H->Fill(TFRSF_mu1);
	  weight = weight*TFRSF_mu1;
	  //cout<<"  "<<TFRSF_mu1<<"  for  eta  "<<etaTau1<<  " pT  "<< ptTau1<<endl;
	}

      if(fillplots)
      FillMainHists(iCut, weight, ElMV, MuMV, TauMV,JetsMV,METV, ChiMass,mIntermediate,analysisTree, Channel, mu_index,el_index,tau_index);
      CFCounter[iCut]+= weight;
      iCFCounter[iCut]++;
      iCut++;

	
	 if (!isData && ( string::npos != filen.find("TTJets")  || string::npos != filen.find("TTPowHeg")) )
	 //if (!isData )
	 	{
	
	if (topPt>0.&&antitopPt>0.) {
	  float topptweight = topPtWeight(topPt,antitopPt);
	//  cout<<"  "<<topPt<<"  "<<antitopPt<<endl;
		weight *= topptweight;
			}

		}

      if(fillplots)
      FillMainHists(iCut, weight, ElMV, MuMV, TauMV,JetsMV,METV, ChiMass,mIntermediate,analysisTree, Channel, mu_index,el_index,tau_index);
      CFCounter[iCut]+= weight;
      iCFCounter[iCut]++;
      iCut++;

      if (MTv<60 ) continue;
      if(fillplots)
      FillMainHists(iCut, weight, ElMV, MuMV, TauMV,JetsMV,METV, ChiMass,mIntermediate,analysisTree, Channel, mu_index,el_index,tau_index);
      CFCounter[iCut]+= weight;
      iCFCounter[iCut]++;
      iCut++;


      //	for (unsigned int j=0;j<LeptMV.size();++j) cout<<" j "<<j<<"  "<<LeptMV.at(j).Pt()<<endl;
      //	cout<<""<<endl;
      ////////jets cleaning 
      vector<int> jets; jets.clear();
      TLorentzVector leptonsV, muonJ, jetsLV;
      
      //      continue;
      
      //JetsV.SetPxPyPzE(analysisTree.pfjet_px[ij], analysisTree.pfjet_py[ij], analysisTree.pfjet_pz[ij], analysisTree.pfjet_e[ij]);
      


      //double ETmiss = TMath::Sqrt(analysisTree.pfmet_ex*analysisTree.pfmet_ex + analysisTree.pfmet_ey*analysisTree.pfmet_ey);
      double ETmiss = METV.Pt();//TMath::Sqrt(analysisTree.pfmet_ex*analysisTree.pfmet_ex + analysisTree.pfmet_ey*analysisTree.pfmet_ey);
      
      if (InvertMET && ETmiss > 100. ) continue;
      if (!InvertMET && ETmiss < 100. ) continue;  //that is the nominal selection ie MET > 100


      if(fillplots)
      FillMainHists(iCut, weight, ElMV, MuMV, TauMV,JetsMV,METV, ChiMass,mIntermediate,analysisTree, Channel, mu_index,el_index,tau_index);
      CFCounter[iCut]+= weight;
      iCFCounter[iCut]++;
      iCut++;


      double ptScalarSum = -1;


      bool btagged= false;
      
    
      		JetsMV.clear();

		float jetEtaCut = 2.4;
      		float DRmax = 0.5;
		int countjets = 0;
	      for (unsigned int jet=0; jet<analysisTree.pfjet_count; ++jet) {
		float absJetEta = fabs(analysisTree.pfjet_eta[jet]);
	
		if (absJetEta > etaJetCut) continue;
                if (fabs(analysisTree.pfjet_pt[jet])<ptJetCut) continue;
	  

	  	//double Dr= deltaR(LeptMV.at(il).Eta(), LeptMV.at(il).Phi(),
	  

		bool isPFJetId = false ; 
		isPFJetId =looseJetiD(analysisTree,jet);

		
		if (!isPFJetId) continue;
		
		//for (unsigned int lep=0;LeptMV.size();lep++){
		//double Dr=(LeptMV.at(lep).Eta(),LeptMV.at(lep).Phi(),
		double Dr=deltaR(analysisTree.muon_eta[mu_index],analysisTree.muon_phi[mu_index],
				analysisTree.pfjet_eta[jet],analysisTree.pfjet_phi[jet]);
		if (  Dr  < DRmax)  continue;

		double Drr=deltaR(analysisTree.tau_eta[tau_index],analysisTree.tau_phi[tau_index],
				analysisTree.pfjet_eta[jet],analysisTree.pfjet_phi[jet]);
		if (  Drr  < DRmax)  continue;


		if (analysisTree.pfjet_btag[jet][0]  > bTag) btagged = true;
		JetsV.SetPxPyPzE(analysisTree.pfjet_px[jet], analysisTree.pfjet_py[jet], analysisTree.pfjet_pz[jet], analysisTree.pfjet_e[jet]);
		JetsMV.push_back(JetsV);
		countjets++;
	      }	 

      if (countjets >2 ) continue;
      if(fillplots)
      FillMainHists(iCut, weight, ElMV, MuMV, TauMV,JetsMV,METV, ChiMass,mIntermediate,analysisTree, Channel, mu_index,el_index,tau_index);
      CFCounter[iCut]+= weight;
      iCFCounter[iCut]++;
      iCut++;

      if (btagged ) continue;
	
      if(fillplots)
      FillMainHists(iCut, weight, ElMV, MuMV, TauMV,JetsMV,METV, ChiMass,mIntermediate,analysisTree, Channel, mu_index,el_index,tau_index);
      CFCounter[iCut]+= weight;
      iCFCounter[iCut]++;
      iCut++;
  
  
      // pt Scalar

      //cout<<"  "<<mu_index<<"  "<<tau_index<<"   "<<MuMV.at(mu_index).M()<<"  "<<TauMV.at(tau_index).M()<<endl;


      TLorentzVector diL = muVc + tauVc;
      if ( diL.M() < 100 ) continue;
      if(fillplots)
      FillMainHists(iCut, weight, ElMV, MuMV, TauMV,JetsMV,METV, ChiMass,mIntermediate,analysisTree, Channel, mu_index,el_index,tau_index);
      CFCounter[iCut]+= weight;
      iCFCounter[iCut]++;
      iCut++;

       

     /* if (ETmiss < 100) continue;
      if (ETmiss < 120) continue;
      FillMainHists(iCut, weight, ElMV, MuMV, TauMV,JetsMV,METV, ChiMass,mIntermediate,analysisTree, Channel, mu_index,el_index,tau_index);
      CFCounter[iCut]+= weight;
      iCFCounter[iCut]++;
      iCut++;
      // topological cut
      //if (DZeta<dZetaCut) continue;
       */


      //double dRr = deltaR(diL.Eta(), diL.Phi(), METV.Eta(), METV.Phi());
            double dRr = deltaR(muVc.Eta(), muVc.Phi(), tauVc.Eta(), tauVc.Phi());

      if (dRr>3 ) continue;
      
      if(fillplots)
      FillMainHists(iCut, weight, ElMV, MuMV, TauMV,JetsMV,METV, ChiMass,mIntermediate,analysisTree, Channel, mu_index,el_index,tau_index);
      CFCounter[iCut]+= weight;
      iCFCounter[iCut]++;
      iCut++;
      FillTree();
      selEvents++;
    } // end of file processing (loop over events in one file)
  
	

    nFiles++;
    delete _tree;
    file_->Close();
    delete file_;
  }
  cout<<"done"<<endl;
	
  cout<<" Total events  "<<nEvents<<"  Will use weight  "<<histWeightsH->GetSumOfWeights()<<" Norm Factor for a Lumi of "<<Lumi<<"/pb is "<<XSec*Lumi/( histWeightsH->GetSumOfWeights())<<endl;
  cout<<" First content "<<CFCounter[0]<<endl;
  cout<<" Run range from -----> "<<RunMin<<" to  "<<RunMax<<endl;
  /*
    for (int i=0;i<CutNumb;++i){
    CFCounter[i] *= double(XSec*Lumi/( histWeights->GetSumOfWeights()));
    if (iCFCounter[i] <0.2) statUnc[i] =0;
    else statUnc[i] = CFCounter[i]/sqrt(iCFCounter[i]);
    }
  */
  //write out cutflow
  ofstream tfile;
  // TString outname = argv[argc-1];
  TString outname=argv[2];
  TString textfilename = "cutflow_"+outname+"_"+Channel+"_"+argv[3]+".txt";
//  tfile.open(textfilename);
//  tfile << "########################################" << endl;
  for(int ci = 0; ci < CutNumb; ci++)
    {
     // tfile << CutList[ci]<<"\t & \t"
//	    << CFCounter[ci]  <<"\t & \t"<< statUnc[ci] <<"\t & \t"<< iCFCounter[ci] << endl;
   
      CutFlowUnW->SetBinContent(1+ci,0);
      CutFlow->SetBinContent(1+ci,0);
      CutFlowUnW->SetBinContent(1+ci,float(CFCounter[ci]) );
  

      CFCounter[ci] *= double(XSec*Lumi/( histWeightsH->GetSumOfWeights()));
     
      CutFlow->SetBinContent(1+ci,float(CFCounter[ci]));
      
      cout << " i "<<ci<<" "<<iCFCounter[ci]<<"  "<<XSec*Lumi/( histWeightsH->GetSumOfWeights())<<"  "<<CutFlowUnW->GetBinContent(1+ci)<<"  "<<CutFlow->GetBinContent(1+ci)<<endl;   
      if (iCFCounter[ci] <0.2) statUnc[ci] =0;
    //else statUnc[i] = CFCounter[i]/sqrt(iCFCounter[i]);
    else statUnc[ci] = sqrt(CFCounter[ci]);
  }
  //ofstream tfile1;
  //TString textfile_Con = "CMG_cutflow_Con_Mu_"+outname+".txt";
  //tfile1.open(textfile_Con);
  //tfile1 << "########################################" << endl;



  //tfile << "Cut efficiency numbers:" << endl;

  //    tfile << " Cut "<<"\t & \t"<<"#Evnts for "<<Lumi/1000<<" fb-1 & \t"<<" Uncertainty \t"<<" cnt\t"<<endl;

 // tfile.close();



  std::cout << std::endl;
  int allEvents = int(inputEventsH->GetEntries());
  std::cout << "Total number of input events    = " << allEvents << std::endl;
  std::cout << "Total number of events in Tree  = " << nEvents << std::endl;
  std::cout << "Total number of selected events = " << selEvents << std::endl;
  std::cout << std::endl;
  

  file->cd(Channel.c_str());
  WriteTree();
  hxsec->Fill(XSec);
  hxsec->Write();
  inputEventsH->Write();
  histWeightsH->Write();
  histRuns->Write();
  CutFlowUnW->Write();
  CutFlow->Write();
  MuSF_IdIso_Mu1H->Write();
  file->Write();
  file->Close();
   
  delete file;
  
}