Christopher Silkworth's Log Book

04-Jun-2010

Worked on some MC trigger rates

Used the formula from Trigger Team's TWiki page OpenHLT RateEff.

  • Worked on lxplus since cmslpc is too slow
  • Used CMSSW_3_5_7
  • Checked out V03_02_24 HLTrigger/HLTanalyzers/test

Problems

  • Was not able to run the Len's macro.
    • Lucie realized I did not have my grid certificate set up on lxplus.
    • Also realized I am not registered in the CMSVO. (although I thought I had done this already)
  • Put my grid certificate on lxplus, seems to be fine now. Submitted application for CMSVO and am now waiting on confirmation.

05-Jun-2010

Still no word from the CMSVO on registration. I assume that means I won't be hearing from them until Monday at the earliest.

The particle flow documentation

Very heavy on jargon, there are many words I need precisely defined:
  • Block
  • Seed
  • Cluster(in ECal)
  • Envelope
  • "Fake" tracks and other "fake" objects.
  • Pre-shower
Also don't understand a lot on page 7 of the documentation. Mostly this sentence fragment " tangents to the tracks are extrapolated to the ECAL". However I don't think this is of upstanding importance.

06-Jun-2010

PFAnalysis Tutorial

Went through the PFAnalysis Tutorial using CMSSW_3_5_6 on lxplus.

PFAnalysis work

Objective: Makes tranverse momentum plots of all particle flow particles. I first moved everything over to lxplus since lpc goes too slow.Also, Note: Must be working on slc5 in order for cmsenv to work in the nobackup space of cmslpc. Spent way too much time figuring that out. Several problems so far.
  1. The analyzer was not even running on the lpc, (where I had last used it)- I commented out all instances of my last added object (jets) and it worked just fine. I also repeated on lxplus
  2. When attempting to run the analyzer I get this error:

  
