Example #1
0
int main( int argc ,char *argv[] ){
  
  DataObject areas;
  areas.getDataFromFile("resources/static_resources/area_noise_CMSSW_IDS.txt",2);
  
  vector<double> rates;
  vector<double> valuesSilvia;
  map<string, double> areaMap;
  
  for (int i=1; i<= areas.getLenght(); i++){
    double area = atof(areas.getElementFromPropertyContainer(i,2).c_str());
    string roll = areas.getElementFromPropertyContainer(i,1);
    areaMap[roll] = area;
  }
  
  //Create a new Acquisition Registry
  TFile* contFile = TFile::Open("Container20062011.root");
  Acquisition Run2011(contFile);
  
  /*  ifstream json("./jsonFilesMu/Cert_160404-167913_7TeV_PromptReco_Collisions11_JSON_MuonPhys.txt");
      Run2011.LoadJSON(json);*/

    
  DataObject runFilter;
  int nColoumnsFilter = 6;
  int filterCol = 1;
  runFilter.getFastDataFromFile("./resources/Extensions/2011/replotmuondpg/tot_RE+3_2_10_2011.txt",nColoumnsFilter);
  for (int i=1; i<= runFilter.getLenght(); i++){
    valuesSilvia.push_back(atof(runFilter.getElementFromPropertyContainer(i,6).c_str()));
  }
  
  
  Run2011.LoadSelectionByDO(&runFilter, filterCol);
  
  //Run2011.PrintValidRuns();
  
  TFile* f = new TFile("Outputs/OutputFile.root", "RECREATE");
  TH2F* plot = new TH2F("RateVsLumi", "Rate Vs Lumi", 2000, 0, 2000, 100, 0, 10);
  
  plot->SetMarkerStyle(21);
  contFile->Close();
  
  int n=0; 
  int nSkip = 100;

  
  while (Run2011.hasNext()){
    
    n++;
    double NormalizedRate = 0;
    
    Run* currentRun = Run2011.next();
    //check on Runs
    //    if (n <= nSkip) continue;
    
    //otherwise no directories
    contFile = TFile::Open("Container20062011.root");
    currentRun->FillFromContainer(contFile, areaMap);
    contFile->Close();
    
    if (currentRun->getID() > 163869) break; //163869
    if (!Run2011.isValid(currentRun)) continue;
    
    //    cout << "continue on: " << currentRun->getID() << endl;
    double TotRate = 0;
    double TotArea = 0;
    int totAmount = 0;
    int k=0;    
    if (currentRun->isFilled() == true){
      
      const map<string,ExRoll* > barrelMap = currentRun->GetBarrel();
      
      for (map<string,ExRoll* >::const_iterator it = barrelMap.begin(); it != barrelMap.end(); it++){
	
	/*
	//Typical selection for Endcap
	//like RE+3_2_10
       	if (atoi(it->second->getRollID().c_str()) != 10) continue;
	if (it->second->getSector() != 2) continue;
	if (it->second->getWheel_Disk_Number() != 3) continue;
	*/

	
	//Typical selection for Barrel
	//like tot_W+1_RB4_04
	if (it->second->getWheel_Disk_Number() != 2) continue;
	if (it->second->getRollID() != "RB2in") continue;
	if (it->second->getSector() != 4) continue;
//	if ( it->second->getOptionalRollID().compare("F") ) continue;
//	cout << "SEC " << it->second->getSector()  << endl;
	cout << "OPT: " << it->second-> getOptionalRollID() << endl;
	cout << "PASS: "******" "
	     << currentRun->getLumi() << " "
	     <<  "; rate: " << TotRate << "; area: "
	     << TotArea << "; norm: " 
	     << NormalizedRate << endl;

 	plot->Fill(currentRun->getLumi(), NormalizedRate);
	k++;
      }
    }
  }
  
    
  f->WriteObject(plot, "Plot");
  
  return 0;
}
Example #2
0
int main( int argc ,char *argv[] ){
  
  DataObject areas;
  areas.getDataFromFile("resources/static_resources/area_noise_CMSSW_IDS.txt",2);
  
  map<string, double> areaMap;
  
  for (int i=1; i<= areas.getLenght(); i++){
    double area = atof(areas.getElementFromPropertyContainer(i,2).c_str());
    string roll = areas.getElementFromPropertyContainer(i,1);
    areaMap[roll] = area;
  }

  //Syntax:
  //EndCap RE(WDN)_SECTOR_RID
  //Barrel W(WDN)_RID_SECTOR

  if (argc < 5) {
    
    cout << "Usage: " << argv[0] << " Zone Wheel Sector RollID [OutFile]" << endl;
    cout << endl;
    cout << "  Conventions:"<< endl;
    cout << "    Barrel: W(WDN)_RID_SECTOR" << endl;
    cout << "    EndCap: RE(WDN)_SECTOR_RID" << endl;
    cout << endl;
    return 0;
  }
  bool corrected = true;
  /*  string zone = "EndCapPlus";
  string RollID = "10";
  int Sector = 2;
  int WheelDiskNo = 2;
  */

  string zone = argv[1];                                                                                                                                                  
  string RollID = argv[4]; 
  int Sector = atoi(argv[3]);                                                                                                                                          
  int WheelDiskNo = atoi(argv[2]);                                                                                                                                                            
  string optionalID = argv[5];

  string ContainerName = "ContainerRun2011.root";
  string jsonFile = "./jsonFilesMu/Cert_160404-180252_7TeV_PromptReco_Collisions11_JSON.txt";
  //Create a new Acquisition Registry

  TFile* contFile = TFile::Open( ContainerName.c_str() );
  
	Acquisition Run2011(contFile);
/*	ifstream json(jsonFile.c_str());
	Run2011.LoadJSON(json);*/


  DataObject filterRun;
  filterRun.getDataFromFile("filters/moreThan100.csv",1);  
  Run2011.LoadSelectionByDO(&filterRun, 1);

      TFile* f;
      if (argc >= 6){
	f = new TFile(argv[6], "RECREATE");
          cout << "Writing results on: " << argv[6] << endl;
}
      else{
	f = new TFile("Outputs/OutputFile.root", "RECREATE");
	cout << "Writing results on: Outputs/OutputFile.root"  << endl;
}

  TGraph* plot = new TGraph();
  TGraph* plotRun = new TGraph();

  plot->SetName("RateVsLumi");
  plotRun->SetName("RateVsRun");

  plot->SetMarkerStyle(21);
  contFile->Close();
    int k=0;    
    int emptyStrip = 0;

	cout << "Analysis of: " << zone << " - Wheel/Disk No." << WheelDiskNo << " ; Sector: " << Sector << " ; ID:" << RollID << endl;
	cout << "Correction activated: " << corrected<< endl;
	cout << "Dataset: " << ContainerName << endl;
	cout << "JSON File: " << jsonFile << endl;

// Run2011.PrintValidRuns();
  cout << "Number of runs: " << Run2011.numberOfRuns() << endl;
  while (Run2011.hasNext()){
    
    double NormalizedRate = 0;
    
    Run* currentRun = Run2011.next();

    //run selection
//    if ( currentRun->getID() > 163289 && currentRun->getID() < 163340 ) continue;
//    if (currentRun->getID() < 170000) continue;
//    if (currentRun->getLumiSection() < 100) continue;
//    if (currentRun->getID() < 178420) continue;
    if (!Run2011.isValid(currentRun, false)) continue;
    
    //Filling
      contFile = TFile::Open( ContainerName.c_str() );

    currentRun->FillFromContainer(contFile, areaMap);

        
    double TotRate = 0;
    double TotArea = 0;
    int totAmount = 0;
    if (currentRun->isFilled() == false){
	cout << "Not filled: " << currentRun->getID() << endl;
    }
    if (currentRun->isFilled() == true){

      map<string,ExRoll* > barrelMap;

      if (zone == "Barrel")
	barrelMap = currentRun->GetBarrel();

      else if (zone == "EndCapPlus")
	barrelMap = currentRun->GetEndCapPlus();

      else if (zone == "EndCapMinus")
	barrelMap = currentRun->GetEndCapMinus();

      for (map<string,ExRoll* >::const_iterator it = barrelMap.begin(); it != barrelMap.end(); it++){

	if (RollID != "-9")
	  if (it->second->getRollID().c_str() != RollID) continue;

	if (Sector != -9)
	  if (it->second->getSector() != Sector) continue;

	if (WheelDiskNo != -9)
	  if (it->second->getWheel_Disk_Number() != WheelDiskNo) continue;

	//When we will decide to plot partition by partition
	if (optionalID != "-9"){
//	cout << optionalID << endl;
//	cout << it->second->getOptionalRollID() << endl;
                if ( it->second->getOptionalRollID().compare(optionalID) ) continue;
	}

      
        emptyStrip += it->second->getEmptyStrip();
//	if ( it->second->getOptionalRollID().compare("B") ) continue;
//	cout << "SEC " << it->second->getSector()  << endl;
/*	cout << "OPT: " << it->second-> getOptionalRollID() << endl;
	cout << "RAW: " << it->second->getRawIDofClone(1) << endl;*/
//	cout << "PASS: "******"VALUE: " << nAnalyzer.HealCloneByClone(it->second) << endl;
        double rollArea = it->second->getRollArea();
        TotArea += rollArea;	
      }

      //Free RAM
      for (map<string,ExRoll* >::const_iterator it = barrelMap.begin(); it != barrelMap.end(); it++){
	delete it->second;
      }

      double NormalizedRate = TotRate / TotArea;
//       cout << NormalizedRate << endl;	      
  string zone = argv[1];                                                                                                                                                  
  string RollID = argv[4]; 
  int Sector = atoi(argv[3]);                                                                                                                                          
  int WheelDiskNo = atoi(argv[2]);     


        if (TotRate != 0 && TotArea != 0 && currentRun->getDelivered() != 0 && currentRun->isFilled()){
//	currentRun->PrintStatistics();	
             
             cout << currentRun->getID() <<
	     "\t" << currentRun->getLumiSection() << "\t" << currentRun->getDelivered() 
	     << "\t" << currentRun->getLumi() <<
	     "\t" << TotRate << "\t" << TotArea << "\t" << NormalizedRate/2 << endl;
		
// 	plot->SetBinContent(plot->FindBin(currentRun->getLumi()), NormalizedRate);
	cout << "POINT: " << k << " "  << currentRun->getLumi()<< " " << NormalizedRate / 2 << endl;; 
	plot->SetPoint(k , currentRun->getLumi(), NormalizedRate / 2);
	plotRun->SetPoint(k, currentRun->getID(), NormalizedRate / 2);
	k++;
	}
    }
    delete currentRun;
    contFile->Close();  
    contFile->Delete();
  }

  plot->SetDrawOption("P");
  f->WriteObject(plotRun, plotRun->GetName());
  f->WriteObject(plot, plot->GetName());

  
  return 0;
}
Example #3
0
int main(int argc, char** argv){

  if (argc < 5) {
	cout << "Usage: " << argv[0] << "SubDet RunNumber Wheel RID PartitionName [OutFile]" << endl;
	return 0;
  }
  
  string RollID = string(argv[4]);
  int WheelDiskNo = atoi(argv[3]);
  int runNumber = atoi(argv[2]);
  string subDet = argv[1];
  int partitionNumber = atoi(argv[5]);
  cout << "You're asking partition " << partitionNumber << endl;
  string ContainerName ="ContainerRun2011.root";
  //Load area map
  DataObject areas;
  areas.getDataFromFile("resources/static_resources/area_noise_CMSSW_IDS.txt",2);

  map<string, double> areaMap;

  for (int i=1; i<= areas.getLenght(); i++){
    double area = atof(areas.getElementFromPropertyContainer(i,2).c_str());
    string roll = areas.getElementFromPropertyContainer(i,1);
    areaMap[roll] = area;
  }

  TFile* contFile = TFile::Open(ContainerName.c_str());
  Acquisition Run2011(contFile);

  
  
  //  map<string, TGraph*> RollIDs;
  map<string, TGraph*> RollIDs;
  
  TFile* f;
  
  if (argc >= 7)
    f = new TFile(argv[6], "RECREATE");
  else
    f = new TFile("Outputs/OutputPlotOnPhiVR.root", "RECREATE");
  
  //  TGraph* plot = new TGraph();
  TGraph* plot = new TGraph();
  plot->SetName("RateVsPhi");
  
  //Load Run
  Run* currentRun = Run2011.getRunById(runNumber) ;
  
  contFile = TFile::Open(ContainerName.c_str());
  currentRun->FillFromContainer(contFile, areaMap);
  contFile->Close();
  currentRun->PrintStatistics();
  
  map<string,ExRoll* > Rolls; 
  vector<TGraph*> vPlot;
  int minSector = 1;
  int nSector;
  int emptyStrip = 0;
  int runIndex = -1;  

  
  cout << "Loading Sectors..." << endl;
  
  //Filling Plots
  if (subDet == "Barrel"){
    
    RollIDs["RB1in"] = new TGraph();
    RollIDs["RB2in"] = new TGraph();
    RollIDs["RB1out"] = new TGraph();
    RollIDs["RB2out"] = new TGraph();
    RollIDs["RB3"] = new TGraph();
    RollIDs["RB4"] = new TGraph();
    nSector = 12;
    Rolls = currentRun->GetBarrel();
  }
  
  else if (subDet == "EndCapPlus"){
    
    RollIDs["2"] = new TGraph();
    RollIDs["3"] = new TGraph();
    nSector = 36;
    
    Rolls = currentRun->GetEndCapPlus();
  }
  
  else if (subDet == "EndCapMinus"){
    
    RollIDs["2"] = new TGraph();
    RollIDs["3"] = new TGraph();
    nSector = 36;
    
    Rolls = currentRun->GetEndCapMinus();
  }
  
  //Filling                                                                                                         
  contFile = TFile::Open( ContainerName.c_str() );
  
  cout << "Begin Loop" << endl;  
  for (map<string, TGraph*>::const_iterator itRoll = RollIDs.begin(); itRoll != RollIDs.end(); itRoll++){
    int nPoint = 0;
  bool setSize = false;    
    string name;
    
    if (subDet == "Barrel")
      name = "Barrel_" + itRoll->first;
    else if (subDet == "EndCapPlus" || subDet == "EndCapMinus")
      name = "EndCap_" + itRoll->first;
    
    itRoll->second->SetName(name.c_str());


 
  for (int iSector = minSector; iSector <= nSector; iSector++){
    
    double TotRate = 0;
    double TotArea = 0;
    
    
    for (map<string,ExRoll* >::const_iterator it = Rolls.begin(); it != Rolls.end(); it++){

      string th1path = it->second->getTH1Path();
      
      if (subDet == "Barrel"){
	string opt1 = "F";
	string opt2 = "+F";
	string opt3 = "-F";

	if (it->second->getSector() != iSector) continue;     
	
	if (it->second->getRollID() != itRoll->first) continue;      
	

	if (WheelDiskNo != -9)
	  if (it->second->getWheel_Disk_Number() != WheelDiskNo) continue;

	if (it->second->getOptionalRollID().find(opt1) == string::npos && it->second->getOptionalRollID().find(opt2) == string::npos) {
		 continue;
	}	
	if (it->second->getOptionalRollID().find(opt3) != string::npos){
		continue;
	}	
	
	
      }
      
      else if (subDet == "EndCapPlus" || subDet == "EndCapMinus"){
	
	if (atoi(it->second->getRollID().c_str()) != iSector) continue;
        
	if (it->second->getSector() != atoi(itRoll->first.c_str())) continue;
	
	if (WheelDiskNo != -9)
	  if (it->second->getWheel_Disk_Number() != WheelDiskNo) continue;
      }
      int nClones = it->second->getClones();
      emptyStrip += it->second->getEmptyStrip();

      TH1F* histo = (TH1F*)(contFile->Get(th1path.c_str()));

      int cNumber = partitionNumber;
      if (partitionNumber > nClones-1) continue;
      cout << "This roll has " << nClones << endl;
      double TotRate = 0;
      double TotArea = 0;
      int cEffectiveNumber =  cNumber + 1;
      
      NoiseAnalyzer nAnalyzer;
      TH1F* cHisto = it->second->getRateHistoForClone(histo, cEffectiveNumber);
      TotRate = nAnalyzer.HealClone(it->second, cHisto, cEffectiveNumber);
      double cloneArea = it->second->getCloneArea(cNumber);
      TotArea += cloneArea;
     
      double NormalizedRate = (TotRate / TotArea);
      itRoll->second->SetPoint(nPoint, (iSector-1)*6.28/(double)nSector, NormalizedRate/2);
      cout << "\t\tPOINT: " << nPoint << " " << (iSector-1)*6.28/(double)nSector << " " << NormalizedRate/2 << endl;
      nPoint++;
    }
  }  
  }


  for (map<string, TGraph*>::const_iterator it = RollIDs.begin(); it != RollIDs.end(); it++)
    f->WriteObject( it->second, it->second->GetName() );
  
  f->Close();
  return 0;
}
Example #4
0
int main( int argc ,char *argv[] ){
  
  DataObject areas;
  areas.getDataFromFile("resources/static_resources/area_noise_CMSSW_IDS.txt",2);

  map<string, double> areaMap;
  
  for (int i=1; i<= areas.getLenght(); i++){
    double area = atof(areas.getElementFromPropertyContainer(i,2).c_str());
    string roll = areas.getElementFromPropertyContainer(i,1);
    areaMap[roll] = area;
  }

  //Create a new Acquisition Registry
  TFile* contFile = TFile::Open("Container.root");
  Acquisition Run2011(contFile);
  TFile* f = new TFile("OutputFile.root", "RECREATE");
  TH2F* plot = new TH2F("RateVsLumi", "Rate Vs Lumi", 2000, 0, 2000, 100, 0, 100);
  contFile->Close();
  while (Run2011.hasNext()){

    double NormalizedRate = 0;

    Run* currentRun = Run2011.next();
    //otherwise no directories
    contFile = TFile::Open("Container.root");
    currentRun->FillFromContainer(contFile, areaMap);
    contFile->Close();

    double TotRate = 0;
    double TotArea = 0;
    int totAmount = 0;

    if (currentRun->isFilled() == true){

      const map<string,ExRoll* > barrelMap = currentRun->GetBarrel();

      for (map<string,ExRoll* >::const_iterator it = barrelMap.begin(); it != barrelMap.end(); it++){

       //Roll Rate
        for (int k=1; k<=96; k++){
          ExStrip * strip = it->second->getStrip(k);
          TotRate = TotRate + strip->getRate();
       	}

      	//Roll Area
        double rollArea = it->second->getRollArea();
        TotArea = TotArea + rollArea;
      }
      double NormalizedRate = TotRate / TotArea;

      if (TotRate != 0 && currentRun->getDelivered() != 0 ){
        cout << currentRun->getID() << " " << currentRun->getLumi() << " " << TotRate << " " << TotArea << " " << NormalizedRate <<endl;
 	plot->Fill(currentRun->getLumi(), NormalizedRate);
	cout  << currentRun->getLumi() << " " << NormalizedRate << endl; 
  }
    }
  }
  f->WriteObject(plot, "Plot");
  return 0;
}