CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
TreeDump.cc File Reference
#include <cstdlib>
#include <TH1F.h>
#include <TROOT.h>
#include <TFile.h>
#include <TSystem.h>
#include <sstream>
#include <fstream>
#include "FWCore/FWLite/interface/FWLiteEnabler.h"
#include "MuonAnalysis/MomentumScaleCalibration/interface/RootTreeHandler.h"

Go to the source code of this file.

Functions

lorentzVector fromPtEtaPhiToPxPyPz (const double *ptEtaPhiE)
 
int main (int argc, char *argv[])
 

Function Documentation

lorentzVector fromPtEtaPhiToPxPyPz ( const double *  ptEtaPhiE)

Dumps the content of a tree to a local TreeDump.txt file.
The txt file contains one pair per row and the values are:

  • for genInfo = 0
    pt1 eta1 phi1 pt2 eta2 phi2
  • for genInfo != 0
    pt1 eta1 phi1 pt2 eta2 phi2 genPt1 genEta1 genPhi1 genPt2 genEta2 genPhi2.

Definition at line 24 of file TreeDump.cc.

References funct::cos(), funct::exp(), fastsim::Constants::muMass, funct::sin(), mathSSE::sqrt(), and createJobs::tmp.

Referenced by main().

24  {
25  double muMass = 0.105658;
26  double px = ptEtaPhiE[0] * cos(ptEtaPhiE[2]);
27  double py = ptEtaPhiE[0] * sin(ptEtaPhiE[2]);
28  double tmp = 2 * atan(exp(-ptEtaPhiE[1]));
29  double pz = ptEtaPhiE[0] * cos(tmp) / sin(tmp);
30  double E = sqrt(px * px + py * py + pz * pz + muMass * muMass);
31 
32  return lorentzVector(px, py, pz, E);
33 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static double constexpr muMass
Muon mass [GeV].
Definition: Constants.h:14
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
reco::Particle::LorentzVector lorentzVector
Definition: GenMuonPair.h:9
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
tmp
align.sh
Definition: createJobs.py:716
int main ( int  argc,
char *  argv[] 
)

===============================================================================================================================================================================================


variant2: for each run define phi-averaged A for normalization channel (Dref,16) and then, divide Rijk on it, i.e. get RRijk

eta=27

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=19

eta=17

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=20

eta=19

eta=18

eta=27 L1=1

eta=25 L1=1

eta=23 L1=1

eta=22 L1=1

eta=21 L1=1

eta=29 L1=1

eta=26 L1=1

eta=24 L1=1

eta=20 L1=1

eta=19 L1=1

eta=18 L1=1

eta=17 L1=1

eta=28 L7=1

eta=27 L7=1

eta=25 L7=1

eta=23 L7=1

eta=22 L7=1

eta=21 L7=1

eta=26 L7=1

eta=24 L7=1

eta=20 L7=1

eta=19 L7=1

eta=18 L7=1

eta=17 L7=1

eta=27

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=19

eta=17

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=20

eta=19

eta=18

eta=27 L1=1

eta=25 L1=1

eta=23 L1=1

eta=22 L1=1

eta=21 L1=1

eta=26 L1=1

eta=24 L1=1

eta=20 L1=1

eta=19 L1=1

eta=18 L1=1

eta=17 L1=1

eta=28 L7=1

eta=27 L7=1

eta=25 L7=1

eta=23 L7=1

eta=22 L7=1

eta=21 L7=1

eta=26 L7=1

eta=24 L7=1

eta=20 L7=1

eta=19 L7=1

eta=18 L7=1

eta=17 L7=1

eta=27

eta=28

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

RBX:

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

RBX:

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

RBX:

Prepare maps of good/bad channels:

Prepare maps of good/bad channels:

Prepare maps of good/bad channels:

Prepare maps of good/bad channels:

Definition at line 35 of file TreeDump.cc.

References gather_cfg::cout, FWLiteEnabler::enable(), beamvalidation::exit(), MillePedeFileConverter_cfg::fileName, download_sqlite_cfg::outputFile, RootTreeHandler::readTree(), contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.

35  {
36  if (argc != 3) {
37  std::cout << "Please provide the name of the file (with file: or rfio: as needed) and if there is generator "
38  "information (0 is false)"
39  << std::endl;
40  exit(1);
41  }
43  if (fileName.find("file:") != 0 && fileName.find("rfio:") != 0) {
44  std::cout << "Please provide the name of the file with file: or rfio: as needed" << std::endl;
45  exit(1);
46  }
47  std::stringstream ss;
48  ss << argv[2];
49  bool genInfo = false;
50  ss >> genInfo;
51  std::cout << "Dumping tree with genInfo = " << genInfo << std::endl;
52 
53  // load framework libraries
54  gSystem->Load("libFWCoreFWLite");
56 
57  // open input file (can be located on castor)
58  TFile* inFile = TFile::Open(fileName.c_str());
59 
60  // MuonPairVector pairVector;
61  MuonPairVector pairVector;
62  MuonPairVector genPairVector;
63 
64  // Create the RootTreeHandler to save the events in the root tree
65  RootTreeHandler treeHandler;
66  // treeHandler.readTree(-1, fileName, &pairVector, &genPairVector);
67  std::vector<std::pair<unsigned int, unsigned long long> > evtRun;
68  treeHandler.readTree(-1, fileName, &pairVector, -20, &evtRun, &genPairVector);
69 
70  if ((pairVector.size() != genPairVector.size()) && genInfo) {
71  std::cout << "Error: the size of pairVector and genPairVector is different" << std::endl;
72  }
73 
74  std::ofstream outputFile;
75  outputFile.open("TreeDump.txt");
76 
77  MuonPairVector::const_iterator it = pairVector.begin();
78  MuonPairVector::const_iterator genIt = genPairVector.begin();
79  std::vector<std::pair<unsigned int, unsigned long long> >::iterator evtRunIt = evtRun.begin();
80  for (; it != pairVector.end(); ++it, ++genIt, ++evtRunIt) {
81  // Write the information to a txt file
82  outputFile << it->first.pt() << " " << it->first.eta() << " " << it->first.phi() << " " << it->second.pt() << " "
83  << it->second.eta() << " " << it->second.phi() << " ";
84  if (genInfo) {
85  outputFile << genIt->first.pt() << " " << genIt->first.eta() << " " << genIt->first.phi() << " "
86  << genIt->second.pt() << " " << genIt->second.eta() << " " << genIt->second.phi() << " ";
87  }
88  outputFile << " " << evtRunIt->first << " " << evtRunIt->second;
89  outputFile << std::endl;
90  }
91 
92  // size_t namePos = fileName.find_last_of("/");
93  // treeHandler.writeTree(("tree_"+fileName.substr(namePos+1, fileName.size())).c_str(), &pairVector);
94 
95  // close input and output files
96  inFile->Close();
97  outputFile.close();
98 
99  return 0;
100 }
void readTree(const int maxEvents, const TString &fileName, MuonPairVector *savedPair, const int muonType, std::vector< std::pair< unsigned int, unsigned long long > > *evtRun, MuonPairVector *genPair=nullptr)
static void enable()
enable automatic library loading
tuple argc
Definition: dir2webdir.py:39
std::vector< std::pair< lorentzVector, lorentzVector > > MuonPairVector
tuple cout
Definition: gather_cfg.py:144