PFAnalyses/CommonTools/prod/patLayer1_fromAOD_PF2PAT_full.root does not exist
chrisAnalysis: /build/356/b/ia32/slc5_ia32_gcc434/external/boost/1.40.0-cms3/include/boost/smart_ptr/shared_ptr.hpp:418: T* boost::shared_ptr< <template-parameter-1-1> v>::operator->() const [with T = TFile]: Assertion `px != 0' failed. 

I attempted to change the data set in which the analyzer was analyzing to /MinimumBias/Commissioning10-May6thPDSkim2_SD_JetMETTau-v1/RECO, thinking that maybe the older data was not located at CERN but still got the same error. (Although this data may also not be at CERN).

07-Jun-2010

PFAnalysis work

Found out what the problem was from last night. The file patLayer1_fromAOD_PF2PAT_full.root was not there only patLayer1_fromAOD_PF2PAT_full_cfg.py . So I copied patLayer1_fromAOD_PF2PAT_full.root from cmslpc onto lxplus and now the code is working.
  • There were only 445 events in patLayer1_fromAOD_PF2PAT_full.root, so I attempted to create another .root file with more events using
cmsRun  patLayer1_fromAOD_PF2PAT_full_cfg.py
with a different set of datasets in the source file found in ../CommonTools/python/Sources/RD/RECO/source_MinimumBias_Commissioning10_PromptReco_v7_RECO_cff.py. But even though the process went through without error all 1000 events failed.

08-Jun-2010

PFAnalysis work

Was struggling with a segmentation violation throughout the day. The ChrisAnalysis code compiled just fine but when I ran it, there was a segmentation violation when I first attempted to fill a histogram with the leading electron's pt. Discovered that you must fist make sure there are electrons by if(sortedEles.empty()) {...} and if there is not any electrons then you return false so as to get out of the analyze loop. I assume this will be the same for the other PAT objects and will have to work around this problem in the future. Attempted to create files MuonHistograms.cc and JetHistograms.cc similar to the already created file ElectronHistograms.cc, however I discovered that this is much more involved than I had previously thought. So instead the histograms will all be of the type ChrisHistograms and I will just add to ChrisHistograms.cc.

CMSVO

Still not registered in the CMSVO even though I did this last week and have been waiting on a response since. I sent an email today but who knows how much longer I'll be tangled in this web of beauracracy.

09-Jun-2010

Finally am registered with the CMSVO. Met with Len to discuss my next trigger project. I took notes and they can be found here.

PFAnalysis work

I added Muon and Jet histograms to ChrisAnalysis.cc and it compiled and the code ran. I got a Pt histogram of the leading jets but still had no events with either electrons or muons. I attempted to make a patTuple that had more events and possibly some with electrons and muons but still have am either getting that all the events fail or that the when I do cmsRun pat.... I get an error and it doesn't run. I will have to come back to this after I have I am done with the trigger project.

Trigger work

Tried to go through the process that is located on Here but got a permission denied when I tried to run:
* ./OHltRateEff hltmenu_4e29_2010March27.cfg
and it isn't because I'm not registered in the CMSVO because I did voms-proxy-init -voms cms and it went through without error. - turns out the "*" wasn't supposed to be there, just started over with the "head version of HLTrigger/... i.e. cvs co HLTrigger/HLTanalyzers/test and got rid of the "*" and it all worked fine.

14-Jun-2010

Trigger work

Have confidence in ability to run trigger rate tests, I moved on to cpu timing tests. I have gone through some of the process found here. Although my familiarity with python is minute and don't have that great of a feel with what I'm actually doing. I picked a trigger menu essentially at random found from confDB : /cdaq/physics/firstCollisions09/v1.9/HLT/V2. Ran into a problem trying cmsRun offline_data.py. got this error:
%MSG-s CMSException:  14-Jun-2010 15:48:03 CEST pre-events
cms::Exception caught in cmsRun
---- Configuration BEGIN
Error occurred while creating SiStripGainESProducer
---- Configuration BEGIN
MissingParameter: VParameterSet 'APVGain' not found.
---- Configuration END
---- Configuration END


%MSG
%MSG-s CMSException:  14-Jun-2010 15:48:03 CEST pre-events
cms::Exception caught in cmsRun
---- Configuration BEGIN
Error occurred while creating SiStripGainESProducer
---- Configuration BEGIN
MissingParameter: VParameterSet 'APVGain' not found.
---- Configuration END
---- Configuration END

I tried again with a different trigger menu and a different data set but got the same error.

16-Jun-2010

Trigger Work

After trying to figure out the exception all day yesterday, I finally got around it. - placed the timer, output module and the various hlt process definitions closer to the beginning of the file. However now I got another exception:
16-Jun-2010 11:26:26 CEST  Initiating request to open file rfio:/castor/cern.ch/cms/store/data/BeamCommissioning09/MinimumBias/RAW/v1/000/124/120/F6ADE109-6BE8-DE11-9680-000423D991D4.root
16-Jun-2010 11:26:26 CEST  Initiating request to open file rfio:/castor/cern.ch/cms/store/data/BeamCommissioning09/MinimumBias/RAW/v1/000/124/120/F6ADE109-6BE8-DE11-9680-000423D991D4.root
16-Jun-2010 11:26:32 CEST  Successfully opened file rfio:/castor/cern.ch/cms/store/data/BeamCommissioning09/MinimumBias/RAW/v1/000/124/120/F6ADE109-6BE8-DE11-9680-000423D991D4.root
16-Jun-2010 11:26:32 CEST  Successfully opened file rfio:/castor/cern.ch/cms/store/data/BeamCommissioning09/MinimumBias/RAW/v1/000/124/120/F6ADE109-6BE8-DE11-9680-000423D991D4.root
%MSG-s CMSException:  AfterModConstruction 16-Jun-2010 11:26:38 CEST pre-events
cms::Exception caught in cmsRun
---- Configuration BEGIN
Error occurred while creating HLTLevel1Activity with label hltBPTXCoincidence
---- Configuration BEGIN
MissingParameter: Parameter 'invert' not found.
---- Configuration END
---- Configuration END

Went to go see Len about it and he informed me that the CMSSW version, menu and dataset must all agree and there is not way to check this a priori. So we set up a CMSSW_3_5_8 and used the file rfio:///castor/cern.ch/cms/store/data/Run2010A/Commissioning/RAW/v1/000/137/028/FC471D54-1B71-DF11-ACB5-001D09F297EF.root (rfio:///castor/cern.ch/cms is important and won't work without it.). We used the menu /cdaq/physics/Run2010/v1.1/HLT_LowInt_2E29_L1MinbiasPrescale/V1 and it ran through fine. This is without all the additions into the file that the twiki has.

Note: Another common problem is that the global tags don't agree. To test this use the command

edmProvDump $DATASETNAME | grep -i globaltag 
and check to make sure that it agrees with the global tag in the offline_data.py file (its around line 330 )

22-Jun-2010

For whatever reason, it seems that the last few days of my log are not here and not in the back links. I don't know if I just never saved it or if there is something with Twiki but I seem to have lost them. So I will just repeat myself here on some things.

Mini Project

Rick gave me a mini project to do for what I will be doing for Yuri in the near future. Here is what he wrote:

(1) Use the fast simulation in CMSSW and produce two small simulated
data samples
   (1000 events each) of:
    (a) single photons (PDG ID 21)
    (b) single charged pions (PDG ID 211)
    (d) single K0_L's (PDG ID 130)

(2) For each of the above data samples, make the following plots:
   (a) 1-D histogram of all PFCandidate types in the event
   (b) 1-D histogram of the pT for all reconstructed photons (type 4)
   (c) 1-D histogram of the pT for all true photons in the event (PDG ID 21)
   (d) 1-D histogram of the Delta pT for all (reconstructed - true)
photons in the event
         To make this plot you will need to match the angles (eta,phi) of the
         reconstructed photon with the angles (eta,phi) of the true photon
   (e) 1-D histogram of the pT for all reconstructed charged hadrons (type 1)
   (f) 1-D histogram of the pT for all true charged pions in the
event (PDG ID 211)
   (g) 1-D histogram of the Delta pT for all (reconstructed - true)
charged pions in the event
   (h) 1-D histogram of the pT for all reconstructed neutral hadrons (type 5)
   (i) 1-D histogram of the pT for all true K0_Ls in the event (PDG ID 130)
   (j) 1-D histogram of the Delta pT for all (reconstructed - true)
K0_Ls in the event
So from my blank analyzer I started writing the analyzer for the above and did so with no compilation errors. As for the fast simulation I used as the input file, found in FastSimulation/Configure/test/Example_cfg.py and altered it so that as the file it took from the generator folder I put SingleGammaPt1000_cfi.py. I also changed the number of events to 1000 and ran Example_cfg.py with cmsRun and it created an output file SingleGammaPt1000.root which seems to be alright. However when running the analyzer I just made I get the cms:exception:
 what():  ---- ProductNotFound BEGIN
getByLabel: Found zero products matching all criteria
Looking for type: edm::Wrapper<std::vector<reco::PFCandidate> >
Looking for module label: particleFlow
Looking for productInstanceName: 

---- ProductNotFound END
Do tomorrow: Make the single charged pion and single K_0 files then run PF2PAT on all three .root files and the data will be complete. Then figure out this exception

23-Jun-2010

Mini Project

Used scratch0/CMSSW_3_6_1_patch2/src/PhysicsTools/PatAlgos/test/patTuple_PF2PAT_cfg.root to create the patTuple from SingleGammaPt1000.root into SingleGammaPt1000_PF2PAT.root.

28-Jun-2010

Once again it seems like a day has been delete or not saved. I don't know whats going on but I will just give a small recap here:

Trigger Work

I have written the code for a simple program that takes in as input a simple text file, then input from the user. From these it takes in a pathname and luminosity then spits out a rate along with errors for slope and for y-intercept (assumed to have a linear dependence). I wrote a class called Path that has contains five objects (path name, y-intercept, slope,y-intercept error, slope error) as well as several function. I also wrote a function reader which takes in a text file and puts all the data into a vector of Paths. reader also contains a simple function that changes a string to a double. We have yet to figure out a nice way of finding the error of any y.

05-Jul-2010

Master code

After the very tedious process of trying to compile the master code Frederic and I have finally succeeded. We had to change all the fortran compilers from g77 to gfortran44 ( Note: gfortran also doesn't work), include many more things like
 #include <cstring> 
and various other things. One important thing to remember is that anytime you want to compile the code again you must first:
  • cmsenv
  • setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH":"/afs/cern.ch/cms/sw/slc5_amd64_gcc434/external/gcc/4.3.4/lib64

Mini Project

Finally found out the problem that has been haunting me with this project for a very long time. Apparently when I was getting the exception:
---- ProductNotFound BEGIN
getByLabel: Found zero products matching all criteria
Looking for type: edm::Wrapper<std::vector<reco::PFCandidate> >
Looking for module label: selectedPatPFParticles
---- ProductNotFound END

The problem was that I was trying to read a PFCandidateCollection when there was only a PFParticle Collection. Artur suggested I use CMSSW_3_7_0_patch2 so I will rewrite everything in there.

11-Jul-2010

Particle Flow Photons

I'm making efficiency and fake rate plots for photons in the particle flow. I'm just using the fast simulation in CMSSW_3_7_0_patch2 to create 1000 event MC files of Single photons from pt=10,20,...1000. I first went into the file FastSimulation/Configure/test/Example_cfg.py and used Configure/Generator/python/SingleGammaPt10_cfi.py as it source. I changed the output file to SingleGammaPt10.root, and I changed it so that I only' kept genParticles and particleFlow. I have been changing the analyzer but something seems wrong. I'm getting many more reco photons then I am getting true photons.

19-Jul-2010

Particle Flow Photons

The full procedure is shown here for CMSSW_3_7_0_patch2. First you need to create a MC dataset using fast simulation, then PF2PAT is run on the data set and finally it is analyzed using ChrisAnalyzer:
  • Create the fast simulation dataset: cp SingleGammaPtQQQQQQ_cfg.py to some another file Where QQQQQQ is changed to specific pt. This is found in FastSimulation/Configuration/test/. Modify the file by replacing the QQQQQQ in your new file with your Pt you are trying to produce Note: The SingleGamma cfi file called in SingleGammaPt cfg file may not exist for your specific pt and you may have to create it. These files are located in Configuration/Generator/python/. cmsRun your cfg file and he output of this will be SingleGammaPtQQQQQQ.root where the QQQQQQ is replaced by your pt.
  • Run PF2PAT on the dataset:
Go into PhysicsTools/PatAlgos/test/ and cp SingleGammaPtQQQQQQ_PF2PAT_cfg.py to another file once again replacing the QQQQQQ with your specific pt. Once again modify the file by replacing the QQQQQQ with the pt you want. Note:The source cfi file may not exist for the pt you are looking for and you may have to create it. The files are location in PhysicsTools/PFCandProducer/python/Sources/.. cmsRun on this file, this will create another root file which will be called SingleGammaPtQQQQQQ_PF2PAT.root. Go to PFAnalyses/ChrisAnalysis/test and modify ChrisQQQQQQ_cfg.py to the right pt in both filename and in the file itself. When you run this do chrisAnalysis ChrisQQQQQQ_cfg.py and it will create an output file PFAnalysis_SingleGamma.root which will contain several histograms. Another .root file needs to exist called FakePlots.root and it needs to contain definitions of 6 histograms called by chrisAnalysis. If this file doesn't exist, before you run chrisAnalysis, run begin.C in root and it will create the necessary file.
  • One Step Method:
A script that does all of this for you exists in PFAnalyses/ChrisAnalysis/test/ called runpt10to1000.sh. You can modify it to go over a bunch of different pt or just one pt by messing with the variable i in the script. This will create, modify and then remove all the necessary cfg files (Fast Sim, PF2PAT, Chris) and root files (but it will keep the last PFAnalysis_SingleGammaPt.root and FakePlots.root). Note: it will not create the cfi files used as sources, you must do this by hand.. Once you have FakePlots.root filled you can run makePlots.C in root and it will make some cleaned up better looking plots.

07-Mar-2011

Particle Flow Hadron Calibration

Preliminary Stuff

  • Setup area, check out necessary packages and compile
cmsrel CMSSW_3_11_2
cd CMSSW_3_11_2/src
cmsenv
cvs co -r V12-03-02-02 RecoParticleFlow/Configuration
cvs co -r V13-02-00-01 RecoParticleFlow/PFRootEvent
cvs co IOMC/ParticleGuns
cvs co Configuration/Generator #not really necessary just get this to keep my directory neat
scram b -j 4
  • Open a new file in emacs called template.py in the directory $CMSSW_BASE/Configuration/Generator/test/ and copy and paste this into it:

import FWCore.ParameterSet.Config as cms

process = cms.Process("PROD")

process.load("Configuration.StandardSequences.SimulationRandomNumberGeneratorSeeds_cff")

process.load("Configuration.StandardSequences.Services_cff")
process.load("Configuration.StandardSequences.GeometryDB_cff")
process.load("Configuration.StandardSequences.MagneticField_38T_cff")
process.load("FWCore.MessageService.MessageLogger_cfi")
process.load('IOMC.EventVertexGenerators.VtxSmearedRealistic7TeVCollision_cfi')
process.load("Configuration.StandardSequences.Generator_cff")
process.load("Configuration.StandardSequences.SimIdeal_cff")
process.load("SimGeneral.MixingModule.mixNoPU_cfi")
process.load('Configuration.StandardSequences.Digi_cff')
process.load("Configuration.StandardSequences.SimL1Emulator_cff")
process.load("Configuration.StandardSequences.DigiToRaw_cff")
process.load("Configuration.StandardSequences.RawToDigi_cff")
process.load('Configuration.StandardSequences.L1Reco_cff')
process.load("Configuration.StandardSequences.Reconstruction_cff")
# Event output                                                                                                                
process.load("Configuration.EventContent.EventContent_cff")

process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
process.GlobalTag.globaltag = 'START311_V1A::All'
#from Configuration.PyReleaseValidation.autoCond import autoCond                                                              
#process.GlobalTag.globaltag = autoCond['mc']                                                                                 

process.maxEvents = cms.untracked.PSet(
    input = cms.untracked.int32(5000)
)
### RANDOM setting (change last digit(s) to make runs different !)                                                            
process.RandomNumberGeneratorService.generator.initialSeed = 12345XXXX

#--- Special: equi-populater log-ranges of momentum 1-10/10-100/100-1000

process.source = cms.Source("EmptySource")
process.generator = cms.EDProducer("ExpoRandomPGunProducer",
    PGunParameters = cms.PSet(
        # you can request more than 1 particle                                                                                
        PartID = cms.vint32(-211),
        MinEta = cms.double(-3.1),
        MaxEta = cms.double(3.1),
        MinPhi = cms.double(-3.14159265359),
	MaxPhi = cms.double(3.14159265359),
        MinP   = cms.double(1.),
	MaxP   = cms.double(2000.),
    ),
    firstRun = cms.untracked.uint32(1),
    AddAntiParticle = cms.bool(False)
)

process.output = cms.OutputModule("PoolOutputModule",
    outputCommands = process.FEVTSIMEventContent.outputCommands,
    fileName = cms.untracked.string('output.root'),
    dataset = cms.untracked.PSet(
    dataTier = cms.untracked.string('GEN-SIM-DIGI-RECO'),
    filterName = cms.untracked.string('')
    )
)


#--- Neither L1RECO, not HLT included ---------------------------------------                                                 
process.p0 = cms.Path(process.generator*process.pgen)
process.p1 = cms.Path(process.psim)
process.p2 = cms.Path(process.pdigi)
process.p3 = cms.Path(process.SimL1Emulator)
process.p4 = cms.Path(process.DigiToRaw)
process.p5 = cms.Path(process.RawToDigi)
###process.L1Reco_step = cms.Path(process.L1Reco)                                                                             
process.p6 = cms.Path(process.reconstruction)
process.outpath = cms.EndPath(process.output)

#-- Regular schedule definition (replaced)                                                                                    
# process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.digitisation_step,process.L1simulation_step,process.digi2raw_step)                                                                 
# process.schedule.extend(process.HLTSchedule)                                                                                
# process.schedule.extend([process.raw2digi_step,process.L1Reco_step,process.reconstruction_step,process.endjob_step,process.FEVTSIMoutput_step])                                                                                                          


#-- Re-defined short schedule                                                                                                 
process.schedule = cms.Schedule(process.p0,process.p1,process.p2,process.p3,process.p4,process.p5,process.p6,process.outpath)
  • Open up a new file in emacs called ExpoRandomPGunProducer.cc in the directory $CMSSW_BASE/IOMC/ParticleGuns/src/ and paste this into it.
/*                                                                                                                            
 *  $Date: 2011/03/07 15:56:01 $                                                                                              
 *  $Revision: 1.24 $                                                                                                          
 *  \author Jean-Roch Vlimant                                                                                                 
 *  modified by S.Abdullin 04/02/2011                                                                                         
 */

#include 

#include "IOMC/ParticleGuns/interface/ExpoRandomPGunProducer.h"

#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

// #include "FWCore/Utilities/interface/Exception.h"                                                                          

// #include "CLHEP/Random/RandExpo.h"                                                                                         

using namespace edm;
using namespace std;

ExpoRandomPGunProducer::ExpoRandomPGunProducer(const ParameterSet& pset) :
   BaseFlatGunProducer(pset)
{


   ParameterSet defpset ;
   ParameterSet pgun_params =
      pset.getParameter("PGunParameters") ;

   fMinP = pgun_params.getParameter("MinP");
   fMaxP = pgun_params.getParameter("MaxP");

   produces();
   produces();

   //the explonential generator                                                                                               
   //   fRandomExpoGenerator = new CLHEP::RandExponential(fRandomEngine,fMeanP);                                              

}

ExpoRandomPGunProducer::~ExpoRandomPGunProducer()
{
   // no need to cleanup GenEvent memory - done in HepMCProduct                                                               
}

void ExpoRandomPGunProducer::produce(Event &e, const EventSetup& es)
{

   if ( fVerbosity > 0 )
   {
     std::cout << " ExpoRandomPGunProducer : Begin New Event Generation"
               << std::endl ;
   }
   // event loop (well, another step in it...)                                                                                

   // no need to clean up GenEvent memory - done in HepMCProduct                                                              
   //                                                                                                                         

   // here re-create fEvt (memory)                                                                                            
   //                                                                                                                         
   fEvt = new HepMC::GenEvent() ;

   // now actualy, cook up the event from PDGTable and gun parameters                                                         
   //                                                                                                                         
   // 1st, primary vertex                                                                                                     
   //                                                                                                                         
   //HepMC::GenVertex* Vtx = new HepMC::GenVertex(CLHEP::HepLorentzVector(0.,0.,0.));                                         
   HepMC::GenVertex* Vtx = new HepMC::GenVertex(HepMC::FourVector(0.,0.,0.));

   // loop over particles                                                                                                     
   //                                                                                                                         
   int barcode = 1 ;
   for (unsigned int ip=0; ipfire(fMinP, fMaxP);
     double y      = (1./fMinP) * fRandomGenerator->fire(0.0,1.0);
     double f      = 1./pmom;
     bool   accpt  = ( y < f);

     /*                                                                                                                       
         std::cout << std::endl                    
                 << "pmom " << pmom << "  f " << f << "   y " << y                                                          
                 << "   accept" << accpt << std::endl;                                                                      
     */

     //shoot until in the designated range                                                                                    
     while ((pmom < fMinP || pmom > fMaxP) || !accpt)
       {
         pmom   = fRandomGenerator->fire(fMinP, fMaxP);
         y      = (1./fMinP) * fRandomGenerator->fire(0.0,1.0);
         f      = 1./pmom;
         accpt  = (y < f);

         /*                                                                                                                   
         std::cout << "pmom " << pmom << "  f " << f << "   y " << y                                                          
                   << "   accept" << accpt << std::endl;                                                                      
         */

       }

     //     std::cout << "result = " <<  pmom << std::endl;                                                                   


       double eta    = fRandomGenerator->fire(fMinEta, fMaxEta) ;
       double phi    = fRandomGenerator->fire(fMinPhi, fMaxPhi) ;
       int PartID = fPartIDs[ip] ;
       const HepPDT::ParticleData*
          PData = fPDGTable->particle(HepPDT::ParticleID(abs(PartID))) ;
       double mass   = PData->mass().value() ;
       double theta  = 2.*atan(exp(-eta)) ;

       // p -> pt                                                                                                             
       double mom    = pmom;
       double pt     = mom * sin(theta);
       double px     = pt  * cos(phi) ;
       double py     = pt  * sin(phi) ;
       //                                                                                                                     
       double pz     = mom*cos(theta) ;
       double energy2= mom*mom + mass*mass ;
       double energy = sqrt(energy2) ;
       //CLHEP::Hep3Vector p(px,py,pz) ;                                                                                      
       //HepMC::GenParticle* Part =                                                                                           
       //    new HepMC::GenParticle(CLHEP::HepLorentzVector(p,energy),PartID,1);                                              
       HepMC::FourVector p(px,py,pz,energy) ;
       HepMC::GenParticle* Part =
           new HepMC::GenParticle(p,PartID,1);
       Part->suggest_barcode( barcode ) ;
       barcode++ ;
       Vtx->add_particle_out(Part);

       if ( fAddAntiParticle )
       {
          //CLHEP::Hep3Vector ap(-px,-py,-pz) ;                                                                               
          HepMC::FourVector ap(-px,-py,-pz,energy) ;
          int APartID = -PartID ;
          if ( PartID == 22 || PartID == 23 )
          {
             APartID = PartID ;
          }
          //HepMC::GenParticle* APart =                                                                                       
          //   new HepMC::GenParticle(CLHEP::HepLorentzVector(ap,energy),APartID,1);                                          
          HepMC::GenParticle* APart =
             new HepMC::GenParticle(ap,APartID,1);
          APart->suggest_barcode( barcode ) ;
          barcode++ ;
          Vtx->add_particle_out(APart) ;
       }

   }

   fEvt->add_vertex(Vtx) ;
   fEvt->set_event_number(e.id().event()) ;
   fEvt->set_signal_process_id(20) ;

   if ( fVerbosity > 0 )
   {
      fEvt->print() ;
   }

   auto_ptr BProduct(new HepMCProduct()) ;
   BProduct->addHepMCData( fEvt );
   e.put(BProduct);

   auto_ptr genEventInfo(new GenEventInfoProduct(fEvt));
   e.put(genEventInfo);

   if ( fVerbosity > 0 )
   {
      // for testing purpose only                                                                                             
      // fEvt->print() ; // prints empty info after it's made into edm::Event                                                 
     std::cout << " FlatRandomPGunProducer : Event Generation Done " << std::endl;
   }
}


  • Open a new file in emacs named ExpoRandomPGunProducer.h in directory $CMSSW_BASE/IOMC/ParticleGuns/interface/ and copy and paste this into it.
ifndef ExpoRandomPGunProducer_H
#define ExpoRandomPGunProducer_H

/** \class ExpoRandomPGunProducer                                                                                             
 *                                                                                                                            
 * Generates single particle gun in HepMC format                                                                              
 * Jean-Roch Vlimant                                                                                                          
 * modificed by S.Abdulin 04/02/2011                                                                                          
 ***************************************/

#include "IOMC/ParticleGuns/interface/BaseFlatGunProducer.h"
#include "CLHEP/Random/RandExponential.h"
namespace edm
{

  class ExpoRandomPGunProducer : public BaseFlatGunProducer
  {

  public:
    ExpoRandomPGunProducer(const ParameterSet & pset);
    virtual ~ExpoRandomPGunProducer();

  private:

    virtual void produce(Event & e, const EventSetup& es);

  protected :

    // data members                                                                                                           

    double            fMinP   ;
    double            fMaxP   ;
    double            fMeanP ;
    CLHEP::RandExponential * fRandomExpoGenerator;

  };
}

#endif

  • Now just add this line to the file $CMSSW_BASE/IOMC/ParticleGuns/src/SealModule.cc:
#include "IOMC/ParticleGuns/interface/ExpoRandomPGunProducer.h"
  • Compile
cd $CMSSW_BASE
scram b -j 4

Create K0L, PiPlus, PiMinus datasets from scratch

  • cd to directory:
cd $CMSSW_BASE/Configuration/Generator/test/
  • Copy template.py to another file name that you wish to make datasets of (K0L, PiMinus, PiPlus). The default is PiMinus since if you look in the file the pdgId is set to -211.
  • Open up the copied file and make the necessary changes:
    • line 33:
      process.RandomNumberGeneratorService.generator.initialSeed = 12345XXXX 
      - change the XXXX to random 4-digit number.
    • line 40:
      PartID
      - change to the pdgId of the particle you want to generate.
    • line 55:
      fileName
      - change output.root to the file name of your choice.
  • Run the generator:
cmsRun yourFile_cfg.py

Create Root NTuple

  • cd to directory:
cd $CMSSW_BASE/RecoParticleFlow/Configuration/test 
  • You can either open up one of the pre-written cfgs (PiMinus_cfg.py, PiPlus_cfg.py, K0L_cfg.py) in order to change the source of what to run over (i.e. to the generated files you created above) or you can simply run as is:
cmsRun K0L_cfg.py # or substitute K0L by PiPlus or PiMinus
  • This will create output files that look like pfcalib_k0L.root ( pfcalib_piminus.root, pfcalib_piplus.root).
  • Copy the file over to $CMSSW_BASE/RecoParcticleFlow/PFRootEvent/test

Run calib Macro

  • cd to directory:
cd $CMSSW_BASE/RecoParticleFlow/PFRootEvent/test   
  • Open up Macros/calib.C in an editor and search for pfcalib. You should see several definitions of a TFile, with all but one commented out.
  • Uncomment the line with the name of the pfcalib root file you are going to run the macro over and comment the rest. Note: There are two places you will have to do this in calib.C
  • Open up root and run the macro:
root -l 
.x calib.C++
Edit | Attach | Watch | Print version | History: r24 < r23 < r22 < r21 < r20 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r24 - 2011-03-07 - ChristopherSilkworth
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback