312 | | |
| 312 | === Part IV - Write a new module === |
| 313 | |
| 314 | In 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 | |
| 316 | 0) Copy the template module to the new one: |
| 317 | {{{ |
| 318 | cp modules/ExampleModule.h modules/Timing.h |
| 319 | cp modules/ExampleModule.cc modules/Timing.cc |
| 320 | }}} |
| 321 | In these two files replace all "ExampleModule" with "Timing". |
| 322 | |
| 323 | 1) Add the Timing module in modules/ModulesLinkDef.h: |
| 324 | {{{ |
| 325 | #include "modules/NewModule.h" |
| 326 | ... |
| 327 | #pragma link C++ class NewModule+; |
| 328 | }}} |
| 329 | |
| 330 | 2) In the main delphes dir, type: |
| 331 | {{{ |
| 332 | ./configure |
| 333 | make |
| 334 | }}} |
| 335 | |
| 336 | You have just added your first empty module in Delphes. |
| 337 | |
| 338 | 3) 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 | {{{ |
| 342 | void 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 | |
| 387 | 4) 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 | |
| 396 | If 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 | |
| 402 | 5) Let's store this information in Tracks. Find this classes in |
| 403 | classes/DelphesClasses.h and add the new variables. Compile. |
| 404 | |
| 405 | 6) 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 | |
| 410 | 7) 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 | |