Fork me on GitHub

Changes between Version 10 and Version 11 of WorkBook/TutorialBologna


Ignore:
Timestamp:
Jun 9, 2016, 8:41:53 AM (8 years ago)
Author:
Michele Selvaggi
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WorkBook/TutorialBologna

    v10 v11  
    310310}}}
    311311
    312 
     312=== Part IV - Write a new module ===
     313
     314In this section we are going to create a module called Timing. This module will take as input a collection of particles. It will produce an output collection of particles with a smeared time variable according to some user defined resolution. It will also store the initial and final time pre-smearing.
     315
     3160) Copy the template module to the new one:
     317{{{
     318cp modules/ExampleModule.h modules/Timing.h
     319cp modules/ExampleModule.cc modules/Timing.cc
     320}}}
     321In these two files replace all "ExampleModule" with "Timing".
     322
     3231) Add the Timing module in modules/ModulesLinkDef.h:
     324{{{
     325#include "modules/NewModule.h"
     326...
     327#pragma link C++ class NewModule+;
     328}}}
     329
     3302) In the main delphes dir, type:
     331{{{
     332./configure
     333make
     334}}}
     335
     336You have just added your first empty module in Delphes.
     337
     3383) Replace the existing "Process"  method in the newly created module. Understand this piece of code.
     339    Then edit the rest of the Timing class (both the .cc and .h), in order to comply with this method.
     340
     341{{{
     342void Timing::Process()
     343{
     344  Candidate *candidate, *mother, *particle;
     345  Double_t t0, tf, t0_smeared, tf_smeared;
     346  const Double_t c_light = 2.99792458E8;
     347
     348  fItInputArray->Reset();
     349  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     350  {
     351
     352    //access particle before delphes processing
     353    particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
     354
     355    //4-position before propagation
     356    const TLorentzVector &initialPosition = particle->Position;
     357    //4-position after propagation
     358    const TLorentzVector &finalPosition   = candidate->Position;
     359
     360    //initial and final time (in mm)
     361    t0 = initialPosition.T();
     362    tf = finalPosition.T();
     363
     364    // apply time smearing on time after propagation
     365    tf_smeared = gRandom->Gaus(tf, fTimeResolution*1.0E3*c_light);
     366
     367    // correct initial time
     368    t0_smeared = t0 + tf_smeared - tf;
     369
     370    //now store these new variables
     371    mother = candidate;
     372    candidate = static_cast<Candidate*>(candidate->Clone());
     373    candidate->AddCandidate(mother);
     374
     375    candidate->genT0 = t0;
     376    candidate->genTF = tf;
     377    candidate->T0 = t0_smeared;
     378    candidate->TF = tf_smeared;
     379    candidate->ErrorT = (tf_smeared - tf);
     380
     381    fOutputArray->Add(candidate);
     382
     383  }
     384}
     385}}}
     386
     3874)  Add the new variables T0, TF, genT0, genTF, ErrorT to the Candidate class.
     388    You will have to edit the files classes/DelphesClasses.h and classes/DelphesClasses.cc.
     389    The Candidate class is defined in classes/DelphesClasses.h. Other methods involving the
     390    Candidate class are defined in classes/DelphesClasses.cc:
     391
     392    - Candidate (constructor)
     393    - Copy
     394    - Clear
     395
     396If this step is performed properly, you should be able to compile by typing "make"
     397
     398 We are not done yet... The newly computed timing information is now properly stored and propagated
     399   inside Delphes. However, we have to decide which objects will display this new information.
     400
     401
     4025) Let's store this information in Tracks. Find this classes in
     403   classes/DelphesClasses.h and add the new variables. Compile.
     404
     4056)  Now we have to tell Delphes that we want these variables to appear in our final root tree.
     406    Store these variables in the Track objects in the ProcessTracks method
     407    in modules/TreeWriter.cc. Compile.
     408
     409
     4107)  Finally, call the Timing module in the delphes_card_CMS_PileUp in the detector and configure it.
     411
     412    Make two different runs with 20 and 100ps. Open the output trees a plots the new interesting
     413    variables.
     414
     415